nterminal 1.2.99 → 1.3.2

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.
Files changed (28) hide show
  1. package/dist/client/assets/MarkdownPreview-CzA5ZyZ3.js +1 -0
  2. package/dist/client/assets/{TranscriptMarkdownBody-B_ctyQyz.js → TranscriptMarkdownBody-Cu7KK3bx.js} +1 -1
  3. package/dist/client/assets/{index-BSYsec0Y.js → index-CosXAR2f.js} +1 -1
  4. package/dist/client/assets/index-lQ2cyEWO.css +1 -0
  5. package/dist/client/assets/index-wiyTLXQg.js +56 -0
  6. package/dist/client/index.html +2 -2
  7. package/dist/server/accounts/accountService.d.ts +10 -0
  8. package/dist/server/accounts/accountService.js +106 -10
  9. package/dist/server/accounts/accountService.js.map +1 -1
  10. package/dist/server/agent/agentRoutes.js +5 -0
  11. package/dist/server/agent/agentRoutes.js.map +1 -1
  12. package/dist/server/routes/agentManagementRoutes.js +30 -0
  13. package/dist/server/routes/agentManagementRoutes.js.map +1 -1
  14. package/dist/server/system/processIdentity.d.ts +6 -0
  15. package/dist/server/system/processIdentity.js +30 -0
  16. package/dist/server/system/processIdentity.js.map +1 -0
  17. package/dist/server/system/projectNames.d.ts +25 -0
  18. package/dist/server/system/projectNames.js +48 -0
  19. package/dist/server/system/projectNames.js.map +1 -0
  20. package/dist/server/system/serverInfo.d.ts +3 -0
  21. package/dist/server/system/serverInfo.js +172 -0
  22. package/dist/server/system/serverInfo.js.map +1 -0
  23. package/dist/shared/protocol.d.ts +24 -0
  24. package/dist/shared/protocol.js.map +1 -1
  25. package/package.json +2 -1
  26. package/dist/client/assets/MarkdownPreview-mvGPeEQn.js +0 -1
  27. package/dist/client/assets/index-Bp9gsGcg.js +0 -56
  28. package/dist/client/assets/index-Cca8_nsS.css +0 -1
@@ -0,0 +1,56 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CzA5ZyZ3.js","assets/index-CosXAR2f.js","assets/TranscriptMarkdownBody-Cu7KK3bx.js"])))=>i.map(i=>d[i]);
2
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function V2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dg={exports:{}},hu={};var uw;function Y2(){if(uw)return hu;uw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:c}}return hu.Fragment=t,hu.jsx=n,hu.jsxs=n,hu}var dw;function X2(){return dw||(dw=1,dg.exports=Y2()),dg.exports}var d=X2(),hg={exports:{}},ot={};var hw;function G2(){if(hw)return ot;hw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function x(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,L={};function A(M,q,he){this.props=M,this.context=q,this.refs=L,this.updater=he||C}A.prototype.isReactComponent={},A.prototype.setState=function(M,q){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,q,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function W(){}W.prototype=A.prototype;function U(M,q,he){this.props=M,this.context=q,this.refs=L,this.updater=he||C}var F=U.prototype=new W;F.constructor=U,N(F,A.prototype),F.isPureReactComponent=!0;var K=Array.isArray;function oe(){}var P={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function Z(M,q,he){var J=he.ref;return{$$typeof:e,type:M,key:q,ref:J!==void 0?J:null,props:he}}function me(M,q){return Z(M.type,q,M.props)}function ee(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function Y(M){var q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(he){return q[he]})}var X=/\/+/g;function V(M,q){return typeof M=="object"&&M!==null&&M.key!=null?Y(""+M.key):q.toString(36)}function ne(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(oe,oe):(M.status="pending",M.then(function(q){M.status==="pending"&&(M.status="fulfilled",M.value=q)},function(q){M.status==="pending"&&(M.status="rejected",M.reason=q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function O(M,q,he,J,ye){var ve=typeof M;(ve==="undefined"||ve==="boolean")&&(M=null);var Le=!1;if(M===null)Le=!0;else switch(ve){case"bigint":case"string":case"number":Le=!0;break;case"object":switch(M.$$typeof){case e:case t:Le=!0;break;case _:return Le=M._init,O(Le(M._payload),q,he,J,ye)}}if(Le)return ye=ye(M),Le=J===""?"."+V(M,0):J,K(ye)?(he="",Le!=null&&(he=Le.replace(X,"$&/")+"/"),O(ye,q,he,"",function(He){return He})):ye!=null&&(ee(ye)&&(ye=me(ye,he+(ye.key==null||M&&M.key===ye.key?"":(""+ye.key).replace(X,"$&/")+"/")+Le)),q.push(ye)),1;Le=0;var Ne=J===""?".":J+":";if(K(M))for(var Fe=0;Fe<M.length;Fe++)J=M[Fe],ve=Ne+V(J,Fe),Le+=O(J,q,he,ve,ye);else if(Fe=x(M),typeof Fe=="function")for(M=Fe.call(M),Fe=0;!(J=M.next()).done;)J=J.value,ve=Ne+V(J,Fe++),Le+=O(J,q,he,ve,ye);else if(ve==="object"){if(typeof M.then=="function")return O(ne(M),q,he,J,ye);throw q=String(M),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return Le}function R(M,q,he){if(M==null)return M;var J=[],ye=0;return O(M,J,"","",function(ve){return q.call(he,ve,ye++)}),J}function I(M){if(M._status===-1){var q=M._result;q=q(),q.then(function(he){(M._status===0||M._status===-1)&&(M._status=1,M._result=he)},function(he){(M._status===0||M._status===-1)&&(M._status=2,M._result=he)}),M._status===-1&&(M._status=0,M._result=q)}if(M._status===1)return M._result.default;throw M._result}var de=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ge={map:R,forEach:function(M,q,he){R(M,function(){q.apply(this,arguments)},he)},count:function(M){var q=0;return R(M,function(){q++}),q},toArray:function(M){return R(M,function(q){return q})||[]},only:function(M){if(!ee(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return ot.Activity=b,ot.Children=ge,ot.Component=A,ot.Fragment=n,ot.Profiler=o,ot.PureComponent=U,ot.StrictMode=r,ot.Suspense=g,ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=P,ot.__COMPILER_RUNTIME={__proto__:null,c:function(M){return P.H.useMemoCache(M)}},ot.cache=function(M){return function(){return M.apply(null,arguments)}},ot.cacheSignal=function(){return null},ot.cloneElement=function(M,q,he){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var J=N({},M.props),ye=M.key;if(q!=null)for(ve in q.key!==void 0&&(ye=""+q.key),q)!te.call(q,ve)||ve==="key"||ve==="__self"||ve==="__source"||ve==="ref"&&q.ref===void 0||(J[ve]=q[ve]);var ve=arguments.length-2;if(ve===1)J.children=he;else if(1<ve){for(var Le=Array(ve),Ne=0;Ne<ve;Ne++)Le[Ne]=arguments[Ne+2];J.children=Le}return Z(M.type,ye,J)},ot.createContext=function(M){return M={$$typeof:u,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},ot.createElement=function(M,q,he){var J,ye={},ve=null;if(q!=null)for(J in q.key!==void 0&&(ve=""+q.key),q)te.call(q,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(ye[J]=q[J]);var Le=arguments.length-2;if(Le===1)ye.children=he;else if(1<Le){for(var Ne=Array(Le),Fe=0;Fe<Le;Fe++)Ne[Fe]=arguments[Fe+2];ye.children=Ne}if(M&&M.defaultProps)for(J in Le=M.defaultProps,Le)ye[J]===void 0&&(ye[J]=Le[J]);return Z(M,ve,ye)},ot.createRef=function(){return{current:null}},ot.forwardRef=function(M){return{$$typeof:f,render:M}},ot.isValidElement=ee,ot.lazy=function(M){return{$$typeof:_,_payload:{_status:-1,_result:M},_init:I}},ot.memo=function(M,q){return{$$typeof:m,type:M,compare:q===void 0?null:q}},ot.startTransition=function(M){var q=P.T,he={};P.T=he;try{var J=M(),ye=P.S;ye!==null&&ye(he,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(oe,de)}catch(ve){de(ve)}finally{q!==null&&he.types!==null&&(q.types=he.types),P.T=q}},ot.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},ot.use=function(M){return P.H.use(M)},ot.useActionState=function(M,q,he){return P.H.useActionState(M,q,he)},ot.useCallback=function(M,q){return P.H.useCallback(M,q)},ot.useContext=function(M){return P.H.useContext(M)},ot.useDebugValue=function(){},ot.useDeferredValue=function(M,q){return P.H.useDeferredValue(M,q)},ot.useEffect=function(M,q){return P.H.useEffect(M,q)},ot.useEffectEvent=function(M){return P.H.useEffectEvent(M)},ot.useId=function(){return P.H.useId()},ot.useImperativeHandle=function(M,q,he){return P.H.useImperativeHandle(M,q,he)},ot.useInsertionEffect=function(M,q){return P.H.useInsertionEffect(M,q)},ot.useLayoutEffect=function(M,q){return P.H.useLayoutEffect(M,q)},ot.useMemo=function(M,q){return P.H.useMemo(M,q)},ot.useOptimistic=function(M,q){return P.H.useOptimistic(M,q)},ot.useReducer=function(M,q,he){return P.H.useReducer(M,q,he)},ot.useRef=function(M){return P.H.useRef(M)},ot.useState=function(M){return P.H.useState(M)},ot.useSyncExternalStore=function(M,q,he){return P.H.useSyncExternalStore(M,q,he)},ot.useTransition=function(){return P.H.useTransition()},ot.version="19.2.6",ot}var fw;function ib(){return fw||(fw=1,hg.exports=G2()),hg.exports}var v=ib();const Ot=V2(v);var fg={exports:{}},fu={},pg={exports:{}},mg={};var pw;function Z2(){return pw||(pw=1,(function(e){function t(O,R){var I=O.length;O.push(R);e:for(;0<I;){var de=I-1>>>1,ge=O[de];if(0<o(ge,R))O[de]=R,O[I]=ge,I=de;else break e}}function n(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var R=O[0],I=O.pop();if(I!==R){O[0]=I;e:for(var de=0,ge=O.length,M=ge>>>1;de<M;){var q=2*(de+1)-1,he=O[q],J=q+1,ye=O[J];if(0>o(he,I))J<ge&&0>o(ye,he)?(O[de]=ye,O[J]=I,de=J):(O[de]=he,O[q]=I,de=q);else if(J<ge&&0>o(ye,I))O[de]=ye,O[J]=I,de=J;else break e}}return R}function o(O,R){var I=O.sortIndex-R.sortIndex;return I!==0?I:O.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var g=[],m=[],_=1,b=null,w=3,x=!1,C=!1,N=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,W=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function F(O){for(var R=n(m);R!==null;){if(R.callback===null)r(m);else if(R.startTime<=O)r(m),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(m)}}function K(O){if(N=!1,F(O),!C)if(n(g)!==null)C=!0,oe||(oe=!0,Y());else{var R=n(m);R!==null&&ne(K,R.startTime-O)}}var oe=!1,P=-1,te=5,Z=-1;function me(){return L?!0:!(e.unstable_now()-Z<te)}function ee(){if(L=!1,oe){var O=e.unstable_now();Z=O;var R=!0;try{e:{C=!1,N&&(N=!1,W(P),P=-1),x=!0;var I=w;try{t:{for(F(O),b=n(g);b!==null&&!(b.expirationTime>O&&me());){var de=b.callback;if(typeof de=="function"){b.callback=null,w=b.priorityLevel;var ge=de(b.expirationTime<=O);if(O=e.unstable_now(),typeof ge=="function"){b.callback=ge,F(O),R=!0;break t}b===n(g)&&r(g),F(O)}else r(g);b=n(g)}if(b!==null)R=!0;else{var M=n(m);M!==null&&ne(K,M.startTime-O),R=!1}}break e}finally{b=null,w=I,x=!1}R=void 0}}finally{R?Y():oe=!1}}}var Y;if(typeof U=="function")Y=function(){U(ee)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,V=X.port2;X.port1.onmessage=ee,Y=function(){V.postMessage(null)}}else Y=function(){A(ee,0)};function ne(O,R){P=A(function(){O(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):te=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(O){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var I=w;w=R;try{return O()}finally{w=I}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(O,R){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var I=w;w=O;try{return R()}finally{w=I}},e.unstable_scheduleCallback=function(O,R,I){var de=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?de+I:de):I=de,O){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=I+ge,O={id:_++,callback:R,priorityLevel:O,startTime:I,expirationTime:ge,sortIndex:-1},I>de?(O.sortIndex=I,t(m,O),n(g)===null&&O===n(m)&&(N?(W(P),P=-1):N=!0,ne(K,I-de))):(O.sortIndex=ge,t(g,O),C||x||(C=!0,oe||(oe=!0,Y()))),O},e.unstable_shouldYield=me,e.unstable_wrapCallback=function(O){var R=w;return function(){var I=w;w=R;try{return O.apply(this,arguments)}finally{w=I}}}})(mg)),mg}var mw;function Q2(){return mw||(mw=1,pg.exports=Z2()),pg.exports}var gg={exports:{}},bn={};var gw;function J2(){if(gw)return bn;gw=1;var e=ib();function t(g){var m="https://react.dev/errors/"+g;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+g+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,m,_){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:m,implementation:_}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,m){if(g==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return bn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,bn.createPortal=function(g,m){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(t(299));return c(g,m,null,_)},bn.flushSync=function(g){var m=u.T,_=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=m,r.p=_,r.d.f()}},bn.preconnect=function(g,m){typeof g=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(g,m))},bn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},bn.preinit=function(g,m){if(typeof g=="string"&&m&&typeof m.as=="string"){var _=m.as,b=f(_,m.crossOrigin),w=typeof m.integrity=="string"?m.integrity:void 0,x=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;_==="style"?r.d.S(g,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:x}):_==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:x,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},bn.preinitModule=function(g,m){if(typeof g=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var _=f(m.as,m.crossOrigin);r.d.M(g,{crossOrigin:_,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(g)},bn.preload=function(g,m){if(typeof g=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var _=m.as,b=f(_,m.crossOrigin);r.d.L(g,_,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},bn.preloadModule=function(g,m){if(typeof g=="string")if(m){var _=f(m.as,m.crossOrigin);r.d.m(g,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:_,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(g)},bn.requestFormReset=function(g){r.d.r(g)},bn.unstable_batchedUpdates=function(g,m){return g(m)},bn.useFormState=function(g,m,_){return u.H.useFormState(g,m,_)},bn.useFormStatus=function(){return u.H.useHostTransitionStatus()},bn.version="19.2.6",bn}var vw;function Kx(){if(vw)return gg.exports;vw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),gg.exports=J2(),gg.exports}var _w;function eD(){if(_w)return fu;_w=1;var e=Q2(),t=ib(),n=Kx();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function u(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function m(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,l=s;;){var h=a.return;if(h===null)break;var p=h.alternate;if(p===null){if(l=h.return,l!==null){a=l;continue}break}if(h.child===p.child){for(p=h.child;p;){if(p===a)return g(h),i;if(p===l)return g(h),s;p=p.sibling}throw Error(r(188))}if(a.return!==l.return)a=h,l=p;else{for(var y=!1,D=h.child;D;){if(D===a){y=!0,a=h,l=p;break}if(D===l){y=!0,l=h,a=p;break}D=D.sibling}if(!y){for(D=p.child;D;){if(D===a){y=!0,a=p,l=h;break}if(D===l){y=!0,l=p,a=h;break}D=D.sibling}if(!y)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function _(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=_(i),s!==null)return s;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),W=Symbol.for("react.consumer"),U=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),me=Symbol.for("react.memo_cache_sentinel"),ee=Symbol.iterator;function Y(i){return i===null||typeof i!="object"?null:(i=ee&&i[ee]||i["@@iterator"],typeof i=="function"?i:null)}var X=Symbol.for("react.client.reference");function V(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===X?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case N:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case K:return"Suspense";case oe:return"SuspenseList";case Z:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case C:return"Portal";case U:return i.displayName||"Context";case W:return(i._context.displayName||"Context")+".Consumer";case F:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case P:return s=i.displayName||null,s!==null?s:V(i.type)||"Memo";case te:s=i._payload,i=i._init;try{return V(i(s))}catch{}}return null}var ne=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},de=[],ge=-1;function M(i){return{current:i}}function q(i){0>ge||(i.current=de[ge],de[ge]=null,ge--)}function he(i,s){ge++,de[ge]=i.current,i.current=s}var J=M(null),ye=M(null),ve=M(null),Le=M(null);function Ne(i,s){switch(he(ve,s),he(ye,i),he(J,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?L0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=L0(s),i=O0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}q(J),he(J,i)}function Fe(){q(J),q(ye),q(ve)}function He(i){i.memoizedState!==null&&he(Le,i);var s=J.current,a=O0(s,i.type);s!==a&&(he(ye,i),he(J,a))}function Pe(i){ye.current===i&&(q(J),q(ye)),Le.current===i&&(q(Le),lu._currentValue=I)}var Ze,E;function z(i){if(Ze===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);Ze=s&&s[1]||"",E=-1<a.stack.indexOf(`
3
+ at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
+ `+Ze+i+E}var we=!1;function Ae(i,s){if(!i||we)return"";we=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var xe=function(){throw Error()};if(Object.defineProperty(xe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(xe,[])}catch(fe){var ue=fe}Reflect.construct(i,[],xe)}else{try{xe.call()}catch(fe){ue=fe}i.call(xe.prototype)}}else{try{throw Error()}catch(fe){ue=fe}(xe=i())&&typeof xe.catch=="function"&&xe.catch(function(){})}}catch(fe){if(fe&&ue&&typeof fe.stack=="string")return[fe.stack,ue.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=l.DetermineComponentFrameRoot(),y=p[0],D=p[1];if(y&&D){var j=y.split(`
5
+ `),re=D.split(`
6
+ `);for(h=l=0;l<j.length&&!j[l].includes("DetermineComponentFrameRoot");)l++;for(;h<re.length&&!re[h].includes("DetermineComponentFrameRoot");)h++;if(l===j.length||h===re.length)for(l=j.length-1,h=re.length-1;1<=l&&0<=h&&j[l]!==re[h];)h--;for(;1<=l&&0<=h;l--,h--)if(j[l]!==re[h]){if(l!==1||h!==1)do if(l--,h--,0>h||j[l]!==re[h]){var _e=`
7
+ `+j[l].replace(" at new "," at ");return i.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",i.displayName)),_e}while(1<=l&&0<=h);break}}}finally{we=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?z(a):""}function ie(i,s){switch(i.tag){case 26:case 27:case 5:return z(i.type);case 16:return z("Lazy");case 13:return i.child!==s&&s!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return Ae(i.type,!1);case 11:return Ae(i.type.render,!1);case 1:return Ae(i.type,!0);case 31:return z("Activity");default:return""}}function pe(i){try{var s="",a=null;do s+=ie(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
8
+ Error generating stack: `+l.message+`
9
+ `+l.stack}}var Te=Object.prototype.hasOwnProperty,De=e.unstable_scheduleCallback,Ee=e.unstable_cancelCallback,je=e.unstable_shouldYield,Ve=e.unstable_requestPaint,$e=e.unstable_now,St=e.unstable_getCurrentPriorityLevel,wt=e.unstable_ImmediatePriority,Nt=e.unstable_UserBlockingPriority,_t=e.unstable_NormalPriority,Pt=e.unstable_LowPriority,oi=e.unstable_IdlePriority,ke=e.log,Ge=e.unstable_setDisableYieldValue,st=null,et=null;function gt(i){if(typeof ke=="function"&&Ge(i),et&&typeof et.setStrictMode=="function")try{et.setStrictMode(st,i)}catch{}}var ct=Math.clz32?Math.clz32:le,mn=Math.log,li=Math.LN2;function le(i){return i>>>=0,i===0?32:31-(mn(i)/li|0)|0}var ze=256,ut=262144,at=4194304;function Bt(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Qt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var h=0,p=i.suspendedLanes,y=i.pingedLanes;i=i.warmLanes;var D=l&134217727;return D!==0?(l=D&~p,l!==0?h=Bt(l):(y&=D,y!==0?h=Bt(y):a||(a=D&~i,a!==0&&(h=Bt(a))))):(D=l&~p,D!==0?h=Bt(D):y!==0?h=Bt(y):a||(a=l&~i,a!==0&&(h=Bt(a)))),h===0?0:s!==0&&s!==h&&(s&p)===0&&(p=h&-h,a=s&-s,p>=a||p===32&&(a&4194048)!==0)?s:h}function Si(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function Ii(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ni(){var i=at;return at<<=1,(at&62914560)===0&&(at=4194304),i}function hi(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function lt(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function xt(i,s,a,l,h,p){var y=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var D=i.entanglements,j=i.expirationTimes,re=i.hiddenUpdates;for(a=y&~a;0<a;){var _e=31-ct(a),xe=1<<_e;D[_e]=0,j[_e]=-1;var ue=re[_e];if(ue!==null)for(re[_e]=null,_e=0;_e<ue.length;_e++){var fe=ue[_e];fe!==null&&(fe.lane&=-536870913)}a&=~xe}l!==0&&fi(i,l,0),p!==0&&h===0&&i.tag!==0&&(i.suspendedLanes|=p&~(y&~s))}function fi(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-ct(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function Jt(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-ct(a),h=1<<l;h&s|i[l]&s&&(i[l]|=s),a&=~h}}function Vi(i,s){var a=s&-s;return a=(a&42)!==0?1:gn(a),(a&(i.suspendedLanes|s))!==0?0:a}function gn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Yi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function pi(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:nw(i.type))}function an(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var Ni=Math.random().toString(36).slice(2),wi="__reactFiber$"+Ni,xi="__reactProps$"+Ni,is="__reactContainer$"+Ni,wn="__reactEvents$"+Ni,xs="__reactListeners$"+Ni,Cs="__reactHandles$"+Ni,ks="__reactResources$"+Ni,on="__reactMarker$"+Ni;function Xs(i){delete i[wi],delete i[xi],delete i[wn],delete i[xs],delete i[Cs]}function $n(i){var s=i[wi];if(s)return s;for(var a=i.parentNode;a;){if(s=a[is]||a[wi]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=U0(i);i!==null;){if(a=i[wi])return a;i=U0(i)}return s}i=a,a=i.parentNode}return null}function Ts(i){if(i=i[wi]||i[is]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function xn(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function Gs(i){var s=i[ks];return s||(s=i[ks]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Ht(i){i[on]=!0}var aa=new Set,br={};function Wt(i,s){Kn(i,s),Kn(i+"Capture",s)}function Kn(i,s){for(br[i]=s,i=0;i<s.length;i++)aa.add(s[i])}var ln=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),yr={},Sr={};function wr(i){return Te.call(Sr,i)?!0:Te.call(yr,i)?!1:ln.test(i)?Sr[i]=!0:(yr[i]=!0,!1)}function Zs(i,s,a){if(wr(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function xr(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function Cn(i,s,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+l)}}function Pi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Qs(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function oa(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var h=l.get,p=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,p.call(this,y)}}),Object.defineProperty(i,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function Es(i){if(!i._valueTracker){var s=Qs(i)?"checked":"value";i._valueTracker=oa(i,s,""+i[s])}}function Xi(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Qs(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function Ds(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var wc=/[\n"\\]/g;function zi(i){return i.replace(wc,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function la(i,s,a,l,h,p,y,D){i.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?i.type=y:i.removeAttribute("type"),s!=null?y==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Pi(s)):i.value!==""+Pi(s)&&(i.value=""+Pi(s)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),s!=null?po(i,y,Pi(s)):a!=null?po(i,y,Pi(a)):l!=null&&i.removeAttribute("value"),h==null&&p!=null&&(i.defaultChecked=!!p),h!=null&&(i.checked=h&&typeof h!="function"&&typeof h!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?i.name=""+Pi(D):i.removeAttribute("name")}function Cr(i,s,a,l,h,p,y,D){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(i.type=p),s!=null||a!=null){if(!(p!=="submit"&&p!=="reset"||s!=null)){Es(i);return}a=a!=null?""+Pi(a):"",s=s!=null?""+Pi(s):a,D||s===i.value||(i.value=s),i.defaultValue=s}l=l??h,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=D?i.checked:!!l,i.defaultChecked=!!l,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.name=y),Es(i)}function po(i,s,a){s==="number"&&Ds(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function kn(i,s,a,l){if(i=i.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<i.length;a++)h=s.hasOwnProperty("$"+i[a].value),i[a].selected!==h&&(i[a].selected=h),h&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Pi(a),s=null,h=0;h<i.length;h++){if(i[h].value===a){i[h].selected=!0,l&&(i[h].defaultSelected=!0);return}s!==null||i[h].disabled||(s=i[h])}s!==null&&(s.selected=!0)}}function mo(i,s,a){if(s!=null&&(s=""+Pi(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Pi(a):""}function ca(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(ne(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Pi(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),Es(i)}function Gi(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var cl=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Rs(i,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":l?i.setProperty(s,a):typeof a!="number"||a===0||cl.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function vn(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var h in s)l=s[h],s.hasOwnProperty(h)&&a[h]!==l&&Rs(i,h,l)}else for(var p in s)s.hasOwnProperty(p)&&Rs(i,p,s[p])}function Ns(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ul=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),dl=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ns(i){return dl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Ln(){}var Zi=null;function go(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ms=null,Ci=null;function kr(i){var s=Ts(i);if(s&&(i=s.stateNode)){var a=i[xi]||null;e:switch(i=s.stateNode,s.type){case"input":if(la(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+zi(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var h=l[xi]||null;if(!h)throw Error(r(90));la(l,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&Xi(l)}break e;case"textarea":mo(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&kn(i,!!a.multiple,s,!1)}}}var Tr=!1;function vo(i,s,a){if(Tr)return i(s,a);Tr=!0;try{var l=i(s);return l}finally{if(Tr=!1,(Ms!==null||Ci!==null)&&(ch(),Ms&&(s=Ms,i=Ci,Ci=Ms=null,kr(s),i)))for(s=0;s<i.length;s++)kr(i[s])}}function Wn(i,s){var a=i.stateNode;if(a===null)return null;var l=a[xi]||null;if(l===null)return null;a=l[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var ki=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ua=!1;if(ki)try{var As={};Object.defineProperty(As,"passive",{get:function(){ua=!0}}),window.addEventListener("test",As,As),window.removeEventListener("test",As,As)}catch{ua=!1}var On=null,_n=null,Ls=null;function rt(){if(Ls)return Ls;var i,s=_n,a=s.length,l,h="value"in On?On.value:On.textContent,p=h.length;for(i=0;i<a&&s[i]===h[i];i++);var y=a-i;for(l=1;l<=y&&s[a-l]===h[p-l];l++);return Ls=h.slice(i,1<l?1-l:void 0)}function Os(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function ss(){return!0}function Js(){return!1}function Hi(i){function s(a,l,h,p,y){this._reactName=a,this._targetInst=h,this.type=l,this.nativeEvent=p,this.target=y,this.currentTarget=null;for(var D in i)i.hasOwnProperty(D)&&(a=i[D],this[D]=a?a(p):p[D]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?ss:Js,this.isPropagationStopped=Js,this}return b(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ss)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ss)},persist:function(){},isPersistent:ss}),s}var rs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bs=Hi(rs),js=b({},rs,{view:0,detail:0}),xc=Hi(js),_o,bo,er,Er=b({},js,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:as,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==er&&(er&&i.type==="mousemove"?(_o=i.screenX-er.screenX,bo=i.screenY-er.screenY):bo=_o=0,er=i),_o)},movementY:function(i){return"movementY"in i?i.movementY:bo}}),hl=Hi(Er),Cc=b({},Er,{dataTransfer:0}),da=Hi(Cc),ha=b({},js,{relatedTarget:0}),Bn=Hi(ha),fa=b({},rs,{animationName:0,elapsedTime:0,pseudoElement:0}),Dr=Hi(fa),tr=b({},rs,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),yo=Hi(tr),Ui=b({},rs,{data:0}),pa=Hi(Ui),ma={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},So={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},wo={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fl(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=wo[i])?!!s[i]:!1}function as(){return fl}var Ti=b({},js,{key:function(i){if(i.key){var s=ma[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=Os(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?So[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:as,charCode:function(i){return i.type==="keypress"?Os(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Os(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),kc=Hi(Ti),pl=b({},Er,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jn=Hi(pl),ga=b({},js,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:as}),Tc=Hi(ga),ml=b({},rs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Is=Hi(ml),xo=b({},Er,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Ec=Hi(xo),S=b({},rs,{newState:0,oldState:0}),T=Hi(S),B=[9,13,27,32],G=ki&&"CompositionEvent"in window,ae=null;ki&&"documentMode"in document&&(ae=document.documentMode);var ce=ki&&"TextEvent"in window&&!ae,Se=ki&&(!G||ae&&8<ae&&11>=ae),Oe=" ",Ie=!1;function ht(i,s){switch(i){case"keyup":return B.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mt(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Tn=!1;function ci(i,s){switch(i){case"compositionend":return Mt(s);case"keypress":return s.which!==32?null:(Ie=!0,Oe);case"textInput":return i=s.data,i===Oe&&Ie?null:i;default:return null}}function Ps(i,s){if(Tn)return i==="compositionend"||!G&&ht(i,s)?(i=rt(),Ls=_n=On=null,Tn=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Se&&s.locale!=="ko"?null:s.data;default:return null}}var Dc={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Co(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!Dc[i.type]:s==="textarea"}function Rc(i,s,a,l){Ms?Ci?Ci.push(l):Ci=[l]:Ms=l,s=gh(s,"onChange"),0<s.length&&(a=new Bs("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var va=null,ko=null;function wd(i){E0(i,0)}function To(i){var s=xn(i);if(Xi(s))return i}function Nc(i,s){if(i==="change")return s}var xd=!1;if(ki){var gl;if(ki){var os="oninput"in document;if(!os){var Cd=document.createElement("div");Cd.setAttribute("oninput","return;"),os=typeof Cd.oninput=="function"}gl=os}else gl=!1;xd=gl&&(!document.documentMode||9<document.documentMode)}function kd(){va&&(va.detachEvent("onpropertychange",Mc),ko=va=null)}function Mc(i){if(i.propertyName==="value"&&To(ko)){var s=[];Rc(s,ko,i,go(i)),vo(wd,s)}}function bp(i,s,a){i==="focusin"?(kd(),va=s,ko=a,va.attachEvent("onpropertychange",Mc)):i==="focusout"&&kd()}function yp(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return To(ko)}function Rr(i,s){if(i==="click")return To(s)}function Sp(i,s){if(i==="input"||i==="change")return To(s)}function wp(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var En=typeof Object.is=="function"?Object.is:wp;function _a(i,s){if(En(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var h=a[l];if(!Te.call(s,h)||!En(i[h],s[h]))return!1}return!0}function zs(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Td(i,s){var a=zs(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=zs(a)}}function Ed(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?Ed(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function Dd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=Ds(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=Ds(i.document)}return s}function Eo(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var xp=ki&&"documentMode"in document&&11>=document.documentMode,Nr=null,k=null,H=null,Me=!1;function Ye(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Me||Nr==null||Nr!==Ds(l)||(l=Nr,"selectionStart"in l&&Eo(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),H&&_a(H,l)||(H=l,l=gh(k,"onSelect"),0<l.length&&(s=new Bs("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=Nr)))}function We(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var it={animationend:We("Animation","AnimationEnd"),animationiteration:We("Animation","AnimationIteration"),animationstart:We("Animation","AnimationStart"),transitionrun:We("Transition","TransitionRun"),transitionstart:We("Transition","TransitionStart"),transitioncancel:We("Transition","TransitionCancel"),transitionend:We("Transition","TransitionEnd")},ft={},vt={};ki&&(vt=document.createElement("div").style,"AnimationEvent"in window||(delete it.animationend.animation,delete it.animationiteration.animation,delete it.animationstart.animation),"TransitionEvent"in window||delete it.transitionend.transition);function Xe(i){if(ft[i])return ft[i];if(!it[i])return i;var s=it[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in vt)return ft[i]=s[a];return i}var Gt=Xe("animationend"),Ut=Xe("animationiteration"),zt=Xe("animationstart"),ir=Xe("transitionrun"),vl=Xe("transitionstart"),nr=Xe("transitioncancel"),Ac=Xe("transitionend"),Lc=new Map,Cp="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Cp.push("scrollEnd");function Hs(i,s){Lc.set(i,s),Wt(s,[i])}var Rd=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},ls=[],_l=0,kp=0;function Nd(){for(var i=_l,s=kp=_l=0;s<i;){var a=ls[s];ls[s++]=null;var l=ls[s];ls[s++]=null;var h=ls[s];ls[s++]=null;var p=ls[s];if(ls[s++]=null,l!==null&&h!==null){var y=l.pending;y===null?h.next=h:(h.next=y.next,y.next=h),l.pending=h}p!==0&&ly(a,h,p)}}function Md(i,s,a,l){ls[_l++]=i,ls[_l++]=s,ls[_l++]=a,ls[_l++]=l,kp|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Tp(i,s,a,l){return Md(i,s,a,l),Ad(i)}function Do(i,s){return Md(i,null,null,s),Ad(i)}function ly(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var h=!1,p=i.return;p!==null;)p.childLanes|=a,l=p.alternate,l!==null&&(l.childLanes|=a),p.tag===22&&(i=p.stateNode,i===null||i._visibility&1||(h=!0)),i=p,p=p.return;return i.tag===3?(p=i.stateNode,h&&s!==null&&(h=31-ct(a),i=p.hiddenUpdates,l=i[h],l===null?i[h]=[s]:l.push(s),s.lane=a|536870912),p):null}function Ad(i){if(50<tu)throw tu=0,Bm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var bl={};function NE(i,s,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qn(i,s,a,l){return new NE(i,s,a,l)}function Ep(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Mr(i,s){var a=i.alternate;return a===null?(a=qn(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function cy(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function Ld(i,s,a,l,h,p){var y=0;if(l=i,typeof i=="function")Ep(i)&&(y=1);else if(typeof i=="string")y=B2(i,a,J.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case Z:return i=qn(31,a,s,h),i.elementType=Z,i.lanes=p,i;case N:return Ro(a.children,h,p,s);case L:y=8,h|=24;break;case A:return i=qn(12,a,s,h|2),i.elementType=A,i.lanes=p,i;case K:return i=qn(13,a,s,h),i.elementType=K,i.lanes=p,i;case oe:return i=qn(19,a,s,h),i.elementType=oe,i.lanes=p,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case U:y=10;break e;case W:y=9;break e;case F:y=11;break e;case P:y=14;break e;case te:y=16,l=null;break e}y=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return s=qn(y,a,s,h),s.elementType=i,s.type=l,s.lanes=p,s}function Ro(i,s,a,l){return i=qn(7,i,l,s),i.lanes=a,i}function Dp(i,s,a){return i=qn(6,i,null,s),i.lanes=a,i}function uy(i){var s=qn(18,null,null,0);return s.stateNode=i,s}function Rp(i,s,a){return s=qn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var dy=new WeakMap;function cs(i,s){if(typeof i=="object"&&i!==null){var a=dy.get(i);return a!==void 0?a:(s={value:i,source:s,stack:pe(s)},dy.set(i,s),s)}return{value:i,source:s,stack:pe(s)}}var yl=[],Sl=0,Od=null,Oc=0,us=[],ds=0,ba=null,sr=1,rr="";function Ar(i,s){yl[Sl++]=Oc,yl[Sl++]=Od,Od=i,Oc=s}function hy(i,s,a){us[ds++]=sr,us[ds++]=rr,us[ds++]=ba,ba=i;var l=sr;i=rr;var h=32-ct(l)-1;l&=~(1<<h),a+=1;var p=32-ct(s)+h;if(30<p){var y=h-h%5;p=(l&(1<<y)-1).toString(32),l>>=y,h-=y,sr=1<<32-ct(s)+h|a<<h|l,rr=p+i}else sr=1<<p|a<<h|l,rr=i}function Np(i){i.return!==null&&(Ar(i,1),hy(i,1,0))}function Mp(i){for(;i===Od;)Od=yl[--Sl],yl[Sl]=null,Oc=yl[--Sl],yl[Sl]=null;for(;i===ba;)ba=us[--ds],us[ds]=null,rr=us[--ds],us[ds]=null,sr=us[--ds],us[ds]=null}function fy(i,s){us[ds++]=sr,us[ds++]=rr,us[ds++]=ba,sr=s.id,rr=s.overflow,ba=i}var cn=null,ei=null,Rt=!1,ya=null,hs=!1,Ap=Error(r(519));function Sa(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Bc(cs(s,i)),Ap}function py(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[wi]=i,s[xi]=l,a){case"dialog":Tt("cancel",s),Tt("close",s);break;case"iframe":case"object":case"embed":Tt("load",s);break;case"video":case"audio":for(a=0;a<nu.length;a++)Tt(nu[a],s);break;case"source":Tt("error",s);break;case"img":case"image":case"link":Tt("error",s),Tt("load",s);break;case"details":Tt("toggle",s);break;case"input":Tt("invalid",s),Cr(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Tt("invalid",s);break;case"textarea":Tt("invalid",s),ca(s,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||l.suppressHydrationWarning===!0||M0(s.textContent,a)?(l.popover!=null&&(Tt("beforetoggle",s),Tt("toggle",s)),l.onScroll!=null&&Tt("scroll",s),l.onScrollEnd!=null&&Tt("scrollend",s),l.onClick!=null&&(s.onclick=Ln),s=!0):s=!1,s||Sa(i,!0)}function my(i){for(cn=i.return;cn;)switch(cn.tag){case 5:case 31:case 13:hs=!1;return;case 27:case 3:hs=!0;return;default:cn=cn.return}}function wl(i){if(i!==cn)return!1;if(!Rt)return my(i),Rt=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Gm(i.type,i.memoizedProps)),a=!a),a&&ei&&Sa(i),my(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ei=H0(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ei=H0(i)}else s===27?(s=ei,Ba(i.type)?(i=tg,tg=null,ei=i):ei=s):ei=cn?ps(i.stateNode.nextSibling):null;return!0}function No(){ei=cn=null,Rt=!1}function Lp(){var i=ya;return i!==null&&(Hn===null?Hn=i:Hn.push.apply(Hn,i),ya=null),i}function Bc(i){ya===null?ya=[i]:ya.push(i)}var Op=M(null),Mo=null,Lr=null;function wa(i,s,a){he(Op,s._currentValue),s._currentValue=a}function Or(i){i._currentValue=Op.current,q(Op)}function Bp(i,s,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),i===a)break;i=i.return}}function jp(i,s,a,l){var h=i.child;for(h!==null&&(h.return=i);h!==null;){var p=h.dependencies;if(p!==null){var y=h.child;p=p.firstContext;e:for(;p!==null;){var D=p;p=h;for(var j=0;j<s.length;j++)if(D.context===s[j]){p.lanes|=a,D=p.alternate,D!==null&&(D.lanes|=a),Bp(p.return,a,i),l||(y=null);break e}p=D.next}}else if(h.tag===18){if(y=h.return,y===null)throw Error(r(341));y.lanes|=a,p=y.alternate,p!==null&&(p.lanes|=a),Bp(y,a,i),y=null}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===i){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}}function xl(i,s,a,l){i=null;for(var h=s,p=!1;h!==null;){if(!p){if((h.flags&524288)!==0)p=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var y=h.alternate;if(y===null)throw Error(r(387));if(y=y.memoizedProps,y!==null){var D=h.type;En(h.pendingProps.value,y.value)||(i!==null?i.push(D):i=[D])}}else if(h===Le.current){if(y=h.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(i!==null?i.push(lu):i=[lu])}h=h.return}i!==null&&jp(s,i,a,l),s.flags|=262144}function Bd(i){for(i=i.firstContext;i!==null;){if(!En(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ao(i){Mo=i,Lr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function un(i){return gy(Mo,i)}function jd(i,s){return Mo===null&&Ao(i),gy(i,s)}function gy(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},Lr===null){if(i===null)throw Error(r(308));Lr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else Lr=Lr.next=s;return a}var ME=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},AE=e.unstable_scheduleCallback,LE=e.unstable_NormalPriority,Mi={$$typeof:U,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ip(){return{controller:new ME,data:new Map,refCount:0}}function jc(i){i.refCount--,i.refCount===0&&AE(LE,function(){i.controller.abort()})}var Ic=null,Pp=0,Cl=0,kl=null;function OE(i,s){if(Ic===null){var a=Ic=[];Pp=0,Cl=Um(),kl={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Pp++,s.then(vy,vy),s}function vy(){if(--Pp===0&&Ic!==null){kl!==null&&(kl.status="fulfilled");var i=Ic;Ic=null,Cl=0,kl=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function BE(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(h){a.push(h)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var h=0;h<a.length;h++)(0,a[h])(s)},function(h){for(l.status="rejected",l.reason=h,h=0;h<a.length;h++)(0,a[h])(void 0)}),l}var _y=O.S;O.S=function(i,s){t0=$e(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&OE(i,s),_y!==null&&_y(i,s)};var Lo=M(null);function zp(){var i=Lo.current;return i!==null?i:Zt.pooledCache}function Id(i,s){s===null?he(Lo,Lo.current):he(Lo,s.pool)}function by(){var i=zp();return i===null?null:{parent:Mi._currentValue,pool:i}}var Tl=Error(r(460)),Hp=Error(r(474)),Pd=Error(r(542)),zd={then:function(){}};function yy(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Sy(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Ln,Ln),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,xy(i),i;default:if(typeof s.status=="string")s.then(Ln,Ln);else{if(i=Zt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var h=s;h.status="fulfilled",h.value=l}},function(l){if(s.status==="pending"){var h=s;h.status="rejected",h.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,xy(i),i}throw Bo=s,Tl}}function Oo(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Bo=a,Tl):a}}var Bo=null;function wy(){if(Bo===null)throw Error(r(459));var i=Bo;return Bo=null,i}function xy(i){if(i===Tl||i===Pd)throw Error(r(483))}var El=null,Pc=0;function Hd(i){var s=Pc;return Pc+=1,El===null&&(El=[]),Sy(El,i,s)}function zc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function Ud(i,s){throw s.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function Cy(i){function s(Q,$){if(i){var se=Q.deletions;se===null?(Q.deletions=[$],Q.flags|=16):se.push($)}}function a(Q,$){if(!i)return null;for(;$!==null;)s(Q,$),$=$.sibling;return null}function l(Q){for(var $=new Map;Q!==null;)Q.key!==null?$.set(Q.key,Q):$.set(Q.index,Q),Q=Q.sibling;return $}function h(Q,$){return Q=Mr(Q,$),Q.index=0,Q.sibling=null,Q}function p(Q,$,se){return Q.index=se,i?(se=Q.alternate,se!==null?(se=se.index,se<$?(Q.flags|=67108866,$):se):(Q.flags|=67108866,$)):(Q.flags|=1048576,$)}function y(Q){return i&&Q.alternate===null&&(Q.flags|=67108866),Q}function D(Q,$,se,be){return $===null||$.tag!==6?($=Dp(se,Q.mode,be),$.return=Q,$):($=h($,se),$.return=Q,$)}function j(Q,$,se,be){var Qe=se.type;return Qe===N?_e(Q,$,se.props.children,be,se.key):$!==null&&($.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===te&&Oo(Qe)===$.type)?($=h($,se.props),zc($,se),$.return=Q,$):($=Ld(se.type,se.key,se.props,null,Q.mode,be),zc($,se),$.return=Q,$)}function re(Q,$,se,be){return $===null||$.tag!==4||$.stateNode.containerInfo!==se.containerInfo||$.stateNode.implementation!==se.implementation?($=Rp(se,Q.mode,be),$.return=Q,$):($=h($,se.children||[]),$.return=Q,$)}function _e(Q,$,se,be,Qe){return $===null||$.tag!==7?($=Ro(se,Q.mode,be,Qe),$.return=Q,$):($=h($,se),$.return=Q,$)}function xe(Q,$,se){if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $=Dp(""+$,Q.mode,se),$.return=Q,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case x:return se=Ld($.type,$.key,$.props,null,Q.mode,se),zc(se,$),se.return=Q,se;case C:return $=Rp($,Q.mode,se),$.return=Q,$;case te:return $=Oo($),xe(Q,$,se)}if(ne($)||Y($))return $=Ro($,Q.mode,se,null),$.return=Q,$;if(typeof $.then=="function")return xe(Q,Hd($),se);if($.$$typeof===U)return xe(Q,jd(Q,$),se);Ud(Q,$)}return null}function ue(Q,$,se,be){var Qe=$!==null?$.key:null;if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return Qe!==null?null:D(Q,$,""+se,be);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case x:return se.key===Qe?j(Q,$,se,be):null;case C:return se.key===Qe?re(Q,$,se,be):null;case te:return se=Oo(se),ue(Q,$,se,be)}if(ne(se)||Y(se))return Qe!==null?null:_e(Q,$,se,be,null);if(typeof se.then=="function")return ue(Q,$,Hd(se),be);if(se.$$typeof===U)return ue(Q,$,jd(Q,se),be);Ud(Q,se)}return null}function fe(Q,$,se,be,Qe){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return Q=Q.get(se)||null,D($,Q,""+be,Qe);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case x:return Q=Q.get(be.key===null?se:be.key)||null,j($,Q,be,Qe);case C:return Q=Q.get(be.key===null?se:be.key)||null,re($,Q,be,Qe);case te:return be=Oo(be),fe(Q,$,se,be,Qe)}if(ne(be)||Y(be))return Q=Q.get(se)||null,_e($,Q,be,Qe,null);if(typeof be.then=="function")return fe(Q,$,se,Hd(be),Qe);if(be.$$typeof===U)return fe(Q,$,se,jd($,be),Qe);Ud($,be)}return null}function Ke(Q,$,se,be){for(var Qe=null,At=null,qe=$,pt=$=0,Dt=null;qe!==null&&pt<se.length;pt++){qe.index>pt?(Dt=qe,qe=null):Dt=qe.sibling;var Lt=ue(Q,qe,se[pt],be);if(Lt===null){qe===null&&(qe=Dt);break}i&&qe&&Lt.alternate===null&&s(Q,qe),$=p(Lt,$,pt),At===null?Qe=Lt:At.sibling=Lt,At=Lt,qe=Dt}if(pt===se.length)return a(Q,qe),Rt&&Ar(Q,pt),Qe;if(qe===null){for(;pt<se.length;pt++)qe=xe(Q,se[pt],be),qe!==null&&($=p(qe,$,pt),At===null?Qe=qe:At.sibling=qe,At=qe);return Rt&&Ar(Q,pt),Qe}for(qe=l(qe);pt<se.length;pt++)Dt=fe(qe,Q,pt,se[pt],be),Dt!==null&&(i&&Dt.alternate!==null&&qe.delete(Dt.key===null?pt:Dt.key),$=p(Dt,$,pt),At===null?Qe=Dt:At.sibling=Dt,At=Dt);return i&&qe.forEach(function(Ha){return s(Q,Ha)}),Rt&&Ar(Q,pt),Qe}function tt(Q,$,se,be){if(se==null)throw Error(r(151));for(var Qe=null,At=null,qe=$,pt=$=0,Dt=null,Lt=se.next();qe!==null&&!Lt.done;pt++,Lt=se.next()){qe.index>pt?(Dt=qe,qe=null):Dt=qe.sibling;var Ha=ue(Q,qe,Lt.value,be);if(Ha===null){qe===null&&(qe=Dt);break}i&&qe&&Ha.alternate===null&&s(Q,qe),$=p(Ha,$,pt),At===null?Qe=Ha:At.sibling=Ha,At=Ha,qe=Dt}if(Lt.done)return a(Q,qe),Rt&&Ar(Q,pt),Qe;if(qe===null){for(;!Lt.done;pt++,Lt=se.next())Lt=xe(Q,Lt.value,be),Lt!==null&&($=p(Lt,$,pt),At===null?Qe=Lt:At.sibling=Lt,At=Lt);return Rt&&Ar(Q,pt),Qe}for(qe=l(qe);!Lt.done;pt++,Lt=se.next())Lt=fe(qe,Q,pt,Lt.value,be),Lt!==null&&(i&&Lt.alternate!==null&&qe.delete(Lt.key===null?pt:Lt.key),$=p(Lt,$,pt),At===null?Qe=Lt:At.sibling=Lt,At=Lt);return i&&qe.forEach(function(q2){return s(Q,q2)}),Rt&&Ar(Q,pt),Qe}function Yt(Q,$,se,be){if(typeof se=="object"&&se!==null&&se.type===N&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case x:e:{for(var Qe=se.key;$!==null;){if($.key===Qe){if(Qe=se.type,Qe===N){if($.tag===7){a(Q,$.sibling),be=h($,se.props.children),be.return=Q,Q=be;break e}}else if($.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===te&&Oo(Qe)===$.type){a(Q,$.sibling),be=h($,se.props),zc(be,se),be.return=Q,Q=be;break e}a(Q,$);break}else s(Q,$);$=$.sibling}se.type===N?(be=Ro(se.props.children,Q.mode,be,se.key),be.return=Q,Q=be):(be=Ld(se.type,se.key,se.props,null,Q.mode,be),zc(be,se),be.return=Q,Q=be)}return y(Q);case C:e:{for(Qe=se.key;$!==null;){if($.key===Qe)if($.tag===4&&$.stateNode.containerInfo===se.containerInfo&&$.stateNode.implementation===se.implementation){a(Q,$.sibling),be=h($,se.children||[]),be.return=Q,Q=be;break e}else{a(Q,$);break}else s(Q,$);$=$.sibling}be=Rp(se,Q.mode,be),be.return=Q,Q=be}return y(Q);case te:return se=Oo(se),Yt(Q,$,se,be)}if(ne(se))return Ke(Q,$,se,be);if(Y(se)){if(Qe=Y(se),typeof Qe!="function")throw Error(r(150));return se=Qe.call(se),tt(Q,$,se,be)}if(typeof se.then=="function")return Yt(Q,$,Hd(se),be);if(se.$$typeof===U)return Yt(Q,$,jd(Q,se),be);Ud(Q,se)}return typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint"?(se=""+se,$!==null&&$.tag===6?(a(Q,$.sibling),be=h($,se),be.return=Q,Q=be):(a(Q,$),be=Dp(se,Q.mode,be),be.return=Q,Q=be),y(Q)):a(Q,$)}return function(Q,$,se,be){try{Pc=0;var Qe=Yt(Q,$,se,be);return El=null,Qe}catch(qe){if(qe===Tl||qe===Pd)throw qe;var At=qn(29,qe,null,Q.mode);return At.lanes=be,At.return=Q,At}}}var jo=Cy(!0),ky=Cy(!1),xa=!1;function Up(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fp(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Ca(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ka(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(jt&2)!==0){var h=l.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),l.pending=s,s=Ad(i),ly(i,null,a),s}return Md(i,l,s,a),Ad(i)}function Hc(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,Jt(i,a)}}function $p(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var h=null,p=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};p===null?h=p=y:p=p.next=y,a=a.next}while(a!==null);p===null?h=p=s:p=p.next=s}else h=p=s;a={baseState:l.baseState,firstBaseUpdate:h,lastBaseUpdate:p,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var Kp=!1;function Uc(){if(Kp){var i=kl;if(i!==null)throw i}}function Fc(i,s,a,l){Kp=!1;var h=i.updateQueue;xa=!1;var p=h.firstBaseUpdate,y=h.lastBaseUpdate,D=h.shared.pending;if(D!==null){h.shared.pending=null;var j=D,re=j.next;j.next=null,y===null?p=re:y.next=re,y=j;var _e=i.alternate;_e!==null&&(_e=_e.updateQueue,D=_e.lastBaseUpdate,D!==y&&(D===null?_e.firstBaseUpdate=re:D.next=re,_e.lastBaseUpdate=j))}if(p!==null){var xe=h.baseState;y=0,_e=re=j=null,D=p;do{var ue=D.lane&-536870913,fe=ue!==D.lane;if(fe?(Et&ue)===ue:(l&ue)===ue){ue!==0&&ue===Cl&&(Kp=!0),_e!==null&&(_e=_e.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Ke=i,tt=D;ue=s;var Yt=a;switch(tt.tag){case 1:if(Ke=tt.payload,typeof Ke=="function"){xe=Ke.call(Yt,xe,ue);break e}xe=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=tt.payload,ue=typeof Ke=="function"?Ke.call(Yt,xe,ue):Ke,ue==null)break e;xe=b({},xe,ue);break e;case 2:xa=!0}}ue=D.callback,ue!==null&&(i.flags|=64,fe&&(i.flags|=8192),fe=h.callbacks,fe===null?h.callbacks=[ue]:fe.push(ue))}else fe={lane:ue,tag:D.tag,payload:D.payload,callback:D.callback,next:null},_e===null?(re=_e=fe,j=xe):_e=_e.next=fe,y|=ue;if(D=D.next,D===null){if(D=h.shared.pending,D===null)break;fe=D,D=fe.next,fe.next=null,h.lastBaseUpdate=fe,h.shared.pending=null}}while(!0);_e===null&&(j=xe),h.baseState=j,h.firstBaseUpdate=re,h.lastBaseUpdate=_e,p===null&&(h.shared.lanes=0),Na|=y,i.lanes=y,i.memoizedState=xe}}function Ty(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function Ey(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Ty(a[i],s)}var Dl=M(null),Fd=M(0);function Dy(i,s){i=$r,he(Fd,i),he(Dl,s),$r=i|s.baseLanes}function Wp(){he(Fd,$r),he(Dl,Dl.current)}function qp(){$r=Fd.current,q(Dl),q(Fd)}var Vn=M(null),fs=null;function Ta(i){var s=i.alternate;he(Ei,Ei.current&1),he(Vn,i),fs===null&&(s===null||Dl.current!==null||s.memoizedState!==null)&&(fs=i)}function Vp(i){he(Ei,Ei.current),he(Vn,i),fs===null&&(fs=i)}function Ry(i){i.tag===22?(he(Ei,Ei.current),he(Vn,i),fs===null&&(fs=i)):Ea()}function Ea(){he(Ei,Ei.current),he(Vn,Vn.current)}function Yn(i){q(Vn),fs===i&&(fs=null),q(Ei)}var Ei=M(0);function $d(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Jm(a)||eg(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Br=0,dt=null,qt=null,Ai=null,Kd=!1,Rl=!1,Io=!1,Wd=0,$c=0,Nl=null,jE=0;function mi(){throw Error(r(321))}function Yp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!En(i[a],s[a]))return!1;return!0}function Xp(i,s,a,l,h,p){return Br=p,dt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,O.H=i===null||i.memoizedState===null?hS:um,Io=!1,p=a(l,h),Io=!1,Rl&&(p=My(s,a,l,h)),Ny(i),p}function Ny(i){O.H=qc;var s=qt!==null&&qt.next!==null;if(Br=0,Ai=qt=dt=null,Kd=!1,$c=0,Nl=null,s)throw Error(r(300));i===null||Li||(i=i.dependencies,i!==null&&Bd(i)&&(Li=!0))}function My(i,s,a,l){dt=i;var h=0;do{if(Rl&&(Nl=null),$c=0,Rl=!1,25<=h)throw Error(r(301));if(h+=1,Ai=qt=null,i.updateQueue!=null){var p=i.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}O.H=fS,p=s(a,l)}while(Rl);return p}function IE(){var i=O.H,s=i.useState()[0];return s=typeof s.then=="function"?Kc(s):s,i=i.useState()[0],(qt!==null?qt.memoizedState:null)!==i&&(dt.flags|=1024),s}function Gp(){var i=Wd!==0;return Wd=0,i}function Zp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Qp(i){if(Kd){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Kd=!1}Br=0,Ai=qt=dt=null,Rl=!1,$c=Wd=0,Nl=null}function Dn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ai===null?dt.memoizedState=Ai=i:Ai=Ai.next=i,Ai}function Di(){if(qt===null){var i=dt.alternate;i=i!==null?i.memoizedState:null}else i=qt.next;var s=Ai===null?dt.memoizedState:Ai.next;if(s!==null)Ai=s,qt=i;else{if(i===null)throw dt.alternate===null?Error(r(467)):Error(r(310));qt=i,i={memoizedState:qt.memoizedState,baseState:qt.baseState,baseQueue:qt.baseQueue,queue:qt.queue,next:null},Ai===null?dt.memoizedState=Ai=i:Ai=Ai.next=i}return Ai}function qd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Kc(i){var s=$c;return $c+=1,Nl===null&&(Nl=[]),i=Sy(Nl,i,s),s=dt,(Ai===null?s.memoizedState:Ai.next)===null&&(s=s.alternate,O.H=s===null||s.memoizedState===null?hS:um),i}function Vd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Kc(i);if(i.$$typeof===U)return un(i)}throw Error(r(438,String(i)))}function Jp(i){var s=null,a=dt.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=dt.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(h){return h.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=qd(),dt.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),l=0;l<i;l++)a[l]=me;return s.index++,a}function jr(i,s){return typeof s=="function"?s(i):s}function Yd(i){var s=Di();return em(s,qt,i)}function em(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var h=i.baseQueue,p=l.pending;if(p!==null){if(h!==null){var y=h.next;h.next=p.next,p.next=y}s.baseQueue=h=p,l.pending=null}if(p=i.baseState,h===null)i.memoizedState=p;else{s=h.next;var D=y=null,j=null,re=s,_e=!1;do{var xe=re.lane&-536870913;if(xe!==re.lane?(Et&xe)===xe:(Br&xe)===xe){var ue=re.revertLane;if(ue===0)j!==null&&(j=j.next={lane:0,revertLane:0,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),xe===Cl&&(_e=!0);else if((Br&ue)===ue){re=re.next,ue===Cl&&(_e=!0);continue}else xe={lane:0,revertLane:re.revertLane,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},j===null?(D=j=xe,y=p):j=j.next=xe,dt.lanes|=ue,Na|=ue;xe=re.action,Io&&a(p,xe),p=re.hasEagerState?re.eagerState:a(p,xe)}else ue={lane:xe,revertLane:re.revertLane,gesture:re.gesture,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},j===null?(D=j=ue,y=p):j=j.next=ue,dt.lanes|=xe,Na|=xe;re=re.next}while(re!==null&&re!==s);if(j===null?y=p:j.next=D,!En(p,i.memoizedState)&&(Li=!0,_e&&(a=kl,a!==null)))throw a;i.memoizedState=p,i.baseState=y,i.baseQueue=j,l.lastRenderedState=p}return h===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function tm(i){var s=Di(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,h=a.pending,p=s.memoizedState;if(h!==null){a.pending=null;var y=h=h.next;do p=i(p,y.action),y=y.next;while(y!==h);En(p,s.memoizedState)||(Li=!0),s.memoizedState=p,s.baseQueue===null&&(s.baseState=p),a.lastRenderedState=p}return[p,l]}function Ay(i,s,a){var l=dt,h=Di(),p=Rt;if(p){if(a===void 0)throw Error(r(407));a=a()}else a=s();var y=!En((qt||h).memoizedState,a);if(y&&(h.memoizedState=a,Li=!0),h=h.queue,sm(By.bind(null,l,h,i),[i]),h.getSnapshot!==s||y||Ai!==null&&Ai.memoizedState.tag&1){if(l.flags|=2048,Ml(9,{destroy:void 0},Oy.bind(null,l,h,a,s),null),Zt===null)throw Error(r(349));p||(Br&127)!==0||Ly(l,s,a)}return a}function Ly(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=dt.updateQueue,s===null?(s=qd(),dt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function Oy(i,s,a,l){s.value=a,s.getSnapshot=l,jy(s)&&Iy(i)}function By(i,s,a){return a(function(){jy(s)&&Iy(i)})}function jy(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!En(i,a)}catch{return!0}}function Iy(i){var s=Do(i,2);s!==null&&Un(s,i,2)}function im(i){var s=Dn();if(typeof i=="function"){var a=i;if(i=a(),Io){gt(!0);try{a()}finally{gt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:i},s}function Py(i,s,a,l){return i.baseState=a,em(i,qt,typeof l=="function"?l:jr)}function PE(i,s,a,l,h){if(Zd(i))throw Error(r(485));if(i=s.action,i!==null){var p={payload:h,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){p.listeners.push(y)}};O.T!==null?a(!0):p.isTransition=!1,l(p),a=s.pending,a===null?(p.next=s.pending=p,zy(s,p)):(p.next=a.next,s.pending=a.next=p)}}function zy(i,s){var a=s.action,l=s.payload,h=i.state;if(s.isTransition){var p=O.T,y={};O.T=y;try{var D=a(h,l),j=O.S;j!==null&&j(y,D),Hy(i,s,D)}catch(re){nm(i,s,re)}finally{p!==null&&y.types!==null&&(p.types=y.types),O.T=p}}else try{p=a(h,l),Hy(i,s,p)}catch(re){nm(i,s,re)}}function Hy(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Uy(i,s,l)},function(l){return nm(i,s,l)}):Uy(i,s,a)}function Uy(i,s,a){s.status="fulfilled",s.value=a,Fy(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,zy(i,a)))}function nm(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,Fy(s),s=s.next;while(s!==l)}i.action=null}function Fy(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function $y(i,s){return s}function Ky(i,s){if(Rt){var a=Zt.formState;if(a!==null){e:{var l=dt;if(Rt){if(ei){t:{for(var h=ei,p=hs;h.nodeType!==8;){if(!p){h=null;break t}if(h=ps(h.nextSibling),h===null){h=null;break t}}p=h.data,h=p==="F!"||p==="F"?h:null}if(h){ei=ps(h.nextSibling),l=h.data==="F!";break e}}Sa(l)}l=!1}l&&(s=a[0])}}return a=Dn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:$y,lastRenderedState:s},a.queue=l,a=cS.bind(null,dt,l),l.dispatch=a,l=im(!1),p=cm.bind(null,dt,!1,l.queue),l=Dn(),h={state:s,dispatch:null,action:i,pending:null},l.queue=h,a=PE.bind(null,dt,h,p,a),h.dispatch=a,l.memoizedState=i,[s,a,!1]}function Wy(i){var s=Di();return qy(s,qt,i)}function qy(i,s,a){if(s=em(i,s,$y)[0],i=Yd(jr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=Kc(s)}catch(y){throw y===Tl?Pd:y}else l=s;s=Di();var h=s.queue,p=h.dispatch;return a!==s.memoizedState&&(dt.flags|=2048,Ml(9,{destroy:void 0},zE.bind(null,h,a),null)),[l,p,i]}function zE(i,s){i.action=s}function Vy(i){var s=Di(),a=qt;if(a!==null)return qy(s,a,i);Di(),s=s.memoizedState,a=Di();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function Ml(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=dt.updateQueue,s===null&&(s=qd(),dt.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,s.lastEffect=i),i}function Yy(){return Di().memoizedState}function Xd(i,s,a,l){var h=Dn();dt.flags|=i,h.memoizedState=Ml(1|s,{destroy:void 0},a,l===void 0?null:l)}function Gd(i,s,a,l){var h=Di();l=l===void 0?null:l;var p=h.memoizedState.inst;qt!==null&&l!==null&&Yp(l,qt.memoizedState.deps)?h.memoizedState=Ml(s,p,a,l):(dt.flags|=i,h.memoizedState=Ml(1|s,p,a,l))}function Xy(i,s){Xd(8390656,8,i,s)}function sm(i,s){Gd(2048,8,i,s)}function HE(i){dt.flags|=4;var s=dt.updateQueue;if(s===null)s=qd(),dt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function Gy(i){var s=Di().memoizedState;return HE({ref:s,nextImpl:i}),function(){if((jt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Zy(i,s){return Gd(4,2,i,s)}function Qy(i,s){return Gd(4,4,i,s)}function Jy(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function eS(i,s,a){a=a!=null?a.concat([i]):null,Gd(4,4,Jy.bind(null,s,i),a)}function rm(){}function tS(i,s){var a=Di();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Yp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function iS(i,s){var a=Di();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Yp(s,l[1]))return l[0];if(l=i(),Io){gt(!0);try{i()}finally{gt(!1)}}return a.memoizedState=[l,s],l}function am(i,s,a){return a===void 0||(Br&1073741824)!==0&&(Et&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=n0(),dt.lanes|=i,Na|=i,a)}function nS(i,s,a,l){return En(a,s)?a:Dl.current!==null?(i=am(i,a,l),En(i,s)||(Li=!0),i):(Br&42)===0||(Br&1073741824)!==0&&(Et&261930)===0?(Li=!0,i.memoizedState=a):(i=n0(),dt.lanes|=i,Na|=i,s)}function sS(i,s,a,l,h){var p=R.p;R.p=p!==0&&8>p?p:8;var y=O.T,D={};O.T=D,cm(i,!1,s,a);try{var j=h(),re=O.S;if(re!==null&&re(D,j),j!==null&&typeof j=="object"&&typeof j.then=="function"){var _e=BE(j,l);Wc(i,s,_e,Zn(i))}else Wc(i,s,l,Zn(i))}catch(xe){Wc(i,s,{then:function(){},status:"rejected",reason:xe},Zn())}finally{R.p=p,y!==null&&D.types!==null&&(y.types=D.types),O.T=y}}function UE(){}function om(i,s,a,l){if(i.tag!==5)throw Error(r(476));var h=rS(i).queue;sS(i,h,s,I,a===null?UE:function(){return aS(i),a(l)})}function rS(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:I},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function aS(i){var s=rS(i);s.next===null&&(s=i.alternate.memoizedState),Wc(i,s.next.queue,{},Zn())}function lm(){return un(lu)}function oS(){return Di().memoizedState}function lS(){return Di().memoizedState}function FE(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Zn();i=Ca(a);var l=ka(s,i,a);l!==null&&(Un(l,s,a),Hc(l,s,a)),s={cache:Ip()},i.payload=s;return}s=s.return}}function $E(i,s,a){var l=Zn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Zd(i)?uS(s,a):(a=Tp(i,s,a,l),a!==null&&(Un(a,i,l),dS(a,s,l)))}function cS(i,s,a){var l=Zn();Wc(i,s,a,l)}function Wc(i,s,a,l){var h={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Zd(i))uS(s,h);else{var p=i.alternate;if(i.lanes===0&&(p===null||p.lanes===0)&&(p=s.lastRenderedReducer,p!==null))try{var y=s.lastRenderedState,D=p(y,a);if(h.hasEagerState=!0,h.eagerState=D,En(D,y))return Md(i,s,h,0),Zt===null&&Nd(),!1}catch{}if(a=Tp(i,s,h,l),a!==null)return Un(a,i,l),dS(a,s,l),!0}return!1}function cm(i,s,a,l){if(l={lane:2,revertLane:Um(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Zd(i)){if(s)throw Error(r(479))}else s=Tp(i,a,l,2),s!==null&&Un(s,i,2)}function Zd(i){var s=i.alternate;return i===dt||s!==null&&s===dt}function uS(i,s){Rl=Kd=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function dS(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,Jt(i,a)}}var qc={readContext:un,use:Vd,useCallback:mi,useContext:mi,useEffect:mi,useImperativeHandle:mi,useLayoutEffect:mi,useInsertionEffect:mi,useMemo:mi,useReducer:mi,useRef:mi,useState:mi,useDebugValue:mi,useDeferredValue:mi,useTransition:mi,useSyncExternalStore:mi,useId:mi,useHostTransitionStatus:mi,useFormState:mi,useActionState:mi,useOptimistic:mi,useMemoCache:mi,useCacheRefresh:mi};qc.useEffectEvent=mi;var hS={readContext:un,use:Vd,useCallback:function(i,s){return Dn().memoizedState=[i,s===void 0?null:s],i},useContext:un,useEffect:Xy,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,Xd(4194308,4,Jy.bind(null,s,i),a)},useLayoutEffect:function(i,s){return Xd(4194308,4,i,s)},useInsertionEffect:function(i,s){Xd(4,2,i,s)},useMemo:function(i,s){var a=Dn();s=s===void 0?null:s;var l=i();if(Io){gt(!0);try{i()}finally{gt(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=Dn();if(a!==void 0){var h=a(s);if(Io){gt(!0);try{a(s)}finally{gt(!1)}}}else h=s;return l.memoizedState=l.baseState=h,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:h},l.queue=i,i=i.dispatch=$E.bind(null,dt,i),[l.memoizedState,i]},useRef:function(i){var s=Dn();return i={current:i},s.memoizedState=i},useState:function(i){i=im(i);var s=i.queue,a=cS.bind(null,dt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:rm,useDeferredValue:function(i,s){var a=Dn();return am(a,i,s)},useTransition:function(){var i=im(!1);return i=sS.bind(null,dt,i.queue,!0,!1),Dn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=dt,h=Dn();if(Rt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Zt===null)throw Error(r(349));(Et&127)!==0||Ly(l,s,a)}h.memoizedState=a;var p={value:a,getSnapshot:s};return h.queue=p,Xy(By.bind(null,l,p,i),[i]),l.flags|=2048,Ml(9,{destroy:void 0},Oy.bind(null,l,p,a,s),null),a},useId:function(){var i=Dn(),s=Zt.identifierPrefix;if(Rt){var a=rr,l=sr;a=(l&~(1<<32-ct(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Wd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=jE++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:lm,useFormState:Ky,useActionState:Ky,useOptimistic:function(i){var s=Dn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=cm.bind(null,dt,!0,a),a.dispatch=s,[i,s]},useMemoCache:Jp,useCacheRefresh:function(){return Dn().memoizedState=FE.bind(null,dt)},useEffectEvent:function(i){var s=Dn(),a={impl:i};return s.memoizedState=a,function(){if((jt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},um={readContext:un,use:Vd,useCallback:tS,useContext:un,useEffect:sm,useImperativeHandle:eS,useInsertionEffect:Zy,useLayoutEffect:Qy,useMemo:iS,useReducer:Yd,useRef:Yy,useState:function(){return Yd(jr)},useDebugValue:rm,useDeferredValue:function(i,s){var a=Di();return nS(a,qt.memoizedState,i,s)},useTransition:function(){var i=Yd(jr)[0],s=Di().memoizedState;return[typeof i=="boolean"?i:Kc(i),s]},useSyncExternalStore:Ay,useId:oS,useHostTransitionStatus:lm,useFormState:Wy,useActionState:Wy,useOptimistic:function(i,s){var a=Di();return Py(a,qt,i,s)},useMemoCache:Jp,useCacheRefresh:lS};um.useEffectEvent=Gy;var fS={readContext:un,use:Vd,useCallback:tS,useContext:un,useEffect:sm,useImperativeHandle:eS,useInsertionEffect:Zy,useLayoutEffect:Qy,useMemo:iS,useReducer:tm,useRef:Yy,useState:function(){return tm(jr)},useDebugValue:rm,useDeferredValue:function(i,s){var a=Di();return qt===null?am(a,i,s):nS(a,qt.memoizedState,i,s)},useTransition:function(){var i=tm(jr)[0],s=Di().memoizedState;return[typeof i=="boolean"?i:Kc(i),s]},useSyncExternalStore:Ay,useId:oS,useHostTransitionStatus:lm,useFormState:Vy,useActionState:Vy,useOptimistic:function(i,s){var a=Di();return qt!==null?Py(a,qt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Jp,useCacheRefresh:lS};fS.useEffectEvent=Gy;function dm(i,s,a,l){s=i.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var hm={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Zn(),h=Ca(l);h.payload=s,a!=null&&(h.callback=a),s=ka(i,h,l),s!==null&&(Un(s,i,l),Hc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Zn(),h=Ca(l);h.tag=1,h.payload=s,a!=null&&(h.callback=a),s=ka(i,h,l),s!==null&&(Un(s,i,l),Hc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Zn(),l=Ca(a);l.tag=2,s!=null&&(l.callback=s),s=ka(i,l,a),s!==null&&(Un(s,i,a),Hc(s,i,a))}};function pS(i,s,a,l,h,p,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,p,y):s.prototype&&s.prototype.isPureReactComponent?!_a(a,l)||!_a(h,p):!0}function mS(i,s,a,l){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==i&&hm.enqueueReplaceState(s,s.state,null)}function Po(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var h in i)a[h]===void 0&&(a[h]=i[h])}return a}function gS(i){Rd(i)}function vS(i){console.error(i)}function _S(i){Rd(i)}function Qd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function bS(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function fm(i,s,a){return a=Ca(a),a.tag=3,a.payload={element:null},a.callback=function(){Qd(i,s)},a}function yS(i){return i=Ca(i),i.tag=3,i}function SS(i,s,a,l){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var p=l.value;i.payload=function(){return h(p)},i.callback=function(){bS(s,a,l)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){bS(s,a,l),typeof h!="function"&&(Ma===null?Ma=new Set([this]):Ma.add(this));var D=l.stack;this.componentDidCatch(l.value,{componentStack:D!==null?D:""})})}function KE(i,s,a,l,h){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&xl(s,a,h,!0),a=Vn.current,a!==null){switch(a.tag){case 31:case 13:return fs===null?uh():a.alternate===null&&gi===0&&(gi=3),a.flags&=-257,a.flags|=65536,a.lanes=h,l===zd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),Pm(i,l,h)),!1;case 22:return a.flags|=65536,l===zd?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([l]):a.add(l)),Pm(i,l,h)),!1}throw Error(r(435,a.tag))}return Pm(i,l,h),uh(),!1}if(Rt)return s=Vn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=h,l!==Ap&&(i=Error(r(422),{cause:l}),Bc(cs(i,a)))):(l!==Ap&&(s=Error(r(423),{cause:l}),Bc(cs(s,a))),i=i.current.alternate,i.flags|=65536,h&=-h,i.lanes|=h,l=cs(l,a),h=fm(i.stateNode,l,h),$p(i,h),gi!==4&&(gi=2)),!1;var p=Error(r(520),{cause:l});if(p=cs(p,a),eu===null?eu=[p]:eu.push(p),gi!==4&&(gi=2),s===null)return!0;l=cs(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=h&-h,a.lanes|=i,i=fm(a.stateNode,l,i),$p(a,i),!1;case 1:if(s=a.type,p=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(Ma===null||!Ma.has(p))))return a.flags|=65536,h&=-h,a.lanes|=h,h=yS(h),SS(h,i,a,l),$p(a,h),!1}a=a.return}while(a!==null);return!1}var pm=Error(r(461)),Li=!1;function dn(i,s,a,l){s.child=i===null?ky(s,null,a,l):jo(s,i.child,a,l)}function wS(i,s,a,l,h){a=a.render;var p=s.ref;if("ref"in l){var y={};for(var D in l)D!=="ref"&&(y[D]=l[D])}else y=l;return Ao(s),l=Xp(i,s,a,y,p,h),D=Gp(),i!==null&&!Li?(Zp(i,s,h),Ir(i,s,h)):(Rt&&D&&Np(s),s.flags|=1,dn(i,s,l,h),s.child)}function xS(i,s,a,l,h){if(i===null){var p=a.type;return typeof p=="function"&&!Ep(p)&&p.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=p,CS(i,s,p,l,h)):(i=Ld(a.type,null,l,s,s.mode,h),i.ref=s.ref,i.return=s,s.child=i)}if(p=i.child,!wm(i,h)){var y=p.memoizedProps;if(a=a.compare,a=a!==null?a:_a,a(y,l)&&i.ref===s.ref)return Ir(i,s,h)}return s.flags|=1,i=Mr(p,l),i.ref=s.ref,i.return=s,s.child=i}function CS(i,s,a,l,h){if(i!==null){var p=i.memoizedProps;if(_a(p,l)&&i.ref===s.ref)if(Li=!1,s.pendingProps=l=p,wm(i,h))(i.flags&131072)!==0&&(Li=!0);else return s.lanes=i.lanes,Ir(i,s,h)}return mm(i,s,a,l,h)}function kS(i,s,a,l){var h=l.children,p=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(p=p!==null?p.baseLanes|a:a,i!==null){for(l=s.child=i.child,h=0;l!==null;)h=h|l.lanes|l.childLanes,l=l.sibling;l=h&~p}else l=0,s.child=null;return TS(i,s,p,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Id(s,p!==null?p.cachePool:null),p!==null?Dy(s,p):Wp(),Ry(s);else return l=s.lanes=536870912,TS(i,s,p!==null?p.baseLanes|a:a,a,l)}else p!==null?(Id(s,p.cachePool),Dy(s,p),Ea(),s.memoizedState=null):(i!==null&&Id(s,null),Wp(),Ea());return dn(i,s,h,a),s.child}function Vc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function TS(i,s,a,l,h){var p=zp();return p=p===null?null:{parent:Mi._currentValue,pool:p},s.memoizedState={baseLanes:a,cachePool:p},i!==null&&Id(s,null),Wp(),Ry(s),i!==null&&xl(i,s,l,!0),s.childLanes=h,null}function Jd(i,s){return s=th({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function ES(i,s,a){return jo(s,i.child,null,a),i=Jd(s,s.pendingProps),i.flags|=2,Yn(s),s.memoizedState=null,i}function WE(i,s,a){var l=s.pendingProps,h=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Rt){if(l.mode==="hidden")return i=Jd(s,l),s.lanes=536870912,Vc(null,i);if(Vp(s),(i=ei)?(i=z0(i,hs),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ba!==null?{id:sr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=uy(i),a.return=s,s.child=a,cn=s,ei=null)):i=null,i===null)throw Sa(s);return s.lanes=536870912,null}return Jd(s,l)}var p=i.memoizedState;if(p!==null){var y=p.dehydrated;if(Vp(s),h)if(s.flags&256)s.flags&=-257,s=ES(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Li||xl(i,s,a,!1),h=(a&i.childLanes)!==0,Li||h){if(l=Zt,l!==null&&(y=Vi(l,a),y!==0&&y!==p.retryLane))throw p.retryLane=y,Do(i,y),Un(l,i,y),pm;uh(),s=ES(i,s,a)}else i=p.treeContext,ei=ps(y.nextSibling),cn=s,Rt=!0,ya=null,hs=!1,i!==null&&fy(s,i),s=Jd(s,l),s.flags|=4096;return s}return i=Mr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function eh(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function mm(i,s,a,l,h){return Ao(s),a=Xp(i,s,a,l,void 0,h),l=Gp(),i!==null&&!Li?(Zp(i,s,h),Ir(i,s,h)):(Rt&&l&&Np(s),s.flags|=1,dn(i,s,a,h),s.child)}function DS(i,s,a,l,h,p){return Ao(s),s.updateQueue=null,a=My(s,l,a,h),Ny(i),l=Gp(),i!==null&&!Li?(Zp(i,s,p),Ir(i,s,p)):(Rt&&l&&Np(s),s.flags|=1,dn(i,s,a,p),s.child)}function RS(i,s,a,l,h){if(Ao(s),s.stateNode===null){var p=bl,y=a.contextType;typeof y=="object"&&y!==null&&(p=un(y)),p=new a(l,p),s.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=hm,s.stateNode=p,p._reactInternals=s,p=s.stateNode,p.props=l,p.state=s.memoizedState,p.refs={},Up(s),y=a.contextType,p.context=typeof y=="object"&&y!==null?un(y):bl,p.state=s.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(dm(s,a,y,l),p.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(y=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),y!==p.state&&hm.enqueueReplaceState(p,p.state,null),Fc(s,l,p,h),Uc(),p.state=s.memoizedState),typeof p.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){p=s.stateNode;var D=s.memoizedProps,j=Po(a,D);p.props=j;var re=p.context,_e=a.contextType;y=bl,typeof _e=="object"&&_e!==null&&(y=un(_e));var xe=a.getDerivedStateFromProps;_e=typeof xe=="function"||typeof p.getSnapshotBeforeUpdate=="function",D=s.pendingProps!==D,_e||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(D||re!==y)&&mS(s,p,l,y),xa=!1;var ue=s.memoizedState;p.state=ue,Fc(s,l,p,h),Uc(),re=s.memoizedState,D||ue!==re||xa?(typeof xe=="function"&&(dm(s,a,xe,l),re=s.memoizedState),(j=xa||pS(s,a,j,l,ue,re,y))?(_e||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(s.flags|=4194308)):(typeof p.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=re),p.props=l,p.state=re,p.context=y,l=j):(typeof p.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{p=s.stateNode,Fp(i,s),y=s.memoizedProps,_e=Po(a,y),p.props=_e,xe=s.pendingProps,ue=p.context,re=a.contextType,j=bl,typeof re=="object"&&re!==null&&(j=un(re)),D=a.getDerivedStateFromProps,(re=typeof D=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(y!==xe||ue!==j)&&mS(s,p,l,j),xa=!1,ue=s.memoizedState,p.state=ue,Fc(s,l,p,h),Uc();var fe=s.memoizedState;y!==xe||ue!==fe||xa||i!==null&&i.dependencies!==null&&Bd(i.dependencies)?(typeof D=="function"&&(dm(s,a,D,l),fe=s.memoizedState),(_e=xa||pS(s,a,_e,l,ue,fe,j)||i!==null&&i.dependencies!==null&&Bd(i.dependencies))?(re||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(l,fe,j),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(l,fe,j)),typeof p.componentDidUpdate=="function"&&(s.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof p.componentDidUpdate!="function"||y===i.memoizedProps&&ue===i.memoizedState||(s.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&ue===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=fe),p.props=l,p.state=fe,p.context=j,l=_e):(typeof p.componentDidUpdate!="function"||y===i.memoizedProps&&ue===i.memoizedState||(s.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&ue===i.memoizedState||(s.flags|=1024),l=!1)}return p=l,eh(i,s),l=(s.flags&128)!==0,p||l?(p=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:p.render(),s.flags|=1,i!==null&&l?(s.child=jo(s,i.child,null,h),s.child=jo(s,null,a,h)):dn(i,s,a,h),s.memoizedState=p.state,i=s.child):i=Ir(i,s,h),i}function NS(i,s,a,l){return No(),s.flags|=256,dn(i,s,a,l),s.child}var gm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function vm(i){return{baseLanes:i,cachePool:by()}}function _m(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Gn),i}function MS(i,s,a){var l=s.pendingProps,h=!1,p=(s.flags&128)!==0,y;if((y=p)||(y=i!==null&&i.memoizedState===null?!1:(Ei.current&2)!==0),y&&(h=!0,s.flags&=-129),y=(s.flags&32)!==0,s.flags&=-33,i===null){if(Rt){if(h?Ta(s):Ea(),(i=ei)?(i=z0(i,hs),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ba!==null?{id:sr,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},a=uy(i),a.return=s,s.child=a,cn=s,ei=null)):i=null,i===null)throw Sa(s);return eg(i)?s.lanes=32:s.lanes=536870912,null}var D=l.children;return l=l.fallback,h?(Ea(),h=s.mode,D=th({mode:"hidden",children:D},h),l=Ro(l,h,a,null),D.return=s,l.return=s,D.sibling=l,s.child=D,l=s.child,l.memoizedState=vm(a),l.childLanes=_m(i,y,a),s.memoizedState=gm,Vc(null,l)):(Ta(s),bm(s,D))}var j=i.memoizedState;if(j!==null&&(D=j.dehydrated,D!==null)){if(p)s.flags&256?(Ta(s),s.flags&=-257,s=ym(i,s,a)):s.memoizedState!==null?(Ea(),s.child=i.child,s.flags|=128,s=null):(Ea(),D=l.fallback,h=s.mode,l=th({mode:"visible",children:l.children},h),D=Ro(D,h,a,null),D.flags|=2,l.return=s,D.return=s,l.sibling=D,s.child=l,jo(s,i.child,null,a),l=s.child,l.memoizedState=vm(a),l.childLanes=_m(i,y,a),s.memoizedState=gm,s=Vc(null,l));else if(Ta(s),eg(D)){if(y=D.nextSibling&&D.nextSibling.dataset,y)var re=y.dgst;y=re,l=Error(r(419)),l.stack="",l.digest=y,Bc({value:l,source:null,stack:null}),s=ym(i,s,a)}else if(Li||xl(i,s,a,!1),y=(a&i.childLanes)!==0,Li||y){if(y=Zt,y!==null&&(l=Vi(y,a),l!==0&&l!==j.retryLane))throw j.retryLane=l,Do(i,l),Un(y,i,l),pm;Jm(D)||uh(),s=ym(i,s,a)}else Jm(D)?(s.flags|=192,s.child=i.child,s=null):(i=j.treeContext,ei=ps(D.nextSibling),cn=s,Rt=!0,ya=null,hs=!1,i!==null&&fy(s,i),s=bm(s,l.children),s.flags|=4096);return s}return h?(Ea(),D=l.fallback,h=s.mode,j=i.child,re=j.sibling,l=Mr(j,{mode:"hidden",children:l.children}),l.subtreeFlags=j.subtreeFlags&65011712,re!==null?D=Mr(re,D):(D=Ro(D,h,a,null),D.flags|=2),D.return=s,l.return=s,l.sibling=D,s.child=l,Vc(null,l),l=s.child,D=i.child.memoizedState,D===null?D=vm(a):(h=D.cachePool,h!==null?(j=Mi._currentValue,h=h.parent!==j?{parent:j,pool:j}:h):h=by(),D={baseLanes:D.baseLanes|a,cachePool:h}),l.memoizedState=D,l.childLanes=_m(i,y,a),s.memoizedState=gm,Vc(i.child,l)):(Ta(s),a=i.child,i=a.sibling,a=Mr(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,i!==null&&(y=s.deletions,y===null?(s.deletions=[i],s.flags|=16):y.push(i)),s.child=a,s.memoizedState=null,a)}function bm(i,s){return s=th({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function th(i,s){return i=qn(22,i,null,s),i.lanes=0,i}function ym(i,s,a){return jo(s,i.child,null,a),i=bm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function AS(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),Bp(i.return,s,a)}function Sm(i,s,a,l,h,p){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:h,treeForkCount:p}:(y.isBackwards=s,y.rendering=null,y.renderingStartTime=0,y.last=l,y.tail=a,y.tailMode=h,y.treeForkCount=p)}function LS(i,s,a){var l=s.pendingProps,h=l.revealOrder,p=l.tail;l=l.children;var y=Ei.current,D=(y&2)!==0;if(D?(y=y&1|2,s.flags|=128):y&=1,he(Ei,y),dn(i,s,l,a),l=Rt?Oc:0,!D&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&AS(i,a,s);else if(i.tag===19)AS(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(h){case"forwards":for(a=s.child,h=null;a!==null;)i=a.alternate,i!==null&&$d(i)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),Sm(s,!1,h,a,p,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(i=h.alternate,i!==null&&$d(i)===null){s.child=h;break}i=h.sibling,h.sibling=a,a=h,h=i}Sm(s,!0,a,null,p,l);break;case"together":Sm(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function Ir(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),Na|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(xl(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=Mr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=Mr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function wm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Bd(i)))}function qE(i,s,a){switch(s.tag){case 3:Ne(s,s.stateNode.containerInfo),wa(s,Mi,i.memoizedState.cache),No();break;case 27:case 5:He(s);break;case 4:Ne(s,s.stateNode.containerInfo);break;case 10:wa(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Vp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(Ta(s),s.flags|=128,null):(a&s.child.childLanes)!==0?MS(i,s,a):(Ta(s),i=Ir(i,s,a),i!==null?i.sibling:null);Ta(s);break;case 19:var h=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(xl(i,s,a,!1),l=(a&s.childLanes)!==0),h){if(l)return LS(i,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),he(Ei,Ei.current),l)break;return null;case 22:return s.lanes=0,kS(i,s,a,s.pendingProps);case 24:wa(s,Mi,i.memoizedState.cache)}return Ir(i,s,a)}function OS(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Li=!0;else{if(!wm(i,a)&&(s.flags&128)===0)return Li=!1,qE(i,s,a);Li=(i.flags&131072)!==0}else Li=!1,Rt&&(s.flags&1048576)!==0&&hy(s,Oc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=Oo(s.elementType),s.type=i,typeof i=="function")Ep(i)?(l=Po(i,l),s.tag=1,s=RS(null,s,i,l,a)):(s.tag=0,s=mm(null,s,i,l,a));else{if(i!=null){var h=i.$$typeof;if(h===F){s.tag=11,s=wS(null,s,i,l,a);break e}else if(h===P){s.tag=14,s=xS(null,s,i,l,a);break e}}throw s=V(i)||i,Error(r(306,s,""))}}return s;case 0:return mm(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,h=Po(l,s.pendingProps),RS(i,s,l,h,a);case 3:e:{if(Ne(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var p=s.memoizedState;h=p.element,Fp(i,s),Fc(s,l,null,a);var y=s.memoizedState;if(l=y.cache,wa(s,Mi,l),l!==p.cache&&jp(s,[Mi],a,!0),Uc(),l=y.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:y.cache},s.updateQueue.baseState=p,s.memoizedState=p,s.flags&256){s=NS(i,s,l,a);break e}else if(l!==h){h=cs(Error(r(424)),s),Bc(h),s=NS(i,s,l,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,ei=ps(i.firstChild),cn=s,Rt=!0,ya=null,hs=!0,a=ky(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(No(),l===h){s=Ir(i,s,a);break e}dn(i,s,l,a)}s=s.child}return s;case 26:return eh(i,s),i===null?(a=W0(s.type,null,s.pendingProps,null))?s.memoizedState=a:Rt||(a=s.type,i=s.pendingProps,l=vh(ve.current).createElement(a),l[wi]=s,l[xi]=i,hn(l,a,i),Ht(l),s.stateNode=l):s.memoizedState=W0(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return He(s),i===null&&Rt&&(l=s.stateNode=F0(s.type,s.pendingProps,ve.current),cn=s,hs=!0,h=ei,Ba(s.type)?(tg=h,ei=ps(l.firstChild)):ei=h),dn(i,s,s.pendingProps.children,a),eh(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Rt&&((h=l=ei)&&(l=w2(l,s.type,s.pendingProps,hs),l!==null?(s.stateNode=l,cn=s,ei=ps(l.firstChild),hs=!1,h=!0):h=!1),h||Sa(s)),He(s),h=s.type,p=s.pendingProps,y=i!==null?i.memoizedProps:null,l=p.children,Gm(h,p)?l=null:y!==null&&Gm(h,y)&&(s.flags|=32),s.memoizedState!==null&&(h=Xp(i,s,IE,null,null,a),lu._currentValue=h),eh(i,s),dn(i,s,l,a),s.child;case 6:return i===null&&Rt&&((i=a=ei)&&(a=x2(a,s.pendingProps,hs),a!==null?(s.stateNode=a,cn=s,ei=null,i=!0):i=!1),i||Sa(s)),null;case 13:return MS(i,s,a);case 4:return Ne(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=jo(s,null,l,a):dn(i,s,l,a),s.child;case 11:return wS(i,s,s.type,s.pendingProps,a);case 7:return dn(i,s,s.pendingProps,a),s.child;case 8:return dn(i,s,s.pendingProps.children,a),s.child;case 12:return dn(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,wa(s,s.type,l.value),dn(i,s,l.children,a),s.child;case 9:return h=s.type._context,l=s.pendingProps.children,Ao(s),h=un(h),l=l(h),s.flags|=1,dn(i,s,l,a),s.child;case 14:return xS(i,s,s.type,s.pendingProps,a);case 15:return CS(i,s,s.type,s.pendingProps,a);case 19:return LS(i,s,a);case 31:return WE(i,s,a);case 22:return kS(i,s,a,s.pendingProps);case 24:return Ao(s),l=un(Mi),i===null?(h=zp(),h===null&&(h=Zt,p=Ip(),h.pooledCache=p,p.refCount++,p!==null&&(h.pooledCacheLanes|=a),h=p),s.memoizedState={parent:l,cache:h},Up(s),wa(s,Mi,h)):((i.lanes&a)!==0&&(Fp(i,s),Fc(s,null,null,a),Uc()),h=i.memoizedState,p=s.memoizedState,h.parent!==l?(h={parent:l,cache:l},s.memoizedState=h,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=h),wa(s,Mi,l)):(l=p.cache,wa(s,Mi,l),l!==h.cache&&jp(s,[Mi],a,!0))),dn(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function Pr(i){i.flags|=4}function xm(i,s,a,l,h){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(h&335544128)===h)if(i.stateNode.complete)i.flags|=8192;else if(o0())i.flags|=8192;else throw Bo=zd,Hp}else i.flags&=-16777217}function BS(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!G0(s))if(o0())i.flags|=8192;else throw Bo=zd,Hp}function ih(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?ni():536870912,i.lanes|=s,Bl|=s)}function Yc(i,s){if(!Rt)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function ti(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var h=i.child;h!==null;)a|=h.lanes|h.childLanes,l|=h.subtreeFlags&65011712,l|=h.flags&65011712,h.return=i,h=h.sibling;else for(h=i.child;h!==null;)a|=h.lanes|h.childLanes,l|=h.subtreeFlags,l|=h.flags,h.return=i,h=h.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function VE(i,s,a){var l=s.pendingProps;switch(Mp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ti(s),null;case 1:return ti(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),Or(Mi),Fe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(wl(s)?Pr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Lp())),ti(s),null;case 26:var h=s.type,p=s.memoizedState;return i===null?(Pr(s),p!==null?(ti(s),BS(s,p)):(ti(s),xm(s,h,null,l,a))):p?p!==i.memoizedState?(Pr(s),ti(s),BS(s,p)):(ti(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&Pr(s),ti(s),xm(s,h,i,l,a)),null;case 27:if(Pe(s),a=ve.current,h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&Pr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ti(s),null}i=J.current,wl(s)?py(s):(i=F0(h,l,a),s.stateNode=i,Pr(s))}return ti(s),null;case 5:if(Pe(s),h=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&Pr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ti(s),null}if(p=J.current,wl(s))py(s);else{var y=vh(ve.current);switch(p){case 1:p=y.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:p=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":p=y.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":p=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":p=y.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof l.is=="string"?y.createElement("select",{is:l.is}):y.createElement("select"),l.multiple?p.multiple=!0:l.size&&(p.size=l.size);break;default:p=typeof l.is=="string"?y.createElement(h,{is:l.is}):y.createElement(h)}}p[wi]=s,p[xi]=l;e:for(y=s.child;y!==null;){if(y.tag===5||y.tag===6)p.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===s)break e;for(;y.sibling===null;){if(y.return===null||y.return===s)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}s.stateNode=p;e:switch(hn(p,h,l),h){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Pr(s)}}return ti(s),xm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&Pr(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=ve.current,wl(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,h=cn,h!==null)switch(h.tag){case 27:case 5:l=h.memoizedProps}i[wi]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||M0(i.nodeValue,a)),i||Sa(s,!0)}else i=vh(i).createTextNode(l),i[wi]=s,s.stateNode=i}return ti(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=wl(s),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[wi]=s}else No(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ti(s),i=!1}else a=Lp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Yn(s),s):(Yn(s),null);if((s.flags&128)!==0)throw Error(r(558))}return ti(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(h=wl(s),l!==null&&l.dehydrated!==null){if(i===null){if(!h)throw Error(r(318));if(h=s.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[wi]=s}else No(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ti(s),h=!1}else h=Lp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=h),h=!0;if(!h)return s.flags&256?(Yn(s),s):(Yn(s),null)}return Yn(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,h=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(h=l.alternate.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==h&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),ih(s,s.updateQueue),ti(s),null);case 4:return Fe(),i===null&&Wm(s.stateNode.containerInfo),ti(s),null;case 10:return Or(s.type),ti(s),null;case 19:if(q(Ei),l=s.memoizedState,l===null)return ti(s),null;if(h=(s.flags&128)!==0,p=l.rendering,p===null)if(h)Yc(l,!1);else{if(gi!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(p=$d(i),p!==null){for(s.flags|=128,Yc(l,!1),i=p.updateQueue,s.updateQueue=i,ih(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)cy(a,i),a=a.sibling;return he(Ei,Ei.current&1|2),Rt&&Ar(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&$e()>oh&&(s.flags|=128,h=!0,Yc(l,!1),s.lanes=4194304)}else{if(!h)if(i=$d(p),i!==null){if(s.flags|=128,h=!0,i=i.updateQueue,s.updateQueue=i,ih(s,i),Yc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!p.alternate&&!Rt)return ti(s),null}else 2*$e()-l.renderingStartTime>oh&&a!==536870912&&(s.flags|=128,h=!0,Yc(l,!1),s.lanes=4194304);l.isBackwards?(p.sibling=s.child,s.child=p):(i=l.last,i!==null?i.sibling=p:s.child=p,l.last=p)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=$e(),i.sibling=null,a=Ei.current,he(Ei,h?a&1|2:a&1),Rt&&Ar(s,l.treeForkCount),i):(ti(s),null);case 22:case 23:return Yn(s),qp(),l=s.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(ti(s),s.subtreeFlags&6&&(s.flags|=8192)):ti(s),a=s.updateQueue,a!==null&&ih(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),i!==null&&q(Lo),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),Or(Mi),ti(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function YE(i,s){switch(Mp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return Or(Mi),Fe(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return Pe(s),null;case 31:if(s.memoizedState!==null){if(Yn(s),s.alternate===null)throw Error(r(340));No()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Yn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));No()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return q(Ei),null;case 4:return Fe(),null;case 10:return Or(s.type),null;case 22:case 23:return Yn(s),qp(),i!==null&&q(Lo),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return Or(Mi),null;case 25:return null;default:return null}}function jS(i,s){switch(Mp(s),s.tag){case 3:Or(Mi),Fe();break;case 26:case 27:case 5:Pe(s);break;case 4:Fe();break;case 31:s.memoizedState!==null&&Yn(s);break;case 13:Yn(s);break;case 19:q(Ei);break;case 10:Or(s.type);break;case 22:case 23:Yn(s),qp(),i!==null&&q(Lo);break;case 24:Or(Mi)}}function Xc(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var h=l.next;a=h;do{if((a.tag&i)===i){l=void 0;var p=a.create,y=a.inst;l=p(),y.destroy=l}a=a.next}while(a!==h)}}catch(D){$t(s,s.return,D)}}function Da(i,s,a){try{var l=s.updateQueue,h=l!==null?l.lastEffect:null;if(h!==null){var p=h.next;l=p;do{if((l.tag&i)===i){var y=l.inst,D=y.destroy;if(D!==void 0){y.destroy=void 0,h=s;var j=a,re=D;try{re()}catch(_e){$t(h,j,_e)}}}l=l.next}while(l!==p)}}catch(_e){$t(s,s.return,_e)}}function IS(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{Ey(s,a)}catch(l){$t(i,i.return,l)}}}function PS(i,s,a){a.props=Po(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){$t(i,s,l)}}function Gc(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(h){$t(i,s,h)}}function ar(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(h){$t(i,s,h)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(h){$t(i,s,h)}else a.current=null}function zS(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(h){$t(i,i.return,h)}}function Cm(i,s,a){try{var l=i.stateNode;g2(l,i.type,a,s),l[xi]=s}catch(h){$t(i,i.return,h)}}function HS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ba(i.type)||i.tag===4}function km(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||HS(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Ba(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Tm(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Ln));else if(l!==4&&(l===27&&Ba(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Tm(i,s,a),i=i.sibling;i!==null;)Tm(i,s,a),i=i.sibling}function nh(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(l!==4&&(l===27&&Ba(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(nh(i,s,a),i=i.sibling;i!==null;)nh(i,s,a),i=i.sibling}function US(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,h=s.attributes;h.length;)s.removeAttributeNode(h[0]);hn(s,l,a),s[wi]=i,s[xi]=a}catch(p){$t(i,i.return,p)}}var zr=!1,Oi=!1,Em=!1,FS=typeof WeakSet=="function"?WeakSet:Set,Qi=null;function XE(i,s){if(i=i.containerInfo,Ym=Ch,i=Dd(i),Eo(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var h=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{a.nodeType,p.nodeType}catch{a=null;break e}var y=0,D=-1,j=-1,re=0,_e=0,xe=i,ue=null;t:for(;;){for(var fe;xe!==a||h!==0&&xe.nodeType!==3||(D=y+h),xe!==p||l!==0&&xe.nodeType!==3||(j=y+l),xe.nodeType===3&&(y+=xe.nodeValue.length),(fe=xe.firstChild)!==null;)ue=xe,xe=fe;for(;;){if(xe===i)break t;if(ue===a&&++re===h&&(D=y),ue===p&&++_e===l&&(j=y),(fe=xe.nextSibling)!==null)break;xe=ue,ue=xe.parentNode}xe=fe}a=D===-1||j===-1?null:{start:D,end:j}}else a=null}a=a||{start:0,end:0}}else a=null;for(Xm={focusedElem:i,selectionRange:a},Ch=!1,Qi=s;Qi!==null;)if(s=Qi,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,Qi=i;else for(;Qi!==null;){switch(s=Qi,p=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)h=i[a],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&p!==null){i=void 0,a=s,h=p.memoizedProps,p=p.memoizedState,l=a.stateNode;try{var Ke=Po(a.type,h);i=l.getSnapshotBeforeUpdate(Ke,p),l.__reactInternalSnapshotBeforeUpdate=i}catch(tt){$t(a,a.return,tt)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Qm(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Qm(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,Qi=i;break}Qi=s.return}}function $S(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Ur(i,a),l&4&&Xc(5,a);break;case 1:if(Ur(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(y){$t(a,a.return,y)}else{var h=Po(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(h,s,i.__reactInternalSnapshotBeforeUpdate)}catch(y){$t(a,a.return,y)}}l&64&&IS(a),l&512&&Gc(a,a.return);break;case 3:if(Ur(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{Ey(i,s)}catch(y){$t(a,a.return,y)}}break;case 27:s===null&&l&4&&US(a);case 26:case 5:Ur(i,a),s===null&&l&4&&zS(a),l&512&&Gc(a,a.return);break;case 12:Ur(i,a);break;case 31:Ur(i,a),l&4&&qS(i,a);break;case 13:Ur(i,a),l&4&&VS(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=s2.bind(null,a),C2(i,a))));break;case 22:if(l=a.memoizedState!==null||zr,!l){s=s!==null&&s.memoizedState!==null||Oi,h=zr;var p=Oi;zr=l,(Oi=s)&&!p?Fr(i,a,(a.subtreeFlags&8772)!==0):Ur(i,a),zr=h,Oi=p}break;case 30:break;default:Ur(i,a)}}function KS(i){var s=i.alternate;s!==null&&(i.alternate=null,KS(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Xs(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var si=null,In=!1;function Hr(i,s,a){for(a=a.child;a!==null;)WS(i,s,a),a=a.sibling}function WS(i,s,a){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(st,a)}catch{}switch(a.tag){case 26:Oi||ar(a,s),Hr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Oi||ar(a,s);var l=si,h=In;Ba(a.type)&&(si=a.stateNode,In=!1),Hr(i,s,a),ru(a.stateNode),si=l,In=h;break;case 5:Oi||ar(a,s);case 6:if(l=si,h=In,si=null,Hr(i,s,a),si=l,In=h,si!==null)if(In)try{(si.nodeType===9?si.body:si.nodeName==="HTML"?si.ownerDocument.body:si).removeChild(a.stateNode)}catch(p){$t(a,s,p)}else try{si.removeChild(a.stateNode)}catch(p){$t(a,s,p)}break;case 18:si!==null&&(In?(i=si,I0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),$l(i)):I0(si,a.stateNode));break;case 4:l=si,h=In,si=a.stateNode.containerInfo,In=!0,Hr(i,s,a),si=l,In=h;break;case 0:case 11:case 14:case 15:Da(2,a,s),Oi||Da(4,a,s),Hr(i,s,a);break;case 1:Oi||(ar(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&PS(a,s,l)),Hr(i,s,a);break;case 21:Hr(i,s,a);break;case 22:Oi=(l=Oi)||a.memoizedState!==null,Hr(i,s,a),Oi=l;break;default:Hr(i,s,a)}}function qS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{$l(i)}catch(a){$t(s,s.return,a)}}}function VS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{$l(i)}catch(a){$t(s,s.return,a)}}function GE(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new FS),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new FS),s;default:throw Error(r(435,i.tag))}}function sh(i,s){var a=GE(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var h=r2.bind(null,i,l);l.then(h,h)}})}function Pn(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var h=a[l],p=i,y=s,D=y;e:for(;D!==null;){switch(D.tag){case 27:if(Ba(D.type)){si=D.stateNode,In=!1;break e}break;case 5:si=D.stateNode,In=!1;break e;case 3:case 4:si=D.stateNode.containerInfo,In=!0;break e}D=D.return}if(si===null)throw Error(r(160));WS(p,y,h),si=null,In=!1,p=h.alternate,p!==null&&(p.return=null),h.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)YS(s,i),s=s.sibling}var Us=null;function YS(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Pn(s,i),zn(i),l&4&&(Da(3,i,i.return),Xc(3,i),Da(5,i,i.return));break;case 1:Pn(s,i),zn(i),l&512&&(Oi||a===null||ar(a,a.return)),l&64&&zr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var h=Us;if(Pn(s,i),zn(i),l&512&&(Oi||a===null||ar(a,a.return)),l&4){var p=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,h=h.ownerDocument||h;t:switch(l){case"title":p=h.getElementsByTagName("title")[0],(!p||p[on]||p[wi]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=h.createElement(l),h.head.insertBefore(p,h.querySelector("head > title"))),hn(p,l,a),p[wi]=i,Ht(p),l=p;break e;case"link":var y=Y0("link","href",h).get(l+(a.href||""));if(y){for(var D=0;D<y.length;D++)if(p=y[D],p.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&p.getAttribute("rel")===(a.rel==null?null:a.rel)&&p.getAttribute("title")===(a.title==null?null:a.title)&&p.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(D,1);break t}}p=h.createElement(l),hn(p,l,a),h.head.appendChild(p);break;case"meta":if(y=Y0("meta","content",h).get(l+(a.content||""))){for(D=0;D<y.length;D++)if(p=y[D],p.getAttribute("content")===(a.content==null?null:""+a.content)&&p.getAttribute("name")===(a.name==null?null:a.name)&&p.getAttribute("property")===(a.property==null?null:a.property)&&p.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&p.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(D,1);break t}}p=h.createElement(l),hn(p,l,a),h.head.appendChild(p);break;default:throw Error(r(468,l))}p[wi]=i,Ht(p),l=p}i.stateNode=l}else X0(h,i.type,i.stateNode);else i.stateNode=V0(h,l,i.memoizedProps);else p!==l?(p===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):p.count--,l===null?X0(h,i.type,i.stateNode):V0(h,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Cm(i,i.memoizedProps,a.memoizedProps)}break;case 27:Pn(s,i),zn(i),l&512&&(Oi||a===null||ar(a,a.return)),a!==null&&l&4&&Cm(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Pn(s,i),zn(i),l&512&&(Oi||a===null||ar(a,a.return)),i.flags&32){h=i.stateNode;try{Gi(h,"")}catch(Ke){$t(i,i.return,Ke)}}l&4&&i.stateNode!=null&&(h=i.memoizedProps,Cm(i,h,a!==null?a.memoizedProps:h)),l&1024&&(Em=!0);break;case 6:if(Pn(s,i),zn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ke){$t(i,i.return,Ke)}}break;case 3:if(yh=null,h=Us,Us=_h(s.containerInfo),Pn(s,i),Us=h,zn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{$l(s.containerInfo)}catch(Ke){$t(i,i.return,Ke)}Em&&(Em=!1,XS(i));break;case 4:l=Us,Us=_h(i.stateNode.containerInfo),Pn(s,i),zn(i),Us=l;break;case 12:Pn(s,i),zn(i);break;case 31:Pn(s,i),zn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sh(i,l)));break;case 13:Pn(s,i),zn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(ah=$e()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sh(i,l)));break;case 22:h=i.memoizedState!==null;var j=a!==null&&a.memoizedState!==null,re=zr,_e=Oi;if(zr=re||h,Oi=_e||j,Pn(s,i),Oi=_e,zr=re,zn(i),l&8192)e:for(s=i.stateNode,s._visibility=h?s._visibility&-2:s._visibility|1,h&&(a===null||j||zr||Oi||zo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){j=a=s;try{if(p=j.stateNode,h)y=p.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{D=j.stateNode;var xe=j.memoizedProps.style,ue=xe!=null&&xe.hasOwnProperty("display")?xe.display:null;D.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ke){$t(j,j.return,Ke)}}}else if(s.tag===6){if(a===null){j=s;try{j.stateNode.nodeValue=h?"":j.memoizedProps}catch(Ke){$t(j,j.return,Ke)}}}else if(s.tag===18){if(a===null){j=s;try{var fe=j.stateNode;h?P0(fe,!0):P0(j.stateNode,!1)}catch(Ke){$t(j,j.return,Ke)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,sh(i,a))));break;case 19:Pn(s,i),zn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,sh(i,l)));break;case 30:break;case 21:break;default:Pn(s,i),zn(i)}}function zn(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(HS(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var h=a.stateNode,p=km(i);nh(i,p,h);break;case 5:var y=a.stateNode;a.flags&32&&(Gi(y,""),a.flags&=-33);var D=km(i);nh(i,D,y);break;case 3:case 4:var j=a.stateNode.containerInfo,re=km(i);Tm(i,re,j);break;default:throw Error(r(161))}}catch(_e){$t(i,i.return,_e)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function XS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;XS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function Ur(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)$S(i,s.alternate,s),s=s.sibling}function zo(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:Da(4,s,s.return),zo(s);break;case 1:ar(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&PS(s,s.return,a),zo(s);break;case 27:ru(s.stateNode);case 26:case 5:ar(s,s.return),zo(s);break;case 22:s.memoizedState===null&&zo(s);break;case 30:zo(s);break;default:zo(s)}i=i.sibling}}function Fr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,h=i,p=s,y=p.flags;switch(p.tag){case 0:case 11:case 15:Fr(h,p,a),Xc(4,p);break;case 1:if(Fr(h,p,a),l=p,h=l.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(re){$t(l,l.return,re)}if(l=p,h=l.updateQueue,h!==null){var D=l.stateNode;try{var j=h.shared.hiddenCallbacks;if(j!==null)for(h.shared.hiddenCallbacks=null,h=0;h<j.length;h++)Ty(j[h],D)}catch(re){$t(l,l.return,re)}}a&&y&64&&IS(p),Gc(p,p.return);break;case 27:US(p);case 26:case 5:Fr(h,p,a),a&&l===null&&y&4&&zS(p),Gc(p,p.return);break;case 12:Fr(h,p,a);break;case 31:Fr(h,p,a),a&&y&4&&qS(h,p);break;case 13:Fr(h,p,a),a&&y&4&&VS(h,p);break;case 22:p.memoizedState===null&&Fr(h,p,a),Gc(p,p.return);break;case 30:break;default:Fr(h,p,a)}s=s.sibling}}function Dm(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&jc(a))}function Rm(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&jc(i))}function Fs(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)GS(i,s,a,l),s=s.sibling}function GS(i,s,a,l){var h=s.flags;switch(s.tag){case 0:case 11:case 15:Fs(i,s,a,l),h&2048&&Xc(9,s);break;case 1:Fs(i,s,a,l);break;case 3:Fs(i,s,a,l),h&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&jc(i)));break;case 12:if(h&2048){Fs(i,s,a,l),i=s.stateNode;try{var p=s.memoizedProps,y=p.id,D=p.onPostCommit;typeof D=="function"&&D(y,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(j){$t(s,s.return,j)}}else Fs(i,s,a,l);break;case 31:Fs(i,s,a,l);break;case 13:Fs(i,s,a,l);break;case 23:break;case 22:p=s.stateNode,y=s.alternate,s.memoizedState!==null?p._visibility&2?Fs(i,s,a,l):Zc(i,s):p._visibility&2?Fs(i,s,a,l):(p._visibility|=2,Al(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),h&2048&&Dm(y,s);break;case 24:Fs(i,s,a,l),h&2048&&Rm(s.alternate,s);break;default:Fs(i,s,a,l)}}function Al(i,s,a,l,h){for(h=h&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var p=i,y=s,D=a,j=l,re=y.flags;switch(y.tag){case 0:case 11:case 15:Al(p,y,D,j,h),Xc(8,y);break;case 23:break;case 22:var _e=y.stateNode;y.memoizedState!==null?_e._visibility&2?Al(p,y,D,j,h):Zc(p,y):(_e._visibility|=2,Al(p,y,D,j,h)),h&&re&2048&&Dm(y.alternate,y);break;case 24:Al(p,y,D,j,h),h&&re&2048&&Rm(y.alternate,y);break;default:Al(p,y,D,j,h)}s=s.sibling}}function Zc(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,h=l.flags;switch(l.tag){case 22:Zc(a,l),h&2048&&Dm(l.alternate,l);break;case 24:Zc(a,l),h&2048&&Rm(l.alternate,l);break;default:Zc(a,l)}s=s.sibling}}var Qc=8192;function Ll(i,s,a){if(i.subtreeFlags&Qc)for(i=i.child;i!==null;)ZS(i,s,a),i=i.sibling}function ZS(i,s,a){switch(i.tag){case 26:Ll(i,s,a),i.flags&Qc&&i.memoizedState!==null&&j2(a,Us,i.memoizedState,i.memoizedProps);break;case 5:Ll(i,s,a);break;case 3:case 4:var l=Us;Us=_h(i.stateNode.containerInfo),Ll(i,s,a),Us=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Qc,Qc=16777216,Ll(i,s,a),Qc=l):Ll(i,s,a));break;default:Ll(i,s,a)}}function QS(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Jc(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];Qi=l,e0(l,i)}QS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)JS(i),i=i.sibling}function JS(i){switch(i.tag){case 0:case 11:case 15:Jc(i),i.flags&2048&&Da(9,i,i.return);break;case 3:Jc(i);break;case 12:Jc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,rh(i)):Jc(i);break;default:Jc(i)}}function rh(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];Qi=l,e0(l,i)}QS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:Da(8,s,s.return),rh(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,rh(s));break;default:rh(s)}i=i.sibling}}function e0(i,s){for(;Qi!==null;){var a=Qi;switch(a.tag){case 0:case 11:case 15:Da(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:jc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Qi=l;else e:for(a=i;Qi!==null;){l=Qi;var h=l.sibling,p=l.return;if(KS(l),l===a){Qi=null;break e}if(h!==null){h.return=p,Qi=h;break e}Qi=p}}}var ZE={getCacheForType:function(i){var s=un(Mi),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return un(Mi).controller.signal}},QE=typeof WeakMap=="function"?WeakMap:Map,jt=0,Zt=null,kt=null,Et=0,Ft=0,Xn=null,Ra=!1,Ol=!1,Nm=!1,$r=0,gi=0,Na=0,Ho=0,Mm=0,Gn=0,Bl=0,eu=null,Hn=null,Am=!1,ah=0,t0=0,oh=1/0,lh=null,Ma=null,Fi=0,Aa=null,jl=null,Kr=0,Lm=0,Om=null,i0=null,tu=0,Bm=null;function Zn(){return(jt&2)!==0&&Et!==0?Et&-Et:O.T!==null?Um():pi()}function n0(){if(Gn===0)if((Et&536870912)===0||Rt){var i=ut;ut<<=1,(ut&3932160)===0&&(ut=262144),Gn=i}else Gn=536870912;return i=Vn.current,i!==null&&(i.flags|=32),Gn}function Un(i,s,a){(i===Zt&&(Ft===2||Ft===9)||i.cancelPendingCommit!==null)&&(Il(i,0),La(i,Et,Gn,!1)),lt(i,a),((jt&2)===0||i!==Zt)&&(i===Zt&&((jt&2)===0&&(Ho|=a),gi===4&&La(i,Et,Gn,!1)),or(i))}function s0(i,s,a){if((jt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Si(i,s),h=l?t2(i,s):Im(i,s,!0),p=l;do{if(h===0){Ol&&!l&&La(i,s,0,!1);break}else{if(a=i.current.alternate,p&&!JE(a)){h=Im(i,s,!1),p=!1;continue}if(h===2){if(p=s,i.errorRecoveryDisabledLanes&p)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){s=y;e:{var D=i;h=eu;var j=D.current.memoizedState.isDehydrated;if(j&&(Il(D,y).flags|=256),y=Im(D,y,!1),y!==2){if(Nm&&!j){D.errorRecoveryDisabledLanes|=p,Ho|=p,h=4;break e}p=Hn,Hn=h,p!==null&&(Hn===null?Hn=p:Hn.push.apply(Hn,p))}h=y}if(p=!1,h!==2)continue}}if(h===1){Il(i,0),La(i,s,0,!0);break}e:{switch(l=i,p=h,p){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:La(l,s,Gn,!Ra);break e;case 2:Hn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(h=ah+300-$e(),10<h)){if(La(l,s,Gn,!Ra),Qt(l,0,!0)!==0)break e;Kr=s,l.timeoutHandle=B0(r0.bind(null,l,a,Hn,lh,Am,s,Gn,Ho,Bl,Ra,p,"Throttled",-0,0),h);break e}r0(l,a,Hn,lh,Am,s,Gn,Ho,Bl,Ra,p,null,-0,0)}}break}while(!0);or(i)}function r0(i,s,a,l,h,p,y,D,j,re,_e,xe,ue,fe){if(i.timeoutHandle=-1,xe=s.subtreeFlags,xe&8192||(xe&16785408)===16785408){xe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ln},ZS(s,p,xe);var Ke=(p&62914560)===p?ah-$e():(p&4194048)===p?t0-$e():0;if(Ke=I2(xe,Ke),Ke!==null){Kr=p,i.cancelPendingCommit=Ke(f0.bind(null,i,s,p,a,l,h,y,D,j,_e,xe,null,ue,fe)),La(i,p,y,!re);return}}f0(i,s,p,a,l,h,y,D,j)}function JE(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var h=a[l],p=h.getSnapshot;h=h.value;try{if(!En(p(),h))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function La(i,s,a,l){s&=~Mm,s&=~Ho,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var h=s;0<h;){var p=31-ct(h),y=1<<p;l[p]=-1,h&=~y}a!==0&&fi(i,a,s)}function ch(){return(jt&6)===0?(iu(0),!1):!0}function jm(){if(kt!==null){if(Ft===0)var i=kt.return;else i=kt,Lr=Mo=null,Qp(i),El=null,Pc=0,i=kt;for(;i!==null;)jS(i.alternate,i),i=i.return;kt=null}}function Il(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,b2(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Kr=0,jm(),Zt=i,kt=a=Mr(i.current,null),Et=s,Ft=0,Xn=null,Ra=!1,Ol=Si(i,s),Nm=!1,Bl=Gn=Mm=Ho=Na=gi=0,Hn=eu=null,Am=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var h=31-ct(l),p=1<<h;s|=i[h],l&=~p}return $r=s,Nd(),a}function a0(i,s){dt=null,O.H=qc,s===Tl||s===Pd?(s=wy(),Ft=3):s===Hp?(s=wy(),Ft=4):Ft=s===pm?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Xn=s,kt===null&&(gi=1,Qd(i,cs(s,i.current)))}function o0(){var i=Vn.current;return i===null?!0:(Et&4194048)===Et?fs===null:(Et&62914560)===Et||(Et&536870912)!==0?i===fs:!1}function l0(){var i=O.H;return O.H=qc,i===null?qc:i}function c0(){var i=O.A;return O.A=ZE,i}function uh(){gi=4,Ra||(Et&4194048)!==Et&&Vn.current!==null||(Ol=!0),(Na&134217727)===0&&(Ho&134217727)===0||Zt===null||La(Zt,Et,Gn,!1)}function Im(i,s,a){var l=jt;jt|=2;var h=l0(),p=c0();(Zt!==i||Et!==s)&&(lh=null,Il(i,s)),s=!1;var y=gi;e:do try{if(Ft!==0&&kt!==null){var D=kt,j=Xn;switch(Ft){case 8:jm(),y=6;break e;case 3:case 2:case 9:case 6:Vn.current===null&&(s=!0);var re=Ft;if(Ft=0,Xn=null,Pl(i,D,j,re),a&&Ol){y=0;break e}break;default:re=Ft,Ft=0,Xn=null,Pl(i,D,j,re)}}e2(),y=gi;break}catch(_e){a0(i,_e)}while(!0);return s&&i.shellSuspendCounter++,Lr=Mo=null,jt=l,O.H=h,O.A=p,kt===null&&(Zt=null,Et=0,Nd()),y}function e2(){for(;kt!==null;)u0(kt)}function t2(i,s){var a=jt;jt|=2;var l=l0(),h=c0();Zt!==i||Et!==s?(lh=null,oh=$e()+500,Il(i,s)):Ol=Si(i,s);e:do try{if(Ft!==0&&kt!==null){s=kt;var p=Xn;t:switch(Ft){case 1:Ft=0,Xn=null,Pl(i,s,p,1);break;case 2:case 9:if(yy(p)){Ft=0,Xn=null,d0(s);break}s=function(){Ft!==2&&Ft!==9||Zt!==i||(Ft=7),or(i)},p.then(s,s);break e;case 3:Ft=7;break e;case 4:Ft=5;break e;case 7:yy(p)?(Ft=0,Xn=null,d0(s)):(Ft=0,Xn=null,Pl(i,s,p,7));break;case 5:var y=null;switch(kt.tag){case 26:y=kt.memoizedState;case 5:case 27:var D=kt;if(y?G0(y):D.stateNode.complete){Ft=0,Xn=null;var j=D.sibling;if(j!==null)kt=j;else{var re=D.return;re!==null?(kt=re,dh(re)):kt=null}break t}}Ft=0,Xn=null,Pl(i,s,p,5);break;case 6:Ft=0,Xn=null,Pl(i,s,p,6);break;case 8:jm(),gi=6;break e;default:throw Error(r(462))}}i2();break}catch(_e){a0(i,_e)}while(!0);return Lr=Mo=null,O.H=l,O.A=h,jt=a,kt!==null?0:(Zt=null,Et=0,Nd(),gi)}function i2(){for(;kt!==null&&!je();)u0(kt)}function u0(i){var s=OS(i.alternate,i,$r);i.memoizedProps=i.pendingProps,s===null?dh(i):kt=s}function d0(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=DS(a,s,s.pendingProps,s.type,void 0,Et);break;case 11:s=DS(a,s,s.pendingProps,s.type.render,s.ref,Et);break;case 5:Qp(s);default:jS(a,s),s=kt=cy(s,$r),s=OS(a,s,$r)}i.memoizedProps=i.pendingProps,s===null?dh(i):kt=s}function Pl(i,s,a,l){Lr=Mo=null,Qp(s),El=null,Pc=0;var h=s.return;try{if(KE(i,h,s,a,Et)){gi=1,Qd(i,cs(a,i.current)),kt=null;return}}catch(p){if(h!==null)throw kt=h,p;gi=1,Qd(i,cs(a,i.current)),kt=null;return}s.flags&32768?(Rt||l===1?i=!0:Ol||(Et&536870912)!==0?i=!1:(Ra=i=!0,(l===2||l===9||l===3||l===6)&&(l=Vn.current,l!==null&&l.tag===13&&(l.flags|=16384))),h0(s,i)):dh(s)}function dh(i){var s=i;do{if((s.flags&32768)!==0){h0(s,Ra);return}i=s.return;var a=VE(s.alternate,s,$r);if(a!==null){kt=a;return}if(s=s.sibling,s!==null){kt=s;return}kt=s=i}while(s!==null);gi===0&&(gi=5)}function h0(i,s){do{var a=YE(i.alternate,i);if(a!==null){a.flags&=32767,kt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){kt=i;return}kt=i=a}while(i!==null);gi=6,kt=null}function f0(i,s,a,l,h,p,y,D,j){i.cancelPendingCommit=null;do hh();while(Fi!==0);if((jt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(p=s.lanes|s.childLanes,p|=kp,xt(i,a,p,y,D,j),i===Zt&&(kt=Zt=null,Et=0),jl=s,Aa=i,Kr=a,Lm=p,Om=h,i0=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,a2(_t,function(){return _0(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=O.T,O.T=null,h=R.p,R.p=2,y=jt,jt|=4;try{XE(i,s,a)}finally{jt=y,R.p=h,O.T=l}}Fi=1,p0(),m0(),g0()}}function p0(){if(Fi===1){Fi=0;var i=Aa,s=jl,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var l=R.p;R.p=2;var h=jt;jt|=4;try{YS(s,i);var p=Xm,y=Dd(i.containerInfo),D=p.focusedElem,j=p.selectionRange;if(y!==D&&D&&D.ownerDocument&&Ed(D.ownerDocument.documentElement,D)){if(j!==null&&Eo(D)){var re=j.start,_e=j.end;if(_e===void 0&&(_e=re),"selectionStart"in D)D.selectionStart=re,D.selectionEnd=Math.min(_e,D.value.length);else{var xe=D.ownerDocument||document,ue=xe&&xe.defaultView||window;if(ue.getSelection){var fe=ue.getSelection(),Ke=D.textContent.length,tt=Math.min(j.start,Ke),Yt=j.end===void 0?tt:Math.min(j.end,Ke);!fe.extend&&tt>Yt&&(y=Yt,Yt=tt,tt=y);var Q=Td(D,tt),$=Td(D,Yt);if(Q&&$&&(fe.rangeCount!==1||fe.anchorNode!==Q.node||fe.anchorOffset!==Q.offset||fe.focusNode!==$.node||fe.focusOffset!==$.offset)){var se=xe.createRange();se.setStart(Q.node,Q.offset),fe.removeAllRanges(),tt>Yt?(fe.addRange(se),fe.extend($.node,$.offset)):(se.setEnd($.node,$.offset),fe.addRange(se))}}}}for(xe=[],fe=D;fe=fe.parentNode;)fe.nodeType===1&&xe.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<xe.length;D++){var be=xe[D];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}Ch=!!Ym,Xm=Ym=null}finally{jt=h,R.p=l,O.T=a}}i.current=s,Fi=2}}function m0(){if(Fi===2){Fi=0;var i=Aa,s=jl,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var l=R.p;R.p=2;var h=jt;jt|=4;try{$S(i,s.alternate,s)}finally{jt=h,R.p=l,O.T=a}}Fi=3}}function g0(){if(Fi===4||Fi===3){Fi=0,Ve();var i=Aa,s=jl,a=Kr,l=i0;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Fi=5:(Fi=0,jl=Aa=null,v0(i,i.pendingLanes));var h=i.pendingLanes;if(h===0&&(Ma=null),Yi(a),s=s.stateNode,et&&typeof et.onCommitFiberRoot=="function")try{et.onCommitFiberRoot(st,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=O.T,h=R.p,R.p=2,O.T=null;try{for(var p=i.onRecoverableError,y=0;y<l.length;y++){var D=l[y];p(D.value,{componentStack:D.stack})}}finally{O.T=s,R.p=h}}(Kr&3)!==0&&hh(),or(i),h=i.pendingLanes,(a&261930)!==0&&(h&42)!==0?i===Bm?tu++:(tu=0,Bm=i):tu=0,iu(0)}}function v0(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,jc(s)))}function hh(){return p0(),m0(),g0(),_0()}function _0(){if(Fi!==5)return!1;var i=Aa,s=Lm;Lm=0;var a=Yi(Kr),l=O.T,h=R.p;try{R.p=32>a?32:a,O.T=null,a=Om,Om=null;var p=Aa,y=Kr;if(Fi=0,jl=Aa=null,Kr=0,(jt&6)!==0)throw Error(r(331));var D=jt;if(jt|=4,JS(p.current),GS(p,p.current,y,a),jt=D,iu(0,!1),et&&typeof et.onPostCommitFiberRoot=="function")try{et.onPostCommitFiberRoot(st,p)}catch{}return!0}finally{R.p=h,O.T=l,v0(i,s)}}function b0(i,s,a){s=cs(a,s),s=fm(i.stateNode,s,2),i=ka(i,s,2),i!==null&&(lt(i,2),or(i))}function $t(i,s,a){if(i.tag===3)b0(i,i,a);else for(;s!==null;){if(s.tag===3){b0(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Ma===null||!Ma.has(l))){i=cs(a,i),a=yS(2),l=ka(s,a,2),l!==null&&(SS(a,l,s,i),lt(l,2),or(l));break}}s=s.return}}function Pm(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new QE;var h=new Set;l.set(s,h)}else h=l.get(s),h===void 0&&(h=new Set,l.set(s,h));h.has(a)||(Nm=!0,h.add(a),i=n2.bind(null,i,s,a),s.then(i,i))}function n2(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Zt===i&&(Et&a)===a&&(gi===4||gi===3&&(Et&62914560)===Et&&300>$e()-ah?(jt&2)===0&&Il(i,0):Mm|=a,Bl===Et&&(Bl=0)),or(i)}function y0(i,s){s===0&&(s=ni()),i=Do(i,s),i!==null&&(lt(i,s),or(i))}function s2(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),y0(i,a)}function r2(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,h=i.memoizedState;h!==null&&(a=h.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),y0(i,a)}function a2(i,s){return De(i,s)}var fh=null,zl=null,zm=!1,ph=!1,Hm=!1,Oa=0;function or(i){i!==zl&&i.next===null&&(zl===null?fh=zl=i:zl=zl.next=i),ph=!0,zm||(zm=!0,l2())}function iu(i,s){if(!Hm&&ph){Hm=!0;do for(var a=!1,l=fh;l!==null;){if(i!==0){var h=l.pendingLanes;if(h===0)var p=0;else{var y=l.suspendedLanes,D=l.pingedLanes;p=(1<<31-ct(42|i)+1)-1,p&=h&~(y&~D),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(a=!0,C0(l,p))}else p=Et,p=Qt(l,l===Zt?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(p&3)===0||Si(l,p)||(a=!0,C0(l,p));l=l.next}while(a);Hm=!1}}function o2(){S0()}function S0(){ph=zm=!1;var i=0;Oa!==0&&_2()&&(i=Oa);for(var s=$e(),a=null,l=fh;l!==null;){var h=l.next,p=w0(l,s);p===0?(l.next=null,a===null?fh=h:a.next=h,h===null&&(zl=a)):(a=l,(i!==0||(p&3)!==0)&&(ph=!0)),l=h}Fi!==0&&Fi!==5||iu(i),Oa!==0&&(Oa=0)}function w0(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,h=i.expirationTimes,p=i.pendingLanes&-62914561;0<p;){var y=31-ct(p),D=1<<y,j=h[y];j===-1?((D&a)===0||(D&l)!==0)&&(h[y]=Ii(D,s)):j<=s&&(i.expiredLanes|=D),p&=~D}if(s=Zt,a=Et,a=Qt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Ft===2||Ft===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ee(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Si(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&Ee(l),Yi(a)){case 2:case 8:a=Nt;break;case 32:a=_t;break;case 268435456:a=oi;break;default:a=_t}return l=x0.bind(null,i),a=De(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&Ee(l),i.callbackPriority=2,i.callbackNode=null,2}function x0(i,s){if(Fi!==0&&Fi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(hh()&&i.callbackNode!==a)return null;var l=Et;return l=Qt(i,i===Zt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(s0(i,l,s),w0(i,$e()),i.callbackNode!=null&&i.callbackNode===a?x0.bind(null,i):null)}function C0(i,s){if(hh())return null;s0(i,s,!0)}function l2(){y2(function(){(jt&6)!==0?De(wt,o2):S0()})}function Um(){if(Oa===0){var i=Cl;i===0&&(i=ze,ze<<=1,(ze&261888)===0&&(ze=256)),Oa=i}return Oa}function k0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:ns(""+i)}function T0(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function c2(i,s,a,l,h){if(s==="submit"&&a&&a.stateNode===h){var p=k0((h[xi]||null).action),y=l.submitter;y&&(s=(s=y[xi]||null)?k0(s.formAction):y.getAttribute("formAction"),s!==null&&(p=s,y=null));var D=new Bs("action","action",null,l,h);i.push({event:D,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Oa!==0){var j=y?T0(h,y):new FormData(h);om(a,{pending:!0,data:j,method:h.method,action:p},null,j)}}else typeof p=="function"&&(D.preventDefault(),j=y?T0(h,y):new FormData(h),om(a,{pending:!0,data:j,method:h.method,action:p},p,j))},currentTarget:h}]})}}for(var Fm=0;Fm<Cp.length;Fm++){var $m=Cp[Fm],u2=$m.toLowerCase(),d2=$m[0].toUpperCase()+$m.slice(1);Hs(u2,"on"+d2)}Hs(Gt,"onAnimationEnd"),Hs(Ut,"onAnimationIteration"),Hs(zt,"onAnimationStart"),Hs("dblclick","onDoubleClick"),Hs("focusin","onFocus"),Hs("focusout","onBlur"),Hs(ir,"onTransitionRun"),Hs(vl,"onTransitionStart"),Hs(nr,"onTransitionCancel"),Hs(Ac,"onTransitionEnd"),Kn("onMouseEnter",["mouseout","mouseover"]),Kn("onMouseLeave",["mouseout","mouseover"]),Kn("onPointerEnter",["pointerout","pointerover"]),Kn("onPointerLeave",["pointerout","pointerover"]),Wt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Wt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Wt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Wt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Wt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Wt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var nu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),h2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(nu));function E0(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],h=l.event;l=l.listeners;e:{var p=void 0;if(s)for(var y=l.length-1;0<=y;y--){var D=l[y],j=D.instance,re=D.currentTarget;if(D=D.listener,j!==p&&h.isPropagationStopped())break e;p=D,h.currentTarget=re;try{p(h)}catch(_e){Rd(_e)}h.currentTarget=null,p=j}else for(y=0;y<l.length;y++){if(D=l[y],j=D.instance,re=D.currentTarget,D=D.listener,j!==p&&h.isPropagationStopped())break e;p=D,h.currentTarget=re;try{p(h)}catch(_e){Rd(_e)}h.currentTarget=null,p=j}}}}function Tt(i,s){var a=s[wn];a===void 0&&(a=s[wn]=new Set);var l=i+"__bubble";a.has(l)||(D0(s,i,2,!1),a.add(l))}function Km(i,s,a){var l=0;s&&(l|=4),D0(a,i,l,s)}var mh="_reactListening"+Math.random().toString(36).slice(2);function Wm(i){if(!i[mh]){i[mh]=!0,aa.forEach(function(a){a!=="selectionchange"&&(h2.has(a)||Km(a,!1,i),Km(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[mh]||(s[mh]=!0,Km("selectionchange",!1,s))}}function D0(i,s,a,l){switch(nw(s)){case 2:var h=H2;break;case 8:h=U2;break;default:h=ag}a=h.bind(null,s,a,i),h=void 0,!ua||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),l?h!==void 0?i.addEventListener(s,a,{capture:!0,passive:h}):i.addEventListener(s,a,!0):h!==void 0?i.addEventListener(s,a,{passive:h}):i.addEventListener(s,a,!1)}function qm(i,s,a,l,h){var p=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var y=l.tag;if(y===3||y===4){var D=l.stateNode.containerInfo;if(D===h)break;if(y===4)for(y=l.return;y!==null;){var j=y.tag;if((j===3||j===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;D!==null;){if(y=$n(D),y===null)return;if(j=y.tag,j===5||j===6||j===26||j===27){l=p=y;continue e}D=D.parentNode}}l=l.return}vo(function(){var re=p,_e=go(a),xe=[];e:{var ue=Lc.get(i);if(ue!==void 0){var fe=Bs,Ke=i;switch(i){case"keypress":if(Os(a)===0)break e;case"keydown":case"keyup":fe=kc;break;case"focusin":Ke="focus",fe=Bn;break;case"focusout":Ke="blur",fe=Bn;break;case"beforeblur":case"afterblur":fe=Bn;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=hl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=da;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=Tc;break;case Gt:case Ut:case zt:fe=Dr;break;case Ac:fe=Is;break;case"scroll":case"scrollend":fe=xc;break;case"wheel":fe=Ec;break;case"copy":case"cut":case"paste":fe=yo;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=jn;break;case"toggle":case"beforetoggle":fe=T}var tt=(s&4)!==0,Yt=!tt&&(i==="scroll"||i==="scrollend"),Q=tt?ue!==null?ue+"Capture":null:ue;tt=[];for(var $=re,se;$!==null;){var be=$;if(se=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||se===null||Q===null||(be=Wn($,Q),be!=null&&tt.push(su($,be,se))),Yt)break;$=$.return}0<tt.length&&(ue=new fe(ue,Ke,null,a,_e),xe.push({event:ue,listeners:tt}))}}if((s&7)===0){e:{if(ue=i==="mouseover"||i==="pointerover",fe=i==="mouseout"||i==="pointerout",ue&&a!==Zi&&(Ke=a.relatedTarget||a.fromElement)&&($n(Ke)||Ke[is]))break e;if((fe||ue)&&(ue=_e.window===_e?_e:(ue=_e.ownerDocument)?ue.defaultView||ue.parentWindow:window,fe?(Ke=a.relatedTarget||a.toElement,fe=re,Ke=Ke?$n(Ke):null,Ke!==null&&(Yt=c(Ke),tt=Ke.tag,Ke!==Yt||tt!==5&&tt!==27&&tt!==6)&&(Ke=null)):(fe=null,Ke=re),fe!==Ke)){if(tt=hl,be="onMouseLeave",Q="onMouseEnter",$="mouse",(i==="pointerout"||i==="pointerover")&&(tt=jn,be="onPointerLeave",Q="onPointerEnter",$="pointer"),Yt=fe==null?ue:xn(fe),se=Ke==null?ue:xn(Ke),ue=new tt(be,$+"leave",fe,a,_e),ue.target=Yt,ue.relatedTarget=se,be=null,$n(_e)===re&&(tt=new tt(Q,$+"enter",Ke,a,_e),tt.target=se,tt.relatedTarget=Yt,be=tt),Yt=be,fe&&Ke)t:{for(tt=f2,Q=fe,$=Ke,se=0,be=Q;be;be=tt(be))se++;be=0;for(var Qe=$;Qe;Qe=tt(Qe))be++;for(;0<se-be;)Q=tt(Q),se--;for(;0<be-se;)$=tt($),be--;for(;se--;){if(Q===$||$!==null&&Q===$.alternate){tt=Q;break t}Q=tt(Q),$=tt($)}tt=null}else tt=null;fe!==null&&R0(xe,ue,fe,tt,!1),Ke!==null&&Yt!==null&&R0(xe,Yt,Ke,tt,!0)}}e:{if(ue=re?xn(re):window,fe=ue.nodeName&&ue.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ue.type==="file")var At=Nc;else if(Co(ue))if(xd)At=Sp;else{At=yp;var qe=bp}else fe=ue.nodeName,!fe||fe.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?re&&Ns(re.elementType)&&(At=Nc):At=Rr;if(At&&(At=At(i,re))){Rc(xe,At,a,_e);break e}qe&&qe(i,ue,re),i==="focusout"&&re&&ue.type==="number"&&re.memoizedProps.value!=null&&po(ue,"number",ue.value)}switch(qe=re?xn(re):window,i){case"focusin":(Co(qe)||qe.contentEditable==="true")&&(Nr=qe,k=re,H=null);break;case"focusout":H=k=Nr=null;break;case"mousedown":Me=!0;break;case"contextmenu":case"mouseup":case"dragend":Me=!1,Ye(xe,a,_e);break;case"selectionchange":if(xp)break;case"keydown":case"keyup":Ye(xe,a,_e)}var pt;if(G)e:{switch(i){case"compositionstart":var Dt="onCompositionStart";break e;case"compositionend":Dt="onCompositionEnd";break e;case"compositionupdate":Dt="onCompositionUpdate";break e}Dt=void 0}else Tn?ht(i,a)&&(Dt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Dt="onCompositionStart");Dt&&(Se&&a.locale!=="ko"&&(Tn||Dt!=="onCompositionStart"?Dt==="onCompositionEnd"&&Tn&&(pt=rt()):(On=_e,_n="value"in On?On.value:On.textContent,Tn=!0)),qe=gh(re,Dt),0<qe.length&&(Dt=new pa(Dt,i,null,a,_e),xe.push({event:Dt,listeners:qe}),pt?Dt.data=pt:(pt=Mt(a),pt!==null&&(Dt.data=pt)))),(pt=ce?ci(i,a):Ps(i,a))&&(Dt=gh(re,"onBeforeInput"),0<Dt.length&&(qe=new pa("onBeforeInput","beforeinput",null,a,_e),xe.push({event:qe,listeners:Dt}),qe.data=pt)),c2(xe,i,re,a,_e)}E0(xe,s)})}function su(i,s,a){return{instance:i,listener:s,currentTarget:a}}function gh(i,s){for(var a=s+"Capture",l=[];i!==null;){var h=i,p=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||p===null||(h=Wn(i,a),h!=null&&l.unshift(su(i,h,p)),h=Wn(i,s),h!=null&&l.push(su(i,h,p))),i.tag===3)return l;i=i.return}return[]}function f2(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function R0(i,s,a,l,h){for(var p=s._reactName,y=[];a!==null&&a!==l;){var D=a,j=D.alternate,re=D.stateNode;if(D=D.tag,j!==null&&j===l)break;D!==5&&D!==26&&D!==27||re===null||(j=re,h?(re=Wn(a,p),re!=null&&y.unshift(su(a,re,j))):h||(re=Wn(a,p),re!=null&&y.push(su(a,re,j)))),a=a.return}y.length!==0&&i.push({event:s,listeners:y})}var p2=/\r\n?/g,m2=/\u0000|\uFFFD/g;function N0(i){return(typeof i=="string"?i:""+i).replace(p2,`
10
+ `).replace(m2,"")}function M0(i,s){return s=N0(s),N0(i)===s}function Vt(i,s,a,l,h,p){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||Gi(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&Gi(i,""+l);break;case"className":xr(i,"class",l);break;case"tabIndex":xr(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":xr(i,a,l);break;case"style":vn(i,l,p);break;case"data":if(s!=="object"){xr(i,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ns(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(a==="formAction"?(s!=="input"&&Vt(i,s,"name",h.name,h,null),Vt(i,s,"formEncType",h.formEncType,h,null),Vt(i,s,"formMethod",h.formMethod,h,null),Vt(i,s,"formTarget",h.formTarget,h,null)):(Vt(i,s,"encType",h.encType,h,null),Vt(i,s,"method",h.method,h,null),Vt(i,s,"target",h.target,h,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ns(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Ln);break;case"onScroll":l!=null&&Tt("scroll",i);break;case"onScrollEnd":l!=null&&Tt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=ns(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":Tt("beforetoggle",i),Tt("toggle",i),Zs(i,"popover",l);break;case"xlinkActuate":Cn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Cn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Cn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Cn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Cn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Cn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Cn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Cn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Cn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Zs(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=ul.get(a)||a,Zs(i,a,l))}}function Vm(i,s,a,l,h,p){switch(a){case"style":vn(i,l,p);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(h.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Gi(i,l):(typeof l=="number"||typeof l=="bigint")&&Gi(i,""+l);break;case"onScroll":l!=null&&Tt("scroll",i);break;case"onScrollEnd":l!=null&&Tt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Ln);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!br.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),s=a.slice(2,h?a.length-7:void 0),p=i[xi]||null,p=p!=null?p[a]:null,typeof p=="function"&&i.removeEventListener(s,p,h),typeof l=="function")){typeof p!="function"&&p!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,h);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Zs(i,a,l)}}}function hn(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Tt("error",i),Tt("load",i);var l=!1,h=!1,p;for(p in a)if(a.hasOwnProperty(p)){var y=a[p];if(y!=null)switch(p){case"src":l=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Vt(i,s,p,y,a,null)}}h&&Vt(i,s,"srcSet",a.srcSet,a,null),l&&Vt(i,s,"src",a.src,a,null);return;case"input":Tt("invalid",i);var D=p=y=h=null,j=null,re=null;for(l in a)if(a.hasOwnProperty(l)){var _e=a[l];if(_e!=null)switch(l){case"name":h=_e;break;case"type":y=_e;break;case"checked":j=_e;break;case"defaultChecked":re=_e;break;case"value":p=_e;break;case"defaultValue":D=_e;break;case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(r(137,s));break;default:Vt(i,s,l,_e,a,null)}}Cr(i,p,D,j,re,y,h,!1);return;case"select":Tt("invalid",i),l=y=p=null;for(h in a)if(a.hasOwnProperty(h)&&(D=a[h],D!=null))switch(h){case"value":p=D;break;case"defaultValue":y=D;break;case"multiple":l=D;default:Vt(i,s,h,D,a,null)}s=p,a=y,i.multiple=!!l,s!=null?kn(i,!!l,s,!1):a!=null&&kn(i,!!l,a,!0);return;case"textarea":Tt("invalid",i),p=h=l=null;for(y in a)if(a.hasOwnProperty(y)&&(D=a[y],D!=null))switch(y){case"value":l=D;break;case"defaultValue":h=D;break;case"children":p=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(r(91));break;default:Vt(i,s,y,D,a,null)}ca(i,l,h,p);return;case"option":for(j in a)a.hasOwnProperty(j)&&(l=a[j],l!=null)&&(j==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":Vt(i,s,j,l,a,null));return;case"dialog":Tt("beforetoggle",i),Tt("toggle",i),Tt("cancel",i),Tt("close",i);break;case"iframe":case"object":Tt("load",i);break;case"video":case"audio":for(l=0;l<nu.length;l++)Tt(nu[l],i);break;case"image":Tt("error",i),Tt("load",i);break;case"details":Tt("toggle",i);break;case"embed":case"source":case"link":Tt("error",i),Tt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(re in a)if(a.hasOwnProperty(re)&&(l=a[re],l!=null))switch(re){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Vt(i,s,re,l,a,null)}return;default:if(Ns(s)){for(_e in a)a.hasOwnProperty(_e)&&(l=a[_e],l!==void 0&&Vm(i,s,_e,l,a,void 0));return}}for(D in a)a.hasOwnProperty(D)&&(l=a[D],l!=null&&Vt(i,s,D,l,a,null))}function g2(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,p=null,y=null,D=null,j=null,re=null,_e=null;for(fe in a){var xe=a[fe];if(a.hasOwnProperty(fe)&&xe!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":j=xe;default:l.hasOwnProperty(fe)||Vt(i,s,fe,null,l,xe)}}for(var ue in l){var fe=l[ue];if(xe=a[ue],l.hasOwnProperty(ue)&&(fe!=null||xe!=null))switch(ue){case"type":p=fe;break;case"name":h=fe;break;case"checked":re=fe;break;case"defaultChecked":_e=fe;break;case"value":y=fe;break;case"defaultValue":D=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,s));break;default:fe!==xe&&Vt(i,s,ue,fe,l,xe)}}la(i,y,D,j,re,_e,p,h);return;case"select":fe=y=D=ue=null;for(p in a)if(j=a[p],a.hasOwnProperty(p)&&j!=null)switch(p){case"value":break;case"multiple":fe=j;default:l.hasOwnProperty(p)||Vt(i,s,p,null,l,j)}for(h in l)if(p=l[h],j=a[h],l.hasOwnProperty(h)&&(p!=null||j!=null))switch(h){case"value":ue=p;break;case"defaultValue":D=p;break;case"multiple":y=p;default:p!==j&&Vt(i,s,h,p,l,j)}s=D,a=y,l=fe,ue!=null?kn(i,!!a,ue,!1):!!l!=!!a&&(s!=null?kn(i,!!a,s,!0):kn(i,!!a,a?[]:"",!1));return;case"textarea":fe=ue=null;for(D in a)if(h=a[D],a.hasOwnProperty(D)&&h!=null&&!l.hasOwnProperty(D))switch(D){case"value":break;case"children":break;default:Vt(i,s,D,null,l,h)}for(y in l)if(h=l[y],p=a[y],l.hasOwnProperty(y)&&(h!=null||p!=null))switch(y){case"value":ue=h;break;case"defaultValue":fe=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(91));break;default:h!==p&&Vt(i,s,y,h,l,p)}mo(i,ue,fe);return;case"option":for(var Ke in a)ue=a[Ke],a.hasOwnProperty(Ke)&&ue!=null&&!l.hasOwnProperty(Ke)&&(Ke==="selected"?i.selected=!1:Vt(i,s,Ke,null,l,ue));for(j in l)ue=l[j],fe=a[j],l.hasOwnProperty(j)&&ue!==fe&&(ue!=null||fe!=null)&&(j==="selected"?i.selected=ue&&typeof ue!="function"&&typeof ue!="symbol":Vt(i,s,j,ue,l,fe));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var tt in a)ue=a[tt],a.hasOwnProperty(tt)&&ue!=null&&!l.hasOwnProperty(tt)&&Vt(i,s,tt,null,l,ue);for(re in l)if(ue=l[re],fe=a[re],l.hasOwnProperty(re)&&ue!==fe&&(ue!=null||fe!=null))switch(re){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(r(137,s));break;default:Vt(i,s,re,ue,l,fe)}return;default:if(Ns(s)){for(var Yt in a)ue=a[Yt],a.hasOwnProperty(Yt)&&ue!==void 0&&!l.hasOwnProperty(Yt)&&Vm(i,s,Yt,void 0,l,ue);for(_e in l)ue=l[_e],fe=a[_e],!l.hasOwnProperty(_e)||ue===fe||ue===void 0&&fe===void 0||Vm(i,s,_e,ue,l,fe);return}}for(var Q in a)ue=a[Q],a.hasOwnProperty(Q)&&ue!=null&&!l.hasOwnProperty(Q)&&Vt(i,s,Q,null,l,ue);for(xe in l)ue=l[xe],fe=a[xe],!l.hasOwnProperty(xe)||ue===fe||ue==null&&fe==null||Vt(i,s,xe,ue,l,fe)}function A0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function v2(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var h=a[l],p=h.transferSize,y=h.initiatorType,D=h.duration;if(p&&D&&A0(y)){for(y=0,D=h.responseEnd,l+=1;l<a.length;l++){var j=a[l],re=j.startTime;if(re>D)break;var _e=j.transferSize,xe=j.initiatorType;_e&&A0(xe)&&(j=j.responseEnd,y+=_e*(j<D?1:(D-re)/(j-re)))}if(--l,s+=8*(p+y)/(h.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Ym=null,Xm=null;function vh(i){return i.nodeType===9?i:i.ownerDocument}function L0(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function O0(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function Gm(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Zm=null;function _2(){var i=window.event;return i&&i.type==="popstate"?i===Zm?!1:(Zm=i,!0):(Zm=null,!1)}var B0=typeof setTimeout=="function"?setTimeout:void 0,b2=typeof clearTimeout=="function"?clearTimeout:void 0,j0=typeof Promise=="function"?Promise:void 0,y2=typeof queueMicrotask=="function"?queueMicrotask:typeof j0<"u"?function(i){return j0.resolve(null).then(i).catch(S2)}:B0;function S2(i){setTimeout(function(){throw i})}function Ba(i){return i==="head"}function I0(i,s){var a=s,l=0;do{var h=a.nextSibling;if(i.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(h),$l(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")ru(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,ru(a);for(var p=a.firstChild;p;){var y=p.nextSibling,D=p.nodeName;p[on]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&p.rel.toLowerCase()==="stylesheet"||a.removeChild(p),p=y}}else a==="body"&&ru(i.ownerDocument.body);a=h}while(a);$l(s)}function P0(i,s){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function Qm(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Qm(a),Xs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function w2(i,s,a,l){for(;i.nodeType===1;){var h=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[on])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(p=i.getAttribute("rel"),p==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(p!==h.rel||i.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||i.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||i.getAttribute("title")!==(h.title==null?null:h.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(p=i.getAttribute("src"),(p!==(h.src==null?null:h.src)||i.getAttribute("type")!==(h.type==null?null:h.type)||i.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&p&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var p=h.name==null?null:""+h.name;if(h.type==="hidden"&&i.getAttribute("name")===p)return i}else return i;if(i=ps(i.nextSibling),i===null)break}return null}function x2(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ps(i.nextSibling),i===null))return null;return i}function z0(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=ps(i.nextSibling),i===null))return null;return i}function Jm(i){return i.data==="$?"||i.data==="$~"}function eg(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function C2(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function ps(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var tg=null;function H0(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return ps(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function U0(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function F0(i,s,a){switch(s=vh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function ru(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Xs(i)}var ms=new Map,$0=new Set;function _h(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Wr=R.d;R.d={f:k2,r:T2,D:E2,C:D2,L:R2,m:N2,X:A2,S:M2,M:L2};function k2(){var i=Wr.f(),s=ch();return i||s}function T2(i){var s=Ts(i);s!==null&&s.tag===5&&s.type==="form"?aS(s):Wr.r(i)}var Hl=typeof document>"u"?null:document;function K0(i,s,a){var l=Hl;if(l&&typeof s=="string"&&s){var h=zi(s);h='link[rel="'+i+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),$0.has(h)||($0.add(h),i={rel:i,crossOrigin:a,href:s},l.querySelector(h)===null&&(s=l.createElement("link"),hn(s,"link",i),Ht(s),l.head.appendChild(s)))}}function E2(i){Wr.D(i),K0("dns-prefetch",i,null)}function D2(i,s){Wr.C(i,s),K0("preconnect",i,s)}function R2(i,s,a){Wr.L(i,s,a);var l=Hl;if(l&&i&&s){var h='link[rel="preload"][as="'+zi(s)+'"]';s==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+zi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+zi(a.imageSizes)+'"]')):h+='[href="'+zi(i)+'"]';var p=h;switch(s){case"style":p=Ul(i);break;case"script":p=Fl(i)}ms.has(p)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),ms.set(p,i),l.querySelector(h)!==null||s==="style"&&l.querySelector(au(p))||s==="script"&&l.querySelector(ou(p))||(s=l.createElement("link"),hn(s,"link",i),Ht(s),l.head.appendChild(s)))}}function N2(i,s){Wr.m(i,s);var a=Hl;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",h='link[rel="modulepreload"][as="'+zi(l)+'"][href="'+zi(i)+'"]',p=h;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Fl(i)}if(!ms.has(p)&&(i=b({rel:"modulepreload",href:i},s),ms.set(p,i),a.querySelector(h)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(ou(p)))return}l=a.createElement("link"),hn(l,"link",i),Ht(l),a.head.appendChild(l)}}}function M2(i,s,a){Wr.S(i,s,a);var l=Hl;if(l&&i){var h=Gs(l).hoistableStyles,p=Ul(i);s=s||"default";var y=h.get(p);if(!y){var D={loading:0,preload:null};if(y=l.querySelector(au(p)))D.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=ms.get(p))&&ig(i,a);var j=y=l.createElement("link");Ht(j),hn(j,"link",i),j._p=new Promise(function(re,_e){j.onload=re,j.onerror=_e}),j.addEventListener("load",function(){D.loading|=1}),j.addEventListener("error",function(){D.loading|=2}),D.loading|=4,bh(y,s,l)}y={type:"stylesheet",instance:y,count:1,state:D},h.set(p,y)}}}function A2(i,s){Wr.X(i,s);var a=Hl;if(a&&i){var l=Gs(a).hoistableScripts,h=Fl(i),p=l.get(h);p||(p=a.querySelector(ou(h)),p||(i=b({src:i,async:!0},s),(s=ms.get(h))&&ng(i,s),p=a.createElement("script"),Ht(p),hn(p,"link",i),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(h,p))}}function L2(i,s){Wr.M(i,s);var a=Hl;if(a&&i){var l=Gs(a).hoistableScripts,h=Fl(i),p=l.get(h);p||(p=a.querySelector(ou(h)),p||(i=b({src:i,async:!0,type:"module"},s),(s=ms.get(h))&&ng(i,s),p=a.createElement("script"),Ht(p),hn(p,"link",i),a.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(h,p))}}function W0(i,s,a,l){var h=(h=ve.current)?_h(h):null;if(!h)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=Ul(a.href),a=Gs(h).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Ul(a.href);var p=Gs(h).hoistableStyles,y=p.get(i);if(y||(h=h.ownerDocument||h,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(i,y),(p=h.querySelector(au(i)))&&!p._p&&(y.instance=p,y.state.loading=5),ms.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},ms.set(i,a),p||O2(h,i,a,y.state))),s&&l===null)throw Error(r(528,""));return y}if(s&&l!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Fl(a),a=Gs(h).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Ul(i){return'href="'+zi(i)+'"'}function au(i){return'link[rel="stylesheet"]['+i+"]"}function q0(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function O2(i,s,a,l){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=i.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),hn(s,"link",a),Ht(s),i.head.appendChild(s))}function Fl(i){return'[src="'+zi(i)+'"]'}function ou(i){return"script[async]"+i}function V0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+zi(a.href)+'"]');if(l)return s.instance=l,Ht(l),l;var h=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Ht(l),hn(l,"style",h),bh(l,a.precedence,i),s.instance=l;case"stylesheet":h=Ul(a.href);var p=i.querySelector(au(h));if(p)return s.state.loading|=4,s.instance=p,Ht(p),p;l=q0(a),(h=ms.get(h))&&ig(l,h),p=(i.ownerDocument||i).createElement("link"),Ht(p);var y=p;return y._p=new Promise(function(D,j){y.onload=D,y.onerror=j}),hn(p,"link",l),s.state.loading|=4,bh(p,a.precedence,i),s.instance=p;case"script":return p=Fl(a.src),(h=i.querySelector(ou(p)))?(s.instance=h,Ht(h),h):(l=a,(h=ms.get(p))&&(l=b({},a),ng(l,h)),i=i.ownerDocument||i,h=i.createElement("script"),Ht(h),hn(h,"link",l),i.head.appendChild(h),s.instance=h);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,bh(l,a.precedence,i));return s.instance}function bh(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=l.length?l[l.length-1]:null,p=h,y=0;y<l.length;y++){var D=l[y];if(D.dataset.precedence===s)p=D;else if(p!==h)break}p?p.parentNode.insertBefore(i,p.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function ig(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function ng(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var yh=null;function Y0(i,s,a){if(yh===null){var l=new Map,h=yh=new Map;h.set(a,l)}else h=yh,l=h.get(a),l||(l=new Map,h.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),h=0;h<a.length;h++){var p=a[h];if(!(p[on]||p[wi]||i==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var y=p.getAttribute(s)||"";y=i+y;var D=l.get(y);D?D.push(p):l.set(y,[p])}}return l}function X0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function B2(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function G0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function j2(i,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var h=Ul(l.href),p=s.querySelector(au(h));if(p){s=p._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=Sh.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=p,Ht(p);return}p=s.ownerDocument||s,l=q0(l),(h=ms.get(h))&&ig(l,h),p=p.createElement("link"),Ht(p);var y=p;y._p=new Promise(function(D,j){y.onload=D,y.onerror=j}),hn(p,"link",l),a.instance=p}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Sh.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var sg=0;function I2(i,s){return i.stylesheets&&i.count===0&&xh(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&xh(i,i.stylesheets),i.unsuspend){var p=i.unsuspend;i.unsuspend=null,p()}},6e4+s);0<i.imgBytes&&sg===0&&(sg=62500*v2());var h=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&xh(i,i.stylesheets),i.unsuspend)){var p=i.unsuspend;i.unsuspend=null,p()}},(i.imgBytes>sg?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(h)}}:null}function Sh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xh(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var wh=null;function xh(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,wh=new Map,s.forEach(P2,i),wh=null,Sh.call(i))}function P2(i,s){if(!(s.state.loading&4)){var a=wh.get(i);if(a)var l=a.get(null);else{a=new Map,wh.set(i,a);for(var h=i.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<h.length;p++){var y=h[p];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(a.set(y.dataset.precedence,y),l=y)}l&&a.set(null,l)}h=s.instance,y=h.getAttribute("data-precedence"),p=a.get(y)||l,p===l&&a.set(null,h),a.set(y,h),this.count++,l=Sh.bind(this),h.addEventListener("load",l),h.addEventListener("error",l),p?p.parentNode.insertBefore(h,p.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(h,i.firstChild)),s.state.loading|=4}}var lu={$$typeof:U,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function z2(i,s,a,l,h,p,y,D,j){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=hi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hi(0),this.hiddenUpdates=hi(null),this.identifierPrefix=l,this.onUncaughtError=h,this.onCaughtError=p,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=j,this.incompleteTransitions=new Map}function Z0(i,s,a,l,h,p,y,D,j,re,_e,xe){return i=new z2(i,s,a,y,j,re,_e,xe,D),s=1,p===!0&&(s|=24),p=qn(3,null,null,s),i.current=p,p.stateNode=i,s=Ip(),s.refCount++,i.pooledCache=s,s.refCount++,p.memoizedState={element:l,isDehydrated:a,cache:s},Up(p),i}function Q0(i){return i?(i=bl,i):bl}function J0(i,s,a,l,h,p){h=Q0(h),l.context===null?l.context=h:l.pendingContext=h,l=Ca(s),l.payload={element:a},p=p===void 0?null:p,p!==null&&(l.callback=p),a=ka(i,l,s),a!==null&&(Un(a,i,s),Hc(a,i,s))}function ew(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function rg(i,s){ew(i,s),(i=i.alternate)&&ew(i,s)}function tw(i){if(i.tag===13||i.tag===31){var s=Do(i,67108864);s!==null&&Un(s,i,67108864),rg(i,67108864)}}function iw(i){if(i.tag===13||i.tag===31){var s=Zn();s=gn(s);var a=Do(i,s);a!==null&&Un(a,i,s),rg(i,s)}}var Ch=!0;function H2(i,s,a,l){var h=O.T;O.T=null;var p=R.p;try{R.p=2,ag(i,s,a,l)}finally{R.p=p,O.T=h}}function U2(i,s,a,l){var h=O.T;O.T=null;var p=R.p;try{R.p=8,ag(i,s,a,l)}finally{R.p=p,O.T=h}}function ag(i,s,a,l){if(Ch){var h=og(l);if(h===null)qm(i,s,l,kh,a),sw(i,l);else if($2(h,i,s,a,l))l.stopPropagation();else if(sw(i,l),s&4&&-1<F2.indexOf(i)){for(;h!==null;){var p=Ts(h);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var y=Bt(p.pendingLanes);if(y!==0){var D=p;for(D.pendingLanes|=2,D.entangledLanes|=2;y;){var j=1<<31-ct(y);D.entanglements[1]|=j,y&=~j}or(p),(jt&6)===0&&(oh=$e()+500,iu(0))}}break;case 31:case 13:D=Do(p,2),D!==null&&Un(D,p,2),ch(),rg(p,2)}if(p=og(l),p===null&&qm(i,s,l,kh,a),p===h)break;h=p}h!==null&&l.stopPropagation()}else qm(i,s,l,null,a)}}function og(i){return i=go(i),lg(i)}var kh=null;function lg(i){if(kh=null,i=$n(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=u(s),i!==null)return i;i=null}else if(a===31){if(i=f(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return kh=i,null}function nw(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(St()){case wt:return 2;case Nt:return 8;case _t:case Pt:return 32;case oi:return 268435456;default:return 32}default:return 32}}var cg=!1,ja=null,Ia=null,Pa=null,cu=new Map,uu=new Map,za=[],F2="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function sw(i,s){switch(i){case"focusin":case"focusout":ja=null;break;case"dragenter":case"dragleave":Ia=null;break;case"mouseover":case"mouseout":Pa=null;break;case"pointerover":case"pointerout":cu.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":uu.delete(s.pointerId)}}function du(i,s,a,l,h,p){return i===null||i.nativeEvent!==p?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:p,targetContainers:[h]},s!==null&&(s=Ts(s),s!==null&&tw(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),i)}function $2(i,s,a,l,h){switch(s){case"focusin":return ja=du(ja,i,s,a,l,h),!0;case"dragenter":return Ia=du(Ia,i,s,a,l,h),!0;case"mouseover":return Pa=du(Pa,i,s,a,l,h),!0;case"pointerover":var p=h.pointerId;return cu.set(p,du(cu.get(p)||null,i,s,a,l,h)),!0;case"gotpointercapture":return p=h.pointerId,uu.set(p,du(uu.get(p)||null,i,s,a,l,h)),!0}return!1}function rw(i){var s=$n(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){i.blockedOn=s,an(i.priority,function(){iw(a)});return}}else if(s===31){if(s=f(a),s!==null){i.blockedOn=s,an(i.priority,function(){iw(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Th(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=og(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Zi=l,a.target.dispatchEvent(l),Zi=null}else return s=Ts(a),s!==null&&tw(s),i.blockedOn=a,!1;s.shift()}return!0}function aw(i,s,a){Th(i)&&a.delete(s)}function K2(){cg=!1,ja!==null&&Th(ja)&&(ja=null),Ia!==null&&Th(Ia)&&(Ia=null),Pa!==null&&Th(Pa)&&(Pa=null),cu.forEach(aw),uu.forEach(aw)}function Eh(i,s){i.blockedOn===s&&(i.blockedOn=null,cg||(cg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,K2)))}var Dh=null;function ow(i){Dh!==i&&(Dh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Dh===i&&(Dh=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],h=i[s+2];if(typeof l!="function"){if(lg(l||a)===null)continue;break}var p=Ts(a);p!==null&&(i.splice(s,3),s-=3,om(p,{pending:!0,data:h,method:a.method,action:l},l,h))}}))}function $l(i){function s(j){return Eh(j,i)}ja!==null&&Eh(ja,i),Ia!==null&&Eh(Ia,i),Pa!==null&&Eh(Pa,i),cu.forEach(s),uu.forEach(s);for(var a=0;a<za.length;a++){var l=za[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<za.length&&(a=za[0],a.blockedOn===null);)rw(a),a.blockedOn===null&&za.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var h=a[l],p=a[l+1],y=h[xi]||null;if(typeof p=="function")y||ow(a);else if(y){var D=null;if(p&&p.hasAttribute("formAction")){if(h=p,y=p[xi]||null)D=y.formAction;else if(lg(h)!==null)continue}else D=y.action;typeof D=="function"?a[l+1]=D:(a.splice(l,3),l-=3),ow(a)}}}function lw(){function i(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(y){return h=y})},focusReset:"manual",scroll:"manual"})}function s(){h!==null&&(h(),h=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,h=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),h!==null&&(h(),h=null)}}}function ug(i){this._internalRoot=i}Rh.prototype.render=ug.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Zn();J0(a,l,i,s,null,null)},Rh.prototype.unmount=ug.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;J0(i.current,2,null,i,null,null),ch(),s[is]=null}};function Rh(i){this._internalRoot=i}Rh.prototype.unstable_scheduleHydration=function(i){if(i){var s=pi();i={blockedOn:null,target:i,priority:s};for(var a=0;a<za.length&&s!==0&&s<za[a].priority;a++);za.splice(a,0,i),a===0&&rw(i)}};var cw=t.version;if(cw!=="19.2.6")throw Error(r(527,cw,"19.2.6"));R.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=m(s),i=i!==null?_(i):null,i=i===null?null:i.stateNode,i};var W2={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Nh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Nh.isDisabled&&Nh.supportsFiber)try{st=Nh.inject(W2),et=Nh}catch{}}return fu.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",h=gS,p=vS,y=_S;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(h=s.onUncaughtError),s.onCaughtError!==void 0&&(p=s.onCaughtError),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=Z0(i,1,!1,null,null,a,l,null,h,p,y,lw),i[is]=s.current,Wm(i),new ug(s)},fu.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,h="",p=gS,y=vS,D=_S,j=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(h=a.identifierPrefix),a.onUncaughtError!==void 0&&(p=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(D=a.onRecoverableError),a.formState!==void 0&&(j=a.formState)),s=Z0(i,1,!0,s,a??null,l,h,j,p,y,D,lw),s.context=Q0(null),a=s.current,l=Zn(),l=gn(l),h=Ca(l),h.callback=null,ka(a,h,l),a=l,s.current.lanes=a,lt(s,a),or(s),i[is]=s.current,Wm(i),new Rh(s)},fu.version="19.2.6",fu}var bw;function tD(){if(bw)return fg.exports;bw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),fg.exports=eD(),fg.exports}var iD=tD();class Uo extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function Wx(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let u=!1;const f=()=>{e.signal?.removeEventListener("abort",_)},g=b=>{u||(u=!0,f(),o(b))},m=b=>{u||(u=!0,f(),c(b))},_=()=>{t.abort(),m(new Uo(0,"Upload aborted."))};if(e.signal?.aborted){m(new Uo(0,"Upload aborted."));return}e.signal?.addEventListener("abort",_,{once:!0}),t.open("POST",e.endpoint??"/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{m(new Uo(t.status,"Invalid upload response."))}return}m(new Uo(t.status,nD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>m(new Uo(0,"Upload failed.")),t.onabort=()=>m(new Uo(0,"Upload aborted.")),t.ontimeout=()=>m(new Uo(0,"Upload timed out.")),t.send(n)})}function nD(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class fn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Vf(e=fetch){return{getSession:(t={})=>Re(e,`/api/auth/session${hr(t)}`),setupPassword:t=>Re(e,"/api/auth/password",Je("POST",t)),login:t=>Re(e,"/api/auth/login",Je("POST",t)),reauth:t=>Re(e,"/api/auth/reauth",Je("POST",t)),logout:()=>Re(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Re(e,"/api/client-diagnostics",Je("POST",t)),setupTotp:()=>Re(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Re(e,"/api/auth/totp/activate",Je("POST",t)),disableTotp:()=>Re(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Re(e,"/api/auth/devices"),revokeDevice:async t=>{await ql(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Re(e,"/api/auth/networks"),addNetwork:t=>Re(e,"/api/auth/networks",Je("POST",t)),removeNetwork:async t=>{await ql(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Re(e,"/api/agents"),addAgent:t=>Re(e,"/api/agents",Je("POST",t)),reorderAgents:t=>Re(e,"/api/agents/order",Je("PUT",{serverIds:t})),renameAgent:(t,n)=>Re(e,`/api/agents/${encodeURIComponent(t)}`,Je("PATCH",{name:n})),getMainInfo:()=>Re(e,"/api/main"),renameMain:t=>Re(e,"/api/main",Je("PATCH",{name:t})),removeAgent:async t=>{await ql(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Re(e,"/api/stats"),getAgentStats:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Re(e,"/api/version"),checkUpdate:()=>Re(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Re(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Re(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Re(e,`/api/code-server/status${hr(t)}`),installCodeServer:()=>Re(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Re(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Re(e,"/api/code-server/open",Je("POST",t)),stopCodeServer:(t={})=>Re(e,"/api/code-server/stop",Je("POST",t)),uninstallCodeServer:()=>Re(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),getFavorites:()=>Re(e,"/api/favorites"),saveFavorites:t=>Re(e,"/api/favorites",Je("PUT",t)),listTerminals:()=>Re(e,"/api/terminals"),getTerminalLayout:()=>Re(e,"/api/terminal-layout"),saveTerminalLayout:t=>Re(e,"/api/terminal-layout",Je("PUT",t)),createFileRoot:t=>Re(e,"/api/files/root",Je("POST",t)),listFiles:t=>Re(e,"/api/files/list",Je("POST",t)),readFile:t=>Re(e,"/api/files/read",Je("POST",t)),writeFile:t=>Re(e,"/api/files/write",Je("POST",t)),createFileEntry:t=>Re(e,"/api/files/create",Je("POST",t)),moveFileEntry:t=>Re(e,"/api/files/move",Je("POST",t)),previewDeleteFileEntry:t=>Re(e,"/api/files/delete-preview",Je("POST",t)),deleteFileEntry:t=>Re(e,"/api/files/delete",Je("POST",t)),openFileInTerminal:t=>Re(e,"/api/files/open",Je("POST",t)),previewFile:t=>qx(e,"/api/files/preview",Je("POST",t)),createTerminal:(t={})=>Re(e,"/api/terminals",Je("POST",t)),closeTerminal:async t=>{await ql(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Re(e,`/api/terminals/${encodeURIComponent(t)}`,Je("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Re(e,`/api/terminals/${encodeURIComponent(t)}/history${hr(n)}`),getTerminalTranscriptHistory:(t,n={})=>Re(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${hr(n)}`),getTerminalTranscriptSource:t=>Re(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Re(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>Re(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${hr(r)}`),listNotificationAssets:()=>Re(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Re(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Re(e,"/api/notification-assets/selection",Je("PUT",t)),deleteNotificationAsset:async t=>{await ql(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Re(e,`/api/push-notifications/status${t||n?hr({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Re(e,"/api/push-notifications/prepare",Je("POST",{clientId:t})),subscribePushNotifications:t=>Re(e,"/api/push-notifications/subscription",Je("POST",t)),updatePushNotificationDevice:t=>Re(e,"/api/push-notifications/device",Je("PATCH",t)),unsubscribePushNotifications:t=>Re(e,"/api/push-notifications/unsubscribe",Je("POST",t)),updatePushPresence:t=>Re(e,"/api/push-notifications/presence",Je("POST",t)),testPushNotification:t=>Re(e,"/api/push-notifications/test",Je("POST",t))}}function dr(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Re(t,n("terminals")),createTerminal:(r={})=>Re(t,n("terminals"),Je("POST",r)),closeTerminal:async r=>{await ql(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Re(t,n(`terminals/${encodeURIComponent(r)}`),Je("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Re(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${hr(o)}`),getTerminalTranscriptHistory:(r,o={})=>Re(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${hr(o)}`),getTerminalTranscriptSource:r=>Re(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>Re(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>Re(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${hr(c)}`),getTerminalLayout:()=>Re(t,n("terminal-layout")),saveTerminalLayout:r=>Re(t,n("terminal-layout"),Je("PUT",r)),createFileRoot:r=>Re(t,n("files/root"),Je("POST",r)),listFiles:r=>Re(t,n("files/list"),Je("POST",r)),readFile:r=>Re(t,n("files/read"),Je("POST",r)),writeFile:r=>Re(t,n("files/write"),Je("POST",r)),createFileEntry:r=>Re(t,n("files/create"),Je("POST",r)),moveFileEntry:r=>Re(t,n("files/move"),Je("POST",r)),previewDeleteFileEntry:r=>Re(t,n("files/delete-preview"),Je("POST",r)),deleteFileEntry:r=>Re(t,n("files/delete"),Je("POST",r)),openFileInTerminal:r=>Re(t,n("files/open"),Je("POST",r)),previewFile:r=>qx(t,n("files/preview"),Je("POST",r)),uploadComposeAttachments:r=>Wx({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>Re(t,n("attachments/limits")),deleteComposeAttachments:r=>Re(t,n("attachments/delete"),Je("POST",r)),getCodeServerStatus:(r={})=>Re(t,`${n("code-server/status")}${hr(r)}`),installCodeServer:()=>Re(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Re(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>Re(t,n("code-server/open"),Je("POST",r)),stopCodeServer:(r={})=>Re(t,n("code-server/stop"),Je("POST",r)),uninstallCodeServer:()=>Re(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getAccounts:()=>Re(t,n("accounts")),getServerProcesses:()=>Re(t,n("server-info/processes")),renameServerProject:(r,o)=>Re(t,n("server-info/project-name"),Je("POST",{path:r,name:o})),getServerExternalIp:(r=!1)=>Re(t,n("server-info/external-ip")+(r?"?refresh=1":"")),selectAccount:(r,o)=>Re(t,n(`accounts/${r}/select`),Je("POST",{profileId:o})),removeAccount:(r,o)=>Re(t,n(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>Re(t,n(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(r,o)=>Re(t,n(`accounts/${r}/login/complete`),Je("POST",{label:o})),cancelAccountLogin:r=>Re(t,n(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>Re(t,n(`accounts/${r}/refresh`),Je("POST",o?{profileId:o}:{})),terminateProviderSessions:r=>Re(t,n(`accounts/${r}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>sD(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function sD(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function Je(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function hr(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function Re(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await nb(r);try{return await r.json()}catch{throw new fn(r.status,"invalid_json_response")}}async function ql(e,t,n){const r=await e(t,n);await nb(r)}async function qx(e,t,n){const r=await e(t,n);return await nb(r),r.blob()}async function nb(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new fn(e.status,t)}const sb="nterminal.theme.id",Vx="nterminal.theme.accent",hv="nterminal:theme",vf=[{id:"midnight",label:"Midnight",description:"Current dark terminal look with aqua focus.",mode:"dark",tokens:{bg:"#0a0d10",bg2:"#0d1216",bgSidebar:"#08090b",line:"#1a2128",line2:"#2a3340",fg:"#e2e8ee",fg2:"#8896a3",fg3:"#54616d",fg4:"#3f4a54",accent:"#5eead4",accentSoft:"rgba(94, 234, 212, 0.10)",accentGlow:"rgba(94, 234, 212, 0.55)",onAccent:"#062423",ok:"#34d399",danger:"#f87171",onDanger:"#190607",dangerSoft:"rgba(248, 113, 113, 0.08)",dangerLine:"rgba(248, 113, 113, 0.30)",warning:"#fbbf24",warningSoft:"rgba(247, 217, 119, 0.075)",warningGlow:"rgba(245, 158, 11, 0.55)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.35)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(10, 13, 16, 0.86)",floatingBgStrong:"rgba(10, 13, 16, 0.96)",floatingBgHover:"rgba(15, 23, 27, 0.94)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.015)",scrollbarThumb:"rgba(148, 163, 184, 0.50)",scrollbarThumbHover:"rgba(148, 163, 184, 0.70)",transcriptUser:"#f7d977",transcriptAssistant:"#5eead4",transcriptTool:"#9aa7b4",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f7d977",transcriptOnSearch:"#121417",qrBg:"#ffffff"},xterm:{background:"#0a0d10",foreground:"#e2e8ee",cursor:"#5eead4",selectionBackground:"#1f3f45"}},{id:"daylight",label:"Daylight",description:"Light workspace with dark terminal contrast.",mode:"light",tokens:{bg:"#f7f9fc",bg2:"#ffffff",bgSidebar:"#eef2f7",line:"#dbe3ec",line2:"#c3cedb",fg:"#17212b",fg2:"#526170",fg3:"#7b8794",fg4:"#a1acb8",accent:"#0f8f83",accentSoft:"rgba(15, 143, 131, 0.11)",accentGlow:"rgba(15, 143, 131, 0.24)",onAccent:"#021918",ok:"#16835c",danger:"#c03545",onDanger:"#fff7f8",dangerSoft:"rgba(192, 53, 69, 0.10)",dangerLine:"rgba(192, 53, 69, 0.30)",warning:"#b7791f",warningSoft:"rgba(183, 121, 31, 0.12)",warningGlow:"rgba(183, 121, 31, 0.26)",scrim:"rgba(15, 23, 42, 0.34)",scrimSoft:"rgba(15, 23, 42, 0.20)",shadow:"rgba(15, 23, 42, 0.18)",shadowStrong:"rgba(15, 23, 42, 0.28)",floatingBg:"rgba(255, 255, 255, 0.92)",floatingBgStrong:"rgba(255, 255, 255, 0.98)",floatingBgHover:"rgba(239, 246, 249, 0.96)",subtleFill:"rgba(15, 23, 42, 0.025)",hoverFill:"rgba(15, 23, 42, 0.035)",scrollbarThumb:"rgba(82, 97, 112, 0.38)",scrollbarThumbHover:"rgba(82, 97, 112, 0.58)",transcriptUser:"#8b3f75",transcriptAssistant:"#0f8f83",transcriptTool:"#66717d",transcriptCommand:"#0b6fa4",transcriptCode:"#075985",transcriptSearch:"#f0c14b",transcriptOnSearch:"#1f1a10",qrBg:"#ffffff"},xterm:{background:"#ffffff",foreground:"#17212b",cursor:"#0f8f83",selectionBackground:"#cdeee9",...yw({foreground:"#17212b",foregroundMuted:"#526170",line:"#dbe3ec",red:"#b4232f",green:"#16794f",yellow:"#9a6700",blue:"#0b6fa4",magenta:"#8f3f85",cyan:"#0f766e"})}},{id:"signal-red",label:"Signal",description:"Dark control-room surface with red alerts.",mode:"dark",tokens:{bg:"#100d0f",bg2:"#171113",bgSidebar:"#0b080a",line:"#2a1b20",line2:"#452b32",fg:"#f1e7e9",fg2:"#a58d93",fg3:"#765f66",fg4:"#55434a",accent:"#ff2a3d",accentSoft:"rgba(255, 42, 61, 0.12)",accentGlow:"rgba(255, 42, 61, 0.52)",onAccent:"#210407",ok:"#34d399",danger:"#ff4d5f",onDanger:"#210407",dangerSoft:"rgba(255, 77, 95, 0.10)",dangerLine:"rgba(255, 77, 95, 0.32)",warning:"#fbbf24",warningSoft:"rgba(251, 191, 36, 0.10)",warningGlow:"rgba(245, 158, 11, 0.50)",scrim:"rgba(0, 0, 0, 0.58)",scrimSoft:"rgba(0, 0, 0, 0.30)",shadow:"rgba(0, 0, 0, 0.36)",shadowStrong:"rgba(0, 0, 0, 0.52)",floatingBg:"rgba(16, 13, 15, 0.88)",floatingBgStrong:"rgba(16, 13, 15, 0.96)",floatingBgHover:"rgba(25, 16, 19, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(165, 141, 147, 0.45)",scrollbarThumbHover:"rgba(165, 141, 147, 0.65)",transcriptUser:"#f8d36f",transcriptAssistant:"#ff2a3d",transcriptTool:"#ad9ca2",transcriptCommand:"#ff9ca6",transcriptCode:"#ffd1d6",transcriptSearch:"#f8d36f",transcriptOnSearch:"#1b0e10",qrBg:"#ffffff"},xterm:{background:"#100d0f",foreground:"#f1e7e9",cursor:"#ff2a3d",selectionBackground:"#4a1b22"}},{id:"graphite",label:"Graphite",description:"Neutral dark theme with blue command focus.",mode:"dark",tokens:{bg:"#101214",bg2:"#171a1d",bgSidebar:"#0c0e10",line:"#262b30",line2:"#39414a",fg:"#eceff3",fg2:"#9aa4af",fg3:"#6c7680",fg4:"#4d5660",accent:"#7dd3fc",accentSoft:"rgba(125, 211, 252, 0.11)",accentGlow:"rgba(125, 211, 252, 0.38)",onAccent:"#071c26",ok:"#4ade80",danger:"#fb7185",onDanger:"#26070d",dangerSoft:"rgba(251, 113, 133, 0.09)",dangerLine:"rgba(251, 113, 133, 0.30)",warning:"#facc15",warningSoft:"rgba(250, 204, 21, 0.09)",warningGlow:"rgba(250, 204, 21, 0.42)",scrim:"rgba(0, 0, 0, 0.55)",scrimSoft:"rgba(0, 0, 0, 0.28)",shadow:"rgba(0, 0, 0, 0.34)",shadowStrong:"rgba(0, 0, 0, 0.50)",floatingBg:"rgba(16, 18, 20, 0.88)",floatingBgStrong:"rgba(16, 18, 20, 0.96)",floatingBgHover:"rgba(22, 28, 33, 0.96)",subtleFill:"rgba(255, 255, 255, 0.018)",hoverFill:"rgba(255, 255, 255, 0.018)",scrollbarThumb:"rgba(154, 164, 175, 0.45)",scrollbarThumbHover:"rgba(154, 164, 175, 0.65)",transcriptUser:"#f2d675",transcriptAssistant:"#7dd3fc",transcriptTool:"#aab4bf",transcriptCommand:"#8fd6ff",transcriptCode:"#c4f1ff",transcriptSearch:"#f2d675",transcriptOnSearch:"#141513",qrBg:"#ffffff"},xterm:{background:"#101214",foreground:"#eceff3",cursor:"#7dd3fc",selectionBackground:"#263d4b"}},{id:"paper",label:"Paper",description:"Warm light surface with restrained amber accent.",mode:"light",tokens:{bg:"#fbfaf7",bg2:"#ffffff",bgSidebar:"#f2f0ea",line:"#e2ddd4",line2:"#cbc3b6",fg:"#25211d",fg2:"#62584e",fg3:"#8d8275",fg4:"#afa69b",accent:"#a35d00",accentSoft:"rgba(163, 93, 0, 0.11)",accentGlow:"rgba(163, 93, 0, 0.24)",onAccent:"#fffaf2",ok:"#26744d",danger:"#b23a48",onDanger:"#fff8f8",dangerSoft:"rgba(178, 58, 72, 0.10)",dangerLine:"rgba(178, 58, 72, 0.30)",warning:"#a35d00",warningSoft:"rgba(163, 93, 0, 0.12)",warningGlow:"rgba(163, 93, 0, 0.26)",scrim:"rgba(37, 33, 29, 0.32)",scrimSoft:"rgba(37, 33, 29, 0.18)",shadow:"rgba(37, 33, 29, 0.18)",shadowStrong:"rgba(37, 33, 29, 0.28)",floatingBg:"rgba(255, 253, 249, 0.92)",floatingBgStrong:"rgba(255, 253, 249, 0.98)",floatingBgHover:"rgba(250, 247, 240, 0.96)",subtleFill:"rgba(37, 33, 29, 0.025)",hoverFill:"rgba(37, 33, 29, 0.035)",scrollbarThumb:"rgba(98, 88, 78, 0.35)",scrollbarThumbHover:"rgba(98, 88, 78, 0.55)",transcriptUser:"#7b3f8c",transcriptAssistant:"#a35d00",transcriptTool:"#776d63",transcriptCommand:"#176a94",transcriptCode:"#6f4b00",transcriptSearch:"#e9c46a",transcriptOnSearch:"#241b0a",qrBg:"#ffffff"},xterm:{background:"#fffdf9",foreground:"#25211d",cursor:"#a35d00",selectionBackground:"#f2dfc5",...yw({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],oc="midnight";function Yf(e){return vf.some(t=>t.id===e)?e:oc}function rb(e){return vf.find(t=>t.id===e)??vf[0]}function no(){if(typeof window>"u")return oc;try{const e=window.localStorage.getItem(sb);return e?Yf(e):cD(window.localStorage.getItem(Vx))}catch{return oc}}function rD(e){const t=Yf(e);if(typeof window<"u"){try{window.localStorage.setItem(sb,t)}catch{}ab(t),window.dispatchEvent(new CustomEvent(hv,{detail:t}))}return t}function ab(e=no()){if(typeof document>"u")return;const t=rb(Yf(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),mt(n,"--nt-bg",t.tokens.bg),mt(n,"--nt-bg-2",t.tokens.bg2),mt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),mt(n,"--nt-line",t.tokens.line),mt(n,"--nt-line-2",t.tokens.line2),mt(n,"--nt-fg",t.tokens.fg),mt(n,"--nt-fg-2",t.tokens.fg2),mt(n,"--nt-fg-3",t.tokens.fg3),mt(n,"--nt-fg-4",t.tokens.fg4),mt(n,"--nt-accent",t.tokens.accent),mt(n,"--nt-accent-soft",t.tokens.accentSoft),mt(n,"--nt-accent-glow",t.tokens.accentGlow),mt(n,"--nt-on-accent",t.tokens.onAccent),mt(n,"--nt-ok",t.tokens.ok),mt(n,"--nt-danger",t.tokens.danger),mt(n,"--nt-on-danger",t.tokens.onDanger),mt(n,"--nt-danger-soft",t.tokens.dangerSoft),mt(n,"--nt-danger-line",t.tokens.dangerLine),mt(n,"--nt-warning",t.tokens.warning),mt(n,"--nt-warn",t.tokens.warning),mt(n,"--nt-warning-soft",t.tokens.warningSoft),mt(n,"--nt-warning-glow",t.tokens.warningGlow),mt(n,"--nt-scrim",t.tokens.scrim),mt(n,"--nt-scrim-soft",t.tokens.scrimSoft),mt(n,"--nt-shadow",t.tokens.shadow),mt(n,"--nt-shadow-strong",t.tokens.shadowStrong),mt(n,"--nt-floating-bg",t.tokens.floatingBg),mt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),mt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),mt(n,"--nt-subtle-fill",t.tokens.subtleFill),mt(n,"--nt-hover-fill",t.tokens.hoverFill),mt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),mt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),mt(n,"--nt-transcript-user",t.tokens.transcriptUser),mt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),mt(n,"--nt-transcript-tool",t.tokens.transcriptTool),mt(n,"--nt-transcript-command",t.tokens.transcriptCommand),mt(n,"--nt-transcript-code",t.tokens.transcriptCode),mt(n,"--nt-transcript-search",t.tokens.transcriptSearch),mt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),mt(n,"--nt-qr-bg",t.tokens.qrBg)}function aD(e=no()){return rb(Yf(e)).xterm}function ob(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===sb||n.key===Vx)&&(ab(no()),e())};return window.addEventListener(hv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(hv,e),window.removeEventListener("storage",t)}}function mt(e,t,n){e.style.setProperty(t,n)}function yw(e){const t=oD(237);return t[215]=e.foreground,t[221]=e.line,{black:e.foreground,red:e.red,green:e.green,yellow:e.yellow,blue:e.blue,magenta:e.magenta,cyan:e.cyan,white:e.foregroundMuted,brightBlack:e.foregroundMuted,brightRed:e.red,brightGreen:e.green,brightYellow:e.yellow,brightBlue:e.blue,brightMagenta:e.magenta,brightCyan:e.cyan,brightWhite:e.foreground,extendedAnsi:t}}function oD(e){const t=[];for(let n=16;n<=e;n+=1)t.push(lD(n));return t}function lD(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return Sw(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return Sw(t,t,t)}return"#000000"}function Sw(e,t,n){return`#${vg(e)}${vg(t)}${vg(n)}`}function vg(e){return e.toString(16).padStart(2,"0")}function cD(e){return e==="signal-red"?"signal-red":oc}function Yx(){const e=v.useSyncExternalStore(ob,no,()=>oc);return rb(e).mode==="light"?"-light":""}function Xx({size:e=22}){const t=Yx();return d.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function Gx({height:e=18}){const t=Yx(),n=Math.round(243/34*e);return d.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var Eu=Kx();function uD(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const Xf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function lb(e){return"nodeType"in e}function Nn(e){var t,n;return e?fc(e)?e:lb(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function cb(e){const{Document:t}=Nn(e);return e instanceof t}function fd(e){return fc(e)?!1:e instanceof Nn(e).HTMLElement}function Zx(e){return e instanceof Nn(e).SVGElement}function pc(e){return e?fc(e)?e.document:lb(e)?cb(e)?e:fd(e)||Zx(e)?e.ownerDocument:document:document:document}const Ws=Xf?v.useLayoutEffect:v.useEffect;function Gf(e){const t=v.useRef(e);return Ws(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function dD(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Yu(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Ws(()=>{n.current!==e&&(n.current=e)},t),n}function pd(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function _f(e){const t=Gf(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function bf(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let _g={};function md(e,t){return v.useMemo(()=>{if(t)return t;const n=_g[e]==null?0:_g[e]+1;return _g[e]=n,e+"-"+n},[e,t])}function Qx(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,u)=>{const f=Object.entries(u);for(const[g,m]of f){const _=c[g];_!=null&&(c[g]=_+e*m)}return c},{...t})}}const nc=Qx(1),yf=Qx(-1);function hD(e){return"clientX"in e&&"clientY"in e}function Zf(e){if(!e)return!1;const{KeyboardEvent:t}=Nn(e.target);return t&&e instanceof t}function fD(e){if(!e)return!1;const{TouchEvent:t}=Nn(e.target);return t&&e instanceof t}function Sf(e){if(fD(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return hD(e)?{x:e.clientX,y:e.clientY}:null}const ta=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ta.Translate.toString(e),ta.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),ww="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pD(e){return e.matches(ww)?e:e.querySelector(ww)}const mD={display:"none"};function gD(e){let{id:t,value:n}=e;return Ot.createElement("div",{id:t,style:mD},n)}function vD(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ot.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function _D(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Jx=v.createContext(null);function bD(e){const t=v.useContext(Jx);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function yD(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(u=>{var f;return(f=u[o])==null?void 0:f.call(u,c)})},[e]),t]}const SD={draggable:`
11
+ To pick up a draggable item, press the space bar.
12
+ While dragging, use the arrow keys to move the item.
13
+ Press space again to drop the item in its new position, or press escape to cancel.
14
+ `},wD={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function xD(e){let{announcements:t=wD,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=SD}=e;const{announce:c,announcement:u}=_D(),f=md("DndLiveRegion"),[g,m]=v.useState(!1);if(v.useEffect(()=>{m(!0)},[]),bD(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:x}=b;t.onDragMove&&c(t.onDragMove({active:w,over:x}))},onDragOver(b){let{active:w,over:x}=b;c(t.onDragOver({active:w,over:x}))},onDragEnd(b){let{active:w,over:x}=b;c(t.onDragEnd({active:w,over:x}))},onDragCancel(b){let{active:w,over:x}=b;c(t.onDragCancel({active:w,over:x}))}}),[c,t])),!g)return null;const _=Ot.createElement(Ot.Fragment,null,Ot.createElement(gD,{id:r,value:o.draggable}),Ot.createElement(vD,{id:f,announcement:u}));return n?Eu.createPortal(_,n):_}var Wi;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Wi||(Wi={}));function wf(){}function xf(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function eC(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const qs=Object.freeze({x:0,y:0});function CD(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function kD(e,t){const n=Sf(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function TD(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ED(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function DD(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function xw(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const RD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=xw(t,t.left,t.top),c=[];for(const u of r){const{id:f}=u,g=n.get(f);if(g){const m=CD(xw(g),o);c.push({id:f,data:{droppableContainer:u,value:m}})}}return c.sort(TD)};function ND(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),u=o-r,f=c-n;if(r<o&&n<c){const g=t.width*t.height,m=e.width*e.height,_=u*f,b=_/(g+m-_);return Number(b.toFixed(4))}return 0}const MD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,f=n.get(u);if(f){const g=ND(f,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(ED)};function AD(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function tC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qs}function LD(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((u,f)=>({...u,top:u.top+e*f.y,bottom:u.bottom+e*f.y,left:u.left+e*f.x,right:u.right+e*f.x}),{...n})}}const OD=LD(1);function iC(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function BD(e,t,n){const r=iC(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:f}=r,g=e.left-u-(1-o)*parseFloat(n),m=e.top-f-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),_=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:_,height:b,top:m,right:g+_,bottom:m+b,left:g}}const jD={ignoreTransform:!1};function mc(e,t){t===void 0&&(t=jD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:m,transformOrigin:_}=Nn(e).getComputedStyle(e);m&&(n=BD(n,m,_))}const{top:r,left:o,width:c,height:u,bottom:f,right:g}=n;return{top:r,left:o,width:c,height:u,bottom:f,right:g}}function Cw(e){return mc(e,{ignoreTransform:!0})}function ID(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function PD(e,t){return t===void 0&&(t=Nn(e).getComputedStyle(e)),t.position==="fixed"}function zD(e,t){t===void 0&&(t=Nn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function ub(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(cb(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!fd(o)||Zx(o)||n.includes(o))return n;const c=Nn(e).getComputedStyle(o);return o!==e&&zD(o,c)&&n.push(o),PD(o,c)?n:r(o.parentNode)}return e?r(e):n}function nC(e){const[t]=ub(e,1);return t??null}function bg(e){return!Xf||!e?null:fc(e)?e:lb(e)?cb(e)||e===pc(e).scrollingElement?window:fd(e)?e:null:null}function sC(e){return fc(e)?e.scrollX:e.scrollLeft}function rC(e){return fc(e)?e.scrollY:e.scrollTop}function fv(e){return{x:sC(e),y:rC(e)}}var en;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(en||(en={}));function aC(e){return!Xf||!e?!1:e===document.scrollingElement}function oC(e){const t={x:0,y:0},n=aC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,u=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:u,isRight:f,maxScroll:r,minScroll:t}}const HD={x:.2,y:.2};function UD(e,t,n,r,o){let{top:c,left:u,right:f,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=HD);const{isTop:m,isBottom:_,isLeft:b,isRight:w}=oC(e),x={x:0,y:0},C={x:0,y:0},N={height:t.height*o.y,width:t.width*o.x};return!m&&c<=t.top+N.height?(x.y=en.Backward,C.y=r*Math.abs((t.top+N.height-c)/N.height)):!_&&g>=t.bottom-N.height&&(x.y=en.Forward,C.y=r*Math.abs((t.bottom-N.height-g)/N.height)),!w&&f>=t.right-N.width?(x.x=en.Forward,C.x=r*Math.abs((t.right-N.width-f)/N.width)):!b&&u<=t.left+N.width&&(x.x=en.Backward,C.x=r*Math.abs((t.left+N.width-u)/N.width)),{direction:x,speed:C}}function FD(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function lC(e){return e.reduce((t,n)=>nc(t,fv(n)),qs)}function $D(e){return e.reduce((t,n)=>t+sC(n),0)}function KD(e){return e.reduce((t,n)=>t+rC(n),0)}function cC(e,t){if(t===void 0&&(t=mc),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);nC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const WD=[["x",["left","right"],$D],["y",["top","bottom"],KD]];class db{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=ub(n),o=lC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,f]of WD)for(const g of u)Object.defineProperty(this,g,{get:()=>{const m=f(r),_=o[c]-m;return this.rect[g]+_},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ju{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function qD(e){const{EventTarget:t}=Nn(e);return e instanceof t?e:pc(e)}function yg(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var bs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bs||(bs={}));function kw(e){e.preventDefault()}function VD(e){e.stopPropagation()}var It;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(It||(It={}));const uC={start:[It.Space,It.Enter],cancel:[It.Esc],end:[It.Space,It.Enter,It.Tab]},YD=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case It.Right:return{...n,x:n.x+25};case It.Left:return{...n,x:n.x-25};case It.Down:return{...n,y:n.y+25};case It.Up:return{...n,y:n.y-25}}};class dC{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new ju(pc(n)),this.windowListeners=new ju(Nn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&cC(r),n(qs)}handleKeyDown(t){if(Zf(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=uC,coordinateGetter:u=YD,scrollBehavior:f="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:m}=r.current,_=m?{x:m.left,y:m.top}:qs;this.referenceCoordinates||(this.referenceCoordinates=_);const b=u(t,{active:n,context:r.current,currentCoordinates:_});if(b){const w=yf(b,_),x={x:0,y:0},{scrollableAncestors:C}=r.current;for(const N of C){const L=t.code,{isTop:A,isRight:W,isLeft:U,isBottom:F,maxScroll:K,minScroll:oe}=oC(N),P=FD(N),te={x:Math.min(L===It.Right?P.right-P.width/2:P.right,Math.max(L===It.Right?P.left:P.left+P.width/2,b.x)),y:Math.min(L===It.Down?P.bottom-P.height/2:P.bottom,Math.max(L===It.Down?P.top:P.top+P.height/2,b.y))},Z=L===It.Right&&!W||L===It.Left&&!U,me=L===It.Down&&!F||L===It.Up&&!A;if(Z&&te.x!==b.x){const ee=N.scrollLeft+w.x,Y=L===It.Right&&ee<=K.x||L===It.Left&&ee>=oe.x;if(Y&&!w.y){N.scrollTo({left:ee,behavior:f});return}Y?x.x=N.scrollLeft-ee:x.x=L===It.Right?N.scrollLeft-K.x:N.scrollLeft-oe.x,x.x&&N.scrollBy({left:-x.x,behavior:f});break}else if(me&&te.y!==b.y){const ee=N.scrollTop+w.y,Y=L===It.Down&&ee<=K.y||L===It.Up&&ee>=oe.y;if(Y&&!w.x){N.scrollTo({top:ee,behavior:f});return}Y?x.y=N.scrollTop-ee:x.y=L===It.Down?N.scrollTop-K.y:N.scrollTop-oe.y,x.y&&N.scrollBy({top:-x.y,behavior:f});break}}this.handleMove(t,nc(yf(b,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}dC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=uC,onActivation:o}=t,{active:c}=n;const{code:u}=e.nativeEvent;if(r.start.includes(u)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Tw(e){return!!(e&&"distance"in e)}function Ew(e){return!!(e&&"delay"in e)}class hb{constructor(t,n,r){var o;r===void 0&&(r=qD(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:u}=c;this.props=t,this.events=n,this.document=pc(u),this.documentListeners=new ju(this.document),this.listeners=new ju(r),this.windowListeners=new ju(Nn(u)),this.initialCoordinates=(o=Sf(c))!=null?o:qs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.DragStart,kw),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),this.windowListeners.add(bs.ContextMenu,kw),this.documentListeners.add(bs.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ew(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Tw(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(bs.Click,VD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bs.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:f}}=c;if(!o)return;const g=(n=Sf(t))!=null?n:qs,m=yf(o,g);if(!r&&f){if(Tw(f)){if(f.tolerance!=null&&yg(m,f.tolerance))return this.handleCancel();if(yg(m,f.distance))return this.handleStart()}if(Ew(f)&&yg(m,f.tolerance))return this.handleCancel();this.handlePending(f,m);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===It.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const XD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class hC extends hb{constructor(t){const{event:n}=t,r=pc(n.target);super(t,XD,r)}}hC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const GD={move:{name:"mousemove"},end:{name:"mouseup"}};var pv;(function(e){e[e.RightClick=2]="RightClick"})(pv||(pv={}));class fb extends hb{constructor(t){super(t,GD,pc(t.event.target))}}fb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===pv.RightClick?!1:(r?.({event:n}),!0)}}];const Sg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class pb extends hb{constructor(t){super(t,Sg)}static setup(){return window.addEventListener(Sg.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Sg.move.name,t)};function t(){}}}pb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Iu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Iu||(Iu={}));var Cf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Cf||(Cf={}));function ZD(e){let{acceleration:t,activator:n=Iu.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:f=Cf.TreeOrder,pointerCoordinates:g,scrollableAncestors:m,scrollableAncestorRects:_,delta:b,threshold:w}=e;const x=JD({delta:b,disabled:!c}),[C,N]=dD(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),W=v.useMemo(()=>{switch(n){case Iu.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Iu.DraggableRect:return o}},[n,o,g]),U=v.useRef(null),F=v.useCallback(()=>{const oe=U.current;if(!oe)return;const P=L.current.x*A.current.x,te=L.current.y*A.current.y;oe.scrollBy(P,te)},[]),K=v.useMemo(()=>f===Cf.TreeOrder?[...m].reverse():m,[f,m]);v.useEffect(()=>{if(!c||!m.length||!W){N();return}for(const oe of K){if(r?.(oe)===!1)continue;const P=m.indexOf(oe),te=_[P];if(!te)continue;const{direction:Z,speed:me}=UD(oe,te,W,t,w);for(const ee of["x","y"])x[ee][Z[ee]]||(me[ee]=0,Z[ee]=0);if(me.x>0||me.y>0){N(),U.current=oe,C(F,u),L.current=me,A.current=Z;return}}L.current={x:0,y:0},A.current={x:0,y:0},N()},[t,F,r,N,c,u,JSON.stringify(W),JSON.stringify(x),C,m,K,_,JSON.stringify(w)])}const QD={x:{[en.Backward]:!1,[en.Forward]:!1},y:{[en.Backward]:!1,[en.Forward]:!1}};function JD(e){let{delta:t,disabled:n}=e;const r=bf(t);return pd(o=>{if(n||!r||!o)return QD;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[en.Backward]:o.x[en.Backward]||c.x===-1,[en.Forward]:o.x[en.Forward]||c.x===1},y:{[en.Backward]:o.y[en.Backward]||c.y===-1,[en.Forward]:o.y[en.Forward]||c.y===1}}},[n,t,r])}function eR(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return pd(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function tR(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...n,...c]},[]),[e,t])}var Xu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Xu||(Xu={}));var mv;(function(e){e.Optimized="optimized"})(mv||(mv={}));const Dw=new Map;function iR(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:f,measure:g,strategy:m}=o,_=v.useRef(e),b=L(),w=Yu(b),x=v.useCallback(function(A){A===void 0&&(A=[]),!w.current&&u(W=>W===null?A:W.concat(A.filter(U=>!W.includes(U))))},[w]),C=v.useRef(null),N=pd(A=>{if(b&&!n)return Dw;if(!A||A===Dw||_.current!==e||c!=null){const W=new Map;for(let U of e){if(!U)continue;if(c&&c.length>0&&!c.includes(U.id)&&U.rect.current){W.set(U.id,U.rect.current);continue}const F=U.node.current,K=F?new db(g(F),F):null;U.rect.current=K,K&&W.set(U.id,K)}return W}return A},[e,c,n,b,g]);return v.useEffect(()=>{_.current=e},[e]),v.useEffect(()=>{b||x()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof f!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},f))},[f,b,x,...r]),{droppableRects:N,measureDroppableContainers:x,measuringScheduled:c!=null};function L(){switch(m){case Xu.Always:return!1;case Xu.BeforeDragging:return n;default:return!n}}}function mb(e,t){return pd(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function nR(e,t){return mb(e,t)}function sR(e){let{callback:t,disabled:n}=e;const r=Gf(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Qf(e){let{callback:t,disabled:n}=e;const r=Gf(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function rR(e){return new db(mc(e),e)}function Rw(e,t,n){t===void 0&&(t=rR);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var m;return(m=g??n)!=null?m:null}const _=t(e);return JSON.stringify(g)===JSON.stringify(_)?g:_})}const u=sR({callback(g){if(e)for(const m of g){const{type:_,target:b}=m;if(_==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),f=Qf({callback:c});return Ws(()=>{c(),e?(f?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),u?.disconnect())},[e]),r}function aR(e){const t=mb(e);return tC(e,t)}const Nw=[];function oR(e){const t=v.useRef(e),n=pd(r=>e?r&&r!==Nw&&e&&t.current&&e.parentNode===t.current.parentNode?r:ub(e):Nw,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function lR(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=bg(c.target);u&&n(f=>f?(f.set(u,fv(u)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const f=e.map(g=>{const m=bg(g);return m?(m.addEventListener("scroll",o,{passive:!0}),[m,fv(m)]):null}).filter(g=>g!=null);n(f.length?new Map(f):null),r.current=e}return()=>{u(e),u(c)};function u(f){f.forEach(g=>{const m=bg(g);m?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>nc(c,u),qs):lC(e):qs,[e,t])}function Mw(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==qs;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?yf(e,n.current):qs}function cR(e){v.useEffect(()=>{if(!Xf)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function uR(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=u=>{c(u,t)},n},{}),[e,t])}function fC(e){return v.useMemo(()=>e?ID(e):null,[e])}const Aw=[];function dR(e,t){t===void 0&&(t=mc);const[n]=e,r=fC(n?Nn(n):null),[o,c]=v.useState(Aw);function u(){c(()=>e.length?e.map(g=>aC(g)?r:new db(t(g),g)):Aw)}const f=Qf({callback:u});return Ws(()=>{f?.disconnect(),u(),e.forEach(g=>f?.observe(g))},[e]),o}function pC(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return fd(t)?t:e}function hR(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(m=>{for(const{target:_}of m)if(fd(_)){r(b=>{const w=t(_);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=Qf({callback:o}),u=v.useCallback(m=>{const _=pC(m);c?.disconnect(),_&&c?.observe(_),r(_?t(_):null)},[t,c]),[f,g]=_f(u);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:g}),[n,f,g])}const fR=[{sensor:hC,options:{}},{sensor:dC,options:{}}],pR={current:{}},Zh={draggable:{measure:Cw},droppable:{measure:Cw,strategy:Xu.WhileDragging,frequency:mv.Optimized},dragOverlay:{measure:mc}};class Pu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const mR={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Pu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:wf},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Zh,measureDroppableContainers:wf,windowRect:null,measuringScheduled:!1},mC={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:wf,draggableNodes:new Map,over:null,measureDroppableContainers:wf},gd=v.createContext(mC),gC=v.createContext(mR);function gR(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Pu}}}function vR(e,t){switch(t.type){case Wi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Wi.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Wi.DragEnd:case Wi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Wi.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Pu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Wi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const u=new Pu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case Wi.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new Pu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function _R(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(gd),c=bf(r),u=bf(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!Zf(c)||document.activeElement===c.target)return;const f=o.get(u);if(!f)return;const{activatorNode:g,node:m}=f;if(!g.current&&!m.current)return;requestAnimationFrame(()=>{for(const _ of[g.current,m.current]){if(!_)continue;const b=pD(_);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function vC(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function bR(e){return v.useMemo(()=>({draggable:{...Zh.draggable,...e?.draggable},droppable:{...Zh.droppable,...e?.droppable},dragOverlay:{...Zh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function yR(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:f}=typeof o=="boolean"?{x:o,y:o}:o;Ws(()=>{if(!u&&!f||!t){c.current=!1;return}if(c.current||!r)return;const m=t?.node.current;if(!m||m.isConnected===!1)return;const _=n(m),b=tC(_,r);if(u||(b.x=0),f||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=nC(m);w&&w.scrollBy({top:b.y,left:b.x})}},[t,u,f,r,n])}const Jf=v.createContext({...qs,scaleX:1,scaleY:1});var Ya;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ya||(Ya={}));const _C=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:f,autoScroll:g=!0,children:m,sensors:_=fR,collisionDetection:b=MD,measuring:w,modifiers:x,...C}=t;const N=v.useReducer(vR,void 0,gR),[L,A]=N,[W,U]=yD(),[F,K]=v.useState(Ya.Uninitialized),oe=F===Ya.Initialized,{draggable:{active:P,nodes:te,translate:Z},droppable:{containers:me}}=L,ee=P!=null?te.get(P):null,Y=v.useRef({initial:null,translated:null}),X=v.useMemo(()=>{var at;return P!=null?{id:P,data:(at=ee?.data)!=null?at:pR,rect:Y}:null},[P,ee]),V=v.useRef(null),[ne,O]=v.useState(null),[R,I]=v.useState(null),de=Yu(C,Object.values(C)),ge=md("DndDescribedBy",u),M=v.useMemo(()=>me.getEnabled(),[me]),q=bR(w),{droppableRects:he,measureDroppableContainers:J,measuringScheduled:ye}=iR(M,{dragging:oe,dependencies:[Z.x,Z.y],config:q.droppable}),ve=eR(te,P),Le=v.useMemo(()=>R?Sf(R):null,[R]),Ne=ut(),Fe=nR(ve,q.draggable.measure);yR({activeNode:P!=null?te.get(P):null,config:Ne.layoutShiftCompensation,initialRect:Fe,measure:q.draggable.measure});const He=Rw(ve,q.draggable.measure,Fe),Pe=Rw(ve?ve.parentElement:null),Ze=v.useRef({activatorEvent:null,active:null,activeNode:ve,collisionRect:null,collisions:null,droppableRects:he,draggableNodes:te,draggingNode:null,draggingNodeRect:null,droppableContainers:me,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),E=me.getNodeFor((n=Ze.current.over)==null?void 0:n.id),z=hR({measure:q.dragOverlay.measure}),we=(r=z.nodeRef.current)!=null?r:ve,Ae=oe?(o=z.rect)!=null?o:He:null,ie=!!(z.nodeRef.current&&z.rect),pe=aR(ie?null:He),Te=fC(we?Nn(we):null),De=oR(oe?E??ve:null),Ee=dR(De),je=vC(x,{transform:{x:Z.x-pe.x,y:Z.y-pe.y,scaleX:1,scaleY:1},activatorEvent:R,active:X,activeNodeRect:He,containerNodeRect:Pe,draggingNodeRect:Ae,over:Ze.current.over,overlayNodeRect:z.rect,scrollableAncestors:De,scrollableAncestorRects:Ee,windowRect:Te}),Ve=Le?nc(Le,Z):null,$e=lR(De),St=Mw($e),wt=Mw($e,[He]),Nt=nc(je,St),_t=Ae?OD(Ae,je):null,Pt=X&&_t?b({active:X,collisionRect:_t,droppableRects:he,droppableContainers:M,pointerCoordinates:Ve}):null,oi=DD(Pt,"id"),[ke,Ge]=v.useState(null),st=ie?je:nc(je,wt),et=AD(st,(c=ke?.rect)!=null?c:null,He),gt=v.useRef(null),ct=v.useCallback((at,Bt)=>{let{sensor:Qt,options:Si}=Bt;if(V.current==null)return;const Ii=te.get(V.current);if(!Ii)return;const ni=at.nativeEvent,hi=new Qt({active:V.current,activeNode:Ii,event:ni,options:Si,context:Ze,onAbort(xt){if(!te.get(xt))return;const{onDragAbort:Jt}=de.current,Vi={id:xt};Jt?.(Vi),W({type:"onDragAbort",event:Vi})},onPending(xt,fi,Jt,Vi){if(!te.get(xt))return;const{onDragPending:Yi}=de.current,pi={id:xt,constraint:fi,initialCoordinates:Jt,offset:Vi};Yi?.(pi),W({type:"onDragPending",event:pi})},onStart(xt){const fi=V.current;if(fi==null)return;const Jt=te.get(fi);if(!Jt)return;const{onDragStart:Vi}=de.current,gn={activatorEvent:ni,active:{id:fi,data:Jt.data,rect:Y}};Eu.unstable_batchedUpdates(()=>{Vi?.(gn),K(Ya.Initializing),A({type:Wi.DragStart,initialCoordinates:xt,active:fi}),W({type:"onDragStart",event:gn}),O(gt.current),I(ni)})},onMove(xt){A({type:Wi.DragMove,coordinates:xt})},onEnd:lt(Wi.DragEnd),onCancel:lt(Wi.DragCancel)});gt.current=hi;function lt(xt){return async function(){const{active:Jt,collisions:Vi,over:gn,scrollAdjustedTranslate:Yi}=Ze.current;let pi=null;if(Jt&&Yi){const{cancelDrop:an}=de.current;pi={activatorEvent:ni,active:Jt,collisions:Vi,delta:Yi,over:gn},xt===Wi.DragEnd&&typeof an=="function"&&await Promise.resolve(an(pi))&&(xt=Wi.DragCancel)}V.current=null,Eu.unstable_batchedUpdates(()=>{A({type:xt}),K(Ya.Uninitialized),Ge(null),O(null),I(null),gt.current=null;const an=xt===Wi.DragEnd?"onDragEnd":"onDragCancel";if(pi){const Ni=de.current[an];Ni?.(pi),W({type:an,event:pi})}})}}},[te]),mn=v.useCallback((at,Bt)=>(Qt,Si)=>{const Ii=Qt.nativeEvent,ni=te.get(Si);if(V.current!==null||!ni||Ii.dndKit||Ii.defaultPrevented)return;const hi={active:ni};at(Qt,Bt.options,hi)===!0&&(Ii.dndKit={capturedBy:Bt.sensor},V.current=Si,ct(Qt,Bt))},[te,ct]),li=tR(_,mn);cR(_),Ws(()=>{He&&F===Ya.Initializing&&K(Ya.Initialized)},[He,F]),v.useEffect(()=>{const{onDragMove:at}=de.current,{active:Bt,activatorEvent:Qt,collisions:Si,over:Ii}=Ze.current;if(!Bt||!Qt)return;const ni={active:Bt,activatorEvent:Qt,collisions:Si,delta:{x:Nt.x,y:Nt.y},over:Ii};Eu.unstable_batchedUpdates(()=>{at?.(ni),W({type:"onDragMove",event:ni})})},[Nt.x,Nt.y]),v.useEffect(()=>{const{active:at,activatorEvent:Bt,collisions:Qt,droppableContainers:Si,scrollAdjustedTranslate:Ii}=Ze.current;if(!at||V.current==null||!Bt||!Ii)return;const{onDragOver:ni}=de.current,hi=Si.get(oi),lt=hi&&hi.rect.current?{id:hi.id,rect:hi.rect.current,data:hi.data,disabled:hi.disabled}:null,xt={active:at,activatorEvent:Bt,collisions:Qt,delta:{x:Ii.x,y:Ii.y},over:lt};Eu.unstable_batchedUpdates(()=>{Ge(lt),ni?.(xt),W({type:"onDragOver",event:xt})})},[oi]),Ws(()=>{Ze.current={activatorEvent:R,active:X,activeNode:ve,collisionRect:_t,collisions:Pt,droppableRects:he,draggableNodes:te,draggingNode:we,draggingNodeRect:Ae,droppableContainers:me,over:ke,scrollableAncestors:De,scrollAdjustedTranslate:Nt},Y.current={initial:Ae,translated:_t}},[X,ve,Pt,_t,te,we,Ae,he,me,ke,De,Nt]),ZD({...Ne,delta:Z,draggingRect:_t,pointerCoordinates:Ve,scrollableAncestors:De,scrollableAncestorRects:Ee});const le=v.useMemo(()=>({active:X,activeNode:ve,activeNodeRect:He,activatorEvent:R,collisions:Pt,containerNodeRect:Pe,dragOverlay:z,draggableNodes:te,droppableContainers:me,droppableRects:he,over:ke,measureDroppableContainers:J,scrollableAncestors:De,scrollableAncestorRects:Ee,measuringConfiguration:q,measuringScheduled:ye,windowRect:Te}),[X,ve,He,R,Pt,Pe,z,te,me,he,ke,J,De,Ee,q,ye,Te]),ze=v.useMemo(()=>({activatorEvent:R,activators:li,active:X,activeNodeRect:He,ariaDescribedById:{draggable:ge},dispatch:A,draggableNodes:te,over:ke,measureDroppableContainers:J}),[R,li,X,He,A,ge,te,ke,J]);return Ot.createElement(Jx.Provider,{value:U},Ot.createElement(gd.Provider,{value:ze},Ot.createElement(gC.Provider,{value:le},Ot.createElement(Jf.Provider,{value:et},m)),Ot.createElement(_R,{disabled:f?.restoreFocus===!1})),Ot.createElement(xD,{...f,hiddenTextDescribedById:ge}));function ut(){const at=ne?.autoScrollEnabled===!1,Bt=typeof g=="object"?g.enabled===!1:g===!1,Qt=oe&&!at&&!Bt;return typeof g=="object"?{...g,enabled:Qt}:{enabled:Qt}}}),SR=v.createContext(null),Lw="button",wR="Draggable";function gb(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=md(wR),{activators:u,activatorEvent:f,active:g,activeNodeRect:m,ariaDescribedById:_,draggableNodes:b,over:w}=v.useContext(gd),{role:x=Lw,roleDescription:C="draggable",tabIndex:N=0}=o??{},L=g?.id===t,A=v.useContext(L?Jf:SR),[W,U]=_f(),[F,K]=_f(),oe=uR(u,t),P=Yu(n);Ws(()=>(b.set(t,{id:t,key:c,node:W,activatorNode:F,data:P}),()=>{const Z=b.get(t);Z&&Z.key===c&&b.delete(t)}),[b,t]);const te=v.useMemo(()=>({role:x,tabIndex:N,"aria-disabled":r,"aria-pressed":L&&x===Lw?!0:void 0,"aria-roledescription":C,"aria-describedby":_.draggable}),[r,x,N,L,C,_.draggable]);return{active:g,activatorEvent:f,activeNodeRect:m,attributes:te,isDragging:L,listeners:r?void 0:oe,node:W,over:w,setNodeRef:U,setActivatorNodeRef:K,transform:A}}function bC(){return v.useContext(gC)}const xR="Droppable",CR={timeout:25};function ep(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=md(xR),{active:u,dispatch:f,over:g,measureDroppableContainers:m}=v.useContext(gd),_=v.useRef({disabled:n}),b=v.useRef(!1),w=v.useRef(null),x=v.useRef(null),{disabled:C,updateMeasurementsFor:N,timeout:L}={...CR,...o},A=Yu(N??r),W=v.useCallback(()=>{if(!b.current){b.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{m(Array.isArray(A.current)?A.current:[A.current]),x.current=null},L)},[L]),U=Qf({callback:W,disabled:C||!u}),F=v.useCallback((te,Z)=>{U&&(Z&&(U.unobserve(Z),b.current=!1),te&&U.observe(te))},[U]),[K,oe]=_f(F),P=Yu(t);return v.useEffect(()=>{!U||!K.current||(U.disconnect(),b.current=!1,U.observe(K.current))},[K,U]),v.useEffect(()=>(f({type:Wi.RegisterDroppable,element:{id:r,key:c,disabled:n,node:K,rect:w,data:P}}),()=>f({type:Wi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==_.current.disabled&&(f({type:Wi.SetDroppableDisabled,id:r,key:c,disabled:n}),_.current.disabled=n)},[r,c,n,f]),{active:u,rect:w,isOver:g?.id===r,node:K,over:g,setNodeRef:oe}}function kR(e){let{animation:t,children:n}=e;const[r,o]=v.useState(null),[c,u]=v.useState(null),f=bf(n);return!n&&!r&&f&&o(f),Ws(()=>{if(!c)return;const g=r?.key,m=r?.props.id;if(g==null||m==null){o(null);return}Promise.resolve(t(m,c)).then(()=>{o(null)})},[t,r,c]),Ot.createElement(Ot.Fragment,null,n,r?v.cloneElement(r,{ref:u}):null)}const TR={x:0,y:0,scaleX:1,scaleY:1};function ER(e){let{children:t}=e;return Ot.createElement(gd.Provider,{value:mC},Ot.createElement(Jf.Provider,{value:TR},t))}const DR={position:"fixed",touchAction:"none"},RR=e=>Zf(e)?"transform 250ms ease":void 0,NR=v.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:c,className:u,rect:f,style:g,transform:m,transition:_=RR}=e;if(!f)return null;const b=o?m:{...m,scaleX:1,scaleY:1},w={...DR,width:f.width,height:f.height,top:f.top,left:f.left,transform:ta.Transform.toString(b),transformOrigin:o&&r?kD(r,f):void 0,transition:typeof _=="function"?_(r):_,...g};return Ot.createElement(n,{className:u,style:w,ref:t},c)}),MR=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:c,className:u}=e;if(c!=null&&c.active)for(const[f,g]of Object.entries(c.active))g!==void 0&&(o[f]=n.node.style.getPropertyValue(f),n.node.style.setProperty(f,g));if(c!=null&&c.dragOverlay)for(const[f,g]of Object.entries(c.dragOverlay))g!==void 0&&r.node.style.setProperty(f,g);return u!=null&&u.active&&n.node.classList.add(u.active),u!=null&&u.dragOverlay&&r.node.classList.add(u.dragOverlay),function(){for(const[g,m]of Object.entries(o))n.node.style.setProperty(g,m);u!=null&&u.active&&n.node.classList.remove(u.active)}},AR=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ta.Transform.toString(t)},{transform:ta.Transform.toString(n)}]},LR={duration:250,easing:"ease",keyframes:AR,sideEffects:MR({styles:{active:{opacity:"0"}}})};function OR(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return Gf((c,u)=>{if(t===null)return;const f=n.get(c);if(!f)return;const g=f.node.current;if(!g)return;const m=pC(u);if(!m)return;const{transform:_}=Nn(u).getComputedStyle(u),b=iC(_);if(!b)return;const w=typeof t=="function"?t:BR(t);return cC(g,o.draggable.measure),w({active:{id:c,data:f.data,node:g,rect:o.draggable.measure(g)},draggableNodes:n,dragOverlay:{node:u,rect:o.dragOverlay.measure(m)},droppableContainers:r,measuringConfiguration:o,transform:b})})}function BR(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...LR,...e};return c=>{let{active:u,dragOverlay:f,transform:g,...m}=c;if(!t)return;const _={x:f.rect.left-u.rect.left,y:f.rect.top-u.rect.top},b={scaleX:g.scaleX!==1?u.rect.width*g.scaleX/f.rect.width:1,scaleY:g.scaleY!==1?u.rect.height*g.scaleY/f.rect.height:1},w={x:g.x-_.x,y:g.y-_.y,...b},x=o({...m,active:u,dragOverlay:f,transform:{initial:g,final:w}}),[C]=x,N=x[x.length-1];if(JSON.stringify(C)===JSON.stringify(N))return;const L=r?.({active:u,dragOverlay:f,...m}),A=f.node.animate(x,{duration:t,easing:n,fill:"forwards"});return new Promise(W=>{A.onfinish=()=>{L?.(),W()}})}}let Ow=0;function jR(e){return v.useMemo(()=>{if(e!=null)return Ow++,Ow},[e])}const IR=Ot.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:c,modifiers:u,wrapperElement:f="div",className:g,zIndex:m=999}=e;const{activatorEvent:_,active:b,activeNodeRect:w,containerNodeRect:x,draggableNodes:C,droppableContainers:N,dragOverlay:L,over:A,measuringConfiguration:W,scrollableAncestors:U,scrollableAncestorRects:F,windowRect:K}=bC(),oe=v.useContext(Jf),P=jR(b?.id),te=vC(u,{activatorEvent:_,active:b,activeNodeRect:w,containerNodeRect:x,draggingNodeRect:L.rect,over:A,overlayNodeRect:L.rect,scrollableAncestors:U,scrollableAncestorRects:F,transform:oe,windowRect:K}),Z=mb(w),me=OR({config:r,draggableNodes:C,droppableContainers:N,measuringConfiguration:W}),ee=Z?L.setRef:void 0;return Ot.createElement(ER,null,Ot.createElement(kR,{animation:me},b&&P?Ot.createElement(NR,{key:P,id:b.id,ref:ee,as:f,activatorEvent:_,adjustScale:t,className:g,transition:c,rect:Z,style:{zIndex:m,...o},transform:te},n):null))}),PR=128,zR=512,gc=100,HR="too_many_detached_terminals",UR=64,FR=4096;function yC(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>PR)return null;const n=t.workspaces.map($R);if(n.some(u=>u===null))return null;const r=n,o=new Set,c=new Set;for(const u of r){if(o.has(u.id))return null;o.add(u.id);for(const f of u.tabs){if(c.has(f.id))return null;c.add(f.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function SC(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>gc}):!1}function $R(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>zR)return null;const n=t.tabs.map(KR);if(n.some(o=>o===null))return null;const r=YR(t.detachedTerminalIds,gc);return r===null?null:{id:t.id,title:t.title,defaultCwd:VR(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function KR(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=WR(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function WR(e){if(!e||typeof e!="object")return null;let t=0;return gv(e,1,()=>(t+=1,t<=FR))}function gv(e,t,n){if(!e||typeof e!="object"||t>UR||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=gv(r.first,t+1,n),c=gv(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:qR(r.ratio),first:o,second:c}}function qR(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function VR(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function YR(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const wC=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],XR="nterminal-focus",GR=/^[A-Za-z0-9_.:-]{1,128}$/;function ZR(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(XR)!=="terminal"?null:tp({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function tp(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!Bw(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!Bw(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function Bw(e){return typeof e=="string"&&GR.test(e)}const Kt="__main__",xC=128,QR=600*1e3,CC="nterminal.clientDiagnostics.v1",kC="nterminal.terminalDiagnosticsCursor.v1",ip=150,JR=24,eN=160,tN=48*1024,iN="terminal-connection-recovery";let jw=!1,pu=null,mu=null,wg=0;function nN(){jw||typeof window>"u"||(jw=!0,Sn("page.load",{navigation:yN(),visibility:document.visibilityState,online:navigator.onLine,viewport:NC(),standalone:bN()}),document.addEventListener("visibilitychange",()=>{Sn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Sn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Sn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Sn("network.online")),window.addEventListener("offline",()=>Sn("network.offline")),window.addEventListener("focus",()=>Sn("window.focus")),window.addEventListener("blur",()=>Sn("window.blur")),window.addEventListener("error",e=>{Sn("runtime.error",{message:e.message,source:SN(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Sn("runtime.unhandledrejection",{reason:wN(e.reason)})}))}function Sn(e,t={}){const n={id:hN(),at:new Date().toISOString(),event:Gu(e,80),data:RC({...t,visibility:t.visibility??vN(),online:t.online??_N(),viewport:t.viewport??NC()})},r=vb();return r.push(n),uN(r.slice(-ip)),n}function vb(){try{const e=window.localStorage.getItem(CC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(dN).filter(n=>n!==null).slice(-ip):[]}catch{return[]}}async function _b(e,t=fetch){if(pu)return pu;const n=vb(),r={reason:Gu(e,80),events:n},o=JSON.stringify(r);pu=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await pu}finally{pu=null}}function np(){return TC().events.length>0}async function sN(e=fetch){if(mu)return mu;mu=rN(e);try{return await mu}finally{mu=null}}async function rN(e){const t=TC();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(cN(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function TC(){const e=EC(),t=vb().filter(o=>aN(o)&&lN(o,e)),n=[];let r=Iw([]);for(const o of t){const c=[...n,o],u=Iw(c);if(oN(u)>tN)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function Iw(e){return JSON.stringify({reason:iN,events:e})}function aN(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function oN(e){return new TextEncoder().encode(e).byteLength}function lN(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(DC(e))}function EC(){try{const e=window.localStorage.getItem(kC);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-ip):[]}}catch{return null}}function cN(e){const t=e.at(-1);if(!t)return;const n=EC(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(DC(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-ip)};try{window.localStorage.setItem(kC,JSON.stringify(o))}catch{}}function uN(e){try{window.localStorage.setItem(CC,JSON.stringify(e))}catch{}}function dN(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:Gu(t.id,128)}:{},at:t.at.slice(0,40),event:Gu(t.event,80),...t.data&&typeof t.data=="object"?{data:RC(t.data)}:{}}}function hN(){return wg=(wg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${wg.toString(36)}`.slice(0,128)}function DC(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function RC(e){const t={};for(const[n,r]of Object.entries(e).slice(0,JR)){const o=Gu(n,64);if(!o||fN(o))continue;const c=pN(r);c!==void 0&&(t[o]=c)}return t}function fN(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function pN(e){if(typeof e=="string")return mN(e,eN);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Gu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function mN(e,t){return gN(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function gN(e){return e.replace(/https?:\/\/[^\s"'<>]+/gi,"[url]").replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,"Bearer [redacted]").replace(/\b[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,"[redacted]").replace(/\b((?:auth|authorization|cookie|password|secret|session|sessionid|session_id|token)[a-z0-9_.:-]*\s*[:=]\s*)[^\s&,;]+/gi,"$1[redacted]").replace(/\b(nterminal_session|nterminal_device)\s*=\s*[^\s;,]+/gi,"$1=[redacted]").replace(/\b[A-Za-z0-9+/_=-]{48,}\b/g,"[redacted]")}function vN(){return typeof document>"u"?void 0:document.visibilityState}function _N(){return typeof navigator>"u"?void 0:navigator.onLine}function NC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function bN(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function yN(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function SN(e){if(!e)return null;try{const t=new URL(e);return t.pathname.split("/").pop()||t.pathname}catch{return e.split("/").pop()??e}}function wN(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const MC="nterminal.notifications.completionEnabled",bb="nterminal.notifications.completionToastEnabled",yb="nterminal.notifications.completionToastDurationSeconds",Sb="nterminal.notifications.completionToastPersistent",vv="nterminal:completion-toast-display",_v="nterminal:notification-focus",zu=6.5,bv=2,yv=60;function sp(){return typeof window<"u"&&"Notification"in window}function wb(){try{return window.localStorage.getItem(MC)==="true"}catch{return!1}}function Pw(e){try{window.localStorage.setItem(MC,e?"true":"false")}catch{}}function Jo(){return{enabled:TN(),durationSeconds:kN(),persistUntilDismissed:EN()}}function xN(e){if(typeof window<"u"){try{window.localStorage.setItem(bb,e?"true":"false")}catch{}xb()}return Jo()}function zw(e){const t=LC(e);if(typeof window<"u"){try{window.localStorage.setItem(yb,String(t))}catch{}xb()}return Jo()}function CN(e){if(typeof window<"u"){try{window.localStorage.setItem(Sb,e?"true":"false")}catch{}xb()}return Jo()}function AC(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===bb||n.key===yb||n.key===Sb)&&e()};return window.addEventListener(vv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(vv,e),window.removeEventListener("storage",t)}}function vc(){return sp()?window.Notification.permission:"unsupported"}function kN(){if(typeof window>"u")return zu;try{const e=window.localStorage.getItem(yb);return e===null?zu:LC(Number(e))}catch{return zu}}function TN(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(bb)!=="false"}catch{return!0}}function EN(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Sb)==="true"}catch{return!1}}function LC(e){if(!Number.isFinite(e))return zu;const t=Math.round(e*2)/2;return Math.max(bv,Math.min(yv,t))}function xb(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(vv))}async function OC(){if(!sp())return"unsupported";try{return await window.Notification.requestPermission()}catch{return vc()}}function DN(e){if(!sp()||vc()!=="granted"||!wb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=tp({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),RN(r)})}catch{}}function RN(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(_v,{detail:e}))}const Hw="nterminal.push.clientId",NN=2e4,Uw=[5e3,3e4,12e4];function Zr(){try{const e=window.localStorage.getItem(Hw);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${wv()}`;return window.localStorage.setItem(Hw,t),t}catch{return`client-${wv()}`}}function MN(){return`page-${wv()}`}function rp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=PN(),n=zN(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function AN(e,t){const n=rp();if(!n.supported)throw new Error(n.reason);if((vc()==="granted"?"granted":await OC())!=="granted")throw new Error("permission_denied");const o=Zr(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await UN(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:IC(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:jC(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:BC(n.deviceKind),alwaysNotify:t})}async function LN(e){const t=rp();if(!t.supported||vc()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Zr(),c=await FN(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&Sv(r,u.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&Sv(r,f.publicKey);g||await r.unsubscribe();const m=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:IC(f.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:jC(m),deviceKind:t.deviceKind,displayMode:t.displayMode,label:BC(t.deviceKind),alwaysNotify:!1}),!0}function ON(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=_=>{t||n||(n=!0,LN(e).then(b=>{r=0,b&&Sn("push.subscription.reconciled",{trigger:_})}).catch(b=>{if(Sn("push.subscription.reconcile_failed",{trigger:_,reason:b instanceof Error?b.message:String(b)}),!t&&r<Uw.length){const w=Uw[r++];o=window.setTimeout(()=>{o=null,u("retry")},w)}}).finally(()=>{n=!1}))},f=_=>{c(),r=0,u(_)},g=()=>f("online"),m=()=>f("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",m),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",m)}}async function BN(e){const t=Zr();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function jN(e,t){await e.updatePushNotificationDevice({clientId:Zr(),alwaysNotify:t})}function IN(e){if(typeof window>"u")return()=>{};const t=Zr(),n=MN();let r=null,o=!1;const c=(m=!0)=>{const _=rp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:HN(),focused:document.hasFocus(),deviceKind:_.deviceKind,displayMode:_.displayMode,browserNotificationsEnabled:wb()&&vc()==="granted",active:m}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),NN))},f=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",f),window.addEventListener("blur",f),document.addEventListener("visibilitychange",f),window.addEventListener("pagehide",g),c(!0),u(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",f),window.removeEventListener("blur",f),document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",g),c(!1)}}function PN(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function zN(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function BC(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function HN(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function jC(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function UN(e,t){const n=await e.pushManager.getSubscription();return n?Sv(n,t)?n:(await n.unsubscribe(),null):null}function Sv(e,t){const n=e.options.applicationServerKey;return n?PC(n)===t:!0}async function FN(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return PC(t)}function IC(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let u=0;u<r.length;u+=1)c[u]=r.charCodeAt(u);return o}function PC(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function wv(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const $N=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function KN(e,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:$N(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}const WN=e=>{let t="",n=!1;for(const r of e){if(r==="-"||r==="_"||r<=" "){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t};const qN=e=>{const t=WN(e);return t.charAt(0).toUpperCase()+t.slice(1)};const xv=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const Fo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function xg(e){return e!=null}function VN(e,t={}){const n=t.attributeNames??{},r=w=>n[w]??w,o=e.size??e.width??Fo.width,c=e.size??e.height??Fo.height,u=e.aliases?.filter(w=>typeof w=="string"&&w.trim()!=="").map(w=>`lucide-${w}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...u],g=t.className?.split(" ").filter(Boolean)??[],m=t.includeDefaultClasses===!1?xv(...g):xv("lucide",...f,...g),_=t.absoluteStrokeWidth?Number(t.strokeWidth??Fo["stroke-width"])*Number(e.size??e.width??Fo.width)/Number(t.size??t.width??Fo.width):t.strokeWidth??Fo["stroke-width"];return["svg",{...Object.entries(Fo).reduce((w,[x,C])=>(w[r(x)]=C,w),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&xg(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&xg(t.width)&&{[r("width")]:t.width},..."height"in t&&xg(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:_,...m&&{[r("class")]:m},[r("viewBox")]:`0 0 ${o} ${c}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(w=>{const[x,C,N]=w,L=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...C}:C;return N?[x,L,N]:[x,L]})]}function YN(e,t={}){return VN(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const XN=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},GN=v.createContext({}),ZN=()=>v.useContext(GN),QN=v.forwardRef(({color:e,size:t,width:n,height:r,strokeWidth:o,absoluteStrokeWidth:c,nonScalingStroke:u,className:f="",children:g,iconNode:m=[],icon:_={node:m,aliases:[],size:24},...b},w)=>{const{size:x=24,strokeWidth:C=2,absoluteStrokeWidth:N=!1,nonScalingStroke:L=!1,color:A="currentColor",className:W=""}=ZN()??{},U=!!g||XN(b),[F,K,oe=[]]=YN(_,{color:e??A,width:n??t??x,height:r??t??x,strokeWidth:o??C,absoluteStrokeWidth:c??N,nonScalingStroke:u??L,className:xv(W,f),hasA11yProp:U,attributes:b});return v.createElement(F,{ref:w,...K},[...oe.map(([P,te])=>v.createElement(P,te)),...Array.isArray(g)?g:[g]])});function na(e,t=[],n=[]){const r=typeof e=="string"?KN(e,t,n):e,o=v.forwardRef(({className:c,...u},f)=>v.createElement(QN,{ref:f,icon:r,className:c,...u}));return r.name&&(o.displayName=qN(r.name)),o}const zC={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};zC.node;const JN=na(zC);const HC={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};HC.node;const eM=na(HC);const UC={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};UC.node;const FC=na(UC);const $C={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};$C.node;const Fw=na($C);const KC={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};KC.node;const tM=na(KC);const WC={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};WC.node;const iM=na(WC);const qC={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};qC.node;const nM=na(qC);const VC={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};VC.node;const $w=na(VC);const YC={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};YC.node;const Kw=na(YC);function Gr(e,t){const n=[Kt,...t.map(u=>u.id)],r=new Set(n),o=new Set,c=[];for(const u of e??[])!r.has(u)||o.has(u)||(o.add(u),c.push(u));for(const u of n)o.has(u)||c.push(u);return c}function sM(e,t){return Gr(e,t).map(n=>n===Kt?null:n)}function rM(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function aM(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Ww="Local",oM=3e4,lM=2,cM=6,XC="nterminal.serverList.viewMode.v1";function uM(){try{return window.localStorage.getItem(XC)==="list"?"list":"stats"}catch{return"stats"}}function dM(e){try{window.localStorage.setItem(XC,e)}catch{}}function hM(e,t){const n=new Map(e.map(r=>[r.id,r]));return Gr(t,e).flatMap(r=>{if(r===Kt)return[{kind:"main",id:Kt}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function qw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function GC(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Ss(e.value.cpuPercent)} ${Cb(e.value)}`,`MEM ${Ss(e.value.memoryPercent)} ${ea(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Ss(e.value.diskPercent)} ${ea(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Ss(e.value.swapPercent)} ${ea(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function Vw(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Ss(e.value.cpuPercent)} (${Cb(e.value)})`,`RAM ${Ss(e.value.memoryPercent)} (${ea(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Ss(e.value.diskPercent)} (${ea(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Ss(e.value.swapPercent)} (${ea(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function fM(e,t){const n=GC(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function Ss(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Cb(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Cv(e.cpuPercent/100*t)}/${t} cores`}function ea(e,t){return!Yw(e)||!Yw(t)?"–/–":pM(e,t)}function pM(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Cv(e/r)}/${Cv(t/r)} ${n}`}function Cv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Yw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Mh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function mM(e){return[{label:"CPU",percent:Ss(e.cpuPercent),detail:Cb(e),tone:Mh(e.cpuPercent)},{label:"MEM",percent:Ss(e.memoryPercent),detail:ea(e.memoryUsedBytes,e.memoryTotalBytes),tone:Mh(e.memoryPercent)},{label:"DISK",percent:Ss(e.diskPercent),detail:ea(e.diskUsedBytes,e.diskTotalBytes),tone:Mh(e.diskPercent)},{label:"SWAP",percent:Ss(e.swapPercent),detail:ea(e.swapUsedBytes,e.swapTotalBytes),tone:Mh(e.swapPercent)}]}function gM({entry:e}){return e?.status==="offline"?d.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?d.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t}),d.jsx("span",{className:"server-list-stat-value",children:"–"})]}),d.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):d.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:Vw(e),"aria-label":Vw(e),children:mM(e.value).map(t=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t.label}),d.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),d.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function Xw({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,onManageAccounts:u,onServerInfo:f,renderServerChildren:g,compact:m=!1}){const[_,b]=v.useState([]),[w,x]=v.useState([Kt]),[C,N]=v.useState(null),[L,A]=v.useState(null),[W,U]=v.useState(""),F=v.useRef(null),[K,oe]=v.useState(()=>uM()),[P,te]=v.useState(null),[Z,me]=v.useState(null),[ee,Y]=v.useState({}),X=v.useRef({}),V=v.useRef(0),ne=v.useRef([]),O=v.useRef([Kt]),R=v.useRef(null);v.useEffect(()=>{ne.current=_},[_]),v.useEffect(()=>{const E=Gr(w,_);O.current=E,qw(E,w)||x(E)},[_,w]),v.useEffect(()=>{let E=!1;return e.listAgents().then(z=>{E||(b(z.agents),x(Gr(z.serverOrder,z.agents)))}).catch(()=>{}),e.getMainInfo().then(z=>{E||N(z.name)}).catch(()=>{}),()=>{E=!0}},[e,o]),v.useEffect(()=>{L&&(F.current?.focus(),F.current?.select())},[L]),v.useEffect(()=>{let E=!1;function z(){const Ae=[{key:Kt,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},..._.map(pe=>({key:pe.id,load:()=>e.getAgentStats(pe.id),probe:async()=>(await e.pingAgent(pe.id)).ok}))],ie=new Set(Ae.map(pe=>pe.key));for(const pe of Object.keys(X.current))ie.has(pe)||delete X.current[pe];Y(pe=>{const Te={};for(const De of ie)De in pe&&(Te[De]=pe[De]);return Te});for(const pe of Ae)pe.load().then(Te=>{E||(X.current[pe.key]=0,Y(De=>ie.has(pe.key)?{...De,[pe.key]:{status:"online",value:Te,stale:!1}}:De))}).catch(async Te=>{if(E)return;if(Te instanceof fn&&Te.status===401&&pe.key===Kt){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(pe.key===Kt&&Te instanceof fn){X.current[pe.key]=0,Y(Ee=>{if(!ie.has(pe.key))return Ee;const je=Ee[pe.key];return{...Ee,[pe.key]:{status:"online",value:je?.value??null,stale:!0}}});return}if(pe.probe)try{if(await pe.probe()){if(E)return;X.current[pe.key]=0,Y(Ee=>{if(!ie.has(pe.key))return Ee;const je=Ee[pe.key];return{...Ee,[pe.key]:{status:"online",value:je?.value??null,stale:!0}}});return}}catch(Ee){if(E)return;if(Ee instanceof fn&&Ee.status===401){r?.({source:pe.key===Kt?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const De=(X.current[pe.key]??0)+1;X.current[pe.key]=De,De>=lM&&Y(Ee=>ie.has(pe.key)?{...Ee,[pe.key]:{status:"offline",value:Ee[pe.key]?.value??null,stale:!0}}:Ee)})}z();const we=window.setInterval(z,oM);return()=>{E=!0,window.clearInterval(we)}},[e,_,r]);function I(E){E==="main"?(U(C??""),A({kind:"main"})):(U(E.name),A({kind:"agent",id:E.id}))}async function de(){if(!L)return;const E=W.trim(),z=L;if(A(null),z.kind==="main"){const we=E||"";try{const Ae=await e.renameMain(we);N(Ae.name)}catch{}}else{if(!E)return;const we=_.find(Ae=>Ae.id===z.id)?.name;b(Ae=>Ae.map(ie=>ie.id===z.id?{...ie,name:E}:ie));try{await e.renameAgent(z.id,E)}catch{we!==void 0&&b(Ae=>Ae.map(ie=>ie.id===z.id?{...ie,name:we}:ie))}}}function ge(){A(null)}function M(E){oe(E),dM(E)}function q(E,z,we){if(E===z)return;const Ae=Gr(O.current,ne.current),ie=Ae.findIndex($e=>$e===E),pe=Ae.findIndex($e=>$e===z);if(ie<0||pe<0)return;const Te=[...Ae],[De]=Te.splice(ie,1);if(!De)return;const Ee=Te.findIndex($e=>$e===z);if(Ee<0)return;const je=we==="before"?Ee:Ee+1;if(Te.splice(je,0,De),qw(Te,Ae))return;const Ve=V.current+1;V.current=Ve,O.current=Te,x(Te),e.reorderAgents(Te).then($e=>{if(V.current===Ve){ne.current=$e.agents;const St=Gr($e.serverOrder,$e.agents);O.current=St,b($e.agents),x(St)}}).catch(async()=>{if(V.current===Ve)try{const $e=await e.listAgents();if(V.current===Ve){ne.current=$e.agents;const St=Gr($e.serverOrder,$e.agents);O.current=St,b($e.agents),x(St)}}catch{V.current===Ve&&(O.current=Ae,x(Ae))}})}function he(E,z){const we=Gr(O.current,ne.current),Ae=we.findIndex(pe=>pe===E),ie=we[Ae+z];Ae<0||!ie||q(E,ie,z<0?"before":"after")}function J(E,z){z.pointerType==="mouse"&&z.button!==0||(z.stopPropagation(),R.current={sourceId:E,pointerId:z.pointerId,startX:z.clientX,startY:z.clientY,active:!1,targetId:null,placement:"after"},z.currentTarget.setPointerCapture?.(z.pointerId))}function ye(E){const z=R.current;if(!z||z.pointerId!==E.pointerId)return;const we=Math.hypot(E.clientX-z.startX,E.clientY-z.startY);if(!z.active){if(we<cM)return;z.active=!0,te(z.sourceId)}const ie=document.elementFromPoint(E.clientX,E.clientY)?.closest("[data-server-id]"),pe=ie?.dataset.serverId??null;if(!ie||!pe||pe===z.sourceId){z.targetId=null,me(null);return}const Te=ie.getBoundingClientRect(),De=E.clientY<Te.top+Te.height/2?"before":"after";z.targetId=pe,z.placement=De,me({serverId:pe,placement:De})}function ve(E){const z=R.current;!z||z.pointerId!==E.pointerId||(E.stopPropagation(),E.currentTarget.releasePointerCapture?.(E.pointerId),R.current=null,te(null),me(null),z.active&&z.targetId&&q(z.sourceId,z.targetId,z.placement))}function Le(E){const z=R.current;z&&z.pointerId===E.pointerId&&E.currentTarget.releasePointerCapture?.(E.pointerId),R.current=null,te(null),me(null)}const Ne=C?.trim()||Ww,Fe=L?.kind==="main",He=K==="stats",Pe=hM(_,w),Ze=Pe.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:Ne},..._.map(E=>({agentId:E.id,label:E.name}))])},[_,Ne,c]),m?d.jsx("div",{className:"server-list server-list--compact",children:Pe.map(E=>{const z=E.kind==="main",we=z?Ne:E.agent.name,Ae=z?Kt:E.id,ie=ee[Ae],pe=GC(ie);return d.jsxs("button",{type:"button",className:`server-list-chip${(z?t===null:t===E.id)?" server-list-chip--active":""}`,onClick:()=>n(z?null:E.id),"aria-label":`${we}${pe?` — ${pe}`:""}`,title:`${we}${pe?` — ${pe}`:""}`,children:[d.jsx("span",{className:"server-list-chip-initial",children:aM(we)}),d.jsx("span",{className:"server-list-chip-pip","data-status":rM(ie)})]},E.id)})}):d.jsxs("div",{className:`server-list server-list--${K}`,children:[d.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="list",onClick:()=>M("list"),title:"Show server names only",children:"List"}),d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="stats",onClick:()=>M("stats"),title:"Show resource usage",children:"Stats"})]}),Pe.map(E=>{const z=E.kind==="main",we=z?Ne:E.agent.name,Ae=z?Kt:E.id,ie=z?t===null:t===E.id,pe=z?Fe:L?.kind==="agent"&&L.id===E.id,Te=g?.({agentId:z?null:E.id,serverId:E.id,label:we,active:ie}),De=Z?.serverId===E.id&&P!==E.id?` server-list-section--drop-target server-list-section--drop-${Z.placement}`:"";return d.jsxs("section",{className:`server-list-section${De}`,"aria-label":`${we} server`,children:[d.jsx("div",{className:["server-list-row",P===E.id?"server-list-row--dragging":"",Z?.serverId===E.id&&P!==E.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":E.id,children:pe?d.jsxs(d.Fragment,{children:[Ze?d.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,d.jsx("form",{className:"server-list-editor",onSubmit:Ee=>{Ee.preventDefault(),de()},children:d.jsx("input",{ref:F,"aria-label":z?"Rename main server":`Rename ${we}`,value:W,onChange:Ee=>U(Ee.target.value),onBlur:()=>{de()},onKeyDown:Ee=>{Ee.key==="Escape"&&(Ee.preventDefault(),ge())},placeholder:z?Ww:void 0})})]}):d.jsxs(d.Fragment,{children:[Ze?d.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":E.id,title:"Drag to reorder","aria-label":`Reorder ${we}`,"aria-grabbed":P===E.id,onPointerDown:Ee=>J(E.id,Ee),onPointerMove:ye,onPointerUp:ve,onPointerCancel:Le,onKeyDown:Ee=>{(Ee.key==="ArrowUp"||Ee.key==="ArrowDown")&&(Ee.preventDefault(),Ee.stopPropagation(),he(E.id,Ee.key==="ArrowUp"?-1:1))},onClick:Ee=>Ee.stopPropagation(),children:"::"}):null,d.jsxs("div",{className:`server-list-item${ie?" server-list-item--active":""}`,title:fM(we,ee[Ae]),children:[d.jsxs("div",{className:"server-list-item-header",children:[d.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(z?null:E.id),onDoubleClick:Ee=>{Ee.preventDefault(),I(z?"main":{id:E.id,name:we})},children:[d.jsx("span",{className:"server-list-dot"}),d.jsx("span",{className:"server-list-name",title:z?void 0:E.agent.url??"Outbound connection to main",children:we})]}),u?d.jsx("span",{className:"server-list-provider-actions","aria-label":`${we} account management`,children:["codex","claude"].map(Ee=>d.jsx("button",{type:"button",className:"server-list-provider-button",title:`Manage ${Ee==="codex"?"Codex":"Claude"} accounts`,"aria-label":`Manage ${Ee==="codex"?"Codex":"Claude"} accounts on ${we}`,onClick:()=>u({agentId:z?null:E.id,label:we},Ee),children:d.jsx("img",{src:`/brand/${Ee}.webp`,alt:""})},Ee))}):null,f&&d.jsx("button",{type:"button",className:"server-list-provider-button",title:"Server information","aria-label":`Server information: ${we}`,onClick:()=>f({agentId:z?null:E.id,label:we}),children:d.jsx(iM,{size:17})})]}),He?d.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(z?null:E.id),children:d.jsx(gM,{entry:ee[Ae]})}):null]})]})}),Te?d.jsx("div",{className:"server-list-children",children:Te}):null]},E.id)})]})}function vM({provider:e,serverLabel:t,api:n,onClose:r,onLoginStarted:o,onLoginFinished:c}){const[u,f]=v.useState(null),[g,m]=v.useState(!0),[_,b]=v.useState(null),[w,x]=v.useState(null),[C,N]=v.useState(""),[L,A]=v.useState(!1),[W,U]=v.useState(null),[F,K]=v.useState(!1),[oe,P]=v.useState(()=>Date.now()),te=v.useRef(0),Z=v.useCallback(async(V=!1)=>{const ne=++te.current;V||(m(!0),x(null));try{const O=await n.getAccounts();ne===te.current&&f(O)}catch(O){ne===te.current&&!V&&x(Ah(O))}finally{ne===te.current&&!V&&m(!1)}},[n]),me=v.useMemo(()=>u?.providers.find(V=>V.provider===e)??null,[e,u]);v.useEffect(()=>(Z(),()=>{te.current+=1}),[Z]),v.useEffect(()=>{const V=ne=>{ne.key==="Escape"&&!_&&(L?A(!1):r())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[r,_,L]),v.useEffect(()=>{const V=window.setInterval(()=>P(Date.now()),6e4);return()=>window.clearInterval(V)},[]),v.useEffect(()=>{if(!me?.pendingLogin||_)return;const ne=window.setInterval(()=>{Z(!0)},1500);return()=>window.clearInterval(ne)},[_,me?.pendingLogin,Z]),v.useEffect(()=>{const V=me?.pendingLogin;!V?.ready||!V.terminalId||V.terminalId===W||F||(K(!0),c(V.terminalId).then(()=>{U(V.terminalId)}).catch(ne=>{x(Ah(ne))}).finally(()=>{K(!1)}))},[W,F,c,me?.pendingLogin]);async function ee(V,ne){const O=++te.current;m(!1),b(V),x(null);try{const R=await ne();O===te.current&&f(R)}catch(R){O===te.current&&x(Ah(R))}finally{O===te.current&&b(null)}}async function Y(){b("login"),x(null);try{const V=await n.beginAccountLogin(e);o(V.terminal),await Z()}catch(V){x(Ah(V))}finally{b(null)}}const X=e==="codex"?"Codex":"Claude";return d.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:V=>{V.target===V.currentTarget&&!_&&r()},children:[d.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${X} accounts on ${t}`,children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"account-dialog-title",children:[d.jsx(bM,{provider:e}),d.jsxs("div",{children:[d.jsxs("h2",{children:[X," accounts"]}),d.jsx("p",{children:t})]})]}),d.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",onClick:r,disabled:!!_,children:"x"})]}),d.jsxs("div",{className:"account-dialog-scroll",children:[g?d.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,!g&&me?d.jsx(_M,{provider:e,status:me,pendingAction:_,clock:oe,label:C,onLabelChange:N,onSelect:V=>{ee(`select:${V}`,()=>n.selectAccount(e,V))},onDelete:V=>{ee(`delete:${V}`,()=>n.removeAccount(e,V))},onRefresh:V=>{ee(`refresh:${V}`,()=>n.refreshAccount(e,V))},onBeginLogin:()=>{Y()},onCompleteLogin:()=>{ee("complete",()=>n.completeAccountLogin(e,C))},onCancelLogin:()=>{ee("cancel",()=>n.cancelAccountLogin(e))},onRequestTerminate:()=>A(!0),loginPaneClosed:!me.pendingLogin?.terminalId||W===me.pendingLogin.terminalId,loginPaneClosing:F}):null,w?d.jsx("p",{className:"account-dialog-error",role:"alert",children:w}):null]}),d.jsxs("footer",{className:"account-dialog-footer",children:[d.jsx("button",{type:"button",onClick:()=>{Z()},disabled:g||!!_,children:"Refresh"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!_,children:"Close"})]})]}),L?d.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:V=>{V.target===V.currentTarget&&!_&&A(!1)},children:d.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${X} sessions`,children:[d.jsxs("h3",{children:["Exit all ",X," sessions?"]}),d.jsxs("p",{children:["This stops detected ",X," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),e==="codex"?d.jsx("p",{children:"The shared Codex daemon will also stop. All Codex work using that daemon is affected."}):null,d.jsxs("div",{children:[d.jsx("button",{type:"button",onClick:()=>A(!1),disabled:!!_,children:"Cancel"}),d.jsx("button",{type:"button",className:"danger-button",disabled:!!_,onClick:()=>{A(!1),ee("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function _M({provider:e,status:t,pendingAction:n,clock:r,label:o,onLabelChange:c,onSelect:u,onDelete:f,onRefresh:g,onBeginLogin:m,onCompleteLogin:_,onCancelLogin:b,onRequestTerminate:w,loginPaneClosed:x,loginPaneClosing:C}){const N=t.runningProcesses??[],L=t.runningPanes.length>0||N.length>0||t.processCheckUnavailable===!0,A=(e==="codex"||!t.terminationAcknowledged)&&L,W=L||t.terminationAcknowledged?d.jsxs("div",{className:"account-dialog-running",role:"status",children:[d.jsx("strong",{children:t.terminationAcknowledged?"Termination requested.":`Exit ${e==="codex"?"Codex":"Claude"} before changing accounts.`}),t.runningPanes.map(U=>d.jsxs("span",{children:[d.jsx("b",{children:U.title}),d.jsx("small",{children:U.cwd})]},U.terminalId)),N.map(U=>d.jsxs("span",{children:[d.jsxs("b",{children:[U.command," ",d.jsxs("em",{children:["PID ",U.pid]})]}),d.jsx("small",{children:U.role==="daemon"?"Shared Codex daemon / manager":"Detected provider process on this server"})]},U.pid)),t.processCheckUnavailable&&!t.terminationAcknowledged?d.jsxs("span",{children:[d.jsx("b",{children:"Process check unavailable"}),d.jsx("small",{children:"Account changes stay blocked until this server can verify provider processes."})]}):null,t.terminationAcknowledged?d.jsxs("span",{children:[d.jsx("b",{children:"Proceeding after termination request"}),d.jsx("small",{children:"You can now change accounts even if a provider process takes time to exit."})]}):null,!t.processCheckUnavailable&&L?d.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:w,children:["Exit all ",e==="codex"?"Codex":"Claude"," sessions"]}):null]}):null;return t.pendingLogin?d.jsxs(d.Fragment,{children:[W,d.jsxs("div",{className:"account-dialog-section",children:[d.jsx("p",{children:t.pendingLogin.ready?C?"Sign-in completed. Closing the login terminal...":"Sign-in completed. Name this account to save it in the server vault.":"Complete sign-in in the login terminal. This dialog will continue automatically."}),t.pendingLogin.ready&&x?d.jsxs("label",{className:"account-dialog-label",children:["Account name",d.jsx("input",{value:o,onChange:U=>c(U.target.value),placeholder:`${e==="codex"?"Codex":"Claude"} account`,maxLength:80,autoFocus:!0})]}):null,d.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready&&x?d.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:_,children:"Save account"}):null,d.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:b,children:"Cancel and restore previous"})]})]})]}):d.jsxs(d.Fragment,{children:[W,d.jsxs("div",{className:"account-dialog-section",children:[d.jsxs("div",{className:"account-dialog-section-heading",children:[d.jsx("span",{children:"Saved accounts"}),d.jsx("button",{type:"button",className:"primary-button",disabled:A||!!n,onClick:m,children:"Add account"})]}),t.profiles.length===0?d.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map(U=>{const F=U.id===t.activeProfileId;return d.jsxs("article",{className:`account-profile${F?" account-profile--active":""}`,children:[d.jsxs("div",{children:[d.jsx("strong",{children:U.label}),d.jsxs("small",{title:SM(U.expiresAt),children:[F?"Active":"Saved"," · ",yM(U.expiresAt,r)," · ",wM(U.updatedAt,r)]})]}),d.jsxs("div",{className:"account-profile-actions",children:[d.jsx("button",{type:"button",disabled:A||!!n||F,onClick:()=>u(U.id),children:"Use"}),d.jsx("button",{type:"button",disabled:F&&L||!!n,onClick:()=>g(U.id),children:"Refresh"}),d.jsx("button",{type:"button",className:"danger-button",disabled:!!n||F,onClick:()=>f(U.id),children:"Remove"})]})]},U.id)})]})]})}function bM({provider:e}){return d.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function yM(e,t=Date.now()){if(!e||!Number.isFinite(Date.parse(e)))return"Session expiry unavailable";const n=Math.ceil((Date.parse(e)-t)/6e4);if(n<=0)return"Session expired";const r=Math.floor(n/1440),o=Math.floor(n%1440/60),c=n%60;return`Session ${[r?`${r}d`:null,o?`${o}h`:null,`${c}m`].filter(Boolean).join(" ")} remaining`}function SM(e){return!e||!Number.isFinite(Date.parse(e))?"Session expiry timestamp unavailable":`Session expires ${new Date(e).toLocaleString()}`}function wM(e,t=Date.now()){const n=Math.max(0,Math.floor((t-Date.parse(e))/6e4));return!Number.isFinite(n)||n>1440?"Updated earlier":n===0?"Updated now":n<60?`Updated ${n}m ago`:`Updated ${Math.floor(n/60)}h ago`}function Ah(e){return e instanceof fn?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",codex_daemon_stop_failed:"Could not stop the shared Codex daemon. No account was switched. Stop the daemon and try again.",account_operation_busy:"Another account operation is in progress. Try again shortly.",account_process_check_unavailable:"Could not verify running CLI processes. No account was switched.",account_credential_changed:"Credentials changed during refresh. Refresh the account list before trying again.",account_login_already_pending:"Finish or cancel the current sign-in first.",account_login_not_complete:"The provider login has not finished yet.",account_refresh_failed:"The provider rejected this refresh. Sign in again to update the account.",account_refresh_unavailable:"The provider refresh endpoint is temporarily unavailable.",preview_mode:"Account changes are disabled in preview mode."}[e.message]??"The account operation could not be completed.":"The account operation could not be completed."}function xM(e){const t=new Map(e.map(c=>[c.pid,{process:c,children:[],count:1,cpuPercent:c.cpuPercent,memoryBytes:c.memoryBytes}])),n=[];for(const c of t.values()){const u=t.get(c.process.ppid);u&&u!==c?u.children.push(c):n.push(c)}const r=[...n],o=new Set;for(let c=0;c<r.length;c++){const u=r[c];o.add(u.process.pid);for(const f of u.children)r.push(f)}for(const c of t.values())o.has(c.process.pid)||(c.children=[],n.push(c));for(let c=r.length-1;c>=0;c--){const u=r[c];for(const f of u.children)u.count+=f.count,u.cpuPercent+=f.cpuPercent,u.memoryBytes+=f.memoryBytes}return n}const kv=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function CM({api:e,label:t,main:n,favorites:r,targets:o,onClose:c,onFavorite:u,onTarget:f,getRuntimeStatus:g,targetStatus:m}){const[_,b]=v.useState(null),[w,x]=v.useState(null),[C,N]=v.useState(!0),[L,A]=v.useState(!0),[W,U]=v.useState(null),[F,K]=v.useState(!1),[oe,P]=v.useState(null),[te,Z]=v.useState(""),[me,ee]=v.useState(!1),[Y,X]=v.useState(null),V=v.useRef(null),ne=v.useRef(c);ne.current=c;const O=v.useRef(!0);async function R(J=!1){N(!0);try{const ye=await e.getServerExternalIp(J);O.current&&b(ye)}catch{O.current&&b(ye=>({address:ye?.address??null,checkedAt:ye?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{O.current&&N(!1)}}async function I(){A(!0),U(null);try{const J=await e.getServerProcesses();O.current&&x(J)}catch{O.current&&U("Could not retrieve processes. The server may be offline or need an update.")}finally{O.current&&A(!1)}}v.useEffect(()=>(O.current=!0,R(),I(),()=>{O.current=!1}),[e]),v.useEffect(()=>{const J=document.activeElement;V.current?.focus();const ye=ve=>{if(ve.key==="Escape"){ve.preventDefault(),ve.stopImmediatePropagation(),ne.current();return}if(ve.key==="Tab"){const Le=[...V.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(Fe=>Fe.getClientRects().length>0),Ne=Le.indexOf(document.activeElement);Le.length&&(Ne<0||(ve.shiftKey?Ne===0:Ne===Le.length-1))&&(ve.preventDefault(),Le[ve.shiftKey?Le.length-1:0]?.focus()),ve.stopPropagation();return}V.current?.contains(ve.target)||(ve.preventDefault(),ve.stopImmediatePropagation())};return window.addEventListener("keydown",ye,!0),()=>{window.removeEventListener("keydown",ye,!0),J instanceof HTMLButtonElement&&J.isConnected&&J.focus({preventScroll:!0})}},[]);async function de(J){try{await navigator.clipboard.writeText(J),K(!1)}catch{K(!0)}}async function ge(J){if(!(me||!te.trim())){ee(!0),X(null);try{const ye=await e.renameServerProject(J,te.trim());if(!O.current)return;x(ve=>ve&&{...ve,projects:ve.projects.map(Le=>Le.path===J?{...Le,name:ye.name}:Le)}),P(null)}catch{O.current&&X("Could not save project name.")}finally{O.current&&ee(!1)}}}const M=v.useMemo(()=>w?.projects.filter(J=>J.category!=="services")??[],[w]),q=v.useMemo(()=>{const J=w?.projects.filter(ye=>ye.category==="services")??[];return M.length?[...J,{name:"Development tools",path:"",category:"tools",cpuPercent:M.reduce((ye,ve)=>ye+ve.cpuPercent,0),memoryBytes:M.reduce((ye,ve)=>ye+ve.memoryBytes,0),processes:M.flatMap(ye=>ye.processes)}]:J},[w,M]);function he(J){const ye=J.path?o.filter(ve=>ve.cwd===J.path||ve.cwd.startsWith(J.path.replace(/\/$/,"")+"/")):[];return d.jsxs(d.Fragment,{children:[J.category!=="services"&&d.jsxs("div",{className:"server-info-tool-name",children:[d.jsx(tM,{size:15,"aria-hidden":"true"}),d.jsx("strong",{children:J.path?J.name:"Shared tools"})]}),d.jsxs("div",{className:"server-info-path",children:[d.jsx("code",{children:J.path||"Shared across projects"}),J.path&&d.jsxs(d.Fragment,{children:[d.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{de(J.path)},children:d.jsx(Fw,{size:14})}),d.jsx("button",{disabled:L||me,title:"Rename project","aria-label":`Rename ${J.name}`,onClick:()=>{P(`${J.category}:${J.path}`),Z(J.name),X(null)},children:d.jsx(nM,{size:14})})]})]}),oe===`${J.category}:${J.path}`&&d.jsxs("form",{className:"server-info-rename",onSubmit:ve=>{ve.preventDefault(),ge(J.path)},children:[d.jsx("input",{"aria-label":"Project display name",maxLength:80,value:te,disabled:me,onChange:ve=>Z(ve.target.value)}),d.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:me||!te.trim(),children:d.jsx(eM,{size:16})}),d.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:me,onClick:()=>P(null),children:d.jsx(Kw,{size:16})}),Y&&d.jsx("small",{role:"alert",className:"server-info-error",children:Y})]}),J.path&&d.jsx("div",{className:"server-info-targets",children:ye.length?ye.map(ve=>d.jsxs("button",{onClick:()=>f(ve),title:`Open ${ve.label}`,children:[d.jsx(JN,{size:14}),ve.label]},ve.terminalId)):d.jsx("button",{disabled:!0,children:m??"No open tab"})}),d.jsx(kM,{processes:J.processes})]})}return d.jsx("div",{className:"server-info-backdrop",onMouseDown:J=>{J.target===J.currentTarget&&c()},children:d.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:V,onKeyDown:J=>J.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("h2",{children:t}),d.jsx("small",{children:n?"Main":"Secondary"})]}),d.jsx("button",{title:"Close","aria-label":"Close server information",onClick:c,children:d.jsx(Kw,{size:18})})]}),d.jsxs("div",{className:"server-info-body",children:[d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-ip",children:[d.jsx("h3",{title:"External IPv4",children:"IPv4"}),d.jsx("code",{title:_?.checkedAt?`Checked ${new Date(_.checkedAt).toLocaleString()}`:void 0,children:_?.address??(C?"Loading...":"Unavailable")}),d.jsxs("span",{className:"server-info-ip-actions",children:[_?.address&&d.jsx("button",{title:"Copy IPv4","aria-label":"Copy IPv4",onClick:()=>{de(_.address)},children:d.jsx(Fw,{size:16})}),d.jsx("button",{disabled:C,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{R(!0)},children:d.jsx($w,{size:16})})]})]}),_?.error&&d.jsx("p",{role:"status",className:"server-info-error",children:_.error})]}),d.jsxs("section",{children:[d.jsx("h3",{children:"Favorites"}),d.jsx("div",{className:"server-info-favorites",children:r.map(J=>d.jsxs("button",{onClick:()=>u(J),children:[d.jsx("strong",{children:J.tabName}),d.jsxs("small",{children:[J.workspaceName," · ",g?.(J)?.state??"Not loaded"]}),d.jsx("span",{children:J.providers.map(ye=>d.jsx("img",{alt:ye,src:`/brand/${ye}.webp`},ye))})]},`${J.workspaceId}:${J.tabId}`))}),!r.length&&d.jsx("small",{children:"No favorite tabs on this server."})]}),d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-heading",children:[d.jsx("h3",{children:"Projects"}),d.jsx("button",{disabled:L||me,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{I()},children:d.jsx($w,{size:16})})]}),L&&d.jsx("p",{role:"status",children:"Sampling processes..."}),W&&d.jsx("p",{role:"alert",className:"server-info-error",children:W}),w&&d.jsxs("small",{children:["Sampled ",new Date(w.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),q.map(J=>d.jsxs(QC,{className:"server-info-project",children:[d.jsxs("summary",{children:[d.jsxs("span",{className:"server-info-project-label",children:[d.jsx(FC,{className:"server-info-chevron",size:16,"aria-hidden":"true"}),d.jsx("strong",{title:J.name,children:J.name}),d.jsx("small",{className:"server-info-project-location",title:J.path,children:J.path}),d.jsx("small",{className:"server-info-project-count",title:`${J.processes.length} processes`,children:J.processes.length})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[J.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:kv(J.memoryBytes)})]})]}),d.jsx("div",{className:"server-info-project-body",children:J.category==="services"?he(J):M.map(ye=>d.jsx("div",{className:"server-info-tool-project",children:he(ye)},`${ye.category}:${ye.path}`))})]},`${J.category}:${J.path}`)),w&&!w.projects.length&&d.jsx("p",{children:"No processes found for the runtime user."})]}),F&&d.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function kM({processes:e}){const t=v.useMemo(()=>xM(e),[e]);return d.jsx("div",{className:"server-info-process-list",children:t.map(n=>d.jsx("div",{className:"server-info-process-root",children:d.jsx(ZC,{node:n})},n.process.pid))})}function ZC({node:e}){const t=e.process,n=d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"server-info-process-label",children:[e.children.length?d.jsx(FC,{className:"server-info-chevron",size:14,"aria-hidden":"true"}):d.jsx("span",{className:"server-info-process-dot","aria-hidden":"true"}),d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · ",t.manager??"Unmanaged",e.count>1?` · ${e.count} processes · Total`:""]})]})]}),d.jsxs("span",{className:"server-info-metrics",title:e.count>1?"Total for this process and its descendants":"Process usage",children:[d.jsxs("span",{children:[e.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:kv(e.memoryBytes)})]})]});return e.children.length?d.jsxs(QC,{className:"server-info-process-group",children:[d.jsx("summary",{className:"server-info-process",children:n}),d.jsxs("div",{className:"server-info-process-children",children:[d.jsxs("div",{className:"server-info-process",children:[d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · Parent"]})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[t.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:kv(t.memoryBytes)})]})]}),e.children.map(r=>d.jsx(ZC,{node:r},r.process.pid))]})]}):d.jsx("div",{className:"server-info-process",children:n})}function QC({children:e,className:t}){const[n,r]=v.useState(!1),[o,...c]=Ot.Children.toArray(e);return d.jsxs("details",{className:t,onToggle:u=>{u.target===u.currentTarget&&r(u.currentTarget.open)},children:[o,n?c:null]})}function TM({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[f,g]=v.useState(null),[m,_]=v.useState(""),[b,w]=v.useState("");async function x(){try{const[A,W,U]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(W.networks),u(U.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{x()},[]);async function C(A){await e.revokeDevice(A),await x()}async function N(A){await e.removeNetwork(A),await x()}async function L(A){A.preventDefault(),g(null);try{await e.addNetwork({value:m.trim(),label:b.trim()}),_(""),w(""),await x()}catch(W){g(W instanceof Error?W.message:"Failed to add network")}}return d.jsxs(d.Fragment,{children:[f?d.jsx("p",{className:"form-error",children:f}):null,d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted devices"}),d.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?d.jsx("p",{className:"muted",children:"No trusted devices."}):d.jsx("ul",{className:"security-list",children:t.map(A=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[A.label,A.current?d.jsx("span",{className:"security-badge",children:"this device"}):null]}),d.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(A.id)},children:"revoke"})]},A.id))})]}),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted networks"}),d.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?d.jsx("p",{className:"muted",children:"No trusted networks."}):d.jsx("ul",{className:"security-list",children:r.map(A=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?d.jsx("span",{className:"security-item-meta",children:A.label}):null]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{N(A.id)},children:"remove"})]},A.id))}),d.jsxs("form",{className:"security-add-form",onSubmit:L,children:[d.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:m,onChange:A=>_(A.currentTarget.value),required:!0}),d.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>w(A.currentTarget.value)}),d.jsx("button",{type:"submit",disabled:!m.trim(),children:"Add"})]})]}),c?d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Two-factor authentication"}),d.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),d.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const EM=1500,kb="nterminal.terminal.fontSize",Tb="nterminal.terminal.fontFamily",Tv="nterminal:terminal-font-size",Ev="nterminal:terminal-font-family",Dv=11,Rv=20,Xo=14,kf=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],lc="meslo";Nv(lc);async function Cg(e=Xo,t=lc){if(typeof document>"u"||!document.fonts)return;const n=tk(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,EM)})])}function JC(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Xo;const n=Math.round(t);return Math.max(Dv,Math.min(Rv,n))}function ek(e){return kf.some(t=>t.id===e)?e:lc}function Nv(e){return tk(e).cssFamily}function tk(e){return kf.find(t=>t.id===e)??kf[0]}function Mv(){if(typeof window>"u")return Xo;try{const e=window.localStorage.getItem(kb);return e?JC(e):Xo}catch{return Xo}}function Av(){if(typeof window>"u")return lc;try{return ek(window.localStorage.getItem(Tb))}catch{return lc}}function Lh(e){const t=JC(e);if(typeof window>"u")return t;try{window.localStorage.setItem(kb,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Tv,{detail:t})),t}function DM(e){const t=ek(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Tb,t)}catch{}return window.dispatchEvent(new CustomEvent(Ev,{detail:t})),t}function ik(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===kb&&e()};return window.addEventListener(Tv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Tv,e),window.removeEventListener("storage",t)}}function nk(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Tb&&e()};return window.addEventListener(Ev,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ev,e),window.removeEventListener("storage",t)}}const Eb="nterminal.terminal.showScrollProgress",Lv="nterminal:terminal-scroll-progress",Db="nterminal.terminal.tmuxScrollback.shell",Rb="nterminal.terminal.tmuxScrollback.agent",Nb="nterminal.terminal.tmuxScrollback.overrides",Zu="nterminal:terminal-tmux-scrollback",RM=200;function Ov(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Eb)!=="false"}catch{return!0}}function NM(e){if(typeof window<"u"){try{window.localStorage.setItem(Eb,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Lv,{detail:e}))}return e}function sk(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Eb&&e()};return window.addEventListener(Lv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Lv,e),window.removeEventListener("storage",t)}}function Bv(){return rk(Db,!0)}function MM(e){return ak(Db,e,Zu)}function jv(){return rk(Rb,!0)}function AM(e){return ak(Rb,e,Zu)}function Qh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Db||n.key===Rb||n.key===Nb)&&e()};return window.addEventListener(Zu,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Zu,e),window.removeEventListener("storage",t)}}function kg(e){const n=ok()[e];return typeof n=="boolean"?n:null}function LM(e,t){if(typeof window<"u"){try{const n=ok(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-RM);window.localStorage.setItem(Nb,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Zu,{detail:{terminalId:e,enabled:t}}))}return t}function rk(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function ak(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function ok(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Nb);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const Mb="nterminal.shortcuts.workspace.v1",Iv="nterminal:workspace-shortcuts",Qu=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"subagents.toggle",label:"Toggle view agents",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0},{id:"favorites.toggle",label:"Open favorite tabs",group:"Tabs",requiresPrimaryModifier:!0}],ap={"server.previous":ri("ArrowUp",{ctrlKey:!0}),"server.next":ri("ArrowDown",{ctrlKey:!0}),"tab.previous":ri("ArrowLeft",{ctrlKey:!0}),"tab.next":ri("ArrowRight",{ctrlKey:!0}),"tab.index":ri("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":ri("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":ri("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":ri("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":ri("KeyH",{altKey:!0}),"subagents.toggle":ri("KeyA",{altKey:!0}),"scrollback.toggle":ri("KeyS",{altKey:!0}),"favorites.toggle":ri("KeyF",{ctrlKey:!0,altKey:!0})},OM={"server.previous":ri("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":ri("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":ri("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":ri("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":ri("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":ri("Digit",{ctrlKey:!0,altKey:!0}),"split.right":ri("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":ri("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":ri("KeyH",{altKey:!0}),"subagents.toggle":ri("KeyA",{altKey:!0}),"scrollback.toggle":ri("KeyS",{altKey:!0}),"favorites.toggle":ri("KeyF",{ctrlKey:!0,altKey:!0})};function el(){const e=uk(ap);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Mb);if(!t)return e;const n=JSON.parse(t);for(const r of Qu){const o=n[r.id];if(FM(o)){const c=dk(o,r);UM(c,OM[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Gw(){return JSON.stringify(el())}function BM(e,t){const n=el(),r=Qu.find(o=>o.id===e);return r&&(n[e]=dk(t,r),Ab(n)),n}function jM(e){const t=el();return t[e]={...ap[e]},Ab(t),t}function IM(){const e=uk(ap);return Ab(e),e}function Hu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Mb&&e()};return window.addEventListener(Iv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Iv,e),window.removeEventListener("storage",t)}}function PM(e,t){const n=pk(e);return!n||KM(n)||t.indexed&&fk(e)===null||t.requiresPrimaryModifier&&!hk(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function lk(e){const t=el();for(const n of Qu){const r=t[n.id];if(!(!r||!$M(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=fk(e);if(o!==null)return{id:n.id,index:o};continue}if(pk(e)===r.code)return{id:n.id,index:null}}}return null}function Uu(e){return ck(el()[e])}function ck(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(WM(e.code)),t.join("+")}const zM=()=>Uu("split.right"),HM=()=>Uu("split.down");function ri(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function uk(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function UM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Ab(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Mb,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Iv))}}function dk(e,t){return t.requiresPrimaryModifier&&!hk(e)?{...ap[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function hk(e){return e.ctrlKey||e.altKey||e.metaKey}function FM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function $M(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function fk(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function pk(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function KM(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function WM(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const qM="Automatic update needs write access to the global npm install. Run this from a normal NTerminal runtime-user shell; only the npm install step uses sudo.";function VM(e="nterminal",t=new Date){return{reason:"permission",message:qM,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function YM(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const mk=3600*1e3,XM="local",Pv=new Set,Qa=new Map;let so={checking:!1,hasUpdates:!1,lastCheckedAt:null},Lb=null,Fu=null,Tf=0,Va=null;function GM(e){return Pv.add(e),()=>{Pv.delete(e)}}function Zw(){return so}function ZM(e){const t=iA();Lb=e,Ob(),zv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!ro(e,t))return;const r=so.lastCheckedAt;(r===null||Date.now()-r>=mk)&&zv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),ro(e,t)&&tA()}}function QM(e,t){Qa.set(e,gk(t)),cc({...so,hasUpdates:Bb(),lastCheckedAt:Date.now()})}function Tg(e){e===void 0?Qa.clear():Qa.set(e,!1),cc({...so,hasUpdates:Bb()})}async function zv(e,t){if(!ro(e,t))return;if(Va&&Va.api===e&&Va.runId===t)return Va.promise;cc({...so,checking:!0});const n=JM(e,t).finally(()=>{Va?.promise===n&&(Va=null),ro(e,t)&&(cc({...so,checking:!1,lastCheckedAt:Date.now()}),eA(e,t))});return Va={api:e,runId:t,promise:n},n}async function JM(e,t){try{const n=await e.listAgents();if(!ro(e,t))return;const r=[{key:XM,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const u=await c.check();o.set(c.key,gk(u))}catch{o.set(c.key,Qa.get(c.key)??!1)}})),!ro(e,t))return;Qa.clear();for(const[c,u]of o)Qa.set(c,u);cc({...so,hasUpdates:Bb()})}catch{}}function eA(e,t){ro(e,t)&&(Ob(),Fu=window.setTimeout(()=>{Fu=null,ro(e,t)&&zv(e,t)},mk))}function tA(){Tf+=1,Ob(),Lb=null,Va=null,Qa.clear(),cc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Ob(){Fu!==null&&(window.clearTimeout(Fu),Fu=null)}function iA(){return Tf+=1,Tf}function ro(e,t){return Lb===e&&Tf===t}function gk(e){return e.updateAvailable===!0}function Bb(){return Array.from(Qa.values()).some(Boolean)}function cc(e){so=e;for(const t of Array.from(Pv))t()}const nA=e=>new Promise(t=>setTimeout(t,e));function sA({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[u,f]=v.useState(!1),[g,m]=v.useState(null),[_,b]=v.useState(!1),[w,x]=v.useState({});function C(R,I){c(de=>({...de,[R]:{...de[R],...I}}))}function N(R,I){x(de=>({...de,[R]:{status:de[R]?.status??null,busy:de[R]?.busy??!1,error:de[R]?.error??null,...I}}))}const L=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),A=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),W=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),U=R=>R.id===null?e:dr(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async I=>{if(R)return;let de="Local";try{de=(await e.getMainInfo()).name?.trim()||de}catch{}if(R)return;const ge=new Map(I.agents.map(q=>[q.id,q])),M=Gr(I.serverOrder,I.agents).flatMap(q=>{if(q===Kt)return[{key:"local",id:null,name:de}];const he=ge.get(q);return he?[{key:he.id,id:he.id,name:he.name}]:[]});r(M);for(const q of M)L(q).then(he=>C(q.key,{version:he,manualUpdate:he.manualUpdate??null})).catch(he=>C(q.key,{error:he instanceof Error?he.message:"unreachable"})),V(q)}).catch(()=>{}),()=>{R=!0}},[]);async function F(R){C(R.key,{busy:!0,status:"checking…",error:void 0});try{const I=await A(R);QM(R.key,I),C(R.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:ee(I),...I.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(I){C(R.key,{busy:!1,error:I instanceof Error?I.message:"check failed"})}}async function K(){f(!0),await Promise.all(n.map(R=>F(R))),f(!1)}async function oe(R,I){const de=Date.now()+18e4;for(;Date.now()<de;){await nA(3e3);try{const ge=await L(R);if(I&&ge.runningVersion!==I.runningVersion)return ge}catch{}}return null}async function P(R){let I=o[R.key]?.version;if(!I)try{I=await L(R),C(R.key,{version:I,manualUpdate:I.manualUpdate??null})}catch(M){return C(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}C(R.key,{busy:!0,status:"updating…",error:void 0});let de;try{de=await W(R)}catch(M){return C(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!de.ok){const M=de.manualUpdate??(YM(de.message)?VM():null);return M?(C(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(C(R.key,{busy:!1,status:void 0,error:de.message}),"failed")}if(!de.changed)return C(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Tg(R.key),"unchanged";C(R.key,{status:"restarting…"});const ge=await oe(R,I);return ge?(C(R.key,{busy:!1,version:ge,updateAvailable:!1,status:"updated",manualUpdate:ge.manualUpdate??null}),Tg(R.key),R.id===null&&(b(!0),m("Main server updated. Reload the page to use the new client.")),"updated"):(C(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function te(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
15
+ `)))){C(R.key,{busy:!0,status:"deleting…",error:void 0}),m(null);try{const de=await e.uninstallAgent(R.id);r(ge=>ge.filter(M=>M.key!==R.key)),c(ge=>{const M={...ge};return delete M[R.key],M}),Tg(R.key),t?.(R.id),m(de.message)}catch(de){C(R.key,{busy:!1,status:void 0,error:de instanceof Error?de.message:"delete failed"})}}}async function Z(){f(!0),m(null);const R=n.filter(he=>he.id!==null),I=n.find(he=>he.id===null),de=await Promise.all(R.map(he=>P(he))),ge=de.filter(he=>he==="failed").length;let M=de.filter(he=>he==="manual").length,q=null;if(I&&(q=await P(I),q==="manual"&&(M+=1),q==="updated")){ge>0&&m("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),f(!1);return}ge>0&&M>0?m("Some servers failed and some need manual update. Check each marked row."):ge>0?m("Some secondary servers failed to update. Check their rows and retry."):M>0&&m("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function me(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function ee(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function Y(R){const I=R?.version;return I?`npm package v${I.runningVersion}`:""}async function X(R,I){try{await aA(I),C(R,{copiedCommand:!0}),window.setTimeout(()=>C(R,{copiedCommand:!1}),1800)}catch(de){C(R,{error:de instanceof Error?de.message:"copy failed"})}}async function V(R,I=!1){try{const de=await U(R).getCodeServerStatus(I?{checkLatest:!0}:void 0);N(R.key,{status:de,error:null})}catch(de){N(R.key,{error:de instanceof Error?de.message:"code-server status failed"})}}async function ne(R,I){if(I==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const de=U(R);N(R.key,{busy:!0,error:null});try{if(I==="install"){const ge=await de.installCodeServer();N(R.key,{status:ge.status})}else if(I==="update"){const ge=await de.updateCodeServer();N(R.key,{status:ge.status})}else{const ge=await de.uninstallCodeServer();N(R.key,{status:ge.status})}}catch(ge){N(R.key,{error:ge instanceof Error?ge.message:"code-server action failed"})}finally{N(R.key,{busy:!1})}}const O=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(de=>w[de.key]?.status?.job?.status==="running");if(R.length===0)return;const I=window.setInterval(()=>{for(const de of R)V(de)},1e3);return()=>window.clearInterval(I)},[O]),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Servers"}),d.jsxs("div",{className:"update-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{K()},disabled:u,children:"Check for updates"}),d.jsx("button",{type:"button",onClick:()=>{Z()},disabled:u,children:"Update all"})]}),g?d.jsx("p",{className:"settings-status",children:g}):null,_?d.jsxs("div",{className:"server-reload-required",role:"status",children:[d.jsx("span",{children:"Main server update is ready."}),d.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,d.jsx("ul",{className:"security-list",children:n.map(R=>{const I=o[R.key],de=Y(I),ge=I?.manualUpdate??null,M=w[R.key]??{status:null,busy:!1,error:null},q=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!u,he=R.id!==null&&!I?.busy&&!u;return d.jsxs("li",{children:[d.jsxs("div",{className:"server-row-main",children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?d.jsx("span",{className:"security-badge",children:"Main"}):null]}),d.jsxs("span",{className:"security-item-meta",children:[de?`${de} — `:"",me(I)]})]}),ge?d.jsxs("div",{className:"server-manual-update",children:[d.jsx("span",{children:ge.message}),d.jsxs("div",{className:"server-manual-command",children:[d.jsx("code",{children:ge.command}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{X(R.key,ge.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null,d.jsx(rA,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{V(R,!0)},onInstall:()=>{ne(R,"install")},onUpdate:()=>{ne(R,"update")},onUninstall:()=>{ne(R,"uninstall")}})]}),d.jsxs("div",{className:"server-row-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{P(R)},disabled:!q,children:I?.busy?"…":"Update"}),R.id!==null?d.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{te(R)},disabled:!he,children:"Delete"}):null]})]},R.key)})})]})}function rA({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onUninstall:u}){const f=e?.job??null,g=f?.status==="running",m=e!==null,_=e?.installed===!0,b=e?.supported!==!1,w=e===null&&!n;return d.jsxs("div",{className:"server-code-addon-inline",children:[d.jsxs("div",{className:"server-code-addon-summary",children:[d.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),d.jsxs("span",{className:"security-item-meta",children:[b?w?"checking...":_?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?d.jsx("p",{className:"settings-error",children:n}):null,f?d.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,d.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[d.jsx("a",{className:"server-code-addon-icon-button",href:"https://github.com/coder/code-server",target:"_blank",rel:"noreferrer",title:"Open code-server on GitHub","aria-label":"Open code-server on GitHub",children:"↗"}),_?d.jsxs(d.Fragment,{children:[e?.updateAvailable?d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:c,disabled:t||g||!b,title:"Update code-server","aria-label":"Update code-server",children:"↑"}):d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:r,disabled:t||g||!b,title:"Check code-server updates","aria-label":"Check code-server updates",children:"↻"}),d.jsx("button",{type:"button",className:"server-code-addon-icon-button server-code-addon-icon-button--delete",onClick:u,disabled:t||g,title:"Uninstall code-server","aria-label":"Uninstall code-server",children:"×"})]}):d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:o,disabled:!m||w||t||g||!b,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function aA(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Oh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function oA({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??Vf(),[t]),[u,f]=v.useState(()=>Mv()),[g,m]=v.useState(()=>Av()),[_,b]=v.useState(()=>Ov()),[w,x]=v.useState(()=>Bv()),[C,N]=v.useState(()=>jv()),[L,A]=v.useState(()=>no()),[W,U]=v.useState(()=>el()),[F,K]=v.useState(null),[oe,P]=v.useState(null),[te,Z]=v.useState("appearance"),[me,ee]=v.useState(()=>wb()),[Y,X]=v.useState(()=>Jo()),[V,ne]=v.useState(()=>vc()),[O,R]=v.useState([]),[I,de]=v.useState([]),[ge,M]=v.useState([]),[q,he]=v.useState(5*1024*1024),[J,ye]=v.useState(!1),[ve,Le]=v.useState(null),[Ne,Fe]=v.useState(null),[He,Pe]=v.useState(!1),[Ze,E]=v.useState(null),[z,we]=v.useState(null),Ae=v.useRef(null),ie=v.useRef(null),pe=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),Te=v.useMemo(()=>new Set(I),[I]),De=!cA(I,ge),Ee=v.useMemo(()=>rp(),[]),je=Ne?.displayMode==="standalone"&&(Ne.deviceKind==="mobile"||Ne.deviceKind==="tablet");v.useEffect(()=>ik(()=>f(Mv())),[]),v.useEffect(()=>nk(()=>m(Av())),[]),v.useEffect(()=>sk(()=>b(Ov())),[]),v.useEffect(()=>Qh(()=>{x(Bv()),N(jv())}),[]),v.useEffect(()=>ob(()=>A(no())),[]),v.useEffect(()=>Hu(()=>U(el())),[]),v.useEffect(()=>AC(()=>X(Jo())),[]),v.useEffect(()=>{if(!F)return;const le=Qu.find(ut=>ut.id===F);if(!le)return;const ze=ut=>{if(ut.preventDefault(),ut.stopPropagation(),ut.key==="Escape"){K(null),P(null);return}const at=PM(ut,le);if(!at){P(lA(le));return}U(BM(F,at)),K(null),P(null)};return window.addEventListener("keydown",ze,!0),()=>window.removeEventListener("keydown",ze,!0)},[F]),v.useEffect(()=>{let le=!1;return c.listNotificationAssets().then(ze=>{le||Pt(ze)}).catch(ze=>{le||Le(Vl(ze))}),()=>{le=!0}},[c]),v.useEffect(()=>{let le=!1;return c.getPushNotificationStatus(Zr()).then(ze=>{le||(Fe(ze.currentDevice),E(null))}).catch(ze=>{le||E(Vl(ze))}),()=>{le=!0}},[c]);function Ve(le){f(Lh(Number(le)))}function $e(le){X(zw(Number(le)))}function St(le){Z(le);const ze=ie.current,ut=pe.current[le];if(!ze||!ut)return;const at=Math.max(0,Qw(ut,ze)-12);typeof ze.scrollTo=="function"?ze.scrollTo({top:at,behavior:"smooth"}):ze.scrollTop=at}function wt(){const le=ie.current;if(!le)return;if(le.scrollTop+le.clientHeight>=le.scrollHeight-2){Z(Oh[Oh.length-1].id);return}let ze="appearance";const ut=le.scrollTop+Math.min(180,Math.max(48,le.clientHeight*.28));for(const at of Oh){const Bt=pe.current[at.id];Bt&&Qw(Bt,le)<=ut&&(ze=at.id)}Z(ze)}function Nt(le){U(jM(le)),K(null),P(null)}function _t(){U(IM()),K(null),P(null)}function Pt(le){const ze=le.assets.filter(ut=>ut.enabled).map(ut=>ut.id);R(le.assets),de(ze),M(ze),he(le.maxFileBytes),Le(null)}async function oi(){if(me){Pw(!1),ee(!1);return}let le=V;le==="default"&&(le=await OC(),ne(le)),le==="granted"&&(Pw(!0),ee(!0))}async function ke(){Pe(!0),E(null),we(null);try{if(Ne)await BN(c),Fe(null);else{await AN(c,!1);const le=await c.getPushNotificationStatus(Zr());Fe(le.currentDevice)}}catch(le){E(Dg(le))}finally{Pe(!1)}}async function Ge(le){Pe(!0),E(null),we(null);try{await jN(c,le);const ze=await c.getPushNotificationStatus(Zr());Fe(ze.currentDevice)}catch(ze){E(Dg(ze))}finally{Pe(!1)}}async function st(){Pe(!0),E(null),we(null);try{await c.testPushNotification({clientId:Zr()}),we("Test notification accepted by the push service.")}catch(le){E(Dg(le))}finally{Pe(!1)}}async function et(le){const ze=le?.[0];if(ze){if(ze.size>q){Le(`File must be ${Eg(q)} or smaller.`),ct();return}if(ze.type!=="video/mp4"&&ze.type!=="video/webm"){Le("Upload an MP4 or WebM video."),ct();return}ye(!0),Le(null);try{await c.uploadNotificationAsset(ze),Pt(await c.listNotificationAssets()),r?.()}catch(ut){Le(Vl(ut))}finally{ye(!1),ct()}}}async function gt(le){ye(!0),Le(null);try{await c.deleteNotificationAsset(le),Pt(await c.listNotificationAssets()),r?.()}catch(ze){Le(Vl(ze))}finally{ye(!1)}}function ct(){Ae.current&&(Ae.current.value="")}function mn(le,ze){const ut=new Set(I);if(ze?ut.add(le):ut.delete(le),ut.size===0){Le("Keep at least one toast video selected.");return}Le(null),de(Array.from(ut))}async function li(){if(I.length===0){Le("Keep at least one toast video selected.");return}ye(!0),Le(null);try{const le=await c.updateNotificationAssetSelection({enabledAssetIds:I});Pt(le),r?.()}catch(le){Le(Vl(le))}finally{ye(!1)}}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:d.jsxs("div",{className:"security-panel settings-panel",onClick:le=>le.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{children:"Settings"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),d.jsxs("div",{className:"settings-layout",children:[d.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Oh.map(le=>d.jsxs("button",{type:"button","data-active":te===le.id?"true":"false","aria-current":te===le.id?"true":void 0,onClick:()=>St(le.id),children:[le.label,le.id==="servers"&&n?d.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},le.id))}),d.jsxs("div",{ref:ie,className:"settings-content",onScroll:wt,children:[d.jsxs("section",{id:"settings-appearance",ref:le=>{pe.current.appearance=le},className:"security-section settings-section",children:[d.jsx("h3",{children:"Appearance"}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Theme"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),d.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:vf.map(le=>d.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===le.id,"data-active":L===le.id?"true":"false",onClick:()=>A(rD(le.id)),style:{"--settings-theme-bg":le.tokens.bg,"--settings-theme-bg-2":le.tokens.bg2,"--settings-theme-sidebar":le.tokens.bgSidebar,"--settings-theme-line":le.tokens.line,"--settings-theme-fg":le.tokens.fg,"--settings-theme-fg-2":le.tokens.fg2,"--settings-theme-accent":le.tokens.accent,"--settings-theme-xterm-bg":le.xterm.background,"--settings-theme-xterm-fg":le.xterm.foreground,"--settings-theme-xterm-selection":le.xterm.selectionBackground},children:[d.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[d.jsxs("span",{className:"settings-theme-preview-sidebar",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-main",children:[d.jsxs("span",{className:"settings-theme-preview-tabs",children:[d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-terminal",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})]})]}),d.jsxs("span",{className:"settings-theme-card-copy",children:[d.jsx("strong",{children:le.label}),d.jsx("small",{children:le.description})]})]},le.id))}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font size"}),d.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),d.jsx("input",{type:"range",min:Dv,max:Rv,step:1,value:u,"aria-label":"Terminal font size",onChange:le=>Ve(le.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row",children:[d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Lh(u-1)),children:"-"}),d.jsx("input",{type:"number",min:Dv,max:Rv,step:1,value:u,"aria-label":"Terminal font size value",onChange:le=>Ve(le.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Lh(u+1)),children:"+"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Lh(Xo)),children:"Reset"})]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font family"}),d.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:le=>m(DM(le.currentTarget.value)),children:kf.map(le=>d.jsx("option",{value:le.id,children:le.label},le.id))})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:_,onChange:le=>b(NM(le.currentTarget.checked))}),"Show scroll progress"]}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:w,onChange:le=>x(MM(le.currentTarget.checked))}),"Shell panes"]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:C,onChange:le=>N(AM(le.currentTarget.checked))}),"Codex/Claude panes"]})]}),d.jsxs("section",{id:"settings-shortcuts",ref:le=>{pe.current.shortcuts=le},className:"security-section settings-section",children:[d.jsxs("div",{className:"settings-section-heading",children:[d.jsx("h3",{children:"Shortcuts"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:_t,children:"Reset all"})]}),d.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),oe?d.jsx("p",{className:"settings-error",children:oe}):null,d.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Qu.map(le=>{const ze=F===le.id;return d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"settings-shortcut-label",children:le.label}),d.jsx("span",{className:"settings-shortcut-group",children:le.group})]}),d.jsxs("div",{className:"settings-shortcut-actions",children:[d.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":ze?"true":"false",onClick:()=>{K(le.id),P(null)},children:ze?"Press keys…":ck(W[le.id])}),d.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Nt(le.id),children:"Reset"})]})]},le.id)})})]}),d.jsxs("section",{id:"settings-notifications",ref:le=>{pe.current.notifications=le},className:"security-section settings-section",children:[d.jsx("h3",{children:"Notifications"}),sp()?d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:me&&V==="granted",onChange:()=>{oi()},disabled:V==="denied"}),"System notification when page is hidden"]}),V==="denied"?d.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):d.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):d.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),d.jsxs("div",{className:"settings-subsection",children:[d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:!!Ne,onChange:()=>{ke()},disabled:He||!Ee.supported}),"Installed app push notifications"]}),d.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ee.supported?null:d.jsx("p",{className:"muted",children:Jh(Ee.reason)}),Ne?d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"muted",children:["Registered as ",Ne.label,". Last active ",new Date(Ne.lastActiveAt).toLocaleString(),"."]}),d.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{st()},disabled:He,children:"Send test notification"})]}):null,je?d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:Ne?.alwaysNotify===!0,onChange:le=>{Ge(le.currentTarget.checked)},disabled:He||!Ne}),"Always notify this mobile device"]}):null,Ze?d.jsx("p",{className:"form-error",children:Ze}):null,z?d.jsx("p",{className:"muted",role:"status",children:z}):null]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:Y.enabled,onChange:le=>X(xN(le.currentTarget.checked))}),"Show animated completion toast"]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Toast duration"}),d.jsx("span",{className:"settings-control-value",children:Y.persistUntilDismissed?"Until closed":`${Y.durationSeconds}s`}),d.jsx("input",{type:"range",min:bv,max:yv,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:le=>$e(le.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[d.jsx("input",{type:"number",min:bv,max:yv,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:le=>$e(le.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!Y.enabled||Y.persistUntilDismissed,onClick:()=>X(zw(zu)),children:"Reset"})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:Y.persistUntilDismissed,disabled:!Y.enabled,onChange:le=>X(CN(le.currentTarget.checked))}),"Keep toast until dismissed"]}),d.jsxs("div",{className:"settings-assets-header",children:[d.jsx("span",{children:"Toast videos"}),d.jsxs("span",{children:[Eg(q)," max"]})]}),d.jsx("input",{ref:Ae,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:le=>{et(le.currentTarget.files)}}),d.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:J,onClick:()=>Ae.current?.click(),children:"Upload video"}),ve?d.jsx("p",{className:"settings-error",children:ve}):null,O.length>0?d.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(le=>d.jsxs("li",{"data-enabled":Te.has(le.id)?"true":"false",children:[d.jsxs("label",{className:"settings-asset-choice",children:[d.jsx("input",{type:"checkbox",checked:Te.has(le.id),disabled:J,"aria-label":`Use ${le.filename}`,onChange:ze=>mn(le.id,ze.currentTarget.checked)}),d.jsx("video",{src:le.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),d.jsxs("span",{className:"settings-asset-copy",children:[d.jsx("span",{children:le.filename}),d.jsx("small",{children:le.source==="built-in"?"Built-in":Eg(le.size)})]})]}),le.source==="uploaded"?d.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:J,"aria-label":`Delete ${le.filename}`,onClick:()=>{gt(le.id)},children:"x"}):null]},le.id))}):d.jsx("p",{className:"muted",children:"Built-in videos will be used."}),d.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:J||O.length===0||!De,onClick:()=>{li()},children:"Save selected videos"})]}),d.jsx("div",{id:"settings-security",ref:le=>{pe.current.security=le},className:"settings-section-group",children:d.jsx(TM,{api:c})}),d.jsx("div",{id:"settings-servers",ref:le=>{pe.current.servers=le},className:"settings-section-group",children:d.jsx(sA,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Qw(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Eg(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Vl(e){return e instanceof Error?e.message:"Request failed."}function Jh(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function Dg(e){const t=Vl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Jh("not_standalone"):t==="insecure"?Jh("insecure"):t==="not_mobile"?Jh("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function lA(e){return e.indexed?"Press a shortcut ending in a number from 1 to 9.":e.requiresPrimaryModifier?"Use Ctrl, Alt, or Meta with another key.":"Press a complete shortcut."}function cA(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const uA="modulepreload",dA=function(e){return"/"+e},Jw={},jb=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(m){return Promise.all(m.map(_=>Promise.resolve(_).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");o=g(n.map(m=>{if(m=dA(m),m in Jw)return;Jw[m]=!0;const _=m.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${b}`))return;const w=document.createElement("link");if(w.rel=_?"stylesheet":uA,_||(w.as="script"),w.crossOrigin="",w.href=m,f&&w.setAttribute("nonce",f),document.head.appendChild(w),_)return new Promise((x,C)=>{w.addEventListener("load",x),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${m}`)))})}))}function c(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return o.then(u=>{for(const f of u||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},hA=v.lazy(()=>jb(()=>import("./MarkdownPreview-CzA5ZyZ3.js"),__vite__mapDeps([0,1])));function fA({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[f,g]=v.useState(""),[m,_]=v.useState({}),[b,w]=v.useState(()=>new Set),[x,C]=v.useState(null),[N,L]=v.useState({type:"empty"}),[A,W]=v.useState("idle"),[U,F]=v.useState(null),K=v.useRef(null),oe=v.useRef(null),P=v.useRef(!1),te=v.useRef(0),Z=v.useRef(null);Z.current===null&&t&&(Z.current=t);const me=Z.current,ee=r?mA(r):t?e1(t,n):null,Y=c?[c.rootPath,f].filter(Boolean).join("/"):"",X=x?.path??null;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,te.current+=1,Pe()}),[]),v.useEffect(()=>{Z.current=t,oe.current=null,V(ee)},[e]),v.useEffect(()=>{r&&ee!==oe.current&&ne(r,ee)},[r,ee]),v.useEffect(()=>{if(r||!me||t!==me)return;const ie=e1(me,n);ie!==oe.current&&O(me,ie)},[me,t,n,r]);async function V(ie=ee){if(r){await ne(r,ie);return}await O(t,ie)}async function ne(ie,pe=ee){const Te=Ze();if(oe.current=pe,Pe(),u(null),g(""),_({}),w(new Set),C(null),L({type:"empty"}),F(null),!ie){W("idle");return}W("loading");try{const De=await e.createFileRoot({path:ie});if(!E(Te))return;u({rootToken:De.rootToken,rootPath:De.rootPath});const Ee=await e.listFiles({rootToken:De.rootToken,path:""});if(!E(Te))return;de(Ee),W("idle")}catch(De){E(Te)&&(F(qr(De)),W("idle"))}}async function O(ie,pe=ee){const Te=Ze();if(oe.current=pe,Pe(),u(null),g(""),_({}),w(new Set),C(null),L({type:"empty"}),F(null),!ie){W("idle");return}W("loading");try{const De=await e.createFileRoot({terminalId:ie});if(!E(Te))return;u({rootToken:De.rootToken,rootPath:De.rootPath});const Ee=await e.listFiles({rootToken:De.rootToken,path:""});if(!E(Te))return;de(Ee),W("idle")}catch(De){if(await z(De,Te))return;E(Te)&&(F(qr(De)),W("idle"))}}async function R(ie=f,pe=c){if(!pe)return;const Te=Ze();W("loading"),F(null);try{const De=await e.listFiles({rootToken:pe.rootToken,path:ie});if(!E(Te))return;de(De),W("idle")}catch(De){if(await z(De,Te))return;E(Te)&&(F(qr(De)),W("idle"))}}async function I(){if(r){await ne(r,ee);return}Z.current=t,await O(t,ee)}function de(ie){_(pe=>({...pe,[ie.path]:gA(ie.entries)}))}async function ge(ie){if(!(!Rg(ie)||!c)){if(C(ie),F(null),ie.kind==="directory"){g(ie.path),He(),await q(ie);return}if(g($o(ie.path)),ie.editable){await J(ie);return}ie.previewKind!=="none"&&await ve(ie,ie.previewKind)}}async function M(ie){if(!(!Rg(ie)||!c)){if(C(ie),F(null),ie.kind==="directory"){g(ie.path),He(),await q(ie);return}if(g($o(ie.path)),ie.editable){await ye(ie);return}ie.previewKind!=="none"&&await ve(ie,ie.previewKind)}}async function q(ie){if(b.has(ie.path)){w(pe=>{const Te=new Set(pe);return Te.delete(ie.path),Te});return}w(pe=>new Set(pe).add(ie.path)),await R(ie.path)}function he(ie,pe){ie.key==="Enter"&&(ie.preventDefault(),M(pe))}async function J(ie){if(!c)return;const pe=Ze();W("loading"),Pe();try{const Te=await e.readFile({rootToken:c.rootToken,path:ie.path});if(!E(pe))return;L({type:"text-preview",file:ie,read:Te}),W("idle")}catch(Te){if(await z(Te,pe))return;E(pe)&&(F(qr(Te)),W("idle"))}}async function ye(ie){if(!c)return;const pe=Ze();W("loading");try{await o({rootToken:c.rootToken,path:ie.path,...t?{terminalId:t}:{}}),E(pe)&&W("idle")}catch(Te){if(await z(Te,pe))return;E(pe)&&(F(qr(Te)),W("idle"))}}async function ve(ie,pe){if(!c)return;const Te=Ze();W("loading"),Pe();try{const De=await e.previewFile({rootToken:c.rootToken,path:ie.path});if(!E(Te))return;const Ee=URL.createObjectURL(De);if(!E(Te)){URL.revokeObjectURL(Ee);return}K.current=Ee,L({type:"preview",file:ie,previewKind:pe,url:Ee}),W("idle")}catch(De){if(await z(De,Te))return;E(Te)&&(F(qr(De)),W("idle"))}}async function Le(ie){if(!c)return;const pe=ie==="file"?"New file":"New folder",Te=window.prompt(pe,""),De=x?x.kind==="directory"?x.path:$o(x.path):f,Ee=t1(Te,De);if(Ee){F(null);try{const je=await e.createFileEntry({rootToken:c.rootToken,path:Ee,kind:ie});C(je.entry),await R(De)}catch(je){if(await z(je))return;F(qr(je))}}}async function Ne(){if(!c||!x)return;const ie=window.prompt("Move selected entry",x.path),pe=t1(ie,"");if(!pe||pe===x.path)return;const Te=$o(x.path),De=$o(pe);F(null);try{const Ee=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:x.path,destinationPath:pe});C(Ee.entry),g(Ee.entry.kind==="directory"?Ee.entry.path:$o(Ee.entry.path)),He(),await R(Te),De!==Te&&await R(De)}catch(Ee){if(await z(Ee))return;F(qr(Ee))}}async function Fe(){if(!c||!x)return;const ie=x.path,pe=$o(ie);F(null);try{const Te=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:x.path}),De=Te.descendantCount>0?` and ${Te.descendantCount} nested item${Te.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Te.path}${De}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:x.path,previewToken:Te.previewToken}),C(null),g(pe),w(Ee=>{const je=new Set(Ee);for(const Ve of Ee)(Ve===ie||Ve.startsWith(`${ie}/`))&&je.delete(Ve);return je}),He(),await R(pe)}catch(Te){if(await z(Te))return;F(qr(Te))}}function He(){te.current+=1,Pe(),L({type:"empty"})}function Pe(){K.current&&(URL.revokeObjectURL(K.current),K.current=null)}function Ze(){return te.current+=1,te.current}function E(ie){return P.current&&ie===te.current}async function z(ie,pe){return vA(ie)?(pe!==void 0&&!E(pe)||await V(ee),!0):!1}function we(ie,pe){const Te=Rg(ie),De=ie.kind==="directory"&&b.has(ie.path),Ee=m[ie.path]??[],je={"--file-tree-depth":pe};return d.jsxs(Ot.Fragment,{children:[d.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ie.kind,"data-expanded":De,"data-active":X===ie.path,disabled:!Te,style:je,"aria-expanded":ie.kind==="directory"?De:void 0,"aria-label":`${ie.kind==="directory"?"Open folder":"Open file"} ${ie.name}`,title:ie.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ge(ie)},onDoubleClick:()=>{M(ie)},onKeyDown:Ve=>he(Ve,ie),children:[d.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ie.kind==="directory"?De?"▾":"▸":""}),d.jsx("span",{className:"file-entry-name",children:ie.name}),d.jsx("small",{children:pA(ie)})]}),De?d.jsx("div",{className:"file-tree-children",role:"group",children:Ee.map(Ve=>we(Ve,pe+1))}):null]},ie.path)}const Ae=m[""]??[];return d.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[d.jsxs("header",{className:"file-explorer-header",children:[d.jsx("div",{className:"file-explorer-path",title:Y,children:Y||"No active pane"}),d.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[d.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{I()},children:"↻"}),d.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Le("file")},children:"+"}),d.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Le("directory")},children:"▣"})]})]}),U?d.jsx("div",{className:"file-explorer-alert",role:"alert",children:U}):null,d.jsxs("div",{className:"file-explorer-layout",children:[d.jsx("div",{className:"file-tree","aria-label":Y?`Files in ${Y}`:"Files",children:Ae.map(ie=>we(ie,0))}),d.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[d.jsxs("div",{className:"file-detail-header",children:[d.jsx("strong",{children:x?.name??"detail"}),d.jsxs("div",{className:"file-detail-actions",children:[d.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!x,onClick:()=>{Ne()},children:"Move"}),d.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!x,onClick:()=>{Fe()},children:"Delete"})]})]}),A==="loading"?d.jsx("div",{className:"file-detail-empty",children:"loading"}):null,N.type==="empty"&&A!=="loading"?d.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,N.type==="preview"?d.jsxs("div",{className:"file-preview-frame",children:[N.previewKind==="image"?d.jsx("img",{src:N.url,alt:N.file.name}):null,N.previewKind==="pdf"?d.jsx("iframe",{src:N.url,title:N.file.name}):null]}):null,N.type==="text-preview"&&N.read.language==="markdown"?d.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${N.file.name}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:d.jsx(hA,{content:N.read.content})})}):null,N.type==="text-preview"&&N.read.language==="text"?d.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${N.file.name}`,children:N.read.content}):null]})]})]})}function Rg(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function pA(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function e1(e,t){return`${e}\0${t??""}`}function mA(e){return`workspace\0${e}`}function gA(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function $o(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function t1(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function qr(e){return e instanceof Error?e.message:"Request failed"}function vA(e){return e instanceof fn&&e.status===409&&e.message==="terminal_cwd_changed"}const _A=v.lazy(()=>jb(()=>import("./MarkdownPreview-CzA5ZyZ3.js"),__vite__mapDeps([0,1])));function i1({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,f]=v.useState(t.read.content),[g,m]=v.useState("idle"),[_,b]=v.useState(null),[w,x]=v.useState(!1),[C,N]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),W=v.useRef(t.read.content),U=v.useRef(!1),F=v.useRef(!1),K=v.useRef(0),oe=u!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(F.current=!0,()=>{F.current=!1,K.current+=1}),[]),v.useEffect(()=>{K.current+=1,U.current=!1,L.current=t,A.current=t.read,W.current=t.read.content,c(t.read),f(t.read.content),m("idle"),b(null),x(!1),N("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{W.current=u},[u]),v.useEffect(()=>{if(u===o.content||w)return;const ee=window.setInterval(()=>{!U.current&&W.current!==A.current.content&&P()},1e3);return()=>window.clearInterval(ee)},[u===o.content,w,t.id]);async function P(){if(U.current)return;const ee=W.current,Y=A.current;if(ee===Y.content)return;const X=L.current,V=K.current;U.current=!0,m("saving"),b(null),x(!1);try{const ne=await e.writeFile({rootToken:X.rootToken,path:X.path,content:ee,expectedVersion:Y.version});if(!F.current||V!==K.current)return;const O={...Y,content:ee,version:ne.version};A.current=O,c(O),m(W.current===ee?"saved":"idle")}catch(ne){if(!F.current||V!==K.current)return;if(ne instanceof fn&&ne.status===409){x(!0),m("idle");return}b(bA(ne)),m("idle")}finally{V===K.current&&(U.current=!1)}}const te=g==="saving"?"saving":g==="saved"?"saved":o.language,Z=o.language==="markdown",me=Z&&C==="preview";return d.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[d.jsxs("header",{className:"editor-pane-header",children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("strong",{children:t.title}),d.jsx("span",{className:"terminal-pane-spacer"}),d.jsx("span",{className:"terminal-pane-state",children:te}),d.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!oe,onClick:()=>{P()},children:"Save"}),Z?d.jsx("button",{type:"button","aria-label":`${me?"Edit":"Preview"} ${t.title}`,onClick:()=>N(ee=>ee==="preview"?"edit":"preview"),children:me?"Edit":"Preview"}):null,n?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),_?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:_}):null,w?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,me?d.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:d.jsx(_A,{content:u})})}):d.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ee=>{const Y=ee.target.value;W.current=Y,f(Y),m("idle"),b(null),x(!1)}})]})}function bA(e){return e instanceof Error?e.message:"Request failed"}var yA=2,SA=1,wA=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),u={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},f=u.top+u.bottom,g=u.right+u.left,m=r-f,_=o-g-t;return{cols:Math.max(yA,Math.floor(_/e.css.cell.width)),rows:Math.max(SA,Math.floor(m/e.css.cell.height))}}};var vk=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,CA=(e,t)=>{for(var n in t)vk(e,n,{get:t[n],enumerable:!0})},yi=(e,t,n,r)=>{for(var o=r>1?void 0:r?xA(t,n):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,n,o):u(o))||o);return r&&o&&vk(t,n,o),o},Ue=(e,t)=>(n,r)=>t(n,r,e),n1="Terminal input",Hv={get:()=>n1,set:e=>n1=e},s1="Too much output to announce, navigate to rows manually to read",Uv={get:()=>s1,set:e=>s1=e};function kA(e){return e.replace(/\r?\n/g,"\r")}function TA(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function EA(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function DA(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");_k(o,t,n,r)}}function _k(e,t,n,r){e=kA(e),e=TA(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function bk(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function r1(e,t,n,r,o){bk(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Xa(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function op(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var RA=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=n)return this._interim=u,r;let f=e.charCodeAt(c);56320<=f&&f<=57343?t[r++]=(u-55296)*1024+f-56320+65536:(t[r++]=u,t[r++]=f);continue}u!==65279&&(t[r++]=u)}return r}},NA=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,u,f,g=0,m=0;if(this.interim[0]){let w=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,N;for(;(N=this.interim[++C]&63)&&C<4;)x<<=6,x|=N;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-C;for(;m<A;){if(m>=n)return 0;if(N=e[m++],(N&192)!==128){m--,w=!0;break}else this.interim[C++]=N,x<<=6,x|=N&63}w||(L===2?x<128?m--:t[r++]=x:L===3?x<2048||x>=55296&&x<=57343||x===65279||(t[r++]=x):x<65536||x>1114111||(t[r++]=x)),this.interim.fill(0)}let _=n-4,b=m;for(;b<n;){for(;b<_&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((u=e[b+2])&128)&&!((f=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=u,t[r++]=f,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=u,r;if(f=e[b++],(f&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(u&63)<<6|f&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},yk="",Za=" ",vd=class Sk{constructor(){this.fg=0,this.bg=0,this.extended=new Ef}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Sk;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}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}},Ef=class wk{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new wk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ws=class xk extends vd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ef,this.combinedData=""}static fromCharData(t){let n=new xk;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xa(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},a1="di$target",Fv="di$dependencies",Ng=new Map;function MA(e){return e[Fv]||[]}function rn(e){if(Ng.has(e))return Ng.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");AA(t,n,o)};return t._id=e,Ng.set(e,t),t}function AA(e,t,n){t[a1]===t?t[Fv].push({id:e,index:n}):(t[Fv]=[{id:e,index:n}],t[a1]=t)}var Mn=rn("BufferService"),Ck=rn("CoreMouseService"),rl=rn("CoreService"),LA=rn("CharsetService"),Ib=rn("InstantiationService"),kk=rn("LogService"),An=rn("OptionsService"),Tk=rn("OscLinkService"),OA=rn("UnicodeService"),_d=rn("DecorationService"),$v=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new ws,u=n.getTrimmedLength(),f=-1,g=-1,m=!1;for(let _=0;_<u;_++)if(!(g===-1&&!n.hasContent(_))){if(n.loadCell(_,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=_,f=c.extended.urlId;continue}else m=c.extended.urlId!==f;else g!==-1&&(m=!0);if(m||g!==-1&&_===u-1){let b=this._oscLinkService.getLinkData(f)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:_+(!m&&_===u-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(b);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||r.push({text:b,range:w,activate:(C,N)=>o?o.activate(C,N,w):BA(C,N),hover:(C,N)=>o?.hover?.(C,N,w),leave:(C,N)=>o?.leave?.(C,N,w)})}m=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=_,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};$v=yi([Ue(0,Mn),Ue(1,An),Ue(2,Tk)],$v);function BA(e,t){if(confirm(`Do you want to navigate to ${t}?
16
+
17
+ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var lp=rn("CharSizeService"),sa=rn("CoreBrowserService"),Pb=rn("MouseService"),ra=rn("RenderService"),jA=rn("SelectionService"),Ek=rn("CharacterJoinerService"),_c=rn("ThemeService"),Dk=rn("LinkProviderService"),IA=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?o1.isErrorNoTelemetry(e)?new o1(e.message+`
18
+
19
+ `+e.stack):new Error(e.message+`
20
+
21
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(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)}},PA=new IA;function ef(e){zA(e)||PA.onUnexpectedError(e)}var Kv="Canceled";function zA(e){return e instanceof HA?!0:e instanceof Error&&e.name===Kv&&e.message===Kv}var HA=class extends Error{constructor(){super(Kv),this.name=this.message}};function UA(e){return new Error(`Illegal argument: ${e}`)}var o1=class Wv extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Wv)return t;let n=new Wv;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},qv=class Rk extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Rk.prototype)}};function Qn(e,t=0){return e[e.length-(1+t)]}var FA;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(FA||={});function $A(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var Nk;(e=>{function t(F){return F&&typeof F=="object"&&typeof F[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(F){yield F}e.single=o;function c(F){return t(F)?F:o(F)}e.wrap=c;function u(F){return F||n}e.from=u;function*f(F){for(let K=F.length-1;K>=0;K--)yield F[K]}e.reverse=f;function g(F){return!F||F[Symbol.iterator]().next().done===!0}e.isEmpty=g;function m(F){return F[Symbol.iterator]().next().value}e.first=m;function _(F,K){let oe=0;for(let P of F)if(K(P,oe++))return!0;return!1}e.some=_;function b(F,K){for(let oe of F)if(K(oe))return oe}e.find=b;function*w(F,K){for(let oe of F)K(oe)&&(yield oe)}e.filter=w;function*x(F,K){let oe=0;for(let P of F)yield K(P,oe++)}e.map=x;function*C(F,K){let oe=0;for(let P of F)yield*K(P,oe++)}e.flatMap=C;function*N(...F){for(let K of F)yield*K}e.concat=N;function L(F,K,oe){let P=oe;for(let te of F)P=K(P,te);return P}e.reduce=L;function*A(F,K,oe=F.length){for(K<0&&(K+=F.length),oe<0?oe+=F.length:oe>F.length&&(oe=F.length);K<oe;K++)yield F[K]}e.slice=A;function W(F,K=Number.POSITIVE_INFINITY){let oe=[];if(K===0)return[oe,F];let P=F[Symbol.iterator]();for(let te=0;te<K;te++){let Z=P.next();if(Z.done)return[oe,e.empty()];oe.push(Z.value)}return[oe,{[Symbol.iterator](){return P}}]}e.consume=W;async function U(F){let K=[];for await(let oe of F)K.push(oe);return Promise.resolve(K)}e.asyncToArray=U})(Nk||={});function tl(e){if(Nk.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function KA(...e){return ai(()=>tl(e))}function ai(e){return{dispose:$A(()=>{e()})}}var Mk=class Ak{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{tl(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ak.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(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Mk.DISABLE_DISPOSED_WARNING=!1;var Ja=Mk,yt=class{constructor(){this._store=new Ja,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)}};yt.None=Object.freeze({dispose(){}});var uc=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Qr=typeof window=="object"?window:globalThis,Vv=class Yv{constructor(t){this.element=t,this.next=Yv.Undefined,this.prev=Yv.Undefined}};Vv.Undefined=new Vv(void 0);var ui=Vv,l1=class{constructor(){this._first=ui.Undefined,this._last=ui.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ui.Undefined}clear(){let e=this._first;for(;e!==ui.Undefined;){let t=e.next;e.prev=ui.Undefined,e.next=ui.Undefined,e=t}this._first=ui.Undefined,this._last=ui.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ui(e);if(this._first===ui.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==ui.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ui.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ui.Undefined&&e.next!==ui.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ui.Undefined&&e.next===ui.Undefined?(this._first=ui.Undefined,this._last=ui.Undefined):e.next===ui.Undefined?(this._last=this._last.prev,this._last.next=ui.Undefined):e.prev===ui.Undefined&&(this._first=this._first.next,this._first.prev=ui.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ui.Undefined;)yield e.element,e=e.next}},WA=globalThis.performance&&typeof globalThis.performance.now=="function",qA=class Lk{static create(t){return new Lk(t)}constructor(t){this._now=WA&&t===!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}},pn;(e=>{e.None=()=>yt.None;function t(Y,X){return b(Y,()=>{},0,void 0,!0,void 0,X)}e.defer=t;function n(Y){return(X,V=null,ne)=>{let O=!1,R;return R=Y(I=>{if(!O)return R?R.dispose():O=!0,X.call(V,I)},null,ne),O&&R.dispose(),R}}e.once=n;function r(Y,X,V){return m((ne,O=null,R)=>Y(I=>ne.call(O,X(I)),null,R),V)}e.map=r;function o(Y,X,V){return m((ne,O=null,R)=>Y(I=>{X(I),ne.call(O,I)},null,R),V)}e.forEach=o;function c(Y,X,V){return m((ne,O=null,R)=>Y(I=>X(I)&&ne.call(O,I),null,R),V)}e.filter=c;function u(Y){return Y}e.signal=u;function f(...Y){return(X,V=null,ne)=>{let O=KA(...Y.map(R=>R(I=>X.call(V,I))));return _(O,ne)}}e.any=f;function g(Y,X,V,ne){let O=V;return r(Y,R=>(O=X(O,R),O),ne)}e.reduce=g;function m(Y,X){let V,ne={onWillAddFirstListener(){V=Y(O.fire,O)},onDidRemoveLastListener(){V?.dispose()}},O=new Be(ne);return X?.add(O),O.event}function _(Y,X){return X instanceof Array?X.push(Y):X&&X.add(Y),Y}function b(Y,X,V=100,ne=!1,O=!1,R,I){let de,ge,M,q=0,he,J={leakWarningThreshold:R,onWillAddFirstListener(){de=Y(ve=>{q++,ge=X(ge,ve),ne&&!M&&(ye.fire(ge),ge=void 0),he=()=>{let Le=ge;ge=void 0,M=void 0,(!ne||q>1)&&ye.fire(Le),q=0},typeof V=="number"?(clearTimeout(M),M=setTimeout(he,V)):M===void 0&&(M=0,queueMicrotask(he))})},onWillRemoveListener(){O&&q>0&&he?.()},onDidRemoveLastListener(){he=void 0,de.dispose()}},ye=new Be(J);return I?.add(ye),ye.event}e.debounce=b;function w(Y,X=0,V){return e.debounce(Y,(ne,O)=>ne?(ne.push(O),ne):[O],X,void 0,!0,void 0,V)}e.accumulate=w;function x(Y,X=(ne,O)=>ne===O,V){let ne=!0,O;return c(Y,R=>{let I=ne||!X(R,O);return ne=!1,O=R,I},V)}e.latch=x;function C(Y,X,V){return[e.filter(Y,X,V),e.filter(Y,ne=>!X(ne),V)]}e.split=C;function N(Y,X=!1,V=[],ne){let O=V.slice(),R=Y(ge=>{O?O.push(ge):de.fire(ge)});ne&&ne.add(R);let I=()=>{O?.forEach(ge=>de.fire(ge)),O=null},de=new Be({onWillAddFirstListener(){R||(R=Y(ge=>de.fire(ge)),ne&&ne.add(R))},onDidAddFirstListener(){O&&(X?setTimeout(I):I())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return ne&&ne.add(de),de.event}e.buffer=N;function L(Y,X){return(V,ne,O)=>{let R=X(new W);return Y(function(I){let de=R.evaluate(I);de!==A&&V.call(ne,de)},void 0,O)}}e.chain=L;let A=Symbol("HaltChainable");class W{constructor(){this.steps=[]}map(X){return this.steps.push(X),this}forEach(X){return this.steps.push(V=>(X(V),V)),this}filter(X){return this.steps.push(V=>X(V)?V:A),this}reduce(X,V){let ne=V;return this.steps.push(O=>(ne=X(ne,O),ne)),this}latch(X=(V,ne)=>V===ne){let V=!0,ne;return this.steps.push(O=>{let R=V||!X(O,ne);return V=!1,ne=O,R?O:A}),this}evaluate(X){for(let V of this.steps)if(X=V(X),X===A)break;return X}}function U(Y,X,V=ne=>ne){let ne=(...de)=>I.fire(V(...de)),O=()=>Y.on(X,ne),R=()=>Y.removeListener(X,ne),I=new Be({onWillAddFirstListener:O,onDidRemoveLastListener:R});return I.event}e.fromNodeEventEmitter=U;function F(Y,X,V=ne=>ne){let ne=(...de)=>I.fire(V(...de)),O=()=>Y.addEventListener(X,ne),R=()=>Y.removeEventListener(X,ne),I=new Be({onWillAddFirstListener:O,onDidRemoveLastListener:R});return I.event}e.fromDOMEventEmitter=F;function K(Y){return new Promise(X=>n(Y)(X))}e.toPromise=K;function oe(Y){let X=new Be;return Y.then(V=>{X.fire(V)},()=>{X.fire(void 0)}).finally(()=>{X.dispose()}),X.event}e.fromPromise=oe;function P(Y,X){return Y(V=>X.fire(V))}e.forward=P;function te(Y,X,V){return X(V),Y(ne=>X(ne))}e.runAndSubscribe=te;class Z{constructor(X,V){this._observable=X,this._counter=0,this._hasChanged=!1;let ne={onWillAddFirstListener:()=>{X.addObserver(this)},onDidRemoveLastListener:()=>{X.removeObserver(this)}};this.emitter=new Be(ne),V&&V.add(this.emitter)}beginUpdate(X){this._counter++}handlePossibleChange(X){}handleChange(X,V){this._hasChanged=!0}endUpdate(X){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function me(Y,X){return new Z(Y,X).emitter.event}e.fromObservable=me;function ee(Y){return(X,V,ne)=>{let O=0,R=!1,I={beginUpdate(){O++},endUpdate(){O--,O===0&&(Y.reportChanges(),R&&(R=!1,X.call(V)))},handlePossibleChange(){},handleChange(){R=!0}};Y.addObserver(I),Y.reportChanges();let de={dispose(){Y.removeObserver(I)}};return ne instanceof Ja?ne.add(de):Array.isArray(ne)&&ne.push(de),de}}e.fromObservableLight=ee})(pn||={});var Xv=class Gv{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Gv._idPool++}`,Gv.all.add(this)}start(t){this._stopWatch=new qA,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Xv.all=new Set,Xv._idPool=0;var VA=Xv,YA=-1,Ok=class Bk{constructor(t,n,r=(Bk._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,u]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(f),console.warn(c);let g=new ZA(f,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};Ok._idPool=1;var XA=Ok,GA=class jk{constructor(t){this.value=t}static create(){let t=new Error;return new jk(t.stack??"")}print(){console.warn(this.value.split(`
22
+ `).slice(2).join(`
23
+ `))}},ZA=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},QA=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},JA=0,Mg=class{constructor(e){this.value=e,this.id=JA++}},eL=2,tL,Be=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new XA(e?.onListenerError??ef,this._options?.leakWarningThreshold??YA):void 0,this._perfMon=this._options?._profName?new VA(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new QA(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||ef)(g),yt.None}if(this._disposed)return yt.None;t&&(e=e.bind(t));let r=new Mg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=GA.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Mg?(this._deliveryQueue??=new iL,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=ai(()=>{o?.(),this._removeListener(r)});return n instanceof Ja?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-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--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*eL<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||ef;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Mg)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},iL=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Zv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Be,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Be,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Zv.INSTANCE=new Zv;var zb=Zv;function nL(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}zb.INSTANCE.onDidChangeZoomLevel;function sL(e){return zb.INSTANCE.getZoomFactor(e)}zb.INSTANCE.onDidChangeFullscreen;var bc=typeof navigator=="object"?navigator.userAgent:"",Qv=bc.indexOf("Firefox")>=0,rL=bc.indexOf("AppleWebKit")>=0,Hb=bc.indexOf("Chrome")>=0,aL=!Hb&&bc.indexOf("Safari")>=0;bc.indexOf("Electron/")>=0;bc.indexOf("Android")>=0;var Ag=!1;if(typeof Qr.matchMedia=="function"){let e=Qr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Qr.matchMedia("(display-mode: fullscreen)");Ag=e.matches,nL(Qr,e,({matches:n})=>{Ag&&t.matches||(Ag=n)})}var Ql="en",Jv=!1,e_=!1,tf=!1,Ik=!1,Bh,nf=Ql,c1=Ql,oL,Yr,Go=globalThis,ts;typeof Go.vscode<"u"&&typeof Go.vscode.process<"u"?ts=Go.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ts=process);var lL=typeof ts?.versions?.electron=="string",cL=lL&&ts?.type==="renderer";if(typeof ts=="object"){Jv=ts.platform==="win32",e_=ts.platform==="darwin",tf=ts.platform==="linux",tf&&ts.env.SNAP&&ts.env.SNAP_REVISION,ts.env.CI||ts.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Bh=Ql,nf=Ql;let e=ts.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Bh=t.userLocale,c1=t.osLocale,nf=t.resolvedLanguage||Ql,oL=t.languagePack?.translationsConfigFile}catch{}Ik=!0}else typeof navigator=="object"&&!cL?(Yr=navigator.userAgent,Jv=Yr.indexOf("Windows")>=0,e_=Yr.indexOf("Macintosh")>=0,(Yr.indexOf("Macintosh")>=0||Yr.indexOf("iPad")>=0||Yr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tf=Yr.indexOf("Linux")>=0,Yr?.indexOf("Mobi")>=0,nf=globalThis._VSCODE_NLS_LANGUAGE||Ql,Bh=navigator.language.toLowerCase(),c1=Bh):console.error("Unable to resolve platform.");var Pk=Jv,pr=e_,uL=tf,u1=Ik,gr=Yr,Ua=nf,dL;(e=>{function t(){return Ua}e.value=t;function n(){return Ua.length===2?Ua==="en":Ua.length>=3?Ua[0]==="e"&&Ua[1]==="n"&&Ua[2]==="-":!1}e.isDefaultVariant=n;function r(){return Ua==="en"}e.isDefault=r})(dL||={});var hL=typeof Go.postMessage=="function"&&!Go.importScripts;(()=>{if(hL){let e=[];Go.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Go.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var fL=!!(gr&&gr.indexOf("Chrome")>=0);gr&&gr.indexOf("Firefox")>=0;!fL&&gr&&gr.indexOf("Safari")>=0;gr&&gr.indexOf("Edg/")>=0;gr&&gr.indexOf("Android")>=0;var Kl=typeof navigator=="object"?navigator:{};u1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Kl&&Kl.clipboard&&Kl.clipboard.writeText,u1||Kl&&Kl.clipboard&&Kl.clipboard.readText;var Ub=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Lg=new Ub,d1=new Ub,h1=new Ub,pL=new Array(230),zk;(e=>{function t(f){return Lg.keyCodeToStr(f)}e.toString=t;function n(f){return Lg.strToKeyCode(f)}e.fromString=n;function r(f){return d1.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return h1.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return d1.strToKeyCode(f)||h1.strToKeyCode(f)}e.fromUserSettings=c;function u(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Lg.keyCodeToStr(f)}e.toElectronAccelerator=u})(zk||={});var mL=class Hk{constructor(t,n,r,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Hk&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new gL([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},gL=class{constructor(e){if(e.length===0)throw UA("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function vL(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return zk.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Qv)switch(t){case 59:return 85;case 60:if(uL)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(pr)return 57;break}else if(rL&&(pr&&t===93||!pr&&t===92))return 57;return pL[t]||0}var _L=pr?256:2048,bL=512,yL=1024,SL=pr?2048:256,f1=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=vL(t),this.code=t.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 t=0;return this.ctrlKey&&(t|=_L),this.altKey&&(t|=bL),this.shiftKey&&(t|=yL),this.metaKey&&(t|=SL),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new mL(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},p1=new WeakMap;function wL(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var xL=class{static getSameOriginWindowChain(e){let t=p1.get(e);if(!t){t=[],p1.set(e,t);let n=e,r;do r=wL(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(n+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let f=c.iframeElement.getBoundingClientRect();n+=f.top,r+=f.left}return{top:n,left:r}}},jh=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=xL.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},m1=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(Hb){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*u):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Qv&&!pr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")aL&&Pk?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*u):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Qv&&!pr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Uk=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),CL;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof kL?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:pn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Uk})})(CL||={});var kL=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?Uk:(this._emitter||(this._emitter=new Be),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Fb=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new qv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new qv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},TL=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new qv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=ai(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},EL;(e=>{async function t(r){let o,c=await Promise.all(r.map(u=>u.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(u){c(u)}})}e.withAsyncBody=n})(EL||={});var g1=class vs{static fromArray(t){return new vs(n=>{n.emitMany(t)})}static fromPromise(t){return new vs(async n=>{n.emitMany(await t)})}static fromPromises(t){return new vs(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new vs(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Be,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await pn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new vs(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return vs.map(this,t)}static filter(t,n){return new vs(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return vs.filter(this,t)}static coalesce(t){return vs.filter(t,n=>!!n)}coalesce(){return vs.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return vs.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};g1.EMPTY=g1.fromArray([]);var{getWindow:fr,getWindowId:DL,onDidRegisterWindow:RL}=(function(){let e=new Map,t={window:Qr,disposables:new Ja};e.set(Qr.vscodeWindowId,t);let n=new Be,r=new Be,o=new Be;function c(u,f){return(typeof u=="number"?e.get(u):void 0)??(f?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return yt.None;let f=new Ja,g={window:u,disposables:f.add(new Ja)};return e.set(u.vscodeWindowId,g),f.add(ai(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),f.add(nt(u,Ji.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:c,getWindow(u){let f=u;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:Qr},getDocument(u){return fr(u).document}}})(),NL=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!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 nt(e,t,n,r){return new NL(e,t,n,r)}var v1=function(e,t,n,r){return nt(e,t,n,r)},$b,ML=class extends TL{constructor(e){super(),this.defaultTarget=e&&fr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},_1=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ef(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let u=e.get(c)??[];for(t.set(c,u),e.set(c,[]),r.set(c,!0);u.length>0;)u.sort(_1.sort),u.shift().execute();r.set(c,!1)};$b=(c,u,f=0)=>{let g=DL(c),m=new _1(u,f),_=e.get(g);return _||(_=[],e.set(g,_)),_.push(m),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),m}})();function AL(e){let t=e.getBoundingClientRect(),n=fr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Ji={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"},LL=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 t=Fn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Fn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Fn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Fn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Fn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Fn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Fn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Fn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Fn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Fn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Fn(e);this._paddingRight!==t&&(this._paddingRight=t,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 t=Fn(e);this._fontSize!==t&&(this._fontSize=t,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 t=Fn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Fn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),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,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Fn(e){return typeof e=="number"?`${e}px`:e}function $u(e){return new LL(e)}var Fk=class{constructor(){this._hooks=new Ja,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(ai(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=fr(e)}this._hooks.add(nt(c,Ji.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(nt(c,Ji.POINTER_UP,u=>this.stopMonitoring(!0)))}};function OL(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[c]}}var ur;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ur||={});var Du=class yn extends yt{constructor(){super(),this.dispatched=!1,this.targets=new l1,this.ignoreTargets=new l1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(pn.runAndSubscribe(RL,({window:t,disposables:n})=>{n.add(nt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(nt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(nt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Qr,disposables:this._store}))}static addTarget(t){if(!yn.isTouchDevice())return yt.None;yn.INSTANCE||(yn.INSTANCE=new yn);let n=yn.INSTANCE.targets.push(t);return ai(n)}static ignoreTarget(t){if(!yn.isTouchDevice())return yt.None;yn.INSTANCE||(yn.INSTANCE=new yn);let n=yn.INSTANCE.ignoreTargets.push(t);return ai(n)}static isTouchDevice(){return"ontouchstart"in Qr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let u=this.newGestureEvent(ur.Start,c.target);u.pageX=c.pageX,u.pageY=c.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=n.changedTouches.length;c<u;c++){let f=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let g=this.activeTouches[f.identifier],m=Date.now()-g.initialTimeStamp;if(m<yn.HOLD_DELAY&&Math.abs(g.initialPageX-Qn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Qn(g.rollingPageY))<30){let _=this.newGestureEvent(ur.Tap,g.initialTarget);_.pageX=Qn(g.rollingPageX),_.pageY=Qn(g.rollingPageY),this.dispatchEvent(_)}else if(m>=yn.HOLD_DELAY&&Math.abs(g.initialPageX-Qn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Qn(g.rollingPageY))<30){let _=this.newGestureEvent(ur.Contextmenu,g.initialTarget);_.pageX=Qn(g.rollingPageX),_.pageY=Qn(g.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=Qn(g.rollingPageX),b=Qn(g.rollingPageY),w=Qn(g.rollingTimestamps)-g.rollingTimestamps[0],x=_-g.rollingPageX[0],C=b-g.rollingPageY[0],N=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,N,r,Math.abs(x)/w,x>0?1:-1,_,Math.abs(C)/w,C>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(ur.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===ur.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>yn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===ur.Change||t.type===ur.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,u,f,g,m){this.handle=$b(t,()=>{let _=Date.now(),b=_-r,w=0,x=0,C=!0;o+=yn.SCROLL_FRICTION*b,f+=yn.SCROLL_FRICTION*b,o>0&&(C=!1,w=c*o*b),f>0&&(C=!1,x=g*f*b);let N=this.newGestureEvent(ur.Change);N.translationX=w,N.translationY=x,n.forEach(L=>L.dispatchEvent(N)),C||this.inertia(t,n,_,o,c,u+w,f,g,m+x)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let u=this.activeTouches[c.identifier],f=this.newGestureEvent(ur.Change,u.initialTarget);f.translationX=c.pageX-Qn(u.rollingPageX),f.translationY=c.pageY-Qn(u.rollingPageY),f.pageX=c.pageX,f.pageY=c.pageY,this.dispatchEvent(f),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(c.pageX),u.rollingPageY.push(c.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Du.SCROLL_FRICTION=-.005,Du.HOLD_DELAY=700,Du.CLEAR_TAP_COUNT_TIME=400,yi([OL],Du,"isTouchDevice",1);var BL=Du,Kb=class extends yt{onclick(e,t){this._register(nt(e,Ji.CLICK,n=>t(new jh(fr(e),n))))}onmousedown(e,t){this._register(nt(e,Ji.MOUSE_DOWN,n=>t(new jh(fr(e),n))))}onmouseover(e,t){this._register(nt(e,Ji.MOUSE_OVER,n=>t(new jh(fr(e),n))))}onmouseleave(e,t){this._register(nt(e,Ji.MOUSE_LEAVE,n=>t(new jh(fr(e),n))))}onkeydown(e,t){this._register(nt(e,Ji.KEY_DOWN,n=>t(new f1(n))))}onkeyup(e,t){this._register(nt(e,Ji.KEY_UP,n=>t(new f1(n))))}oninput(e,t){this._register(nt(e,Ji.INPUT,t))}onblur(e,t){this._register(nt(e,Ji.BLUR,t))}onfocus(e,t){this._register(nt(e,Ji.FOCUS,t))}onchange(e,t){this._register(nt(e,Ji.CHANGE,t))}ignoreGesture(e){return BL.ignoreTarget(e)}},b1=11,jL=class extends Kb{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=b1+"px",this.domNode.style.height=b1+"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 Fk),this._register(v1(this.bgDomNode,Ji.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(v1(this.domNode,Ji.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ML),this._pointerdownScheduleRepeatTimer=this._register(new Fb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,fr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},IL=class t_{constructor(t,n,r,o,c,u,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,u=u|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),c<0&&(c=0),f+c>u&&(f=u-c),f<0&&(f=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=u,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new t_(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new t_(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:u,scrollHeightChanged:f,scrollTopChanged:g}}},PL=class extends yt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new IL(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,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){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 n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new S1(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=S1.start(this._state,n,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(),t=this._state.withScrollPosition(e);if(this._setState(t,!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,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},y1=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Og(e,t){let n=t-e;return function(r){return e+n*UL(r)}}function zL(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var S1=class i_{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,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(t,n,r){if(Math.abs(t-n)>2.5*r){let o,c;return t<n?(o=t+.75*r,c=n-.75*r):(o=t-.75*r,c=n+.75*r),zL(Og(t,o),Og(c,n),.33)}return Og(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new y1(r,o,!1)}return new y1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return i_.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new i_(t,n,o,r)}};function HL(e){return Math.pow(e,3)}function UL(e){return 1-HL(1-e)}var FL=class extends yt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Fb)}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(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},$L=140,$k=class extends Kb{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 FL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Fk),this._shouldRender=!0,this.domNode=$u(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(nt(this.domNode.domNode,Ji.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new jL(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=$u(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(nt(this.slider.domNode,Ji.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.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 t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=AL(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),u=Math.abs(c-n);if(Pk&&u>$L){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Kk=class n_{constructor(t,n,r,o,c,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new n_(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,c){let u=Math.max(0,r-t),f=Math.max(0,u-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(r*f/o))),_=(f-m)/(o-r),b=c*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:_,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=n_._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.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(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},KL=class extends $k{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Kk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),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,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}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}},WL=class extends $k{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Kk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),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,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},qL=500,w1=50,VL=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},s_=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Hb){let n=fr(t.browserEvent),r=sL(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,c=new VL(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=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]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(n.deltaX),f=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),m=Math.max(Math.min(c,f),1),_=Math.max(o,u),b=Math.max(c,f);_%g===0&&b%m===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};s_.INSTANCE=new s_;var YL=s_,XL=class extends Kb{constructor(e,t,n){super(),this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Be),this.onWillScroll=this._onWillScroll.event,this._options=ZL(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new WL(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new KL(this._scrollable,this._options,r)),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=$u(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=$u(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=$u(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,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Fb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=tl(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,pr&&(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 m1(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=tl(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new m1(n))};this._mouseWheelToDispose.push(nt(this._listenOnDomNode,Ji.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=YL.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let u=!pr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),g={};if(o){let m=w1*o,_=f.scrollTop-(m<0?Math.floor(m):Math.ceil(m));this._verticalScrollbar.writeScrollPosition(g,_)}if(c){let m=w1*c,_=f.scrollLeft-(m<0?Math.floor(m):Math.ceil(m));this._horizontalScrollbar.writeScrollPosition(g,_)}g=this._scrollable.validateScrollPosition(g),(f.scrollLeft!==g.scrollLeft||f.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(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(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_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(),qL)}},GL=class extends XL{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ZL(e){let t={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 t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,pr&&(t.className+=" mac"),t}var r_=class extends yt{constructor(e,t,n,r,o,c,u,f){super(),this._bufferService=n,this._optionsService=u,this._renderService=f,this._onRequestScrollLines=this._register(new Be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new PL({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>$b(r.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new GL(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(pn.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ai(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ai(()=>this._styleElement.remove())),this._register(pn.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
24
+ `)})),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(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.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 t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};r_=yi([Ue(2,Mn),Ue(3,sa),Ue(4,Ck),Ue(5,_c),Ue(6,An),Ue(7,ra)],r_);var a_=class extends yt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,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(c=>this._removeDecoration(c))),this._register(ai(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(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=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};a_=yi([Ue(1,Mn),Ue(2,sa),Ue(3,_d),Ue(4,ra)],a_);var QL=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,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,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},lr={full:0,left:0,center:0,right:0},Fa={full:0,left:0,center:0,right:0},gu={full:0,left:0,center:0,right:0},Df=class extends yt{constructor(e,t,n,r,o,c,u,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=f,this._colorZoneStore=new QL,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(ai(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;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(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Fa.full=this._canvas.width,Fa.left=e,Fa.center=t,Fa.right=e,this._refreshDrawHeightConstants(),gu.full=1,gu.left=1,gu.center=1+Fa.left,gu.right=1+Fa.left+Fa.center}_refreshDrawHeightConstants(){lr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);lr.left=t,lr.center=t,lr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*lr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*lr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*lr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*lr.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 t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_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(gu[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-lr[e.position||"full"]/2),Fa[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+lr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Df=yi([Ue(2,Mn),Ue(3,_d),Ue(4,ra),Ue(5,An),Ue(6,_c),Ue(7,sa)],Df);var Ce;(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=`
25
+ `,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=""))(Ce||={});var sf;(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="Ÿ"))(sf||={});var Wk;(e=>e.ST=`${Ce.ESC}\\`)(Wk||={});var o_=class{constructor(e,t,n,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=c,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 t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Ce.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};o_=yi([Ue(2,Mn),Ue(3,An),Ue(4,rl),Ue(5,ra)],o_);var tn=0,nn=0,sn=0,_i=0,x1={css:"#00000000",rgba:0},ji;(e=>{function t(o,c,u,f){return f!==void 0?`#${Ko(o)}${Ko(c)}${Ko(u)}${Ko(f)}`:`#${Ko(o)}${Ko(c)}${Ko(u)}`}e.toCss=t;function n(o,c,u,f=255){return(o<<24|c<<16|u<<8|f)>>>0}e.toRgba=n;function r(o,c,u,f){return{css:e.toCss(o,c,u,f),rgba:e.toRgba(o,c,u,f)}}e.toColor=r})(ji||={});var ii;(e=>{function t(g,m){if(_i=(m.rgba&255)/255,_i===1)return{css:m.css,rgba:m.rgba};let _=m.rgba>>24&255,b=m.rgba>>16&255,w=m.rgba>>8&255,x=g.rgba>>24&255,C=g.rgba>>16&255,N=g.rgba>>8&255;tn=x+Math.round((_-x)*_i),nn=C+Math.round((b-C)*_i),sn=N+Math.round((w-N)*_i);let L=ji.toCss(tn,nn,sn),A=ji.toRgba(tn,nn,sn);return{css:L,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,m,_){let b=rf.ensureContrastRatio(g.rgba,m.rgba,_);if(b)return ji.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let m=(g.rgba|255)>>>0;return[tn,nn,sn]=rf.toChannels(m),{css:ji.toCss(tn,nn,sn),rgba:m}}e.opaque=o;function c(g,m){return _i=Math.round(m*255),[tn,nn,sn]=rf.toChannels(g.rgba),{css:ji.toCss(tn,nn,sn,_i),rgba:ji.toRgba(tn,nn,sn,_i)}}e.opacity=c;function u(g,m){return _i=g.rgba&255,c(g,_i*m/255)}e.multiplyOpacity=u;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(ii||={});var di;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return tn=parseInt(o.slice(1,2).repeat(2),16),nn=parseInt(o.slice(2,3).repeat(2),16),sn=parseInt(o.slice(3,4).repeat(2),16),ji.toColor(tn,nn,sn);case 5:return tn=parseInt(o.slice(1,2).repeat(2),16),nn=parseInt(o.slice(2,3).repeat(2),16),sn=parseInt(o.slice(3,4).repeat(2),16),_i=parseInt(o.slice(4,5).repeat(2),16),ji.toColor(tn,nn,sn,_i);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return tn=parseInt(c[1]),nn=parseInt(c[2]),sn=parseInt(c[3]),_i=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ji.toColor(tn,nn,sn,_i);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[tn,nn,sn,_i]=t.getImageData(0,0,1,1).data,_i!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ji.toRgba(tn,nn,sn,_i),css:o}}e.toColor=r})(di||={});var Rn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let u=r/255,f=o/255,g=c/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return m*.2126+_*.7152+b*.0722}e.relativeLuminance2=n})(Rn||={});var rf;(e=>{function t(u,f){if(_i=(f&255)/255,_i===1)return f;let g=f>>24&255,m=f>>16&255,_=f>>8&255,b=u>>24&255,w=u>>16&255,x=u>>8&255;return tn=b+Math.round((g-b)*_i),nn=w+Math.round((m-w)*_i),sn=x+Math.round((_-x)*_i),ji.toRgba(tn,nn,sn)}e.blend=t;function n(u,f,g){let m=Rn.relativeLuminance(u>>8),_=Rn.relativeLuminance(f>>8);if(Vr(m,_)<g){if(_<m){let x=r(u,f,g),C=Vr(m,Rn.relativeLuminance(x>>8));if(C<g){let N=o(u,f,g),L=Vr(m,Rn.relativeLuminance(N>>8));return C>L?x:N}return x}let b=o(u,f,g),w=Vr(m,Rn.relativeLuminance(b>>8));if(w<g){let x=r(u,f,g),C=Vr(m,Rn.relativeLuminance(x>>8));return w>C?b:x}return b}}e.ensureContrastRatio=n;function r(u,f,g){let m=u>>24&255,_=u>>16&255,b=u>>8&255,w=f>>24&255,x=f>>16&255,C=f>>8&255,N=Vr(Rn.relativeLuminance2(w,x,C),Rn.relativeLuminance2(m,_,b));for(;N<g&&(w>0||x>0||C>0);)w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),C-=Math.max(0,Math.ceil(C*.1)),N=Vr(Rn.relativeLuminance2(w,x,C),Rn.relativeLuminance2(m,_,b));return(w<<24|x<<16|C<<8|255)>>>0}e.reduceLuminance=r;function o(u,f,g){let m=u>>24&255,_=u>>16&255,b=u>>8&255,w=f>>24&255,x=f>>16&255,C=f>>8&255,N=Vr(Rn.relativeLuminance2(w,x,C),Rn.relativeLuminance2(m,_,b));for(;N<g&&(w<255||x<255||C<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),N=Vr(Rn.relativeLuminance2(w,x,C),Rn.relativeLuminance2(m,_,b));return(w<<24|x<<16|C<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(rf||={});function Ko(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Vr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var JL=class extends vd{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Rf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ws}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,c=0,u=0,f=t.getFg(0),g=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(m-o>1){let _=this._getJoinedRanges(r,u,c,t,o);for(let b=0;b<_.length;b++)n.push(_[b])}o=m,u=c,f=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Za.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(r,u,c,t,o);for(let _=0;_<m.length;_++)n.push(m[_])}return n}_getJoinedRanges(e,t,n,r,o){let c=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(c)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let g=this._characterJoiners[f].handler(c);for(let m=0;m<g.length;m++)Rf._mergeRanges(u,g[m])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,u=e[r];if(u){for(let f=n;f<this._bufferService.cols;f++){let g=t.getWidth(f),m=t.getString(f).length||Za.length;if(g!==0){if(!o&&u[0]<=c&&(u[0]=f,o=!0),u[1]<=c){if(u[1]=f,u=e[++r],!u)break;u[0]<=c?(u[0]=f,o=!0):o=!1}c+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Rf=yi([Ue(0,Mn)],Rf);function e3(e){return 57508<=e&&e<=57558}function t3(e){return 9472<=e&&e<=9631}function i3(e){return e3(e)||t3(e)}function n3(){return{css:{canvas:Ih(),cell:Ih()},device:{canvas:Ih(),cell:Ih(),char:{width:0,height:0,left:0,top:0}}}}function Ih(){return{width:0,height:0}}var l_=class{constructor(e,t,n,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new ws,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,u,f,g,m,_){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),x=this._themeService.colors,C=e.getNoBgTrimmedLength();n&&C<c+1&&(C=c+1);let N,L=0,A="",W=0,U=0,F=0,K=0,oe=!1,P=0,te=!1,Z=0,me=0,ee=[],Y=m!==-1&&_!==-1;for(let X=0;X<C;X++){e.loadCell(X,this._workCell);let V=this._workCell.getWidth();if(V===0)continue;let ne=!1,O=X>=me,R=X,I=this._workCell;if(w.length>0&&X===w[0][0]&&O){let E=w.shift(),z=this._isCellInSelection(E[0],t);for(W=E[0]+1;W<E[1];W++)O&&=z===this._isCellInSelection(W,t);O&&=!n||c<E[0]||c>=E[1],O?(ne=!0,I=new JL(this._workCell,e.translateToString(!0,E[0],E[1]),E[1]-E[0]),R=E[1]-1,V=I.getWidth()):me=E[1]}let de=this._isCellInSelection(X,t),ge=n&&X===c,M=Y&&X>=m&&X<=_,q=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,E=>{q=!0});let he=I.getChars()||Za;if(he===" "&&(I.isUnderline()||I.isOverline())&&(he=" "),Z=V*f-g.get(he,I.isBold(),I.isItalic()),!N)N=this._document.createElement("span");else if(L&&(de&&te||!de&&!te&&I.bg===U)&&(de&&te&&x.selectionForeground||I.fg===F)&&I.extended.ext===K&&M===oe&&Z===P&&!ge&&!ne&&!q&&O){I.isInvisible()?A+=Za:A+=he,L++;continue}else L&&(N.textContent=A),N=this._document.createElement("span"),L=0,A="";if(U=I.bg,F=I.fg,K=I.extended.ext,oe=M,P=Z,te=de,ne&&c>=X&&c<=R&&(c=X),!this._coreService.isCursorHidden&&ge&&this._coreService.isCursorInitialized){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ee.push("xterm-cursor-blink"),ee.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline");break}}if(I.isBold()&&ee.push("xterm-bold"),I.isItalic()&&ee.push("xterm-italic"),I.isDim()&&ee.push("xterm-dim"),I.isInvisible()?A=Za:A=I.getChars()||Za,I.isUnderline()&&(ee.push(`xterm-underline-${I.extended.underlineStyle}`),A===" "&&(A=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${vd.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let E=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&E<8&&(E+=8),N.style.textDecorationColor=x.ansi[E].css}I.isOverline()&&(ee.push("xterm-overline"),A===" "&&(A=" ")),I.isStrikethrough()&&ee.push("xterm-strikethrough"),M&&(N.style.textDecoration="underline");let J=I.getFgColor(),ye=I.getFgColorMode(),ve=I.getBgColor(),Le=I.getBgColorMode(),Ne=!!I.isInverse();if(Ne){let E=J;J=ve,ve=E;let z=ye;ye=Le,Le=z}let Fe,He,Pe=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,E=>{E.options.layer!=="top"&&Pe||(E.backgroundColorRGB&&(Le=50331648,ve=E.backgroundColorRGB.rgba>>8&16777215,Fe=E.backgroundColorRGB),E.foregroundColorRGB&&(ye=50331648,J=E.foregroundColorRGB.rgba>>8&16777215,He=E.foregroundColorRGB),Pe=E.options.layer==="top")}),!Pe&&de&&(Fe=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,ve=Fe.rgba>>8&16777215,Le=50331648,Pe=!0,x.selectionForeground&&(ye=50331648,J=x.selectionForeground.rgba>>8&16777215,He=x.selectionForeground)),Pe&&ee.push("xterm-decoration-top");let Ze;switch(Le){case 16777216:case 33554432:Ze=x.ansi[ve],ee.push(`xterm-bg-${ve}`);break;case 50331648:Ze=ji.toColor(ve>>16,ve>>8&255,ve&255),this._addStyle(N,`background-color:#${C1((ve>>>0).toString(16),"0",6)}`);break;default:Ne?(Ze=x.foreground,ee.push("xterm-bg-257")):Ze=x.background}switch(Fe||I.isDim()&&(Fe=ii.multiplyOpacity(Ze,.5)),ye){case 16777216:case 33554432:I.isBold()&&J<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(J+=8),this._applyMinimumContrast(N,Ze,x.ansi[J],I,Fe,void 0)||ee.push(`xterm-fg-${J}`);break;case 50331648:let E=ji.toColor(J>>16&255,J>>8&255,J&255);this._applyMinimumContrast(N,Ze,E,I,Fe,He)||this._addStyle(N,`color:#${C1(J.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(N,Ze,x.foreground,I,Fe,He)||Ne&&ee.push("xterm-fg-257")}ee.length&&(N.className=ee.join(" "),ee.length=0),!ge&&!ne&&!q&&O?L++:N.textContent=A,Z!==this.defaultSpacing&&(N.style.letterSpacing=`${Z}px`),b.push(N),X=R}return N&&L&&(N.textContent=A),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||i3(r.getCode()))return!1;let u=this._getContrastCache(r),f;if(!o&&!c&&(f=u.getColor(t.rgba,n.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=ii.ensureContrastRatio(o||t,c||n,g),u.setColor((o||t).rgba,(c||n).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};l_=yi([Ue(1,Ek),Ue(2,An),Ue(3,sa),Ue(4,rl),Ue(5,_d),Ue(6,_c)],l_);function C1(e,t,n){for(;e.length<n;)e=t+e;return e}var s3=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,r,o,c],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),n&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},r3=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,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,u=n[1]-o,f=Math.max(c,0),g=Math.min(u,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=u,this.viewportCappedStartRow=f,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function a3(){return new r3}var Bg="xterm-dom-renderer-owner-",gs="xterm-rows",Ph="xterm-fg-",k1="xterm-bg-",vu="xterm-focus",zh="xterm-selection",o3=1,c_=class extends yt{constructor(e,t,n,r,o,c,u,f,g,m,_,b,w,x){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=u,this._charSizeService=g,this._optionsService=m,this._bufferService=_,this._coreService=b,this._coreBrowserService=w,this._themeService=x,this._terminalClass=o3++,this._rowElements=[],this._selectionRenderModel=a3(),this.onRequestRedraw=this._register(new Be).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(gs),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(zh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=n3(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(C=>this._injectCss(C))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(l_,document),this._element.classList.add(Bg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(C=>this._handleLinkHover(C))),this._register(this._linkifier2.onHideLinkUnderline(C=>this._handleLinkLeave(C))),this._register(ai(()=>{this._element.classList.remove(Bg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new s3(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 n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${gs} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${gs} { 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}`;t+=`${this._terminalSelector} .${gs} .xterm-dim { color: ${ii.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${gs}.${vu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${gs}.${vu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${gs}.${vu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${gs} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${gs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${gs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${gs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${gs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${zh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${zh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${zh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Ph}${c} { color: ${u.css}; }${this._terminalSelector} .${Ph}${c}.xterm-dim { color: ${ii.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${k1}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Ph}257 { color: ${ii.opaque(e.background).css}; }${this._terminalSelector} .${Ph}257.xterm-dim { color: ${ii.multiplyOpacity(ii.opaque(e.background),.5).css}; }${this._terminalSelector} .${k1}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(vu),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(vu),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];f.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],u-c+1))}else{let g=r===c?e[0]:0,m=c===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,g,m));let _=u-c-1;if(f.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,_)),c!==u){let b=o===u?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let m=g+n.ydisp,_=this._rowElements[g],b=n.lines.get(m);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,m,m===r,u,f,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Bg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,c){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,g=f.ybase+f.y,m=Math.min(f.x,o-1),_=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=n;x<=r;++x){let C=x+f.ydisp,N=this._rowElements[x],L=f.lines.get(C);if(!N||!L)break;N.replaceChildren(...this._rowFactory.createRow(L,C,C===g,b,w,m,_,this.dimensions.css.cell.width,this._widthCache,c?x===n?e:0:-1,c?(x===r?t:o)-1:-1))}}};c_=yi([Ue(7,Ib),Ue(8,lp),Ue(9,An),Ue(10,Mn),Ue(11,rl),Ue(12,sa),Ue(13,_c)],c_);var u_=class extends yt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Be),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new c3(this._optionsService))}catch{this._measureStrategy=this._register(new l3(e,t,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())}};u_=yi([Ue(2,An)],u_);var qk=class extends yt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},l3=class extends qk{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},c3=class extends qk{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw 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}},u3=class extends yt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new d3(this._window)),this._onDprChange=this._register(new Be),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Be),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(pn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(nt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(nt(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}},d3=class extends yt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new uc),this._onDprChange=this._register(new Be),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ai(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=nt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},h3=class extends yt{constructor(){super(),this.linkProviders=[],this._register(ai(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Wb(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function f3(e,t,n,r,o,c,u,f,g){if(!c)return;let m=Wb(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(g?u/2:0))/u),m[1]=Math.ceil(m[1]/f),m[0]=Math.min(Math.max(m[0],1),r+(g?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var d_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return f3(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Wb(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};d_=yi([Ue(0,ra),Ue(1,lp)],d_);var p3=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,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,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t: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,t):t,!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),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Vk={};CA(Vk,{getSafariVersion:()=>g3,isChromeOS:()=>Zk,isFirefox:()=>Yk,isIpad:()=>v3,isIphone:()=>_3,isLegacyEdge:()=>m3,isLinux:()=>qb,isMac:()=>Nf,isNode:()=>cp,isSafari:()=>Xk,isWindows:()=>Gk});var cp=typeof process<"u"&&"title"in process,bd=cp?"node":navigator.userAgent,yd=cp?"node":navigator.platform,Yk=bd.includes("Firefox"),m3=bd.includes("Edge"),Xk=/^((?!chrome|android).)*safari/i.test(bd);function g3(){if(!Xk)return 0;let e=bd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Nf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(yd),v3=yd==="iPad",_3=yd==="iPhone",Gk=["Windows","Win16","Win32","WinCE"].includes(yd),qb=yd.indexOf("Linux")>=0,Zk=/\bCrOS\b/.test(bd),Qk=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 t=0,n=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},b3=class extends Qk{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},y3=class extends Qk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Mf=!cp&&"requestIdleCallback"in window?y3:b3,S3=class{constructor(){this._queue=new Mf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},h_=class extends yt{constructor(e,t,n,r,o,c,u,f,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new uc),this._pausedResizeTask=new S3,this._observerDisposable=this._register(new uc),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 Be),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Be),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Be),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Be),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p3((m,_)=>this._renderRows(m,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new w3(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ai(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ai(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};h_=yi([Ue(2,An),Ue(3,lp),Ue(4,rl),Ue(5,_d),Ue(6,Mn),Ue(7,sa),Ue(8,_c)],h_);var w3=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,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 x3(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return T3(o,c,e,t,n,r)+up(c,t,n,r)+E3(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",ed(Math.abs(o-e),Ju(u,r));u=c>t?"D":"C";let f=Math.abs(c-t),g=k3(c>t?e:o,n)+(f-1)*n.cols+1+C3(c>t?o:e);return ed(g,Ju(u,r))}function C3(e,t){return e-1}function k3(e,t){return t.cols-e}function T3(e,t,n,r,o,c){return up(t,r,o,c).length===0?"":ed(eT(e,t,e,t-il(t,o),!1,o).length,Ju("D",c))}function up(e,t,n,r){let o=e-il(e,n),c=t-il(t,n),u=Math.abs(o-c)-D3(e,t,n);return ed(u,Ju(Jk(e,t),r))}function E3(e,t,n,r,o,c){let u;up(t,r,o,c).length>0?u=r-il(r,o):u=t;let f=r,g=R3(e,t,n,r,o,c);return ed(eT(e,u,n,f,g==="C",o).length,Ju(g,c))}function D3(e,t,n){let r=0,o=e-il(e,n),c=t-il(t,n);for(let u=0;u<Math.abs(o-c);u++){let f=Jk(e,t)==="A"?-1:1;n.buffer.lines.get(o+f*u)?.isWrapped&&r++}return r}function il(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function R3(e,t,n,r,o,c){let u;return up(n,r,o,c).length>0?u=r-il(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function Jk(e,t){return e>t?"A":"B"}function eT(e,t,n,r,o,c){let u=e,f=t,g="";for(;(u!==n||f!==r)&&f>=0&&f<c.buffer.lines.length;)u+=o?1:-1,o&&u>c.cols-1?(g+=c.buffer.translateBufferLineToString(f,!1,e,u),u=0,e=0,f++):!o&&u<0&&(g+=c.buffer.translateBufferLineToString(f,!1,0,e+1),u=c.cols-1,e=u,f--);return g+c.buffer.translateBufferLineToString(f,!1,e,u)}function Ju(e,t){let n=t?"O":"[";return Ce.ESC+n+e}function ed(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var N3=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,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function T1(e,t){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 t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var jg=50,M3=15,A3=50,L3=500,O3=" ",B3=new RegExp(O3,"g"),f_=class extends yt{constructor(e,t,n,r,o,c,u,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=u,this._renderService=f,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ws,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Be),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Be),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Be),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new N3(this._bufferService),this._activeSelectionMode=0,this._register(ai(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.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,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let f=n.translateBufferLineToString(u,!0,o,c);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let u=n.lines.get(c),f=n.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(B3," ")).join(Gk?`\r
26
+ `:`
27
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),qb&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=T1(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Wb(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-jg),jg),t/=jg,t/Math.abs(t)+Math.round(t*(M3-1)))}shouldForceSelection(e){return Nf?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(),A3)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Nf&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<L3&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=x3(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let u=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(c,e[0]),g=f,m=e[0]-f,_=0,b=0,w=0,x=0;if(u.charAt(f)===" "){for(;f>0&&u.charAt(f-1)===" ";)f--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let L=e[0],A=e[0];c.getWidth(L)===0&&(_++,L--),c.getWidth(A)===2&&(b++,A++);let W=c.getString(A).length;for(W>1&&(x+=W-1,g+=W-1);L>0&&f>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,L--):U>1&&(w+=U-1,f-=U-1),f--,L--}for(;A<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let U=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,A++):U>1&&(x+=U-1,g+=U-1),g++,A++}}g++;let C=f+m-_+w,N=Math.min(this._bufferService.cols,g-f+_+b-w-x);if(!(!t&&u.slice(f,g).trim()==="")){if(n&&C===0&&c.getCodePoint(0)!==32){let L=o.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let W=this._bufferService.cols-A.start;C-=W,N+=W}}}if(r&&C+N===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=o.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(N+=A.length)}}return{start:C,length:N}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=T1(n,this._bufferService.cols)}};f_=yi([Ue(3,Mn),Ue(4,rl),Ue(5,Pb),Ue(6,An),Ue(7,ra),Ue(8,sa)],f_);var E1=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},D1=class{constructor(){this._color=new E1,this._css=new E1}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},$i=Object.freeze((()=>{let e=[di.toColor("#2e3436"),di.toColor("#cc0000"),di.toColor("#4e9a06"),di.toColor("#c4a000"),di.toColor("#3465a4"),di.toColor("#75507b"),di.toColor("#06989a"),di.toColor("#d3d7cf"),di.toColor("#555753"),di.toColor("#ef2929"),di.toColor("#8ae234"),di.toColor("#fce94f"),di.toColor("#729fcf"),di.toColor("#ad7fa8"),di.toColor("#34e2e2"),di.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:ji.toCss(r,o,c),rgba:ji.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:ji.toCss(r,r,r),rgba:ji.toRgba(r,r,r)})}return e})()),Wo=di.toColor("#ffffff"),Ru=di.toColor("#000000"),R1=di.toColor("#ffffff"),N1=Ru,_u={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},j3=Wo,p_=class extends yt{constructor(e){super(),this._optionsService=e,this._contrastCache=new D1,this._halfContrastCache=new D1,this._onChangeColors=this._register(new Be),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Wo,background:Ru,cursor:R1,cursorAccent:N1,selectionForeground:void 0,selectionBackgroundTransparent:_u,selectionBackgroundOpaque:ii.blend(Ru,_u),selectionInactiveBackgroundTransparent:_u,selectionInactiveBackgroundOpaque:ii.blend(Ru,_u),scrollbarSliderBackground:ii.opacity(Wo,.2),scrollbarSliderHoverBackground:ii.opacity(Wo,.4),scrollbarSliderActiveBackground:ii.opacity(Wo,.5),overviewRulerBorder:Wo,ansi:$i.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Xt(e.foreground,Wo),t.background=Xt(e.background,Ru),t.cursor=ii.blend(t.background,Xt(e.cursor,R1)),t.cursorAccent=ii.blend(t.background,Xt(e.cursorAccent,N1)),t.selectionBackgroundTransparent=Xt(e.selectionBackground,_u),t.selectionBackgroundOpaque=ii.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Xt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ii.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Xt(e.selectionForeground,x1):void 0,t.selectionForeground===x1&&(t.selectionForeground=void 0),ii.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ii.opacity(t.selectionBackgroundTransparent,.3)),ii.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ii.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Xt(e.scrollbarSliderBackground,ii.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Xt(e.scrollbarSliderHoverBackground,ii.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Xt(e.scrollbarSliderActiveBackground,ii.opacity(t.foreground,.5)),t.overviewRulerBorder=Xt(e.overviewRulerBorder,j3),t.ansi=$i.slice(),t.ansi[0]=Xt(e.black,$i[0]),t.ansi[1]=Xt(e.red,$i[1]),t.ansi[2]=Xt(e.green,$i[2]),t.ansi[3]=Xt(e.yellow,$i[3]),t.ansi[4]=Xt(e.blue,$i[4]),t.ansi[5]=Xt(e.magenta,$i[5]),t.ansi[6]=Xt(e.cyan,$i[6]),t.ansi[7]=Xt(e.white,$i[7]),t.ansi[8]=Xt(e.brightBlack,$i[8]),t.ansi[9]=Xt(e.brightRed,$i[9]),t.ansi[10]=Xt(e.brightGreen,$i[10]),t.ansi[11]=Xt(e.brightYellow,$i[11]),t.ansi[12]=Xt(e.brightBlue,$i[12]),t.ansi[13]=Xt(e.brightMagenta,$i[13]),t.ansi[14]=Xt(e.brightCyan,$i[14]),t.ansi[15]=Xt(e.brightWhite,$i[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Xt(e.extendedAnsi[r],$i[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];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()}}};p_=yi([Ue(0,An)],p_);function Xt(e,t){if(e!==void 0)try{return di.toColor(e)}catch{}return t}var I3=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},P3=class{constructor(){this._services=new I3,this._services.set(Ib,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=MA(e).sort((c,u)=>c.index-u.index),r=[];for(let c of n){let u=this._services.get(c.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},z3={trace:0,debug:1,info:2,warn:3,error:4,off:5},H3="xterm.js: ",m_=class extends yt{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=z3[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":H3)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};m_=yi([Ue(0,An)],m_);var M1=class extends yt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Be),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Be),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Be),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 t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},bt=3,Bi=Object.freeze(new vd),Hh=0,Ig=2,Nu=class tT{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*bt);let o=n||ws.fromCharData([0,yk,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*bt+0],r=n&2097151;return[this._data[t*bt+1],n&2097152?this._combined[t]:r?Xa(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*bt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*bt+0]=t|2097152|n[2]<<22):this._data[t*bt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*bt+0]>>22}hasWidth(t){return this._data[t*bt+0]&12582912}getFg(t){return this._data[t*bt+1]}getBg(t){return this._data[t*bt+2]}hasContent(t){return this._data[t*bt+0]&4194303}getCodePoint(t){let n=this._data[t*bt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*bt+0]&2097152}getString(t){let n=this._data[t*bt+0];return n&2097152?this._combined[t]:n&2097151?Xa(n&2097151):""}isProtected(t){return this._data[t*bt+2]&536870912}loadCell(t,n){return Hh=t*bt,n.content=this._data[Hh+0],n.fg=this._data[Hh+1],n.bg=this._data[Hh+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*bt+0]=n.content,this._data[t*bt+1]=n.fg,this._data[t*bt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*bt+0]=n|r<<22,this._data[t*bt+1]=o.fg,this._data[t*bt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*bt+0];o&2097152?this._combined[t]+=Xa(n):o&2097151?(this._combined[t]=Xa(o&2097151)+Xa(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*bt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new ws;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,o));for(let c=0;c<n;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new ws;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,o));for(let c=this.length-n;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*Ig<this._data.buffer.byteLength;let r=t*bt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let f=parseInt(o[u],10);f>=t&&delete this._combined[f]}let c=Object.keys(this._extendedAttrs);for(let u=0;u<c.length;u++){let f=parseInt(c[u],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*Ig<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ig<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new tT(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*bt+0]&4194303)return t+(this._data[t*bt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*bt+0]&4194303||this._data[t*bt+2]&50331648)return t+(this._data[t*bt+0]>>22);return 0}copyCellsFrom(t,n,r,o,c){let u=t._data;if(c)for(let g=o-1;g>=0;g--){for(let m=0;m<bt;m++)this._data[(r+g)*bt+m]=u[(n+g)*bt+m];u[(n+g)*bt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let m=0;m<bt;m++)this._data[(r+g)*bt+m]=u[(n+g)*bt+m];u[(n+g)*bt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let m=parseInt(f[g],10);m>=n&&(this._combined[m-n+r]=t._combined[m])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<r;){let u=this._data[n*bt+0],f=u&2097151,g=u&2097152?this._combined[n]:f?Xa(f):Za;if(c+=g,o)for(let m=0;m<g.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function U3(e,t,n,r,o,c){let u=[];for(let f=0;f<e.length-1;f++){let g=f,m=e.get(++g);if(!m.isWrapped)continue;let _=[e.get(f)];for(;g<e.length&&m.isWrapped;)_.push(m),m=e.get(++g);if(!c&&r>=f&&r<g){f+=_.length-1;continue}let b=0,w=td(_,b,t),x=1,C=0;for(;x<_.length;){let L=td(_,x,t),A=L-C,W=n-w,U=Math.min(A,W);_[b].copyCellsFrom(_[x],C,w,U,!1),w+=U,w===n&&(b++,w=0),C+=U,C===L&&(x++,C=0),w===0&&b!==0&&_[b-1].getWidth(n-1)===2&&(_[b].copyCellsFrom(_[b-1],n-1,w++,1,!1),_[b-1].setCell(n-1,o))}_[b].replaceCells(w,n,o);let N=0;for(let L=_.length-1;L>0&&(L>b||_[L].getTrimmedLength()===0);L--)N++;N>0&&(u.push(f+_.length-N),u.push(N)),f+=_.length-1}return u}function F3(e,t){let n=[],r=0,o=t[r],c=0;for(let u=0;u<e.length;u++)if(o===u){let f=t[++r];e.onDeleteEmitter.fire({index:u-c,amount:f}),u+=f-1,c+=f,o=t[++r]}else n.push(u);return{layout:n,countRemoved:c}}function $3(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function K3(e,t,n){let r=[],o=e.map((g,m)=>td(e,m,t)).reduce((g,m)=>g+m),c=0,u=0,f=0;for(;f<o;){if(o-f<n){r.push(o-f);break}c+=n;let g=td(e,u,t);c>g&&(c-=g,u++);let m=e[u].getWidth(c-1)===2;m&&c--;let _=m?n-1:n;r.push(_),f+=_}return r}function td(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var iT=class nT{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=nT._nextId++,this._onDispose=this.register(new Be),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),tl(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};iT._nextId=1;var W3=iT,qi={},qo=qi.B;qi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};qi.A={"#":"£"};qi.B=void 0;qi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};qi.C=qi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};qi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};qi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};qi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};qi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};qi.E=qi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};qi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};qi.H=qi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};qi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var A1=4294967295,L1=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Bi.clone(),this.savedCharset=qo,this.markers=[],this._nullCell=ws.fromCharData([0,yk,1,0]),this._whitespaceCell=ws.fromCharData([0,Za,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Mf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new M1(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 Ef),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 Ef),this._whitespaceCell}getBlankLine(e,t){return new Nu(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>A1?A1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Bi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new M1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Bi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let c=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Nu(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Nu(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=U3(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Bi),n);if(r.length>0){let o=F3(this.lines,r);$3(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Bi),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Nu(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Bi),o=[],c=0;for(let u=this.lines.length-1;u>=0;u--){let f=this.lines.get(u);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&u>0;)f=this.lines.get(--u),g.unshift(f);if(!n){let U=this.ybase+this.y;if(U>=u&&U<u+g.length)continue}let m=g[g.length-1].getTrimmedLength(),_=K3(g,this._cols,e),b=_.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let x=[];for(let U=0;U<b;U++){let F=this.getBlankLine(Bi,!0);x.push(F)}x.length>0&&(o.push({start:u+g.length+c,newLines:x}),c+=x.length),g.push(...x);let C=_.length-1,N=_[C];N===0&&(C--,N=_[C]);let L=g.length-b-1,A=m;for(;L>=0;){let U=Math.min(A,N);if(g[C]===void 0)break;if(g[C].copyCellsFrom(g[L],A-U,N-U,U,!0),N-=U,N===0&&(C--,N=_[C]),A-=U,A===0){L--;let F=Math.max(L,0);A=td(g,F,this._cols)}}for(let U=0;U<g.length;U++)_[U]<e&&g[U].setCell(_[U],r);let W=b-w;for(;W-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],f=[];for(let N=0;N<this.lines.length;N++)f.push(this.lines.get(N));let g=this.lines.length,m=g-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let N=Math.min(this.lines.maxLength-1,g+c-1);N>=0;N--)if(b&&b.start>m+w){for(let L=b.newLines.length-1;L>=0;L--)this.lines.set(N--,b.newLines[L]);N++,u.push({index:m+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++_]}else this.lines.set(N,f[m--]);let x=0;for(let N=u.length-1;N>=0;N--)u[N].index+=x,this.lines.onInsertEmitter.fire(u[N]),x+=u[N].amount;let C=Math.max(0,g+c-this.lines.maxLength);C>0&&this.lines.onTrimEmitter.fire(C)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(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 t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new W3(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},q3=class extends yt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Be),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 L1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new L1(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},sT=2,rT=1,g_=class extends yt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Be),this.onResize=this._onResize.event,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,sT),this.rows=Math.max(e.rawOptions.rows||0,rT),this.buffers=this._register(new q3(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;c===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=c-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(c,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};g_=yi([Ue(0,An)],g_);var Wl={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:Nf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},V3=["normal","bold","100","200","300","400","500","600","700","800","900"],Y3=class extends yt{constructor(e){super(),this._onOptionChange=this._register(new Be),this.onOptionChange=this._onOptionChange.event;let t={...Wl};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ai(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Wl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in Wl))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wl[e]),!X3(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=V3.includes(t)?t:Wl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function X3(e){return e==="block"||e==="underline"||e==="bar"}function Mu(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Mu(e[r],t-1);return n}var O1=Object.freeze({insertMode:!1}),B1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),v_=class extends yt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Be),this.onData=this._onData.event,this._onUserInput=this._register(new Be),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Be),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Be),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Mu(O1),this.decPrivateModes=Mu(B1)}reset(){this.modes=Mu(O1),this.decPrivateModes=Mu(B1)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};v_=yi([Ue(0,Mn),Ue(1,kk),Ue(2,An)],v_);var j1={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 Pg(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var zg=String.fromCharCode,I1={DEFAULT:e=>{let t=[Pg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${zg(t[0])}${zg(t[1])}${zg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Pg(e,!0)};${e.x};${e.y}${t}`}},__=class extends yt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Be),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(j1))this.addProtocol(r,j1[r]);for(let r of Object.keys(I1))this.addEncoding(r,I1[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw 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,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};__=yi([Ue(0,Mn),Ue(1,rl),Ue(2,An)],__);var Hg=[[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]],G3=[[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]],Ki;function Z3(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var Q3=class{constructor(){if(this.version="6",!Ki){Ki=new Uint8Array(65536),Ki.fill(1),Ki[0]=0,Ki.fill(0,1,32),Ki.fill(0,127,160),Ki.fill(2,4352,4448),Ki[9001]=2,Ki[9002]=2,Ki.fill(2,11904,42192),Ki[12351]=1,Ki.fill(2,44032,55204),Ki.fill(2,63744,64256),Ki.fill(2,65040,65050),Ki.fill(2,65072,65136),Ki.fill(2,65280,65377),Ki.fill(2,65504,65511);for(let e=0;e<Hg.length;++e)Ki.fill(0,Hg[e][0],Hg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ki[e]:Z3(e,G3)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=Vo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return Vo.createPropertyValue(0,n,r)}},Vo=class af{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Be,this.onChange=this._onChange.event;let t=new Q3;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let c=0;c<o;++c){let u=t.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=o)return n+this.wcwidth(u);let m=t.charCodeAt(c);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let f=this.charProperties(u,r),g=af.extractWidth(f);af.extractShouldJoin(f)&&(g-=af.extractWidth(r)),n+=g,r=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},J3=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function P1(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var bu=2147483647,eO=256,aT=class b_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>eO)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new b_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)n.addSubParam(o[c]);else n.addParam(o)}return n}clone(){let t=new b_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>bu?bu:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>bu?bu:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,bu):t}},yu=[],tO=class{constructor(){this._state=0,this._active=yu,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,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=yu}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=yu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||yu,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",op(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=yu,this._id=-1,this._state=0}}},Jn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=op(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Su=[],iO=class{constructor(){this._handlers=Object.create(null),this._active=Su,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Su}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,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=Su,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Su,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",op(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Su,this._ident=0}},Au=new aT;Au.addParam(0);var z1=class{constructor(e){this._handler=e,this._data="",this._params=Au,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Au,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=op(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Au,this._data="",this._hitLimit=!1,n));return this._params=Au,this._data="",this._hitLimit=!1,t}},nO=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},ys=160,sO=(function(){let e=new nO(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),n=(f,g)=>t.slice(f,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in c)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ys,0,2,0),e.add(ys,8,5,8),e.add(ys,6,0,6),e.add(ys,11,0,11),e.add(ys,13,13,13),e})(),rO=class extends yt{constructor(e=sO){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 aT,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ai(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new tO),this._dcsParser=this._register(new iO),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>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 o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(u=f[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=f[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=c;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:ys)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<ys){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ys){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ys){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ys){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],m=g?g.length-1:-1;for(;m>=0&&(u=g[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,g,m,o,f),u;m<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++f<t&&(r=e[f])>47&&r<60);f--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let _=this._escHandlers[this._collect<<8|r],b=_?_.length-1:-1;for(;b>=0&&(u=_[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,_,b,o,f),u;b<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let w=f+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<ys){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,f),u;r===27&&(o|=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 w=f+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<ys){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,f),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},aO=/^([\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})$/,oO=/^[\da-f]+$/;function H1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=aO.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),oO.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return r}}function Ug(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function lO(e,t=16){let[n,r,o]=e;return`rgb:${Ug(n,t)}/${Ug(r,t)}/${Ug(o,t)}`}var cO={"(":0,")":1,"*":2,"+":3,"-":1,".":2},$a=131072,U1=10;function F1(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var $1=5e3,K1=0,uO=class extends yt{constructor(e,t,n,r,o,c,u,f,g=new rO){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=u,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new RA,this._utf8Decoder=new NA,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Bi.clone(),this._eraseAttrDataInternal=Bi.clone(),this._onRequestBell=this._register(new Be),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Be),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Be),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Be),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Be),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Be),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Be),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Be),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Be),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Be),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Be),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Be),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 y_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:_.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,_,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:_,data:b})}),this._parser.setDcsHandlerFallback((m,_,b)=>{_==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:_,payload:b})}),this._parser.setPrintHandler((m,_,b)=>this.print(m,_,b)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(Ce.BEL,()=>this.bell()),this._parser.setExecuteHandler(Ce.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ce.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Ce.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Ce.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Ce.BS,()=>this.backspace()),this._parser.setExecuteHandler(Ce.HT,()=>this.tab()),this._parser.setExecuteHandler(Ce.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Ce.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(sf.IND,()=>this.index()),this._parser.setExecuteHandler(sf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(sf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Jn(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new Jn(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new Jn(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new Jn(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new Jn(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new Jn(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new Jn(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new Jn(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new Jn(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new Jn(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new Jn(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new Jn(m=>this.restoreCursorColor(m))),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 m in qi)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new z1((m,_)=>this.requestStatusString(m,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),$1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${$1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>$a&&(c=this._parseStack.position+$a)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<$a&&(this._parseBuffer=new Uint32Array(Math.min(e.length,$a))),u||this._dirtyRowTracker.clearRange(),e.length>$a)for(let m=c;m<e.length;m+=$a){let _=m+$a<e.length?m+$a:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(m,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,_),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(r,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(f,this._bufferService.rows-1)})}print(e,t,n){let r,o,c=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,_=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let w=this._parser.precedingJoinState;for(let x=t;x<n;++x){if(r=e[x],r<127&&c){let A=c[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let C=this._unicodeService.charProperties(r,w);o=Vo.extractWidth(C);let N=Vo.extractShouldJoin(C),L=N?Vo.extractWidth(w):0;if(w=C,u&&this._onA11yChar.fire(Xa(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-L>f){if(g){let A=b,W=this._activeBuffer.x-L;for(this._activeBuffer.x=L,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),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&b instanceof Nu&&b.copyCellsFrom(A,W,0,L,!1);W<f;)A.setCellFromCodepoint(W++,0,1,_)}else if(this._activeBuffer.x=f-1,o===2)continue}if(N&&this._activeBuffer.x){let A=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-A,r,o);for(let W=o-L;--W>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(m&&(b.insertCells(this._activeBuffer.x,o-L,this._activeBuffer.getNullCell(_)),b.getWidth(f-1)===2&&b.setCellFromCodepoint(f-1,0,1,_)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,_),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>F1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new z1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Jn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Bi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=Vo.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*n),f=0;for(let m=0;m<c.length;){let _=c.codePointAt(m)||0;u[f++]=_,m+=_>65535?2:1}let g=f;for(let m=1;m<n;++m)u.copyWithin(g,0,f),g+=f;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Ce.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Ce.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Ce.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Ce.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Ce.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,qo),this._charsetService.setgCharset(1,qo),this._charsetService.setgCharset(2,qo),this._charsetService.setgCharset(3,qo);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 t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,u=this._coreService,{buffers:f,cols:g}=this._bufferService,{active:m,alt:_}=f,b=this._optionsService.rawOptions,w=(N,L)=>(u.triggerDataEvent(`${Ce.ESC}[${t?"":"?"}${N};${L}$y`),!0),x=N=>N?1:2,C=e.params[0];return t?C===2?w(C,4):C===4?w(C,x(u.modes.insertMode)):C===12?w(C,3):C===20?w(C,x(b.convertEol)):w(C,0):C===1?w(C,x(r.applicationCursorKeys)):C===3?w(C,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):C===6?w(C,x(r.origin)):C===7?w(C,x(r.wraparound)):C===8?w(C,3):C===9?w(C,x(o==="X10")):C===12?w(C,x(b.cursorBlink)):C===25?w(C,x(!u.isCursorHidden)):C===45?w(C,x(r.reverseWraparound)):C===66?w(C,x(r.applicationKeypad)):C===67?w(C,4):C===1e3?w(C,x(o==="VT200")):C===1002?w(C,x(o==="DRAG")):C===1003?w(C,x(o==="ANY")):C===1004?w(C,x(r.sendFocus)):C===1005?w(C,4):C===1006?w(C,x(c==="SGR")):C===1015?w(C,4):C===1016?w(C,x(c==="SGR_PIXELS")):C===1048?w(C,1):C===47||C===1047||C===1049?w(C,x(m===_)):C===2004?w(C,x(r.bracketedPasteMode)):C===2026?w(C,x(r.synchronizedOutput)):w(C,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=vd.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let u=e.getSubParams(t+c),f=0;do r[1]===5&&(o=1),r[c+f+1+o]=u[f];while(++f<u.length&&f+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Bi.fg,e.bg=Bi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Bi.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Bi.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Bi.fg&16777215,r.bg&=-67108864,r.bg|=Bi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Ce.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ce.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Ce.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Bi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!F1(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Ce.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>U1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>U1&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());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 t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(W1(c))if(o==="?")t.push({type:0,index:c});else{let u=H1(o);u&&t.push({type:1,index:c,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=H1(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);W1(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,qo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(cO[e[0]],qi[e[1]]||qo),!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=Bi.clone(),this._eraseAttrDataInternal=Bi.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 ws;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${Ce.ESC}${u}${Ce.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},y_=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(K1=e,e=t,t=K1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};y_=yi([Ue(0,Mn)],y_);function W1(e){return 0<=e&&e<256}var dO=5e7,q1=12,hO=50,fO=class extends yt{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 Be),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>dO)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(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let u=f=>performance.now()-n>=q1?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(n,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=q1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>hO&&(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()}},S_=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(g,f)),this._dataByLinkId.set(g.id,g),g.id}let n=e,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};S_=yi([Ue(0,Mn)],S_);var V1=!1,pO=class extends yt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new uc),this._onBinary=this._register(new Be),this.onBinary=this._onBinary.event,this._onData=this._register(new Be),this.onData=this._onData.event,this._onLineFeed=this._register(new Be),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Be),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Be),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Be),this._instantiationService=new P3,this.optionsService=this._register(new Y3(e)),this._instantiationService.setService(An,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(g_)),this._instantiationService.setService(Mn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(m_)),this._instantiationService.setService(kk,this._logService),this.coreService=this._register(this._instantiationService.createInstance(v_)),this._instantiationService.setService(rl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(__)),this._instantiationService.setService(Ck,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Vo)),this._instantiationService.setService(OA,this.unicodeService),this._charsetService=this._instantiationService.createInstance(J3),this._instantiationService.setService(LA,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(S_),this._instantiationService.setService(Tk,this._oscLinkService),this._inputHandler=this._register(new uO(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(pn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(pn.forward(this._bufferService.onResize,this._onResize)),this._register(pn.forward(this.coreService.onData,this._onData)),this._register(pn.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 fO((t,n)=>this._inputHandler.parse(t,n))),this._register(pn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Be),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!V1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),V1=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,sT),t=Math.max(t,rT),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(P1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(P1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ai(()=>{for(let t of e)t.dispose()})}}},mO={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 gO(e,t,n,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=Ce.ESC+"OA":o.key=Ce.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=Ce.ESC+"OD":o.key=Ce.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=Ce.ESC+"OC":o.key=Ce.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=Ce.ESC+"OB":o.key=Ce.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":Ce.DEL,e.altKey&&(o.key=Ce.ESC+o.key);break;case 9:if(e.shiftKey){o.key=Ce.ESC+"[Z";break}o.key=Ce.HT,o.cancel=!0;break;case 13:o.key=e.altKey?Ce.ESC+Ce.CR:Ce.CR,o.cancel=!0;break;case 27:o.key=Ce.ESC,e.altKey&&(o.key=Ce.ESC+Ce.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=Ce.ESC+"[1;"+(c+1)+"D":t?o.key=Ce.ESC+"OD":o.key=Ce.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=Ce.ESC+"[1;"+(c+1)+"C":t?o.key=Ce.ESC+"OC":o.key=Ce.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=Ce.ESC+"[1;"+(c+1)+"A":t?o.key=Ce.ESC+"OA":o.key=Ce.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=Ce.ESC+"[1;"+(c+1)+"B":t?o.key=Ce.ESC+"OB":o.key=Ce.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=Ce.ESC+"[2~");break;case 46:c?o.key=Ce.ESC+"[3;"+(c+1)+"~":o.key=Ce.ESC+"[3~";break;case 36:c?o.key=Ce.ESC+"[1;"+(c+1)+"H":t?o.key=Ce.ESC+"OH":o.key=Ce.ESC+"[H";break;case 35:c?o.key=Ce.ESC+"[1;"+(c+1)+"F":t?o.key=Ce.ESC+"OF":o.key=Ce.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=Ce.ESC+"[5;"+(c+1)+"~":o.key=Ce.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=Ce.ESC+"[6;"+(c+1)+"~":o.key=Ce.ESC+"[6~";break;case 112:c?o.key=Ce.ESC+"[1;"+(c+1)+"P":o.key=Ce.ESC+"OP";break;case 113:c?o.key=Ce.ESC+"[1;"+(c+1)+"Q":o.key=Ce.ESC+"OQ";break;case 114:c?o.key=Ce.ESC+"[1;"+(c+1)+"R":o.key=Ce.ESC+"OR";break;case 115:c?o.key=Ce.ESC+"[1;"+(c+1)+"S":o.key=Ce.ESC+"OS";break;case 116:c?o.key=Ce.ESC+"[15;"+(c+1)+"~":o.key=Ce.ESC+"[15~";break;case 117:c?o.key=Ce.ESC+"[17;"+(c+1)+"~":o.key=Ce.ESC+"[17~";break;case 118:c?o.key=Ce.ESC+"[18;"+(c+1)+"~":o.key=Ce.ESC+"[18~";break;case 119:c?o.key=Ce.ESC+"[19;"+(c+1)+"~":o.key=Ce.ESC+"[19~";break;case 120:c?o.key=Ce.ESC+"[20;"+(c+1)+"~":o.key=Ce.ESC+"[20~";break;case 121:c?o.key=Ce.ESC+"[21;"+(c+1)+"~":o.key=Ce.ESC+"[21~";break;case 122:c?o.key=Ce.ESC+"[23;"+(c+1)+"~":o.key=Ce.ESC+"[23~";break;case 123:c?o.key=Ce.ESC+"[24;"+(c+1)+"~":o.key=Ce.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=Ce.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=Ce.DEL:e.keyCode===219?o.key=Ce.ESC:e.keyCode===220?o.key=Ce.FS:e.keyCode===221&&(o.key=Ce.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=mO[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=Ce.ESC+u;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(f);e.shiftKey&&(g=g.toUpperCase()),o.key=Ce.ESC+g}else if(e.keyCode===32)o.key=Ce.ESC+(e.ctrlKey?Ce.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=Ce.ESC+f,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=Ce.US),e.key==="@"&&(o.key=Ce.NUL));break}return o}var Ri=0,vO=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Mf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Mf,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((o,c)=>this._getKey(o)-this._getKey(c)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Ri=this._search(t),Ri===-1)||this._getKey(this._array[Ri])!==t)return!1;do if(this._array[Ri]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ri),!0;while(++Ri<this._array.length&&this._getKey(this._array[Ri])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ri=this._search(e),!(Ri<0||Ri>=this._array.length)&&this._getKey(this._array[Ri])===e))do yield this._array[Ri];while(++Ri<this._array.length&&this._getKey(this._array[Ri])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ri=this._search(e),!(Ri<0||Ri>=this._array.length)&&this._getKey(this._array[Ri])===e))do t(this._array[Ri]);while(++Ri<this._array.length&&this._getKey(this._array[Ri])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Fg=0,Y1=0,_O=class extends yt{constructor(){super(),this._decorations=new vO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Be),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Be),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ai(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new bO(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{Fg=o.options.x??0,Y1=Fg+(o.options.width??1),e>=Fg&&e<Y1&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},bO=class extends Ja{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Be),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Be),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=di.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=di.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},yO=1e3,SO=class{constructor(e,t=yO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t: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,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},X1=20,Af=class extends yt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,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=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new SO(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(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
28
+ `))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(nt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ai(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<X1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
29
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===X1+1&&(this._liveRegion.textContent+=Uv.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,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),u=[],f=c?.translateToString(!0,void 0,void 0,u)||"",g=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(f.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=f,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",g),m.setAttribute("aria-setsize",r),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let u,f;if(t===0?(u=n,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(u=this._rowElements.shift(),f=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:f,offset:g})=>{let m=f instanceof Text?f.parentNode:f,_=parseInt(m?.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(m);if(!b)return console.warn("columns is null. Race condition?"),null;let w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++_,w=0),{row:_,column:w}},c=o(t),u=o(n);if(!(!c||!u)){if(c.row>u.row||c.row===u.row&&c.column>=u.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(u.row-c.row)*this._terminal.cols-c.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Af=yi([Ue(1,Ib),Ue(2,sa),Ue(3,ra)],Af);var w_=class extends yt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Be),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Be),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ai(()=>{tl(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(nt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(nt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(nt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(nt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){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,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(f=>({link:f}));this._activeProviderReplies?.set(r,u),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let u=o[c],f=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let m=f;m<=g;m++){if(n.has(m)){o.splice(c--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(u=>this._linkAtPosition(u.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=this._activeProviderReplies.get(c)?.find(f=>this._linkAtPosition(f.link,t));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&wO(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,tl(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!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:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};w_=yi([Ue(1,Pb),Ue(2,ra),Ue(3,Mn),Ue(4,Dk)],w_);function wO(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var xO=class extends pO{constructor(e={}){super(e),this._linkifier=this._register(new uc),this.browser=Vk,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new uc),this._onCursorMove=this._register(new Be),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Be),this.onKey=this._onKey.event,this._onRender=this._register(new Be),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Be),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Be),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Be),this.onBell=this._onBell.event,this._onFocus=this._register(new Be),this._onBlur=this._register(new Be),this._onA11yCharEmitter=this._register(new Be),this._onA11yTabEmitter=this._register(new Be),this._onWillOpen=this._register(new Be),this._setup(),this._decorationService=this._instantiationService.createInstance(_O),this._instantiationService.setService(_d,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(h3),this._instantiationService.setService(Dk,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance($v)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(pn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(pn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(pn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(pn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ai(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=ii.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${Ce.ESC}]${r};${lO(o)}${Wk.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=ji.toColor(...t.color));else{let c=n;this._themeService.modifyColors(u=>u[c]=ji.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.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(Af,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ce.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Ce.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,f=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(nt(this.element,"copy",t=>{this.hasSelection()&&EA(t,this._selectionService)}));let e=t=>DA(t,this.textarea,this.coreService,this.optionsService);this._register(nt(this.textarea,"paste",e)),this._register(nt(this.element,"paste",e)),Yk?this._register(nt(this.element,"mousedown",t=>{t.button===2&&r1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(nt(this.element,"contextmenu",t=>{r1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),qb&&this._register(nt(this.element,"auxclick",t=>{t.button===1&&bk(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(nt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(nt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(nt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(nt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(nt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(nt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(nt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){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"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(nt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Hv.get()),Zk||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(u3,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(sa,this._coreBrowserService),this._register(nt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(nt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u_,this._document,this._helperContainer),this._instantiationService.setService(lp,this._charSizeService),this._themeService=this._instantiationService.createInstance(p_),this._instantiationService.setService(_c,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Rf),this._instantiationService.setService(Ek,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(h_,this.rows,this.screenElement)),this._instantiationService.setService(ra,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(o_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(d_),this._instantiationService.setService(Pb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(w_,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(r_,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(f_,this.element,this.screenElement,r)),this._instantiationService.setService(jA,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(pn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(a_,this.screenElement)),this._register(nt(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(Af,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Df,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Df,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(c_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let f,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(f=3,c.button!==void 0&&(f=c.button<3?c.button:3)):f=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,f=c.button<3?c.button:3;break;case"mousedown":g=1,f=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let m=c.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=m<0?0:1,f=4;break;default:return!1}return g===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:f,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),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()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(nt(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(nt(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let u=Ce.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){_k(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 t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}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,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=gO(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Ce.ETX||n.key===Ce.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(CO(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Bi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(Ce.ESC+"[I"):this.coreService.triggerDataEvent(Ce.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Ce.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Ce.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function CO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var kO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},TO=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new ws)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},G1=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new TO(t)}getNullCell(){return new ws}},EO=class extends yt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Be),this.onBufferChange=this._onBufferChange.event,this._normal=new G1(this._core.buffers.normal,"normal"),this._alternate=new G1(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)}},DO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},RO=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}},NO=["cols","rows"],cr=0,MO=class extends yt{constructor(e){super(),this._core=this._register(new xO(e)),this._addonManager=this._register(new kO),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(NO.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 DO(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new RO(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 EO(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
30
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Hv.get()},set promptLabel(e){Hv.set(e)},get tooMuchOutput(){return Uv.get()},set tooMuchOutput(e){Uv.set(e)}}}_verifyIntegers(...e){for(cr of e)if(cr===1/0||isNaN(cr)||cr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(cr of e)if(cr&&(cr===1/0||isNaN(cr)||cr%1!==0||cr<0))throw new Error("This API only accepts positive integers")}};const AO=Ot.lazy(()=>jb(()=>import("./TranscriptMarkdownBody-Cu7KK3bx.js"),__vite__mapDeps([2,1])));function oT({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=u.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const m=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?m[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let f=-1;return d.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,m)=>{const _=g.kind==="user"?++f:null,b=n===m?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return d.jsxs("section",{ref:w=>{w?u.current.set(m,w):u.current.delete(m)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":m,..._!==null?{"data-transcript-prompt-position":_}:{},children:[g.header?d.jsx("div",{className:"transcript-entry-header",children:lT(g.header,t)}):null,g.body?d.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?d.jsx(Z1,{text:g.body,searchQuery:t}):d.jsx(Ot.Suspense,{fallback:d.jsx(Z1,{text:g.body,searchQuery:t}),children:d.jsx(AO,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${m}`)})})}function Z1({text:e,searchQuery:t}){const n=e.endsWith(`
31
+ `)?e.slice(0,-1).split(`
32
+ `):e.split(`
33
+ `);return d.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>d.jsx("span",{className:`transcript-line transcript-line-${IO(r,o===0||n[o-1]?.trim()==="")}`,children:lT(r,t)},o))})}function lT(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let u=0,f=r.indexOf(o);for(;f!==-1;){f>u&&c.push(e.slice(u,f));const g=f+n.length;c.push(d.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),u=g,f=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function LO(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(n);for(;c!==-1;)o+=1,c=r.indexOf(n,c+n.length);return o}function cT(e){const t=e.endsWith(`
34
+ `)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function u(){const f=OO(c).join(`
35
+ `);(r||f)&&n.push({header:r,body:f,kind:o}),r=null,o="plain",c=[]}for(const f of t.split(`
36
+ `)){const g=BO(f);g?(u(),r=f,o=g):c.push(f)}return u(),n}function OO(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function BO(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function jO(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
37
+ ${o.body}`:o.body,u=LO(c,t);for(let f=0;f<u;f+=1)n.push({entryIndex:r,matchIndexInEntry:f})}return n}function IO(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||hT(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function nl(e){return e==="codex"?"Codex":"Claude"}function x_(e,t,n={}){const r=`[nterminal] ${nl(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
38
+ `).replace(/\r/g,`
39
+ `).replace(r,"").replace(/\n{3,}/g,`
40
+
41
+ `).trimEnd(),c=uT(o),u=n.includeTools?c:dT(c);return u?`${u}
42
+ `:""}function uT(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=PO(n);return r?`[${r}]`:t})}function PO(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=wu(t.getMonth()+1),o=wu(t.getDate()),c=wu(t.getHours()),u=wu(t.getMinutes()),f=wu(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${f}`}function wu(e){return e.toString().padStart(2,"0")}function Lf(e,t){return e.map(n=>t?n:dT(n)).filter(Boolean).map(n=>n.endsWith(`
43
+ `)?n:`${n}
44
+ `).join("")}function dT(e){if(!e)return"";const t=e.split(`
45
+ `),n=[];let r=!1,o=!1,c=!0;for(const u of t){const f=u.trim()==="",g=c?zO(u):null;if(g&&(r=g==="tool",o=!1),hT(u)){o=!0,c=!1;continue}if(o){f?(o=!1,r||n.push(u),c=!0):c=!1;continue}r||n.push(u),c=f}return n.join(`
46
+ `).replace(/\n{3,}/g,`
47
+
48
+ `).trimEnd()}function zO(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function hT(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Vb(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Uh(e,t){return e===null?t===null:t!==null&&Vb(e,t)}const HO=5e3,UO=200,FO=1200,$O=4,KO=Ot.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const u=v.useRef(null),f=v.useRef(0),g=v.useRef(!1),m=v.useRef(!1),_=v.useRef(null),b=v.useRef(!1),[w,x]=v.useState(null),[C,N]=v.useState(null),[L,A]=v.useState(null),[W,U]=v.useState(()=>new Set),[F,K]=v.useState(!1),[oe,P]=v.useState(!1),[te,Z]=v.useState([]),[me,ee]=v.useState(null),[Y,X]=v.useState(!1),[V,ne]=v.useState(!1),[O,R]=v.useState(!1),[I,de]=v.useState(null),ge=w?.find(E=>E.id===L)??null;v.useEffect(()=>{function E(z){z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),c())}return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[c]);const M=v.useCallback(async()=>{try{const E=await n.getTerminalSubagents(t);if(N(null),x(z=>z&&XO(z,E.subagents)?z:E.subagents),!b.current){const z=E.subagents.find(we=>we.hasTranscript);z&&(b.current=!0,A(we=>we??z.id))}}catch(E){N(E instanceof Error?E.message:"Failed to load subagents."),x(z=>z??[])}},[n,t]);v.useEffect(()=>{M();const E=window.setInterval(()=>{document.hidden||M()},HO);function z(){document.hidden||M()}return document.addEventListener("visibilitychange",z),()=>{window.clearInterval(E),document.removeEventListener("visibilitychange",z)}},[M]),v.useEffect(()=>{f.current+=1;const E=f.current;return g.current=!1,m.current=!0,_.current=null,Z([]),ee(null),X(!1),de(null),L&&q(null,"initial",E),()=>{f.current===E&&(f.current+=1)}},[n,t,L,oe]),v.useLayoutEffect(()=>{const E=u.current;if(!E)return;if(m.current){if(V||te.length===0)return;m.current=!1;const we=()=>{E.scrollTop=E.scrollHeight};we(),window.requestAnimationFrame?.(we);return}const z=_.current;z!==null&&(_.current=null,E.scrollTop+=E.scrollHeight-z)},[te,V,oe]);async function q(E,z,we=f.current){const Ae=L;if(!(!Ae||g.current)){g.current=!0,z==="initial"?ne(!0):(R(!0),_.current=u.current?.scrollHeight??null),de(null);try{let ie=E,pe=0,Te=0,De=[];for(;f.current===we;){const Ee=await n.getTerminalSubagentTranscriptHistory(t,Ae,{...ie?{cursor:ie}:{},limit:UO,maxLines:FO,includeTools:oe});if(f.current!==we)return;if(!Ee.source){if(Te<1){Te+=1,await new Promise(Ve=>setTimeout(Ve,600));continue}de("Subagent transcript is unavailable.");return}const je=x_(Ee.output,Ee.source.provider,{includeTools:oe});if(ee(Ee.cursor),X(!!(Ee.hasMore&&Ee.cursor)),je&&(De=[je,...De],Lf(De,oe))){Z(Ve=>z==="older"?[...De,...Ve]:De);return}if(!Ee.hasMore||!Ee.cursor||pe>=$O){De.length>0&&Z(Ve=>z==="older"?[...De,...Ve]:De);return}ie=Ee.cursor,pe+=1}}catch(ie){if(f.current!==we)return;de(ie instanceof Error?ie.message:"Failed to load subagent transcript.")}finally{f.current===we&&(g.current=!1,ne(!1),R(!1))}}}function he(){const E=u.current;E&&(E.scrollTop>72||!Y||!me||g.current||q(me,"older"))}function J(E){U(z=>{const we=new Set(z);return we.delete(E)||we.add(E),we})}function ye(E){b.current=!0,K(!0),E.id!==L&&A(E.id),ve(E.id)}function ve(E){const z=VO(w??[],E);z.length!==0&&U(we=>{if(z.every(ie=>we.has(ie)))return we;const Ae=new Set(we);for(const ie of z)Ae.add(ie);return Ae})}function Le(){f.current+=1;const E=f.current;g.current=!1,m.current=!0,_.current=null,Z([]),ee(null),X(!1),de(null),q(null,"initial",E)}const Ne=v.useMemo(()=>Lf(te,oe),[te,oe]),Fe=v.useMemo(()=>cT(Ne),[Ne]),He=w===null;v.useEffect(()=>{if(V||O||!Y||!me||g.current)return;const E=u.current;!E||te.length===0||E.scrollHeight<=E.clientHeight+4&&q(me,"older")},[te,Y,me,V,O]);const Pe=w?.filter(E=>E.state==="working").length??0,Ze=v.useMemo(()=>mT(WO(w??[]),W),[w,W]);return d.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>{E.stopPropagation(),c()},children:d.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":F?"transcript":"list",onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?d.jsx("span",{className:"subagents-count",children:Pe>0?`${Pe} working · ${w.length} total`:`${w.length} total`}):null]}),d.jsxs("span",{title:r.sessionId,children:[nl(r.provider)," session ",r.sessionId]})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),d.jsxs("div",{className:"subagents-body",children:[d.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[He?d.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!He&&C?d.jsx("div",{className:"subagents-list-status subagents-list-error",children:C}):null,!He&&!C&&w!==null&&w.length===0?d.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Ze.map(E=>{const z=E.subagent,we=W.has(z.id);return d.jsxs("div",{className:"subagent-row-wrap",style:E.level>0?{paddingLeft:`${Math.min(E.level,4)*14}px`}:void 0,children:[E.nestedCount>0?d.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":we,"aria-label":`${we?"Collapse":"Expand"} ${E.nestedCount} nested subagents of ${z.name}`,title:E.nestedWorkingCount>0?`${E.nestedCount} nested · ${E.nestedWorkingCount} working`:`${E.nestedCount} nested`,onClick:()=>J(z.id),children:[d.jsx("span",{"aria-hidden":"true",children:we?"▾":"▸"}),d.jsx("span",{className:"subagent-expander-count","data-working":E.nestedWorkingCount>0?"true":"false",children:E.nestedCount})]}):d.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),d.jsxs("button",{type:"button",className:"subagent-row","data-selected":z.id===L?"true":"false","data-state":z.state,disabled:!z.hasTranscript,title:z.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>ye(z),children:[d.jsx("span",{className:"subagent-row-dot","data-state":z.state,"aria-hidden":"true"}),d.jsxs("span",{className:"subagent-row-main",children:[d.jsxs("span",{className:"subagent-row-title",children:[d.jsx("strong",{children:z.name}),d.jsx("span",{className:"subagent-row-badge","data-kind":z.kind,children:z.kind==="cross"?nl(z.provider):z.provider})]}),z.description?d.jsx("span",{className:"subagent-row-description",children:z.description}):null,d.jsxs("span",{className:"subagent-row-meta",children:[GO(z.state),z.model?` · ${z.model}`:"",z.updatedAt?` · ${ZO(z.updatedAt)}`:"",E.nestedCount>0&&!we?` · ${E.nestedCount} nested${E.nestedWorkingCount>0?` (${E.nestedWorkingCount} working)`:""}`:""]})]})]})]},z.id)})]}),d.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[d.jsxs("div",{className:"subagents-transcript-controls",children:[d.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>K(!1),children:"‹ List"}),d.jsx("span",{className:"subagents-transcript-name",children:ge?ge.name:"Select a subagent"}),d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:oe,onChange:E=>P(E.currentTarget.checked)}),"Show tool output"]}),d.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!ge,onClick:Le,children:"↻"})]}),ge?d.jsx("div",{className:"subagents-transcript-hint",children:YO(ge)}):null,d.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:he,children:[O?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!V&&Y?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Ne?d.jsx(oT,{entries:Fe,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,V?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!V&&ge&&!Ne&&!I?Y&&me?d.jsxs("div",{className:"transcript-dialog-status",children:[oe?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{q(me,"older")},disabled:O,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!ge&&!He&&!Ne?d.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,I?d.jsx("div",{className:"transcript-dialog-error",children:I}):null]})]})]})]})})});function WO(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=qO(r,t);o?o.children.push(r):n.push(r)}for(const r of n)fT(r);return pT(n),n}function qO(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const u=c.subagent.parentId;c=u?t.get(u):void 0}return r}function fT(e){let t=0,n=0;for(const r of e.children)fT(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,pT(e.children)}function pT(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function mT(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...mT(o.children,t,n+1));return r}function VO(e,t){const n=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function YO(e){return e.kind==="cross"?'"User" entries are the prompt the parent session passed to codex exec, not operator input.':e.provider==="codex"?"Codex forks the parent thread to start a teammate; the inherited history is hidden here. Coordinator instructions are stored encrypted by Codex, so they show as placeholders.":`"User" entries are the parent session's instructions and tool results, not operator input.`}function XO(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function GO(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function ZO(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}class QO{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():bT.has(t)?this.acceptConsonant(t):yT.has(t)?this.acceptVowel(t):iB(t)&&this.canReplacePendingWith(t)?(this.pending=J1(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(ST.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=tB.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=eB.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=Q1.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const r=this.pending.final,o=ex({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=Q1.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=J1(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=ex(this.pending);return this.pending=null,t}}const Of=44032,Bf=21,Jl=28,JO=19*Bf*Jl,gT=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],vT=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],_T=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],bT=Yb(gT),yT=Yb(vT),ST=Yb(_T),eB=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),wT=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],tB=new Map(wT),Q1=new Map(wT.map(([e,t])=>[t,[e[0],e[1]]]));function Yb(e){return new Map(e.map((t,n)=>[t,n]))}function iB(e){const t=e.codePointAt(0);return t!==void 0&&t>=Of&&t<Of+JO}function J1(e){const t=e.codePointAt(0)-Of,n=Math.floor(t/(Bf*Jl)),r=Math.floor(t%(Bf*Jl)/Jl),o=t%Jl,c={initial:gT[n],vowel:vT[r]};return o===0?c:{...c,final:_T[o]}}function ex(e){if(!e.vowel)return e.initial;const t=bT.get(e.initial),n=yT.get(e.vowel),r=e.final?ST.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Of+(t*Bf+n)*Jl+r)}const nB=[{key:"interrupt",label:"^C",ariaLabel:"Send Interrupt"},{key:"escape",label:"Esc",ariaLabel:"Send Escape"},{key:"tab",label:"Tab",ariaLabel:"Send Tab"},{key:"arrowLeft",label:"←",ariaLabel:"Send Arrow Left"},{key:"arrowDown",label:"↓",ariaLabel:"Send Arrow Down"},{key:"arrowUp",label:"↑",ariaLabel:"Send Arrow Up"},{key:"arrowRight",label:"→",ariaLabel:"Send Arrow Right"}];function sB({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return d.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[d.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),nB.map(u=>d.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),d.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const rB={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function aB(e){return rB[e]}function oB(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const xT="--nterminal-viewport-height",CT="--nterminal-keyboard-inset-bottom",kT="data-nterminal-keyboard-visible",dp="data-nterminal-compose-open",jf="nterminal:viewport-refresh",lB=120;function cB(e=window){const t=e.document.documentElement,n=e.visualViewport,r=mB(e);function o(){Xb(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(jf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(jf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(xT),t.style.removeProperty(CT),t.removeAttribute(kT)}}function Xb(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=C_(e),o=uB(e,r);return o!==null&&tx(t,xT,`${o}px`),tx(t,CT,`${n}px`),dB(t,kT,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function C_(e=window){const t=hB(e);return{keyboardInsetBottom:t,keyboardVisible:t>lB}}function uB(e,t){if((e.document.documentElement.hasAttribute(dp)||t)&&Zo(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Zo(n)?n:Zo(e.innerHeight)?e.innerHeight:null}function Zo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function tx(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function dB(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function hB(e){return Math.max(fB(e),pB(e))}function fB(e){const t=e.visualViewport?.height;if(!Zo(t)||!Zo(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function pB(e){if(!Zo(e.innerHeight))return 0;const n=TT(e)?.boundingRect?.height;return!Zo(n)||n>=e.innerHeight*.8?0:Math.round(n)}function TT(e){return e.navigator.virtualKeyboard}function mB(e){const t=TT(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Sd=new Map,id=new Map,gB=Object.freeze({open:!1,text:""});function vB(e){let t=id.get(e);return t||(t=new Set,id.set(e,t)),t}function ET(e){const t=id.get(e);if(t)for(const n of Array.from(t))n()}function sc(e){return Sd.get(e)??gB}function _B(e,t){const n=vB(e);return n.add(t),()=>{n.delete(t)}}function bB(e,t){const n=sc(e);n.open!==t&&(Sd.set(e,{...n,open:t}),ET(e))}function yB(e,t){const n=sc(e);n.text!==t&&(Sd.set(e,{...n,text:t}),ET(e))}function xu(e){Sd.delete(e),id.delete(e)}function ix(){Sd.clear(),id.clear()}const ao=new Map,nd=new Map,If=new Map,SB=Object.freeze([]);function sd(e){return ao.get(e)??SB}function wB(e,t){let n=nd.get(e);return n||(n=new Set,nd.set(e,n)),n.add(t),()=>n?.delete(t)}function $g(e,t){t.length!==0&&(ao.set(e,[...sd(e),...t]),hp(e))}function Kg(e){const t=If.get(e)??1;return If.set(e,t+1),`attach${t}`}function k_(e){If.delete(e)}function Cu(e,t,n){const r=sd(e);r.length!==0&&(ao.set(e,r.map(o=>t.has(o.id)?n(o):o)),hp(e))}function Fh(e,t){const n=sd(e);n.find(c=>c.id===t)?.cancel?.();const o=n.filter(c=>c.id!==t);o.length!==n.length&&(o.length===0?ao.delete(e):ao.set(e,o),hp(e))}function DT(e){const t=ao.get(e);if(t){for(const n of t)n.cancel?.();ao.delete(e),hp(e)}}function Yl(e){DT(e),k_(e),nd.delete(e)}function nx(){for(const e of Array.from(ao.keys()))Yl(e);nd.clear(),If.clear()}function hp(e){for(const t of Array.from(nd.get(e)??[]))t()}class xB extends Error{constructor(t){super(t),this.name="UploadDropError"}}function ec(e){return e?Array.from(e.types??[]).includes("Files")||Zb(e.items).some(n=>n.kind==="file")?!0:LT(e.files).length>0:!1}async function RT(e){const t=Zb(e.items).filter(n=>n.kind==="file");return t.length>0?kB(t):NT(e.files)}function CB(e){const t=Zb(e.items).filter(o=>o.kind==="file").flatMap(o=>{const c=o.getAsFile();return c?[{relativePath:Gb(c),file:c}]:[]}),n=NT(e.files);if(t.length===0)return n;if(n.length===0)return t;const r=[...t];for(const o of n)r.some(c=>RB(c.file,o.file))||r.push(o);return r}async function kB(e){const t=[];for(const n of e){const r=NB(n);if(r){await MT(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Gb(o),file:o});continue}throw new xB("Folder upload is not supported by this browser.")}return t}function NT(e){return LT(e).map(t=>({relativePath:Gb(t),file:t}))}async function MT(e,t,n){const r=AB(t,e.name);if(e.isFile){const u=await TB(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await EB(o);for(const u of c)await MT(u,r,n)}function TB(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function EB(e){const t=[];for(;;){const n=await DB(e);if(n.length===0)return t;t.push(...n)}}function DB(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Gb(e){const t=e.webkitRelativePath;return AT(typeof t=="string"&&t?t:e.name)}function RB(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified}function NB(e){const t=e.webkitGetAsEntry?.();return MB(t)?t:null}function MB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function AB(e,t){return AT(e?`${e}/${t}`:t)}function AT(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Zb(e){return e?Array.from(e):[]}function LT(e){return e?Array.from(e):[]}const LB=120,OB="\x1B[200~",BB="\x1B[201~";function Wg(e,t){const n=t.stripTrailingLineBreaks===!1?e:Qb(e),r=IB(n);return r?t.bracketedPasteMode?`${OB}${r}${BB}`:r:""}function jB(e){return e==="queue"?" ":"\r"}function Qb(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function IB(e){return e.replace(/\r\n/g,`
49
+ `).replace(/\r/g,`
50
+ `).replace(/\n/g,"\r")}const PB=420,zB=3e3,sx=650,HB=80,UB=3,FB=10,$B=50*1024*1024,KB=100*1024*1024,WB=2,qB={maxFiles:FB,maxFileBytes:$B,maxBatchBytes:KB},of=new Set;let rc=null;function VB({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const f=v.useMemo(()=>E=>_B(e,E),[e]),g=v.useMemo(()=>()=>sc(e),[e]),m=v.useSyncExternalStore(f,g,g),{open:_,text:b}=m,w=v.useMemo(()=>E=>wB(e,E),[e]),x=v.useMemo(()=>()=>sd(e),[e]),C=v.useSyncExternalStore(w,x,x),[N,L]=v.useState(qB),[A,W]=v.useState(!1),U=v.useRef(null),F=v.useRef(null),K=v.useRef(null),oe=v.useRef(null),P=v.useRef(new Map),te=v.useRef(c),Z=v.useRef(u),me=v.useRef(null),ee=v.useRef({start:0,end:0});te.current=c,Z.current=u,v.useEffect(()=>()=>{me.current?.(),me.current=null},[]),v.useEffect(()=>{if(!_||!te.current)return;let E=!0;return te.current().then(z=>{E&&L(z)}).catch(()=>{}),()=>{E=!1}},[_,e]),v.useLayoutEffect(()=>{if(!(!_||!lf()))return t5(e),()=>i5(e)},[_,e]),v.useLayoutEffect(()=>{const E=U.current?.closest(".terminal-pane");if(!E)return;function z(){E?.removeAttribute("data-compose-open"),E?.style.removeProperty("--compose-drawer-panel-height")}if(!_){z();return}const we=F.current;E.setAttribute("data-compose-open","true");function Ae(){const De=we?.getBoundingClientRect().height??0;De>0&&E?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(De)}px`)}Ae();const ie=[window.setTimeout(Ae,0),window.setTimeout(Ae,180),window.setTimeout(Ae,260)],pe=window.requestAnimationFrame?.(Ae)??null,Te=typeof ResizeObserver=="function"&&we?new ResizeObserver(Ae):null;return Te&&we&&Te.observe(we),()=>{for(const De of ie)window.clearTimeout(De);pe!==null&&window.cancelAnimationFrame?.(pe),Te?.disconnect(),z()}},[_]),v.useEffect(()=>{if(!_){me.current?.(),me.current=null;return}Xg(K.current),He()},[_]);function Y(E){bB(e,E)}function X(E){yB(e,E)}function V(){e5(U.current),Y(!1),ox()}function ne(E="send"){const z=C.filter(Ae=>Ae.status==="uploaded"&&Ae.path);if(r||C.some(Ae=>Ae.status==="uploading"||Ae.status==="failed")||!b&&z.length===0)return;const we=GB(b,C);if(we.parts.some(Ae=>Ae.kind==="image"||Ae.value.trim())&&t(we,E)){if(X(""),DT(e),k_(e),lf()){K.current?.blur(),ox();return}window.setTimeout(()=>K.current?.focus(),LB+20)}}async function O(E){if(r||E.length===0)return;const z=sd(e).filter(je=>je.status!=="failed"),we=z.reduce((je,Ve)=>je+Ve.file.size,0);let Ae=0,ie=z.length;const pe=[],Te=E.filter((je,Ve)=>{const $e=we+Ae+je.file.size,St=je.file.size>N.maxFileBytes?`File exceeds the ${ax(N.maxFileBytes)} attachment limit.`:ie>=N.maxFiles?`A compose message can include up to ${N.maxFiles} attachments.`:$e>N.maxBatchBytes?`Compose attachments cannot exceed ${ax(N.maxBatchBytes)} in total.`:null;return St?(pe.push({id:Vg(Ve),reference:Kg(e),file:je.file,relativePath:rx(je.relativePath,je.file.name),status:"failed",error:St}),!1):(ie+=1,Ae+=je.file.size,!0)});if(pe.length>0&&$g(e,pe),Te.length===0)return;const De=new Map,Ee=Te.map((je,Ve)=>{const $e=Vg(Ve),St=new AbortController;return De.set($e,St),{id:$e,reference:Kg(e),file:je.file,relativePath:rx(je.relativePath,je.file.name),status:"uploading",loaded:0,total:je.file.size,cancel:()=>St.abort()}});$g(e,Ee),Pe(Ee.map(je=>je.reference));for(const je of Ee)P.current.set(je.id,De.get(je.id));await JB(Ee,WB,async je=>{const Ve=De.get(je.id),$e=new Set([je.id]);try{const wt=(await o([{relativePath:je.relativePath,file:je.file}],{signal:Ve.signal,onProgress:Nt=>{Cu(e,$e,_t=>({..._t,loaded:Nt.loaded,total:Nt.total}))}})).results[0];if(Ve.signal.aborted){const Nt=Z.current;wt?.status==="uploaded"&&wt.attachmentId&&Nt&&Nt([wt.attachmentId]).catch(()=>{});return}Cu(e,$e,Nt=>{const{error:_t,cancel:Pt,...oi}=Nt;return wt?.status==="uploaded"&&wt.path?{...oi,status:"uploaded",...wt.attachmentId?{attachmentId:wt.attachmentId}:{},path:wt.path,loaded:wt.size??Nt.file.size,total:wt.size??Nt.file.size}:{...oi,status:"failed",error:wt?.error??"upload_failed"}})}catch(St){const wt=Ve.signal.aborted?"Upload canceled.":Yg(St);Cu(e,$e,Nt=>{const{cancel:_t,...Pt}=Nt;return{...Pt,status:"failed",error:wt}})}finally{P.current.get(je.id)===Ve&&P.current.delete(je.id)}})}function R(E){if(E.status!=="removing"){if(Ze(E.reference),E.status!=="uploaded"&&E.status!=="failed"||!E.attachmentId||!Z.current){P.current.delete(E.id),Fh(e,E.id);return}de([E])}}function I(){X(""),k_(e);const E=C.filter(z=>!!(z.path&&z.attachmentId));for(const z of C)E.includes(z)||(P.current.delete(z.id),Fh(e,z.id));E.length>0&&de(E)}function de(E){const z=E.flatMap(Ae=>Ae.attachmentId?[Ae.attachmentId]:[]);if(z.length===0||!Z.current){for(const Ae of E)Fh(e,Ae.id);return}const we=new Set(E.map(Ae=>Ae.id));Cu(e,we,Ae=>{const{error:ie,...pe}=Ae;return{...pe,status:"removing"}}),Z.current(z).then(()=>{for(const Ae of E)Fh(e,Ae.id)}).catch(Ae=>{Cu(e,we,ie=>({...ie,status:"failed",error:`Could not remove attachment: ${Yg(Ae)}`}))})}function ge(E){const z=Array.from(E.currentTarget.files??[]).map(we=>({relativePath:we.name,file:we}));E.currentTarget.value="",O(z)}function M(E){const z=CB(E.clipboardData);z.length!==0&&(E.preventDefault(),O(z))}function q(E){r||!ec(E.dataTransfer)||(E.preventDefault(),E.stopPropagation(),E.dataTransfer.dropEffect="copy",W(!0))}function he(E){r||!ec(E.dataTransfer)||(E.preventDefault(),E.stopPropagation(),W(!0))}function J(E){if(!ec(E.dataTransfer))return;const z=E.relatedTarget;z instanceof Node&&E.currentTarget.contains(z)||W(!1)}function ye(E){ec(E.dataTransfer)&&(E.preventDefault(),E.stopPropagation(),W(!1),RT(E.dataTransfer).then(O).catch(z=>{const we={id:Vg(0),reference:Kg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:Yg(z)};$g(e,[we])}))}const ve=C.some(E=>E.status==="uploading"),Le=C.some(E=>E.status==="failed"),Ne=C.filter(E=>E.status==="uploaded"&&E.path).length,Fe=!r&&!ve&&!Le&&(!!b||Ne>0);function He(){lf()&&(me.current?.(),me.current=n5())}function Pe(E){if(E.length===0)return;const z=E.map(St=>`@${St}`).join(" "),we=sc(e).text,Ae=Math.min(ee.current.start,we.length),ie=Math.min(Math.max(Ae,ee.current.end),we.length),pe=we.slice(0,Ae),Te=we.slice(ie),De=pe&&!/\s$/.test(pe)?" ":"",Ee=Te&&!/^\s/.test(Te)?" ":"",je=`${De}${z}${Ee}`,Ve=`${pe}${je}${Te}`,$e=pe.length+je.length;ee.current={start:$e,end:$e},X(Ve),window.requestAnimationFrame(()=>{const St=K.current;St&&(Xg(St),St.setSelectionRange($e,$e))})}function Ze(E){const z=sc(e).text,we=z.replace(new RegExp(`@${QB(E)}(?![A-Za-z0-9_])`,"g"),"");we!==z&&X(we.replace(/[ \t]{2,}/g," "))}return d.jsxs("div",{ref:U,className:"compose-drawer","data-open":_?"true":"false",children:[d.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":_?"true":void 0,tabIndex:_?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>Y(!0),children:[d.jsx("span",{"aria-hidden":"true",children:"▴"}),d.jsx("span",{children:"compose"}),b||C.length>0?d.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),d.jsxs("div",{ref:F,className:"compose-drawer-panel","aria-hidden":_?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:he,onDragOver:q,onDragLeave:J,onDrop:ye,children:[A?d.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,d.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:_?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:V,children:[d.jsx("span",{"aria-hidden":"true",children:"▾"}),d.jsx("span",{className:"compose-drawer-title",children:"compose"}),d.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),d.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),d.jsx("textarea",{ref:K,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:_?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:E=>{ee.current={start:E.target.selectionStart,end:E.target.selectionEnd},X(E.target.value)},onSelect:E=>{ee.current={start:E.currentTarget.selectionStart,end:E.currentTarget.selectionEnd}},onPaste:M,onFocus:He,onKeyDown:E=>{if(E.key==="Enter"&&(E.metaKey||E.ctrlKey)){if(E.preventDefault(),E.shiftKey){n&&ne("queue");return}ne("send");return}E.key==="Escape"&&(E.preventDefault(),V())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),d.jsx("input",{ref:oe,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:ge}),C.length>0?d.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:C.map(E=>d.jsx(YB,{attachment:E,onRemove:()=>R(E)},E.id))}):null,d.jsxs("div",{className:"compose-drawer-actions",children:[d.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:_?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>oe.current?.click(),disabled:r,children:"+"}),d.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:_?0:-1,onClick:()=>{I(),Xg(K.current),He()},disabled:!b&&C.length===0,children:"Clear"}),n?d.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:_?0:-1,title:Le?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>ne("queue"),disabled:!Fe,children:"Queue"}):null,d.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:_?0:-1,title:Le?"Remove failed attachments before sending.":void 0,onClick:()=>ne("send"),disabled:!Fe,children:"Send"})]})]})]})}function YB({attachment:e,onRemove:t}){const n=XB(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return d.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?d.jsx("img",{src:n,alt:""}):d.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),d.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),d.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),d.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),d.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function XB(e,t){const n=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n}function GB(e,t){const n=new Map(t.map(f=>[f.reference,f])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let c=0,u;for(;(u=o.exec(e))!==null;){const f=n.get(u[1]);f&&(qg(r,e.slice(c,u.index)),f.status==="uploaded"&&f.path&&(ZB(f)?r.push({kind:"image",path:f.path}):qg(r,f.path)),c=o.lastIndex)}return qg(r,e.slice(c)),{parts:r}}function qg(e,t){if(!t)return;const n=e.at(-1);if(n?.kind==="text"){n.value+=t;return}e.push({kind:"text",value:t})}function ZB(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function QB(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rx(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Vg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function Yg(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function ax(e){return e%(1024*1024)===0?`${e/(1024*1024)} MB`:e>=1024*1024?`${Math.round(e/(1024*1024)*10)/10} MB`:`${Math.ceil(e/1024)} KB`}async function JB(e,t,n){let r=0;const o=Array.from({length:Math.min(t,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;await n(e[c])}});await Promise.all(o)}function e5(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Xg(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function lf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function ox(){if(!lf())return;const e=tc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function t5(e){rc!==null&&(window.clearTimeout(rc),rc=null),of.add(e),document.documentElement.setAttribute(dp,"true"),tc()}function i5(e){if(of.delete(e),of.size>0||rc!==null){tc();return}rc=window.setTimeout(()=>{if(rc=null,of.size>0){tc();return}document.documentElement.removeAttribute(dp),tc()},PB),tc()}function n5(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,f=s5();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function m(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),f?.removeEventListener("geometrychange",b))}function _(w){if(!e){if(w<sx&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,HB)}}function b(){if(e)return;g();const w=Xb(),x=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),x>=zB||x>=sx&&o>=UB){m();return}_(x)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),f?.addEventListener("geometrychange",b),b(),m}function tc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Xb()}function s5(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function r5(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(l5(u))return u.preventDefault(),u.stopPropagation(),a5(e),!1;if(o5(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(c5(u)){const f=T_(e);return f?(u.preventDefault(),u.stopPropagation(),E_(f),!1):!0}return u5(u)?(u.preventDefault(),u.stopPropagation(),d5(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const f=T_(e);if(f){if(u.clipboardData){u.clipboardData.setData("text/plain",f),u.preventDefault();return}u.preventDefault(),E_(f)}},c=u=>{const f=u.clipboardData?.getData("text/plain");if(!f)return;const g=Qb(f);u.preventDefault(),u.stopImmediatePropagation(),OT(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",c,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function a5(e){const t=T_(e);t&&await E_(t)}function o5(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function l5(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey}function c5(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function u5(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="v"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}async function d5(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;OT(e,Qb(n),t)}catch{}}function OT(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function T_(e){return e.hasSelection()?e.getSelection():h5(e.element??null)}function h5(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function E_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}f5(e)}function f5(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const p5=[4,10,11,12];function m5(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>lx(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>lx(r)),e.parser.registerCsiHandler({final:"n"},r=>g5(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>v5(r)),e.parser.registerCsiHandler({final:"t"},r=>_5(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...p5.map(r=>e.parser.registerOscHandler(r,o=>b5(o)))];return{dispose(){for(const r of n)r.dispose()}}}function lx(e){return fp(e)===0}function g5(e){const t=fp(e);return t===5||t===6}function v5(e){return fp(e)===6}function _5(e){const t=fp(e);return t===14||t===16||t===18}function b5(e){return e.split(";").some(t=>t==="?")}function fp(e){const t=e[0];return typeof t=="number"?t:0}const Vs=new Map,Gg=2*1024*1024,y5=1500,cx=25e3,S5=2500,w5=2500,x5=1e3,C5=2e3,k5=3e4,T5=16*1024*1024,D_=256,BT=QR-3e4,E5=3e3,jT=1e4,D5=3e3,R_=16*1024*1024,pp=4*1024*1024,Pf=25,R5=1e3,N5=3e3,Zg=8,M5=100,IT=1e3,ux=[2e3,5e3,15e3,6e4];let A5=0,L5=0,Qg=0,Jg=null,cf=!1,N_=0,uf=0,eo=!1,dx=!1,Ku=null,hx=!1,M_=0,rd=document.visibilityState!=="hidden";const zf=new Set;let ac=null,Wu=0;const O5=new TextEncoder,B5=nj();function j5(e,t){P5(),W5(),np()&&Jr(0);let n=Vs.get(e);n||(n=U5(e),Vs.set(e,n),yc(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>ey(n));const o=(f,g)=>V5(n,f,g),c=f=>{f?(n.foregroundAttachments.add(r),Hf(),HT(n)):(n.foregroundAttachments.delete(r),A_())},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),A_()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function Xl(e){const t=Vs.get(e);t&&(ij(t),Vs.delete(e),A_())}function I5(e){const t=Vs.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),co(t),Ks(t),vr(t),uo(t),mr(t,"reconnecting"),fo(t);const n=t.socket;return t.socket=null,Ga(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),yc(t),!0}function P5(){if(hx)return;hx=!0;const e=()=>{if(document.visibilityState==="hidden"){rd=!1,M_+=1,UT(),zT(),z5();return}Jb(),Wu=Date.now(),Hf()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),Hf()}function Hf(){ac!==null||document.visibilityState==="hidden"||!PT()||typeof window.requestAnimationFrame!="function"||(ac=window.requestAnimationFrame(()=>{if(ac=null,document.visibilityState==="hidden")return;const e=Date.now(),t=Wu>0?e-Wu:0;if(Wu=e,t>=C5){for(const n of Vs.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&oo("terminal.connection.foreground_gap",n,{gapMs:t});Jb(void 0,{foregroundOnly:!0})}Hf()}))}function PT(){for(const e of Vs.values())if(e.foregroundAttachments.size>0)return!0;return!1}function A_(){PT()||(zT(),Wu=0)}function zT(){ac!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(ac),ac=null}function HT(e){if(document.visibilityState!=="hidden"){if(!rd||e?.heartbeatSuspended){Jb(e);return}e&&L_(e)}}function Jb(e,t={}){if(document.visibilityState==="hidden")return;rd=!0;const n=++M_;UT();const r=Array.from(Vs.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=r.filter(f=>f===e||f.foregroundAttachments.size>0||X5(f)),c=new Set(o),u=r.filter(f=>!c.has(f));for(const f of o)L_(f);if(!t.foregroundOnly)for(let f=0;f<u.length;f+=Zg){const g=u.slice(f,f+Zg),m=Math.floor(f/Zg)*M5,_=window.setTimeout(()=>{if(zf.delete(_),!(n!==M_||!rd||document.visibilityState==="hidden"))for(const b of g)L_(b)},m);zf.add(_)}}function UT(){for(const e of zf)window.clearTimeout(e);zf.clear()}function L_(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,yc(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<x5)return Promise.resolve("alive");mr(e,"reconnecting"),fo(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++A5).toString(36)}`;let o;const c=new Promise(f=>{o=f}),u={socket:t,nonce:r,timeout:0,promise:c,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(oo("terminal.connection.resume_timeout",e,{pendingInputs:to(e)}),mr(e,"reconnecting"),io(e))},S5);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{mr(e,"reconnecting"),io(e)}return c}function z5(){rd=!1;for(const e of Vs.values())e.heartbeatSuspended=!0,co(e),Ks(e),vr(e),uo(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,mr(e,"skipped"),fo(e)}function H5(){eo=!1,np()&&Jr(0);for(const e of Vs.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),co(e),Ks(e),vr(e),uo(e),mr(e,"reconnecting"),fo(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ga(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),yc(e)}}function ev(){for(const e of Array.from(Vs.keys()))Xl(e)}function U5(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:Pf,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function yc(e){if(!e.reconnectEnabled)return;Ga(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Ks(e),vr(e),uo(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,co(e),Ks(e),Ga(e,"connected"),lo(e,t),FT(e,t),e.isAlive=!0,fx(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let c=null;try{c=JSON.parse(o)}catch{return}if(!c||typeof c.type!="string")return;if(dj(c)){hj(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),eo&&(eo=!1,np()&&Jr(0));return}if(e.inputProtocolMode==="unknown"&&WT(e,t),c.type==="pong"){e.isAlive=!0;const f=e.resumeProbe;f?.socket===t&&f.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),to(e)>0&&oo("terminal.connection.resume_alive",e,{pendingInputs:to(e)}),mr(e,"alive"),lo(e,t),fx(e),sl(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(od(e),oo("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:to(e)}),io(e));return}if(c.type==="input_ack"){oj(e,t,c);return}if(c.type==="input_received"){lj(e,t,c);return}if(c.type==="error"&&cj(e,c),c.type==="input_ack_confirmed"){pj(e,c);return}const u=$5(e,c);if(ad(e,{type:"message",message:u}),c.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;ey(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",co(e),Ks(e),vr(e),uo(e),mr(e,"reconnecting"),fo(e),r.code===1008){e.reconnectEnabled=!1,Ga(e,F5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=k5)&&(e.lastUpgradeAuthProbeAt=o,ad(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Ga(e,"closed");return}Ga(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,yc(e)},y5)}}),t.addEventListener("error",()=>{})}function fx(e){if(fo(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>cx*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},cx)}function fo(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function F5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function $5(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+ia(r),0),px(e),e.exited&&df(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=ia(t.data),px(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,df(e)),t):(t.type==="exit"&&(e.exited=!0,df(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function px(e){for(;e.outputBytes>Gg&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=ia(t)}e.outputBytes>Gg&&e.output.length===1&&(e.output[0]=gj(e.output[0],Gg),e.outputBytes=ia(e.output[0]))}function Ga(e,t){e.status!==t&&(e.status=t,ad(e,{type:"status",status:t}))}function ad(e,t){for(const n of Array.from(e.listeners))n(t)}function to(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function K5(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function oo(e,t,n={}){Sn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:to(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??K5(t)}),N_+=1,uf=0,Jr(IT)}function W5(){if(dx)return;dx=!0;const e=()=>{document.visibilityState==="hidden"||eo||np()&&Jr(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Jr(e){if(cf){Ku=Ku===null?e:Math.min(Ku,e);return}Jg!==null||eo||document.visibilityState==="hidden"||navigator.onLine===!1||(Jg=window.setTimeout(()=>{Jg=null,q5()},e))}async function q5(){if(cf||eo||document.visibilityState==="hidden"||navigator.onLine===!1)return;cf=!0;const e=N_;try{const t=await sN();if(t.outcome==="auth_blocked"){eo=!0;return}if(t.outcome==="retryable"){const n=ux[Math.min(uf,ux.length-1)];uf+=1,Jr(n);return}if(uf=0,t.outcome==="sent"&&t.hasMore){Jr(0);return}}finally{cf=!1;const t=Ku;Ku=null,t!==null&&Jr(t),N_!==e&&!eo&&Jr(IT)}}function V5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=rj(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=ia(o);if(c>T5)return"rejected";const u=n.durability!=="live-only",f={message:r,encoded:o,bytes:c,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:u};if(!aj(e,f))return"rejected";const g=e.socket,m=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(oo("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:to(e)}),HT(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!m||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>pp))return!u&&r.type==="input"?"rejected":Y5(e,r)?(m&&g&&lo(e,g),"queued"):e.pendingOut.length>=D_||e.pendingOutBytes+c>R_?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=c,gx(e,f),m&&g&&lo(e,g),"queued");if(m){gx(e,f);try{return g.send(o),KT(e,f),"sent"}catch{if(b&&u&&e.pendingOut.length<D_&&e.pendingOutBytes+c<=R_)return e.pendingOut.push(f),e.pendingOutBytes+=c,g.close(),"queued";al(e,f),g.close()}}return"rejected"}function lo(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Ks(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>pp){mj(e,t),Z5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){FT(e,t);return}try{t.send(r.encoded),KT(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=Pf,n=!0}e.outboundFlushDelayMs=Pf,Ks(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&ad(e,{type:"outbound_flushed"})})}function Y5(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=ia(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function co(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=Pf}function Ks(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function Uf(e){return e.pendingOut.some(t=>t.message.type==="input")}function X5(e){return Uf(e)||e.unackedInputs.size>0}function G5(e){if(!Uf(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function Z5(e,t){e.outboundStallWatchdog!==null||!Uf(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!Uf(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>pp;if(!n&&!r){lo(e,t);return}G5(e),io(e)},N5))}function vr(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function FT(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&io(e)},D5))}function $T(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function od(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function uo(e){$T(e),od(e)}function sl(e){$T(e),O_(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=mx(e),r=Q5(e),o=ej(e);if(n===null&&r===null&&o===null){od(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+E5,u=Math.max(0,Math.min(c,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(O_(e,{notifyImmediately:!0})){sl(e);return}if(J5(e),mx(e)===null){sl(e);return}tj(e,t)},u)}function Q5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+jT;t=t===null?r:Math.min(t,r)}return t}function J5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<jT||(n.writeSlowReported=!0,oo("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function mx(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function ej(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+BT;t=t===null?r:Math.min(t,r)}return t}function tj(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>pp){io(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++L5).toString(36)}`;oo("terminal.input.delivery_probe_started",e,{pendingInputs:to(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(oo("terminal.input.delivery_probe_timeout",e,{pendingInputs:to(e)}),od(e),io(e))},w5);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{od(e),io(e)}}function mr(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function io(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),co(e),Ks(e),vr(e),uo(e),mr(e,"reconnecting"),fo(e);const t=e.socket;e.socket=null,Ga(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),yc(e)}function ij(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),co(e),Ks(e),vr(e),uo(e),mr(e,"skipped"),fo(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),df(e),e.listeners.clear()}function nj(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function sj(){return Qg=(Qg+1)%Number.MAX_SAFE_INTEGER,`${B5}-${Qg.toString(36)}`.slice(0,xC)}function rj(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=sj();return n.length===0||n.length>xC?null:{...t,messageId:n}}function aj(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<D_&&e.unackedInputBytes+t.bytes<=R_)}function gx(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function al(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function oj(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&B_(e,t,c);return}if(al(e,r),sl(e),!ty(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),B_(e,t,o)}function lj(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",sl(e))}function cj(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(al(e,n),sl(e))}function KT(e,t){if(t.message.type!=="input"||!t.message.messageId||!ty(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",sl(e)}function uj(e){if(O_(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){al(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function O_(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=BT&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&al(e,u)}return o>0&&(VT(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&ey(e)),!0}function dj(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function hj(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){WT(e,t);return}vr(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(uj(e),fj(e,t)):c!==null&&(qT(e),YT(e)),lo(e,t)}function WT(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",vr(e),e.serverInstanceId=null,qT(e),YT(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;al(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=ia(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}lo(e,t)}}function qT(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&al(e,o)}n>0&&VT(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function VT(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function ey(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)ad(e,{type:"message",message:{type:"error",message:n.message}})}}function df(e){co(e),Ks(e),vr(e),uo(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function B_(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!ty(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function ty(e){return e==="ack"||e==="receipt-ack"}function fj(e,t){for(const n of e.pendingAckReceipts.values())if(B_(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function pj(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function YT(e){e.pendingAckReceipts.clear()}function mj(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(R5,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,lo(e,t)},n)}function ia(e){return O5.encode(e).byteLength}function gj(e,t){if(ia(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);ia(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const vj=[0,50,150,350],_j=[100,300,750],bj=2,yj=[300,1200,2500],Sj=1e3,wj=1e5,xj="",j_="\x1B[?1049l\x1B[?1047l\x1B[?47l",Cj=new Set(["47","1047","1049"]),kj=400,Tj=9,Ej=9,Dj=32,Rj=1.42,Nj=2,Mj=24,Aj=720,Lj=60,Oj=1260,Bj=6,jj=2,vx=[500,1500,3e3,5e3,8e3],_x=15e3,Ij=2,Pj=1e3,bx="Do not take action. Wait for my next input.",Ff=6e4,zj=Ff+5*6e4,yx=Ff+6e4,Hj=40,$h=240,Uj=5e3,qu=new Map,Gl=new Map;function Sx({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:f,onSelect:g,onClose:m,onExit:_,onSnapshot:b,onAuthClose:w}){const x=v.useSyncExternalStore(ik,Mv,()=>Xo),C=v.useSyncExternalStore(nk,Av,()=>lc),N=v.useSyncExternalStore(sk,Ov,()=>!0),L=v.useSyncExternalStore(Qh,Bv,()=>!0),A=v.useSyncExternalStore(Qh,jv,()=>!0),W=v.useSyncExternalStore(ob,no,()=>oc),U=v.useSyncExternalStore(Hu,()=>Uu("history.toggle"),()=>"Alt+H"),F=v.useSyncExternalStore(Hu,()=>Uu("scrollback.toggle"),()=>"Alt+S"),K=v.useSyncExternalStore(Hu,()=>Uu("subagents.toggle"),()=>"Alt+A"),oe=v.useRef(null),P=v.useRef(null),te=v.useRef(null),Z=v.useRef(null),me=v.useRef(null),ee=v.useRef(e.id),Y=v.useRef({onExit:_,onSnapshot:b}),X=v.useRef(t.createWebSocketUrl),V=v.useRef(w),ne=v.useRef(null),O=v.useRef(null),R=v.useRef(null),I=v.useRef(!1),de=v.useRef(new Map),ge=v.useRef(new Map),M=v.useRef(new Set),q=v.useRef([]),he=v.useRef(!1),J=v.useRef(null),ye=v.useRef(0),ve=v.useRef(!1),Le=v.useRef(!1),Ne=v.useRef(!1),Fe=v.useRef({terminalId:e.id,enabled:!1}),He=v.useRef([]),Pe=v.useRef([]),Ze=v.useRef(0),E=v.useRef(!1),z=v.useRef(null),we=v.useRef(0),Ae=v.useRef(0),ie=v.useRef(null),pe=v.useRef(null),Te=v.useRef(!1),De=v.useRef(!1),Ee=v.useRef(!1),je=v.useRef(null),Ve=v.useRef(!1),$e=v.useRef(null),St=v.useRef(null),wt=v.useRef(!1),Nt=v.useRef(!1),_t=v.useRef(!1),Pt=v.useRef(!1),oi=v.useRef(!1),ke=v.useRef(!1),Ge=v.useRef(!1),st=v.useRef(n),et=v.useRef(r),gt=v.useRef(c),ct=v.useRef(x),mn=v.useRef(C),li=v.useRef(!1),le=v.useRef(!1),ze=v.useRef(null),ut=v.useRef(0),at=v.useRef(0),Bt=v.useRef(e.id),Qt=v.useRef(()=>{}),Si=v.useRef(null),Ii=v.useRef(null),ni=v.useRef(!1),hi=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),lt=v.useRef(0),xt=v.useRef(null),fi=v.useRef(0),Jt=v.useRef(null),Vi=v.useRef(0),gn=v.useRef(!1),Yi=v.useRef(!1),pi=v.useRef(null),an=v.useRef(null),[,Ni]=v.useState("connecting"),[wi,xi]=v.useState(!1),[is,wn]=v.useState(null),[xs,Cs]=v.useState(!1),[ks,on]=v.useState(null),[Xs,$n]=v.useState(!1),[Ts,xn]=v.useState(!1),[Gs,Ht]=v.useState(!1),[aa,br]=v.useState(!1),[Wt,Kn]=v.useState(null),ln=e.agentCache&&Wt&&e.agentCache.source.provider===Wt.provider&&e.agentCache.source.sessionId===Wt.sessionId?e.agentCache:null,[yr,Sr]=v.useState(()=>Date.now()),[wr,Zs]=v.useState(!1),[xr,Cn]=v.useState(null),[Pi,Qs]=v.useState(!1),[oa,Es]=v.useState(!1),[Xi,Ds]=v.useState(null),[wc,zi]=v.useState(!1),[la,Cr]=v.useState(!1),[po,kn]=v.useState(null),[mo,ca]=v.useState(null),Gi=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[cl,Rs]=v.useState(()=>kg(e.id)),vn=Wt?.provider??e.agentStatus?.provider??null,Ns=vn!==null||Zl(e.currentCommand),ul=vn==="claude"||JT(e.currentCommand),dl=vn!==null||Zl(e.currentCommand),ns=e.capabilities?.tmuxScrollback===!0,Zi=ns&&(cl??(dl?A:L)),[go,Ms]=v.useState(!1);v.useLayoutEffect(()=>{st.current=n},[n]),v.useLayoutEffect(()=>{et.current=r},[r]),v.useLayoutEffect(()=>{gt.current=c},[c]),v.useLayoutEffect(()=>{ct.current=x},[x]),v.useLayoutEffect(()=>{mn.current=C},[C]),v.useLayoutEffect(()=>{li.current=Pi},[Pi]),v.useLayoutEffect(()=>{le.current=oa},[oa]),v.useLayoutEffect(()=>{ze.current=Wt},[Wt]);const Ci=v.useCallback((k,H={})=>{!k&&H.preserveOnNull||(Uh(ze.current,k)||(at.current+=1),ze.current=k,Kn(Me=>Me&&k&&Me.provider===k.provider&&Me.sessionId===k.sessionId?Me:k))},[]),kr=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),Tr=v.useCallback(()=>{const k=ze.current,H=at.current;k&&(async()=>{let Me=k;try{Me=await kr()??Me}catch{}Me&&Bt.current===e.id&&at.current===H&&Uh(k,ze.current)&&(Ci(Me,{preserveOnNull:!0}),Si.current=nv(e.id,Me),Es(!1),Qs(!0))})()},[Ci,kr,e.id]),vo=v.useCallback(()=>{ze.current&&(Qs(!1),Es(!0))},[]),Wn=v.useCallback(async(k={})=>{const H=await xx(Gi,t,k);return Ds(H),H},[Gi,t]),ki=v.useCallback((k,H="info")=>{Jt.current!==null&&window.clearTimeout(Jt.current),ca({id:fi.current++,message:k,tone:H}),Jt.current=window.setTimeout(()=>{ca(null),Jt.current=null},3200)},[]),ua=v.useCallback(()=>{const k=f?.serverKey.trim()||"local",H=f?.serverName.trim()||"Local",Me=f?.tabName.trim()||e.title||"Terminal",Ye=Xi?.instances.find(ft=>ft.cwd===e.cwd);if(Ye&&Cx(Kh(k,Ye.id))){ki("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Ye&&tv(Kh(k,Ye.id),Ye.url)){ki("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let We=null;const it=()=>((!We||GT(We))&&(We=window.open("about:blank","_blank"),Fj(We)),We);Xi?.installed!==!0&&it(),Cr(!0),kn(null),(async()=>{let ft=Xi;if(ft?.installed||(ft=await Wn({force:!0})),!ft?.installed||ft.supported===!1){iv(We),zi(!0);return}const vt=ft.instances.find(Ut=>Ut.cwd===e.cwd);if(vt){const Ut=Kh(k,vt.id);if(kx(We,Ut,vt.url)||tv(Ut,vt.url)!==null){ki("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Xe=it();return{response:await t.openCodeServer({terminalId:e.id,serverName:H,tabName:Me}),targetPopup:Xe}})().then(ft=>{if(!ft)return;const{response:vt,targetPopup:Xe}=ft;I_(Gi,vt.status),Ds(vt.status);const Gt=Kh(k,vt.instance.id);if(Cx(Gt)){iv(Xe),ki("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}kx(Xe,Gt,vt.url)||tv(Gt,vt.url)?ki("Opening VS Code..."):ki("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ft=>{iv(We),zi(!0),kn(Wh(ft))}).finally(()=>Cr(!1))},[f?.serverName,f?.tabName,Gi,Xi,Wn,t,ki,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return xx(Gi,t).then(H=>{k||Ds(H)}).catch(()=>{}),()=>{k=!0}},[Gi,t]),v.useEffect(()=>{if(Xi?.job?.status!=="running")return;const k=window.setInterval(()=>{Wn({force:!0}).catch(H=>kn(Wh(H)))},1e3);return()=>window.clearInterval(k)},[Xi?.job?.status,Wn]),v.useEffect(()=>()=>{Jt.current!==null&&window.clearTimeout(Jt.current)},[]),v.useLayoutEffect(()=>{Qt.current=Tr},[Tr]),v.useLayoutEffect(()=>{Ii.current=ln},[ln]),v.useLayoutEffect(()=>{ni.current=wr},[wr]),v.useLayoutEffect(()=>{gn.current=Ns},[Ns]),v.useLayoutEffect(()=>{Yi.current=ul},[ul]),v.useLayoutEffect(()=>{const k=Fe.current;Le.current=Zi,Ne.current=ns,Fe.current={terminalId:e.id,enabled:Zi},Ex(oe.current,Zi),k.terminalId===e.id&&k.enabled&&!Zi&&ko(),Zi||Ht(!1)},[e.id,Zi,ns]),v.useEffect(()=>{Rs(kg(e.id)),ye.current=0,ve.current=!1,Ht(!1),Co()},[e.id]),v.useEffect(()=>Qh(()=>{Rs(kg(e.id))}),[e.id]),v.useEffect(()=>()=>{gl()},[]),v.useEffect(()=>{me.current?.(r&&e.status==="running"),r&&e.status==="running"&&Bs()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&zs("auto")},[n,r,e.status]),v.useEffect(()=>{Y.current={onExit:_,onSnapshot:b}},[_,b]),v.useLayoutEffect(()=>{X.current=t.createWebSocketUrl,V.current=w},[t,w]),v.useLayoutEffect(()=>{ee.current=e.id,Ge.current=!1,br(!1)},[e.id]),v.useEffect(()=>{let k=!1,H=null,Me=0;const Ye=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",We=Ye||u4(e.currentCommand),it=Ye||Zl(e.currentCommand);function ft(){H!==null&&(window.clearTimeout(H),H=null)}function vt(Gt){if(k)return;let Ut;if(Gt)Ut=_x;else if(Me<vx.length){if(!We)return;Ut=vx[Me++]}else{if(!it)return;Ut=_x}H=window.setTimeout(()=>{H=null,Xe()},Ut)}async function Xe(){try{const Gt=ze.current!==null,Ut=await kr();if(k)return;if(Ut){ut.current=0,Ci(Ut),vt(!0);return}ut.current+=1;const zt=!!(Gt&&We&&ut.current<Ij);Ci(null,{preserveOnNull:zt}),vt(zt)}catch(Gt){if(k)return;sv(Gt)&&Ci(null),vt(!1)}}return Bt.current!==e.id&&(Bt.current=e.id,at.current+=1,ze.current=null,ut.current=0,Kn(null)),e.status!=="running"?(at.current+=1,ze.current=null,ut.current=0,Kn(null),()=>{k=!0,ft()}):(Xe(),()=>{k=!0,ft()})},[Ci,kr,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=nv(e.id,Wt),H=Si.current;H!==null&&k!==null&&H!==k&&(pe.current=null,Te.current=!1,De.current=!1,li.current&&Qs(!1),Es(!1)),Si.current=k},[e.id,Wt?.provider,Wt?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!Wt){Zs(!1);return}const k=window.setInterval(()=>{Sr(Date.now())},Pj);return()=>{window.clearInterval(k)}},[e.status,Wt?.provider,Wt?.sessionId]),v.useEffect(()=>{const k=Wj(ln);hi.current.key!==k&&(hi.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[ln?.expiresAt,ln?.source?.provider,ln?.source?.sessionId]),v.useEffect(()=>{if(!wr||!ln||ln.status!=="ready")return;const k=ZT(ln,yr);if(k===null||k<=0)return;const H=hi.current;!H.warnedFiveMinutes&&k<=zj&&k>yx&&(H.warnedFiveMinutes=!0,os({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!H.warnedOneMinute&&k<=yx&&k>Ff&&(H.warnedOneMinute=!0,os({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!H.sent&&!H.skipped&&k<=Ff&&Mc()},[wr,yr,ln,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(H){if(!st.current||!et.current||H.isComposing||H.key==="Process"||Yj(H.target))return;const Me=lk(H);if(Me?.id==="history.toggle"&&ze.current){H.preventDefault(),H.stopPropagation(),li.current?Qs(!1):Qt.current();return}if(Me?.id==="subagents.toggle"&&ze.current){H.preventDefault(),H.stopPropagation(),le.current?Es(!1):vo();return}if(Me?.id==="scrollback.toggle"&&Ne.current){H.preventDefault(),H.stopPropagation(),Nc();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=P.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&Ni("closed")},[e.status]),v.useEffect(()=>{const k=P.current;k&&(k.options.fontSize=x,Cg(x,mn.current).then(()=>{ct.current===x&&Ui()}))},[x]),v.useEffect(()=>{const k=P.current;k&&(k.options.fontFamily=Nv(C),Cg(ct.current,C).then(()=>{mn.current===C&&Ui()}))},[C]),v.useEffect(()=>{const k=P.current;k&&(k.options.theme=wx(W))},[W]),v.useEffect(()=>{const k=oe.current;if(!k)return;let H=!1,Me=null,Ye=null,We=null,it=null,ft=null,vt=null,Xe=null;ne.current=null,oi.current=!1,ke.current=!1,Ve.current=!1,So(),wo(),On(),he.current=!1;const Gt=ct.current,Ut=mn.current,zt=new MO({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Nv(Ut),fontSize:Gt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:wj,theme:{...wx(no())}}),ir=new wA;return zt.loadAddon(ir),it=m5(zt),P.current=zt,te.current=ir,Cg(Gt,Ut).then(()=>{if(H)return;zt.open(k),Ex(k,Le.current),oi.current=!0,Me=r5(zt,{onPasteText:wp,onInterrupt:Sp,shouldInterruptPlainCtrlC:()=>Yi.current}),et.current&&st.current&&e.status==="running"&&zs("auto"),Ui(),ft=g4(k,zt,()=>ct.current*1.2,as,nr=>{Js(nr)},G,ae,()=>Le.current,va),vt=f4(k,zt,as,nr=>{Js(nr)},G,ae,()=>Le.current,va);const vl=new QO;Ye=zt.onData(nr=>{if(Ge.current){const Lc=oB(nr);if(Lc){Eo(!1),Rr(Lc);return}}const Ac=vl.accept(nr);Ac&&Rr(Ac)}),We=zt.onScroll(nr=>{if(Nt.current||Pt.current||_t.current){Ti();return}jn(),es(zt)&&Is({scrollToBottom:!0}),as(),!Le.current&&nr<=3&&Js()}),Xe=new ResizeObserver(()=>{er()}),Xe.observe(k),ke.current&&(Os(),ke.current=!1,Ui()),yo()}),()=>{wd(Z.current,{updateUi:!1}),H=!0,oi.current=!1,ke.current=!1,So(),wo(),O.current=null,R.current=null,I.current=!1,fl(),he.current=!1,pl(),_t.current=!1,E.current=!1,we.current+=1,Ae.current+=1,z.current=null,pi.current=null,an.current=null,Ee.current=!1,je.current=null,xi(!1),ft?.(),vt?.(),Xe?.disconnect(),Me?.dispose(),Ye?.dispose(),We?.dispose(),it?.dispose(),zt.dispose(),P.current=null,te.current=null}},[e.id]),v.useEffect(()=>{const k=X.current(e.id),H=j5(k,As);return Z.current=H.send,me.current=H.setForeground,H.setForeground(et.current&&e.status==="running"),Ni(H.status),H.status==="connected"&&Ui(),H.snapshot&&(Y.current.onSnapshot(H.snapshot,{notifyCompletion:!1}),P.current&&(Ui(),_n(H.output,H.history),Ui())),()=>{wd(H.send,{updateUi:!1}),H.setForeground(!1),H.detach(),Z.current=null,me.current=null}},[e.id,e.status]);function As(k){if(k.type==="status"){Ni(k.status),k.status==="unauthorized"&&V.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(Ui(),pa());return}if(k.type==="upgrade_rejected"){V.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){he.current&&(he.current=!1,_a());return}xc(k.message)}function On(k=[],H=null){He.current=[],Pe.current=qh(k),Ze.current=0,E.current=!1,z.current=null,_t.current=!1,we.current+=1,ie.current=H,pe.current=null,Te.current=!1,De.current=!1,Ee.current=!1,je.current=null,ke.current=!1,pi.current=null,an.current=null,$e.current=null,wt.current=!1,xi(!1),wn(null),Cs(!1),on(null),$n(!1),xn(!1)}function _n(k=[],H=null){if(_t.current||E.current){an.current={output:k,history:H,appendFromLiveOutputIndex:Pe.current.length};return}On(k,H),rt()}function Ls(){if(_t.current||E.current)return!1;const k=an.current;if(!k)return!1;const H=Pe.current.slice(k.appendFromLiveOutputIndex);return an.current=null,On([...k.output,...H],k.history),rt(),!0}function rt(){if(!P.current||!oi.current){ke.current=!0;return}ke.current=!1,Os()}async function Os(){const k=P.current;if(!k)return;const H=Vh(k,wt.current),Me=H?Pe.current.length:Ze.current,Ye=await ss(k,{liveOutputLimit:Me,scrollToBottom:H});P.current===k&&(Ti(),Ye&&pa())}function ss(k,H={}){return new Promise(Me=>{_t.current=!0,E.current=!1;const Ye=we.current+1;we.current=Ye;const We=Math.max(0,Math.min(H.liveOutputLimit??Pe.current.length,Pe.current.length)),it=H.historyPages??He.current,ft=()=>P.current===k&&we.current===Ye,vt=()=>ft()&&(H.isCurrent?.()??!0),Xe=()=>{ft()&&(_t.current=!1),Me(!1)},Gt=()=>{if(!vt()){Xe();return}try{Ze.current=We,H.scrollToBottom&&ce(k)}finally{if(_t.current=!1,Ls()){Me(!1);return}const zt=ml();zt?Is(zt):H.applyDeferredSnapshot!==!1&&B(),Me(!0)}},Ut=()=>{if(!vt()){Xe();return}k.clear();const zt=qh([...it,...Pe.current.slice(0,We)]);if(zt.length===0){Gt();return}for(let ir=0;ir<zt.length;ir+=1){const vl=zt[ir];ir===zt.length-1?k.write(vl,Gt):k.write(vl)}};if(k.buffer.active.type==="alternate"){k.write(j_,Ut);return}Ut()})}async function Js(k=0){const H=P.current;if(Ee.current||!H)return;if(xo(H)){Ti();return}const Me=ie.current,Ye=Ae.current,We=Symbol("history-load"),it=()=>P.current===H&&Ae.current===Ye;je.current=We,Ee.current=!0,xi(!0);const ft=H.buffer.active.viewportY;try{let vt=!!(Me&&!Me.hasMore);if(!vt)try{const Xe=await t.getTerminalHistory(e.id,{beforeLine:Me?.startLine??0,...Me?.snapshotHistorySize!==void 0?{snapshotHistorySize:Me.snapshotHistorySize}:{},...Me?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Me.snapshotHistoryLimit}:{},...Me?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Me.snapshotHistoryToken}:{},...Me?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Me.snapshotPaneWidth}:{},limit:Sj});if(!it()||ie.current!==Me)return;const Gt=()=>it()&&ie.current===Me;if(Xe.invalidated){js();return}const Ut=Xe.hasMore&&Xe.snapshotHistorySize!==void 0&&Xe.snapshotPaneWidth!==void 0,zt={startLine:Xe.startLine,endLine:Xe.endLine,hasMore:Ut,...Xe.snapshotHistorySize!==void 0?{snapshotHistorySize:Xe.snapshotHistorySize}:{},...Xe.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Xe.snapshotHistoryLimit}:{},...Xe.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Xe.snapshotHistoryToken}:{},...Xe.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Xe.snapshotPaneWidth}:{}};if(Xe.output.length>0){await rs(H,Xe.output,ft,k)&&Gt()&&(ie.current=zt);return}if(!Gt())return;ie.current=zt,vt=!Ut}catch(Xe){vt=it()&&sv(Xe)}if(vt){if(!it()||xo(H)){Ti();return}await Hi(H,ft,k,it)}}catch{}finally{je.current===We&&(je.current=null,Ee.current=!1,xi(!1))}}async function Hi(k,H,Me,Ye){if(!Ye()||Te.current||De.current)return;const We=ze.current,it=at.current,ft=pe.current,vt=()=>Ye()&&at.current===it&&Uh(We,ze.current)&&pe.current===ft;try{const Xe=await t.getTerminalTranscriptHistory(e.id,{...ft?{cursor:ft}:{},limit:kj}),Gt=Xe.output.map(uT);if(!Xe.source||Xe.terminalId!==e.id||!vt())return;if(We&&!Vb(We,Xe.source)){pe.current=null,Te.current=!1,De.current=!1,Ci(Xe.source);return}if(Gt.length===0){Ci(Xe.source),pe.current=Xe.cursor,De.current=!Xe.hasMore||!Xe.cursor;return}await rs(k,Gt,H,Me,vt)&&vt()&&(Ci(Xe.source),pe.current=Xe.cursor,De.current=!Xe.hasMore||!Xe.cursor)}catch(Xe){vt()&&sv(Xe)&&(Te.current=!0)}}async function rs(k,H,Me,Ye,We){if(xo(k)||We&&!We())return Ti(),!1;const it=He.current,ft=[...H,...it],vt=d4(H),Xe=we.current+1,Gt=await ss(k,{liveOutputLimit:Ze.current,scrollToBottom:!1,historyPages:ft,applyDeferredSnapshot:!1,...We?{isCurrent:We}:{}}),Ut=We!==void 0&&!We();return!Gt||Ut||P.current!==k?(Ut&&P.current===k&&we.current===Xe&&await ss(k,{liveOutputLimit:Ze.current,scrollToBottom:!1,historyPages:it,applyDeferredSnapshot:!1})&&P.current===k&&(Se(k,Me),wt.current=!es(k),as()),!1):(He.current=ft,Se(k,Math.max(0,Me+vt+Math.min(0,Ye))),wt.current=!es(k),as(),!0)}v.useEffect(()=>{const k=window.visualViewport;function H(){document.visibilityState!=="hidden"&&Bs()}function Me(){Bs()}function Ye(){Bs()}function We(){er()}function it(){hl()}return document.addEventListener("visibilitychange",H),window.addEventListener("pageshow",Me),window.addEventListener("online",Ye),window.addEventListener("resize",We),window.addEventListener(jf,it),k?.addEventListener("resize",We),k?.addEventListener("scroll",We),()=>{document.removeEventListener("visibilitychange",H),window.removeEventListener("pageshow",Me),window.removeEventListener("online",Ye),window.removeEventListener("resize",We),window.removeEventListener(jf,it),k?.removeEventListener("resize",We),k?.removeEventListener("scroll",We)}},[e.id]);function Bs(){document.visibilityState==="hidden"||!et.current||(pa(),Ui())}function js(){const k=X.current(e.id);Ae.current+=1,Ve.current=!0,pi.current=null,Ni("reconnecting"),Ui(),I5(k)}function xc(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Ae.current+=1,Y.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Me=Ve.current;Ve.current=!1;const Ye=P.current;if(!Ye)return;if(Ui(),Me){_o(k.output,k.history??null);return}if(Ec(Ye,k.terminal)){T(k.output,k.history??null),Ti(),Ui();return}_n(k.output,k.history??null),Ui();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){Y.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Me=eE(k.data);if(!Me)return;Pe.current.push(Me),P.current&&oi.current?Is({scrollToBottom:!0}):ke.current=!0;return}const H=P.current;if(H){if(k.type==="exit"&&k.terminalId===e.id){Y.current.onExit(k.exitCode),Ni("closed");return}k.type==="error"&&H.writeln(`\r
51
+ [nterminal] ${k.message}`)}}function _o(k,H){_n(k,H),Ui()}function bo(k=25){if(document.visibilityState==="hidden"||!et.current||de.current.has(k))return;const H=window.setTimeout(()=>{de.current.delete(k),!Er()&&ci()},k);de.current.set(k,H)}function er(){Er()||yo()}function Er(){const k=ha();return k&&Cc(k)?(I.current=!0,R.current=k,!0):k&&da(k)?(I.current=!1,R.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(I.current=!1,R.current=null),!1)}function hl(){if(!I.current)return;const k=ha();k&&(k.composeOpen||k.keyboardVisible)||(I.current=!1,R.current=null)}function Cc(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const H=O.current;return H?tr(k.windowWidth,H.windowWidth)&&tr(k.visualViewportWidth,H.visualViewportWidth)&&tr(k.containerWidth,H.containerWidth):!1}function da(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const H=R.current;return!H||!H.composeOpen&&!H.keyboardVisible?!1:tr(k.windowWidth,H.windowWidth)&&tr(k.visualViewportWidth,H.visualViewportWidth)&&tr(k.containerWidth,H.containerWidth)}function ha(){const k=oe.current;if(!k||k.isConnected===!1)return null;const H=k.getBoundingClientRect(),Me=Dr(window.innerWidth)??0,Ye=Dr(window.visualViewport?.width)??Me,We=Dr(H.width)??Dr(k.clientWidth)??Me;if(Me<=0||Ye<=0||We<=0)return null;const{keyboardVisible:it}=C_(),ft=document.documentElement.hasAttribute(dp),vt=Bn()||it;return{windowWidth:Me,visualViewportWidth:Ye,containerWidth:We,composeOpen:ft,keyboardVisible:it,mobileLike:vt}}function Bn(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fa(){return C_().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Dr(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function tr(k,H){return Math.abs(k-H)<=bj}function yo(){for(const k of vj)bo(k)}function Ui(){ne.current=null,yo()}function pa(){if(ma(),M.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{M.current.delete(k),ma();const H=window.requestAnimationFrame(()=>{M.current.delete(H),ma()});M.current.add(H)});M.current.add(k)}for(const k of _j){if(ge.current.has(k))continue;const H=window.setTimeout(()=>{ge.current.delete(k),ma()},k);ge.current.set(k,H)}}function ma(){const k=P.current;if(!(!k||!oi.current||document.visibilityState==="hidden"||!et.current||oe.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function So(){for(const k of de.current.values())window.clearTimeout(k);de.current.clear()}function wo(){for(const k of ge.current.values())window.clearTimeout(k);ge.current.clear();for(const k of M.current)window.cancelAnimationFrame(k);M.current.clear()}function fl(){for(const k of q.current)window.clearTimeout(k);q.current=[]}function as(){if(Ti(),!$e.current){Cs(!1);return}Cs(!0),pl(),St.current=window.setTimeout(()=>{St.current=null,Cs(!1)},1200)}function Ti(){const k=P.current,H=k?h4(k):null;if($e.current=H,wn(H),xn(!!(k&&H)),$n(!!(k&&H&&!es(k))),H||!k||!kc()){on(null);return}on({alternate:k.buffer.active.type==="alternate"})}function kc(){const k=ie.current;return He.current.length>0||!!k?.hasMore}function pl(){St.current!==null&&(window.clearTimeout(St.current),St.current=null)}function jn(){const k=P.current;k&&(wt.current=!es(k),Ti())}function ga(k){z.current=rv(z.current,k)}function Tc(k){const H=z.current;return z.current=null,rv(H,k)}function ml(){const k=z.current;return z.current=null,k}function Is(k={}){const H=P.current;if(!H||!oi.current){ke.current=!0;return}if(pi.current&&!_t.current&&!E.current&&es(H)){B();return}if(_t.current){ga(k);return}if(E.current){ga(k);return}const Me=Tc(k);if(!Me.force&&!Vh(H,wt.current)){Ti();return}E.current=!0;const Ye=we.current,We=()=>{if(P.current!==H||we.current!==Ye)return;if(!Me.force&&!Vh(H,wt.current)){if(E.current=!1,Ls())return;Ti();return}const it=Ze.current,ft=Pe.current[it];if(ft===void 0){if(E.current=!1,Ls())return;Me.scrollToBottom&&ce(H),Ti();const vt=ml();vt?Is(rv(Me,vt)):B();return}H.write(ft,()=>{P.current!==H||we.current!==Ye||(Ze.current=it+1,We())})};We()}function xo(k){return pi.current!==null||!es(k)&&(S()||E.current||_t.current)}function Ec(k,H){return(H?.agentStatus?.provider==="codex"||H?.agentStatus?.provider==="claude"||gn.current||Zl(H?.currentCommand))&&!es(k)}function S(){return Ze.current<Pe.current.length}function T(k,H){pi.current={output:k,history:H,appendFromLiveOutputIndex:Pe.current.length}}function B(){const k=P.current,H=pi.current;if(!k||!H||!es(k)||E.current||_t.current)return;const Me=qh(H.output),Ye=qh(Pe.current.slice(H.appendFromLiveOutputIndex));pi.current=null,_n([...Me,...Ye],H.history),Ui()}function G(){Pt.current=!0}function ae(){jn(),Pt.current=!1;const k=P.current;k&&es(k)&&Is({scrollToBottom:!0})}function ce(k){Oe(()=>Dx(k))&&(wt.current=!1)}function Se(k,H){Oe(()=>(k.scrollToLine(H),!0))}function Oe(k){Nt.current=!0;try{return k()}finally{Nt.current=!1}}function Ie(){const k=P.current;if(!k)return;const H=()=>{Le.current&&(To(Z.current),Ht(!1)),Dx(k),wt.current=!1,Ti(),Is({force:!0,scrollToBottom:!0}),zs("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(j_,H);return}H()}function ht(k){const H=P.current,Me=oe.current;if(!H||!Me)return;const Ye=Me.getBoundingClientRect();if(Ye.height<=0)return;const We=Math.max(0,Math.min(1,(k-Ye.top)/Ye.height)),it=Math.round(H.buffer.active.baseY*We);G();try{H.scrollToLine(it)}finally{ae()}wt.current=!es(H),Ti(),as(),it<=3&&Js()}function Mt(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),ht(k.clientY)}function Tn(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),ht(k.clientY))}function ci(){const k=P.current,H=te.current;if(!(!k||!H)&&!(document.visibilityState==="hidden"||!et.current||oe.current?.isConnected===!1))try{const Me=Vh(k,wt.current),Ye=ha();H.fit(),Ye&&(O.current=Ye),Me&&ce(k),k.refresh(0,Math.max(0,k.rows-1)),Ti();const We={cols:k.cols,rows:k.rows},it=ne.current;if(it&&it.cols===We.cols&&it.rows===We.rows)return;Dc({type:"resize",terminalId:e.id,cols:We.cols,rows:We.rows})&&(ne.current=We)}catch{}}function Ps(k,H){const Me=Z.current;return Me?Me(k,H):"rejected"}function Dc(k){return Ps(k)!=="rejected"}function Co(){J.current!==null&&(window.clearTimeout(J.current),J.current=null)}function Rc(){Co();const k=Math.max(-$h,Math.min($h,ye.current));if(ye.current=0,k===0)return!1;const H=Dc({type:"scrollback_scroll",terminalId:e.id,lines:k});return H&&(ve.current=!0,k<0&&Ht(!0)),H}function va(k){if(!Le.current||k===0)return;const H=ye.current+k;ye.current=Math.max(-$h,Math.min($h,H)),J.current===null&&(J.current=window.setTimeout(()=>{J.current=null,Rc()},Hj))}function ko(){To(Z.current)}function wd(k=Z.current,H={}){const Me=ve.current;Co(),ye.current=0,ve.current=!1,H.updateUi!==!1&&Ht(!1),Me&&k?.({type:"cancel_scrollback",terminalId:e.id})}function To(k){Co(),ye.current=0,ve.current=!1,Ht(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function Nc(){if(!Ne.current)return;const k=!Le.current;Rs(LM(ee.current,k)),yp()}function xd(){const k=!ni.current;ni.current=k,Zs(k),os({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function gl(){xt.current!==null&&(window.clearTimeout(xt.current),xt.current=null)}function os(k,H={}){gl();const Me=lt.current+1;lt.current=Me,Cn({...k,id:Me}),!H.sticky&&(xt.current=window.setTimeout(()=>{xt.current=null,Cn(Ye=>Ye?.id===Me?null:Ye)},12e3))}function Cd(){hi.current.skipped=!0,os({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function kd(){ni.current=!1,Zs(!1),os({tone:"skipped",message:"Cache keep-alive off"})}async function Mc(){const k=hi.current;if(k.sent||k.skipped)return;const H=bp();if(k.sent=!0,H){os({tone:"skipped",message:"Skipped cache keep-alive",detail:H});return}if(Rr(`${bx}\r`,{userInitiated:!1})==="rejected"){os({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}os({tone:"success",message:"Cache keep-alive sent",detail:bx})}function bp(){const k=Ii.current,H=ze.current;return ni.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!H?"Transcript cache status is unavailable.":k.source.provider!==H.provider||k.source.sessionId!==H.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${nl(H.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":sc(e.id).text.trim()?"Compose has an unsent draft.":Xj(oe.current)?"Pane input is focused.":Date.now()-Vi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function yp(){const k=P.current;k&&(ce(k),Ti())}function Rr(k,H={}){Rc();const Me=ve.current;Is({force:!0,scrollToBottom:!0});const Ye=Ps({type:"input",terminalId:e.id,data:k,...Me?{cancelScrollbackMode:!0}:{}},{durability:H.userInitiated===!1?"live-only":"durable"});return Ye==="rejected"?(H.userInitiated!==!1&&ki("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Ye):(H.userInitiated!==!1&&(Vi.current=Date.now()),Me&&(ve.current=!1,Ht(!1)),c4(k)&&(Ye==="sent"?_a():Ye==="queued"&&(he.current=!0)),Ye)}function Sp(){Ge.current&&Eo(!1),Rr(xj)}function wp(k){const H=Wg(k,{bracketedPasteMode:P.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});H&&Rr(H)}function En(k,H){const Me=P.current?.modes.bracketedPasteMode===!0,Ye=vn==="codex"||vn==="claude"||Zl(e.currentCommand),We=k.parts.map(it=>it.kind==="image"&&Ye?Wg(it.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Wg(it.kind==="image"?it.path:it.value,{bracketedPasteMode:Me,stripTrailingLineBreaks:!1})).join("");return We?Rr(`${We}${jB(H)}`)!=="rejected":!1}function _a(){!gt.current||!st.current||(fl(),q.current=yj.map(k=>{const H=window.setTimeout(()=>{q.current=q.current.filter(Me=>Me!==H),gt.current&&st.current&&Dc({type:"refresh_cwd",terminalId:e.id})},k);return H}))}function zs(k="terminal-interaction"){li.current||fa()&&(k==="auto"||k==="scroll-action")||P.current?.focus()}const Td=v.useCallback(()=>{Qs(!1)},[]),Ed=v.useCallback(async()=>{const k=ze.current,H=at.current;try{const Me=await t.getTerminalTranscriptSource(e.id);if(!Me.source||Bt.current!==e.id||at.current!==H||!Uh(k,ze.current))return;pe.current=null,Te.current=!1,De.current=!1,Ci(Me.source),Si.current=nv(e.id,Me.source)}catch{}},[Ci,t,e.id]);function Dd(){br(k=>{const H=!k;return Ge.current=H,H}),zs("input-action")}function Eo(k){Ge.current=k,br(k)}function xp(k){Ge.current&&Eo(!1),Rr(aB(k)),zs("input-action")}async function Nr(k="install"){Cr(!0),kn(null);try{const H=k==="update"?await t.updateCodeServer():await t.installCodeServer();I_(Gi,H.status),Ds(H.status)}catch(H){kn(Wh(H))}finally{Cr(!1)}}return d.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Zi?"true":"false",onMouseDown:()=>{n||g()},children:[d.jsx(Gj,{terminal:e,canClose:o,tabId:u,transcriptSource:Wt,transcriptShortcutLabel:U,subagentsShortcutLabel:K,transcriptCacheStatus:ln,transcriptCacheNow:yr,cacheKeepAliveEnabled:wr,codeServerAvailable:!0,codeServerInstallState:Xi===null?"unknown":Xi.installed?"installed":"missing",codeServerBusy:la||Xi?.job?.status==="running",codeServerSupported:Xi?.supported!==!1,scrollbackShortcutLabel:F,tmuxScrollbackSupported:ns,tmuxScrollbackEnabled:Zi,onToggleCacheKeepAlive:xd,onOpenCodeServer:ua,onToggleTmuxScrollback:Nc,onOpenTranscript:Tr,onOpenSubagents:vo,onReload:js,onClose:m}),d.jsx("div",{className:"xterm-container",ref:oe}),wi?d.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:d.jsx("span",{"aria-hidden":"true"})}):null,N&&!Zi&&is?d.jsxs("div",{className:"terminal-scroll-progress","data-active":xs,"aria-hidden":"true",children:[is.current,"/",is.total]}):N&&!Zi&&ks?d.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":ks.alternate?"alternate":"normal","aria-hidden":"true",children:[ks.alternate?"alt ":"","0/?"]}):null,Xs||Zi&&Gs?d.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),Ie()},children:"↓"}):null,Ts&&!Zi?d.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Mt,onPointerMove:Tn,children:d.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?go?d.jsx(sB,{ctrlActive:aa,onCtrl:Dd,onStandaloneKey:xp,onPreserveFocus:()=>zs("input-action"),onHide:()=>Ms(!1)}):d.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),zs("input-action")},onPointerDown:k=>{k.stopPropagation(),zs("input-action")},onClick:()=>Ms(!0),children:"⌨"}):null,d.jsx(VB,{terminalId:e.id,onSubmit:En,onUploadAttachments:(k,H)=>t.uploadComposeAttachments({terminalId:e.id,files:k,signal:H.signal,onProgress:H.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:k=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:k})}:{},queueAvailable:vn==="codex"||QT(e.currentCommand),disabled:e.status!=="running"}),d.jsx(e4,{toast:xr,onSendNow:()=>{Mc()},onSkipOnce:Cd,onTurnOff:kd,onDismiss:()=>Cn(null)}),Pi&&Wt?d.jsx(t4,{terminalId:e.id,serverApi:t,source:Wt,fontSize:x,onClose:Td,onReloadLatest:Ed}):null,oa&&Wt?d.jsx(KO,{terminalId:e.id,serverApi:t,source:Wt,fontSize:x,onClose:()=>Es(!1)}):null,mo?d.jsx(Qj,{notice:mo}):null,wc?d.jsx(Zj,{status:Xi,busy:la,error:po,onInstall:()=>{Nr("install")},onUpdate:()=>{Nr("update")},onOpen:ua,onRefresh:()=>{Wn({checkLatest:!0}).catch(k=>kn(Wh(k)))},onClose:()=>zi(!1)}):null]})}function wx(e){return aD(e)}async function xx(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=Gl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=Uj)return u.status;if(u?.inflight&&(!r||u.inflightCheckLatest))return u.inflight;let f;return f=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(I_(e,g),g)).catch(g=>{const m=Gl.get(e);throw m?.inflight===f&&(m.status?Gl.set(e,{status:m.status,fetchedAt:m.fetchedAt}):Gl.delete(e)),g}),Gl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:f,inflightCheckLatest:r}),f}function I_(e,t){Gl.set(e,{status:t,fetchedAt:Date.now()})}function Kh(e,t){return`${e}:${t}`}function XT(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function Cx(e){const t=qu.get(e);if(!t)return!1;try{return t.closed?(qu.delete(e),!1):(t.focus(),!0)}catch{return qu.delete(e),!1}}function tv(e,t){const n=window.open(t,XT(e));if(!n)return null;qu.set(e,n);try{n.focus()}catch{}return n}function kx(e,t,n){if(!e||GT(e))return!1;try{return e.name=XT(t),e.location.href=n,qu.set(t,e),e.focus(),!0}catch{return!1}}function Fj(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function GT(e){if(!e)return!0;try{return e.closed}catch{return!0}}function iv(e){if(e)try{e.closed||e.close()}catch{}}function $j(e,t,n){const r=Kj(e,t),o=Tx(r*Math.max(1,n),Lj,Oj);return{limit:Tx(Math.ceil(o/Nj),Mj,Aj),maxLines:o}}function Kj(e,t){const n=e?.clientHeight??0;if(n<=0)return Dj;const r=Math.max(10,t*Rj);return Math.max(1,Math.floor(n/r))}function Tx(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function Wj(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function nv(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function ZT(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function qj(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function Vj(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),u=r%24;return u>0?`${c}d ${u}h`:`${c}d`}function Yj(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Wh(e){return e instanceof fn||e instanceof Error?e.message:"Something went wrong."}function Xj(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function Gj({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:f,cacheKeepAliveEnabled:g,codeServerAvailable:m,codeServerInstallState:_,codeServerBusy:b,codeServerSupported:w,scrollbackShortcutLabel:x,tmuxScrollbackSupported:C,tmuxScrollbackEnabled:N,onToggleCacheKeepAlive:L,onOpenCodeServer:A,onToggleTmuxScrollback:W,onOpenTranscript:U,onOpenSubagents:F,onReload:K,onClose:oe}){const P=gb({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),te={cursor:n?"grab":"default",opacity:P.isDragging?.5:void 0};return d.jsxs("header",{ref:P.setNodeRef,className:"terminal-pane-header",style:te,"data-dragging":P.isDragging,...P.attributes,...P.listeners,children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),d.jsx("span",{className:"terminal-pane-spacer"}),m?d.jsx("button",{type:"button",className:"terminal-pane-code","data-state":_,"data-busy":b?"true":"false",disabled:!w||b,title:_==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":_==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),A()},children:d.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?d.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${nl(r.provider)} transcript history`,"aria-label":`View ${nl(r.provider)} transcript history`,onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),U()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View history"}),d.jsx("span",{className:"pane-button-label-short",children:"History"}),d.jsx("kbd",{children:o})]}):null,r?d.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),F()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View agents"}),d.jsx("span",{className:"pane-button-label-short",children:"Agents"}),d.jsx("kbd",{children:c})]}):null,r?d.jsx(Jj,{status:u,now:f,keepAliveEnabled:g,onToggle:L}):null,e.status==="exited"?d.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,C&&e.status==="running"?d.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":N?"true":"false","aria-pressed":N,"aria-label":`Toggle tmux scrollback (${x})`,title:N?`Scroll input uses tmux scrollback (${x}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${x}).`,onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),W()},children:[N?d.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),d.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):d.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),d.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),d.jsx("kbd",{children:x})]}):null,e.status==="running"?d.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),K()},children:"↻"}):null,t?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:Z=>Z.stopPropagation(),onMouseDown:Z=>Z.stopPropagation(),onClick:Z=>{Z.stopPropagation(),oe()},children:"x"}):null]})}function Zj({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:f}){const g=e?.job??null,m=g?.status==="running",_=e?.installed===!0,b=e?.supported!==!1,w=e===null&&t,x=e?.updateAvailable===!0,C=_?"VS Code add-on":"Install VS Code add-on";return d.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":C,onClick:f,children:d.jsxs("section",{className:"security-panel code-server-dialog",onClick:N=>N.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{children:[d.jsx("h2",{children:C}),d.jsx("p",{children:w?"Checking code-server status...":_?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),d.jsxs("div",{className:"code-server-dialog-scroll",children:[d.jsxs("div",{className:"code-server-dialog-body",children:[d.jsxs("p",{children:["NTerminal installs code-server under ",d.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?d.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:d.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?d.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?d.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[d.jsxs("div",{className:"code-server-progress-heading",children:[d.jsx("span",{children:g.action}),d.jsx("strong",{children:g.status})]}),d.jsx("pre",{children:g.logs.length>0?g.logs.join(`
52
+ `):"Preparing..."})]}):null]}),d.jsxs("div",{className:"code-server-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||m||!b,children:"Check"}),_?d.jsxs(d.Fragment,{children:[x?d.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||m||!b,children:"Update"}):null,d.jsx("button",{type:"button",onClick:c,disabled:t||m,children:"Open"})]}):d.jsx("button",{type:"button",onClick:r,disabled:t||m||!b,children:m?"Installing...":"Install"})]})]})})}function Qj({notice:e}){return d.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function Jj({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=ZT(e,t),c=qj(e,o),u=o===null?"?":Vj(o),f=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return d.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:f,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[d.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),d.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),d.jsx("span",{children:u})]})}function e4({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return d.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[d.jsxs("header",{children:[d.jsx("strong",{children:e.message}),d.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?d.jsx("p",{children:e.detail}):null,c?d.jsxs("div",{className:"cache-keepalive-toast-actions",children:[d.jsx("button",{type:"button",onClick:t,children:"Send now"}),d.jsx("button",{type:"button",onClick:n,children:"Skip once"}),d.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const t4=Ot.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const f=v.useRef(null),g=v.useRef(0),m=v.useRef(!1),_=v.useRef(!1),b=v.useRef(null),w=v.useRef(""),x=v.useRef(null),C=v.useRef(null),[N,L]=v.useState([]),[A,W]=v.useState(!1),[U,F]=v.useState(""),[K,oe]=v.useState(-1),[P,te]=v.useState(!1),[Z,me]=v.useState(-1),[ee,Y]=v.useState(null),[X,V]=v.useState(null),[ne,O]=v.useState(!1),[R,I]=v.useState(!0),[de,ge]=v.useState(!1),[M,q]=v.useState(null),[he,J]=v.useState(!1);v.useEffect(()=>{function ke(Ge){Ge.key==="Escape"&&(Ge.preventDefault(),Ge.stopPropagation(),c())}return document.addEventListener("keydown",ke,!0),()=>document.removeEventListener("keydown",ke,!0)},[c]),v.useEffect(()=>{g.current+=1;const ke=g.current;return m.current=!1,_.current=!0,b.current=null,x.current=null,C.current=null,L([]),V(null),O(!1),q(null),J(!1),oe(-1),me(-1),Y(null),Ve(null,"initial",ke),()=>{g.current===ke&&(g.current+=1)}},[n,A,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ke=f.current;if(!ke)return;if(_.current){if(R||N.length===0)return;_.current=!1;const st=()=>{ke.scrollTop=ke.scrollHeight};st(),window.requestAnimationFrame?.(st);return}const Ge=b.current;Ge!==null&&(b.current=null,ke.scrollTop+=ke.scrollHeight-Ge)},[N,R,A]);const ye=nl(r.provider),ve=Lf(N,A),Le=cT(ve),Ne=i4(Le),Fe=Ne.map(ke=>ke.key).join(""),He=ee?Ne.find(ke=>ke.key===ee)?.entryIndex??null:null,Pe=U.trim().length>0,Ze=jO(Le,U),E=Ze.length,z=E>0?K>=0&&K<E?K:0:-1,we=z>=0?Ze[z]?.entryIndex??null:null,Ae=z>=0?Ze[z]??null:null,ie=Pe?we:He,pe=Pe?we===null?null:"search":He===null?null:"prompt",Te=ve?ve.split(`
53
+ `).length-1:0,De=Ne.length>0&&Z>=0&&Z<Ne.length?Z:Ne.length-1,Ee=ee??(De>=0?Ne[De]?.key??null:null),je=Pe?E>0?`${z+1}/${E} ${E===1?"match":"matches"} · ${Te} ${Te===1?"line":"lines"}`:`0 matches · ${Te} ${Te===1?"line":"lines"}`:Ne.length>0?`${De+1}/${Ne.length} prompts · ${Te} ${Te===1?"line":"lines"}`:`0 prompts · ${Te} ${Te===1?"line":"lines"}`;v.useEffect(()=>{const ke=U.trim().toLowerCase();oe(Ge=>!ke||E===0?-1:w.current!==ke?0:Ge>=0&&Ge<E?Ge:0),w.current=ke},[U,E]),v.useEffect(()=>{if(Pe){Y(null);return}ee&&!Ne.some(ke=>ke.key===ee)&&Y(null),me(ke=>{if(Ne.length===0)return C.current=null,-1;const Ge=C.current?Ne.findIndex(et=>et.key===C.current):-1,st=Ge>=0?Ge:ke>=0&&ke<Ne.length?ke:Ne.length-1;return C.current=Ne[st]?.key??null,st})},[ee,Pe,Fe]),v.useEffect(()=>{const ke=x.current;if(!ke||Ne.length===0)return;x.current=null;const Ge=ke.anchorKey?Ne.findIndex(et=>et.key===ke.anchorKey):-1,st=Ge>0?Ge-1:0;_t(st)},[Fe]);async function Ve(ke,Ge,st=g.current){if(!m.current){m.current=!0,Ge==="initial"?I(!0):(ge(!0),b.current=f.current?.scrollHeight??null),q(null);try{await $e(ke,Ge,st)}catch(et){if(g.current!==st)return;q(et instanceof Error?et.message:"Failed to load transcript history.")}finally{g.current===st&&(m.current=!1,I(!1),ge(!1))}}}async function $e(ke,Ge,st){let et=ke,gt=0,ct=[];const mn=Ge==="initial"&&r.provider!=="claude"?jj:Bj;for(;g.current===st;){const li=await n.getTerminalTranscriptHistory(t,{...et?{cursor:et}:{},...$j(f.current,o,Ge==="initial"?Tj:Ej),includeTools:A});if(g.current!==st)return;if(!li.source){q("Transcript source is temporarily unavailable.");return}if(!Vb(r,li.source)){J(!0),O(!1);return}const le=x_(li.output,r.provider,{includeTools:A}),ze=St(li,Ge,ct,le);if(le&&(ct=[le,...ct],ze))return;if(!li.hasMore||!li.cursor||gt>=mn){ct.length>0&&L(ut=>Ge==="older"?[...ct,...ut]:ct);return}et=li.cursor,gt+=1}}function St(ke,Ge,st,et=x_(ke.output,r.provider,{includeTools:A})){if(V(ke.cursor),O(!!(ke.hasMore&&ke.cursor)),!et)return!1;const gt=[et,...st];return Lf(gt,A)?(L(ct=>Ge==="older"?[...gt,...ct]:gt),!0):!1}function wt(){const ke=f.current;ke&&(oi(),!(ke.scrollTop>72||!ne||!X||m.current)&&Ve(X,"older"))}function Nt(ke){E!==0&&oe(Ge=>{const st=z>=0?z:ke>0?-1:0;return((Ge>=0&&Ge<E?Ge:st)+ke+E)%E})}function _t(ke){const Ge=Ne[ke];Ge&&(C.current=Ge.key,me(ke),Y(Ge.key))}async function Pt(ke){if(Ne.length===0){ke<0&&ne&&X&&!m.current&&(x.current={anchorKey:null},await Ve(X,"older"));return}const st=(Z>=0&&Z<Ne.length?Z:ke<0?Ne.length-1:-1)+ke;if(st>=0&&st<Ne.length){_t(st);return}ke<0&&st<0&&ne&&X&&!m.current&&(x.current={anchorKey:Ne[0]?.key??null},await Ve(X,"older"))}function oi(){if(Pe)return;const ke=f.current;if(!ke)return;const st=ke.getBoundingClientRect().top+Math.min(140,Math.max(48,ke.clientHeight*.28));let et=null;for(const gt of o4(ke)){const ct=l4(gt);if(ct!==null)if(gt.getBoundingClientRect().top<=st)et=ct;else break}if(et!==null){const gt=Ne[et]?.key??null;C.current=gt,me(et),ee&&ee!==gt&&Y(null)}}return d.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ke=>ke.stopPropagation(),onMouseDown:ke=>ke.stopPropagation(),onClick:ke=>{ke.stopPropagation(),c()},children:d.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ke=>ke.stopPropagation(),onMouseDown:ke=>ke.stopPropagation(),onClick:ke=>ke.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"transcript-dialog-title",children:[ye," JSONL"]}),d.jsx("span",{title:r.sessionId,children:r.sessionId})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),d.jsxs("div",{className:"transcript-dialog-controls",children:[d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:A,onChange:ke=>W(ke.currentTarget.checked)}),"Show tool output"]}),d.jsx("label",{className:"transcript-search",children:d.jsx("input",{type:"search",value:U,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ke=>F(ke.currentTarget.value),onKeyDown:ke=>{ke.key==="Enter"&&(ke.preventDefault(),Pe?Nt(ke.shiftKey?-1:1):Pt(ke.shiftKey?-1:1))}})}),d.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":P,"aria-label":"Toggle prompt list",onClick:()=>te(ke=>!ke),disabled:Ne.length===0,children:"List"}),d.jsxs("div",{className:"transcript-search-actions","aria-label":Pe?"Search result navigation":"Prompt navigation",children:[d.jsx("button",{type:"button",onClick:()=>Pe?Nt(-1):void Pt(-1),disabled:Pe?E===0:Ne.length===0&&!ne,"aria-label":Pe?"Previous search match":"Previous user prompt",title:Pe?"Previous search match":"Previous user prompt",children:"Prev"}),d.jsx("button",{type:"button",onClick:()=>Pe?Nt(1):void Pt(1),disabled:Pe?E===0:Ne.length===0,"aria-label":Pe?"Next search match":"Next user prompt",title:Pe?"Next search match":"Next user prompt",children:"Next"})]}),d.jsx("span",{className:"transcript-result-count",children:je})]}),P?d.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ne.length>0?Ne.map((ke,Ge)=>d.jsxs("button",{type:"button",className:Ee===ke.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>_t(Ge),children:[d.jsx("span",{children:ke.timestampLabel}),d.jsx("strong",{children:ke.snippet})]},`${ke.key}:${Ge}`)):d.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,d.jsxs("div",{ref:f,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:wt,children:[de?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&ne?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,ve?d.jsx(oT,{entries:Le,searchQuery:U,activeEntryIndex:ie,activeEntryMode:pe,activeSearchMatch:Ae,fontSize:o}):null,R?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,he?d.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",d.jsx("button",{type:"button",onClick:()=>{u()},children:"Load current session"})]}):null,!he&&!R&&!ve&&!M?ne&&X?d.jsxs("div",{className:"transcript-dialog-status",children:[A?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{Ve(X,"older")},disabled:de,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,M?d.jsx("div",{className:"transcript-dialog-error",children:M}):null]})]})})});function i4(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:n4(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=n.get(c.contentKey)??0;n.set(c.contentKey,u+1),r.set(o,JSON.stringify([c.contentKey,u]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:r4(o.entry.body),timestampLabel:a4(o.entry.header)}))}function n4(e){return JSON.stringify([e.header??"",e.body.length,s4(e.body)])}function s4(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function r4(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function a4(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function o4(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function l4(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function c4(e){return e.includes("\r")||e.includes(`
54
+ `)}function sv(e){return e instanceof fn&&e.status===404}function Zl(e){return QT(e)||JT(e)}function QT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function JT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function u4(e){if(Zl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function d4(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function qh(e){const t=[];for(const n of e){const r=eE(n);r&&t.push(r)}return t}function eE(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!Cj.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function rv(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function h4(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function Ex(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function es(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Vh(e,t){return!t||es(e)}function Dx(e){return es(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function f4(e,t,n,r,o,c,u,f){const g=m=>{const _=m4(m);if(_!==0){if(u()){if(_4(t))return;m.cancelable&&m.preventDefault(),m.stopPropagation(),f(_);return}m.cancelable&&m.preventDefault(),m.stopPropagation(),p4(t,_,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function p4(e,t,n,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(j_,u);return}u()}function m4(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function g4(e,t,n,r,o,c,u,f,g){let m=null,_=0;const b={passive:!1};function w(N){m=av(N),_=0}function x(N){const L=av(N);if(L===null){m=null,_=0;return}if(m===null){m=L;return}const A=L.clientY-m.clientY;if(m=L,N.cancelable&&N.preventDefault(),A===0)return;if(v4(t)&&b4(t,L,-A)){_=0;return}_-=A/n();const W=_<0?Math.ceil(_):Math.floor(_);if(W!==0){if(_-=W,f()){g(W);return}c();try{t.scrollLines(W)}finally{u()}r(),W<0&&t.buffer.active.viewportY<=3&&o(W)}}function C(N){if(N.touches.length>0){m=av(N);return}m=null,_=0}return e.addEventListener("touchstart",w,b),e.addEventListener("touchmove",x,b),e.addEventListener("touchend",C),e.addEventListener("touchcancel",C),()=>{e.removeEventListener("touchstart",w,b),e.removeEventListener("touchmove",x,b),e.removeEventListener("touchend",C),e.removeEventListener("touchcancel",C)}}function av(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function v4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function _4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function b4(e,t,n){const r=e.element;return r?(r.dispatchEvent(y4(t,n)),!0):!1}function y4(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function P_({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:f,codeServerContext:g,dropZoneActive:m=!1,draggingTerminalId:_=null,mobileFocusLeafKey:b=null,path:w=[],totalPanes:x,onSelect:C,onClose:N,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:U,onAuthClose:F}){const K=x??z_(e);if(w.length===0&&b){const Z=H_(e),me=Z.some(ee=>ee.key===b)?b:Z[0]?.key;if(Z.length>1&&me)return d.jsx("div",{className:"mobile-focused-split",children:Z.map(ee=>{const Y=ee.key===me;if(ee.type==="editor"){const V=n[ee.editorId];return d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:V?d.jsx(i1,{api:r,editor:V,canClose:K>1,onClose:()=>U(ee.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ee.key)}const X=t[ee.terminalId];return X?d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:d.jsx(Sx,{terminal:X,serverApi:r,active:Y,visible:c&&Y,canClose:K>1,refreshCwdOnEnter:u&&Y,tabId:f,codeServerContext:g,onSelect:()=>C(ee.terminalId),onClose:()=>N(ee.terminalId),onExit:V=>A(ee.terminalId,V),onSnapshot:W,...F?{onAuthClose:F}:{}})},ee.key):d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ee.key)})})}if(e.type==="pane"){const Z=t[e.terminalId];if(!Z)return d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const me=d.jsx(Sx,{terminal:Z,serverApi:r,active:e.terminalId===o,visible:c,canClose:K>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:f,codeServerContext:g,onSelect:()=>C(e.terminalId),onClose:()=>N(e.terminalId),onExit:Y=>A(e.terminalId,Y),onSnapshot:W,...F?{onAuthClose:F}:{}});return m&&_!==e.terminalId?d.jsxs("div",{className:"pane-drop-host",children:[me,d.jsx(Yh,{terminalId:e.terminalId,side:"top"}),d.jsx(Yh,{terminalId:e.terminalId,side:"right"}),d.jsx(Yh,{terminalId:e.terminalId,side:"bottom"}),d.jsx(Yh,{terminalId:e.terminalId,side:"left"})]}):me}if(e.type==="editor"){const Z=n[e.editorId];return Z?d.jsx(i1,{api:r,editor:Z,canClose:K>1,onClose:()=>U(e.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const oe=Math.max(.1,Math.min(.9,e.ratio)),P=1-oe,te=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${oe}fr) 1px minmax(0, ${P}fr)`}:{gridTemplateRows:`minmax(0, ${oe}fr) 1px minmax(0, ${P}fr)`};return d.jsxs("div",{className:"split-pane","data-direction":e.direction,style:te,children:[d.jsx("div",{className:"split-cell",children:d.jsx(P_,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:m,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...w,0],totalPanes:K,onSelect:C,onClose:N,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:U,...F?{onAuthClose:F}:{}})}),d.jsx(S4,{direction:e.direction,path:w,onResize:L}),d.jsx("div",{className:"split-cell",children:d.jsx(P_,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:m,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...w,1],totalPanes:K,onSelect:C,onClose:N,onResize:L,onExit:A,onSnapshot:W,onCloseEditor:U,...F?{onAuthClose:F}:{}})})]})}function Yh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=ep({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return d.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function S4({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const u=c.parentElement;if(!u)return;const f=u.getBoundingClientRect();function g(_){const b=e==="vertical"?(_.clientX-f.left)/f.width:(_.clientY-f.top)/f.height;n(t,Math.min(.9,Math.max(.1,b)))}function m(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m),c.removeEventListener("lostpointercapture",m),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",m),window.addEventListener("pointercancel",m),c.addEventListener("lostpointercapture",m)}return d.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:d.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function z_(e){return e.type==="pane"||e.type==="editor"?1:z_(e.first)+z_(e.second)}function H_(e){return e.type==="pane"?[{key:w4(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:x4(e.editorId),type:"editor",editorId:e.editorId}]:[...H_(e.first),...H_(e.second)]}function w4(e){return`terminal:${e}`}function x4(e){return`editor:${e}`}const mp="workspace-default",C4="NTerminal";function k4(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function T4(e,t){switch(t.type){case"workspace.hydrated":return hf(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return E4(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return M4(e,t.workspaceId);case"workspace.selected":return tE(e,t.workspaceId);case"workspace.renamed":return D4(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return R4(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return N4(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return iE(e,t.terminal);case"terminal.split":return A4(e,t.terminal,t.direction);case"terminal.updated":return $4(e,t.terminal);case"terminal.exited":return K4(e,t.terminalId,t.exitCode);case"terminal.closed":return rE(e,t.terminalId);case"terminal.detached":return W4(e,t.terminalId,t.workspaceId);case"editor.split":return L4(e,t.editorId,t.title,t.direction);case"editor.closed":return q4(e,t.editorId);case"pane.selected":return U4(e,t.terminalId);case"pane.resized":return F4(e,t.path,t.ratio);case"tab.selected":return B4(e,t.tabId);case"tab.renamed":return H4(e,t.tabId,t.title);case"tab.reordered":return iy(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return j4(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return nE(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return sE(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return I4(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return O4(e);default:return e}}function E4(e,t){if(e.workspaces.some(r=>r.id===t.id))return tE(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Ys(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function tE(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function D4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.title===r?u:(o=!0,{...u,title:r}));return o?{...e,workspaces:c}:e}function R4(e,t,n){const r=Ys(n);let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.defaultCwd===r?u:(o=!0,{...u,defaultCwd:r}));return o?{...e,workspaces:c}:e}function N4(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const u=e.workspaces.slice(),[f]=u.splice(o,1);if(!f)return e;const g=u.findIndex(b=>b.id===n);if(g<0)return e;const m=r==="before"?g:g+1,_=u.slice();return _.splice(m,0,f),z4(e.workspaces,_)?e:{...e,workspaces:_}}function M4(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const n=e.workspaces.find(f=>f.id===t),r=new Set(n?Kf(n):[]),o={...e.terminals};for(const f of r)delete o[f];const c=e.workspaces.filter(f=>f.id!==t),u=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:u,terminals:o}}function iE(e,t){const n=oE(e),r=ol(n)??vp(),o=hE(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Ys(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:dE(c,t.id))}}function A4(e,t,n){const r=ol(e),o=r?gp(r):void 0;if(!r||!o)return iE(e,t);const c=o.activeTerminalId,u=ld(o.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??Ys(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:dE(f,t.id))}}function L4(e,t,n,r){const o=ol(e),c=o?gp(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,f=ld(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(m=>m.id===c.id?{...m,root:f,activeTerminalId:u}:m)}:g)}}function O4(e){const t=ol(e),n=t?gp(t):void 0;return n?rE(e,n.activeTerminalId):e}function B4(e,t){const n=ol(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function iy(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(_=>_.id===t);if(c<0)return o;const u=o.tabs.slice(),[f]=u.splice(c,1);if(!f)return o;const g=Math.max(0,Math.min(u.length,n)),m=u.slice();return m.splice(g,0,f),P4(o.tabs,m)?o:{...o,tabs:m}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function j4(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const m=g.tabs.findIndex(C=>C.id===t);if(m<0)return g;const _=g.tabs[m];if(!_)return g;const b=dc(_.root,n);if(!b){const C=g.tabs.filter((N,L)=>L!==m);return{...g,tabs:C}}const w={..._,root:b,activeTerminalId:bi(b)[0]??_.activeTerminalId},x=g.tabs.slice();return x[m]=w,{...g,tabs:x}});const u=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const m=g.tabs.findIndex(N=>bi(N.root).includes(r));if(m<0)return g;const _=g.tabs[m];if(!_)return g;const b={type:"pane",terminalId:n},w={type:"split",direction:u,ratio:.5,first:f?b:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:b},x=ld(_.root,r,w),C=g.tabs.slice();return C[m]={..._,root:x,activeTerminalId:n},{...g,tabs:C,activeTabId:_.id}}),oE({...e,workspaces:c})}function nE(e,t,n,r){let o=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(W=>W.id===t);if(A>=0){o=L,c=A;break}}if(o<0)return e;const u=e.workspaces[o],f=u.tabs[c],g=bi(f.root);if(!g.includes(n))return e;if(g.length===1)return iy(e,t,r);const m=dc(f.root,n);if(!m)return e;const _={...f,root:m,activeTerminalId:bi(m)[0]??f.activeTerminalId},b=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},x=u.tabs.slice();x[c]=_;const C=Math.max(0,Math.min(x.length,r));x.splice(C,0,w);const N=e.workspaces.slice();return N[o]={...u,tabs:x,activeTabId:w.id},{...e,workspaces:N}}function sE(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=lE(e.workspaces,t),c=e.workspaces.find(m=>m.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:iy(e,t,r);const u=bi(o.tab.root),f=u.map(m=>e.terminals[m]).find(Boolean),g=e.workspaces.map(m=>{if(m.id===o.workspace.id)return ll({...m,tabs:m.tabs.filter(_=>_.id!==t)});if(m.id===n){const _=m.tabs.slice(),b=Math.max(0,Math.min(_.length,r));return _.splice(b,0,o.tab),{...m,defaultCwd:m.defaultCwd??Ys(f?.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(w=>!u.includes(w)),tabs:_,activeTabId:o.tab.id}}return m});return{...e,workspaces:g,activeWorkspaceId:n}}function I4(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(x=>x.id===r),u=lE(e.workspaces,t);if(!c||!u||!e.terminals[n]||!bi(u.tab.root).includes(n))return e;if(u.workspace.id===r)return nE(e,t,n,o);if(bi(u.tab.root).length===1)return sE(e,t,r,o);const g=dc(u.tab.root,n);if(!g)return e;const m={...u.tab,root:g,activeTerminalId:bi(g)[0]??u.tab.activeTerminalId},_=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:_.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},w=e.workspaces.map(x=>{if(x.id===u.workspace.id)return ll({...x,tabs:x.tabs.map(C=>C.id===t?m:C)});if(x.id===r){const C=x.tabs.slice(),N=Math.max(0,Math.min(C.length,o));return C.splice(N,0,b),{...x,defaultCwd:x.defaultCwd??Ys(_.cwd),detachedTerminalIds:x.detachedTerminalIds.filter(L=>L!==n),tabs:C,activeTabId:b.id}}return x});return{...e,workspaces:w,activeWorkspaceId:r}}function P4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function z4(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function H4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>{let f=!1;const g=u.tabs.map(m=>m.id!==t||m.title===r?m:(o=!0,f=!0,{...m,title:r}));return f?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function U4(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>hc(c.root,t))),r=n?.tabs.find(o=>hc(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function F4(e,t,n){const r=ol(e),o=r?gp(r):void 0;if(!r||!o)return e;const c=W_(o.root,t,mE(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===r.id?{...u,tabs:u.tabs.map(f=>f.id===o.id?{...f,root:c}:f)}:u)}}function hf(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,f=!!(n&&n.some(b=>fE(b))||t&&t.some(b=>pE(b)));let g=V4(t,n,c,u);g.length===0&&(g=[vp()]);const m=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,_=m??g[0]?.id??mp;for(const b of e)if(!u.has(b.id)){if(f)g=G4(g,_,b.id,b);else{const w=hE(b);g=Q4(g,_,w,b)}u.add(b.id)}return{workspaces:g.map(b=>ll(Z4(b,o))),activeWorkspaceId:m,terminals:o}}function Yo(e){return bi(e.root)}function $f(e){return q_(e.root)}function Kf(e){return ny([...e.tabs.flatMap(t=>bi(t.root)),...e.detachedTerminalIds])}function ov(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=$_(o.root);return c?[{...o,root:c}]:[]});return ll({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function $4(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>hc(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function K4(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function rE(e,t){const n={...e.terminals};return delete n[t],aE(e,t,n)}function W4(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??Y4(e,t)?.id??X4(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??mp,o=e.workspaces.find(c=>c.id===r);return!o||!uE(o,t)?e:aE(e,t,{...e.terminals},{detachToWorkspaceId:r})}function aE(e,t,n,r={}){let o=e.workspaces.map(u=>{const f=[];for(const g of u.tabs){const m=dc(g.root,t);if(!m)continue;const _=bi(m),b=_.includes(g.activeTerminalId)?g.activeTerminalId:_[0];b&&f.push({...g,root:m,activeTerminalId:b})}return ll({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?cE(u,t,n[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function q4(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const f=U_(u.root,t);if(!f)continue;const g=bi(f),m=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];m&&c.push({...u,root:f,activeTerminalId:m})}return ll({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function V4(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)fE(c)&&o.push(Rx(c,n,r));if(o.length>0)return o}return[Rx({...vp(),tabs:e??[]},n,r)]}function Rx(e,t,n){const r=[];for(const c of e.tabs){if(!pE(c))continue;const u=F_(c.root,t);if(!u)continue;const f=bi(u);for(const m of f)n.add(m);const g=f.includes(c.activeTerminalId)?c.activeTerminalId:f[0];g&&r.push({...c,root:u,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return ll({...e,defaultCwd:Ys(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function oE(e){return ol(e)?e:{...e,workspaces:[vp()],activeWorkspaceId:mp}}function ol(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function gp(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function lE(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function Y4(e,t){return e.workspaces.find(n=>n.tabs.some(r=>hc(r.root,t)))}function X4(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function G4(e,t,n,r){return e.map(o=>o.id===t?cE(o,n,r):o)}function cE(e,t,n){return uE(e,t)?{...e,defaultCwd:e.defaultCwd??Ys(n?.cwd),detachedTerminalIds:ny([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function uE(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<gc}function dE(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function Z4(e,t){if(e.defaultCwd)return e;const n=Kf(e).find(o=>!!t[o]),r=n?Ys(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function vp(){return{id:mp,title:C4,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ll(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Ys(e.defaultCwd),detachedTerminalIds:ny(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function Q4(e,t,n,r){const o=bi(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Ys(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function hE(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function ld(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:ld(e.first,t,n),second:ld(e.second,t,n)}}function dc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=dc(e.first,t),r=dc(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function U_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=U_(e.first,t),r=U_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function F_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=F_(e.first,t),r=F_(e.second,t);return n&&r?{...e,ratio:mE(e.ratio),first:n,second:r}:n??r}function $_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=$_(e.first),n=$_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function fE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function pE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&K_(t.root)}function K_(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&K_(t.first)&&K_(t.second):!1}function W_(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const c=W_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=W_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function mE(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Ys(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ny(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function hc(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:hc(e.first,t)||hc(e.second,t)}function bi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...bi(e.first),...bi(e.second)]}function q_(e){return e.type==="pane"||e.type==="editor"?1:q_(e.first)+q_(e.second)}const _r=new Map,cd=new Map,ud=new Map,dd=new Map,hd=new Map,V_=new Set;let gE=0;function ho(e){return e??"__local__"}function J4(e){return{agentId:e,state:k4(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Ct(e){const t=ho(e);let n=_r.get(t);return n||(n=J4(e),_r.set(t,n)),n}function e6(e){return _r.get(ho(e))??null}function vE(e,t){const n=ho(e);let r=cd.get(n);return r||(r=new Set,cd.set(n,r)),r.add(t),()=>{r.delete(t)}}function t6(e){const t=ho(e),n=cd.get(t);if(n)for(const r of Array.from(n))r()}function Sc(e,t,n=!0){const r=_r.get(ho(e)),o=n&&Nx(r)!==Nx(t);_r.set(ho(e),t),t6(e),o&&ry()}function Y_(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function sy(e,t){const n=e.state.workspaces.find(u=>u.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const u of n.tabs)for(const f of bi(u.root))r.add(f);let o=0,c=0;for(const u of r)Y_(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(c+=1);return{workingTerminalCount:o,unreadCompletionCount:c}}function Nx(e){return e?e.state.workspaces.map(t=>{const n=sy(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function _E(e){return!!(e&&e.state.workspaces.some(t=>{const n=sy(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function ry(){gE+=1;for(const e of Array.from(V_))e()}function i6(e){return V_.add(e),()=>{V_.delete(e)}}function Mx(){return gE}function n6(e,t){return sy(Ct(e),t)}const X_=new Set;function s6(e){return X_.add(e),()=>{X_.delete(e)}}function Ka(e,t){const n=Ct(e),r=ho(e),o=a6(n.state,t);t.type==="workspace.hydrated"&&(ud.delete(r),dd.delete(r),hd.delete(r));const c=T4(n.state,t);let u=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const _=n.state.terminals[t.terminal.id],b=f6(r),w=p6(r),x=o6(r);if(t.terminal.agentStatus){const C=t.terminal.agentStatus.state,N=t.terminal.agentStatus.sessionId,L=x.get(t.terminal.id),A=!!(_&&(_.currentCommand!==t.terminal.currentCommand||_.agentStatus?.provider!==t.terminal.agentStatus.provider||r6(L,N)));A&&(w.delete(t.terminal.id),b.delete(t.terminal.id),x.delete(t.terminal.id)),N&&x.set(t.terminal.id,N),t.notifyCompletion===!0&&(C==="working"?(w.add(t.terminal.id),b.delete(t.terminal.id)):C==="unknown"&&t.terminal.activity==="busy"&&b.add(t.terminal.id)),!A&&(C==="done"||C==="stopped")&&(w.has(t.terminal.id)||b.has(t.terminal.id))&&(f=Ox(c,t.terminal.id,_?.currentCommand??null,C==="stopped"?"stopped":"finished"),w.delete(t.terminal.id),b.delete(t.terminal.id)),C==="idle"&&(w.delete(t.terminal.id),b.delete(t.terminal.id))}else{_?.agentStatus&&(w.delete(t.terminal.id),x.delete(t.terminal.id));const C=_?.activity==="busy",N=t.terminal.activity==="busy",L=t.terminal.activity==="idle";t.notifyCompletion===!0&&N&&b.add(t.terminal.id),t.notifyCompletion===!0&&C&&L&&b.has(t.terminal.id)&&(f=Ox(c,t.terminal.id,_?.currentCommand??null,"finished")),(L||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(f){const C=bE(c,t.terminal.id);C&&(C.workspace.activeTabId!==C.tab.id||C.workspace.id!==c.activeWorkspaceId)&&(u.has(t.terminal.id)||(u=new Set(u),u.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),w.delete(t.terminal.id),x.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let _=null;if(t.type==="tab.selected")_=l6(c,t.tabId)?.tab??null;else{const w=c.workspaces.find(x=>x.id===t.workspaceId);_=w?.tabs.find(x=>x.id===w.activeTabId)??null}const b=_?bi(_.root):[];if(b.some(w=>u.has(w))){const w=new Set(u);for(const x of b)w.delete(x);u=w}}const g=c!==n.state,m=u!==n.unreadCompletions;if((g||m)&&Sc(e,{...n,state:c,unreadCompletions:u},o||m),m&&_p(),f)for(const _ of Array.from(X_))_({agentId:e,...f})}function r6(e,t){return e!==void 0&&t!==void 0&&e!==t}function a6(e,t){switch(t.type){case"terminal.updated":return Y_(e.terminals[t.terminal.id])!==Y_(t.terminal);case"workspace.renamed":case"workspace.defaultCwdChanged":case"workspace.reordered":case"editor.split":case"editor.closed":case"pane.selected":case"pane.resized":case"tab.renamed":case"tab.reordered":return!1;default:return!0}}function o6(e){let t=hd.get(e);return t||(t=new Map,hd.set(e,t)),t}function bE(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(bi(r.root).includes(t))return{workspace:n,tab:r};return null}function l6(e,t){for(const n of e.workspaces){const r=n.tabs.find(o=>o.id===t);if(r)return{workspace:n,tab:r}}return null}const G_=new Set;function c6(e){return G_.add(e),()=>{G_.delete(e)}}function u6(){let e=0;for(const t of _r.values())e+=t.unreadCompletions.size;return e}function _p(){for(const e of Array.from(G_))e()}function Ax(e,t){const n=Ct(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Sc(e,{...n,unreadCompletions:r}),_p()}function Lx(e,t){const n=Ct(e);t!==n.state&&Sc(e,{...n,state:t})}function lv(e,t){const n=Ct(e),r=t(n.editors);r!==n.editors&&Sc(e,{...n,editors:r},!1)}function Wa(e,t,n){const r=Ct(e);r.loaded===t&&r.error===n||Sc(e,{...r,loaded:t,error:n},!1)}function ku(e,t,n){const r=Ct(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Sc(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1)}function d6(e){const t=Ct(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function h6(e){const t=ho(e),n=_r.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=_E(n);_r.delete(t),cd.delete(t),ud.delete(t),dd.delete(t),hd.delete(t),r&&_p(),o&&ry()}function cv(){let e=!1,t=!1;for(const n of _r.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),_E(n)&&(t=!0)}_r.clear(),cd.clear(),ud.clear(),dd.clear(),hd.clear(),e&&_p(),t&&ry()}function f6(e){let t=ud.get(e);return t||(t=new Set,ud.set(e,t)),t}function p6(e){let t=dd.get(e);return t||(t=new Set,dd.set(e,t)),t}function Ox(e,t,n,r){const o=bE(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function Z_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of Yo(e)){const f=t[u];if(f){if(f.status==="exited"){c=!0,n=!0;continue}f.activity==="busy"?(r=!0,n=!0,!o&&f.currentCommand&&(o=f.currentCommand)):f.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function ay(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Q_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function m6(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function g6({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,onSelectTab:u,onCreateTab:f,onToggleWorkspaces:g,onCloseTerminals:m,onReattachTerminal:_,onDeleteTerminal:b,onSplitVertical:w,onSplitHorizontal:x,onRenameTab:C,onToggleFavorite:N,onOpenFavorites:L,activePaneAvailable:A}){const[W,U]=v.useState(null),[F,K]=v.useState(!1),[oe,P]=v.useState(null),te=v.useRef(null),Z=e.findIndex(R=>R.id===t),me=Z>=0?e[Z]:e[0]??null,ee=me?Z_(me,n):null,Y=me?$f(me):0,X=me?Q_(me,n):"No tab";v.useEffect(()=>{te.current?.focus(),te.current?.select()},[W?.tabId]),v.useEffect(()=>{if(!F)return;const R=I=>{I.key==="Escape"&&K(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[F]),v.useEffect(()=>{F&&e.length===0&&K(!1)},[F,e.length]);function V(R,I){U({tabId:R,title:I})}function ne(){if(!W)return;const R=W.title.trim();R&&C(W.tabId,R),U(null)}function O(){return d.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${zM()}`,onClick:w,disabled:!A,children:d.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${HM()}`,onClick:x,disabled:!A,children:d.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return d.jsxs(d.Fragment,{children:[d.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[d.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:g,children:d.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}),d.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:X,onClick:()=>K(!0),disabled:e.length===0,children:[ee?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":ee.state,"aria-hidden":"true",title:ay(ee)}):null,d.jsx("span",{children:X}),d.jsxs("small",{children:[Z>=0?Z+1:0,"/",e.length||0,Y>1?` / ${Y}`:""]})]}),d.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,I)=>{const de=Yo(R),ge=$f(R),M=Q_(R,n),q=R.id===t,he=W?.tabId===R.id,J=Z_(R,n),ye=r?.has(R.id)??!1;return d.jsxs(Ot.Fragment,{children:[d.jsx(Bx,{index:I}),d.jsx(v6,{tab:R,active:q,editing:he,title:M,paneCount:ge,terminalIds:de,canClose:e.length>1,editValue:he?W.title:null,editInputRef:he?te:null,activity:J,unread:ye,favorite:o?.has(R.id)??!1,onSelect:()=>u(R.id),onBeginRename:()=>V(R.id,M),onCloseAll:()=>m(de),onCommitRename:ne,onCancelRename:()=>U(null),onRenameChange:ve=>U({tabId:R.id,title:ve}),onToggleFavorite:()=>N?.(R)})]},R.id)}),d.jsx(Bx,{index:e.length}),d.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),d.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>L?.(),children:"★"}),(c?.length??0)>0?d.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(c??[]).map(R=>d.jsx(b6,{terminal:R,onReattach:()=>_?.(R.id),onDelete:()=>P(R)},R.id))}):null]}),d.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),A?O():null]}),F?d.jsx(_6,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:W,editInputRef:te,onClose:()=>K(!1),onSelectTab:R=>{u(R),K(!1)},onCreateTab:()=>{f(),K(!1)},onBeginRename:V,onCloseTerminals:R=>{m(R),K(!1)},onCommitRename:ne,onCancelRename:()=>U(null),onRenameChange:(R,I)=>U({tabId:R,title:I}),onToggleFavorite:N,onOpenFavorites:L,onReattachTerminal:R=>{_?.(R),K(!1)},onDeleteTerminal:R=>{P(R),K(!1)}}):null,oe?d.jsx(y6,{terminal:oe,onCancel:()=>P(null),onConfirm:()=>{b?.(oe.id),P(null)}}):null]})}function v6({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:f,activity:g,unread:m,favorite:_,onSelect:b,onBeginRename:w,onCloseAll:x,onCommitRename:C,onCancelRename:N,onRenameChange:L,onToggleFavorite:A}){const{attributes:W,listeners:U,setNodeRef:F,transform:K,isDragging:oe}=gb({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),P={transform:ta.Translate.toString(K),opacity:oe?.4:void 0,zIndex:oe?2:void 0};return d.jsxs("div",{ref:F,className:"terminal-tab","data-active":t,"data-dragging":oe,"data-unread":m?"true":void 0,style:P,...W,...U,children:[g?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:ay(g)}):null,n&&f&&u!==null?d.jsxs("form",{className:"terminal-tab-editor",onSubmit:te=>{te.preventDefault(),C()},children:[d.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:u,onBlur:C,onChange:te=>L(te.target.value),onKeyDown:te=>{if(te.key==="Enter"){te.preventDefault(),C();return}te.key==="Escape"&&(te.preventDefault(),N())}}),d.jsx("small",{children:o})]}):d.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:b,onDoubleClick:te=>{te.preventDefault(),w()},children:[d.jsx("span",{children:r}),d.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:d.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":_?`Remove ${r} from favorites`:`Add ${r} to favorites`,title:_?"Remove from favorites":"Add to favorites",onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),A()},children:_?"★":"☆"}),c&&!n?d.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),x()},children:"x"}):null]})}function _6({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:u,editInputRef:f,onClose:g,onSelectTab:m,onCreateTab:_,onBeginRename:b,onCloseTerminals:w,onCommitRename:x,onCancelRename:C,onRenameChange:N,onToggleFavorite:L,onOpenFavorites:A,onReattachTerminal:W,onDeleteTerminal:U}){const F=v.useRef(null);return v.useEffect(()=>{F.current?.scrollIntoView?.({block:"nearest"})},[t]),d.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:g,children:d.jsxs("section",{className:"mobile-tab-sheet",onClick:K=>K.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),d.jsxs("small",{children:[e.length," open"]})]}),d.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[d.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:_,children:"+"}),d.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{g(),A?.()},children:"★"}),d.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:g,children:"×"})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((K,oe)=>{const P=Yo(K),te=$f(K),Z=Q_(K,n),me=K.id===t,ee=u?.tabId===K.id,Y=Z_(K,n),X=r?.has(K.id)??!1,V=o?.has(K.id)??!1;return d.jsxs("div",{ref:me?F:null,className:"mobile-tab-sheet-row","data-active":me,"data-unread":X?"true":void 0,children:[ee&&u?d.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ne=>{ne.preventDefault(),x()},children:d.jsx("input",{ref:f,"aria-label":`Rename ${Z}`,value:u.title,onBlur:x,onChange:ne=>N(K.id,ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),x();return}ne.key==="Escape"&&(ne.preventDefault(),C())}})}):d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${Z}`,onClick:()=>m(K.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:oe+1}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:Z}),d.jsx("small",{children:m6(K,n,te,Y)})]}),d.jsxs("span",{className:"mobile-tab-sheet-meta",children:[Y?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":Y.state,"aria-hidden":"true",title:ay(Y)}):null,d.jsx("span",{children:te})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ee?d.jsx("button",{type:"button","aria-label":`Done renaming ${Z}`,onClick:x,children:"Done"}):d.jsx("button",{type:"button","aria-label":`Rename ${Z}`,onClick:()=>b(K.id,Z),children:"Rename"}),ee?null:d.jsx("button",{type:"button","aria-label":V?`Remove ${Z} from favorites`:`Add ${Z} to favorites`,title:V?"Remove from favorites":"Add to favorites",onClick:()=>L?.(K),children:V?"★":"☆"}),e.length>1?d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${Z}`,onClick:()=>w(P),children:"×"}):null]})]},K.id)}),(c?.length??0)>0?d.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[d.jsx("span",{children:"Detached"}),(c??[]).map(K=>{const oe=K.title||K.cwd||K.id.slice(0,8);return d.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${oe}`,onClick:()=>W(K.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:oe}),d.jsx("small",{children:K.cwd})]}),d.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),d.jsx("div",{className:"mobile-tab-sheet-actions",children:d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${oe}`,onClick:()=>U(K),children:"×"})})]},K.id)})]}):null]})]})})}function Bx({index:e}){const{setNodeRef:t,isOver:n}=ep({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return d.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function b6({terminal:e,onReattach:t,onDelete:n}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
55
+ ${e.cwd}
56
+ (detached — click to re-open, × to delete)`;return d.jsxs("span",{className:"terminal-detached-pill",title:o,children:[d.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),d.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function y6({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:"Delete this terminal?"}),d.jsx("span",{children:r}),d.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function yE(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function S6(e,t){return e.reduce((n,r,o)=>{const c=t.get(r);return c&&(n[o]=c),n},Array(e.length))}function Xh(e){return e!==null&&e>=0}function w6(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function x6(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const oy=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const c=yE(t,r,n),u=t[o],f=c[o];return!f||!u?null:{x:f.left-u.left,y:f.top-u.top,scaleX:f.width/u.width,scaleY:f.height/u.height}},Gh={scaleX:1,scaleY:1},C6=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:c,overIndex:u}=e;const f=(t=c[n])!=null?t:r;if(!f)return null;if(o===n){const m=c[u];return m?{x:0,y:n<u?m.top+m.height-(f.top+f.height):m.top-f.top,...Gh}:null}const g=k6(c,o,n);return o>n&&o<=u?{x:0,y:-f.height-g,...Gh}:o<n&&o>=u?{x:0,y:f.height+g,...Gh}:{x:0,y:0,...Gh}};function k6(e,t,n){const r=e[t],o=e[t-1],c=e[t+1];return r?n<t?o?r.top-(o.top+o.height):c?c.top-(r.top+r.height):0:c?c.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const SE="Sortable",wE=Ot.createContext({activeIndex:-1,containerId:SE,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:oy,disabled:{draggable:!1,droppable:!1}});function T6(e){let{children:t,id:n,items:r,strategy:o=oy,disabled:c=!1}=e;const{active:u,dragOverlay:f,droppableRects:g,over:m,measureDroppableContainers:_}=bC(),b=md(SE,n),w=f.rect!==null,x=v.useMemo(()=>r.map(oe=>typeof oe=="object"&&"id"in oe?oe.id:oe),[r]),C=u!=null,N=u?x.indexOf(u.id):-1,L=m?x.indexOf(m.id):-1,A=v.useRef(x),W=!w6(x,A.current),U=L!==-1&&N===-1||W,F=x6(c);Ws(()=>{W&&C&&_(x)},[W,x,C,_]),v.useEffect(()=>{A.current=x},[x]);const K=v.useMemo(()=>({activeIndex:N,containerId:b,disabled:F,disableTransforms:U,items:x,overIndex:L,useDragOverlay:w,sortedRects:S6(x,g),strategy:o}),[N,b,F.draggable,F.droppable,U,x,L,g,w,o]);return Ot.createElement(wE.Provider,{value:K},t)}const E6=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return yE(n,r,o).indexOf(t)},D6=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:c,newIndex:u,previousItems:f,previousContainerId:g,transition:m}=e;return!m||!r||f!==c&&o===u?!1:n?!0:u!==o&&t===g},R6={duration:200,easing:"ease"},xE="transform",N6=ta.Transition.toString({property:xE,duration:0,easing:"linear"}),M6={roleDescription:"sortable"};function A6(e){let{disabled:t,index:n,node:r,rect:o}=e;const[c,u]=v.useState(null),f=v.useRef(n);return Ws(()=>{if(!t&&n!==f.current&&r.current){const g=o.current;if(g){const m=mc(r.current,{ignoreTransform:!0}),_={x:g.left-m.left,y:g.top-m.top,scaleX:g.width/m.width,scaleY:g.height/m.height};(_.x||_.y)&&u(_)}}n!==f.current&&(f.current=n)},[t,n,r,o]),v.useEffect(()=>{c&&u(null)},[c]),c}function L6(e){let{animateLayoutChanges:t=D6,attributes:n,disabled:r,data:o,getNewIndex:c=E6,id:u,strategy:f,resizeObserverConfig:g,transition:m=R6}=e;const{items:_,containerId:b,activeIndex:w,disabled:x,disableTransforms:C,sortedRects:N,overIndex:L,useDragOverlay:A,strategy:W}=v.useContext(wE),U=O6(r,x),F=_.indexOf(u),K=v.useMemo(()=>({sortable:{containerId:b,index:F,items:_},...o}),[b,o,F,_]),oe=v.useMemo(()=>_.slice(_.indexOf(u)),[_,u]),{rect:P,node:te,isOver:Z,setNodeRef:me}=ep({id:u,data:K,disabled:U.droppable,resizeObserverConfig:{updateMeasurementsFor:oe,...g}}),{active:ee,activatorEvent:Y,activeNodeRect:X,attributes:V,setNodeRef:ne,listeners:O,isDragging:R,over:I,setActivatorNodeRef:de,transform:ge}=gb({id:u,data:K,attributes:{...M6,...n},disabled:U.draggable}),M=uD(me,ne),q=!!ee,he=q&&!C&&Xh(w)&&Xh(L),J=!A&&R,ye=J&&he?ge:null,Le=he?ye??(f??W)({rects:N,activeNodeRect:X,activeIndex:w,overIndex:L,index:F}):null,Ne=Xh(w)&&Xh(L)?c({id:u,items:_,activeIndex:w,overIndex:L}):F,Fe=ee?.id,He=v.useRef({activeId:Fe,items:_,newIndex:Ne,containerId:b}),Pe=_!==He.current.items,Ze=t({active:ee,containerId:b,isDragging:R,isSorting:q,id:u,index:F,items:_,newIndex:He.current.newIndex,previousItems:He.current.items,previousContainerId:He.current.containerId,transition:m,wasDragging:He.current.activeId!=null}),E=A6({disabled:!Ze,index:F,node:te,rect:P});return v.useEffect(()=>{q&&He.current.newIndex!==Ne&&(He.current.newIndex=Ne),b!==He.current.containerId&&(He.current.containerId=b),_!==He.current.items&&(He.current.items=_)},[q,Ne,b,_]),v.useEffect(()=>{if(Fe===He.current.activeId)return;if(Fe!=null&&He.current.activeId==null){He.current.activeId=Fe;return}const we=setTimeout(()=>{He.current.activeId=Fe},50);return()=>clearTimeout(we)},[Fe]),{active:ee,activeIndex:w,attributes:V,data:K,rect:P,index:F,newIndex:Ne,items:_,isOver:Z,isSorting:q,isDragging:R,listeners:O,node:te,overIndex:L,over:I,setNodeRef:M,setActivatorNodeRef:de,setDroppableNodeRef:me,setDraggableNodeRef:ne,transform:E??Le,transition:z()};function z(){if(E||Pe&&He.current.newIndex===F)return N6;if(!(J&&!Zf(Y)||!m)&&(q||Ze))return ta.Transition.toString({...m,property:xE})}}function O6(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}It.Down,It.Right,It.Up,It.Left;function B6({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:r=null,getRuntimeStatus:o,onClose:c,onOpen:u,onRemove:f,onReorder:g}){const m=v.useRef(null),[_,b]=v.useState(()=>Date.now()),[w,x]=v.useState("grid"),[C,N]=v.useState(null),L=eC(xf(fb,{activationConstraint:{distance:6}}),xf(pb,{activationConstraint:{delay:180,tolerance:8}})),A=v.useMemo(()=>e.map($s),[e]),W=v.useMemo(()=>new Map(e.map(P=>[$s(P),o?.(P)??null])),[e,o,_]);v.useEffect(()=>{const P=window.setInterval(()=>b(Date.now()),3e4);return()=>window.clearInterval(P)},[]),v.useEffect(()=>{const P=te=>{if(te.key==="Escape"){te.preventDefault(),te.stopImmediatePropagation(),c();return}const Z=te.target;if((Z instanceof HTMLInputElement||Z instanceof HTMLTextAreaElement)&&m.current?.contains(Z)||te.ctrlKey||te.altKey||te.metaKey)return;const me=Number.parseInt(te.key,10)-1;me>=0&&me<Math.min(9,e.length)&&(te.preventDefault(),te.stopImmediatePropagation(),u(e[me]))};return window.addEventListener("keydown",P,!0),()=>window.removeEventListener("keydown",P,!0)},[e,c,u]);const U=P=>{N(null);const te=String(P.active.id),Z=P.over?String(P.over.id):null;if(!Z||te===Z)return;const me=e.find(Y=>$s(Y)===te),ee=e.find(Y=>$s(Y)===Z);me&&ee&&g(me,ee)},F=P=>N({activeId:String(P.active.id),overId:null}),K=P=>{const te=String(P.active.id),Z=P.over?String(P.over.id):null;N(me=>me?.activeId===te&&me.overId===Z?me:{activeId:te,overId:Z})},oe=C?e.find(P=>$s(P)===C.activeId)??null:null;return d.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:c,children:d.jsxs("section",{ref:m,className:"favorite-tabs-dialog",onClick:P=>P.stopPropagation(),children:[d.jsxs("header",{className:"favorite-tabs-header",children:[d.jsxs("div",{children:[d.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",d.jsx("span",{children:e.length})]}),d.jsx("p",{children:"Press 1–9 to open a favorite"})]}),d.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":w==="grid",onClick:()=>x("grid"),children:"▦"}),d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":w==="list",onClick:()=>x("list"),children:"☷"}),d.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:c,children:"×"})]})]}),d.jsxs(_C,{sensors:L,collisionDetection:RD,onDragStart:F,onDragOver:K,onDragEnd:U,onDragCancel:()=>N(null),children:[d.jsxs("div",{className:"favorite-tabs-list","data-view":w,children:[r?d.jsx("p",{className:"favorite-tabs-error",role:"alert",children:r}):null,e.length===0?d.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):d.jsx(T6,{items:A,strategy:w==="grid"?oy:C6,children:e.map((P,te)=>d.jsx(j6,{favorite:P,index:te,busy:n,unavailable:t?.has($s(P))??!1,runtimeStatus:W.get($s(P))??null,now:_,isDropTarget:C?.overId===$s(P)&&C.activeId!==$s(P),onOpen:u,onRemove:f},$s(P)))})]}),d.jsx(IR,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:oe?d.jsx(I6,{favorite:oe}):null})]})]})})}const j6=v.memo(function({favorite:t,index:n,busy:r,unavailable:o,runtimeStatus:c,now:u,isDropTarget:f,onOpen:g,onRemove:m}){const _=$s(t),{attributes:b,listeners:w,setActivatorNodeRef:x,setNodeRef:C,transform:N,transition:L,isDragging:A}=L6({id:_,disabled:r,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),W={transform:ta.Transform.toString(N),transition:L,zIndex:A?1:void 0,opacity:A?.16:void 0};return d.jsxs("div",{ref:C,className:"favorite-tab-row","data-dragging":A||void 0,"data-drop-target":f||void 0,style:W,children:[d.jsx("button",{ref:x,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:U=>U.stopPropagation(),...b,...w,children:"⋮⋮"}),d.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>g(t),disabled:r||o,title:o?"Server is no longer registered":void 0,children:[d.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),c&&!o?d.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${c.state}`,title:"Last observed terminal status",children:[d.jsx("i",{"aria-hidden":"true"}),P6(c.state),c.lastActivityAt?` · ${z6(c.lastActivityAt,u)}`:""]}):null]}),d.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(U=>d.jsx("img",{src:`/brand/${U}.webp`,alt:"","aria-hidden":"true"},U)),d.jsx("em",{children:t.paneCount})]})]}),d.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:r,onClick:()=>m(t),children:"×"})]})}),I6=v.memo(function({favorite:t}){return d.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[d.jsx("span",{className:"favorite-tab-index",children:"★"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),d.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(n=>d.jsx("img",{src:`/brand/${n}.webp`,alt:""},n)),d.jsx("em",{children:t.paneCount})]})]})});function $s(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function P6(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function z6(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"recently";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return"now";const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const c=Math.floor(o/60);return c<24?`${c}h ago`:`${Math.floor(c/24)}d ago`}function H6({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return d.jsxs("aside",{className:`upload-toast upload-toast-${W6(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[d.jsxs("header",{className:"upload-toast-header",children:[d.jsx("strong",{children:e.length===1?ff(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),d.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),d.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>d.jsx(U6,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function U6({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return d.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":ff(e),children:[d.jsxs("div",{className:"upload-queue-item-header",children:[d.jsx("strong",{children:ff(e)}),d.jsxs("div",{className:"upload-queue-actions",children:[f?d.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?d.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,d.jsx("button",{type:"button","aria-label":`Dismiss ${ff(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?d.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?d.jsx(F6,{toast:e}):null,c&&"message"in e&&e.message?d.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?d.jsx($6,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?d.jsx("p",{children:e.message}):null]})}function F6({toast:e}){const t=e.percent===null?q6(e.loaded):`${e.percent}%`;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"upload-progress-row",children:[d.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),d.jsx("span",{children:t})]}),d.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:d.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function $6({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?d.jsx("ul",{className:"upload-result-list",children:c.map((u,f)=>d.jsx(K6,{result:u},`${u.relativePath}-${f}`))}):null,e.results.length>c.length?d.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function K6({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return d.jsxs("li",{"data-status":e.status,children:[d.jsx("span",{className:"upload-result-path",children:t}),n?d.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?d.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function ff(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function W6(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function q6(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function V6({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function f(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return d.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:f,children:[d.jsxs("header",{className:"completion-toast-header",children:[d.jsxs("div",{className:"completion-toast-copy",children:[d.jsx("strong",{children:r.tabTitle}),d.jsx("span",{children:c})]}),d.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),d.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const Y6=Ou(0,0,1,1),Xr=1e-6;function X6(e){return CE(e).map(t=>t.terminalId)}function CE(e){return Lu(e,Y6).sort(J6).map((t,n)=>({...t,index:n+1}))}function G6(e,t,n){const r=CE(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>Q6(o,u,n)).filter(u=>u!==null).sort(eI)[0]?.entry.terminalId??null:null}function Z6(e,t){return!Number.isInteger(t)||t<1?null:X6(e)[t-1]??null}function Lu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=tI(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Lu(e.first,Ou(t.left,t.top,o,t.bottom)),...Lu(e.second,Ou(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...Lu(e.first,Ou(t.left,t.top,t.right,r)),...Lu(e.second,Ou(t.left,r,t.right,t.bottom))]}function Q6(e,t,n){const r=e.bounds,o=t.bounds,c=jx(r.left,r.right,o.left,o.right),u=jx(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Xr||u<=Xr?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"right":return o.centerX<=r.centerX+Xr||u<=Xr?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"up":return o.centerY>=r.centerY-Xr||c<=Xr?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Xr||c<=Xr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function J6(e,t){return ic(e.bounds.top,t.bounds.top)||ic(e.bounds.left,t.bounds.left)}function eI(e,t){return ic(e.primaryDistance,t.primaryDistance)||ic(e.perpendicularDistance,t.perpendicularDistance)||ic(t.overlap,e.overlap)||ic(e.entry.index,t.entry.index)}function ic(e,t){const n=e-t;return Math.abs(n)<=Xr?0:n}function jx(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function Ou(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function tI(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const Ix="nterminal.terminalWorkspaces.v2",kE="nterminal.sidebarCollapsed.v1",iI=75,Px=wC.map(e=>e.url),nI=wC[0].url,sI=6;function rI({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:f}){const g=v.useMemo(()=>e??Vf(),[e]),m=v.useMemo(()=>t??dr(null),[t]),_=v.useMemo(()=>DI(n),[n]),b=v.useMemo(()=>S=>vE(n,S),[n]),w=v.useMemo(()=>()=>Ct(n),[n]),x=v.useSyncExternalStore(b,w,w),C=x.state,N=x.editors,L=!x.loaded,A=x.error,[W,U]=v.useState(!1),[F,K]=v.useState(()=>BI()),[oe,P]=v.useState("servers"),[te,Z]=v.useState(!1),[me,ee]=v.useState(!1),[Y,X]=v.useState([]),[V,ne]=v.useState(!1),[O,R]=v.useState(null),[I,de]=v.useState(null),[ge,M]=v.useState(null),q=v.useMemo(()=>dr(ge?.agentId??null),[ge?.agentId]),he=v.useMemo(()=>dr(I?.agentId??null),[I?.agentId]),J=v.useSyncExternalStore(GM,Zw,Zw);v.useSyncExternalStore(Hu,Gw,Gw);const[ye,ve]=v.useState(0),[Le,Ne]=v.useState(null),[Fe,He]=v.useState(()=>[null]),[Pe,Ze]=v.useState(()=>({[Kt]:"Local"})),[E,z]=v.useState(0),[we,Ae]=v.useState(()=>[n]),[ie,pe]=v.useState(()=>new Set),[Te,De]=v.useState({}),[Ee,je]=v.useState(null),Ve=v.useRef(0),$e=v.useRef(0),[St,wt]=v.useState(null),[Nt,_t]=v.useState(null),Pt=v.useRef(null),oi=v.useRef(0),ke=v.useRef(null),Ge=v.useRef(null),st=v.useRef(null),et=v.useRef(null),gt=v.useRef([]),ct=v.useRef(0),mn=v.useRef(!1),li=v.useRef(0),le=v.useRef(0),ze=v.useRef([]),ut=v.useRef(null),at=v.useRef(()=>{}),[Bt,Qt]=v.useState(null),Si=eC(xf(fb,{activationConstraint:{distance:8}}),xf(pb,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>ZM(g),[g]);function Ii(S){const T=S.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){Qt({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&Qt({tabId:T.sourceTabId,terminalId:T.terminalId})}}function ni(S){Qt(null);const T=S.active.data.current,B=S.over?.data.current;if(!(!T||!B||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){rt({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){rt({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){rt({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){rt({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function hi(){Qt(null)}const lt=C.workspaces.find(S=>S.id===C.activeWorkspaceId)??C.workspaces[0],xt=lt?.tabs.find(S=>S.id===lt.activeTabId)??lt?.tabs[0],fi=xt?.activeTerminalId??null,Jt=fi?C.terminals[fi]:void 0,Vi=wI("(max-width: 760px)"),gn=v.useMemo(()=>xt?Wf(xt.root):[],[xt]),Yi=lt&&xt?Bu(n,lt.id,xt.id):null,pi=xt?TE(gn,xt.activeTerminalId,Yi?Te[Yi]:void 0):null,an=Vi&&gn.length>1,Ni=v.useMemo(()=>(lt?.detachedTerminalIds??[]).flatMap(S=>{const T=C.terminals[S];return T?[T]:[]}),[lt?.detachedTerminalIds,C.terminals]),wi=v.useMemo(()=>{const S=new Set;for(const T of lt?.tabs??[])Yo(T).some(B=>x.unreadCompletions.has(B))&&S.add(T.id);return S},[lt?.tabs,x.unreadCompletions]);v.useSyncExternalStore(i6,Mx,Mx);const[xi,is]=v.useState([]),wn=v.useRef([]),xs=v.useRef(null),[Cs,ks]=v.useState(null),[on,Xs]=v.useState(null),[$n,Ts]=v.useState([]),[xn,Gs]=v.useState(()=>Jo()),Ht=v.useRef(0),aa=v.useRef(n),br=v.useRef(Px),Wt=v.useRef(xn),Kn=v.useRef(()=>{});Kn.current=Bs,at.current=So;const ln=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();Ts(S.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Ts([])}},[g]),yr=v.useCallback(S=>{Ze(T=>{const B={...T};for(const G of S)B[gf(G.agentId)]=G.label;return uv(T,B)?T:B})},[]);v.useEffect(()=>{const S=le.current+1;le.current=S;const T=li.current;g.getFavorites().then(B=>{S!==le.current||T!==li.current||(Rs(B.favorites,B.revision),Ns(B.favorites,n,C))}).catch(()=>{})},[g]),v.useEffect(()=>{Ns(gt.current,n,C)},[n,Pe]),v.useEffect(()=>{Ae(S=>S.some(T=>vi(T,n))?S:[...S,n])},[n]);const Sr=v.useCallback(S=>{const T=Ct(S),B=dr(S);for(const G of Object.keys(T.state.terminals))Xl(B.createWebSocketUrl(G)),xu(G),Yl(G);h6(S),Ae(G=>G.filter(ae=>!vi(ae,S))),pe(G=>{const ae=`${mf(S)}:`;let ce=!1;const Se=new Set;for(const Oe of G){if(Oe.startsWith(ae)){ce=!0;continue}Se.add(Oe)}return ce?Se:G}),De(G=>{const ae=`${mf(S)}:`;let ce=!1;const Se={};for(const[Oe,Ie]of Object.entries(G)){if(Oe.startsWith(ae)){ce=!0;continue}Se[Oe]=Ie}return ce?Se:G})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(T=>{if(S)return;const B=T.name?.trim()||"Local";Ze(G=>{const ae={...G,[Kt]:B};return uv(G,ae)?G:ae})}).catch(()=>{}),g.listAgents().then(T=>{if(!S){const B=T.agents.map(ce=>ce.id),G=sM(T.serverOrder,T.agents);Ze(ce=>{const Se={[Kt]:ce[Kt]??"Local"};for(const Oe of T.agents)Se[Oe.id]=Oe.name;return uv(ce,Se)?ce:Se}),n!==null&&!B.includes(n)&&(Sr(n),r?.(null));const ae=et.current;ae&&ae.serverId!==Kt&&!B.includes(ae.serverId)&&(et.current=null,R(`${ae.serverName} is no longer registered.`),ee(!0)),He(G)}}).catch(()=>{}),()=>{S=!0}},[n,g,Sr,r,E]);const wr=v.useCallback(S=>{Sr(S),z(T=>T+1),vi(S,aa.current)&&r?.(null)},[Sr,r]);v.useEffect(()=>{He(S=>S.some(T=>vi(T,n))?S:[...S,n])},[n]),v.useEffect(()=>{aa.current=n},[n]),v.useEffect(()=>{Ne(null)},[n]),v.useEffect(()=>{const S=ke.current;if(!S)return;if(!vi(S.agentId,n)){ke.current=null;return}if(!x.loaded||C.workspaces.length===0)return;ke.current=null;const T=S.edge==="first"?C.workspaces[0]:C.workspaces[C.workspaces.length-1];T&&T.id!==C.activeWorkspaceId&&rt({type:"workspace.selected",workspaceId:T.id})},[n,x.loaded,C.activeWorkspaceId,C.workspaces]),v.useEffect(()=>{const S=Ge.current;if(S){if(!vi(S.agentId,n)){Ge.current=null;return}x.loaded&&(Ge.current=null,C.workspaces.some(T=>T.id===S.workspaceId)&&rt({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,x.loaded,C.workspaces]),v.useEffect(()=>{const S=st.current;if(S){if(!vi(S.agentId,n)){st.current=null;return}x.loaded&&(st.current=null,x.error||Pi())}},[n,x.error,x.loaded]),v.useEffect(()=>{const S=et.current;if(!(!S||!vi(S.serverId===Kt?null:S.serverId,n)||!x.loaded)){if(et.current=null,x.error){R(`Could not reach ${S.serverName}.`),ee(!0);return}ns(S)}},[n,x.loaded]),v.useEffect(()=>{wo()},[n,x.loaded,C]),v.useEffect(()=>{const S=()=>{const G=CI();G&&at.current(G)},T=G=>{const ae=kI(G.data);ae&&at.current(ae)},B=G=>{const ae=tp(G.detail);ae&&at.current(ae)};return S(),window.addEventListener("hashchange",S),window.addEventListener(_v,B),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",S),window.removeEventListener(_v,B),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{ln()},[ln]),v.useEffect(()=>AC(()=>Gs(Jo())),[]),v.useEffect(()=>{const S=T=>{Kn.current(T)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{br.current=$n.length>0?$n:Px},[$n]),v.useEffect(()=>{Wt.current=xn},[xn]),v.useEffect(()=>{if(!x.loaded||!lt||!xt)return;const S=Bu(n,lt.id,xt.id);pe(T=>{if(T.has(S))return T;const B=new Set(T);return B.add(S),B})},[n,x.loaded,lt?.id,xt?.id]),v.useEffect(()=>()=>{as()},[]),v.useEffect(()=>{const S=ON(g),T=IN(g);return()=>{S(),T()}},[g]),v.useEffect(()=>s6(S=>{const T=Ct(S.agentId).state,B=T.workspaces.flatMap(Se=>Se.tabs).find(Se=>Se.id===S.tabId),G=T.terminals[S.terminalId],ae=B?.title?.trim()||G?.title||S.commandName||"terminal",ce=document.visibilityState==="visible"&&vi(S.agentId,aa.current)&&S.tabId===EI(T);if(ce||DN({agentId:S.agentId,tabTitle:ae,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!ce&&document.visibilityState==="visible"&&Wt.current.enabled){const Se=Ht.current+1;Ht.current=Se;const Oe=br.current;ks({id:Se,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:ae,commandName:S.commandName,outcome:S.outcome,assetSrc:Oe[Math.floor(Math.random()*Oe.length)]??nI})}}),[]),v.useEffect(()=>{if(!Cs||xn.persistUntilDismissed)return;const S=window.setTimeout(()=>{ks(T=>T?.id===Cs.id?null:T)},xn.durationSeconds*1e3);return()=>window.clearTimeout(S)},[Cs,xn]),v.useEffect(()=>{jI(F),F&&xr()},[F]),v.useEffect(()=>{let S=!1;async function T(){if(!Ct(n).loaded){Wa(n,!1,null);try{let G=null,ae=null;try{G=RI(_)}catch(Ie){if(!(Ie instanceof qf))throw Ie;ae=Ie}const[ce,Se]=await Promise.all([m.listTerminals(),m.getTerminalLayout()]),Oe=ce.terminals.length>0?ce.terminals:[(await m.createTerminal({cols:80,rows:24})).terminal];if(!S){const Ie=Se.layout?eb(Se.layout):null;if(!Ie&&ae)throw ae;const ht=Ie??G??{},Mt=hf(Oe,void 0,ht.savedWorkspaces,ht.savedActiveWorkspaceId),Tn=ov(Mt);Lx(n,Mt),ku(n,Se.revision,JSON.stringify(Tn)),Wa(n,!0,null),!Ie&&G&&Ti(Tn,{baseRevision:Se.revision})}}catch(G){!S&&!Ls(G)&&Wa(n,!0,qa(G))}}}return T(),()=>{S=!0}},[n,m,ye]);function Zs(){Wa(n,!1,null),ve(S=>S+1)}function xr(){Ve.current+=1,$e.current+=1,je(null)}function Cn(S){Ve.current+=1,$e.current+=1,je(T=>T&&{...T,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Pi(){Ve.current+=1,$e.current+=1;const S=C.workspaces.length+1,T=Es();je({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&Xi(T)}function Qs(S){if(vi(S,n)){Pi();return}st.current={agentId:S},r?.(S)}function oa(S){if(F&&!W)return;const T=C.workspaces.find(G=>G.id===S);if(!T)return;Ve.current+=1,$e.current+=1;const B=T.defaultCwd??Jt?.cwd??"";je({mode:"edit",workspaceId:S,title:T.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Xi(B)}function Es(){return lt?.defaultCwd??Jt?.cwd??""}async function Xi(S){const T=Ve.current+1;Ve.current=T;const B=S.trim();if(je(G=>G&&{...G,cwd:S,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const G=await m.createFileRoot({path:B}),ae=await m.listFiles({rootToken:G.rootToken,path:""});if(Ve.current!==T)return;je(ce=>ce&&{...ce,cwd:G.rootPath,browseRoot:{rootToken:G.rootToken,rootPath:G.rootPath},browseEntries:ae.entries.filter(Se=>Se.kind==="directory"),browseStatus:"idle",error:null})}catch(G){if(Ve.current!==T)return;je(ae=>ae&&{...ae,browseStatus:"idle",error:qa(G)})}}async function Ds(){const S=Ee;if(!S)return;const T=S.title.trim(),B=S.cwd.trim();if(!T||!B){je({...S,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const G=$e.current+1;$e.current=G,je({...S,submitStatus:"submitting",error:null});try{const ae=await m.createFileRoot({path:B});if($e.current!==G)return;if(S.mode==="create"){const ce=C.workspaces.length+1;rt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ce}`,title:T,defaultCwd:ae.rootPath})}else S.workspaceId&&(rt({type:"workspace.renamed",workspaceId:S.workspaceId,title:T}),rt({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:ae.rootPath}));je(null)}catch(ae){if($e.current!==G)return;je(ce=>ce&&{...ce,submitStatus:"idle",error:qa(ae)})}}function wc(S){$e.current+=1,je(S)}function zi(S,T,B){if(S===T)return;const G=C.workspaces.some(ce=>ce.id===S),ae=C.workspaces.some(ce=>ce.id===T);!G||!ae||rt({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:T,placement:B})}function la(S,T){const B=C.workspaces.findIndex(ae=>ae.id===S),G=C.workspaces[B+T];B<0||!G||zi(S,G.id,T<0?"before":"after")}function Cr(S,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),Pt.current={sourceId:S,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function po(S){const T=Pt.current;if(!T||T.pointerId!==S.pointerId)return;const B=Math.hypot(S.clientX-T.startX,S.clientY-T.startY);if(!T.active){if(B<sI)return;T.active=!0,wt(T.sourceId)}const ae=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),ce=ae?.dataset.workspaceId??null;if(!ae||!ce||ce===T.sourceId||!C.workspaces.some(Ie=>Ie.id===ce)){T.targetId=null,_t(null);return}const Se=ae.getBoundingClientRect(),Oe=S.clientY<Se.top+Se.height/2?"before":"after";T.targetId=ce,T.placement=Oe,_t({workspaceId:ce,placement:Oe})}function kn(S){const T=Pt.current;!T||T.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Pt.current=null,wt(null),_t(null),T.active&&T.targetId&&zi(T.sourceId,T.targetId,T.placement))}function mo(S){const T=Pt.current;T&&T.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Pt.current=null,wt(null),_t(null)}async function ca(){await _n(async()=>{const S=lt?.defaultCwd?{cols:80,rows:24,cwd:lt.defaultCwd}:{cols:80,rows:24},T=await m.createTerminal(S);rt({type:"terminal.created",terminal:T.terminal})})}function Gi(S,T=lt,B=C,G=n){const ae=B.terminals[S.activeTerminalId],ce=Array.from(new Set(Yo(S).flatMap(Se=>{const Oe=B.terminals[Se]?.agentStatus?.provider;return Oe==="codex"||Oe==="claude"?[Oe]:[]})));return{serverId:G??Kt,workspaceId:T.id,tabId:S.id,serverName:Pe[gf(G)]??"Local",workspaceName:T.title,tabName:S.title||ae?.title||"Terminal",cwd:ae?.cwd||T.defaultCwd,paneCount:$f(S),providers:ce}}function cl(S){const T=S.serverId===Kt?null:S.serverId,B=e6(T);if(!B?.loaded||B.error)return null;const G=B.state,ce=G.workspaces.find(Ie=>Ie.tabs.some(ht=>ht.id===S.tabId))?.tabs.find(Ie=>Ie.id===S.tabId);if(!ce)return null;const Se=Yo(ce).flatMap(Ie=>{const ht=G.terminals[Ie];return ht?[ht]:[]});if(Se.length===0)return null;const Oe=Se.reduce((Ie,ht)=>{const Mt=ht.agentCache?.lastCallAt;return Mt&&(!Ie||Date.parse(Mt)>Date.parse(Ie))?Mt:Ie},null);return Se.some(Ie=>Ie.status==="running"&&(Ie.agentStatus?.state==="working"||!Ie.agentStatus&&Ie.activity==="busy"))?{state:"working",lastActivityAt:Oe}:Se.some(Ie=>Ie.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Oe}:Se.some(Ie=>Ie.agentStatus?.state==="done")?{state:"done",lastActivityAt:Oe}:Se.every(Ie=>Ie.status==="exited")?{state:"exited",lastActivityAt:Oe}:{state:"idle",lastActivityAt:Oe}}function Rs(S,T){gt.current=S,ct.current=T,X(S)}function vn(S){li.current+=1,ze.current.push(S),!mn.current&&(mn.current=!0,ne(!0),R(null),(async()=>{try{for(;ze.current.length>0;){const T=ze.current.shift();let B=0;for(;B<2;){const G=T(gt.current);if(Hx(G,gt.current))break;Rs(G,ct.current);try{const ae=await g.saveFavorites({favorites:G,baseRevision:ct.current});Rs(ae.favorites,ae.revision);break}catch(ae){const ce=await g.getFavorites().catch(()=>null);if(ce&&Rs(ce.favorites,ce.revision),ae instanceof fn&&ae.status===409&&ce){B+=1;continue}ze.current=[],R("Could not save favorites. Please try again.");return}}if(B>=2){ze.current=[],R("Favorites changed on another device. Please try again.");return}}}finally{mn.current=!1,ne(!1)}})())}function Ns(S,T,B){const G=T??Kt,ae=S.map(ce=>{if(ce.serverId!==G)return ce;const Se=B.workspaces.find(Ie=>Ie.tabs.some(ht=>ht.id===ce.tabId)),Oe=Se?.tabs.find(Ie=>Ie.id===ce.tabId);return Se&&Oe?Gi(Oe,Se,B,T):ce});Hx(S,ae)||vn(()=>ae)}function ul(S){const T=n??Kt,B=gt.current.find(ae=>ae.serverId===T&&ae.tabId===S.id);if(B){const ae=_s(B);vn(ce=>ce.filter(Se=>_s(Se)!==ae));return}if(!lt||gt.current.length>=100)return;const G=Gi(S);vn(ae=>ae.length>=100?ae:[...ae,G])}function dl(S){const T=S.serverId===Kt?null:S.serverId;if(T!==null&&!Fe.some(B=>vi(B,T))){R(`${S.serverName} is no longer registered.`);return}if(R(null),ee(!1),!vi(T,n)){et.current=S,r?.(T);return}ns(S)}async function ns(S){const T=Ct(n).state,B=T.workspaces.find(ae=>ae.tabs.some(ce=>ce.id===S.tabId));if(B){rt({type:"workspace.selected",workspaceId:B.id}),rt({type:"tab.selected",tabId:S.tabId});return}let G=T.workspaces.find(ae=>ae.id===S.workspaceId);if(!G){const ae=`workspace-favorite-${Date.now().toString(36)}`;rt({type:"workspace.created",workspaceId:ae,title:S.workspaceName,defaultCwd:S.cwd}),G=Ct(n).state.workspaces.find(ce=>ce.id===ae)}G&&rt({type:"workspace.selected",workspaceId:G.id}),await _n(async()=>{const ae=await m.createTerminal(S.cwd?{cols:80,rows:24,cwd:S.cwd}:{cols:80,rows:24});rt({type:"terminal.created",terminal:ae.terminal});const Se=Ct(n).state.workspaces.find(ci=>ci.tabs.some(Ps=>Ps.activeTerminalId===ae.terminal.id)),Oe=Se?.tabs.find(ci=>ci.activeTerminalId===ae.terminal.id);if(!Oe||!Se)return;Oe.title!==S.tabName&&rt({type:"tab.renamed",tabId:Oe.id,title:S.tabName});const Ie=Ct(n).state,ht=Ie.workspaces.find(ci=>ci.id===Se.id)??Se,Mt=ht.tabs.find(ci=>ci.id===Oe.id)??Oe,Tn=Gi(Mt,ht,Ie);vn(ci=>ci.map(Ps=>Ps.serverId===S.serverId&&Ps.workspaceId===S.workspaceId&&Ps.tabId===S.tabId?Tn:Ps))})}async function Ln(S){await _n(async()=>{const T=fi?{parentTerminalId:fi,cols:80,rows:24}:lt?.defaultCwd?{cols:80,rows:24,cwd:lt.defaultCwd}:{cols:80,rows:24},B=await m.createTerminal(T);rt({type:"terminal.split",terminal:B.terminal,direction:S})})}async function Zi(S){let T=fi,B=Yi;const G=lt?.defaultCwd?.trim();if(!T&&!G)throw new Error("No active pane is available.");const ae=await m.readFile(S);if(!T&&G){const Oe=await m.createTerminal({cols:80,rows:24,cwd:G});T=Oe.terminal.id,rt({type:"terminal.created",terminal:Oe.terminal})}if(T){rt({type:"pane.selected",terminalId:T});const Oe=Ct(n).state,Ie=Oe.workspaces.find(Mt=>Mt.id===Oe.activeWorkspaceId)??Oe.workspaces[0],ht=Ie?.tabs.find(Mt=>Mt.id===Ie.activeTabId)??Ie?.tabs[0];B=Ie&&ht?Bu(n,Ie.id,ht.id):null}const ce=`editor-${Date.now().toString(36)}-${d6(n)}`,Se=OI(ae.path);lv(n,Oe=>({...Oe,[ce]:{id:ce,title:Se,rootToken:S.rootToken,path:ae.path,read:ae}})),B&&De(Oe=>({...Oe,[B]:EE(ce)})),rt({type:"editor.split",editorId:ce,title:Se,direction:"vertical"})}function go(S){lv(n,T=>{const B={...T};return delete B[S],B}),rt({type:"editor.closed",editorId:S})}function Ms(S){Ci([S])}function Ci(S){const T=[...new Set(S)].filter(G=>C.terminals[G]);if(T.length===0)return;const B=T.length===1?C.terminals[T[0]]?.title||C.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;Ne(null),Xs({terminalIds:T,label:B,workspaceId:lt?.id??C.activeWorkspaceId??null})}function kr(S,T){const B=bo(S,T);if(!B)return!1;const G=S.filter(ae=>!B.detachedTerminalIds.includes(ae));if(B.detachedTerminalIds.length+G.length>gc)return Ne(MI(B.detachedTerminalIds.length)),!1;Ne(null);for(const ae of S)rt(B.id?{type:"terminal.detached",terminalId:ae,workspaceId:B.id}:{type:"terminal.detached",terminalId:ae});return!0}async function Tr(S){await _n(async()=>{for(const T of S)await As(T),Xl(m.createWebSocketUrl(T)),xu(T),Yl(T),rt({type:"terminal.closed",terminalId:T})})}async function vo(S){const T=C.workspaces.find(B=>B.id===S);!T||C.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await _n(async()=>{const B=Kf(T),G=[];let ae=null;for(const Se of B)try{await As(Se)}catch(Oe){G.push(qa(Oe)),Oe instanceof fn&&Oe.status===401&&!m.isAgent&&(ae=Oe)}finally{Xl(m.createWebSocketUrl(Se)),xu(Se),Yl(Se)}const ce=T.tabs.flatMap(Se=>J_(Se.root));if(ce.length>0){const Se=new Set(ce);lv(n,Oe=>{const Ie={...Oe};for(const ht of Se)delete Ie[ht];return Ie})}if(rt({type:"workspace.closed",workspaceId:S}),ae)throw ae;if(G.length>0)throw new Error(`Workspace was removed, but ${G.length} terminal session${G.length===1?"":"s"} may still be running. ${G[0]}`)})}async function Wn(S){await _n(async()=>{await As(S),Xl(m.createWebSocketUrl(S)),xu(S),Yl(S),rt({type:"terminal.closed",terminalId:S})})}async function ki(S,T){const B=T.trim();if(!B)return;let G=null;for(const ae of C.workspaces){const ce=ae.tabs.find(Se=>Se.id===S);if(ce){G=ce.activeTerminalId;break}}if(rt({type:"tab.renamed",tabId:S,title:B}),!!G)try{const ae=await m.renameTerminal(G,B);Os({type:"terminal.updated",terminal:ae.terminal})}catch(ae){Wa(n,!0,qa(ae))}}function ua(S){const T=C.terminals[S];T&&rt({type:"terminal.created",terminal:T})}async function As(S){try{await m.closeTerminal(S)}catch(T){if(T instanceof fn&&T.status===404)return;throw T}}async function On(){await _n(async()=>{await u()})}async function _n(S){Wa(n,!0,null);try{await S()}catch(T){if(Ls(T))return;Wa(n,!0,qa(T))}}function Ls(S){return S instanceof fn&&S.status===401&&!m.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function rt(S){Ka(n,S);const T=Ct(n),B=T.state;if(Ns(gt.current,n,B),!T.loaded||B.workspaces.length===0)return;const G=ov(B);JSON.stringify(G)!==T.lastPersistedLayoutJson&&fl(G)}function Os(S){Ka(n,S),Ns(gt.current,n,Ct(n).state)}function ss(S,T,B,G){const ae=Bu(S,T,B);De(ce=>({...ce,[ae]:G}))}function Js(S){Yi&&De(T=>({...T,[Yi]:S}))}function Hi(S,T){const B=Vu(S);T?ss(n,T.workspaceId,T.tabId,B):Js(B),rt({type:"pane.selected",terminalId:S})}function rs(S){Js(S.key),S.type==="terminal"&&rt({type:"pane.selected",terminalId:S.terminalId})}function Bs(S){if(te||ge||on||S.isComposing||S.key==="Process"||dI(S.target))return;const T=oI(S);if(!T)return;if(S.preventDefault(),S.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){xc(T.type==="server.next"?1:-1);return}if(T.type==="favorites.toggle"){ee(!0);return}const B=Ct(n).state,G=B.workspaces.find(Se=>Se.id===B.activeWorkspaceId)??B.workspaces[0],ae=G?.tabs.find(Se=>Se.id===G.activeTabId)??G?.tabs[0];if(T.type==="split"){if(!ae)return;Ln(T.direction);return}if(!G||!ae)return;if(T.type==="tab.previous"||T.type==="tab.next"){const Se=uI(G.tabs,ae.id,T.type==="tab.next"?1:-1);Se&&rt({type:"tab.selected",tabId:Se.id});return}if(T.type==="tab.index"){const Se=G.tabs[T.index-1];Se&&rt({type:"tab.selected",tabId:Se.id});return}const ce=lI(ae.root,ae.activeTerminalId,T);ce&&Hi(ce,{workspaceId:G.id,tabId:ae.id})}function js(S,T){if(!r||Fe.length===0)return;const B=Fe.findIndex(Se=>vi(Se,n)),ae=((B===-1?0:B)+S+Fe.length)%Fe.length,ce=Fe[ae]??null;vi(ce,n)||(T&&(ke.current={agentId:ce,edge:T}),r(ce))}function xc(S){const T=Ct(n).state,B=T.workspaces;if(B.length===0){js(S,S===1?"first":"last");return}const G=B.findIndex(Se=>Se.id===T.activeWorkspaceId),ce=(G===-1?0:G)+S;if(ce>=0&&ce<B.length){rt({type:"workspace.selected",workspaceId:B[ce].id});return}js(S,S===1?"first":"last")}function _o(S,T){if(vi(S,n)){rt({type:"workspace.selected",workspaceId:T});return}Ge.current={agentId:S,workspaceId:T},r?.(S)}function bo(S,T){if(T)return C.workspaces.find(B=>B.id===T)??null;for(const B of S){const G=C.workspaces.find(ce=>ce.tabs.some(Se=>Yo(Se).includes(B)));if(G)return G;const ae=C.workspaces.find(ce=>ce.detachedTerminalIds.includes(B));if(ae)return ae}return C.workspaces.find(B=>B.id===C.activeWorkspaceId)??C.workspaces[0]??null}function er(S){ec(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function Er(S){if(!ec(S.dataTransfer))return;S.preventDefault();const T=AI(Ct(n).state),B=oi.current+1;if(oi.current=B,!T){ha({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}ha({id:B,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),hl(B,T.id,S.dataTransfer)}async function hl(S,T,B){try{const G=await RT(B);if(G.length===0)throw new Error("No files were found in the drop.");Bn(S,{id:S,status:"queued",fileCount:G.length,message:"Queued"},{terminalId:T,files:G})}catch(G){Bn(S,{id:S,status:"failed",fileCount:0,message:qa(G)},{terminalId:T})}finally{da()}}async function Cc(S){const T=wn.current.find(ce=>ce.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const B=T.terminalId,G=T.files,ae=new AbortController;xs.current=S,Bn(S,{id:S,status:"uploading",fileCount:G.length,loaded:0,total:null,percent:null},{terminalId:B,files:G,abortController:ae});try{const ce=await Wx({terminalId:B,files:G,signal:ae.signal,onProgress:ht=>{Bn(S,{id:S,status:"uploading",fileCount:G.length,loaded:ht.loaded,total:ht.total,percent:ht.percent},{terminalId:B,files:G,abortController:ae})}}),Se=ce.failed>0?ce.uploaded>0?"partial":"failed":"success",Oe=ce.failed>0?LI(ce):void 0,Ie={id:S,status:Se,fileCount:G.length,response:ce};Oe&&(Ie.message=Oe),Bn(S,Ie,{terminalId:B,files:G})}catch(ce){Bn(S,{id:S,status:"failed",fileCount:G.length,message:ae.signal.aborted?"Upload canceled.":qa(ce)},{terminalId:B,files:G})}finally{xs.current===S&&(xs.current=null),da()}}function da(){if(xs.current!==null)return;const S=wn.current.find(T=>T.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&Cc(S.id)}function ha(S){fa(T=>[...T,S])}function Bn(S,T,B={}){fa(G=>G.map(ae=>{if(ae.id!==S)return ae;const ce={...T},Se=B.terminalId??ae.terminalId,Oe=B.files??ae.files;return Se!==void 0&&(ce.terminalId=Se),Oe!==void 0&&(ce.files=Oe),B.abortController!==void 0&&(ce.abortController=B.abortController),ce}))}function fa(S){const T=S(wn.current);wn.current=T,is(T)}function Dr(S){wn.current.find(B=>B.id===S)?.abortController?.abort(),xs.current===S&&(xs.current=null),fa(B=>B.filter(G=>G.id!==S)),da()}function tr(){for(const S of wn.current)S.abortController?.abort();xs.current=null,fa(()=>[])}function yo(S){const T=wn.current.find(B=>B.id===S);if(T){if(T.status==="queued"){Dr(S);return}T.abortController?.abort()}}function Ui(S){const T=wn.current.find(G=>G.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const B=pa(T);if(B.length===0){Bn(S,{id:S,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Bn(S,{id:S,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:T.terminalId,files:B}),da()}function pa(S){const T=S.files??[],B="response"in S?S.response:void 0;if(!B)return T;const G=B.results.filter(Se=>Se.status==="failed").map(Se=>Se.relativePath);if(G.length===0)return[];const ae=new Map;for(const Se of T){const Oe=ae.get(Se.relativePath)??[];Oe.push(Se),ae.set(Se.relativePath,Oe)}const ce=[];for(const Se of G){const Ie=ae.get(Se)?.shift();Ie&&ce.push(Ie)}return ce}function ma(S){const B=Ct(S.agentId).state.workspaces.find(G=>G.tabs.some(ae=>ae.id===S.tabId));B&&ss(S.agentId,B.id,S.tabId,Vu(S.terminalId)),Ka(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ax(S.agentId,S.terminalId),vi(S.agentId,n)||r?.(S.agentId),ks(null)}function So(S){if(ut.current=S,!vi(S.agentId,n)){r?r(S.agentId):ut.current=null;return}wo()}function wo(){const S=ut.current;if(!S||!vi(S.agentId,n)||!x.loaded)return;const T=Ct(S.agentId),B=TI(T.state,S.terminalId);ut.current=null,B&&(ss(S.agentId,B.workspaceId,B.tabId,Vu(S.terminalId)),Ka(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),Ax(S.agentId,S.terminalId))}function fl(S){const T=Ct(n).mutable.saveCoord;T.pendingLayoutSave=S,Tu(S,_),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const B=T.pendingLayoutSave;T.pendingLayoutSave=null,B&&Ti(B)},iI)}function as(){const S=Ct(n).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const T=S.pendingLayoutSave;S.pendingLayoutSave=null,T&&(Tu(T,_),Ti(T))}function Ti(S,T={}){const B=Ct(n).mutable.saveCoord;B.nextPersistLayout=S,T.baseRevision!==void 0&&(B.queuedBaseRevision=T.baseRevision),!B.nextPersistQueued&&(B.nextPersistQueued=!0,B.persistChain=B.persistChain.then(async()=>{B.nextPersistQueued=!1;const G=B.nextPersistLayout,ae=B.queuedBaseRevision;B.nextPersistLayout=null,B.queuedBaseRevision=void 0,G&&await kc(G,ae!==void 0?{baseRevision:ae}:{})}))}async function kc(S,T={}){const B=Ct(n),G=T.baseRevision??B.layoutRevision,ae={layout:S,...typeof G=="number"?{baseRevision:G}:{}};try{const ce=await m.saveTerminalLayout(ae),Se=ce.layout??S;ku(n,ce.revision,JSON.stringify(Se)),Tu(Se,_);return}catch(ce){if(ce instanceof fn&&ce.status===400&&ce.message===HR){NI(n,_),Wa(n,!0,DE());return}if(ce instanceof fn&&ce.status===409)try{const Se=await m.getTerminalLayout(),Oe=Ct(n).mutable.saveCoord;if(Oe.nextPersistLayout||Oe.pendingLayoutSave){const Ie=Se.layout?JSON.stringify(Se.layout):Ct(n).lastPersistedLayoutJson;ku(n,Se.revision,Ie);return}if(Se.layout){const Ie=Ct(n).state,ht=hf(Object.values(Ie.terminals),void 0,Se.layout.workspaces,Se.layout.activeWorkspaceId),Mt=ov(ht);Lx(n,ht),ku(n,Se.revision,JSON.stringify(Mt)),Tu(Mt,_)}else ku(n,Se.revision,B.lastPersistedLayoutJson);return}catch{}Tu(S,_)}}const pl=II(o),jn=!F||W,ga=jn?oe:"servers";function Tc(S){const T=S.active?x:Ct(S.agentId),B=S.active?C:T.state,G=S.active?x.loaded:T.loaded,ae=S.active?A:T.error;return d.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[d.jsxs("div",{className:"workspace-list-header",children:[d.jsx("span",{children:"Workspaces"}),d.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>Qs(S.agentId),children:"+"})]}),G?ae?d.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(S.agentId),children:ae}):d.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(ce=>{const Se=S.active&&ce.id===lt?.id,Oe=Kf(ce).length,Ie=n6(S.agentId,ce.id),ht=gI(Ie),Mt=S.active&&B.workspaces.length>1,Tn=Nt?.workspaceId===ce.id&&St!==ce.id?Nt.placement:null;return d.jsxs(_I,{workspaceId:ce.id,active:Se,disabled:!S.active,reorderable:Mt,dragging:St===ce.id,dropPlacement:Tn,working:Ie.workingTerminalCount>0,unread:Ie.unreadCompletionCount>0,children:[Mt?d.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ce.id,title:"Drag to reorder","aria-label":`Reorder ${ce.title}`,"aria-grabbed":St===ce.id,onPointerDown:ci=>Cr(ce.id,ci),onPointerMove:po,onPointerUp:kn,onPointerCancel:mo,onKeyDown:ci=>{(ci.key==="ArrowUp"||ci.key==="ArrowDown")&&(ci.preventDefault(),ci.stopPropagation(),la(ce.id,ci.key==="ArrowUp"?-1:1))},onClick:ci=>ci.stopPropagation(),children:"::"}):null,d.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Se?"page":void 0,title:ce.defaultCwd??void 0,onClick:()=>_o(S.agentId,ce.id),onDoubleClick:()=>{S.active&&oa(ce.id)},children:[d.jsxs("span",{className:"workspace-list-title-row",children:[d.jsx("span",{className:"workspace-list-name",children:ce.title}),Ie.workingTerminalCount>0||Ie.unreadCompletionCount>0?d.jsxs("span",{className:"workspace-list-attention",title:ht,"aria-label":ht,children:[Ie.workingTerminalCount>0?d.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,Ie.unreadCompletionCount>0?d.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:mI(Ie.unreadCompletionCount)}):null]}):null]}),d.jsxs("small",{children:[ce.defaultCwd??"No folder"," · ",Oe," ",Oe===1?"session":"sessions"]})]}),S.active?d.jsxs("div",{className:"workspace-list-actions",children:[d.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ce.title}`,title:"Edit workspace",onClick:()=>oa(ce.id),children:"..."}),d.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ce.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{vo(ce.id)},children:"x"})]}):null]},ce.id)})}):d.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(S.agentId),children:"Open server to load workspaces"})]})}function ml(S,T){de({...S,provider:T})}async function Is(S){if(M(S),!Ct(S.agentId).loaded)try{const T=dr(S.agentId),[B,G]=await Promise.all([T.listTerminals(),T.getTerminalLayout()]),ae=G.layout?eb(G.layout):null,ce=hf(B.terminals,void 0,ae?.savedWorkspaces,ae?.savedActiveWorkspaceId),Se=ce.workspaces.flatMap(Oe=>Oe.tabs.flatMap(Ie=>bi(Ie.root).flatMap(ht=>{const Mt=ce.terminals[ht];return Mt?[{terminalId:ht,cwd:Mt.cwd,label:`${Oe.title} / ${Ie.title} / ${Mt.title}`}]:[]})));M(Oe=>Oe===S?{...Oe,targets:Se}:Oe)}catch{M(T=>T===S?{...T,targetError:"Could not retrieve open tabs."}:T)}}function xo(S,T){if(vi(S,n)){rt({type:"terminal.created",terminal:T});return}Ka(S,{type:"terminal.created",terminal:T}),r?.(S)}async function Ec(S,T){const B=dr(S);try{await B.closeTerminal(T)}catch(G){if(!(G instanceof fn)||G.status!==404)throw G}if(Xl(B.createWebSocketUrl(T)),xu(T),Yl(T),vi(S,n)){rt({type:"terminal.closed",terminalId:T});return}Ka(S,{type:"terminal.closed",terminalId:T})}return d.jsx(_C,{sensors:Si,onDragStart:Ii,onDragEnd:ni,onDragCancel:hi,children:d.jsxs("main",{className:"terminal-shell","data-collapsed":F,"data-sidebar-open":W,onDragOver:er,onDrop:Er,children:[d.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>U(!1)}),d.jsxs("aside",{className:"workspace-sidebar",children:[d.jsxs("header",{className:"workspace-brand",children:[d.jsxs("div",{className:"workspace-brand-lockup",children:[jn?d.jsx(Gx,{height:20}):d.jsx(Xx,{size:24}),c&&jn?d.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),d.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":F?"Expand sidebar":"Collapse sidebar",title:F?"Expand sidebar":"Collapse sidebar",onClick:()=>K(S=>!S),children:F?">":"<"}),d.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>U(!1),children:"x"})]}),d.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${ga==="files"?"files":"servers"}`,children:[jn?d.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":oe==="servers",onClick:()=>{P("servers")},children:"Workspaces"}),d.jsx("button",{type:"button",role:"tab","aria-selected":oe==="files",onClick:()=>{P("files")},children:"Files"})]}):null,ga==="servers"&&jn?d.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:d.jsx(Xw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:E,onServerLabelsChange:yr,onManageAccounts:ml,onServerInfo:S=>{Is(S)},renderServerChildren:Tc})}):null,jn?null:d.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:d.jsx(Xw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:E,onServerLabelsChange:yr,compact:!0})}),ga==="files"?d.jsx(fA,{api:m,activeTerminalId:fi,activeTerminalCwd:Jt?.cwd??null,workspaceRootPath:fi?null:lt?.defaultCwd??null,onOpenFile:Zi},`${n??"local"}:${lt?.id??"no-workspace"}`):null]}),d.jsxs("div",{className:"workspace-sidebar-footer",children:[jn?d.jsx("span",{children:pl}):null,d.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[d.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>Z(!0),children:[d.jsx(Ux,{name:"settings"}),J.hasUpdates?d.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),jn?d.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{On()},children:d.jsx(Ux,{name:"logout"})}):null]})]})]}),te?d.jsx(oA,{api:g,onClose:()=>Z(!1),updateAvailable:J.hasUpdates,onNotificationAssetsChanged:()=>{ln()},onAgentRemoved:wr}):null,I?d.jsx(vM,{provider:I.provider,serverLabel:I.label,api:he,onClose:()=>de(null),onLoginStarted:S=>xo(I.agentId,S),onLoginFinished:S=>Ec(I.agentId,S)}):null,ge&&d.jsx(CM,{api:q,label:ge.label,main:ge.agentId===null,getRuntimeStatus:cl,favorites:Y.filter(S=>S.serverId===(ge.agentId??Kt)),targetStatus:ge.targetError??(!Ct(ge.agentId).loaded&&!ge.targets?"Loading open tabs...":null),targets:ge.targets??Ct(ge.agentId).state.workspaces.flatMap(S=>S.tabs.flatMap(T=>bi(T.root).flatMap(B=>{const G=Ct(ge.agentId).state.terminals[B];return G?[{terminalId:B,cwd:G.cwd,label:`${S.title} / ${T.title} / ${G.title}`}]:[]}))),onClose:()=>M(null),onFavorite:S=>{M(null),dl(S)},onTarget:S=>{So({kind:"terminal",agentId:ge.agentId,terminalId:S.terminalId}),M(null)}},ge.agentId??Kt),Ee?d.jsx(hI,{dialog:Ee,activePaneCwd:Jt?.cwd??null,activeWorkspaceCwd:lt?.defaultCwd??null,onChange:wc,onManualCwdChange:Cn,onBrowse:Xi,onCancel:xr,onSubmit:()=>{Ds()}}):null,d.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":an?"true":void 0,children:[d.jsx(g6,{tabs:lt?.tabs??[],activeTabId:lt?.activeTabId??null,terminals:C.terminals,unreadCompletionTabIds:wi,favoriteTabIds:new Set(Y.filter(S=>S.serverId===(n??Kt)).map(S=>S.tabId)),detachedTerminals:Ni,onSelectTab:S=>rt({type:"tab.selected",tabId:S}),onCreateTab:()=>{ca()},onToggleWorkspaces:()=>U(S=>!S),onCloseTerminals:S=>Ci(S),onReattachTerminal:S=>ua(S),onDeleteTerminal:S=>{Wn(S)},onSplitVertical:()=>{Ln("vertical")},onSplitHorizontal:()=>{Ln("horizontal")},onRenameTab:(S,T)=>{ki(S,T)},onToggleFavorite:ul,onOpenFavorites:()=>ee(!0),activePaneAvailable:!!fi}),me?d.jsx(B6,{favorites:Y,unavailableFavoriteIds:new Set(Y.filter(S=>S.serverId!==Kt&&!Fe.some(T=>vi(T,S.serverId))).map(_s)),busy:V,error:O,getRuntimeStatus:cl,onClose:()=>{ee(!1),R(null)},onOpen:dl,onRemove:S=>{vn(T=>T.filter(B=>_s(B)!==_s(S)))},onReorder:(S,T)=>{const B=_s(S),G=_s(T);vn(ae=>{const ce=ae.findIndex(Mt=>_s(Mt)===B),Se=ae.findIndex(Mt=>_s(Mt)===G);if(ce<0||Se<0||ce===Se)return ae;const Oe=ae.slice(),[Ie]=Oe.splice(ce,1),ht=Oe.findIndex(Mt=>_s(Mt)===G);return Ie&&ht>=0&&Oe.splice(ht,0,Ie),Oe})}}):null,an?d.jsx(yI,{targets:gn,activeLeafKey:pi,terminals:C.terminals,editors:N,onSelect:rs}):null,A?d.jsxs("div",{className:"workspace-error",role:"alert",children:[d.jsx("span",{children:A}),d.jsxs("div",{className:"workspace-error-actions",children:[d.jsx("button",{type:"button",onClick:Zs,children:"Retry"}),n!==null&&r?d.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,d.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?d.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!xt?d.jsx(vI,{onCreate:()=>{ca()}}):null,we.map(S=>{const T=vi(S,n);return d.jsx(aI,{agentId:S,serverName:Pe[gf(S)]??(S===null?"Local":"Server"),active:T,activeServerApi:T?m:void 0,visitedTabKeys:ie,refreshCwdOnEnter:T,draggingTab:T?Bt:null,mobileSplitFocus:Vi,mobileFocusedLeafByTabKey:Te,onSelect:B=>{T&&Hi(B)},onClose:B=>{T&&Ms(B)},onCloseEditor:B=>{T&&go(B)},onResize:(B,G)=>{T&&rt({type:"pane.resized",path:B,ratio:G})},onExit:(B,G)=>{T?Os({type:"terminal.exited",terminalId:B,exitCode:G}):Ka(S,{type:"terminal.exited",terminalId:B,exitCode:G})},onSnapshot:(B,G)=>{const ae={type:"terminal.updated",terminal:B,notifyCompletion:G?.notifyCompletion===!0};T?Os(ae):Ka(S,ae)},...f?{onAuthClose:B=>f({...B,source:B?.source??"terminal-ws-1008",activeAgentId:S})}:{}},mf(S))})]}),on?d.jsx(bI,{label:on.label,count:on.terminalIds.length,warning:Le,onCancel:()=>{Ne(null),Xs(null)},onHide:()=>{kr(on.terminalIds,on.workspaceId)&&Xs(null)},onDelete:()=>{const S=on.terminalIds;Ne(null),Xs(null),Tr(S)}}):null,d.jsx(V6,{toast:Cs,onActivate:ma,onDismiss:()=>ks(null)}),d.jsx(H6,{uploads:xi,onDismiss:Dr,onDismissAll:tr,onRetry:Ui,onCancel:yo})]})]})})}function aI({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:f,mobileFocusedLeafByTabKey:g,onSelect:m,onClose:_,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,onAuthClose:N}){const L=v.useMemo(()=>me=>vE(e,me),[e]),A=v.useMemo(()=>()=>Ct(e),[e]),W=v.useSyncExternalStore(L,A,A),U=v.useMemo(()=>dr(e),[e]),F=r??U,K=W.state,oe=K.workspaces.find(me=>me.id===K.activeWorkspaceId)??K.workspaces[0],P=oe?.id??null,Z=(oe?.tabs.find(me=>me.id===oe.activeTabId)??oe?.tabs[0])?.id??null;return!W.loaded||K.workspaces.length===0?null:d.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:K.workspaces.flatMap(me=>me.tabs.map(ee=>{const Y=n&&me.id===P&&ee.id===Z,X=Bu(e,me.id,ee.id),V=Wf(ee.root),ne=f&&V.length>1?TE(V,ee.activeTerminalId,g[X]):null;return!Y&&!o.has(X)?null:d.jsx("div",{className:"workspace-tab-surface","data-active":Y,"aria-hidden":!Y,children:d.jsx(P_,{node:ee.root,terminals:K.terminals,editors:W.editors,api:F,activeTerminalId:ee.activeTerminalId,visible:Y,refreshCwdOnEnter:Y&&c,tabId:ee.id,codeServerContext:{serverKey:gf(e),serverName:t,tabName:ee.title||K.terminals[ee.activeTerminalId]?.title||"Terminal"},dropZoneActive:Y&&u!==null,draggingTerminalId:Y?u?.terminalId??null:null,mobileFocusLeafKey:ne,onSelect:m,onClose:_,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,...N?{onAuthClose:N}:{}})},ee.id)}))})}function oI(e){const t=lk(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":case"favorites.toggle":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=cI(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function lI(e,t,n){switch(n.type){case"pane.direction":return G6(e,t,n.direction);case"pane.index":return Z6(e,n.index);default:return null}}function cI(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function uI(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function Wf(e){return e.type==="pane"?[{key:Vu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:EE(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Wf(e.first),...Wf(e.second)]}function J_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...J_(e.first),...J_(e.second)]}function TE(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?Vu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function Vu(e){return`terminal:${e}`}function EE(e){return`editor:${e}`}function dI(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function hI({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,m=e.browseEntries.filter(x=>x.kind==="directory"),_=e.submitStatus==="submitting";function b(x){r(C=>C&&{...C,...x})}function w(x){x&&(b({cwd:x,error:null}),c(x))}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:d.jsxs("form",{className:"security-panel workspace-dialog",onClick:x=>x.stopPropagation(),onSubmit:x=>{x.preventDefault(),_||f()},children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),d.jsxs("section",{className:"workspace-dialog-body",children:[d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{value:e.title,autoFocus:!0,disabled:_,onChange:x=>b({title:x.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Default cwd"}),d.jsxs("div",{className:"workspace-dialog-path-row",children:[d.jsx("input",{value:e.cwd,disabled:_,onChange:x=>o(x.currentTarget.value),placeholder:"/home/user/project"}),d.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:_||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),d.jsxs("div",{className:"workspace-dialog-quick-actions",children:[d.jsx("button",{type:"button",onClick:()=>w(t),disabled:_||!t,children:"Use active pane"}),d.jsx("button",{type:"button",onClick:()=>w(n),disabled:_||!n,children:"Use current workspace"})]}),d.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[d.jsxs("div",{className:"workspace-dialog-browser-header",children:[d.jsx("span",{title:g,children:g||"No folder selected"}),d.jsx("button",{type:"button",onClick:()=>{c(pI(g))},disabled:_||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?d.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&m.length===0?d.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&m.length>0?d.jsx("div",{className:"workspace-dialog-folder-list",children:m.map(x=>d.jsxs("button",{type:"button","aria-label":`Choose folder ${x.name}`,disabled:_,onClick:()=>{c(fI(g,x.path))},children:[d.jsx("span",{children:x.name}),d.jsx("small",{children:x.path})]},x.path))}):null]}),e.error?d.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),d.jsxs("div",{className:"workspace-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),d.jsx("button",{type:"submit",className:"primary-button",disabled:_||e.browseStatus==="loading",children:_?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function fI(e,t){return t?t.startsWith("/")?pf(t):pf(`${e||"/"}/${t}`):pf(e)}function pI(e){const t=pf(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function pf(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function mI(e){return e>99?"99+":String(e)}function gI(e){const t=[];return e.workingTerminalCount>0&&t.push(`${e.workingTerminalCount} ${e.workingTerminalCount===1?"pane is":"panes are"} working`),e.unreadCompletionCount>0&&t.push(`${e.unreadCompletionCount} unreviewed completion${e.unreadCompletionCount===1?"":"s"}`),t.join(" · ")}function vI({onCreate:e}){return d.jsxs("div",{className:"empty-workspace",children:[d.jsx("span",{children:"No terminal is open."}),d.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function _I({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,working:u=!1,unread:f=!1,children:g}){const{setNodeRef:m,isOver:_}=ep({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),b=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",u?"workspace-list-item--working":"",f?"workspace-list-item--unread":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return d.jsx("div",{ref:m,className:b,"data-workspace-id":e,"data-drop-over":_?"true":void 0,children:g})}function bI({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),d.jsx("span",{children:e}),d.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?d.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function yI({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,g=f>=0?f:0,m=e[g]??e[0],_=zx(m,n,r);function b(w){const x=(g+w+e.length)%e.length,C=e[x];C&&o(C)}return d.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[d.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),d.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:_,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",_]}),d.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?d.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:d.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[d.jsxs("header",{children:[d.jsx("strong",{children:"Panes"}),d.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),d.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,x)=>{const C=zx(w,n,r),N=SI(w,n,r),L=w.key===m.key;return d.jsxs("button",{type:"button","data-active":L,onClick:()=>{o(w),u(!1)},children:[d.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),d.jsxs("span",{className:"mobile-pane-sheet-copy",children:[d.jsx("strong",{children:C}),d.jsx("small",{children:N})]}),d.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function zx(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function SI(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function wI(e){const[t,n]=v.useState(()=>xI(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function xI(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function CI(){if(typeof window>"u")return null;const e=ZR(window.location.hash);if(!e)return null;try{window.history.replaceState(window.history.state,document.title,`${window.location.pathname}${window.location.search}`)}catch{}return e}function kI(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:tp(t.focus)}function TI(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(bi(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function vi(e,t){return e===t}function _s(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function Hx(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o!==void 0&&_s(n)===_s(o)&&n.serverName===o.serverName&&n.workspaceName===o.workspaceName&&n.tabName===o.tabName&&n.cwd===o.cwd&&n.paneCount===o.paneCount&&n.providers.length===o.providers.length&&n.providers.every((c,u)=>c===o.providers[u])})}function EI(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function mf(e){return e??"__local__"}function Bu(e,t,n){return`${mf(e)}:${t}:${n}`}class qf extends Error{constructor(){super(DE())}}function DI(e){return e?{workspaceKey:`${Ix}:${e}`}:{workspaceKey:Ix}}function RI(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(SC(n))throw new qf;const r=yC(n);return r?eb(r):null}catch(n){if(n instanceof qf)throw n;return null}}function eb(e){if(SC(e))throw new qf;const t=yC(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Tu(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function NI(e,t){const n=Ct(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function MI(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${gc}. Re-open or delete hidden sessions before hiding more.`}function DE(){return`A saved terminal layout has more than ${gc} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function AI(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function LI(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function OI(e){return e.split("/").filter(Boolean).pop()??e}function BI(){try{return localStorage.getItem(kE)==="true"}catch{return!1}}function jI(e){try{localStorage.setItem(kE,e?"true":"false")}catch{}}function gf(e){return e??Kt}function uv(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function II(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function Ux({name:e}){return d.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M4 7h9"}),d.jsx("path",{d:"M17 7h3"}),d.jsx("circle",{cx:"15",cy:"7",r:"2"}),d.jsx("path",{d:"M4 12h3"}),d.jsx("path",{d:"M11 12h9"}),d.jsx("circle",{cx:"9",cy:"12",r:"2"}),d.jsx("path",{d:"M4 17h9"}),d.jsx("path",{d:"M17 17h3"}),d.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 6H6v12h4"}),d.jsx("path",{d:"M13 8l4 4-4 4"}),d.jsx("path",{d:"M8 12h9"})]}):null]})}function qa(e){return e instanceof Error?e.message:"Request failed"}function PI({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,f]=v.useState(""),[g,m]=v.useState(!1),[_,b]=v.useState(null),[w,x]=v.useState(null);v.useEffect(()=>{let N=!1;return e.setupTotp().then(L=>{N||(r(L.qrDataUrl),c(L.secret))}).catch(L=>{N||x(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{N=!0}},[e]);async function C(N){if(N.preventDefault(),!!o){m(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(L){b(L instanceof Error?L.message:"Verification failed")}finally{m(!1)}}}return w?d.jsx("p",{className:"form-error",children:w}):!n||!o?d.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):d.jsxs("div",{className:"totp-setup",children:[d.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),d.jsx("div",{className:"totp-qr-container",children:d.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),d.jsxs("details",{className:"totp-secret-details",children:[d.jsx("summary",{children:"Can't scan? Enter manually"}),d.jsx("p",{className:"totp-secret-text",children:o})]}),d.jsxs("form",{className:"auth-form",onSubmit:C,children:[d.jsxs("label",{children:["Verification code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:N=>f(N.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),_?d.jsx("p",{className:"form-error",children:_}):null,d.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function zI(e){return{source:dv(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:dv(e.terminalId)}:{},...e?.detail?{detail:dv(e.detail)}:{}}}function HI(e){return{invalidationSource:e.source}}function UI(e){Sn("auth.session_invalid.request",RE(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),_b("session-invalid-request").catch(()=>{}))}function FI(e,t){Sn("auth.session_invalid.result",{...RE(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),_b("session-invalid-result").catch(()=>{}))}function RE(e){return{source:e.source,...typeof e.status=="number"?{status:e.status}:{},...e.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e.terminalId?{terminalId:e.terminalId}:{},...e.detail?{detail:e.detail}:{}}}function dv(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function $I({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??Vf(),[e]),c=v.useMemo(()=>t??dr(null),[t]),[u,f]=v.useState(null),[g,m]=v.useState(null),_=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(W=>{A||(f(W),m(null))}).catch(W=>{A||(m(Qo(W)),f(null))}),()=>{A=!0}},[o]);const w=VI(u);v.useEffect(()=>{const A=b.current;Sn("auth.view",{view:w,previousView:A,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),A==="workspace"&&w!=="workspace"&&_b(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[u,w]);async function x(){const A=await o.getSession();f(A),m(null)}async function C(){ev(),cv(),ix(),nx(),m(null),f(null);try{await x()}catch(A){m(Qo(A))}}function N(A){const W=zI(A);if(UI(W),_.current)return _.current;const U=(async()=>{m(null);try{const F=await o.getSession(HI(W));if(FI(W,F.authenticated),f(F),F.authenticated){H5();return}ev(),cv(),ix(),nx()}catch(F){m(Qo(F))}finally{_.current=null}})();return _.current=U,U}if(w==="workspace")return d.jsx(rI,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:A=>{N(A)},onLogout:async()=>{ev(),cv();const A=await o.logout();f(A)}});const L={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return d.jsxs("main",{className:"auth-screen",children:[d.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[d.jsx("div",{className:"auth-grid"}),d.jsx("div",{className:"auth-glow"})]}),d.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[d.jsxs("header",{className:"auth-header",children:[d.jsxs("div",{className:"auth-brand",children:[d.jsx(Xx,{size:26}),d.jsxs("div",{children:[d.jsx(Gx,{height:17}),d.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),d.jsx("h1",{children:L[w]})]}),g?d.jsx("p",{className:"form-error",children:g}):null,w==="loading"?d.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{C()},children:"Retry"}):null,w==="setup_password"?d.jsx(KI,{api:o,onSession:A=>{f(A)}}):null,w==="setup_totp"?d.jsx(PI,{api:o,onDone:()=>{x()}}):null,w==="login"?d.jsx(WI,{api:o,session:u,onSession:f,onRefresh:x}):null,w==="reauth"?d.jsx(qI,{api:o,session:u,onSession:f,onFullLogin:()=>f(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function KI({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,f]=v.useState(!1),[g,m]=v.useState(null);async function _(b){b.preventDefault(),f(!0),m(null);try{if(n!==o){m("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(w){m(Qo(w))}finally{f(!1)}}return d.jsxs("form",{className:"auth-form",onSubmit:_,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),d.jsxs("label",{children:["Confirm password",d.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?d.jsx("p",{className:"form-error",children:g}):null,d.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function WI({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,f]=v.useState(""),[g,m]=v.useState(!1),[_,b]=v.useState(!1),[w,x]=v.useState(null),C=t?.totpEnabled??!1,N=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),b(!0),x(null);try{n(await e.login({password:o,...C?{otp:u}:{},rememberNetwork:g}))}catch(W){x(Qo(W))}finally{b(!1)}}return d.jsxs("form",{className:"auth-form",onSubmit:L,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),C?d.jsxs("label",{children:["Authenticator code",d.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:A=>f(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,N?null:d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:g,onChange:A=>m(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?d.jsx("p",{className:"form-error",children:w}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:_||o.length===0||C&&u.length!==6,children:"Unlock"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:_,children:"Refresh"})]})]})}function qI({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[f,g]=v.useState(!1),[m,_]=v.useState(!1),[b,w]=v.useState(!1),[x,C]=v.useState(!1),[N,L]=v.useState(null),A=Ot.useCallback(async(U,F)=>{_(!0),L(null);try{n(await e.reauth({...U?{otp:U}:{},rememberNetwork:F}))}catch(K){L(Qo(K))}finally{_(!1)}},[e,n]);v.useEffect(()=>{if(o){let U=!1;w(!0),C(!1),L(null);const F=window.setTimeout(()=>{U||C(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(K=>{U||n(K)}).catch(K=>{U||(L(Qo(K)),C(!0))}).finally(()=>{window.clearTimeout(F),U||w(!1)}),()=>{U=!0,window.clearTimeout(F)}}},[e,o,n]);async function W(U){U.preventDefault(),await A(c,f)}return o&&b&&!x&&!N?d.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):d.jsxs("form",{className:"auth-form",onSubmit:W,children:[o&&x&&!N?d.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,d.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),d.jsxs("label",{children:["Authenticator code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:U=>u(U.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:f,onChange:U=>g(U.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),N?d.jsx("p",{className:"form-error",children:N}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:m||c.length!==6,children:"Continue"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:m,children:"Use password instead"})]})]})}function VI(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Qo(e){return e instanceof Error?e.message:"Request failed"}const Fx="NTerminal",tb="nterminal.activeAgentId";function YI(){const[e,t]=v.useState(()=>XI()),n=v.useMemo(()=>Vf(),[]),r=v.useMemo(()=>dr(e),[e]);v.useEffect(()=>{const c=()=>{const u=u6();document.title=u>0?`(${u}) ${Fx}`:Fx};return c(),c6(c)},[]);function o(c){GI(c),t(c)}return d.jsx($I,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function XI(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(tb);return e&&e.trim()?e:null}catch{return null}}function GI(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(tb,e);return}window.localStorage.removeItem(tb)}catch{}}const $x=["gesturestart","gesturechange","gestureend"],ZI=[".workspace-list",".workspace-nav",".server-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview",".settings-content",".settings-nav",".transcript-dialog-scroll",".transcript-filter-group"].join(",");function QI(e=window){if(!eP(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const u=c.touches;!u||u.length===0||(u.length>1||!JI(c.target))&&r(c)}for(const c of $x)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of $x)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function JI(e){return e instanceof Element&&e.closest(ZI)!==null}function eP(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}nN();cB();QI();ab();iD.createRoot(document.getElementById("root")).render(d.jsx(Ot.StrictMode,{children:d.jsx(YI,{})}));export{Ot as R,V2 as g,d as j};