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
@@ -1,56 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-mvGPeEQn.js","assets/index-BSYsec0Y.js","assets/TranscriptMarkdownBody-B_ctyQyz.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 E2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lg={exports:{}},ou={};var sw;function D2(){if(sw)return ou;sw=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 ou.Fragment=t,ou.jsx=n,ou.jsxs=n,ou}var rw;function R2(){return rw||(rw=1,lg.exports=D2()),lg.exports}var h=R2(),cg={exports:{}},ot={};var aw;function M2(){if(aw)return ot;aw=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"),p=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),C=Symbol.iterator;function w(N){return N===null||typeof N!="object"?null:(N=C&&N[C]||N["@@iterator"],typeof N=="function"?N:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M=Object.assign,O={};function A(N,K,de){this.props=N,this.context=K,this.refs=O,this.updater=de||x}A.prototype.isReactComponent={},A.prototype.setState=function(N,K){if(typeof N!="object"&&typeof N!="function"&&N!=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,N,K,"setState")},A.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function W(){}W.prototype=A.prototype;function F(N,K,de){this.props=N,this.context=K,this.refs=O,this.updater=de||x}var U=F.prototype=new W;U.constructor=F,M(U,A.prototype),U.isPureReactComponent=!0;var q=Array.isArray;function ae(){}var P={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function G(N,K,de){var ke=de.ref;return{$$typeof:e,type:N,key:K,ref:ke!==void 0?ke:null,props:de}}function ge(N,K){return G(N.type,K,N.props)}function ee(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function V(N){var K={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(de){return K[de]})}var Z=/\/+/g;function Y(N,K){return typeof N=="object"&&N!==null&&N.key!=null?V(""+N.key):K.toString(36)}function ie(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(ae,ae):(N.status="pending",N.then(function(K){N.status==="pending"&&(N.status="fulfilled",N.value=K)},function(K){N.status==="pending"&&(N.status="rejected",N.reason=K)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function B(N,K,de,ke,Ne){var Re=typeof N;(Re==="undefined"||Re==="boolean")&&(N=null);var Le=!1;if(N===null)Le=!0;else switch(Re){case"bigint":case"string":case"number":Le=!0;break;case"object":switch(N.$$typeof){case e:case t:Le=!0;break;case _:return Le=N._init,B(Le(N._payload),K,de,ke,Ne)}}if(Le)return Ne=Ne(N),Le=ke===""?"."+Y(N,0):ke,q(Ne)?(de="",Le!=null&&(de=Le.replace(Z,"$&/")+"/"),B(Ne,K,de,"",function(Pe){return Pe})):Ne!=null&&(ee(Ne)&&(Ne=ge(Ne,de+(Ne.key==null||N&&N.key===Ne.key?"":(""+Ne.key).replace(Z,"$&/")+"/")+Le)),K.push(Ne)),1;Le=0;var Ae=ke===""?".":ke+":";if(q(N))for(var We=0;We<N.length;We++)ke=N[We],Re=Ae+Y(ke,We),Le+=B(ke,K,de,Re,Ne);else if(We=w(N),typeof We=="function")for(N=We.call(N),We=0;!(ke=N.next()).done;)ke=ke.value,Re=Ae+Y(ke,We++),Le+=B(ke,K,de,Re,Ne);else if(Re==="object"){if(typeof N.then=="function")return B(ie(N),K,de,ke,Ne);throw K=String(N),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return Le}function R(N,K,de){if(N==null)return N;var ke=[],Ne=0;return B(N,ke,"","",function(Re){return K.call(de,Re,Ne++)}),ke}function I(N){if(N._status===-1){var K=N._result;K=K(),K.then(function(de){(N._status===0||N._status===-1)&&(N._status=1,N._result=de)},function(de){(N._status===0||N._status===-1)&&(N._status=2,N._result=de)}),N._status===-1&&(N._status=0,N._result=K)}if(N._status===1)return N._result.default;throw N._result}var ue=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},xe={map:R,forEach:function(N,K,de){R(N,function(){K.apply(this,arguments)},de)},count:function(N){var K=0;return R(N,function(){K++}),K},toArray:function(N){return R(N,function(K){return K})||[]},only:function(N){if(!ee(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return ot.Activity=b,ot.Children=xe,ot.Component=A,ot.Fragment=n,ot.Profiler=o,ot.PureComponent=F,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(N){return P.H.useMemoCache(N)}},ot.cache=function(N){return function(){return N.apply(null,arguments)}},ot.cacheSignal=function(){return null},ot.cloneElement=function(N,K,de){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var ke=M({},N.props),Ne=N.key;if(K!=null)for(Re in K.key!==void 0&&(Ne=""+K.key),K)!te.call(K,Re)||Re==="key"||Re==="__self"||Re==="__source"||Re==="ref"&&K.ref===void 0||(ke[Re]=K[Re]);var Re=arguments.length-2;if(Re===1)ke.children=de;else if(1<Re){for(var Le=Array(Re),Ae=0;Ae<Re;Ae++)Le[Ae]=arguments[Ae+2];ke.children=Le}return G(N.type,Ne,ke)},ot.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:c,_context:N},N},ot.createElement=function(N,K,de){var ke,Ne={},Re=null;if(K!=null)for(ke in K.key!==void 0&&(Re=""+K.key),K)te.call(K,ke)&&ke!=="key"&&ke!=="__self"&&ke!=="__source"&&(Ne[ke]=K[ke]);var Le=arguments.length-2;if(Le===1)Ne.children=de;else if(1<Le){for(var Ae=Array(Le),We=0;We<Le;We++)Ae[We]=arguments[We+2];Ne.children=Ae}if(N&&N.defaultProps)for(ke in Le=N.defaultProps,Le)Ne[ke]===void 0&&(Ne[ke]=Le[ke]);return G(N,Re,Ne)},ot.createRef=function(){return{current:null}},ot.forwardRef=function(N){return{$$typeof:f,render:N}},ot.isValidElement=ee,ot.lazy=function(N){return{$$typeof:_,_payload:{_status:-1,_result:N},_init:I}},ot.memo=function(N,K){return{$$typeof:p,type:N,compare:K===void 0?null:K}},ot.startTransition=function(N){var K=P.T,de={};P.T=de;try{var ke=N(),Ne=P.S;Ne!==null&&Ne(de,ke),typeof ke=="object"&&ke!==null&&typeof ke.then=="function"&&ke.then(ae,ue)}catch(Re){ue(Re)}finally{K!==null&&de.types!==null&&(K.types=de.types),P.T=K}},ot.unstable_useCacheRefresh=function(){return P.H.useCacheRefresh()},ot.use=function(N){return P.H.use(N)},ot.useActionState=function(N,K,de){return P.H.useActionState(N,K,de)},ot.useCallback=function(N,K){return P.H.useCallback(N,K)},ot.useContext=function(N){return P.H.useContext(N)},ot.useDebugValue=function(){},ot.useDeferredValue=function(N,K){return P.H.useDeferredValue(N,K)},ot.useEffect=function(N,K){return P.H.useEffect(N,K)},ot.useEffectEvent=function(N){return P.H.useEffectEvent(N)},ot.useId=function(){return P.H.useId()},ot.useImperativeHandle=function(N,K,de){return P.H.useImperativeHandle(N,K,de)},ot.useInsertionEffect=function(N,K){return P.H.useInsertionEffect(N,K)},ot.useLayoutEffect=function(N,K){return P.H.useLayoutEffect(N,K)},ot.useMemo=function(N,K){return P.H.useMemo(N,K)},ot.useOptimistic=function(N,K){return P.H.useOptimistic(N,K)},ot.useReducer=function(N,K,de){return P.H.useReducer(N,K,de)},ot.useRef=function(N){return P.H.useRef(N)},ot.useState=function(N){return P.H.useState(N)},ot.useSyncExternalStore=function(N,K,de){return P.H.useSyncExternalStore(N,K,de)},ot.useTransition=function(){return P.H.useTransition()},ot.version="19.2.6",ot}var ow;function G_(){return ow||(ow=1,cg.exports=M2()),cg.exports}var v=G_();const jt=E2(v);var ug={exports:{}},lu={},dg={exports:{}},hg={};var lw;function N2(){return lw||(lw=1,(function(e){function t(B,R){var I=B.length;B.push(R);e:for(;0<I;){var ue=I-1>>>1,xe=B[ue];if(0<o(xe,R))B[ue]=R,B[I]=xe,I=ue;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var R=B[0],I=B.pop();if(I!==R){B[0]=I;e:for(var ue=0,xe=B.length,N=xe>>>1;ue<N;){var K=2*(ue+1)-1,de=B[K],ke=K+1,Ne=B[ke];if(0>o(de,I))ke<xe&&0>o(Ne,de)?(B[ue]=Ne,B[ke]=I,ue=ke):(B[ue]=de,B[K]=I,ue=K);else if(ke<xe&&0>o(Ne,I))B[ue]=Ne,B[ke]=I,ue=ke;else break e}}return R}function o(B,R){var I=B.sortIndex-R.sortIndex;return I!==0?I:B.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=[],p=[],_=1,b=null,C=3,w=!1,x=!1,M=!1,O=!1,A=typeof setTimeout=="function"?setTimeout:null,W=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;function U(B){for(var R=n(p);R!==null;){if(R.callback===null)r(p);else if(R.startTime<=B)r(p),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(p)}}function q(B){if(M=!1,U(B),!x)if(n(g)!==null)x=!0,ae||(ae=!0,V());else{var R=n(p);R!==null&&ie(q,R.startTime-B)}}var ae=!1,P=-1,te=5,G=-1;function ge(){return O?!0:!(e.unstable_now()-G<te)}function ee(){if(O=!1,ae){var B=e.unstable_now();G=B;var R=!0;try{e:{x=!1,M&&(M=!1,W(P),P=-1),w=!0;var I=C;try{t:{for(U(B),b=n(g);b!==null&&!(b.expirationTime>B&&ge());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,C=b.priorityLevel;var xe=ue(b.expirationTime<=B);if(B=e.unstable_now(),typeof xe=="function"){b.callback=xe,U(B),R=!0;break t}b===n(g)&&r(g),U(B)}else r(g);b=n(g)}if(b!==null)R=!0;else{var N=n(p);N!==null&&ie(q,N.startTime-B),R=!1}}break e}finally{b=null,C=I,w=!1}R=void 0}}finally{R?V():ae=!1}}}var V;if(typeof F=="function")V=function(){F(ee)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,Y=Z.port2;Z.port1.onmessage=ee,V=function(){Y.postMessage(null)}}else V=function(){A(ee,0)};function ie(B,R){P=A(function(){B(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(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):te=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(B){switch(C){case 1:case 2:case 3:var R=3;break;default:R=C}var I=C;C=R;try{return B()}finally{C=I}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function(B,R){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var I=C;C=B;try{return R()}finally{C=I}},e.unstable_scheduleCallback=function(B,R,I){var ue=e.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?ue+I:ue):I=ue,B){case 1:var xe=-1;break;case 2:xe=250;break;case 5:xe=1073741823;break;case 4:xe=1e4;break;default:xe=5e3}return xe=I+xe,B={id:_++,callback:R,priorityLevel:B,startTime:I,expirationTime:xe,sortIndex:-1},I>ue?(B.sortIndex=I,t(p,B),n(g)===null&&B===n(p)&&(M?(W(P),P=-1):M=!0,ie(q,I-ue))):(B.sortIndex=xe,t(g,B),x||w||(x=!0,ae||(ae=!0,V()))),B},e.unstable_shouldYield=ge,e.unstable_wrapCallback=function(B){var R=C;return function(){var I=C;C=R;try{return B.apply(this,arguments)}finally{C=I}}}})(hg)),hg}var cw;function A2(){return cw||(cw=1,dg.exports=N2()),dg.exports}var fg={exports:{}},mn={};var uw;function L2(){if(uw)return mn;uw=1;var e=G_();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+g+"; visit "+p+" 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,p,_){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:_}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return mn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,mn.createPortal=function(g,p){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return c(g,p,null,_)},mn.flushSync=function(g){var p=u.T,_=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=p,r.p=_,r.d.f()}},mn.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},mn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},mn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var _=p.as,b=f(_,p.crossOrigin),C=typeof p.integrity=="string"?p.integrity:void 0,w=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;_==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:C,fetchPriority:w}):_==="script"&&r.d.X(g,{crossOrigin:b,integrity:C,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},mn.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var _=f(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:_,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},mn.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var _=p.as,b=f(_,p.crossOrigin);r.d.L(g,_,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},mn.preloadModule=function(g,p){if(typeof g=="string")if(p){var _=f(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:_,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},mn.requestFormReset=function(g){r.d.r(g)},mn.unstable_batchedUpdates=function(g,p){return g(p)},mn.useFormState=function(g,p,_){return u.H.useFormState(g,p,_)},mn.useFormStatus=function(){return u.H.useHostTransitionStatus()},mn.version="19.2.6",mn}var dw;function BC(){if(dw)return fg.exports;dw=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=L2(),fg.exports}var hw;function O2(){if(hw)return lu;hw=1;var e=A2(),t=G_(),n=BC();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 p(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 d=a.return;if(d===null)break;var m=d.alternate;if(m===null){if(l=d.return,l!==null){a=l;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===a)return g(d),i;if(m===l)return g(d),s;m=m.sibling}throw Error(r(188))}if(a.return!==l.return)a=d,l=m;else{for(var y=!1,E=d.child;E;){if(E===a){y=!0,a=d,l=m;break}if(E===l){y=!0,l=d,a=m;break}E=E.sibling}if(!y){for(E=m.child;E;){if(E===a){y=!0,a=m,l=d;break}if(E===l){y=!0,l=m,a=d;break}E=E.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,C=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),W=Symbol.for("react.consumer"),F=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),G=Symbol.for("react.activity"),ge=Symbol.for("react.memo_cache_sentinel"),ee=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=ee&&i[ee]||i["@@iterator"],typeof i=="function"?i:null)}var Z=Symbol.for("react.client.reference");function Y(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===Z?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case M:return"Fragment";case A:return"Profiler";case O:return"StrictMode";case q:return"Suspense";case ae:return"SuspenseList";case G:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case F:return i.displayName||"Context";case W:return(i._context.displayName||"Context")+".Consumer";case U: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:Y(i.type)||"Memo";case te:s=i._payload,i=i._init;try{return Y(i(s))}catch{}}return null}var ie=Array.isArray,B=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},ue=[],xe=-1;function N(i){return{current:i}}function K(i){0>xe||(i.current=ue[xe],ue[xe]=null,xe--)}function de(i,s){xe++,ue[xe]=i.current,i.current=s}var ke=N(null),Ne=N(null),Re=N(null),Le=N(null);function Ae(i,s){switch(de(Re,s),de(Ne,i),de(ke,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?E0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=E0(s),i=D0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(ke),de(ke,i)}function We(){K(ke),K(Ne),K(Re)}function Pe(i){i.memoizedState!==null&&de(Le,i);var s=ke.current,a=D0(s,i.type);s!==a&&(de(Ne,i),de(ke,a))}function He(i){Ne.current===i&&(K(ke),K(Ne)),Le.current===i&&(K(Le),nu._currentValue=I)}var fe,D;function J(i){if(fe===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);fe=s&&s[1]||"",D=-1<a.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+fe+i+D}var Ce=!1;function Ee(i,s){if(!i||Ce)return"";Ce=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var ye=function(){throw Error()};if(Object.defineProperty(ye.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ye,[])}catch(he){var oe=he}Reflect.construct(i,[],ye)}else{try{ye.call()}catch(he){oe=he}i.call(ye.prototype)}}else{try{throw Error()}catch(he){oe=he}(ye=i())&&typeof ye.catch=="function"&&ye.catch(function(){})}}catch(he){if(he&&oe&&typeof he.stack=="string")return[he.stack,oe.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=l.DetermineComponentFrameRoot(),y=m[0],E=m[1];if(y&&E){var j=y.split(`
5
- `),se=E.split(`
6
- `);for(d=l=0;l<j.length&&!j[l].includes("DetermineComponentFrameRoot");)l++;for(;d<se.length&&!se[d].includes("DetermineComponentFrameRoot");)d++;if(l===j.length||d===se.length)for(l=j.length-1,d=se.length-1;1<=l&&0<=d&&j[l]!==se[d];)d--;for(;1<=l&&0<=d;l--,d--)if(j[l]!==se[d]){if(l!==1||d!==1)do if(l--,d--,0>d||j[l]!==se[d]){var me=`
7
- `+j[l].replace(" at new "," at ");return i.displayName&&me.includes("<anonymous>")&&(me=me.replace("<anonymous>",i.displayName)),me}while(1<=l&&0<=d);break}}}finally{Ce=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?J(a):""}function $(i,s){switch(i.tag){case 26:case 27:case 5:return J(i.type);case 16:return J("Lazy");case 13:return i.child!==s&&s!==null?J("Suspense Fallback"):J("Suspense");case 19:return J("SuspenseList");case 0:case 15:return Ee(i.type,!1);case 11:return Ee(i.type.render,!1);case 1:return Ee(i.type,!0);case 31:return J("Activity");default:return""}}function Te(i){try{var s="",a=null;do s+=$(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
8
- Error generating stack: `+l.message+`
9
- `+l.stack}}var _e=Object.prototype.hasOwnProperty,pe=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,Ue=e.unstable_shouldYield,Ke=e.unstable_requestPaint,nt=e.unstable_now,Mt=e.unstable_getCurrentPriorityLevel,ht=e.unstable_ImmediatePriority,Dt=e.unstable_UserBlockingPriority,vt=e.unstable_NormalPriority,$t=e.unstable_LowPriority,si=e.unstable_IdlePriority,Se=e.log,Ve=e.unstable_setDisableYieldValue,rt=null,tt=null;function kt(i){if(typeof Se=="function"&&Ve(i),tt&&typeof tt.setStrictMode=="function")try{tt.setStrictMode(rt,i)}catch{}}var lt=Math.clz32?Math.clz32:re,qi=Math.log,li=Math.LN2;function re(i){return i>>>=0,i===0?32:31-(qi(i)/li|0)|0}var Fe=256,ct=262144,ut=4194304;function Lt(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 fi(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var d=0,m=i.suspendedLanes,y=i.pingedLanes;i=i.warmLanes;var E=l&134217727;return E!==0?(l=E&~m,l!==0?d=Lt(l):(y&=E,y!==0?d=Lt(y):a||(a=E&~i,a!==0&&(d=Lt(a))))):(E=l&~m,E!==0?d=Lt(E):y!==0?d=Lt(y):a||(a=l&~i,a!==0&&(d=Lt(a)))),d===0?0:s!==0&&s!==d&&(s&m)===0&&(m=d&-d,a=s&-s,m>=a||m===32&&(a&4194048)!==0)?s:d}function wi(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function at(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 Tt(){var i=ut;return ut<<=1,(ut&62914560)===0&&(ut=4194304),i}function zt(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function Di(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Wt(i,s,a,l,d,m){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 E=i.entanglements,j=i.expirationTimes,se=i.hiddenUpdates;for(a=y&~a;0<a;){var me=31-lt(a),ye=1<<me;E[me]=0,j[me]=-1;var oe=se[me];if(oe!==null)for(se[me]=null,me=0;me<oe.length;me++){var he=oe[me];he!==null&&(he.lane&=-536870913)}a&=~ye}l!==0&&nn(i,l,0),m!==0&&d===0&&i.tag!==0&&(i.suspendedLanes|=m&~(y&~s))}function nn(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-lt(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ii(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-lt(a),d=1<<l;d&s|i[l]&s&&(i[l]|=s),a&=~d}}function sn(i,s){var a=s&-s;return a=(a&42)!==0?1:_n(a),(a&(i.suspendedLanes|s))!==0?0:a}function _n(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 Rn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function gi(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:Z0(i.type))}function fn(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var Ri=Math.random().toString(36).slice(2),qt="__reactFiber$"+Ri,Qt="__reactProps$"+Ri,bn="__reactContainer$"+Ri,ws="__reactEvents$"+Ri,Cs="__reactListeners$"+Ri,xs="__reactHandles$"+Ri,Ws="__reactResources$"+Ri,Vn="__reactMarker$"+Ri;function Yn(i){delete i[qt],delete i[Qt],delete i[ws],delete i[Cs],delete i[xs]}function ks(i){var s=i[qt];if(s)return s;for(var a=i.parentNode;a;){if(s=a[bn]||a[qt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=B0(i);i!==null;){if(a=i[qt])return a;i=B0(i)}return s}i=a,a=i.parentNode}return null}function Ts(i){if(i=i[qt]||i[bn]){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 Es(i){var s=i[Ws];return s||(s=i[Ws]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Ht(i){i[Vn]=!0}var uo=new Set,qs={};function Vt(i,s){yn(i,s),yn(i+"Capture",s)}function yn(i,s){for(qs[i]=s,i=0;i<s.length;i++)uo.add(s[i])}var Sn=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]*$"),Jr={},ho={};function gr(i){return _e.call(ho,i)?!0:_e.call(Jr,i)?!1:Sn.test(i)?ho[i]=!0:(Jr[i]=!0,!1)}function Ds(i,s,a){if(gr(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 ea(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 pn(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 Vi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Gn(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function fo(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 d=l.get,m=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.call(this)},set:function(y){a=""+y,m.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 Rs(i){if(!i._valueTracker){var s=Gn(i)?"checked":"value";i._valueTracker=fo(i,s,""+i[s])}}function rn(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Gn(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function Ms(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 _c=/[\n"\\]/g;function Yi(i){return i.replace(_c,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function ta(i,s,a,l,d,m,y,E){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=""+Vi(s)):i.value!==""+Vi(s)&&(i.value=""+Vi(s)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),s!=null?ia(i,y,Vi(s)):a!=null?ia(i,y,Vi(a)):l!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?i.name=""+Vi(E):i.removeAttribute("name")}function vr(i,s,a,l,d,m,y,E){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),s!=null||a!=null){if(!(m!=="submit"&&m!=="reset"||s!=null)){Rs(i);return}a=a!=null?""+Vi(a):"",s=s!=null?""+Vi(s):a,E||s===i.value||(i.value=s),i.defaultValue=s}l=l??d,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=E?i.checked:!!l,i.defaultChecked=!!l,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.name=y),Rs(i)}function ia(i,s,a){s==="number"&&Ms(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function an(i,s,a,l){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Vi(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,l&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function po(i,s,a){if(s!=null&&(s=""+Vi(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Vi(a):""}function Vs(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(ie(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Vi(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),Rs(i)}function Ci(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var na=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 sa(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||na.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function Ns(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 d in s)l=s[d],s.hasOwnProperty(d)&&a[d]!==l&&sa(i,d,l)}else for(var m in s)s.hasOwnProperty(m)&&sa(i,m,s[m])}function _r(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 ra=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"]]),bc=/^[\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 As(i){return bc.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Zn(){}var Pi=null;function mo(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ls=null,Mi=null;function br(i){var s=Ts(i);if(s&&(i=s.stateNode)){var a=i[Qt]||null;e:switch(i=s.stateNode,s.type){case"input":if(ta(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="'+Yi(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var d=l[Qt]||null;if(!d)throw Error(r(90));ta(l,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&rn(l)}break e;case"textarea":po(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&an(i,!!a.multiple,s,!1)}}}var yr=!1;function go(i,s,a){if(yr)return i(s,a);yr=!0;try{var l=i(s);return l}finally{if(yr=!1,(Ls!==null||Mi!==null)&&(ah(),Ls&&(s=Ls,i=Mi,Mi=Ls=null,br(s),i)))for(s=0;s<i.length;s++)br(i[s])}}function wn(i,s){var a=i.stateNode;if(a===null)return null;var l=a[Qt]||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 xi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mn=!1;if(xi)try{var Ys={};Object.defineProperty(Ys,"passive",{get:function(){Mn=!0}}),window.addEventListener("test",Ys,Ys),window.removeEventListener("test",Ys,Ys)}catch{Mn=!1}var Qe=null,Qn=null,Jn=null;function aa(){if(Jn)return Jn;var i,s=Qn,a=s.length,l,d="value"in Qe?Qe.value:Qe.textContent,m=d.length;for(i=0;i<a&&s[i]===d[i];i++);var y=a-i;for(l=1;l<=y&&s[a-l]===d[m-l];l++);return Jn=d.slice(i,1<l?1-l:void 0)}function Xs(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 Gs(){return!0}function Sr(){return!1}function zi(i){function s(a,l,d,m,y){this._reactName=a,this._targetInst=d,this.type=l,this.nativeEvent=m,this.target=y,this.currentTarget=null;for(var E in i)i.hasOwnProperty(E)&&(a=i[E],this[E]=a?a(m):m[E]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Gs:Sr,this.isPropagationStopped=Sr,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=Gs)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Gs)},persist:function(){},isPersistent:Gs}),s}var es={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Os=zi(es),Zs=b({},es,{view:0,detail:0}),yc=zi(Zs),vo,_o,Qs,ts=b({},Zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ns,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!==Qs&&(Qs&&i.type==="mousemove"?(vo=i.screenX-Qs.screenX,_o=i.screenY-Qs.screenY):_o=vo=0,Qs=i),vo)},movementY:function(i){return"movementY"in i?i.movementY:_o}}),bo=zi(ts),is=b({},ts,{dataTransfer:0}),oa=zi(is),la=b({},Zs,{relatedTarget:0}),yo=zi(la),Sc=b({},es,{animationName:0,elapsedTime:0,pseudoElement:0}),ca=zi(Sc),Js=b({},es,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),So=zi(Js),Hi=b({},es,{data:0}),wr=zi(Hi),ua={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ll={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"},da={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cl(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=da[i])?!!s[i]:!1}function ns(){return cl}var ni=b({},Zs,{key:function(i){if(i.key){var s=ua[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=Xs(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?ll[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ns,charCode:function(i){return i.type==="keypress"?Xs(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Xs(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),wo=zi(ni),ul=b({},ts,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Co=zi(ul),dl=b({},Zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ns}),wc=zi(dl),S=b({},es,{propertyName:0,elapsedTime:0,pseudoElement:0}),T=zi(S),L=b({},ts,{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}),Q=zi(L),le=b({},es,{newState:0,oldState:0}),ce=zi(le),be=[9,13,27,32],Be=xi&&"CompositionEvent"in window,je=null;xi&&"documentMode"in document&&(je=document.documentMode);var _t=xi&&"TextEvent"in window&&!je,It=xi&&(!Be||je&&8<je&&11>=je),ss=" ",ci=!1;function rs(i,s){switch(i){case"keyup":return be.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ha=!1;function mp(i,s){switch(i){case"compositionend":return vd(s);case"keypress":return s.which!==32?null:(ci=!0,ss);case"textInput":return i=s.data,i===ss&&ci?null:i;default:return null}}function _d(i,s){if(ha)return i==="compositionend"||!Be&&rs(i,s)?(i=aa(),Jn=Qn=Qe=null,ha=!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 It&&s.locale!=="ko"?null:s.data;default:return null}}var Cc={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 xo(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!Cc[i.type]:s==="textarea"}function xc(i,s,a,l){Ls?Mi?Mi.push(l):Mi=[l]:Ls=l,s=fh(s,"onChange"),0<s.length&&(a=new Os("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var fa=null,ko=null;function bd(i){S0(i,0)}function To(i){var s=Xn(i);if(rn(s))return i}function kc(i,s){if(i==="change")return s}var yd=!1;if(xi){var hl;if(xi){var as="oninput"in document;if(!as){var Sd=document.createElement("div");Sd.setAttribute("oninput","return;"),as=typeof Sd.oninput=="function"}hl=as}else hl=!1;yd=hl&&(!document.documentMode||9<document.documentMode)}function wd(){fa&&(fa.detachEvent("onpropertychange",Tc),ko=fa=null)}function Tc(i){if(i.propertyName==="value"&&To(ko)){var s=[];xc(s,ko,i,mo(i)),go(bd,s)}}function gp(i,s,a){i==="focusin"?(wd(),fa=s,ko=a,fa.attachEvent("onpropertychange",Tc)):i==="focusout"&&wd()}function vp(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return To(ko)}function Cr(i,s){if(i==="click")return To(s)}function _p(i,s){if(i==="input"||i==="change")return To(s)}function bp(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var Cn=typeof Object.is=="function"?Object.is:bp;function pa(i,s){if(Cn(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 d=a[l];if(!_e.call(s,d)||!Cn(i[d],s[d]))return!1}return!0}function Bs(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Cd(i,s){var a=Bs(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=Bs(a)}}function xd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?xd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function kd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=Ms(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=Ms(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 yp=xi&&"documentMode"in document&&11>=document.documentMode,xr=null,k=null,z=null,Me=!1;function Xe(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Me||xr==null||xr!==Ms(l)||(l=xr,"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}),z&&pa(z,l)||(z=l,l=fh(k,"onSelect"),0<l.length&&(s=new Os("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=xr)))}function qe(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var it={animationend:qe("Animation","AnimationEnd"),animationiteration:qe("Animation","AnimationIteration"),animationstart:qe("Animation","AnimationStart"),transitionrun:qe("Transition","TransitionRun"),transitionstart:qe("Transition","TransitionStart"),transitioncancel:qe("Transition","TransitionCancel"),transitionend:qe("Transition","TransitionEnd")},ft={},gt={};xi&&(gt=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 Ge(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 gt)return ft[i]=s[a];return i}var Jt=Ge("animationend"),Ut=Ge("animationiteration"),Pt=Ge("animationstart"),er=Ge("transitionrun"),fl=Ge("transitionstart"),tr=Ge("transitioncancel"),Ec=Ge("transitionend"),Dc=new Map,Sp="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(" ");Sp.push("scrollEnd");function js(i,s){Dc.set(i,s),Vt(s,[i])}var Td=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)},os=[],pl=0,wp=0;function Ed(){for(var i=pl,s=wp=pl=0;s<i;){var a=os[s];os[s++]=null;var l=os[s];os[s++]=null;var d=os[s];os[s++]=null;var m=os[s];if(os[s++]=null,l!==null&&d!==null){var y=l.pending;y===null?d.next=d:(d.next=y.next,y.next=d),l.pending=d}m!==0&&iy(a,d,m)}}function Dd(i,s,a,l){os[pl++]=i,os[pl++]=s,os[pl++]=a,os[pl++]=l,wp|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Cp(i,s,a,l){return Dd(i,s,a,l),Rd(i)}function Do(i,s){return Dd(i,null,null,s),Rd(i)}function iy(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var d=!1,m=i.return;m!==null;)m.childLanes|=a,l=m.alternate,l!==null&&(l.childLanes|=a),m.tag===22&&(i=m.stateNode,i===null||i._visibility&1||(d=!0)),i=m,m=m.return;return i.tag===3?(m=i.stateNode,d&&s!==null&&(d=31-lt(a),i=m.hiddenUpdates,l=i[d],l===null?i[d]=[s]:l.push(s),s.lane=a|536870912),m):null}function Rd(i){if(50<Gc)throw Gc=0,Am=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var ml={};function uE(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 In(i,s,a,l){return new uE(i,s,a,l)}function xp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function kr(i,s){var a=i.alternate;return a===null?(a=In(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 ny(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 Md(i,s,a,l,d,m){var y=0;if(l=i,typeof i=="function")xp(i)&&(y=1);else if(typeof i=="string")y=m2(i,a,ke.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case G:return i=In(31,a,s,d),i.elementType=G,i.lanes=m,i;case M:return Ro(a.children,d,m,s);case O:y=8,d|=24;break;case A:return i=In(12,a,s,d|2),i.elementType=A,i.lanes=m,i;case q:return i=In(13,a,s,d),i.elementType=q,i.lanes=m,i;case ae:return i=In(19,a,s,d),i.elementType=ae,i.lanes=m,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case F:y=10;break e;case W:y=9;break e;case U: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=In(y,a,s,d),s.elementType=i,s.type=l,s.lanes=m,s}function Ro(i,s,a,l){return i=In(7,i,l,s),i.lanes=a,i}function kp(i,s,a){return i=In(6,i,null,s),i.lanes=a,i}function sy(i){var s=In(18,null,null,0);return s.stateNode=i,s}function Tp(i,s,a){return s=In(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var ry=new WeakMap;function ls(i,s){if(typeof i=="object"&&i!==null){var a=ry.get(i);return a!==void 0?a:(s={value:i,source:s,stack:Te(s)},ry.set(i,s),s)}return{value:i,source:s,stack:Te(s)}}var gl=[],vl=0,Nd=null,Rc=0,cs=[],us=0,ma=null,ir=1,nr="";function Tr(i,s){gl[vl++]=Rc,gl[vl++]=Nd,Nd=i,Rc=s}function ay(i,s,a){cs[us++]=ir,cs[us++]=nr,cs[us++]=ma,ma=i;var l=ir;i=nr;var d=32-lt(l)-1;l&=~(1<<d),a+=1;var m=32-lt(s)+d;if(30<m){var y=d-d%5;m=(l&(1<<y)-1).toString(32),l>>=y,d-=y,ir=1<<32-lt(s)+d|a<<d|l,nr=m+i}else ir=1<<m|a<<d|l,nr=i}function Ep(i){i.return!==null&&(Tr(i,1),ay(i,1,0))}function Dp(i){for(;i===Nd;)Nd=gl[--vl],gl[vl]=null,Rc=gl[--vl],gl[vl]=null;for(;i===ma;)ma=cs[--us],cs[us]=null,nr=cs[--us],cs[us]=null,ir=cs[--us],cs[us]=null}function oy(i,s){cs[us++]=ir,cs[us++]=nr,cs[us++]=ma,ir=s.id,nr=s.overflow,ma=i}var on=null,ri=null,Et=!1,ga=null,ds=!1,Rp=Error(r(519));function va(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Mc(ls(s,i)),Rp}function ly(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[qt]=i,s[Qt]=l,a){case"dialog":wt("cancel",s),wt("close",s);break;case"iframe":case"object":case"embed":wt("load",s);break;case"video":case"audio":for(a=0;a<Qc.length;a++)wt(Qc[a],s);break;case"source":wt("error",s);break;case"img":case"image":case"link":wt("error",s),wt("load",s);break;case"details":wt("toggle",s);break;case"input":wt("invalid",s),vr(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":wt("invalid",s);break;case"textarea":wt("invalid",s),Vs(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||k0(s.textContent,a)?(l.popover!=null&&(wt("beforetoggle",s),wt("toggle",s)),l.onScroll!=null&&wt("scroll",s),l.onScrollEnd!=null&&wt("scrollend",s),l.onClick!=null&&(s.onclick=Zn),s=!0):s=!1,s||va(i,!0)}function cy(i){for(on=i.return;on;)switch(on.tag){case 5:case 31:case 13:ds=!1;return;case 27:case 3:ds=!0;return;default:on=on.return}}function _l(i){if(i!==on)return!1;if(!Et)return cy(i),Et=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Vm(i.type,i.memoizedProps)),a=!a),a&&ri&&va(i),cy(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ri=O0(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));ri=O0(i)}else s===27?(s=ri,Na(i.type)?(i=Qm,Qm=null,ri=i):ri=s):ri=on?fs(i.stateNode.nextSibling):null;return!0}function Mo(){ri=on=null,Et=!1}function Mp(){var i=ga;return i!==null&&(On===null?On=i:On.push.apply(On,i),ga=null),i}function Mc(i){ga===null?ga=[i]:ga.push(i)}var Np=N(null),No=null,Er=null;function _a(i,s,a){de(Np,s._currentValue),s._currentValue=a}function Dr(i){i._currentValue=Np.current,K(Np)}function Ap(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 Lp(i,s,a,l){var d=i.child;for(d!==null&&(d.return=i);d!==null;){var m=d.dependencies;if(m!==null){var y=d.child;m=m.firstContext;e:for(;m!==null;){var E=m;m=d;for(var j=0;j<s.length;j++)if(E.context===s[j]){m.lanes|=a,E=m.alternate,E!==null&&(E.lanes|=a),Ap(m.return,a,i),l||(y=null);break e}m=E.next}}else if(d.tag===18){if(y=d.return,y===null)throw Error(r(341));y.lanes|=a,m=y.alternate,m!==null&&(m.lanes|=a),Ap(y,a,i),y=null}else y=d.child;if(y!==null)y.return=d;else for(y=d;y!==null;){if(y===i){y=null;break}if(d=y.sibling,d!==null){d.return=y.return,y=d;break}y=y.return}d=y}}function bl(i,s,a,l){i=null;for(var d=s,m=!1;d!==null;){if(!m){if((d.flags&524288)!==0)m=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var y=d.alternate;if(y===null)throw Error(r(387));if(y=y.memoizedProps,y!==null){var E=d.type;Cn(d.pendingProps.value,y.value)||(i!==null?i.push(E):i=[E])}}else if(d===Le.current){if(y=d.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(i!==null?i.push(nu):i=[nu])}d=d.return}i!==null&&Lp(s,i,a,l),s.flags|=262144}function Ad(i){for(i=i.firstContext;i!==null;){if(!Cn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ao(i){No=i,Er=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function ln(i){return uy(No,i)}function Ld(i,s){return No===null&&Ao(i),uy(i,s)}function uy(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},Er===null){if(i===null)throw Error(r(308));Er=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else Er=Er.next=s;return a}var dE=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()})}},hE=e.unstable_scheduleCallback,fE=e.unstable_NormalPriority,Ni={$$typeof:F,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Op(){return{controller:new dE,data:new Map,refCount:0}}function Nc(i){i.refCount--,i.refCount===0&&hE(fE,function(){i.controller.abort()})}var Ac=null,Bp=0,yl=0,Sl=null;function pE(i,s){if(Ac===null){var a=Ac=[];Bp=0,yl=Pm(),Sl={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Bp++,s.then(dy,dy),s}function dy(){if(--Bp===0&&Ac!==null){Sl!==null&&(Sl.status="fulfilled");var i=Ac;Ac=null,yl=0,Sl=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function mE(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(d){a.push(d)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var d=0;d<a.length;d++)(0,a[d])(s)},function(d){for(l.status="rejected",l.reason=d,d=0;d<a.length;d++)(0,a[d])(void 0)}),l}var hy=B.S;B.S=function(i,s){XS=nt(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&pE(i,s),hy!==null&&hy(i,s)};var Lo=N(null);function jp(){var i=Lo.current;return i!==null?i:ei.pooledCache}function Od(i,s){s===null?de(Lo,Lo.current):de(Lo,s.pool)}function fy(){var i=jp();return i===null?null:{parent:Ni._currentValue,pool:i}}var wl=Error(r(460)),Ip=Error(r(474)),Bd=Error(r(542)),jd={then:function(){}};function py(i){return i=i.status,i==="fulfilled"||i==="rejected"}function my(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Zn,Zn),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,vy(i),i;default:if(typeof s.status=="string")s.then(Zn,Zn);else{if(i=ei,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var d=s;d.status="fulfilled",d.value=l}},function(l){if(s.status==="pending"){var d=s;d.status="rejected",d.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,vy(i),i}throw Bo=s,wl}}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,wl):a}}var Bo=null;function gy(){if(Bo===null)throw Error(r(459));var i=Bo;return Bo=null,i}function vy(i){if(i===wl||i===Bd)throw Error(r(483))}var Cl=null,Lc=0;function Id(i){var s=Lc;return Lc+=1,Cl===null&&(Cl=[]),my(Cl,i,s)}function Oc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function Pd(i,s){throw s.$$typeof===C?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function _y(i){function s(X,H){if(i){var ne=X.deletions;ne===null?(X.deletions=[H],X.flags|=16):ne.push(H)}}function a(X,H){if(!i)return null;for(;H!==null;)s(X,H),H=H.sibling;return null}function l(X){for(var H=new Map;X!==null;)X.key!==null?H.set(X.key,X):H.set(X.index,X),X=X.sibling;return H}function d(X,H){return X=kr(X,H),X.index=0,X.sibling=null,X}function m(X,H,ne){return X.index=ne,i?(ne=X.alternate,ne!==null?(ne=ne.index,ne<H?(X.flags|=67108866,H):ne):(X.flags|=67108866,H)):(X.flags|=1048576,H)}function y(X){return i&&X.alternate===null&&(X.flags|=67108866),X}function E(X,H,ne,ve){return H===null||H.tag!==6?(H=kp(ne,X.mode,ve),H.return=X,H):(H=d(H,ne),H.return=X,H)}function j(X,H,ne,ve){var Ze=ne.type;return Ze===M?me(X,H,ne.props.children,ve,ne.key):H!==null&&(H.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===te&&Oo(Ze)===H.type)?(H=d(H,ne.props),Oc(H,ne),H.return=X,H):(H=Md(ne.type,ne.key,ne.props,null,X.mode,ve),Oc(H,ne),H.return=X,H)}function se(X,H,ne,ve){return H===null||H.tag!==4||H.stateNode.containerInfo!==ne.containerInfo||H.stateNode.implementation!==ne.implementation?(H=Tp(ne,X.mode,ve),H.return=X,H):(H=d(H,ne.children||[]),H.return=X,H)}function me(X,H,ne,ve,Ze){return H===null||H.tag!==7?(H=Ro(ne,X.mode,ve,Ze),H.return=X,H):(H=d(H,ne),H.return=X,H)}function ye(X,H,ne){if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return H=kp(""+H,X.mode,ne),H.return=X,H;if(typeof H=="object"&&H!==null){switch(H.$$typeof){case w:return ne=Md(H.type,H.key,H.props,null,X.mode,ne),Oc(ne,H),ne.return=X,ne;case x:return H=Tp(H,X.mode,ne),H.return=X,H;case te:return H=Oo(H),ye(X,H,ne)}if(ie(H)||V(H))return H=Ro(H,X.mode,ne,null),H.return=X,H;if(typeof H.then=="function")return ye(X,Id(H),ne);if(H.$$typeof===F)return ye(X,Ld(X,H),ne);Pd(X,H)}return null}function oe(X,H,ne,ve){var Ze=H!==null?H.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return Ze!==null?null:E(X,H,""+ne,ve);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case w:return ne.key===Ze?j(X,H,ne,ve):null;case x:return ne.key===Ze?se(X,H,ne,ve):null;case te:return ne=Oo(ne),oe(X,H,ne,ve)}if(ie(ne)||V(ne))return Ze!==null?null:me(X,H,ne,ve,null);if(typeof ne.then=="function")return oe(X,H,Id(ne),ve);if(ne.$$typeof===F)return oe(X,H,Ld(X,ne),ve);Pd(X,ne)}return null}function he(X,H,ne,ve,Ze){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return X=X.get(ne)||null,E(H,X,""+ve,Ze);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case w:return X=X.get(ve.key===null?ne:ve.key)||null,j(H,X,ve,Ze);case x:return X=X.get(ve.key===null?ne:ve.key)||null,se(H,X,ve,Ze);case te:return ve=Oo(ve),he(X,H,ne,ve,Ze)}if(ie(ve)||V(ve))return X=X.get(ne)||null,me(H,X,ve,Ze,null);if(typeof ve.then=="function")return he(X,H,ne,Id(ve),Ze);if(ve.$$typeof===F)return he(X,H,ne,Ld(H,ve),Ze);Pd(H,ve)}return null}function $e(X,H,ne,ve){for(var Ze=null,Nt=null,Ye=H,pt=H=0,xt=null;Ye!==null&&pt<ne.length;pt++){Ye.index>pt?(xt=Ye,Ye=null):xt=Ye.sibling;var At=oe(X,Ye,ne[pt],ve);if(At===null){Ye===null&&(Ye=xt);break}i&&Ye&&At.alternate===null&&s(X,Ye),H=m(At,H,pt),Nt===null?Ze=At:Nt.sibling=At,Nt=At,Ye=xt}if(pt===ne.length)return a(X,Ye),Et&&Tr(X,pt),Ze;if(Ye===null){for(;pt<ne.length;pt++)Ye=ye(X,ne[pt],ve),Ye!==null&&(H=m(Ye,H,pt),Nt===null?Ze=Ye:Nt.sibling=Ye,Nt=Ye);return Et&&Tr(X,pt),Ze}for(Ye=l(Ye);pt<ne.length;pt++)xt=he(Ye,X,pt,ne[pt],ve),xt!==null&&(i&&xt.alternate!==null&&Ye.delete(xt.key===null?pt:xt.key),H=m(xt,H,pt),Nt===null?Ze=xt:Nt.sibling=xt,Nt=xt);return i&&Ye.forEach(function(ja){return s(X,ja)}),Et&&Tr(X,pt),Ze}function et(X,H,ne,ve){if(ne==null)throw Error(r(151));for(var Ze=null,Nt=null,Ye=H,pt=H=0,xt=null,At=ne.next();Ye!==null&&!At.done;pt++,At=ne.next()){Ye.index>pt?(xt=Ye,Ye=null):xt=Ye.sibling;var ja=oe(X,Ye,At.value,ve);if(ja===null){Ye===null&&(Ye=xt);break}i&&Ye&&ja.alternate===null&&s(X,Ye),H=m(ja,H,pt),Nt===null?Ze=ja:Nt.sibling=ja,Nt=ja,Ye=xt}if(At.done)return a(X,Ye),Et&&Tr(X,pt),Ze;if(Ye===null){for(;!At.done;pt++,At=ne.next())At=ye(X,At.value,ve),At!==null&&(H=m(At,H,pt),Nt===null?Ze=At:Nt.sibling=At,Nt=At);return Et&&Tr(X,pt),Ze}for(Ye=l(Ye);!At.done;pt++,At=ne.next())At=he(Ye,X,pt,At.value,ve),At!==null&&(i&&At.alternate!==null&&Ye.delete(At.key===null?pt:At.key),H=m(At,H,pt),Nt===null?Ze=At:Nt.sibling=At,Nt=At);return i&&Ye.forEach(function(T2){return s(X,T2)}),Et&&Tr(X,pt),Ze}function Gt(X,H,ne,ve){if(typeof ne=="object"&&ne!==null&&ne.type===M&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case w:e:{for(var Ze=ne.key;H!==null;){if(H.key===Ze){if(Ze=ne.type,Ze===M){if(H.tag===7){a(X,H.sibling),ve=d(H,ne.props.children),ve.return=X,X=ve;break e}}else if(H.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===te&&Oo(Ze)===H.type){a(X,H.sibling),ve=d(H,ne.props),Oc(ve,ne),ve.return=X,X=ve;break e}a(X,H);break}else s(X,H);H=H.sibling}ne.type===M?(ve=Ro(ne.props.children,X.mode,ve,ne.key),ve.return=X,X=ve):(ve=Md(ne.type,ne.key,ne.props,null,X.mode,ve),Oc(ve,ne),ve.return=X,X=ve)}return y(X);case x:e:{for(Ze=ne.key;H!==null;){if(H.key===Ze)if(H.tag===4&&H.stateNode.containerInfo===ne.containerInfo&&H.stateNode.implementation===ne.implementation){a(X,H.sibling),ve=d(H,ne.children||[]),ve.return=X,X=ve;break e}else{a(X,H);break}else s(X,H);H=H.sibling}ve=Tp(ne,X.mode,ve),ve.return=X,X=ve}return y(X);case te:return ne=Oo(ne),Gt(X,H,ne,ve)}if(ie(ne))return $e(X,H,ne,ve);if(V(ne)){if(Ze=V(ne),typeof Ze!="function")throw Error(r(150));return ne=Ze.call(ne),et(X,H,ne,ve)}if(typeof ne.then=="function")return Gt(X,H,Id(ne),ve);if(ne.$$typeof===F)return Gt(X,H,Ld(X,ne),ve);Pd(X,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,H!==null&&H.tag===6?(a(X,H.sibling),ve=d(H,ne),ve.return=X,X=ve):(a(X,H),ve=kp(ne,X.mode,ve),ve.return=X,X=ve),y(X)):a(X,H)}return function(X,H,ne,ve){try{Lc=0;var Ze=Gt(X,H,ne,ve);return Cl=null,Ze}catch(Ye){if(Ye===wl||Ye===Bd)throw Ye;var Nt=In(29,Ye,null,X.mode);return Nt.lanes=ve,Nt.return=X,Nt}}}var jo=_y(!0),by=_y(!1),ba=!1;function Pp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zp(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 ya(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Sa(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Ot&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,s=Rd(i),iy(i,null,a),s}return Dd(i,l,s,a),Rd(i)}function Bc(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,ii(i,a)}}function Hp(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var d=null,m=null;if(a=a.firstBaseUpdate,a!==null){do{var y={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};m===null?d=m=y:m=m.next=y,a=a.next}while(a!==null);m===null?d=m=s:m=m.next=s}else d=m=s;a={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:m,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 Up=!1;function jc(){if(Up){var i=Sl;if(i!==null)throw i}}function Ic(i,s,a,l){Up=!1;var d=i.updateQueue;ba=!1;var m=d.firstBaseUpdate,y=d.lastBaseUpdate,E=d.shared.pending;if(E!==null){d.shared.pending=null;var j=E,se=j.next;j.next=null,y===null?m=se:y.next=se,y=j;var me=i.alternate;me!==null&&(me=me.updateQueue,E=me.lastBaseUpdate,E!==y&&(E===null?me.firstBaseUpdate=se:E.next=se,me.lastBaseUpdate=j))}if(m!==null){var ye=d.baseState;y=0,me=se=j=null,E=m;do{var oe=E.lane&-536870913,he=oe!==E.lane;if(he?(Ct&oe)===oe:(l&oe)===oe){oe!==0&&oe===yl&&(Up=!0),me!==null&&(me=me.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var $e=i,et=E;oe=s;var Gt=a;switch(et.tag){case 1:if($e=et.payload,typeof $e=="function"){ye=$e.call(Gt,ye,oe);break e}ye=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=et.payload,oe=typeof $e=="function"?$e.call(Gt,ye,oe):$e,oe==null)break e;ye=b({},ye,oe);break e;case 2:ba=!0}}oe=E.callback,oe!==null&&(i.flags|=64,he&&(i.flags|=8192),he=d.callbacks,he===null?d.callbacks=[oe]:he.push(oe))}else he={lane:oe,tag:E.tag,payload:E.payload,callback:E.callback,next:null},me===null?(se=me=he,j=ye):me=me.next=he,y|=oe;if(E=E.next,E===null){if(E=d.shared.pending,E===null)break;he=E,E=he.next,he.next=null,d.lastBaseUpdate=he,d.shared.pending=null}}while(!0);me===null&&(j=ye),d.baseState=j,d.firstBaseUpdate=se,d.lastBaseUpdate=me,m===null&&(d.shared.lanes=0),Ta|=y,i.lanes=y,i.memoizedState=ye}}function yy(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function Sy(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)yy(a[i],s)}var xl=N(null),zd=N(0);function wy(i,s){i=Ir,de(zd,i),de(xl,s),Ir=i|s.baseLanes}function Fp(){de(zd,Ir),de(xl,xl.current)}function Kp(){Ir=zd.current,K(xl),K(zd)}var Pn=N(null),hs=null;function wa(i){var s=i.alternate;de(ki,ki.current&1),de(Pn,i),hs===null&&(s===null||xl.current!==null||s.memoizedState!==null)&&(hs=i)}function $p(i){de(ki,ki.current),de(Pn,i),hs===null&&(hs=i)}function Cy(i){i.tag===22?(de(ki,ki.current),de(Pn,i),hs===null&&(hs=i)):Ca()}function Ca(){de(ki,ki.current),de(Pn,Pn.current)}function zn(i){K(Pn),hs===i&&(hs=null),K(ki)}var ki=N(0);function Hd(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Gm(a)||Zm(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 Rr=0,dt=null,Yt=null,Ai=null,Ud=!1,kl=!1,Io=!1,Fd=0,Pc=0,Tl=null,gE=0;function vi(){throw Error(r(321))}function Wp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!Cn(i[a],s[a]))return!1;return!0}function qp(i,s,a,l,d,m){return Rr=m,dt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,B.H=i===null||i.memoizedState===null?aS:om,Io=!1,m=a(l,d),Io=!1,kl&&(m=ky(s,a,l,d)),xy(i),m}function xy(i){B.H=Uc;var s=Yt!==null&&Yt.next!==null;if(Rr=0,Ai=Yt=dt=null,Ud=!1,Pc=0,Tl=null,s)throw Error(r(300));i===null||Li||(i=i.dependencies,i!==null&&Ad(i)&&(Li=!0))}function ky(i,s,a,l){dt=i;var d=0;do{if(kl&&(Tl=null),Pc=0,kl=!1,25<=d)throw Error(r(301));if(d+=1,Ai=Yt=null,i.updateQueue!=null){var m=i.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}B.H=oS,m=s(a,l)}while(kl);return m}function vE(){var i=B.H,s=i.useState()[0];return s=typeof s.then=="function"?zc(s):s,i=i.useState()[0],(Yt!==null?Yt.memoizedState:null)!==i&&(dt.flags|=1024),s}function Vp(){var i=Fd!==0;return Fd=0,i}function Yp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Xp(i){if(Ud){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Ud=!1}Rr=0,Ai=Yt=dt=null,kl=!1,Pc=Fd=0,Tl=null}function xn(){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 Ti(){if(Yt===null){var i=dt.alternate;i=i!==null?i.memoizedState:null}else i=Yt.next;var s=Ai===null?dt.memoizedState:Ai.next;if(s!==null)Ai=s,Yt=i;else{if(i===null)throw dt.alternate===null?Error(r(467)):Error(r(310));Yt=i,i={memoizedState:Yt.memoizedState,baseState:Yt.baseState,baseQueue:Yt.baseQueue,queue:Yt.queue,next:null},Ai===null?dt.memoizedState=Ai=i:Ai=Ai.next=i}return Ai}function Kd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function zc(i){var s=Pc;return Pc+=1,Tl===null&&(Tl=[]),i=my(Tl,i,s),s=dt,(Ai===null?s.memoizedState:Ai.next)===null&&(s=s.alternate,B.H=s===null||s.memoizedState===null?aS:om),i}function $d(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return zc(i);if(i.$$typeof===F)return ln(i)}throw Error(r(438,String(i)))}function Gp(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(d){return d.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Kd(),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]=ge;return s.index++,a}function Mr(i,s){return typeof s=="function"?s(i):s}function Wd(i){var s=Ti();return Zp(s,Yt,i)}function Zp(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var d=i.baseQueue,m=l.pending;if(m!==null){if(d!==null){var y=d.next;d.next=m.next,m.next=y}s.baseQueue=d=m,l.pending=null}if(m=i.baseState,d===null)i.memoizedState=m;else{s=d.next;var E=y=null,j=null,se=s,me=!1;do{var ye=se.lane&-536870913;if(ye!==se.lane?(Ct&ye)===ye:(Rr&ye)===ye){var oe=se.revertLane;if(oe===0)j!==null&&(j=j.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),ye===yl&&(me=!0);else if((Rr&oe)===oe){se=se.next,oe===yl&&(me=!0);continue}else ye={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},j===null?(E=j=ye,y=m):j=j.next=ye,dt.lanes|=oe,Ta|=oe;ye=se.action,Io&&a(m,ye),m=se.hasEagerState?se.eagerState:a(m,ye)}else oe={lane:ye,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},j===null?(E=j=oe,y=m):j=j.next=oe,dt.lanes|=ye,Ta|=ye;se=se.next}while(se!==null&&se!==s);if(j===null?y=m:j.next=E,!Cn(m,i.memoizedState)&&(Li=!0,me&&(a=Sl,a!==null)))throw a;i.memoizedState=m,i.baseState=y,i.baseQueue=j,l.lastRenderedState=m}return d===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Qp(i){var s=Ti(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,d=a.pending,m=s.memoizedState;if(d!==null){a.pending=null;var y=d=d.next;do m=i(m,y.action),y=y.next;while(y!==d);Cn(m,s.memoizedState)||(Li=!0),s.memoizedState=m,s.baseQueue===null&&(s.baseState=m),a.lastRenderedState=m}return[m,l]}function Ty(i,s,a){var l=dt,d=Ti(),m=Et;if(m){if(a===void 0)throw Error(r(407));a=a()}else a=s();var y=!Cn((Yt||d).memoizedState,a);if(y&&(d.memoizedState=a,Li=!0),d=d.queue,tm(Ry.bind(null,l,d,i),[i]),d.getSnapshot!==s||y||Ai!==null&&Ai.memoizedState.tag&1){if(l.flags|=2048,El(9,{destroy:void 0},Dy.bind(null,l,d,a,s),null),ei===null)throw Error(r(349));m||(Rr&127)!==0||Ey(l,s,a)}return a}function Ey(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=dt.updateQueue,s===null?(s=Kd(),dt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function Dy(i,s,a,l){s.value=a,s.getSnapshot=l,My(s)&&Ny(i)}function Ry(i,s,a){return a(function(){My(s)&&Ny(i)})}function My(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!Cn(i,a)}catch{return!0}}function Ny(i){var s=Do(i,2);s!==null&&Bn(s,i,2)}function Jp(i){var s=xn();if(typeof i=="function"){var a=i;if(i=a(),Io){kt(!0);try{a()}finally{kt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mr,lastRenderedState:i},s}function Ay(i,s,a,l){return i.baseState=a,Zp(i,Yt,typeof l=="function"?l:Mr)}function _E(i,s,a,l,d){if(Yd(i))throw Error(r(485));if(i=s.action,i!==null){var m={payload:d,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){m.listeners.push(y)}};B.T!==null?a(!0):m.isTransition=!1,l(m),a=s.pending,a===null?(m.next=s.pending=m,Ly(s,m)):(m.next=a.next,s.pending=a.next=m)}}function Ly(i,s){var a=s.action,l=s.payload,d=i.state;if(s.isTransition){var m=B.T,y={};B.T=y;try{var E=a(d,l),j=B.S;j!==null&&j(y,E),Oy(i,s,E)}catch(se){em(i,s,se)}finally{m!==null&&y.types!==null&&(m.types=y.types),B.T=m}}else try{m=a(d,l),Oy(i,s,m)}catch(se){em(i,s,se)}}function Oy(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){By(i,s,l)},function(l){return em(i,s,l)}):By(i,s,a)}function By(i,s,a){s.status="fulfilled",s.value=a,jy(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,Ly(i,a)))}function em(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,jy(s),s=s.next;while(s!==l)}i.action=null}function jy(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function Iy(i,s){return s}function Py(i,s){if(Et){var a=ei.formState;if(a!==null){e:{var l=dt;if(Et){if(ri){t:{for(var d=ri,m=ds;d.nodeType!==8;){if(!m){d=null;break t}if(d=fs(d.nextSibling),d===null){d=null;break t}}m=d.data,d=m==="F!"||m==="F"?d:null}if(d){ri=fs(d.nextSibling),l=d.data==="F!";break e}}va(l)}l=!1}l&&(s=a[0])}}return a=xn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Iy,lastRenderedState:s},a.queue=l,a=nS.bind(null,dt,l),l.dispatch=a,l=Jp(!1),m=am.bind(null,dt,!1,l.queue),l=xn(),d={state:s,dispatch:null,action:i,pending:null},l.queue=d,a=_E.bind(null,dt,d,m,a),d.dispatch=a,l.memoizedState=i,[s,a,!1]}function zy(i){var s=Ti();return Hy(s,Yt,i)}function Hy(i,s,a){if(s=Zp(i,s,Iy)[0],i=Wd(Mr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=zc(s)}catch(y){throw y===wl?Bd:y}else l=s;s=Ti();var d=s.queue,m=d.dispatch;return a!==s.memoizedState&&(dt.flags|=2048,El(9,{destroy:void 0},bE.bind(null,d,a),null)),[l,m,i]}function bE(i,s){i.action=s}function Uy(i){var s=Ti(),a=Yt;if(a!==null)return Hy(s,a,i);Ti(),s=s.memoizedState,a=Ti();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function El(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=dt.updateQueue,s===null&&(s=Kd(),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 Fy(){return Ti().memoizedState}function qd(i,s,a,l){var d=xn();dt.flags|=i,d.memoizedState=El(1|s,{destroy:void 0},a,l===void 0?null:l)}function Vd(i,s,a,l){var d=Ti();l=l===void 0?null:l;var m=d.memoizedState.inst;Yt!==null&&l!==null&&Wp(l,Yt.memoizedState.deps)?d.memoizedState=El(s,m,a,l):(dt.flags|=i,d.memoizedState=El(1|s,m,a,l))}function Ky(i,s){qd(8390656,8,i,s)}function tm(i,s){Vd(2048,8,i,s)}function yE(i){dt.flags|=4;var s=dt.updateQueue;if(s===null)s=Kd(),dt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function $y(i){var s=Ti().memoizedState;return yE({ref:s,nextImpl:i}),function(){if((Ot&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Wy(i,s){return Vd(4,2,i,s)}function qy(i,s){return Vd(4,4,i,s)}function Vy(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 Yy(i,s,a){a=a!=null?a.concat([i]):null,Vd(4,4,Vy.bind(null,s,i),a)}function im(){}function Xy(i,s){var a=Ti();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Wp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function Gy(i,s){var a=Ti();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Wp(s,l[1]))return l[0];if(l=i(),Io){kt(!0);try{i()}finally{kt(!1)}}return a.memoizedState=[l,s],l}function nm(i,s,a){return a===void 0||(Rr&1073741824)!==0&&(Ct&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=ZS(),dt.lanes|=i,Ta|=i,a)}function Zy(i,s,a,l){return Cn(a,s)?a:xl.current!==null?(i=nm(i,a,l),Cn(i,s)||(Li=!0),i):(Rr&42)===0||(Rr&1073741824)!==0&&(Ct&261930)===0?(Li=!0,i.memoizedState=a):(i=ZS(),dt.lanes|=i,Ta|=i,s)}function Qy(i,s,a,l,d){var m=R.p;R.p=m!==0&&8>m?m:8;var y=B.T,E={};B.T=E,am(i,!1,s,a);try{var j=d(),se=B.S;if(se!==null&&se(E,j),j!==null&&typeof j=="object"&&typeof j.then=="function"){var me=mE(j,l);Hc(i,s,me,Fn(i))}else Hc(i,s,l,Fn(i))}catch(ye){Hc(i,s,{then:function(){},status:"rejected",reason:ye},Fn())}finally{R.p=m,y!==null&&E.types!==null&&(y.types=E.types),B.T=y}}function SE(){}function sm(i,s,a,l){if(i.tag!==5)throw Error(r(476));var d=Jy(i).queue;Qy(i,d,s,I,a===null?SE:function(){return eS(i),a(l)})}function Jy(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:Mr,lastRenderedState:I},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function eS(i){var s=Jy(i);s.next===null&&(s=i.alternate.memoizedState),Hc(i,s.next.queue,{},Fn())}function rm(){return ln(nu)}function tS(){return Ti().memoizedState}function iS(){return Ti().memoizedState}function wE(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Fn();i=ya(a);var l=Sa(s,i,a);l!==null&&(Bn(l,s,a),Bc(l,s,a)),s={cache:Op()},i.payload=s;return}s=s.return}}function CE(i,s,a){var l=Fn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Yd(i)?sS(s,a):(a=Cp(i,s,a,l),a!==null&&(Bn(a,i,l),rS(a,s,l)))}function nS(i,s,a){var l=Fn();Hc(i,s,a,l)}function Hc(i,s,a,l){var d={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Yd(i))sS(s,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=s.lastRenderedReducer,m!==null))try{var y=s.lastRenderedState,E=m(y,a);if(d.hasEagerState=!0,d.eagerState=E,Cn(E,y))return Dd(i,s,d,0),ei===null&&Ed(),!1}catch{}if(a=Cp(i,s,d,l),a!==null)return Bn(a,i,l),rS(a,s,l),!0}return!1}function am(i,s,a,l){if(l={lane:2,revertLane:Pm(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Yd(i)){if(s)throw Error(r(479))}else s=Cp(i,a,l,2),s!==null&&Bn(s,i,2)}function Yd(i){var s=i.alternate;return i===dt||s!==null&&s===dt}function sS(i,s){kl=Ud=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function rS(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,ii(i,a)}}var Uc={readContext:ln,use:$d,useCallback:vi,useContext:vi,useEffect:vi,useImperativeHandle:vi,useLayoutEffect:vi,useInsertionEffect:vi,useMemo:vi,useReducer:vi,useRef:vi,useState:vi,useDebugValue:vi,useDeferredValue:vi,useTransition:vi,useSyncExternalStore:vi,useId:vi,useHostTransitionStatus:vi,useFormState:vi,useActionState:vi,useOptimistic:vi,useMemoCache:vi,useCacheRefresh:vi};Uc.useEffectEvent=vi;var aS={readContext:ln,use:$d,useCallback:function(i,s){return xn().memoizedState=[i,s===void 0?null:s],i},useContext:ln,useEffect:Ky,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,qd(4194308,4,Vy.bind(null,s,i),a)},useLayoutEffect:function(i,s){return qd(4194308,4,i,s)},useInsertionEffect:function(i,s){qd(4,2,i,s)},useMemo:function(i,s){var a=xn();s=s===void 0?null:s;var l=i();if(Io){kt(!0);try{i()}finally{kt(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=xn();if(a!==void 0){var d=a(s);if(Io){kt(!0);try{a(s)}finally{kt(!1)}}}else d=s;return l.memoizedState=l.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},l.queue=i,i=i.dispatch=CE.bind(null,dt,i),[l.memoizedState,i]},useRef:function(i){var s=xn();return i={current:i},s.memoizedState=i},useState:function(i){i=Jp(i);var s=i.queue,a=nS.bind(null,dt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:im,useDeferredValue:function(i,s){var a=xn();return nm(a,i,s)},useTransition:function(){var i=Jp(!1);return i=Qy.bind(null,dt,i.queue,!0,!1),xn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=dt,d=xn();if(Et){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),ei===null)throw Error(r(349));(Ct&127)!==0||Ey(l,s,a)}d.memoizedState=a;var m={value:a,getSnapshot:s};return d.queue=m,Ky(Ry.bind(null,l,m,i),[i]),l.flags|=2048,El(9,{destroy:void 0},Dy.bind(null,l,m,a,s),null),a},useId:function(){var i=xn(),s=ei.identifierPrefix;if(Et){var a=nr,l=ir;a=(l&~(1<<32-lt(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Fd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=gE++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:rm,useFormState:Py,useActionState:Py,useOptimistic:function(i){var s=xn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=am.bind(null,dt,!0,a),a.dispatch=s,[i,s]},useMemoCache:Gp,useCacheRefresh:function(){return xn().memoizedState=wE.bind(null,dt)},useEffectEvent:function(i){var s=xn(),a={impl:i};return s.memoizedState=a,function(){if((Ot&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},om={readContext:ln,use:$d,useCallback:Xy,useContext:ln,useEffect:tm,useImperativeHandle:Yy,useInsertionEffect:Wy,useLayoutEffect:qy,useMemo:Gy,useReducer:Wd,useRef:Fy,useState:function(){return Wd(Mr)},useDebugValue:im,useDeferredValue:function(i,s){var a=Ti();return Zy(a,Yt.memoizedState,i,s)},useTransition:function(){var i=Wd(Mr)[0],s=Ti().memoizedState;return[typeof i=="boolean"?i:zc(i),s]},useSyncExternalStore:Ty,useId:tS,useHostTransitionStatus:rm,useFormState:zy,useActionState:zy,useOptimistic:function(i,s){var a=Ti();return Ay(a,Yt,i,s)},useMemoCache:Gp,useCacheRefresh:iS};om.useEffectEvent=$y;var oS={readContext:ln,use:$d,useCallback:Xy,useContext:ln,useEffect:tm,useImperativeHandle:Yy,useInsertionEffect:Wy,useLayoutEffect:qy,useMemo:Gy,useReducer:Qp,useRef:Fy,useState:function(){return Qp(Mr)},useDebugValue:im,useDeferredValue:function(i,s){var a=Ti();return Yt===null?nm(a,i,s):Zy(a,Yt.memoizedState,i,s)},useTransition:function(){var i=Qp(Mr)[0],s=Ti().memoizedState;return[typeof i=="boolean"?i:zc(i),s]},useSyncExternalStore:Ty,useId:tS,useHostTransitionStatus:rm,useFormState:Uy,useActionState:Uy,useOptimistic:function(i,s){var a=Ti();return Yt!==null?Ay(a,Yt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Gp,useCacheRefresh:iS};oS.useEffectEvent=$y;function lm(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 cm={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Fn(),d=ya(l);d.payload=s,a!=null&&(d.callback=a),s=Sa(i,d,l),s!==null&&(Bn(s,i,l),Bc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Fn(),d=ya(l);d.tag=1,d.payload=s,a!=null&&(d.callback=a),s=Sa(i,d,l),s!==null&&(Bn(s,i,l),Bc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Fn(),l=ya(a);l.tag=2,s!=null&&(l.callback=s),s=Sa(i,l,a),s!==null&&(Bn(s,i,a),Bc(s,i,a))}};function lS(i,s,a,l,d,m,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,m,y):s.prototype&&s.prototype.isPureReactComponent?!pa(a,l)||!pa(d,m):!0}function cS(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&&cm.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 d in i)a[d]===void 0&&(a[d]=i[d])}return a}function uS(i){Td(i)}function dS(i){console.error(i)}function hS(i){Td(i)}function Xd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function fS(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function um(i,s,a){return a=ya(a),a.tag=3,a.payload={element:null},a.callback=function(){Xd(i,s)},a}function pS(i){return i=ya(i),i.tag=3,i}function mS(i,s,a,l){var d=a.type.getDerivedStateFromError;if(typeof d=="function"){var m=l.value;i.payload=function(){return d(m)},i.callback=function(){fS(s,a,l)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){fS(s,a,l),typeof d!="function"&&(Ea===null?Ea=new Set([this]):Ea.add(this));var E=l.stack;this.componentDidCatch(l.value,{componentStack:E!==null?E:""})})}function xE(i,s,a,l,d){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&bl(s,a,d,!0),a=Pn.current,a!==null){switch(a.tag){case 31:case 13:return hs===null?oh():a.alternate===null&&_i===0&&(_i=3),a.flags&=-257,a.flags|=65536,a.lanes=d,l===jd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),Bm(i,l,d)),!1;case 22:return a.flags|=65536,l===jd?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)),Bm(i,l,d)),!1}throw Error(r(435,a.tag))}return Bm(i,l,d),oh(),!1}if(Et)return s=Pn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=d,l!==Rp&&(i=Error(r(422),{cause:l}),Mc(ls(i,a)))):(l!==Rp&&(s=Error(r(423),{cause:l}),Mc(ls(s,a))),i=i.current.alternate,i.flags|=65536,d&=-d,i.lanes|=d,l=ls(l,a),d=um(i.stateNode,l,d),Hp(i,d),_i!==4&&(_i=2)),!1;var m=Error(r(520),{cause:l});if(m=ls(m,a),Xc===null?Xc=[m]:Xc.push(m),_i!==4&&(_i=2),s===null)return!0;l=ls(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=d&-d,a.lanes|=i,i=um(a.stateNode,l,i),Hp(a,i),!1;case 1:if(s=a.type,m=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Ea===null||!Ea.has(m))))return a.flags|=65536,d&=-d,a.lanes|=d,d=pS(d),mS(d,i,a,l),Hp(a,d),!1}a=a.return}while(a!==null);return!1}var dm=Error(r(461)),Li=!1;function cn(i,s,a,l){s.child=i===null?by(s,null,a,l):jo(s,i.child,a,l)}function gS(i,s,a,l,d){a=a.render;var m=s.ref;if("ref"in l){var y={};for(var E in l)E!=="ref"&&(y[E]=l[E])}else y=l;return Ao(s),l=qp(i,s,a,y,m,d),E=Vp(),i!==null&&!Li?(Yp(i,s,d),Nr(i,s,d)):(Et&&E&&Ep(s),s.flags|=1,cn(i,s,l,d),s.child)}function vS(i,s,a,l,d){if(i===null){var m=a.type;return typeof m=="function"&&!xp(m)&&m.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=m,_S(i,s,m,l,d)):(i=Md(a.type,null,l,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(m=i.child,!bm(i,d)){var y=m.memoizedProps;if(a=a.compare,a=a!==null?a:pa,a(y,l)&&i.ref===s.ref)return Nr(i,s,d)}return s.flags|=1,i=kr(m,l),i.ref=s.ref,i.return=s,s.child=i}function _S(i,s,a,l,d){if(i!==null){var m=i.memoizedProps;if(pa(m,l)&&i.ref===s.ref)if(Li=!1,s.pendingProps=l=m,bm(i,d))(i.flags&131072)!==0&&(Li=!0);else return s.lanes=i.lanes,Nr(i,s,d)}return hm(i,s,a,l,d)}function bS(i,s,a,l){var d=l.children,m=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(m=m!==null?m.baseLanes|a:a,i!==null){for(l=s.child=i.child,d=0;l!==null;)d=d|l.lanes|l.childLanes,l=l.sibling;l=d&~m}else l=0,s.child=null;return yS(i,s,m,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Od(s,m!==null?m.cachePool:null),m!==null?wy(s,m):Fp(),Cy(s);else return l=s.lanes=536870912,yS(i,s,m!==null?m.baseLanes|a:a,a,l)}else m!==null?(Od(s,m.cachePool),wy(s,m),Ca(),s.memoizedState=null):(i!==null&&Od(s,null),Fp(),Ca());return cn(i,s,d,a),s.child}function Fc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function yS(i,s,a,l,d){var m=jp();return m=m===null?null:{parent:Ni._currentValue,pool:m},s.memoizedState={baseLanes:a,cachePool:m},i!==null&&Od(s,null),Fp(),Cy(s),i!==null&&bl(i,s,l,!0),s.childLanes=d,null}function Gd(i,s){return s=Qd({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function SS(i,s,a){return jo(s,i.child,null,a),i=Gd(s,s.pendingProps),i.flags|=2,zn(s),s.memoizedState=null,i}function kE(i,s,a){var l=s.pendingProps,d=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Et){if(l.mode==="hidden")return i=Gd(s,l),s.lanes=536870912,Fc(null,i);if($p(s),(i=ri)?(i=L0(i,ds),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ma!==null?{id:ir,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=sy(i),a.return=s,s.child=a,on=s,ri=null)):i=null,i===null)throw va(s);return s.lanes=536870912,null}return Gd(s,l)}var m=i.memoizedState;if(m!==null){var y=m.dehydrated;if($p(s),d)if(s.flags&256)s.flags&=-257,s=SS(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||bl(i,s,a,!1),d=(a&i.childLanes)!==0,Li||d){if(l=ei,l!==null&&(y=sn(l,a),y!==0&&y!==m.retryLane))throw m.retryLane=y,Do(i,y),Bn(l,i,y),dm;oh(),s=SS(i,s,a)}else i=m.treeContext,ri=fs(y.nextSibling),on=s,Et=!0,ga=null,ds=!1,i!==null&&oy(s,i),s=Gd(s,l),s.flags|=4096;return s}return i=kr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Zd(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 hm(i,s,a,l,d){return Ao(s),a=qp(i,s,a,l,void 0,d),l=Vp(),i!==null&&!Li?(Yp(i,s,d),Nr(i,s,d)):(Et&&l&&Ep(s),s.flags|=1,cn(i,s,a,d),s.child)}function wS(i,s,a,l,d,m){return Ao(s),s.updateQueue=null,a=ky(s,l,a,d),xy(i),l=Vp(),i!==null&&!Li?(Yp(i,s,m),Nr(i,s,m)):(Et&&l&&Ep(s),s.flags|=1,cn(i,s,a,m),s.child)}function CS(i,s,a,l,d){if(Ao(s),s.stateNode===null){var m=ml,y=a.contextType;typeof y=="object"&&y!==null&&(m=ln(y)),m=new a(l,m),s.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=cm,s.stateNode=m,m._reactInternals=s,m=s.stateNode,m.props=l,m.state=s.memoizedState,m.refs={},Pp(s),y=a.contextType,m.context=typeof y=="object"&&y!==null?ln(y):ml,m.state=s.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(lm(s,a,y,l),m.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(y=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),y!==m.state&&cm.enqueueReplaceState(m,m.state,null),Ic(s,l,m,d),jc(),m.state=s.memoizedState),typeof m.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){m=s.stateNode;var E=s.memoizedProps,j=Po(a,E);m.props=j;var se=m.context,me=a.contextType;y=ml,typeof me=="object"&&me!==null&&(y=ln(me));var ye=a.getDerivedStateFromProps;me=typeof ye=="function"||typeof m.getSnapshotBeforeUpdate=="function",E=s.pendingProps!==E,me||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(E||se!==y)&&cS(s,m,l,y),ba=!1;var oe=s.memoizedState;m.state=oe,Ic(s,l,m,d),jc(),se=s.memoizedState,E||oe!==se||ba?(typeof ye=="function"&&(lm(s,a,ye,l),se=s.memoizedState),(j=ba||lS(s,a,j,l,oe,se,y))?(me||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(s.flags|=4194308)):(typeof m.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=se),m.props=l,m.state=se,m.context=y,l=j):(typeof m.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{m=s.stateNode,zp(i,s),y=s.memoizedProps,me=Po(a,y),m.props=me,ye=s.pendingProps,oe=m.context,se=a.contextType,j=ml,typeof se=="object"&&se!==null&&(j=ln(se)),E=a.getDerivedStateFromProps,(se=typeof E=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(y!==ye||oe!==j)&&cS(s,m,l,j),ba=!1,oe=s.memoizedState,m.state=oe,Ic(s,l,m,d),jc();var he=s.memoizedState;y!==ye||oe!==he||ba||i!==null&&i.dependencies!==null&&Ad(i.dependencies)?(typeof E=="function"&&(lm(s,a,E,l),he=s.memoizedState),(me=ba||lS(s,a,me,l,oe,he,j)||i!==null&&i.dependencies!==null&&Ad(i.dependencies))?(se||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(l,he,j),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(l,he,j)),typeof m.componentDidUpdate=="function"&&(s.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&oe===i.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&oe===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=he),m.props=l,m.state=he,m.context=j,l=me):(typeof m.componentDidUpdate!="function"||y===i.memoizedProps&&oe===i.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&oe===i.memoizedState||(s.flags|=1024),l=!1)}return m=l,Zd(i,s),l=(s.flags&128)!==0,m||l?(m=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:m.render(),s.flags|=1,i!==null&&l?(s.child=jo(s,i.child,null,d),s.child=jo(s,null,a,d)):cn(i,s,a,d),s.memoizedState=m.state,i=s.child):i=Nr(i,s,d),i}function xS(i,s,a,l){return Mo(),s.flags|=256,cn(i,s,a,l),s.child}var fm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function pm(i){return{baseLanes:i,cachePool:fy()}}function mm(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Un),i}function kS(i,s,a){var l=s.pendingProps,d=!1,m=(s.flags&128)!==0,y;if((y=m)||(y=i!==null&&i.memoizedState===null?!1:(ki.current&2)!==0),y&&(d=!0,s.flags&=-129),y=(s.flags&32)!==0,s.flags&=-33,i===null){if(Et){if(d?wa(s):Ca(),(i=ri)?(i=L0(i,ds),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ma!==null?{id:ir,overflow:nr}:null,retryLane:536870912,hydrationErrors:null},a=sy(i),a.return=s,s.child=a,on=s,ri=null)):i=null,i===null)throw va(s);return Zm(i)?s.lanes=32:s.lanes=536870912,null}var E=l.children;return l=l.fallback,d?(Ca(),d=s.mode,E=Qd({mode:"hidden",children:E},d),l=Ro(l,d,a,null),E.return=s,l.return=s,E.sibling=l,s.child=E,l=s.child,l.memoizedState=pm(a),l.childLanes=mm(i,y,a),s.memoizedState=fm,Fc(null,l)):(wa(s),gm(s,E))}var j=i.memoizedState;if(j!==null&&(E=j.dehydrated,E!==null)){if(m)s.flags&256?(wa(s),s.flags&=-257,s=vm(i,s,a)):s.memoizedState!==null?(Ca(),s.child=i.child,s.flags|=128,s=null):(Ca(),E=l.fallback,d=s.mode,l=Qd({mode:"visible",children:l.children},d),E=Ro(E,d,a,null),E.flags|=2,l.return=s,E.return=s,l.sibling=E,s.child=l,jo(s,i.child,null,a),l=s.child,l.memoizedState=pm(a),l.childLanes=mm(i,y,a),s.memoizedState=fm,s=Fc(null,l));else if(wa(s),Zm(E)){if(y=E.nextSibling&&E.nextSibling.dataset,y)var se=y.dgst;y=se,l=Error(r(419)),l.stack="",l.digest=y,Mc({value:l,source:null,stack:null}),s=vm(i,s,a)}else if(Li||bl(i,s,a,!1),y=(a&i.childLanes)!==0,Li||y){if(y=ei,y!==null&&(l=sn(y,a),l!==0&&l!==j.retryLane))throw j.retryLane=l,Do(i,l),Bn(y,i,l),dm;Gm(E)||oh(),s=vm(i,s,a)}else Gm(E)?(s.flags|=192,s.child=i.child,s=null):(i=j.treeContext,ri=fs(E.nextSibling),on=s,Et=!0,ga=null,ds=!1,i!==null&&oy(s,i),s=gm(s,l.children),s.flags|=4096);return s}return d?(Ca(),E=l.fallback,d=s.mode,j=i.child,se=j.sibling,l=kr(j,{mode:"hidden",children:l.children}),l.subtreeFlags=j.subtreeFlags&65011712,se!==null?E=kr(se,E):(E=Ro(E,d,a,null),E.flags|=2),E.return=s,l.return=s,l.sibling=E,s.child=l,Fc(null,l),l=s.child,E=i.child.memoizedState,E===null?E=pm(a):(d=E.cachePool,d!==null?(j=Ni._currentValue,d=d.parent!==j?{parent:j,pool:j}:d):d=fy(),E={baseLanes:E.baseLanes|a,cachePool:d}),l.memoizedState=E,l.childLanes=mm(i,y,a),s.memoizedState=fm,Fc(i.child,l)):(wa(s),a=i.child,i=a.sibling,a=kr(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 gm(i,s){return s=Qd({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function Qd(i,s){return i=In(22,i,null,s),i.lanes=0,i}function vm(i,s,a){return jo(s,i.child,null,a),i=gm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function TS(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),Ap(i.return,s,a)}function _m(i,s,a,l,d,m){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:d,treeForkCount:m}:(y.isBackwards=s,y.rendering=null,y.renderingStartTime=0,y.last=l,y.tail=a,y.tailMode=d,y.treeForkCount=m)}function ES(i,s,a){var l=s.pendingProps,d=l.revealOrder,m=l.tail;l=l.children;var y=ki.current,E=(y&2)!==0;if(E?(y=y&1|2,s.flags|=128):y&=1,de(ki,y),cn(i,s,l,a),l=Et?Rc:0,!E&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&TS(i,a,s);else if(i.tag===19)TS(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(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&Hd(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),_m(s,!1,d,a,m,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&Hd(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}_m(s,!0,a,null,m,l);break;case"together":_m(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function Nr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),Ta|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(bl(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=kr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=kr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function bm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Ad(i)))}function TE(i,s,a){switch(s.tag){case 3:Ae(s,s.stateNode.containerInfo),_a(s,Ni,i.memoizedState.cache),Mo();break;case 27:case 5:Pe(s);break;case 4:Ae(s,s.stateNode.containerInfo);break;case 10:_a(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,$p(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(wa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?kS(i,s,a):(wa(s),i=Nr(i,s,a),i!==null?i.sibling:null);wa(s);break;case 19:var d=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(bl(i,s,a,!1),l=(a&s.childLanes)!==0),d){if(l)return ES(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),de(ki,ki.current),l)break;return null;case 22:return s.lanes=0,bS(i,s,a,s.pendingProps);case 24:_a(s,Ni,i.memoizedState.cache)}return Nr(i,s,a)}function DS(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Li=!0;else{if(!bm(i,a)&&(s.flags&128)===0)return Li=!1,TE(i,s,a);Li=(i.flags&131072)!==0}else Li=!1,Et&&(s.flags&1048576)!==0&&ay(s,Rc,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")xp(i)?(l=Po(i,l),s.tag=1,s=CS(null,s,i,l,a)):(s.tag=0,s=hm(null,s,i,l,a));else{if(i!=null){var d=i.$$typeof;if(d===U){s.tag=11,s=gS(null,s,i,l,a);break e}else if(d===P){s.tag=14,s=vS(null,s,i,l,a);break e}}throw s=Y(i)||i,Error(r(306,s,""))}}return s;case 0:return hm(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,d=Po(l,s.pendingProps),CS(i,s,l,d,a);case 3:e:{if(Ae(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var m=s.memoizedState;d=m.element,zp(i,s),Ic(s,l,null,a);var y=s.memoizedState;if(l=y.cache,_a(s,Ni,l),l!==m.cache&&Lp(s,[Ni],a,!0),jc(),l=y.element,m.isDehydrated)if(m={element:l,isDehydrated:!1,cache:y.cache},s.updateQueue.baseState=m,s.memoizedState=m,s.flags&256){s=xS(i,s,l,a);break e}else if(l!==d){d=ls(Error(r(424)),s),Mc(d),s=xS(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,ri=fs(i.firstChild),on=s,Et=!0,ga=null,ds=!0,a=by(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Mo(),l===d){s=Nr(i,s,a);break e}cn(i,s,l,a)}s=s.child}return s;case 26:return Zd(i,s),i===null?(a=z0(s.type,null,s.pendingProps,null))?s.memoizedState=a:Et||(a=s.type,i=s.pendingProps,l=ph(Re.current).createElement(a),l[qt]=s,l[Qt]=i,un(l,a,i),Ht(l),s.stateNode=l):s.memoizedState=z0(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return Pe(s),i===null&&Et&&(l=s.stateNode=j0(s.type,s.pendingProps,Re.current),on=s,ds=!0,d=ri,Na(s.type)?(Qm=d,ri=fs(l.firstChild)):ri=d),cn(i,s,s.pendingProps.children,a),Zd(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Et&&((d=l=ri)&&(l=i2(l,s.type,s.pendingProps,ds),l!==null?(s.stateNode=l,on=s,ri=fs(l.firstChild),ds=!1,d=!0):d=!1),d||va(s)),Pe(s),d=s.type,m=s.pendingProps,y=i!==null?i.memoizedProps:null,l=m.children,Vm(d,m)?l=null:y!==null&&Vm(d,y)&&(s.flags|=32),s.memoizedState!==null&&(d=qp(i,s,vE,null,null,a),nu._currentValue=d),Zd(i,s),cn(i,s,l,a),s.child;case 6:return i===null&&Et&&((i=a=ri)&&(a=n2(a,s.pendingProps,ds),a!==null?(s.stateNode=a,on=s,ri=null,i=!0):i=!1),i||va(s)),null;case 13:return kS(i,s,a);case 4:return Ae(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=jo(s,null,l,a):cn(i,s,l,a),s.child;case 11:return gS(i,s,s.type,s.pendingProps,a);case 7:return cn(i,s,s.pendingProps,a),s.child;case 8:return cn(i,s,s.pendingProps.children,a),s.child;case 12:return cn(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,_a(s,s.type,l.value),cn(i,s,l.children,a),s.child;case 9:return d=s.type._context,l=s.pendingProps.children,Ao(s),d=ln(d),l=l(d),s.flags|=1,cn(i,s,l,a),s.child;case 14:return vS(i,s,s.type,s.pendingProps,a);case 15:return _S(i,s,s.type,s.pendingProps,a);case 19:return ES(i,s,a);case 31:return kE(i,s,a);case 22:return bS(i,s,a,s.pendingProps);case 24:return Ao(s),l=ln(Ni),i===null?(d=jp(),d===null&&(d=ei,m=Op(),d.pooledCache=m,m.refCount++,m!==null&&(d.pooledCacheLanes|=a),d=m),s.memoizedState={parent:l,cache:d},Pp(s),_a(s,Ni,d)):((i.lanes&a)!==0&&(zp(i,s),Ic(s,null,null,a),jc()),d=i.memoizedState,m=s.memoizedState,d.parent!==l?(d={parent:l,cache:l},s.memoizedState=d,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=d),_a(s,Ni,l)):(l=m.cache,_a(s,Ni,l),l!==d.cache&&Lp(s,[Ni],a,!0))),cn(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function Ar(i){i.flags|=4}function ym(i,s,a,l,d){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(d&335544128)===d)if(i.stateNode.complete)i.flags|=8192;else if(t0())i.flags|=8192;else throw Bo=jd,Ip}else i.flags&=-16777217}function RS(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!$0(s))if(t0())i.flags|=8192;else throw Bo=jd,Ip}function Jd(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Tt():536870912,i.lanes|=s,Nl|=s)}function Kc(i,s){if(!Et)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 ai(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags&65011712,l|=d.flags&65011712,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function EE(i,s,a){var l=s.pendingProps;switch(Dp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ai(s),null;case 1:return ai(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),Dr(Ni),We(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(_l(s)?Ar(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Mp())),ai(s),null;case 26:var d=s.type,m=s.memoizedState;return i===null?(Ar(s),m!==null?(ai(s),RS(s,m)):(ai(s),ym(s,d,null,l,a))):m?m!==i.memoizedState?(Ar(s),ai(s),RS(s,m)):(ai(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&Ar(s),ai(s),ym(s,d,i,l,a)),null;case 27:if(He(s),a=Re.current,d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&Ar(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ai(s),null}i=ke.current,_l(s)?ly(s):(i=j0(d,l,a),s.stateNode=i,Ar(s))}return ai(s),null;case 5:if(He(s),d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&Ar(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return ai(s),null}if(m=ke.current,_l(s))ly(s);else{var y=ph(Re.current);switch(m){case 1:m=y.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:m=y.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":m=y.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":m=y.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":m=y.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof l.is=="string"?y.createElement("select",{is:l.is}):y.createElement("select"),l.multiple?m.multiple=!0:l.size&&(m.size=l.size);break;default:m=typeof l.is=="string"?y.createElement(d,{is:l.is}):y.createElement(d)}}m[qt]=s,m[Qt]=l;e:for(y=s.child;y!==null;){if(y.tag===5||y.tag===6)m.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=m;e:switch(un(m,d,l),d){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Ar(s)}}return ai(s),ym(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&Ar(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=Re.current,_l(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,d=on,d!==null)switch(d.tag){case 27:case 5:l=d.memoizedProps}i[qt]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||k0(i.nodeValue,a)),i||va(s,!0)}else i=ph(i).createTextNode(l),i[qt]=s,s.stateNode=i}return ai(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=_l(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[qt]=s}else Mo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ai(s),i=!1}else a=Mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(zn(s),s):(zn(s),null);if((s.flags&128)!==0)throw Error(r(558))}return ai(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=_l(s),l!==null&&l.dehydrated!==null){if(i===null){if(!d)throw Error(r(318));if(d=s.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[qt]=s}else Mo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;ai(s),d=!1}else d=Mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return s.flags&256?(zn(s),s):(zn(s),null)}return zn(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,d=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(d=l.alternate.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==d&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Jd(s,s.updateQueue),ai(s),null);case 4:return We(),i===null&&Fm(s.stateNode.containerInfo),ai(s),null;case 10:return Dr(s.type),ai(s),null;case 19:if(K(ki),l=s.memoizedState,l===null)return ai(s),null;if(d=(s.flags&128)!==0,m=l.rendering,m===null)if(d)Kc(l,!1);else{if(_i!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(m=Hd(i),m!==null){for(s.flags|=128,Kc(l,!1),i=m.updateQueue,s.updateQueue=i,Jd(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)ny(a,i),a=a.sibling;return de(ki,ki.current&1|2),Et&&Tr(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&nt()>sh&&(s.flags|=128,d=!0,Kc(l,!1),s.lanes=4194304)}else{if(!d)if(i=Hd(m),i!==null){if(s.flags|=128,d=!0,i=i.updateQueue,s.updateQueue=i,Jd(s,i),Kc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!m.alternate&&!Et)return ai(s),null}else 2*nt()-l.renderingStartTime>sh&&a!==536870912&&(s.flags|=128,d=!0,Kc(l,!1),s.lanes=4194304);l.isBackwards?(m.sibling=s.child,s.child=m):(i=l.last,i!==null?i.sibling=m:s.child=m,l.last=m)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=nt(),i.sibling=null,a=ki.current,de(ki,d?a&1|2:a&1),Et&&Tr(s,l.treeForkCount),i):(ai(s),null);case 22:case 23:return zn(s),Kp(),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&&(ai(s),s.subtreeFlags&6&&(s.flags|=8192)):ai(s),a=s.updateQueue,a!==null&&Jd(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&&K(Lo),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),Dr(Ni),ai(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function DE(i,s){switch(Dp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return Dr(Ni),We(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return He(s),null;case 31:if(s.memoizedState!==null){if(zn(s),s.alternate===null)throw Error(r(340));Mo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(zn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));Mo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return K(ki),null;case 4:return We(),null;case 10:return Dr(s.type),null;case 22:case 23:return zn(s),Kp(),i!==null&&K(Lo),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return Dr(Ni),null;case 25:return null;default:return null}}function MS(i,s){switch(Dp(s),s.tag){case 3:Dr(Ni),We();break;case 26:case 27:case 5:He(s);break;case 4:We();break;case 31:s.memoizedState!==null&&zn(s);break;case 13:zn(s);break;case 19:K(ki);break;case 10:Dr(s.type);break;case 22:case 23:zn(s),Kp(),i!==null&&K(Lo);break;case 24:Dr(Ni)}}function $c(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var d=l.next;a=d;do{if((a.tag&i)===i){l=void 0;var m=a.create,y=a.inst;l=m(),y.destroy=l}a=a.next}while(a!==d)}}catch(E){Kt(s,s.return,E)}}function xa(i,s,a){try{var l=s.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var m=d.next;l=m;do{if((l.tag&i)===i){var y=l.inst,E=y.destroy;if(E!==void 0){y.destroy=void 0,d=s;var j=a,se=E;try{se()}catch(me){Kt(d,j,me)}}}l=l.next}while(l!==m)}}catch(me){Kt(s,s.return,me)}}function NS(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{Sy(s,a)}catch(l){Kt(i,i.return,l)}}}function AS(i,s,a){a.props=Po(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){Kt(i,s,l)}}function Wc(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(d){Kt(i,s,d)}}function sr(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(d){Kt(i,s,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(d){Kt(i,s,d)}else a.current=null}function LS(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(d){Kt(i,i.return,d)}}function Sm(i,s,a){try{var l=i.stateNode;GE(l,i.type,a,s),l[Qt]=s}catch(d){Kt(i,i.return,d)}}function OS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Na(i.type)||i.tag===4}function wm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||OS(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&&Na(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 Cm(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=Zn));else if(l!==4&&(l===27&&Na(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Cm(i,s,a),i=i.sibling;i!==null;)Cm(i,s,a),i=i.sibling}function eh(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&&Na(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(eh(i,s,a),i=i.sibling;i!==null;)eh(i,s,a),i=i.sibling}function BS(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,d=s.attributes;d.length;)s.removeAttributeNode(d[0]);un(s,l,a),s[qt]=i,s[Qt]=a}catch(m){Kt(i,i.return,m)}}var Lr=!1,Oi=!1,xm=!1,jS=typeof WeakSet=="function"?WeakSet:Set,Xi=null;function RE(i,s){if(i=i.containerInfo,Wm=Sh,i=kd(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 d=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var y=0,E=-1,j=-1,se=0,me=0,ye=i,oe=null;t:for(;;){for(var he;ye!==a||d!==0&&ye.nodeType!==3||(E=y+d),ye!==m||l!==0&&ye.nodeType!==3||(j=y+l),ye.nodeType===3&&(y+=ye.nodeValue.length),(he=ye.firstChild)!==null;)oe=ye,ye=he;for(;;){if(ye===i)break t;if(oe===a&&++se===d&&(E=y),oe===m&&++me===l&&(j=y),(he=ye.nextSibling)!==null)break;ye=oe,oe=ye.parentNode}ye=he}a=E===-1||j===-1?null:{start:E,end:j}}else a=null}a=a||{start:0,end:0}}else a=null;for(qm={focusedElem:i,selectionRange:a},Sh=!1,Xi=s;Xi!==null;)if(s=Xi,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,Xi=i;else for(;Xi!==null;){switch(s=Xi,m=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++)d=i[a],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&m!==null){i=void 0,a=s,d=m.memoizedProps,m=m.memoizedState,l=a.stateNode;try{var $e=Po(a.type,d);i=l.getSnapshotBeforeUpdate($e,m),l.__reactInternalSnapshotBeforeUpdate=i}catch(et){Kt(a,a.return,et)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Xm(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Xm(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,Xi=i;break}Xi=s.return}}function IS(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Br(i,a),l&4&&$c(5,a);break;case 1:if(Br(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(y){Kt(a,a.return,y)}else{var d=Po(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(d,s,i.__reactInternalSnapshotBeforeUpdate)}catch(y){Kt(a,a.return,y)}}l&64&&NS(a),l&512&&Wc(a,a.return);break;case 3:if(Br(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{Sy(i,s)}catch(y){Kt(a,a.return,y)}}break;case 27:s===null&&l&4&&BS(a);case 26:case 5:Br(i,a),s===null&&l&4&&LS(a),l&512&&Wc(a,a.return);break;case 12:Br(i,a);break;case 31:Br(i,a),l&4&&HS(i,a);break;case 13:Br(i,a),l&4&&US(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=PE.bind(null,a),s2(i,a))));break;case 22:if(l=a.memoizedState!==null||Lr,!l){s=s!==null&&s.memoizedState!==null||Oi,d=Lr;var m=Oi;Lr=l,(Oi=s)&&!m?jr(i,a,(a.subtreeFlags&8772)!==0):Br(i,a),Lr=d,Oi=m}break;case 30:break;default:Br(i,a)}}function PS(i){var s=i.alternate;s!==null&&(i.alternate=null,PS(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Yn(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 ui=null,Nn=!1;function Or(i,s,a){for(a=a.child;a!==null;)zS(i,s,a),a=a.sibling}function zS(i,s,a){if(tt&&typeof tt.onCommitFiberUnmount=="function")try{tt.onCommitFiberUnmount(rt,a)}catch{}switch(a.tag){case 26:Oi||sr(a,s),Or(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Oi||sr(a,s);var l=ui,d=Nn;Na(a.type)&&(ui=a.stateNode,Nn=!1),Or(i,s,a),eu(a.stateNode),ui=l,Nn=d;break;case 5:Oi||sr(a,s);case 6:if(l=ui,d=Nn,ui=null,Or(i,s,a),ui=l,Nn=d,ui!==null)if(Nn)try{(ui.nodeType===9?ui.body:ui.nodeName==="HTML"?ui.ownerDocument.body:ui).removeChild(a.stateNode)}catch(m){Kt(a,s,m)}else try{ui.removeChild(a.stateNode)}catch(m){Kt(a,s,m)}break;case 18:ui!==null&&(Nn?(i=ui,N0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),zl(i)):N0(ui,a.stateNode));break;case 4:l=ui,d=Nn,ui=a.stateNode.containerInfo,Nn=!0,Or(i,s,a),ui=l,Nn=d;break;case 0:case 11:case 14:case 15:xa(2,a,s),Oi||xa(4,a,s),Or(i,s,a);break;case 1:Oi||(sr(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&AS(a,s,l)),Or(i,s,a);break;case 21:Or(i,s,a);break;case 22:Oi=(l=Oi)||a.memoizedState!==null,Or(i,s,a),Oi=l;break;default:Or(i,s,a)}}function HS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{zl(i)}catch(a){Kt(s,s.return,a)}}}function US(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{zl(i)}catch(a){Kt(s,s.return,a)}}function ME(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new jS),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new jS),s;default:throw Error(r(435,i.tag))}}function th(i,s){var a=ME(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var d=zE.bind(null,i,l);l.then(d,d)}})}function An(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var d=a[l],m=i,y=s,E=y;e:for(;E!==null;){switch(E.tag){case 27:if(Na(E.type)){ui=E.stateNode,Nn=!1;break e}break;case 5:ui=E.stateNode,Nn=!1;break e;case 3:case 4:ui=E.stateNode.containerInfo,Nn=!0;break e}E=E.return}if(ui===null)throw Error(r(160));zS(m,y,d),ui=null,Nn=!1,m=d.alternate,m!==null&&(m.return=null),d.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)FS(s,i),s=s.sibling}var Is=null;function FS(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:An(s,i),Ln(i),l&4&&(xa(3,i,i.return),$c(3,i),xa(5,i,i.return));break;case 1:An(s,i),Ln(i),l&512&&(Oi||a===null||sr(a,a.return)),l&64&&Lr&&(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 d=Is;if(An(s,i),Ln(i),l&512&&(Oi||a===null||sr(a,a.return)),l&4){var m=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,d=d.ownerDocument||d;t:switch(l){case"title":m=d.getElementsByTagName("title")[0],(!m||m[Vn]||m[qt]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=d.createElement(l),d.head.insertBefore(m,d.querySelector("head > title"))),un(m,l,a),m[qt]=i,Ht(m),l=m;break e;case"link":var y=F0("link","href",d).get(l+(a.href||""));if(y){for(var E=0;E<y.length;E++)if(m=y[E],m.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&m.getAttribute("rel")===(a.rel==null?null:a.rel)&&m.getAttribute("title")===(a.title==null?null:a.title)&&m.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){y.splice(E,1);break t}}m=d.createElement(l),un(m,l,a),d.head.appendChild(m);break;case"meta":if(y=F0("meta","content",d).get(l+(a.content||""))){for(E=0;E<y.length;E++)if(m=y[E],m.getAttribute("content")===(a.content==null?null:""+a.content)&&m.getAttribute("name")===(a.name==null?null:a.name)&&m.getAttribute("property")===(a.property==null?null:a.property)&&m.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&m.getAttribute("charset")===(a.charSet==null?null:a.charSet)){y.splice(E,1);break t}}m=d.createElement(l),un(m,l,a),d.head.appendChild(m);break;default:throw Error(r(468,l))}m[qt]=i,Ht(m),l=m}i.stateNode=l}else K0(d,i.type,i.stateNode);else i.stateNode=U0(d,l,i.memoizedProps);else m!==l?(m===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):m.count--,l===null?K0(d,i.type,i.stateNode):U0(d,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Sm(i,i.memoizedProps,a.memoizedProps)}break;case 27:An(s,i),Ln(i),l&512&&(Oi||a===null||sr(a,a.return)),a!==null&&l&4&&Sm(i,i.memoizedProps,a.memoizedProps);break;case 5:if(An(s,i),Ln(i),l&512&&(Oi||a===null||sr(a,a.return)),i.flags&32){d=i.stateNode;try{Ci(d,"")}catch($e){Kt(i,i.return,$e)}}l&4&&i.stateNode!=null&&(d=i.memoizedProps,Sm(i,d,a!==null?a.memoizedProps:d)),l&1024&&(xm=!0);break;case 6:if(An(s,i),Ln(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch($e){Kt(i,i.return,$e)}}break;case 3:if(vh=null,d=Is,Is=mh(s.containerInfo),An(s,i),Is=d,Ln(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{zl(s.containerInfo)}catch($e){Kt(i,i.return,$e)}xm&&(xm=!1,KS(i));break;case 4:l=Is,Is=mh(i.stateNode.containerInfo),An(s,i),Ln(i),Is=l;break;case 12:An(s,i),Ln(i);break;case 31:An(s,i),Ln(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,th(i,l)));break;case 13:An(s,i),Ln(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(nh=nt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,th(i,l)));break;case 22:d=i.memoizedState!==null;var j=a!==null&&a.memoizedState!==null,se=Lr,me=Oi;if(Lr=se||d,Oi=me||j,An(s,i),Oi=me,Lr=se,Ln(i),l&8192)e:for(s=i.stateNode,s._visibility=d?s._visibility&-2:s._visibility|1,d&&(a===null||j||Lr||Oi||zo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){j=a=s;try{if(m=j.stateNode,d)y=m.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{E=j.stateNode;var ye=j.memoizedProps.style,oe=ye!=null&&ye.hasOwnProperty("display")?ye.display:null;E.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch($e){Kt(j,j.return,$e)}}}else if(s.tag===6){if(a===null){j=s;try{j.stateNode.nodeValue=d?"":j.memoizedProps}catch($e){Kt(j,j.return,$e)}}}else if(s.tag===18){if(a===null){j=s;try{var he=j.stateNode;d?A0(he,!0):A0(j.stateNode,!1)}catch($e){Kt(j,j.return,$e)}}}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,th(i,a))));break;case 19:An(s,i),Ln(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,th(i,l)));break;case 30:break;case 21:break;default:An(s,i),Ln(i)}}function Ln(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(OS(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var d=a.stateNode,m=wm(i);eh(i,m,d);break;case 5:var y=a.stateNode;a.flags&32&&(Ci(y,""),a.flags&=-33);var E=wm(i);eh(i,E,y);break;case 3:case 4:var j=a.stateNode.containerInfo,se=wm(i);Cm(i,se,j);break;default:throw Error(r(161))}}catch(me){Kt(i,i.return,me)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function KS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;KS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function Br(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)IS(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:xa(4,s,s.return),zo(s);break;case 1:sr(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&AS(s,s.return,a),zo(s);break;case 27:eu(s.stateNode);case 26:case 5:sr(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 jr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,d=i,m=s,y=m.flags;switch(m.tag){case 0:case 11:case 15:jr(d,m,a),$c(4,m);break;case 1:if(jr(d,m,a),l=m,d=l.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(se){Kt(l,l.return,se)}if(l=m,d=l.updateQueue,d!==null){var E=l.stateNode;try{var j=d.shared.hiddenCallbacks;if(j!==null)for(d.shared.hiddenCallbacks=null,d=0;d<j.length;d++)yy(j[d],E)}catch(se){Kt(l,l.return,se)}}a&&y&64&&NS(m),Wc(m,m.return);break;case 27:BS(m);case 26:case 5:jr(d,m,a),a&&l===null&&y&4&&LS(m),Wc(m,m.return);break;case 12:jr(d,m,a);break;case 31:jr(d,m,a),a&&y&4&&HS(d,m);break;case 13:jr(d,m,a),a&&y&4&&US(d,m);break;case 22:m.memoizedState===null&&jr(d,m,a),Wc(m,m.return);break;case 30:break;default:jr(d,m,a)}s=s.sibling}}function km(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&&Nc(a))}function Tm(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Nc(i))}function Ps(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)$S(i,s,a,l),s=s.sibling}function $S(i,s,a,l){var d=s.flags;switch(s.tag){case 0:case 11:case 15:Ps(i,s,a,l),d&2048&&$c(9,s);break;case 1:Ps(i,s,a,l);break;case 3:Ps(i,s,a,l),d&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Nc(i)));break;case 12:if(d&2048){Ps(i,s,a,l),i=s.stateNode;try{var m=s.memoizedProps,y=m.id,E=m.onPostCommit;typeof E=="function"&&E(y,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(j){Kt(s,s.return,j)}}else Ps(i,s,a,l);break;case 31:Ps(i,s,a,l);break;case 13:Ps(i,s,a,l);break;case 23:break;case 22:m=s.stateNode,y=s.alternate,s.memoizedState!==null?m._visibility&2?Ps(i,s,a,l):qc(i,s):m._visibility&2?Ps(i,s,a,l):(m._visibility|=2,Dl(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),d&2048&&km(y,s);break;case 24:Ps(i,s,a,l),d&2048&&Tm(s.alternate,s);break;default:Ps(i,s,a,l)}}function Dl(i,s,a,l,d){for(d=d&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var m=i,y=s,E=a,j=l,se=y.flags;switch(y.tag){case 0:case 11:case 15:Dl(m,y,E,j,d),$c(8,y);break;case 23:break;case 22:var me=y.stateNode;y.memoizedState!==null?me._visibility&2?Dl(m,y,E,j,d):qc(m,y):(me._visibility|=2,Dl(m,y,E,j,d)),d&&se&2048&&km(y.alternate,y);break;case 24:Dl(m,y,E,j,d),d&&se&2048&&Tm(y.alternate,y);break;default:Dl(m,y,E,j,d)}s=s.sibling}}function qc(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,d=l.flags;switch(l.tag){case 22:qc(a,l),d&2048&&km(l.alternate,l);break;case 24:qc(a,l),d&2048&&Tm(l.alternate,l);break;default:qc(a,l)}s=s.sibling}}var Vc=8192;function Rl(i,s,a){if(i.subtreeFlags&Vc)for(i=i.child;i!==null;)WS(i,s,a),i=i.sibling}function WS(i,s,a){switch(i.tag){case 26:Rl(i,s,a),i.flags&Vc&&i.memoizedState!==null&&g2(a,Is,i.memoizedState,i.memoizedProps);break;case 5:Rl(i,s,a);break;case 3:case 4:var l=Is;Is=mh(i.stateNode.containerInfo),Rl(i,s,a),Is=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Vc,Vc=16777216,Rl(i,s,a),Vc=l):Rl(i,s,a));break;default:Rl(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 Yc(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];Xi=l,YS(l,i)}qS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)VS(i),i=i.sibling}function VS(i){switch(i.tag){case 0:case 11:case 15:Yc(i),i.flags&2048&&xa(9,i,i.return);break;case 3:Yc(i);break;case 12:Yc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,ih(i)):Yc(i);break;default:Yc(i)}}function ih(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];Xi=l,YS(l,i)}qS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:xa(8,s,s.return),ih(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,ih(s));break;default:ih(s)}i=i.sibling}}function YS(i,s){for(;Xi!==null;){var a=Xi;switch(a.tag){case 0:case 11:case 15:xa(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:Nc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Xi=l;else e:for(a=i;Xi!==null;){l=Xi;var d=l.sibling,m=l.return;if(PS(l),l===a){Xi=null;break e}if(d!==null){d.return=m,Xi=d;break e}Xi=m}}}var NE={getCacheForType:function(i){var s=ln(Ni),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return ln(Ni).controller.signal}},AE=typeof WeakMap=="function"?WeakMap:Map,Ot=0,ei=null,St=null,Ct=0,Ft=0,Hn=null,ka=!1,Ml=!1,Em=!1,Ir=0,_i=0,Ta=0,Ho=0,Dm=0,Un=0,Nl=0,Xc=null,On=null,Rm=!1,nh=0,XS=0,sh=1/0,rh=null,Ea=null,Ui=0,Da=null,Al=null,Pr=0,Mm=0,Nm=null,GS=null,Gc=0,Am=null;function Fn(){return(Ot&2)!==0&&Ct!==0?Ct&-Ct:B.T!==null?Pm():gi()}function ZS(){if(Un===0)if((Ct&536870912)===0||Et){var i=ct;ct<<=1,(ct&3932160)===0&&(ct=262144),Un=i}else Un=536870912;return i=Pn.current,i!==null&&(i.flags|=32),Un}function Bn(i,s,a){(i===ei&&(Ft===2||Ft===9)||i.cancelPendingCommit!==null)&&(Ll(i,0),Ra(i,Ct,Un,!1)),Di(i,a),((Ot&2)===0||i!==ei)&&(i===ei&&((Ot&2)===0&&(Ho|=a),_i===4&&Ra(i,Ct,Un,!1)),rr(i))}function QS(i,s,a){if((Ot&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||wi(i,s),d=l?BE(i,s):Om(i,s,!0),m=l;do{if(d===0){Ml&&!l&&Ra(i,s,0,!1);break}else{if(a=i.current.alternate,m&&!LE(a)){d=Om(i,s,!1),m=!1;continue}if(d===2){if(m=s,i.errorRecoveryDisabledLanes&m)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){s=y;e:{var E=i;d=Xc;var j=E.current.memoizedState.isDehydrated;if(j&&(Ll(E,y).flags|=256),y=Om(E,y,!1),y!==2){if(Em&&!j){E.errorRecoveryDisabledLanes|=m,Ho|=m,d=4;break e}m=On,On=d,m!==null&&(On===null?On=m:On.push.apply(On,m))}d=y}if(m=!1,d!==2)continue}}if(d===1){Ll(i,0),Ra(i,s,0,!0);break}e:{switch(l=i,m=d,m){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:Ra(l,s,Un,!ka);break e;case 2:On=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(d=nh+300-nt(),10<d)){if(Ra(l,s,Un,!ka),fi(l,0,!0)!==0)break e;Pr=s,l.timeoutHandle=R0(JS.bind(null,l,a,On,rh,Rm,s,Un,Ho,Nl,ka,m,"Throttled",-0,0),d);break e}JS(l,a,On,rh,Rm,s,Un,Ho,Nl,ka,m,null,-0,0)}}break}while(!0);rr(i)}function JS(i,s,a,l,d,m,y,E,j,se,me,ye,oe,he){if(i.timeoutHandle=-1,ye=s.subtreeFlags,ye&8192||(ye&16785408)===16785408){ye={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Zn},WS(s,m,ye);var $e=(m&62914560)===m?nh-nt():(m&4194048)===m?XS-nt():0;if($e=v2(ye,$e),$e!==null){Pr=m,i.cancelPendingCommit=$e(o0.bind(null,i,s,m,a,l,d,y,E,j,me,ye,null,oe,he)),Ra(i,m,y,!se);return}}o0(i,s,m,a,l,d,y,E,j)}function LE(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 d=a[l],m=d.getSnapshot;d=d.value;try{if(!Cn(m(),d))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 Ra(i,s,a,l){s&=~Dm,s&=~Ho,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var d=s;0<d;){var m=31-lt(d),y=1<<m;l[m]=-1,d&=~y}a!==0&&nn(i,a,s)}function ah(){return(Ot&6)===0?(Zc(0),!1):!0}function Lm(){if(St!==null){if(Ft===0)var i=St.return;else i=St,Er=No=null,Xp(i),Cl=null,Lc=0,i=St;for(;i!==null;)MS(i.alternate,i),i=i.return;St=null}}function Ll(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,JE(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Pr=0,Lm(),ei=i,St=a=kr(i.current,null),Ct=s,Ft=0,Hn=null,ka=!1,Ml=wi(i,s),Em=!1,Nl=Un=Dm=Ho=Ta=_i=0,On=Xc=null,Rm=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var d=31-lt(l),m=1<<d;s|=i[d],l&=~m}return Ir=s,Ed(),a}function e0(i,s){dt=null,B.H=Uc,s===wl||s===Bd?(s=gy(),Ft=3):s===Ip?(s=gy(),Ft=4):Ft=s===dm?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Hn=s,St===null&&(_i=1,Xd(i,ls(s,i.current)))}function t0(){var i=Pn.current;return i===null?!0:(Ct&4194048)===Ct?hs===null:(Ct&62914560)===Ct||(Ct&536870912)!==0?i===hs:!1}function i0(){var i=B.H;return B.H=Uc,i===null?Uc:i}function n0(){var i=B.A;return B.A=NE,i}function oh(){_i=4,ka||(Ct&4194048)!==Ct&&Pn.current!==null||(Ml=!0),(Ta&134217727)===0&&(Ho&134217727)===0||ei===null||Ra(ei,Ct,Un,!1)}function Om(i,s,a){var l=Ot;Ot|=2;var d=i0(),m=n0();(ei!==i||Ct!==s)&&(rh=null,Ll(i,s)),s=!1;var y=_i;e:do try{if(Ft!==0&&St!==null){var E=St,j=Hn;switch(Ft){case 8:Lm(),y=6;break e;case 3:case 2:case 9:case 6:Pn.current===null&&(s=!0);var se=Ft;if(Ft=0,Hn=null,Ol(i,E,j,se),a&&Ml){y=0;break e}break;default:se=Ft,Ft=0,Hn=null,Ol(i,E,j,se)}}OE(),y=_i;break}catch(me){e0(i,me)}while(!0);return s&&i.shellSuspendCounter++,Er=No=null,Ot=l,B.H=d,B.A=m,St===null&&(ei=null,Ct=0,Ed()),y}function OE(){for(;St!==null;)s0(St)}function BE(i,s){var a=Ot;Ot|=2;var l=i0(),d=n0();ei!==i||Ct!==s?(rh=null,sh=nt()+500,Ll(i,s)):Ml=wi(i,s);e:do try{if(Ft!==0&&St!==null){s=St;var m=Hn;t:switch(Ft){case 1:Ft=0,Hn=null,Ol(i,s,m,1);break;case 2:case 9:if(py(m)){Ft=0,Hn=null,r0(s);break}s=function(){Ft!==2&&Ft!==9||ei!==i||(Ft=7),rr(i)},m.then(s,s);break e;case 3:Ft=7;break e;case 4:Ft=5;break e;case 7:py(m)?(Ft=0,Hn=null,r0(s)):(Ft=0,Hn=null,Ol(i,s,m,7));break;case 5:var y=null;switch(St.tag){case 26:y=St.memoizedState;case 5:case 27:var E=St;if(y?$0(y):E.stateNode.complete){Ft=0,Hn=null;var j=E.sibling;if(j!==null)St=j;else{var se=E.return;se!==null?(St=se,lh(se)):St=null}break t}}Ft=0,Hn=null,Ol(i,s,m,5);break;case 6:Ft=0,Hn=null,Ol(i,s,m,6);break;case 8:Lm(),_i=6;break e;default:throw Error(r(462))}}jE();break}catch(me){e0(i,me)}while(!0);return Er=No=null,B.H=l,B.A=d,Ot=a,St!==null?0:(ei=null,Ct=0,Ed(),_i)}function jE(){for(;St!==null&&!Ue();)s0(St)}function s0(i){var s=DS(i.alternate,i,Ir);i.memoizedProps=i.pendingProps,s===null?lh(i):St=s}function r0(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=wS(a,s,s.pendingProps,s.type,void 0,Ct);break;case 11:s=wS(a,s,s.pendingProps,s.type.render,s.ref,Ct);break;case 5:Xp(s);default:MS(a,s),s=St=ny(s,Ir),s=DS(a,s,Ir)}i.memoizedProps=i.pendingProps,s===null?lh(i):St=s}function Ol(i,s,a,l){Er=No=null,Xp(s),Cl=null,Lc=0;var d=s.return;try{if(xE(i,d,s,a,Ct)){_i=1,Xd(i,ls(a,i.current)),St=null;return}}catch(m){if(d!==null)throw St=d,m;_i=1,Xd(i,ls(a,i.current)),St=null;return}s.flags&32768?(Et||l===1?i=!0:Ml||(Ct&536870912)!==0?i=!1:(ka=i=!0,(l===2||l===9||l===3||l===6)&&(l=Pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),a0(s,i)):lh(s)}function lh(i){var s=i;do{if((s.flags&32768)!==0){a0(s,ka);return}i=s.return;var a=EE(s.alternate,s,Ir);if(a!==null){St=a;return}if(s=s.sibling,s!==null){St=s;return}St=s=i}while(s!==null);_i===0&&(_i=5)}function a0(i,s){do{var a=DE(i.alternate,i);if(a!==null){a.flags&=32767,St=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){St=i;return}St=i=a}while(i!==null);_i=6,St=null}function o0(i,s,a,l,d,m,y,E,j){i.cancelPendingCommit=null;do ch();while(Ui!==0);if((Ot&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(m=s.lanes|s.childLanes,m|=wp,Wt(i,a,m,y,E,j),i===ei&&(St=ei=null,Ct=0),Al=s,Da=i,Pr=a,Mm=m,Nm=d,GS=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,HE(vt,function(){return h0(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=B.T,B.T=null,d=R.p,R.p=2,y=Ot,Ot|=4;try{RE(i,s,a)}finally{Ot=y,R.p=d,B.T=l}}Ui=1,l0(),c0(),u0()}}function l0(){if(Ui===1){Ui=0;var i=Da,s=Al,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=B.T,B.T=null;var l=R.p;R.p=2;var d=Ot;Ot|=4;try{FS(s,i);var m=qm,y=kd(i.containerInfo),E=m.focusedElem,j=m.selectionRange;if(y!==E&&E&&E.ownerDocument&&xd(E.ownerDocument.documentElement,E)){if(j!==null&&Eo(E)){var se=j.start,me=j.end;if(me===void 0&&(me=se),"selectionStart"in E)E.selectionStart=se,E.selectionEnd=Math.min(me,E.value.length);else{var ye=E.ownerDocument||document,oe=ye&&ye.defaultView||window;if(oe.getSelection){var he=oe.getSelection(),$e=E.textContent.length,et=Math.min(j.start,$e),Gt=j.end===void 0?et:Math.min(j.end,$e);!he.extend&&et>Gt&&(y=Gt,Gt=et,et=y);var X=Cd(E,et),H=Cd(E,Gt);if(X&&H&&(he.rangeCount!==1||he.anchorNode!==X.node||he.anchorOffset!==X.offset||he.focusNode!==H.node||he.focusOffset!==H.offset)){var ne=ye.createRange();ne.setStart(X.node,X.offset),he.removeAllRanges(),et>Gt?(he.addRange(ne),he.extend(H.node,H.offset)):(ne.setEnd(H.node,H.offset),he.addRange(ne))}}}}for(ye=[],he=E;he=he.parentNode;)he.nodeType===1&&ye.push({element:he,left:he.scrollLeft,top:he.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<ye.length;E++){var ve=ye[E];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}Sh=!!Wm,qm=Wm=null}finally{Ot=d,R.p=l,B.T=a}}i.current=s,Ui=2}}function c0(){if(Ui===2){Ui=0;var i=Da,s=Al,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=B.T,B.T=null;var l=R.p;R.p=2;var d=Ot;Ot|=4;try{IS(i,s.alternate,s)}finally{Ot=d,R.p=l,B.T=a}}Ui=3}}function u0(){if(Ui===4||Ui===3){Ui=0,Ke();var i=Da,s=Al,a=Pr,l=GS;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Ui=5:(Ui=0,Al=Da=null,d0(i,i.pendingLanes));var d=i.pendingLanes;if(d===0&&(Ea=null),Rn(a),s=s.stateNode,tt&&typeof tt.onCommitFiberRoot=="function")try{tt.onCommitFiberRoot(rt,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=B.T,d=R.p,R.p=2,B.T=null;try{for(var m=i.onRecoverableError,y=0;y<l.length;y++){var E=l[y];m(E.value,{componentStack:E.stack})}}finally{B.T=s,R.p=d}}(Pr&3)!==0&&ch(),rr(i),d=i.pendingLanes,(a&261930)!==0&&(d&42)!==0?i===Am?Gc++:(Gc=0,Am=i):Gc=0,Zc(0)}}function d0(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,Nc(s)))}function ch(){return l0(),c0(),u0(),h0()}function h0(){if(Ui!==5)return!1;var i=Da,s=Mm;Mm=0;var a=Rn(Pr),l=B.T,d=R.p;try{R.p=32>a?32:a,B.T=null,a=Nm,Nm=null;var m=Da,y=Pr;if(Ui=0,Al=Da=null,Pr=0,(Ot&6)!==0)throw Error(r(331));var E=Ot;if(Ot|=4,VS(m.current),$S(m,m.current,y,a),Ot=E,Zc(0,!1),tt&&typeof tt.onPostCommitFiberRoot=="function")try{tt.onPostCommitFiberRoot(rt,m)}catch{}return!0}finally{R.p=d,B.T=l,d0(i,s)}}function f0(i,s,a){s=ls(a,s),s=um(i.stateNode,s,2),i=Sa(i,s,2),i!==null&&(Di(i,2),rr(i))}function Kt(i,s,a){if(i.tag===3)f0(i,i,a);else for(;s!==null;){if(s.tag===3){f0(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Ea===null||!Ea.has(l))){i=ls(a,i),a=pS(2),l=Sa(s,a,2),l!==null&&(mS(a,l,s,i),Di(l,2),rr(l));break}}s=s.return}}function Bm(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new AE;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(a)||(Em=!0,d.add(a),i=IE.bind(null,i,s,a),s.then(i,i))}function IE(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,ei===i&&(Ct&a)===a&&(_i===4||_i===3&&(Ct&62914560)===Ct&&300>nt()-nh?(Ot&2)===0&&Ll(i,0):Dm|=a,Nl===Ct&&(Nl=0)),rr(i)}function p0(i,s){s===0&&(s=Tt()),i=Do(i,s),i!==null&&(Di(i,s),rr(i))}function PE(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),p0(i,a)}function zE(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,d=i.memoizedState;d!==null&&(a=d.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),p0(i,a)}function HE(i,s){return pe(i,s)}var uh=null,Bl=null,jm=!1,dh=!1,Im=!1,Ma=0;function rr(i){i!==Bl&&i.next===null&&(Bl===null?uh=Bl=i:Bl=Bl.next=i),dh=!0,jm||(jm=!0,FE())}function Zc(i,s){if(!Im&&dh){Im=!0;do for(var a=!1,l=uh;l!==null;){if(i!==0){var d=l.pendingLanes;if(d===0)var m=0;else{var y=l.suspendedLanes,E=l.pingedLanes;m=(1<<31-lt(42|i)+1)-1,m&=d&~(y&~E),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(a=!0,_0(l,m))}else m=Ct,m=fi(l,l===ei?m:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(m&3)===0||wi(l,m)||(a=!0,_0(l,m));l=l.next}while(a);Im=!1}}function UE(){m0()}function m0(){dh=jm=!1;var i=0;Ma!==0&&QE()&&(i=Ma);for(var s=nt(),a=null,l=uh;l!==null;){var d=l.next,m=g0(l,s);m===0?(l.next=null,a===null?uh=d:a.next=d,d===null&&(Bl=a)):(a=l,(i!==0||(m&3)!==0)&&(dh=!0)),l=d}Ui!==0&&Ui!==5||Zc(i),Ma!==0&&(Ma=0)}function g0(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0<m;){var y=31-lt(m),E=1<<y,j=d[y];j===-1?((E&a)===0||(E&l)!==0)&&(d[y]=at(E,s)):j<=s&&(i.expiredLanes|=E),m&=~E}if(s=ei,a=Ct,a=fi(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&&Ie(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||wi(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&Ie(l),Rn(a)){case 2:case 8:a=Dt;break;case 32:a=vt;break;case 268435456:a=si;break;default:a=vt}return l=v0.bind(null,i),a=pe(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&Ie(l),i.callbackPriority=2,i.callbackNode=null,2}function v0(i,s){if(Ui!==0&&Ui!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(ch()&&i.callbackNode!==a)return null;var l=Ct;return l=fi(i,i===ei?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(QS(i,l,s),g0(i,nt()),i.callbackNode!=null&&i.callbackNode===a?v0.bind(null,i):null)}function _0(i,s){if(ch())return null;QS(i,s,!0)}function FE(){e2(function(){(Ot&6)!==0?pe(ht,UE):m0()})}function Pm(){if(Ma===0){var i=yl;i===0&&(i=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),Ma=i}return Ma}function b0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:As(""+i)}function y0(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 KE(i,s,a,l,d){if(s==="submit"&&a&&a.stateNode===d){var m=b0((d[Qt]||null).action),y=l.submitter;y&&(s=(s=y[Qt]||null)?b0(s.formAction):y.getAttribute("formAction"),s!==null&&(m=s,y=null));var E=new Os("action","action",null,l,d);i.push({event:E,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ma!==0){var j=y?y0(d,y):new FormData(d);sm(a,{pending:!0,data:j,method:d.method,action:m},null,j)}}else typeof m=="function"&&(E.preventDefault(),j=y?y0(d,y):new FormData(d),sm(a,{pending:!0,data:j,method:d.method,action:m},m,j))},currentTarget:d}]})}}for(var zm=0;zm<Sp.length;zm++){var Hm=Sp[zm],$E=Hm.toLowerCase(),WE=Hm[0].toUpperCase()+Hm.slice(1);js($E,"on"+WE)}js(Jt,"onAnimationEnd"),js(Ut,"onAnimationIteration"),js(Pt,"onAnimationStart"),js("dblclick","onDoubleClick"),js("focusin","onFocus"),js("focusout","onBlur"),js(er,"onTransitionRun"),js(fl,"onTransitionStart"),js(tr,"onTransitionCancel"),js(Ec,"onTransitionEnd"),yn("onMouseEnter",["mouseout","mouseover"]),yn("onMouseLeave",["mouseout","mouseover"]),yn("onPointerEnter",["pointerout","pointerover"]),yn("onPointerLeave",["pointerout","pointerover"]),Vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qc="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(" "),qE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qc));function S0(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],d=l.event;l=l.listeners;e:{var m=void 0;if(s)for(var y=l.length-1;0<=y;y--){var E=l[y],j=E.instance,se=E.currentTarget;if(E=E.listener,j!==m&&d.isPropagationStopped())break e;m=E,d.currentTarget=se;try{m(d)}catch(me){Td(me)}d.currentTarget=null,m=j}else for(y=0;y<l.length;y++){if(E=l[y],j=E.instance,se=E.currentTarget,E=E.listener,j!==m&&d.isPropagationStopped())break e;m=E,d.currentTarget=se;try{m(d)}catch(me){Td(me)}d.currentTarget=null,m=j}}}}function wt(i,s){var a=s[ws];a===void 0&&(a=s[ws]=new Set);var l=i+"__bubble";a.has(l)||(w0(s,i,2,!1),a.add(l))}function Um(i,s,a){var l=0;s&&(l|=4),w0(a,i,l,s)}var hh="_reactListening"+Math.random().toString(36).slice(2);function Fm(i){if(!i[hh]){i[hh]=!0,uo.forEach(function(a){a!=="selectionchange"&&(qE.has(a)||Um(a,!1,i),Um(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[hh]||(s[hh]=!0,Um("selectionchange",!1,s))}}function w0(i,s,a,l){switch(Z0(s)){case 2:var d=y2;break;case 8:d=S2;break;default:d=ng}a=d.bind(null,s,a,i),d=void 0,!Mn||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),l?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function Km(i,s,a,l,d){var m=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 E=l.stateNode.containerInfo;if(E===d)break;if(y===4)for(y=l.return;y!==null;){var j=y.tag;if((j===3||j===4)&&y.stateNode.containerInfo===d)return;y=y.return}for(;E!==null;){if(y=ks(E),y===null)return;if(j=y.tag,j===5||j===6||j===26||j===27){l=m=y;continue e}E=E.parentNode}}l=l.return}go(function(){var se=m,me=mo(a),ye=[];e:{var oe=Dc.get(i);if(oe!==void 0){var he=Os,$e=i;switch(i){case"keypress":if(Xs(a)===0)break e;case"keydown":case"keyup":he=wo;break;case"focusin":$e="focus",he=yo;break;case"focusout":$e="blur",he=yo;break;case"beforeblur":case"afterblur":he=yo;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":he=bo;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":he=oa;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":he=wc;break;case Jt:case Ut:case Pt:he=ca;break;case Ec:he=T;break;case"scroll":case"scrollend":he=yc;break;case"wheel":he=Q;break;case"copy":case"cut":case"paste":he=So;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":he=Co;break;case"toggle":case"beforetoggle":he=ce}var et=(s&4)!==0,Gt=!et&&(i==="scroll"||i==="scrollend"),X=et?oe!==null?oe+"Capture":null:oe;et=[];for(var H=se,ne;H!==null;){var ve=H;if(ne=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||ne===null||X===null||(ve=wn(H,X),ve!=null&&et.push(Jc(H,ve,ne))),Gt)break;H=H.return}0<et.length&&(oe=new he(oe,$e,null,a,me),ye.push({event:oe,listeners:et}))}}if((s&7)===0){e:{if(oe=i==="mouseover"||i==="pointerover",he=i==="mouseout"||i==="pointerout",oe&&a!==Pi&&($e=a.relatedTarget||a.fromElement)&&(ks($e)||$e[bn]))break e;if((he||oe)&&(oe=me.window===me?me:(oe=me.ownerDocument)?oe.defaultView||oe.parentWindow:window,he?($e=a.relatedTarget||a.toElement,he=se,$e=$e?ks($e):null,$e!==null&&(Gt=c($e),et=$e.tag,$e!==Gt||et!==5&&et!==27&&et!==6)&&($e=null)):(he=null,$e=se),he!==$e)){if(et=bo,ve="onMouseLeave",X="onMouseEnter",H="mouse",(i==="pointerout"||i==="pointerover")&&(et=Co,ve="onPointerLeave",X="onPointerEnter",H="pointer"),Gt=he==null?oe:Xn(he),ne=$e==null?oe:Xn($e),oe=new et(ve,H+"leave",he,a,me),oe.target=Gt,oe.relatedTarget=ne,ve=null,ks(me)===se&&(et=new et(X,H+"enter",$e,a,me),et.target=ne,et.relatedTarget=Gt,ve=et),Gt=ve,he&&$e)t:{for(et=VE,X=he,H=$e,ne=0,ve=X;ve;ve=et(ve))ne++;ve=0;for(var Ze=H;Ze;Ze=et(Ze))ve++;for(;0<ne-ve;)X=et(X),ne--;for(;0<ve-ne;)H=et(H),ve--;for(;ne--;){if(X===H||H!==null&&X===H.alternate){et=X;break t}X=et(X),H=et(H)}et=null}else et=null;he!==null&&C0(ye,oe,he,et,!1),$e!==null&&Gt!==null&&C0(ye,Gt,$e,et,!0)}}e:{if(oe=se?Xn(se):window,he=oe.nodeName&&oe.nodeName.toLowerCase(),he==="select"||he==="input"&&oe.type==="file")var Nt=kc;else if(xo(oe))if(yd)Nt=_p;else{Nt=vp;var Ye=gp}else he=oe.nodeName,!he||he.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?se&&_r(se.elementType)&&(Nt=kc):Nt=Cr;if(Nt&&(Nt=Nt(i,se))){xc(ye,Nt,a,me);break e}Ye&&Ye(i,oe,se),i==="focusout"&&se&&oe.type==="number"&&se.memoizedProps.value!=null&&ia(oe,"number",oe.value)}switch(Ye=se?Xn(se):window,i){case"focusin":(xo(Ye)||Ye.contentEditable==="true")&&(xr=Ye,k=se,z=null);break;case"focusout":z=k=xr=null;break;case"mousedown":Me=!0;break;case"contextmenu":case"mouseup":case"dragend":Me=!1,Xe(ye,a,me);break;case"selectionchange":if(yp)break;case"keydown":case"keyup":Xe(ye,a,me)}var pt;if(Be)e:{switch(i){case"compositionstart":var xt="onCompositionStart";break e;case"compositionend":xt="onCompositionEnd";break e;case"compositionupdate":xt="onCompositionUpdate";break e}xt=void 0}else ha?rs(i,a)&&(xt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(xt="onCompositionStart");xt&&(It&&a.locale!=="ko"&&(ha||xt!=="onCompositionStart"?xt==="onCompositionEnd"&&ha&&(pt=aa()):(Qe=me,Qn="value"in Qe?Qe.value:Qe.textContent,ha=!0)),Ye=fh(se,xt),0<Ye.length&&(xt=new wr(xt,i,null,a,me),ye.push({event:xt,listeners:Ye}),pt?xt.data=pt:(pt=vd(a),pt!==null&&(xt.data=pt)))),(pt=_t?mp(i,a):_d(i,a))&&(xt=fh(se,"onBeforeInput"),0<xt.length&&(Ye=new wr("onBeforeInput","beforeinput",null,a,me),ye.push({event:Ye,listeners:xt}),Ye.data=pt)),KE(ye,i,se,a,me)}S0(ye,s)})}function Jc(i,s,a){return{instance:i,listener:s,currentTarget:a}}function fh(i,s){for(var a=s+"Capture",l=[];i!==null;){var d=i,m=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||m===null||(d=wn(i,a),d!=null&&l.unshift(Jc(i,d,m)),d=wn(i,s),d!=null&&l.push(Jc(i,d,m))),i.tag===3)return l;i=i.return}return[]}function VE(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function C0(i,s,a,l,d){for(var m=s._reactName,y=[];a!==null&&a!==l;){var E=a,j=E.alternate,se=E.stateNode;if(E=E.tag,j!==null&&j===l)break;E!==5&&E!==26&&E!==27||se===null||(j=se,d?(se=wn(a,m),se!=null&&y.unshift(Jc(a,se,j))):d||(se=wn(a,m),se!=null&&y.push(Jc(a,se,j)))),a=a.return}y.length!==0&&i.push({event:s,listeners:y})}var YE=/\r\n?/g,XE=/\u0000|\uFFFD/g;function x0(i){return(typeof i=="string"?i:""+i).replace(YE,`
10
- `).replace(XE,"")}function k0(i,s){return s=x0(s),x0(i)===s}function Xt(i,s,a,l,d,m){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||Ci(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&Ci(i,""+l);break;case"className":ea(i,"class",l);break;case"tabIndex":ea(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":ea(i,a,l);break;case"style":Ns(i,l,m);break;case"data":if(s!=="object"){ea(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=As(""+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 m=="function"&&(a==="formAction"?(s!=="input"&&Xt(i,s,"name",d.name,d,null),Xt(i,s,"formEncType",d.formEncType,d,null),Xt(i,s,"formMethod",d.formMethod,d,null),Xt(i,s,"formTarget",d.formTarget,d,null)):(Xt(i,s,"encType",d.encType,d,null),Xt(i,s,"method",d.method,d,null),Xt(i,s,"target",d.target,d,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=As(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Zn);break;case"onScroll":l!=null&&wt("scroll",i);break;case"onScrollEnd":l!=null&&wt("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(d.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=As(""+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":wt("beforetoggle",i),wt("toggle",i),Ds(i,"popover",l);break;case"xlinkActuate":pn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":pn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":pn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":pn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":pn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":pn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":pn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":pn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":pn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Ds(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=ra.get(a)||a,Ds(i,a,l))}}function $m(i,s,a,l,d,m){switch(a){case"style":Ns(i,l,m);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Ci(i,l):(typeof l=="number"||typeof l=="bigint")&&Ci(i,""+l);break;case"onScroll":l!=null&&wt("scroll",i);break;case"onScrollEnd":l!=null&&wt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Zn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!qs.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(d=a.endsWith("Capture"),s=a.slice(2,d?a.length-7:void 0),m=i[Qt]||null,m=m!=null?m[a]:null,typeof m=="function"&&i.removeEventListener(s,m,d),typeof l=="function")){typeof m!="function"&&m!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,d);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Ds(i,a,l)}}}function un(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":wt("error",i),wt("load",i);var l=!1,d=!1,m;for(m in a)if(a.hasOwnProperty(m)){var y=a[m];if(y!=null)switch(m){case"src":l=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Xt(i,s,m,y,a,null)}}d&&Xt(i,s,"srcSet",a.srcSet,a,null),l&&Xt(i,s,"src",a.src,a,null);return;case"input":wt("invalid",i);var E=m=y=d=null,j=null,se=null;for(l in a)if(a.hasOwnProperty(l)){var me=a[l];if(me!=null)switch(l){case"name":d=me;break;case"type":y=me;break;case"checked":j=me;break;case"defaultChecked":se=me;break;case"value":m=me;break;case"defaultValue":E=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(r(137,s));break;default:Xt(i,s,l,me,a,null)}}vr(i,m,E,j,se,y,d,!1);return;case"select":wt("invalid",i),l=y=m=null;for(d in a)if(a.hasOwnProperty(d)&&(E=a[d],E!=null))switch(d){case"value":m=E;break;case"defaultValue":y=E;break;case"multiple":l=E;default:Xt(i,s,d,E,a,null)}s=m,a=y,i.multiple=!!l,s!=null?an(i,!!l,s,!1):a!=null&&an(i,!!l,a,!0);return;case"textarea":wt("invalid",i),m=d=l=null;for(y in a)if(a.hasOwnProperty(y)&&(E=a[y],E!=null))switch(y){case"value":l=E;break;case"defaultValue":d=E;break;case"children":m=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(r(91));break;default:Xt(i,s,y,E,a,null)}Vs(i,l,d,m);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":Xt(i,s,j,l,a,null));return;case"dialog":wt("beforetoggle",i),wt("toggle",i),wt("cancel",i),wt("close",i);break;case"iframe":case"object":wt("load",i);break;case"video":case"audio":for(l=0;l<Qc.length;l++)wt(Qc[l],i);break;case"image":wt("error",i),wt("load",i);break;case"details":wt("toggle",i);break;case"embed":case"source":case"link":wt("error",i),wt("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(se in a)if(a.hasOwnProperty(se)&&(l=a[se],l!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Xt(i,s,se,l,a,null)}return;default:if(_r(s)){for(me in a)a.hasOwnProperty(me)&&(l=a[me],l!==void 0&&$m(i,s,me,l,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(l=a[E],l!=null&&Xt(i,s,E,l,a,null))}function GE(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 d=null,m=null,y=null,E=null,j=null,se=null,me=null;for(he in a){var ye=a[he];if(a.hasOwnProperty(he)&&ye!=null)switch(he){case"checked":break;case"value":break;case"defaultValue":j=ye;default:l.hasOwnProperty(he)||Xt(i,s,he,null,l,ye)}}for(var oe in l){var he=l[oe];if(ye=a[oe],l.hasOwnProperty(oe)&&(he!=null||ye!=null))switch(oe){case"type":m=he;break;case"name":d=he;break;case"checked":se=he;break;case"defaultChecked":me=he;break;case"value":y=he;break;case"defaultValue":E=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(r(137,s));break;default:he!==ye&&Xt(i,s,oe,he,l,ye)}}ta(i,y,E,j,se,me,m,d);return;case"select":he=y=E=oe=null;for(m in a)if(j=a[m],a.hasOwnProperty(m)&&j!=null)switch(m){case"value":break;case"multiple":he=j;default:l.hasOwnProperty(m)||Xt(i,s,m,null,l,j)}for(d in l)if(m=l[d],j=a[d],l.hasOwnProperty(d)&&(m!=null||j!=null))switch(d){case"value":oe=m;break;case"defaultValue":E=m;break;case"multiple":y=m;default:m!==j&&Xt(i,s,d,m,l,j)}s=E,a=y,l=he,oe!=null?an(i,!!a,oe,!1):!!l!=!!a&&(s!=null?an(i,!!a,s,!0):an(i,!!a,a?[]:"",!1));return;case"textarea":he=oe=null;for(E in a)if(d=a[E],a.hasOwnProperty(E)&&d!=null&&!l.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:Xt(i,s,E,null,l,d)}for(y in l)if(d=l[y],m=a[y],l.hasOwnProperty(y)&&(d!=null||m!=null))switch(y){case"value":oe=d;break;case"defaultValue":he=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==m&&Xt(i,s,y,d,l,m)}po(i,oe,he);return;case"option":for(var $e in a)oe=a[$e],a.hasOwnProperty($e)&&oe!=null&&!l.hasOwnProperty($e)&&($e==="selected"?i.selected=!1:Xt(i,s,$e,null,l,oe));for(j in l)oe=l[j],he=a[j],l.hasOwnProperty(j)&&oe!==he&&(oe!=null||he!=null)&&(j==="selected"?i.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Xt(i,s,j,oe,l,he));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 et in a)oe=a[et],a.hasOwnProperty(et)&&oe!=null&&!l.hasOwnProperty(et)&&Xt(i,s,et,null,l,oe);for(se in l)if(oe=l[se],he=a[se],l.hasOwnProperty(se)&&oe!==he&&(oe!=null||he!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,s));break;default:Xt(i,s,se,oe,l,he)}return;default:if(_r(s)){for(var Gt in a)oe=a[Gt],a.hasOwnProperty(Gt)&&oe!==void 0&&!l.hasOwnProperty(Gt)&&$m(i,s,Gt,void 0,l,oe);for(me in l)oe=l[me],he=a[me],!l.hasOwnProperty(me)||oe===he||oe===void 0&&he===void 0||$m(i,s,me,oe,l,he);return}}for(var X in a)oe=a[X],a.hasOwnProperty(X)&&oe!=null&&!l.hasOwnProperty(X)&&Xt(i,s,X,null,l,oe);for(ye in l)oe=l[ye],he=a[ye],!l.hasOwnProperty(ye)||oe===he||oe==null&&he==null||Xt(i,s,ye,oe,l,he)}function T0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ZE(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var d=a[l],m=d.transferSize,y=d.initiatorType,E=d.duration;if(m&&E&&T0(y)){for(y=0,E=d.responseEnd,l+=1;l<a.length;l++){var j=a[l],se=j.startTime;if(se>E)break;var me=j.transferSize,ye=j.initiatorType;me&&T0(ye)&&(j=j.responseEnd,y+=me*(j<E?1:(E-se)/(j-se)))}if(--l,s+=8*(m+y)/(d.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 Wm=null,qm=null;function ph(i){return i.nodeType===9?i:i.ownerDocument}function E0(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 D0(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 Vm(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 Ym=null;function QE(){var i=window.event;return i&&i.type==="popstate"?i===Ym?!1:(Ym=i,!0):(Ym=null,!1)}var R0=typeof setTimeout=="function"?setTimeout:void 0,JE=typeof clearTimeout=="function"?clearTimeout:void 0,M0=typeof Promise=="function"?Promise:void 0,e2=typeof queueMicrotask=="function"?queueMicrotask:typeof M0<"u"?function(i){return M0.resolve(null).then(i).catch(t2)}:R0;function t2(i){setTimeout(function(){throw i})}function Na(i){return i==="head"}function N0(i,s){var a=s,l=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(d),zl(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")eu(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,eu(a);for(var m=a.firstChild;m;){var y=m.nextSibling,E=m.nodeName;m[Vn]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&m.rel.toLowerCase()==="stylesheet"||a.removeChild(m),m=y}}else a==="body"&&eu(i.ownerDocument.body);a=d}while(a);zl(s)}function A0(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 Xm(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":Xm(a),Yn(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function i2(i,s,a,l){for(;i.nodeType===1;){var d=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Vn])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(m=i.getAttribute("rel"),m==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(m!==d.rel||i.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||i.getAttribute("title")!==(d.title==null?null:d.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(m=i.getAttribute("src"),(m!==(d.src==null?null:d.src)||i.getAttribute("type")!==(d.type==null?null:d.type)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&m&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var m=d.name==null?null:""+d.name;if(d.type==="hidden"&&i.getAttribute("name")===m)return i}else return i;if(i=fs(i.nextSibling),i===null)break}return null}function n2(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=fs(i.nextSibling),i===null))return null;return i}function L0(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=fs(i.nextSibling),i===null))return null;return i}function Gm(i){return i.data==="$?"||i.data==="$~"}function Zm(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function s2(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 fs(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 Qm=null;function O0(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return fs(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function B0(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 j0(i,s,a){switch(s=ph(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 eu(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Yn(i)}var ps=new Map,I0=new Set;function mh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var zr=R.d;R.d={f:r2,r:a2,D:o2,C:l2,L:c2,m:u2,X:h2,S:d2,M:f2};function r2(){var i=zr.f(),s=ah();return i||s}function a2(i){var s=Ts(i);s!==null&&s.tag===5&&s.type==="form"?eS(s):zr.r(i)}var jl=typeof document>"u"?null:document;function P0(i,s,a){var l=jl;if(l&&typeof s=="string"&&s){var d=Yi(s);d='link[rel="'+i+'"][href="'+d+'"]',typeof a=="string"&&(d+='[crossorigin="'+a+'"]'),I0.has(d)||(I0.add(d),i={rel:i,crossOrigin:a,href:s},l.querySelector(d)===null&&(s=l.createElement("link"),un(s,"link",i),Ht(s),l.head.appendChild(s)))}}function o2(i){zr.D(i),P0("dns-prefetch",i,null)}function l2(i,s){zr.C(i,s),P0("preconnect",i,s)}function c2(i,s,a){zr.L(i,s,a);var l=jl;if(l&&i&&s){var d='link[rel="preload"][as="'+Yi(s)+'"]';s==="image"&&a&&a.imageSrcSet?(d+='[imagesrcset="'+Yi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(d+='[imagesizes="'+Yi(a.imageSizes)+'"]')):d+='[href="'+Yi(i)+'"]';var m=d;switch(s){case"style":m=Il(i);break;case"script":m=Pl(i)}ps.has(m)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),ps.set(m,i),l.querySelector(d)!==null||s==="style"&&l.querySelector(tu(m))||s==="script"&&l.querySelector(iu(m))||(s=l.createElement("link"),un(s,"link",i),Ht(s),l.head.appendChild(s)))}}function u2(i,s){zr.m(i,s);var a=jl;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+Yi(l)+'"][href="'+Yi(i)+'"]',m=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Pl(i)}if(!ps.has(m)&&(i=b({rel:"modulepreload",href:i},s),ps.set(m,i),a.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(iu(m)))return}l=a.createElement("link"),un(l,"link",i),Ht(l),a.head.appendChild(l)}}}function d2(i,s,a){zr.S(i,s,a);var l=jl;if(l&&i){var d=Es(l).hoistableStyles,m=Il(i);s=s||"default";var y=d.get(m);if(!y){var E={loading:0,preload:null};if(y=l.querySelector(tu(m)))E.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=ps.get(m))&&Jm(i,a);var j=y=l.createElement("link");Ht(j),un(j,"link",i),j._p=new Promise(function(se,me){j.onload=se,j.onerror=me}),j.addEventListener("load",function(){E.loading|=1}),j.addEventListener("error",function(){E.loading|=2}),E.loading|=4,gh(y,s,l)}y={type:"stylesheet",instance:y,count:1,state:E},d.set(m,y)}}}function h2(i,s){zr.X(i,s);var a=jl;if(a&&i){var l=Es(a).hoistableScripts,d=Pl(i),m=l.get(d);m||(m=a.querySelector(iu(d)),m||(i=b({src:i,async:!0},s),(s=ps.get(d))&&eg(i,s),m=a.createElement("script"),Ht(m),un(m,"link",i),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},l.set(d,m))}}function f2(i,s){zr.M(i,s);var a=jl;if(a&&i){var l=Es(a).hoistableScripts,d=Pl(i),m=l.get(d);m||(m=a.querySelector(iu(d)),m||(i=b({src:i,async:!0,type:"module"},s),(s=ps.get(d))&&eg(i,s),m=a.createElement("script"),Ht(m),un(m,"link",i),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},l.set(d,m))}}function z0(i,s,a,l){var d=(d=Re.current)?mh(d):null;if(!d)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=Il(a.href),a=Es(d).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=Il(a.href);var m=Es(d).hoistableStyles,y=m.get(i);if(y||(d=d.ownerDocument||d,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,y),(m=d.querySelector(tu(i)))&&!m._p&&(y.instance=m,y.state.loading=5),ps.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},ps.set(i,a),m||p2(d,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=Pl(a),a=Es(d).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 Il(i){return'href="'+Yi(i)+'"'}function tu(i){return'link[rel="stylesheet"]['+i+"]"}function H0(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function p2(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}),un(s,"link",a),Ht(s),i.head.appendChild(s))}function Pl(i){return'[src="'+Yi(i)+'"]'}function iu(i){return"script[async]"+i}function U0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+Yi(a.href)+'"]');if(l)return s.instance=l,Ht(l),l;var d=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Ht(l),un(l,"style",d),gh(l,a.precedence,i),s.instance=l;case"stylesheet":d=Il(a.href);var m=i.querySelector(tu(d));if(m)return s.state.loading|=4,s.instance=m,Ht(m),m;l=H0(a),(d=ps.get(d))&&Jm(l,d),m=(i.ownerDocument||i).createElement("link"),Ht(m);var y=m;return y._p=new Promise(function(E,j){y.onload=E,y.onerror=j}),un(m,"link",l),s.state.loading|=4,gh(m,a.precedence,i),s.instance=m;case"script":return m=Pl(a.src),(d=i.querySelector(iu(m)))?(s.instance=d,Ht(d),d):(l=a,(d=ps.get(m))&&(l=b({},a),eg(l,d)),i=i.ownerDocument||i,d=i.createElement("script"),Ht(d),un(d,"link",l),i.head.appendChild(d),s.instance=d);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,gh(l,a.precedence,i));return s.instance}function gh(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,m=d,y=0;y<l.length;y++){var E=l[y];if(E.dataset.precedence===s)m=E;else if(m!==d)break}m?m.parentNode.insertBefore(i,m.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function Jm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function eg(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var vh=null;function F0(i,s,a){if(vh===null){var l=new Map,d=vh=new Map;d.set(a,l)}else d=vh,l=d.get(a),l||(l=new Map,d.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),d=0;d<a.length;d++){var m=a[d];if(!(m[Vn]||m[qt]||i==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var y=m.getAttribute(s)||"";y=i+y;var E=l.get(y);E?E.push(m):l.set(y,[m])}}return l}function K0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function m2(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 $0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function g2(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 d=Il(l.href),m=s.querySelector(tu(d));if(m){s=m._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=_h.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=m,Ht(m);return}m=s.ownerDocument||s,l=H0(l),(d=ps.get(d))&&Jm(l,d),m=m.createElement("link"),Ht(m);var y=m;y._p=new Promise(function(E,j){y.onload=E,y.onerror=j}),un(m,"link",l),a.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=_h.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var tg=0;function v2(i,s){return i.stylesheets&&i.count===0&&yh(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&yh(i,i.stylesheets),i.unsuspend){var m=i.unsuspend;i.unsuspend=null,m()}},6e4+s);0<i.imgBytes&&tg===0&&(tg=62500*ZE());var d=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&yh(i,i.stylesheets),i.unsuspend)){var m=i.unsuspend;i.unsuspend=null,m()}},(i.imgBytes>tg?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function _h(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yh(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var bh=null;function yh(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,bh=new Map,s.forEach(_2,i),bh=null,_h.call(i))}function _2(i,s){if(!(s.state.loading&4)){var a=bh.get(i);if(a)var l=a.get(null);else{a=new Map,bh.set(i,a);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<d.length;m++){var y=d[m];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(a.set(y.dataset.precedence,y),l=y)}l&&a.set(null,l)}d=s.instance,y=d.getAttribute("data-precedence"),m=a.get(y)||l,m===l&&a.set(null,d),a.set(y,d),this.count++,l=_h.bind(this),d.addEventListener("load",l),d.addEventListener("error",l),m?m.parentNode.insertBefore(d,m.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(d,i.firstChild)),s.state.loading|=4}}var nu={$$typeof:F,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function b2(i,s,a,l,d,m,y,E,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=zt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zt(0),this.hiddenUpdates=zt(null),this.identifierPrefix=l,this.onUncaughtError=d,this.onCaughtError=m,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=j,this.incompleteTransitions=new Map}function W0(i,s,a,l,d,m,y,E,j,se,me,ye){return i=new b2(i,s,a,y,j,se,me,ye,E),s=1,m===!0&&(s|=24),m=In(3,null,null,s),i.current=m,m.stateNode=i,s=Op(),s.refCount++,i.pooledCache=s,s.refCount++,m.memoizedState={element:l,isDehydrated:a,cache:s},Pp(m),i}function q0(i){return i?(i=ml,i):ml}function V0(i,s,a,l,d,m){d=q0(d),l.context===null?l.context=d:l.pendingContext=d,l=ya(s),l.payload={element:a},m=m===void 0?null:m,m!==null&&(l.callback=m),a=Sa(i,l,s),a!==null&&(Bn(a,i,s),Bc(a,i,s))}function Y0(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function ig(i,s){Y0(i,s),(i=i.alternate)&&Y0(i,s)}function X0(i){if(i.tag===13||i.tag===31){var s=Do(i,67108864);s!==null&&Bn(s,i,67108864),ig(i,67108864)}}function G0(i){if(i.tag===13||i.tag===31){var s=Fn();s=_n(s);var a=Do(i,s);a!==null&&Bn(a,i,s),ig(i,s)}}var Sh=!0;function y2(i,s,a,l){var d=B.T;B.T=null;var m=R.p;try{R.p=2,ng(i,s,a,l)}finally{R.p=m,B.T=d}}function S2(i,s,a,l){var d=B.T;B.T=null;var m=R.p;try{R.p=8,ng(i,s,a,l)}finally{R.p=m,B.T=d}}function ng(i,s,a,l){if(Sh){var d=sg(l);if(d===null)Km(i,s,l,wh,a),Q0(i,l);else if(C2(d,i,s,a,l))l.stopPropagation();else if(Q0(i,l),s&4&&-1<w2.indexOf(i)){for(;d!==null;){var m=Ts(d);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var y=Lt(m.pendingLanes);if(y!==0){var E=m;for(E.pendingLanes|=2,E.entangledLanes|=2;y;){var j=1<<31-lt(y);E.entanglements[1]|=j,y&=~j}rr(m),(Ot&6)===0&&(sh=nt()+500,Zc(0))}}break;case 31:case 13:E=Do(m,2),E!==null&&Bn(E,m,2),ah(),ig(m,2)}if(m=sg(l),m===null&&Km(i,s,l,wh,a),m===d)break;d=m}d!==null&&l.stopPropagation()}else Km(i,s,l,null,a)}}function sg(i){return i=mo(i),rg(i)}var wh=null;function rg(i){if(wh=null,i=ks(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 wh=i,null}function Z0(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(Mt()){case ht:return 2;case Dt:return 8;case vt:case $t:return 32;case si:return 268435456;default:return 32}default:return 32}}var ag=!1,Aa=null,La=null,Oa=null,su=new Map,ru=new Map,Ba=[],w2="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 Q0(i,s){switch(i){case"focusin":case"focusout":Aa=null;break;case"dragenter":case"dragleave":La=null;break;case"mouseover":case"mouseout":Oa=null;break;case"pointerover":case"pointerout":su.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":ru.delete(s.pointerId)}}function au(i,s,a,l,d,m){return i===null||i.nativeEvent!==m?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:m,targetContainers:[d]},s!==null&&(s=Ts(s),s!==null&&X0(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function C2(i,s,a,l,d){switch(s){case"focusin":return Aa=au(Aa,i,s,a,l,d),!0;case"dragenter":return La=au(La,i,s,a,l,d),!0;case"mouseover":return Oa=au(Oa,i,s,a,l,d),!0;case"pointerover":var m=d.pointerId;return su.set(m,au(su.get(m)||null,i,s,a,l,d)),!0;case"gotpointercapture":return m=d.pointerId,ru.set(m,au(ru.get(m)||null,i,s,a,l,d)),!0}return!1}function J0(i){var s=ks(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,fn(i.priority,function(){G0(a)});return}}else if(s===31){if(s=f(a),s!==null){i.blockedOn=s,fn(i.priority,function(){G0(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 Ch(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=sg(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Pi=l,a.target.dispatchEvent(l),Pi=null}else return s=Ts(a),s!==null&&X0(s),i.blockedOn=a,!1;s.shift()}return!0}function ew(i,s,a){Ch(i)&&a.delete(s)}function x2(){ag=!1,Aa!==null&&Ch(Aa)&&(Aa=null),La!==null&&Ch(La)&&(La=null),Oa!==null&&Ch(Oa)&&(Oa=null),su.forEach(ew),ru.forEach(ew)}function xh(i,s){i.blockedOn===s&&(i.blockedOn=null,ag||(ag=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,x2)))}var kh=null;function tw(i){kh!==i&&(kh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){kh===i&&(kh=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],d=i[s+2];if(typeof l!="function"){if(rg(l||a)===null)continue;break}var m=Ts(a);m!==null&&(i.splice(s,3),s-=3,sm(m,{pending:!0,data:d,method:a.method,action:l},l,d))}}))}function zl(i){function s(j){return xh(j,i)}Aa!==null&&xh(Aa,i),La!==null&&xh(La,i),Oa!==null&&xh(Oa,i),su.forEach(s),ru.forEach(s);for(var a=0;a<Ba.length;a++){var l=Ba[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Ba.length&&(a=Ba[0],a.blockedOn===null);)J0(a),a.blockedOn===null&&Ba.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var d=a[l],m=a[l+1],y=d[Qt]||null;if(typeof m=="function")y||tw(a);else if(y){var E=null;if(m&&m.hasAttribute("formAction")){if(d=m,y=m[Qt]||null)E=y.formAction;else if(rg(d)!==null)continue}else E=y.action;typeof E=="function"?a[l+1]=E:(a.splice(l,3),l-=3),tw(a)}}}function iw(){function i(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(y){return d=y})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,d=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),d!==null&&(d(),d=null)}}}function og(i){this._internalRoot=i}Th.prototype.render=og.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Fn();V0(a,l,i,s,null,null)},Th.prototype.unmount=og.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;V0(i.current,2,null,i,null,null),ah(),s[bn]=null}};function Th(i){this._internalRoot=i}Th.prototype.unstable_scheduleHydration=function(i){if(i){var s=gi();i={blockedOn:null,target:i,priority:s};for(var a=0;a<Ba.length&&s!==0&&s<Ba[a].priority;a++);Ba.splice(a,0,i),a===0&&J0(i)}};var nw=t.version;if(nw!=="19.2.6")throw Error(r(527,nw,"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=p(s),i=i!==null?_(i):null,i=i===null?null:i.stateNode,i};var k2={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Eh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Eh.isDisabled&&Eh.supportsFiber)try{rt=Eh.inject(k2),tt=Eh}catch{}}return lu.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",d=uS,m=dS,y=hS;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(m=s.onCaughtError),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=W0(i,1,!1,null,null,a,l,null,d,m,y,iw),i[bn]=s.current,Fm(i),new og(s)},lu.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,d="",m=uS,y=dS,E=hS,j=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(m=a.onUncaughtError),a.onCaughtError!==void 0&&(y=a.onCaughtError),a.onRecoverableError!==void 0&&(E=a.onRecoverableError),a.formState!==void 0&&(j=a.formState)),s=W0(i,1,!0,s,a??null,l,d,j,m,y,E,iw),s.context=q0(null),a=s.current,l=Fn(),l=_n(l),d=ya(l),d.callback=null,Sa(a,d,l),a=l,s.current.lanes=a,Di(s,a),rr(s),i[bn]=s.current,Fm(i),new Th(s)},lu.version="19.2.6",lu}var fw;function B2(){if(fw)return ug.exports;fw=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(),ug.exports=O2(),ug.exports}var j2=B2();class Uo extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function jC(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))},p=b=>{u||(u=!0,f(),c(b))},_=()=>{t.abort(),p(new Uo(0,"Upload aborted."))};if(e.signal?.aborted){p(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{p(new Uo(t.status,"Invalid upload response."))}return}p(new Uo(t.status,I2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new Uo(0,"Upload failed.")),t.onabort=()=>p(new Uo(0,"Upload aborted.")),t.ontimeout=()=>p(new Uo(0,"Upload timed out.")),t.send(n)})}function I2(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 dn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Kf(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${cr(t)}`),setupPassword:t=>De(e,"/api/auth/password",Je("POST",t)),login:t=>De(e,"/api/auth/login",Je("POST",t)),reauth:t=>De(e,"/api/auth/reauth",Je("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",Je("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",Je("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Fl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",Je("POST",t)),removeNetwork:async t=>{await Fl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",Je("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",Je("PUT",{serverIds:t})),renameAgent:(t,n)=>De(e,`/api/agents/${encodeURIComponent(t)}`,Je("PATCH",{name:n})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",Je("PATCH",{name:t})),removeAgent:async t=>{await Fl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>De(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>De(e,"/api/stats"),getAgentStats:t=>De(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>De(e,"/api/version"),checkUpdate:()=>De(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>De(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>De(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>De(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>De(e,`/api/code-server/status${cr(t)}`),installCodeServer:()=>De(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>De(e,"/api/code-server/open",Je("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",Je("POST",t)),uninstallCodeServer:()=>De(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),getFavorites:()=>De(e,"/api/favorites"),saveFavorites:t=>De(e,"/api/favorites",Je("PUT",t)),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",Je("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",Je("POST",t)),listFiles:t=>De(e,"/api/files/list",Je("POST",t)),readFile:t=>De(e,"/api/files/read",Je("POST",t)),writeFile:t=>De(e,"/api/files/write",Je("POST",t)),createFileEntry:t=>De(e,"/api/files/create",Je("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",Je("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",Je("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",Je("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",Je("POST",t)),previewFile:t=>IC(e,"/api/files/preview",Je("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",Je("POST",t)),closeTerminal:async t=>{await Fl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,Je("PATCH",{title:n})),getTerminalHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${cr(n)}`),getTerminalTranscriptHistory:(t,n={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${cr(n)}`),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${cr(r)}`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",Je("PUT",t)),deleteNotificationAsset:async t=>{await Fl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>De(e,`/api/push-notifications/status${t||n?cr({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",Je("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",Je("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",Je("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",Je("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",Je("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",Je("POST",t))}}function Va(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>De(t,n("terminals")),createTerminal:(r={})=>De(t,n("terminals"),Je("POST",r)),closeTerminal:async r=>{await Fl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>De(t,n(`terminals/${encodeURIComponent(r)}`),Je("PATCH",{title:o})),getTerminalHistory:(r,o={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${cr(o)}`),getTerminalTranscriptHistory:(r,o={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${cr(o)}`),getTerminalTranscriptSource:r=>De(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>De(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>De(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${cr(c)}`),getTerminalLayout:()=>De(t,n("terminal-layout")),saveTerminalLayout:r=>De(t,n("terminal-layout"),Je("PUT",r)),createFileRoot:r=>De(t,n("files/root"),Je("POST",r)),listFiles:r=>De(t,n("files/list"),Je("POST",r)),readFile:r=>De(t,n("files/read"),Je("POST",r)),writeFile:r=>De(t,n("files/write"),Je("POST",r)),createFileEntry:r=>De(t,n("files/create"),Je("POST",r)),moveFileEntry:r=>De(t,n("files/move"),Je("POST",r)),previewDeleteFileEntry:r=>De(t,n("files/delete-preview"),Je("POST",r)),deleteFileEntry:r=>De(t,n("files/delete"),Je("POST",r)),openFileInTerminal:r=>De(t,n("files/open"),Je("POST",r)),previewFile:r=>IC(t,n("files/preview"),Je("POST",r)),uploadComposeAttachments:r=>jC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>De(t,n("attachments/limits")),deleteComposeAttachments:r=>De(t,n("attachments/delete"),Je("POST",r)),getCodeServerStatus:(r={})=>De(t,`${n("code-server/status")}${cr(r)}`),installCodeServer:()=>De(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>De(t,n("code-server/open"),Je("POST",r)),stopCodeServer:(r={})=>De(t,n("code-server/stop"),Je("POST",r)),uninstallCodeServer:()=>De(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getAccounts:()=>De(t,n("accounts")),selectAccount:(r,o)=>De(t,n(`accounts/${r}/select`),Je("POST",{profileId:o})),removeAccount:(r,o)=>De(t,n(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>De(t,n(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(r,o)=>De(t,n(`accounts/${r}/login/complete`),Je("POST",{label:o})),cancelAccountLogin:r=>De(t,n(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>De(t,n(`accounts/${r}/refresh`),Je("POST",o?{profileId:o}:{})),terminateProviderSessions:r=>De(t,n(`accounts/${r}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>P2(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function P2(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 cr(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 De(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await Z_(r);try{return await r.json()}catch{throw new dn(r.status,"invalid_json_response")}}async function Fl(e,t,n){const r=await e(t,n);await Z_(r)}async function IC(e,t,n){const r=await e(t,n);return await Z_(r),r.blob()}async function Z_(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 dn(e.status,t)}const Q_="nterminal.theme.id",PC="nterminal.theme.accent",lv="nterminal:theme",ff=[{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",...pw({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",...pw({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],nc="midnight";function $f(e){return ff.some(t=>t.id===e)?e:nc}function J_(e){return ff.find(t=>t.id===e)??ff[0]}function eo(){if(typeof window>"u")return nc;try{const e=window.localStorage.getItem(Q_);return e?$f(e):K2(window.localStorage.getItem(PC))}catch{return nc}}function z2(e){const t=$f(e);if(typeof window<"u"){try{window.localStorage.setItem(Q_,t)}catch{}eb(t),window.dispatchEvent(new CustomEvent(lv,{detail:t}))}return t}function eb(e=eo()){if(typeof document>"u")return;const t=J_($f(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 H2(e=eo()){return J_($f(e)).xterm}function tb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Q_||n.key===PC)&&(eb(eo()),e())};return window.addEventListener(lv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(lv,e),window.removeEventListener("storage",t)}}function mt(e,t,n){e.style.setProperty(t,n)}function pw(e){const t=U2(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 U2(e){const t=[];for(let n=16;n<=e;n+=1)t.push(F2(n));return t}function F2(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 mw(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return mw(t,t,t)}return"#000000"}function mw(e,t,n){return`#${pg(e)}${pg(t)}${pg(n)}`}function pg(e){return e.toString(16).padStart(2,"0")}function K2(e){return e==="signal-red"?"signal-red":nc}function zC(){const e=v.useSyncExternalStore(tb,eo,()=>nc);return J_(e).mode==="light"?"-light":""}function HC({size:e=22}){const t=zC();return h.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function UC({height:e=18}){const t=zC(),n=Math.round(243/34*e);return h.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var wu=BC();function $2(){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 Wf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function cc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ib(e){return"nodeType"in e}function Tn(e){var t,n;return e?cc(e)?e:ib(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function nb(e){const{Document:t}=Tn(e);return e instanceof t}function ld(e){return cc(e)?!1:e instanceof Tn(e).HTMLElement}function FC(e){return e instanceof Tn(e).SVGElement}function uc(e){return e?cc(e)?e.document:ib(e)?nb(e)?e:ld(e)||FC(e)?e.ownerDocument:document:document:document}const Us=Wf?v.useLayoutEffect:v.useEffect;function qf(e){const t=v.useRef(e);return Us(()=>{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 W2(){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 Ku(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Us(()=>{n.current!==e&&(n.current=e)},t),n}function cd(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function pf(e){const t=qf(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function mf(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let mg={};function ud(e,t){return v.useMemo(()=>{if(t)return t;const n=mg[e]==null?0:mg[e]+1;return mg[e]=n,e+"-"+n},[e,t])}function KC(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,p]of f){const _=c[g];_!=null&&(c[g]=_+e*p)}return c},{...t})}}const Jl=KC(1),gf=KC(-1);function q2(e){return"clientX"in e&&"clientY"in e}function Vf(e){if(!e)return!1;const{KeyboardEvent:t}=Tn(e.target);return t&&e instanceof t}function V2(e){if(!e)return!1;const{TouchEvent:t}=Tn(e.target);return t&&e instanceof t}function vf(e){if(V2(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 q2(e)?{x:e.clientX,y:e.clientY}:null}const Xr=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[Xr.Translate.toString(e),Xr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),gw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Y2(e){return e.matches(gw)?e:e.querySelector(gw)}const X2={display:"none"};function G2(e){let{id:t,value:n}=e;return jt.createElement("div",{id:t,style:X2},n)}function Z2(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 jt.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Q2(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const $C=v.createContext(null);function J2(e){const t=v.useContext($C);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function eD(){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 tD={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
- `},iD={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 nD(e){let{announcements:t=iD,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=tD}=e;const{announce:c,announcement:u}=Q2(),f=ud("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),J2(v.useMemo(()=>({onDragStart(b){let{active:C}=b;c(t.onDragStart({active:C}))},onDragMove(b){let{active:C,over:w}=b;t.onDragMove&&c(t.onDragMove({active:C,over:w}))},onDragOver(b){let{active:C,over:w}=b;c(t.onDragOver({active:C,over:w}))},onDragEnd(b){let{active:C,over:w}=b;c(t.onDragEnd({active:C,over:w}))},onDragCancel(b){let{active:C,over:w}=b;c(t.onDragCancel({active:C,over:w}))}}),[c,t])),!g)return null;const _=jt.createElement(jt.Fragment,null,jt.createElement(G2,{id:r,value:o.draggable}),jt.createElement(Z2,{id:f,announcement:u}));return n?wu.createPortal(_,n):_}var $i;(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"})($i||($i={}));function _f(){}function bf(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function WC(){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 Fs=Object.freeze({x:0,y:0});function sD(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function rD(e,t){const n=vf(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 aD(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function oD(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function lD(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function vw(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 cD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=vw(t,t.left,t.top),c=[];for(const u of r){const{id:f}=u,g=n.get(f);if(g){const p=sD(vw(g),o);c.push({id:f,data:{droppableContainer:u,value:p}})}}return c.sort(aD)};function uD(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,p=e.width*e.height,_=u*f,b=_/(g+p-_);return Number(b.toFixed(4))}return 0}const dD=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=uD(f,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(oD)};function hD(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function qC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Fs}function fD(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 pD=fD(1);function VC(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 mD(e,t,n){const r=VC(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:f}=r,g=e.left-u-(1-o)*parseFloat(n),p=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:p,right:g+_,bottom:p+b,left:g}}const gD={ignoreTransform:!1};function dc(e,t){t===void 0&&(t=gD);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:_}=Tn(e).getComputedStyle(e);p&&(n=mD(n,p,_))}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 _w(e){return dc(e,{ignoreTransform:!0})}function vD(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function _D(e,t){return t===void 0&&(t=Tn(e).getComputedStyle(e)),t.position==="fixed"}function bD(e,t){t===void 0&&(t=Tn(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 sb(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(nb(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!ld(o)||FC(o)||n.includes(o))return n;const c=Tn(e).getComputedStyle(o);return o!==e&&bD(o,c)&&n.push(o),_D(o,c)?n:r(o.parentNode)}return e?r(e):n}function YC(e){const[t]=sb(e,1);return t??null}function gg(e){return!Wf||!e?null:cc(e)?e:ib(e)?nb(e)||e===uc(e).scrollingElement?window:ld(e)?e:null:null}function XC(e){return cc(e)?e.scrollX:e.scrollLeft}function GC(e){return cc(e)?e.scrollY:e.scrollTop}function cv(e){return{x:XC(e),y:GC(e)}}var Zi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Zi||(Zi={}));function ZC(e){return!Wf||!e?!1:e===document.scrollingElement}function QC(e){const t={x:0,y:0},n=ZC(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 yD={x:.2,y:.2};function SD(e,t,n,r,o){let{top:c,left:u,right:f,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=yD);const{isTop:p,isBottom:_,isLeft:b,isRight:C}=QC(e),w={x:0,y:0},x={x:0,y:0},M={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+M.height?(w.y=Zi.Backward,x.y=r*Math.abs((t.top+M.height-c)/M.height)):!_&&g>=t.bottom-M.height&&(w.y=Zi.Forward,x.y=r*Math.abs((t.bottom-M.height-g)/M.height)),!C&&f>=t.right-M.width?(w.x=Zi.Forward,x.x=r*Math.abs((t.right-M.width-f)/M.width)):!b&&u<=t.left+M.width&&(w.x=Zi.Backward,x.x=r*Math.abs((t.left+M.width-u)/M.width)),{direction:w,speed:x}}function wD(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 JC(e){return e.reduce((t,n)=>Jl(t,cv(n)),Fs)}function CD(e){return e.reduce((t,n)=>t+XC(n),0)}function xD(e){return e.reduce((t,n)=>t+GC(n),0)}function ex(e,t){if(t===void 0&&(t=dc),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);YC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const kD=[["x",["left","right"],CD],["y",["top","bottom"],xD]];class rb{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=sb(n),o=JC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,f]of kD)for(const g of u)Object.defineProperty(this,g,{get:()=>{const p=f(r),_=o[c]-p;return this.rect[g]+_},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Nu{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 TD(e){const{EventTarget:t}=Tn(e);return e instanceof t?e:uc(e)}function vg(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 _s;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(_s||(_s={}));function bw(e){e.preventDefault()}function ED(e){e.stopPropagation()}var Bt;(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"})(Bt||(Bt={}));const tx={start:[Bt.Space,Bt.Enter],cancel:[Bt.Esc],end:[Bt.Space,Bt.Enter,Bt.Tab]},DD=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Bt.Right:return{...n,x:n.x+25};case Bt.Left:return{...n,x:n.x-25};case Bt.Down:return{...n,y:n.y+25};case Bt.Up:return{...n,y:n.y-25}}};class ix{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 Nu(uc(n)),this.windowListeners=new Nu(Tn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(_s.Resize,this.handleCancel),this.windowListeners.add(_s.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(_s.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&ex(r),n(Fs)}handleKeyDown(t){if(Vf(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=tx,coordinateGetter:u=DD,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:p}=r.current,_=p?{x:p.left,y:p.top}:Fs;this.referenceCoordinates||(this.referenceCoordinates=_);const b=u(t,{active:n,context:r.current,currentCoordinates:_});if(b){const C=gf(b,_),w={x:0,y:0},{scrollableAncestors:x}=r.current;for(const M of x){const O=t.code,{isTop:A,isRight:W,isLeft:F,isBottom:U,maxScroll:q,minScroll:ae}=QC(M),P=wD(M),te={x:Math.min(O===Bt.Right?P.right-P.width/2:P.right,Math.max(O===Bt.Right?P.left:P.left+P.width/2,b.x)),y:Math.min(O===Bt.Down?P.bottom-P.height/2:P.bottom,Math.max(O===Bt.Down?P.top:P.top+P.height/2,b.y))},G=O===Bt.Right&&!W||O===Bt.Left&&!F,ge=O===Bt.Down&&!U||O===Bt.Up&&!A;if(G&&te.x!==b.x){const ee=M.scrollLeft+C.x,V=O===Bt.Right&&ee<=q.x||O===Bt.Left&&ee>=ae.x;if(V&&!C.y){M.scrollTo({left:ee,behavior:f});return}V?w.x=M.scrollLeft-ee:w.x=O===Bt.Right?M.scrollLeft-q.x:M.scrollLeft-ae.x,w.x&&M.scrollBy({left:-w.x,behavior:f});break}else if(ge&&te.y!==b.y){const ee=M.scrollTop+C.y,V=O===Bt.Down&&ee<=q.y||O===Bt.Up&&ee>=ae.y;if(V&&!C.x){M.scrollTo({top:ee,behavior:f});return}V?w.y=M.scrollTop-ee:w.y=O===Bt.Down?M.scrollTop-q.y:M.scrollTop-ae.y,w.y&&M.scrollBy({top:-w.y,behavior:f});break}}this.handleMove(t,Jl(gf(b,this.referenceCoordinates),w))}}}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()}}ix.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=tx,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 yw(e){return!!(e&&"distance"in e)}function Sw(e){return!!(e&&"delay"in e)}class ab{constructor(t,n,r){var o;r===void 0&&(r=TD(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=uc(u),this.documentListeners=new Nu(this.document),this.listeners=new Nu(r),this.windowListeners=new Nu(Tn(u)),this.initialCoordinates=(o=vf(c))!=null?o:Fs,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(_s.Resize,this.handleCancel),this.windowListeners.add(_s.DragStart,bw),this.windowListeners.add(_s.VisibilityChange,this.handleCancel),this.windowListeners.add(_s.ContextMenu,bw),this.documentListeners.add(_s.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Sw(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(yw(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(_s.Click,ED,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(_s.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=vf(t))!=null?n:Fs,p=gf(o,g);if(!r&&f){if(yw(f)){if(f.tolerance!=null&&vg(p,f.tolerance))return this.handleCancel();if(vg(p,f.distance))return this.handleStart()}if(Sw(f)&&vg(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);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===Bt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const RD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class nx extends ab{constructor(t){const{event:n}=t,r=uc(n.target);super(t,RD,r)}}nx.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 MD={move:{name:"mousemove"},end:{name:"mouseup"}};var uv;(function(e){e[e.RightClick=2]="RightClick"})(uv||(uv={}));class ob extends ab{constructor(t){super(t,MD,uc(t.event.target))}}ob.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===uv.RightClick?!1:(r?.({event:n}),!0)}}];const _g={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class lb extends ab{constructor(t){super(t,_g)}static setup(){return window.addEventListener(_g.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(_g.move.name,t)};function t(){}}}lb.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 Au;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Au||(Au={}));var yf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(yf||(yf={}));function ND(e){let{acceleration:t,activator:n=Au.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:f=yf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:_,delta:b,threshold:C}=e;const w=LD({delta:b,disabled:!c}),[x,M]=W2(),O=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),W=v.useMemo(()=>{switch(n){case Au.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Au.DraggableRect:return o}},[n,o,g]),F=v.useRef(null),U=v.useCallback(()=>{const ae=F.current;if(!ae)return;const P=O.current.x*A.current.x,te=O.current.y*A.current.y;ae.scrollBy(P,te)},[]),q=v.useMemo(()=>f===yf.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!c||!p.length||!W){M();return}for(const ae of q){if(r?.(ae)===!1)continue;const P=p.indexOf(ae),te=_[P];if(!te)continue;const{direction:G,speed:ge}=SD(ae,te,W,t,C);for(const ee of["x","y"])w[ee][G[ee]]||(ge[ee]=0,G[ee]=0);if(ge.x>0||ge.y>0){M(),F.current=ae,x(U,u),O.current=ge,A.current=G;return}}O.current={x:0,y:0},A.current={x:0,y:0},M()},[t,U,r,M,c,u,JSON.stringify(W),JSON.stringify(w),x,p,q,_,JSON.stringify(C)])}const AD={x:{[Zi.Backward]:!1,[Zi.Forward]:!1},y:{[Zi.Backward]:!1,[Zi.Forward]:!1}};function LD(e){let{delta:t,disabled:n}=e;const r=mf(t);return cd(o=>{if(n||!r||!o)return AD;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Zi.Backward]:o.x[Zi.Backward]||c.x===-1,[Zi.Forward]:o.x[Zi.Forward]||c.x===1},y:{[Zi.Backward]:o.y[Zi.Backward]||c.y===-1,[Zi.Forward]:o.y[Zi.Forward]||c.y===1}}},[n,t,r])}function OD(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return cd(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function BD(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 $u;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($u||($u={}));var dv;(function(e){e.Optimized="optimized"})(dv||(dv={}));const ww=new Map;function jD(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,_=v.useRef(e),b=O(),C=Ku(b),w=v.useCallback(function(A){A===void 0&&(A=[]),!C.current&&u(W=>W===null?A:W.concat(A.filter(F=>!W.includes(F))))},[C]),x=v.useRef(null),M=cd(A=>{if(b&&!n)return ww;if(!A||A===ww||_.current!==e||c!=null){const W=new Map;for(let F of e){if(!F)continue;if(c&&c.length>0&&!c.includes(F.id)&&F.rect.current){W.set(F.id,F.rect.current);continue}const U=F.node.current,q=U?new rb(g(U),U):null;F.rect.current=q,q&&W.set(F.id,q)}return W}return A},[e,c,n,b,g]);return v.useEffect(()=>{_.current=e},[e]),v.useEffect(()=>{b||w()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof f!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},f))},[f,b,w,...r]),{droppableRects:M,measureDroppableContainers:w,measuringScheduled:c!=null};function O(){switch(p){case $u.Always:return!1;case $u.BeforeDragging:return n;default:return!n}}}function cb(e,t){return cd(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ID(e,t){return cb(e,t)}function PD(e){let{callback:t,disabled:n}=e;const r=qf(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 Yf(e){let{callback:t,disabled:n}=e;const r=qf(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 zD(e){return new rb(dc(e),e)}function Cw(e,t,n){t===void 0&&(t=zD);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const _=t(e);return JSON.stringify(g)===JSON.stringify(_)?g:_})}const u=PD({callback(g){if(e)for(const p of g){const{type:_,target:b}=p;if(_==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),f=Yf({callback:c});return Us(()=>{c(),e?(f?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),u?.disconnect())},[e]),r}function HD(e){const t=cb(e);return qC(e,t)}const xw=[];function UD(e){const t=v.useRef(e),n=cd(r=>e?r&&r!==xw&&e&&t.current&&e.parentNode===t.current.parentNode?r:sb(e):xw,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function FD(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=gg(c.target);u&&n(f=>f?(f.set(u,cv(u)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const f=e.map(g=>{const p=gg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,cv(p)]):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 p=gg(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>Jl(c,u),Fs):JC(e):Fs,[e,t])}function kw(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==Fs;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?gf(e,n.current):Fs}function KD(e){v.useEffect(()=>{if(!Wf)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 $D(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 sx(e){return v.useMemo(()=>e?vD(e):null,[e])}const Tw=[];function WD(e,t){t===void 0&&(t=dc);const[n]=e,r=sx(n?Tn(n):null),[o,c]=v.useState(Tw);function u(){c(()=>e.length?e.map(g=>ZC(g)?r:new rb(t(g),g)):Tw)}const f=Yf({callback:u});return Us(()=>{f?.disconnect(),u(),e.forEach(g=>f?.observe(g))},[e]),o}function rx(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ld(t)?t:e}function qD(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:_}of p)if(ld(_)){r(b=>{const C=t(_);return b?{...b,width:C.width,height:C.height}:C});break}},[t]),c=Yf({callback:o}),u=v.useCallback(p=>{const _=rx(p);c?.disconnect(),_&&c?.observe(_),r(_?t(_):null)},[t,c]),[f,g]=pf(u);return v.useMemo(()=>({nodeRef:f,rect:n,setRef:g}),[n,f,g])}const VD=[{sensor:nx,options:{}},{sensor:ix,options:{}}],YD={current:{}},Yh={draggable:{measure:_w},droppable:{measure:_w,strategy:$u.WhileDragging,frequency:dv.Optimized},dragOverlay:{measure:dc}};class Lu 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 XD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Lu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_f},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yh,measureDroppableContainers:_f,windowRect:null,measuringScheduled:!1},ax={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_f,draggableNodes:new Map,over:null,measureDroppableContainers:_f},dd=v.createContext(ax),ox=v.createContext(XD);function GD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Lu}}}function ZD(e,t){switch(t.type){case $i.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $i.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 $i.DragEnd:case $i.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $i.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Lu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $i.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 Lu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case $i.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new Lu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function QD(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(dd),c=mf(r),u=mf(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!Vf(c)||document.activeElement===c.target)return;const f=o.get(u);if(!f)return;const{activatorNode:g,node:p}=f;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const _ of[g.current,p.current]){if(!_)continue;const b=Y2(_);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function lx(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function JD(e){return v.useMemo(()=>({draggable:{...Yh.draggable,...e?.draggable},droppable:{...Yh.droppable,...e?.droppable},dragOverlay:{...Yh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function eR(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;Us(()=>{if(!u&&!f||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const _=n(p),b=qC(_,r);if(u||(b.x=0),f||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const C=YC(p);C&&C.scrollBy({top:b.y,left:b.x})}},[t,u,f,r,n])}const Xf=v.createContext({...Fs,scaleX:1,scaleY:1});var $a;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})($a||($a={}));const cx=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:f,autoScroll:g=!0,children:p,sensors:_=VD,collisionDetection:b=dD,measuring:C,modifiers:w,...x}=t;const M=v.useReducer(ZD,void 0,GD),[O,A]=M,[W,F]=eD(),[U,q]=v.useState($a.Uninitialized),ae=U===$a.Initialized,{draggable:{active:P,nodes:te,translate:G},droppable:{containers:ge}}=O,ee=P!=null?te.get(P):null,V=v.useRef({initial:null,translated:null}),Z=v.useMemo(()=>{var ut;return P!=null?{id:P,data:(ut=ee?.data)!=null?ut:YD,rect:V}:null},[P,ee]),Y=v.useRef(null),[ie,B]=v.useState(null),[R,I]=v.useState(null),ue=Ku(x,Object.values(x)),xe=ud("DndDescribedBy",u),N=v.useMemo(()=>ge.getEnabled(),[ge]),K=JD(C),{droppableRects:de,measureDroppableContainers:ke,measuringScheduled:Ne}=jD(N,{dragging:ae,dependencies:[G.x,G.y],config:K.droppable}),Re=OD(te,P),Le=v.useMemo(()=>R?vf(R):null,[R]),Ae=ct(),We=ID(Re,K.draggable.measure);eR({activeNode:P!=null?te.get(P):null,config:Ae.layoutShiftCompensation,initialRect:We,measure:K.draggable.measure});const Pe=Cw(Re,K.draggable.measure,We),He=Cw(Re?Re.parentElement:null),fe=v.useRef({activatorEvent:null,active:null,activeNode:Re,collisionRect:null,collisions:null,droppableRects:de,draggableNodes:te,draggingNode:null,draggingNodeRect:null,droppableContainers:ge,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),D=ge.getNodeFor((n=fe.current.over)==null?void 0:n.id),J=qD({measure:K.dragOverlay.measure}),Ce=(r=J.nodeRef.current)!=null?r:Re,Ee=ae?(o=J.rect)!=null?o:Pe:null,$=!!(J.nodeRef.current&&J.rect),Te=HD($?null:Pe),_e=sx(Ce?Tn(Ce):null),pe=UD(ae?D??Re:null),Ie=WD(pe),Ue=lx(w,{transform:{x:G.x-Te.x,y:G.y-Te.y,scaleX:1,scaleY:1},activatorEvent:R,active:Z,activeNodeRect:Pe,containerNodeRect:He,draggingNodeRect:Ee,over:fe.current.over,overlayNodeRect:J.rect,scrollableAncestors:pe,scrollableAncestorRects:Ie,windowRect:_e}),Ke=Le?Jl(Le,G):null,nt=FD(pe),Mt=kw(nt),ht=kw(nt,[Pe]),Dt=Jl(Ue,Mt),vt=Ee?pD(Ee,Ue):null,$t=Z&&vt?b({active:Z,collisionRect:vt,droppableRects:de,droppableContainers:N,pointerCoordinates:Ke}):null,si=lD($t,"id"),[Se,Ve]=v.useState(null),rt=$?Ue:Jl(Ue,ht),tt=hD(rt,(c=Se?.rect)!=null?c:null,Pe),kt=v.useRef(null),lt=v.useCallback((ut,Lt)=>{let{sensor:fi,options:wi}=Lt;if(Y.current==null)return;const at=te.get(Y.current);if(!at)return;const Tt=ut.nativeEvent,zt=new fi({active:Y.current,activeNode:at,event:Tt,options:wi,context:fe,onAbort(Wt){if(!te.get(Wt))return;const{onDragAbort:ii}=ue.current,sn={id:Wt};ii?.(sn),W({type:"onDragAbort",event:sn})},onPending(Wt,nn,ii,sn){if(!te.get(Wt))return;const{onDragPending:Rn}=ue.current,gi={id:Wt,constraint:nn,initialCoordinates:ii,offset:sn};Rn?.(gi),W({type:"onDragPending",event:gi})},onStart(Wt){const nn=Y.current;if(nn==null)return;const ii=te.get(nn);if(!ii)return;const{onDragStart:sn}=ue.current,_n={activatorEvent:Tt,active:{id:nn,data:ii.data,rect:V}};wu.unstable_batchedUpdates(()=>{sn?.(_n),q($a.Initializing),A({type:$i.DragStart,initialCoordinates:Wt,active:nn}),W({type:"onDragStart",event:_n}),B(kt.current),I(Tt)})},onMove(Wt){A({type:$i.DragMove,coordinates:Wt})},onEnd:Di($i.DragEnd),onCancel:Di($i.DragCancel)});kt.current=zt;function Di(Wt){return async function(){const{active:ii,collisions:sn,over:_n,scrollAdjustedTranslate:Rn}=fe.current;let gi=null;if(ii&&Rn){const{cancelDrop:fn}=ue.current;gi={activatorEvent:Tt,active:ii,collisions:sn,delta:Rn,over:_n},Wt===$i.DragEnd&&typeof fn=="function"&&await Promise.resolve(fn(gi))&&(Wt=$i.DragCancel)}Y.current=null,wu.unstable_batchedUpdates(()=>{A({type:Wt}),q($a.Uninitialized),Ve(null),B(null),I(null),kt.current=null;const fn=Wt===$i.DragEnd?"onDragEnd":"onDragCancel";if(gi){const Ri=ue.current[fn];Ri?.(gi),W({type:fn,event:gi})}})}}},[te]),qi=v.useCallback((ut,Lt)=>(fi,wi)=>{const at=fi.nativeEvent,Tt=te.get(wi);if(Y.current!==null||!Tt||at.dndKit||at.defaultPrevented)return;const zt={active:Tt};ut(fi,Lt.options,zt)===!0&&(at.dndKit={capturedBy:Lt.sensor},Y.current=wi,lt(fi,Lt))},[te,lt]),li=BD(_,qi);KD(_),Us(()=>{Pe&&U===$a.Initializing&&q($a.Initialized)},[Pe,U]),v.useEffect(()=>{const{onDragMove:ut}=ue.current,{active:Lt,activatorEvent:fi,collisions:wi,over:at}=fe.current;if(!Lt||!fi)return;const Tt={active:Lt,activatorEvent:fi,collisions:wi,delta:{x:Dt.x,y:Dt.y},over:at};wu.unstable_batchedUpdates(()=>{ut?.(Tt),W({type:"onDragMove",event:Tt})})},[Dt.x,Dt.y]),v.useEffect(()=>{const{active:ut,activatorEvent:Lt,collisions:fi,droppableContainers:wi,scrollAdjustedTranslate:at}=fe.current;if(!ut||Y.current==null||!Lt||!at)return;const{onDragOver:Tt}=ue.current,zt=wi.get(si),Di=zt&&zt.rect.current?{id:zt.id,rect:zt.rect.current,data:zt.data,disabled:zt.disabled}:null,Wt={active:ut,activatorEvent:Lt,collisions:fi,delta:{x:at.x,y:at.y},over:Di};wu.unstable_batchedUpdates(()=>{Ve(Di),Tt?.(Wt),W({type:"onDragOver",event:Wt})})},[si]),Us(()=>{fe.current={activatorEvent:R,active:Z,activeNode:Re,collisionRect:vt,collisions:$t,droppableRects:de,draggableNodes:te,draggingNode:Ce,draggingNodeRect:Ee,droppableContainers:ge,over:Se,scrollableAncestors:pe,scrollAdjustedTranslate:Dt},V.current={initial:Ee,translated:vt}},[Z,Re,$t,vt,te,Ce,Ee,de,ge,Se,pe,Dt]),ND({...Ae,delta:G,draggingRect:vt,pointerCoordinates:Ke,scrollableAncestors:pe,scrollableAncestorRects:Ie});const re=v.useMemo(()=>({active:Z,activeNode:Re,activeNodeRect:Pe,activatorEvent:R,collisions:$t,containerNodeRect:He,dragOverlay:J,draggableNodes:te,droppableContainers:ge,droppableRects:de,over:Se,measureDroppableContainers:ke,scrollableAncestors:pe,scrollableAncestorRects:Ie,measuringConfiguration:K,measuringScheduled:Ne,windowRect:_e}),[Z,Re,Pe,R,$t,He,J,te,ge,de,Se,ke,pe,Ie,K,Ne,_e]),Fe=v.useMemo(()=>({activatorEvent:R,activators:li,active:Z,activeNodeRect:Pe,ariaDescribedById:{draggable:xe},dispatch:A,draggableNodes:te,over:Se,measureDroppableContainers:ke}),[R,li,Z,Pe,A,xe,te,Se,ke]);return jt.createElement($C.Provider,{value:F},jt.createElement(dd.Provider,{value:Fe},jt.createElement(ox.Provider,{value:re},jt.createElement(Xf.Provider,{value:tt},p)),jt.createElement(QD,{disabled:f?.restoreFocus===!1})),jt.createElement(nD,{...f,hiddenTextDescribedById:xe}));function ct(){const ut=ie?.autoScrollEnabled===!1,Lt=typeof g=="object"?g.enabled===!1:g===!1,fi=ae&&!ut&&!Lt;return typeof g=="object"?{...g,enabled:fi}:{enabled:fi}}}),tR=v.createContext(null),Ew="button",iR="Draggable";function ub(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=ud(iR),{activators:u,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:_,draggableNodes:b,over:C}=v.useContext(dd),{role:w=Ew,roleDescription:x="draggable",tabIndex:M=0}=o??{},O=g?.id===t,A=v.useContext(O?Xf:tR),[W,F]=pf(),[U,q]=pf(),ae=$D(u,t),P=Ku(n);Us(()=>(b.set(t,{id:t,key:c,node:W,activatorNode:U,data:P}),()=>{const G=b.get(t);G&&G.key===c&&b.delete(t)}),[b,t]);const te=v.useMemo(()=>({role:w,tabIndex:M,"aria-disabled":r,"aria-pressed":O&&w===Ew?!0:void 0,"aria-roledescription":x,"aria-describedby":_.draggable}),[r,w,M,O,x,_.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:te,isDragging:O,listeners:r?void 0:ae,node:W,over:C,setNodeRef:F,setActivatorNodeRef:q,transform:A}}function ux(){return v.useContext(ox)}const nR="Droppable",sR={timeout:25};function Gf(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=ud(nR),{active:u,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(dd),_=v.useRef({disabled:n}),b=v.useRef(!1),C=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:M,timeout:O}={...sR,...o},A=Ku(M??r),W=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),w.current=null},O)},[O]),F=Yf({callback:W,disabled:x||!u}),U=v.useCallback((te,G)=>{F&&(G&&(F.unobserve(G),b.current=!1),te&&F.observe(te))},[F]),[q,ae]=pf(U),P=Ku(t);return v.useEffect(()=>{!F||!q.current||(F.disconnect(),b.current=!1,F.observe(q.current))},[q,F]),v.useEffect(()=>(f({type:$i.RegisterDroppable,element:{id:r,key:c,disabled:n,node:q,rect:C,data:P}}),()=>f({type:$i.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==_.current.disabled&&(f({type:$i.SetDroppableDisabled,id:r,key:c,disabled:n}),_.current.disabled=n)},[r,c,n,f]),{active:u,rect:C,isOver:g?.id===r,node:q,over:g,setNodeRef:ae}}function rR(e){let{animation:t,children:n}=e;const[r,o]=v.useState(null),[c,u]=v.useState(null),f=mf(n);return!n&&!r&&f&&o(f),Us(()=>{if(!c)return;const g=r?.key,p=r?.props.id;if(g==null||p==null){o(null);return}Promise.resolve(t(p,c)).then(()=>{o(null)})},[t,r,c]),jt.createElement(jt.Fragment,null,n,r?v.cloneElement(r,{ref:u}):null)}const aR={x:0,y:0,scaleX:1,scaleY:1};function oR(e){let{children:t}=e;return jt.createElement(dd.Provider,{value:ax},jt.createElement(Xf.Provider,{value:aR},t))}const lR={position:"fixed",touchAction:"none"},cR=e=>Vf(e)?"transform 250ms ease":void 0,uR=v.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:c,className:u,rect:f,style:g,transform:p,transition:_=cR}=e;if(!f)return null;const b=o?p:{...p,scaleX:1,scaleY:1},C={...lR,width:f.width,height:f.height,top:f.top,left:f.left,transform:Xr.Transform.toString(b),transformOrigin:o&&r?rD(r,f):void 0,transition:typeof _=="function"?_(r):_,...g};return jt.createElement(n,{className:u,style:C,ref:t},c)}),dR=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,p]of Object.entries(o))n.node.style.setProperty(g,p);u!=null&&u.active&&n.node.classList.remove(u.active)}},hR=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Xr.Transform.toString(t)},{transform:Xr.Transform.toString(n)}]},fR={duration:250,easing:"ease",keyframes:hR,sideEffects:dR({styles:{active:{opacity:"0"}}})};function pR(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return qf((c,u)=>{if(t===null)return;const f=n.get(c);if(!f)return;const g=f.node.current;if(!g)return;const p=rx(u);if(!p)return;const{transform:_}=Tn(u).getComputedStyle(u),b=VC(_);if(!b)return;const C=typeof t=="function"?t:mR(t);return ex(g,o.draggable.measure),C({active:{id:c,data:f.data,node:g,rect:o.draggable.measure(g)},draggableNodes:n,dragOverlay:{node:u,rect:o.dragOverlay.measure(p)},droppableContainers:r,measuringConfiguration:o,transform:b})})}function mR(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...fR,...e};return c=>{let{active:u,dragOverlay:f,transform:g,...p}=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},C={x:g.x-_.x,y:g.y-_.y,...b},w=o({...p,active:u,dragOverlay:f,transform:{initial:g,final:C}}),[x]=w,M=w[w.length-1];if(JSON.stringify(x)===JSON.stringify(M))return;const O=r?.({active:u,dragOverlay:f,...p}),A=f.node.animate(w,{duration:t,easing:n,fill:"forwards"});return new Promise(W=>{A.onfinish=()=>{O?.(),W()}})}}let Dw=0;function gR(e){return v.useMemo(()=>{if(e!=null)return Dw++,Dw},[e])}const vR=jt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:c,modifiers:u,wrapperElement:f="div",className:g,zIndex:p=999}=e;const{activatorEvent:_,active:b,activeNodeRect:C,containerNodeRect:w,draggableNodes:x,droppableContainers:M,dragOverlay:O,over:A,measuringConfiguration:W,scrollableAncestors:F,scrollableAncestorRects:U,windowRect:q}=ux(),ae=v.useContext(Xf),P=gR(b?.id),te=lx(u,{activatorEvent:_,active:b,activeNodeRect:C,containerNodeRect:w,draggingNodeRect:O.rect,over:A,overlayNodeRect:O.rect,scrollableAncestors:F,scrollableAncestorRects:U,transform:ae,windowRect:q}),G=cb(C),ge=pR({config:r,draggableNodes:x,droppableContainers:M,measuringConfiguration:W}),ee=G?O.setRef:void 0;return jt.createElement(oR,null,jt.createElement(rR,{animation:ge},b&&P?jt.createElement(uR,{key:P,id:b.id,ref:ee,as:f,activatorEvent:_,adjustScale:t,className:g,transition:c,rect:G,style:{zIndex:p,...o},transform:te},n):null))}),_R=128,bR=512,hc=100,yR="too_many_detached_terminals",SR=64,wR=4096;function dx(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>_R)return null;const n=t.workspaces.map(CR);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 hx(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>hc}):!1}function CR(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>bR)return null;const n=t.tabs.map(xR);if(n.some(o=>o===null))return null;const r=DR(t.detachedTerminalIds,hc);return r===null?null:{id:t.id,title:t.title,defaultCwd:ER(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function xR(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=kR(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function kR(e){if(!e||typeof e!="object")return null;let t=0;return hv(e,1,()=>(t+=1,t<=wR))}function hv(e,t,n){if(!e||typeof e!="object"||t>SR||!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=hv(r.first,t+1,n),c=hv(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:TR(r.ratio),first:o,second:c}}function TR(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ER(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function DR(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 fx=[{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"}],RR="nterminal-focus",MR=/^[A-Za-z0-9_.:-]{1,128}$/;function NR(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(RR)!=="terminal"?null:Zf({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Zf(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!Rw(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!Rw(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function Rw(e){return typeof e=="string"&&MR.test(e)}const ti="__main__",px=128,AR=600*1e3,mx="nterminal.clientDiagnostics.v1",gx="nterminal.terminalDiagnosticsCursor.v1",Qf=150,LR=24,OR=160,BR=48*1024,jR="terminal-connection-recovery";let Mw=!1,cu=null,uu=null,bg=0;function IR(){Mw||typeof window>"u"||(Mw=!0,vn("page.load",{navigation:eM(),visibility:document.visibilityState,online:navigator.onLine,viewport:Sx(),standalone:JR()}),document.addEventListener("visibilitychange",()=>{vn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{vn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{vn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>vn("network.online")),window.addEventListener("offline",()=>vn("network.offline")),window.addEventListener("focus",()=>vn("window.focus")),window.addEventListener("blur",()=>vn("window.blur")),window.addEventListener("error",e=>{vn("runtime.error",{message:e.message,source:tM(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{vn("runtime.unhandledrejection",{reason:iM(e.reason)})}))}function vn(e,t={}){const n={id:qR(),at:new Date().toISOString(),event:Wu(e,80),data:yx({...t,visibility:t.visibility??ZR(),online:t.online??QR(),viewport:t.viewport??Sx()})},r=db();return r.push(n),$R(r.slice(-Qf)),n}function db(){try{const e=window.localStorage.getItem(mx);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(WR).filter(n=>n!==null).slice(-Qf):[]}catch{return[]}}async function hb(e,t=fetch){if(cu)return cu;const n=db(),r={reason:Wu(e,80),events:n},o=JSON.stringify(r);cu=(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 cu}finally{cu=null}}function Jf(){return vx().events.length>0}async function PR(e=fetch){if(uu)return uu;uu=zR(e);try{return await uu}finally{uu=null}}async function zR(e){const t=vx();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?(KR(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function vx(){const e=_x(),t=db().filter(o=>HR(o)&&FR(o,e)),n=[];let r=Nw([]);for(const o of t){const c=[...n,o],u=Nw(c);if(UR(u)>BR)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function Nw(e){return JSON.stringify({reason:jR,events:e})}function HR(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function UR(e){return new TextEncoder().encode(e).byteLength}function FR(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(bx(e))}function _x(){try{const e=window.localStorage.getItem(gx);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(-Qf):[]}}catch{return null}}function KR(e){const t=e.at(-1);if(!t)return;const n=_x(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(bx(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-Qf)};try{window.localStorage.setItem(gx,JSON.stringify(o))}catch{}}function $R(e){try{window.localStorage.setItem(mx,JSON.stringify(e))}catch{}}function WR(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:Wu(t.id,128)}:{},at:t.at.slice(0,40),event:Wu(t.event,80),...t.data&&typeof t.data=="object"?{data:yx(t.data)}:{}}}function qR(){return bg=(bg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${bg.toString(36)}`.slice(0,128)}function bx(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 yx(e){const t={};for(const[n,r]of Object.entries(e).slice(0,LR)){const o=Wu(n,64);if(!o||VR(o))continue;const c=YR(r);c!==void 0&&(t[o]=c)}return t}function VR(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function YR(e){if(typeof e=="string")return XR(e,OR);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Wu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function XR(e,t){return GR(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function GR(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 ZR(){return typeof document>"u"?void 0:document.visibilityState}function QR(){return typeof navigator>"u"?void 0:navigator.onLine}function Sx(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function JR(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function eM(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function tM(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 iM(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const wx="nterminal.notifications.completionEnabled",fb="nterminal.notifications.completionToastEnabled",pb="nterminal.notifications.completionToastDurationSeconds",mb="nterminal.notifications.completionToastPersistent",fv="nterminal:completion-toast-display",pv="nterminal:notification-focus",Ou=6.5,mv=2,gv=60;function ep(){return typeof window<"u"&&"Notification"in window}function gb(){try{return window.localStorage.getItem(wx)==="true"}catch{return!1}}function Aw(e){try{window.localStorage.setItem(wx,e?"true":"false")}catch{}}function Qo(){return{enabled:aM(),durationSeconds:rM(),persistUntilDismissed:oM()}}function nM(e){if(typeof window<"u"){try{window.localStorage.setItem(fb,e?"true":"false")}catch{}vb()}return Qo()}function Lw(e){const t=xx(e);if(typeof window<"u"){try{window.localStorage.setItem(pb,String(t))}catch{}vb()}return Qo()}function sM(e){if(typeof window<"u"){try{window.localStorage.setItem(mb,e?"true":"false")}catch{}vb()}return Qo()}function Cx(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===fb||n.key===pb||n.key===mb)&&e()};return window.addEventListener(fv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(fv,e),window.removeEventListener("storage",t)}}function fc(){return ep()?window.Notification.permission:"unsupported"}function rM(){if(typeof window>"u")return Ou;try{const e=window.localStorage.getItem(pb);return e===null?Ou:xx(Number(e))}catch{return Ou}}function aM(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(fb)!=="false"}catch{return!0}}function oM(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(mb)==="true"}catch{return!1}}function xx(e){if(!Number.isFinite(e))return Ou;const t=Math.round(e*2)/2;return Math.max(mv,Math.min(gv,t))}function vb(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(fv))}async function kx(){if(!ep())return"unsupported";try{return await window.Notification.requestPermission()}catch{return fc()}}function lM(e){if(!ep()||fc()!=="granted"||!gb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=Zf({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(),cM(r)})}catch{}}function cM(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(pv,{detail:e}))}const Ow="nterminal.push.clientId",uM=2e4,Bw=[5e3,3e4,12e4];function Wr(){try{const e=window.localStorage.getItem(Ow);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${_v()}`;return window.localStorage.setItem(Ow,t),t}catch{return`client-${_v()}`}}function dM(){return`page-${_v()}`}function tp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=_M(),n=bM(),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 hM(e,t){const n=tp();if(!n.supported)throw new Error(n.reason);if((fc()==="granted"?"granted":await kx())!=="granted")throw new Error("permission_denied");const o=Wr(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await SM(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Dx(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:Ex(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:Tx(n.deviceKind),alwaysNotify:t})}async function fM(e){const t=tp();if(!t.supported||fc()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Wr(),c=await wM(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&vv(r,u.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&vv(r,f.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Dx(f.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:Ex(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:Tx(t.deviceKind),alwaysNotify:!1}),!0}function pM(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=_=>{t||n||(n=!0,fM(e).then(b=>{r=0,b&&vn("push.subscription.reconciled",{trigger:_})}).catch(b=>{if(vn("push.subscription.reconcile_failed",{trigger:_,reason:b instanceof Error?b.message:String(b)}),!t&&r<Bw.length){const C=Bw[r++];o=window.setTimeout(()=>{o=null,u("retry")},C)}}).finally(()=>{n=!1}))},f=_=>{c(),r=0,u(_)},g=()=>f("online"),p=()=>f("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function mM(e){const t=Wr();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 gM(e,t){await e.updatePushNotificationDevice({clientId:Wr(),alwaysNotify:t})}function vM(e){if(typeof window>"u")return()=>{};const t=Wr(),n=dM();let r=null,o=!1;const c=(p=!0)=>{const _=tp();e.updatePushPresence({clientId:t,pageId:n,visibilityState:yM(),focused:document.hasFocus(),deviceKind:_.deviceKind,displayMode:_.displayMode,browserNotificationsEnabled:gb()&&fc()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),uM))},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 _M(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function bM(){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 Tx(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function yM(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function Ex(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 SM(e,t){const n=await e.pushManager.getSubscription();return n?vv(n,t)?n:(await n.unsubscribe(),null):null}function vv(e,t){const n=e.options.applicationServerKey;return n?Rx(n)===t:!0}async function wM(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Rx(t)}function Dx(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 Rx(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 _v(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function $r(e,t){const n=[ti,...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 CM(e,t){return $r(e,t).map(n=>n===ti?null:n)}function xM(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function kM(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const jw="Local",TM=3e4,EM=2,DM=6,Mx="nterminal.serverList.viewMode.v1";function RM(){try{return window.localStorage.getItem(Mx)==="list"?"list":"stats"}catch{return"stats"}}function MM(e){try{window.localStorage.setItem(Mx,e)}catch{}}function NM(e,t){const n=new Map(e.map(r=>[r.id,r]));return $r(t,e).flatMap(r=>{if(r===ti)return[{kind:"main",id:ti}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Iw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Nx(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${ys(e.value.cpuPercent)} ${_b(e.value)}`,`MEM ${ys(e.value.memoryPercent)} ${Yr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${ys(e.value.diskPercent)} ${Yr(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${ys(e.value.swapPercent)} ${Yr(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function Pw(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${ys(e.value.cpuPercent)} (${_b(e.value)})`,`RAM ${ys(e.value.memoryPercent)} (${Yr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${ys(e.value.diskPercent)} (${Yr(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${ys(e.value.swapPercent)} (${Yr(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function AM(e,t){const n=Nx(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function ys(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function _b(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`:`${bv(e.cpuPercent/100*t)}/${t} cores`}function Yr(e,t){return!zw(e)||!zw(t)?"–/–":LM(e,t)}function LM(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${bv(e/r)}/${bv(t/r)} ${n}`}function bv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function zw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Dh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function OM(e){return[{label:"CPU",percent:ys(e.cpuPercent),detail:_b(e),tone:Dh(e.cpuPercent)},{label:"MEM",percent:ys(e.memoryPercent),detail:Yr(e.memoryUsedBytes,e.memoryTotalBytes),tone:Dh(e.memoryPercent)},{label:"DISK",percent:ys(e.diskPercent),detail:Yr(e.diskUsedBytes,e.diskTotalBytes),tone:Dh(e.diskPercent)},{label:"SWAP",percent:ys(e.swapPercent),detail:Yr(e.swapUsedBytes,e.swapTotalBytes),tone:Dh(e.swapPercent)}]}function BM({entry:e}){return e?.status==="offline"?h.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?h.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=>h.jsxs("span",{className:"server-list-stat-cell",children:[h.jsxs("span",{className:"server-list-stat-head",children:[h.jsx("span",{className:"server-list-stat-label",children:t}),h.jsx("span",{className:"server-list-stat-value",children:"–"})]}),h.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):h.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:Pw(e),"aria-label":Pw(e),children:OM(e.value).map(t=>h.jsxs("span",{className:"server-list-stat-cell",children:[h.jsxs("span",{className:"server-list-stat-head",children:[h.jsx("span",{className:"server-list-stat-label",children:t.label}),h.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),h.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function Hw({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,onManageAccounts:u,renderServerChildren:f,compact:g=!1}){const[p,_]=v.useState([]),[b,C]=v.useState([ti]),[w,x]=v.useState(null),[M,O]=v.useState(null),[A,W]=v.useState(""),F=v.useRef(null),[U,q]=v.useState(()=>RM()),[ae,P]=v.useState(null),[te,G]=v.useState(null),[ge,ee]=v.useState({}),V=v.useRef({}),Z=v.useRef(0),Y=v.useRef([]),ie=v.useRef([ti]),B=v.useRef(null);v.useEffect(()=>{Y.current=p},[p]),v.useEffect(()=>{const fe=$r(b,p);ie.current=fe,Iw(fe,b)||C(fe)},[p,b]),v.useEffect(()=>{let fe=!1;return e.listAgents().then(D=>{fe||(_(D.agents),C($r(D.serverOrder,D.agents)))}).catch(()=>{}),e.getMainInfo().then(D=>{fe||x(D.name)}).catch(()=>{}),()=>{fe=!0}},[e,o]),v.useEffect(()=>{M&&(F.current?.focus(),F.current?.select())},[M]),v.useEffect(()=>{let fe=!1;function D(){const Ce=[{key:ti,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...p.map($=>({key:$.id,load:()=>e.getAgentStats($.id),probe:async()=>(await e.pingAgent($.id)).ok}))],Ee=new Set(Ce.map($=>$.key));for(const $ of Object.keys(V.current))Ee.has($)||delete V.current[$];ee($=>{const Te={};for(const _e of Ee)_e in $&&(Te[_e]=$[_e]);return Te});for(const $ of Ce)$.load().then(Te=>{fe||(V.current[$.key]=0,ee(_e=>Ee.has($.key)?{..._e,[$.key]:{status:"online",value:Te,stale:!1}}:_e))}).catch(async Te=>{if(fe)return;if(Te instanceof dn&&Te.status===401&&$.key===ti){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if($.key===ti&&Te instanceof dn){V.current[$.key]=0,ee(pe=>{if(!Ee.has($.key))return pe;const Ie=pe[$.key];return{...pe,[$.key]:{status:"online",value:Ie?.value??null,stale:!0}}});return}if($.probe)try{if(await $.probe()){if(fe)return;V.current[$.key]=0,ee(pe=>{if(!Ee.has($.key))return pe;const Ie=pe[$.key];return{...pe,[$.key]:{status:"online",value:Ie?.value??null,stale:!0}}});return}}catch(pe){if(fe)return;if(pe instanceof dn&&pe.status===401){r?.({source:$.key===ti?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const _e=(V.current[$.key]??0)+1;V.current[$.key]=_e,_e>=EM&&ee(pe=>Ee.has($.key)?{...pe,[$.key]:{status:"offline",value:pe[$.key]?.value??null,stale:!0}}:pe)})}D();const J=window.setInterval(D,TM);return()=>{fe=!0,window.clearInterval(J)}},[e,p,r]);function R(fe){fe==="main"?(W(w??""),O({kind:"main"})):(W(fe.name),O({kind:"agent",id:fe.id}))}async function I(){if(!M)return;const fe=A.trim(),D=M;if(O(null),D.kind==="main"){const J=fe||"";try{const Ce=await e.renameMain(J);x(Ce.name)}catch{}}else{if(!fe)return;const J=p.find(Ce=>Ce.id===D.id)?.name;_(Ce=>Ce.map(Ee=>Ee.id===D.id?{...Ee,name:fe}:Ee));try{await e.renameAgent(D.id,fe)}catch{J!==void 0&&_(Ce=>Ce.map(Ee=>Ee.id===D.id?{...Ee,name:J}:Ee))}}}function ue(){O(null)}function xe(fe){q(fe),MM(fe)}function N(fe,D,J){if(fe===D)return;const Ce=$r(ie.current,Y.current),Ee=Ce.findIndex(Ke=>Ke===fe),$=Ce.findIndex(Ke=>Ke===D);if(Ee<0||$<0)return;const Te=[...Ce],[_e]=Te.splice(Ee,1);if(!_e)return;const pe=Te.findIndex(Ke=>Ke===D);if(pe<0)return;const Ie=J==="before"?pe:pe+1;if(Te.splice(Ie,0,_e),Iw(Te,Ce))return;const Ue=Z.current+1;Z.current=Ue,ie.current=Te,C(Te),e.reorderAgents(Te).then(Ke=>{if(Z.current===Ue){Y.current=Ke.agents;const nt=$r(Ke.serverOrder,Ke.agents);ie.current=nt,_(Ke.agents),C(nt)}}).catch(async()=>{if(Z.current===Ue)try{const Ke=await e.listAgents();if(Z.current===Ue){Y.current=Ke.agents;const nt=$r(Ke.serverOrder,Ke.agents);ie.current=nt,_(Ke.agents),C(nt)}}catch{Z.current===Ue&&(ie.current=Ce,C(Ce))}})}function K(fe,D){const J=$r(ie.current,Y.current),Ce=J.findIndex($=>$===fe),Ee=J[Ce+D];Ce<0||!Ee||N(fe,Ee,D<0?"before":"after")}function de(fe,D){D.pointerType==="mouse"&&D.button!==0||(D.stopPropagation(),B.current={sourceId:fe,pointerId:D.pointerId,startX:D.clientX,startY:D.clientY,active:!1,targetId:null,placement:"after"},D.currentTarget.setPointerCapture?.(D.pointerId))}function ke(fe){const D=B.current;if(!D||D.pointerId!==fe.pointerId)return;const J=Math.hypot(fe.clientX-D.startX,fe.clientY-D.startY);if(!D.active){if(J<DM)return;D.active=!0,P(D.sourceId)}const Ee=document.elementFromPoint(fe.clientX,fe.clientY)?.closest("[data-server-id]"),$=Ee?.dataset.serverId??null;if(!Ee||!$||$===D.sourceId){D.targetId=null,G(null);return}const Te=Ee.getBoundingClientRect(),_e=fe.clientY<Te.top+Te.height/2?"before":"after";D.targetId=$,D.placement=_e,G({serverId:$,placement:_e})}function Ne(fe){const D=B.current;!D||D.pointerId!==fe.pointerId||(fe.stopPropagation(),fe.currentTarget.releasePointerCapture?.(fe.pointerId),B.current=null,P(null),G(null),D.active&&D.targetId&&N(D.sourceId,D.targetId,D.placement))}function Re(fe){const D=B.current;D&&D.pointerId===fe.pointerId&&fe.currentTarget.releasePointerCapture?.(fe.pointerId),B.current=null,P(null),G(null)}const Le=w?.trim()||jw,Ae=M?.kind==="main",We=U==="stats",Pe=NM(p,b),He=Pe.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:Le},...p.map(fe=>({agentId:fe.id,label:fe.name}))])},[p,Le,c]),g?h.jsx("div",{className:"server-list server-list--compact",children:Pe.map(fe=>{const D=fe.kind==="main",J=D?Le:fe.agent.name,Ce=D?ti:fe.id,Ee=ge[Ce],$=Nx(Ee);return h.jsxs("button",{type:"button",className:`server-list-chip${(D?t===null:t===fe.id)?" server-list-chip--active":""}`,onClick:()=>n(D?null:fe.id),"aria-label":`${J}${$?` — ${$}`:""}`,title:`${J}${$?` — ${$}`:""}`,children:[h.jsx("span",{className:"server-list-chip-initial",children:kM(J)}),h.jsx("span",{className:"server-list-chip-pip","data-status":xM(Ee)})]},fe.id)})}):h.jsxs("div",{className:`server-list server-list--${U}`,children:[h.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[h.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":U==="list",onClick:()=>xe("list"),title:"Show server names only",children:"List"}),h.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":U==="stats",onClick:()=>xe("stats"),title:"Show resource usage",children:"Stats"})]}),Pe.map(fe=>{const D=fe.kind==="main",J=D?Le:fe.agent.name,Ce=D?ti:fe.id,Ee=D?t===null:t===fe.id,$=D?Ae:M?.kind==="agent"&&M.id===fe.id,Te=f?.({agentId:D?null:fe.id,serverId:fe.id,label:J,active:Ee}),_e=te?.serverId===fe.id&&ae!==fe.id?` server-list-section--drop-target server-list-section--drop-${te.placement}`:"";return h.jsxs("section",{className:`server-list-section${_e}`,"aria-label":`${J} server`,children:[h.jsx("div",{className:["server-list-row",ae===fe.id?"server-list-row--dragging":"",te?.serverId===fe.id&&ae!==fe.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":fe.id,children:$?h.jsxs(h.Fragment,{children:[He?h.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,h.jsx("form",{className:"server-list-editor",onSubmit:pe=>{pe.preventDefault(),I()},children:h.jsx("input",{ref:F,"aria-label":D?"Rename main server":`Rename ${J}`,value:A,onChange:pe=>W(pe.target.value),onBlur:()=>{I()},onKeyDown:pe=>{pe.key==="Escape"&&(pe.preventDefault(),ue())},placeholder:D?jw:void 0})})]}):h.jsxs(h.Fragment,{children:[He?h.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":fe.id,title:"Drag to reorder","aria-label":`Reorder ${J}`,"aria-grabbed":ae===fe.id,onPointerDown:pe=>de(fe.id,pe),onPointerMove:ke,onPointerUp:Ne,onPointerCancel:Re,onKeyDown:pe=>{(pe.key==="ArrowUp"||pe.key==="ArrowDown")&&(pe.preventDefault(),pe.stopPropagation(),K(fe.id,pe.key==="ArrowUp"?-1:1))},onClick:pe=>pe.stopPropagation(),children:"::"}):null,h.jsxs("div",{className:`server-list-item${Ee?" server-list-item--active":""}`,title:AM(J,ge[Ce]),children:[h.jsxs("div",{className:"server-list-item-header",children:[h.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>n(D?null:fe.id),onDoubleClick:pe=>{pe.preventDefault(),R(D?"main":{id:fe.id,name:J})},children:[h.jsx("span",{className:"server-list-dot"}),h.jsx("span",{className:"server-list-name",title:D?void 0:fe.agent.url??"Outbound connection to main",children:J})]}),u?h.jsx("span",{className:"server-list-provider-actions","aria-label":`${J} account management`,children:["codex","claude"].map(pe=>h.jsx("button",{type:"button",className:"server-list-provider-button",title:`Manage ${pe==="codex"?"Codex":"Claude"} accounts`,"aria-label":`Manage ${pe==="codex"?"Codex":"Claude"} accounts on ${J}`,onClick:()=>u({agentId:D?null:fe.id,label:J},pe),children:h.jsx("img",{src:`/brand/${pe}.webp`,alt:""})},pe))}):null]}),We?h.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>n(D?null:fe.id),children:h.jsx(BM,{entry:ge[Ce]})}):null]})]})}),Te?h.jsx("div",{className:"server-list-children",children:Te}):null]},fe.id)})]})}function jM({provider:e,serverLabel:t,api:n,onClose:r,onLoginStarted:o,onLoginFinished:c}){const[u,f]=v.useState(null),[g,p]=v.useState(!0),[_,b]=v.useState(null),[C,w]=v.useState(null),[x,M]=v.useState(""),[O,A]=v.useState(!1),[W,F]=v.useState(null),[U,q]=v.useState(!1),[ae,P]=v.useState(()=>Date.now()),te=v.useRef(0),G=v.useCallback(async(Y=!1)=>{const ie=++te.current;Y||(p(!0),w(null));try{const B=await n.getAccounts();ie===te.current&&f(B)}catch(B){ie===te.current&&!Y&&w(Rh(B))}finally{ie===te.current&&!Y&&p(!1)}},[n]),ge=v.useMemo(()=>u?.providers.find(Y=>Y.provider===e)??null,[e,u]);v.useEffect(()=>(G(),()=>{te.current+=1}),[G]),v.useEffect(()=>{const Y=ie=>{ie.key==="Escape"&&!_&&(O?A(!1):r())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[r,_,O]),v.useEffect(()=>{const Y=window.setInterval(()=>P(Date.now()),6e4);return()=>window.clearInterval(Y)},[]),v.useEffect(()=>{if(!ge?.pendingLogin||_)return;const ie=window.setInterval(()=>{G(!0)},1500);return()=>window.clearInterval(ie)},[_,ge?.pendingLogin,G]),v.useEffect(()=>{const Y=ge?.pendingLogin;!Y?.ready||!Y.terminalId||Y.terminalId===W||U||(q(!0),c(Y.terminalId).then(()=>{F(Y.terminalId)}).catch(ie=>{w(Rh(ie))}).finally(()=>{q(!1)}))},[W,U,c,ge?.pendingLogin]);async function ee(Y,ie){const B=++te.current;p(!1),b(Y),w(null);try{const R=await ie();B===te.current&&f(R)}catch(R){B===te.current&&w(Rh(R))}finally{B===te.current&&b(null)}}async function V(){b("login"),w(null);try{const Y=await n.beginAccountLogin(e);o(Y.terminal),await G()}catch(Y){w(Rh(Y))}finally{b(null)}}const Z=e==="codex"?"Codex":"Claude";return h.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:Y=>{Y.target===Y.currentTarget&&!_&&r()},children:[h.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${Z} accounts on ${t}`,children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"account-dialog-title",children:[h.jsx(PM,{provider:e}),h.jsxs("div",{children:[h.jsxs("h2",{children:[Z," accounts"]}),h.jsx("p",{children:t})]})]}),h.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",onClick:r,disabled:!!_,children:"x"})]}),h.jsxs("div",{className:"account-dialog-scroll",children:[g?h.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,!g&&ge?h.jsx(IM,{provider:e,status:ge,pendingAction:_,clock:ae,label:x,onLabelChange:M,onSelect:Y=>{ee(`select:${Y}`,()=>n.selectAccount(e,Y))},onDelete:Y=>{ee(`delete:${Y}`,()=>n.removeAccount(e,Y))},onRefresh:Y=>{ee(`refresh:${Y}`,()=>n.refreshAccount(e,Y))},onBeginLogin:()=>{V()},onCompleteLogin:()=>{ee("complete",()=>n.completeAccountLogin(e,x))},onCancelLogin:()=>{ee("cancel",()=>n.cancelAccountLogin(e))},onRequestTerminate:()=>A(!0),loginPaneClosed:!ge.pendingLogin?.terminalId||W===ge.pendingLogin.terminalId,loginPaneClosing:U}):null,C?h.jsx("p",{className:"account-dialog-error",role:"alert",children:C}):null]}),h.jsxs("footer",{className:"account-dialog-footer",children:[h.jsx("button",{type:"button",onClick:()=>{G()},disabled:g||!!_,children:"Refresh"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!_,children:"Close"})]})]}),O?h.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:Y=>{Y.target===Y.currentTarget&&!_&&A(!1)},children:h.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${Z} sessions`,children:[h.jsxs("h3",{children:["Exit all ",Z," sessions?"]}),h.jsxs("p",{children:["This stops detected ",Z," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),h.jsxs("div",{children:[h.jsx("button",{type:"button",onClick:()=>A(!1),disabled:!!_,children:"Cancel"}),h.jsx("button",{type:"button",className:"danger-button",disabled:!!_,onClick:()=>{A(!1),ee("terminate",()=>n.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function IM({provider:e,status:t,pendingAction:n,clock:r,label:o,onLabelChange:c,onSelect:u,onDelete:f,onRefresh:g,onBeginLogin:p,onCompleteLogin:_,onCancelLogin:b,onRequestTerminate:C,loginPaneClosed:w,loginPaneClosing:x}){const M=t.runningProcesses??[],O=t.runningPanes.length>0||M.length>0||t.processCheckUnavailable===!0,A=!t.terminationAcknowledged&&O,W=O||t.terminationAcknowledged?h.jsxs("div",{className:"account-dialog-running",role:"status",children:[h.jsx("strong",{children:t.terminationAcknowledged?"Termination requested.":`Exit ${e==="codex"?"Codex":"Claude"} before changing accounts.`}),t.runningPanes.map(F=>h.jsxs("span",{children:[h.jsx("b",{children:F.title}),h.jsx("small",{children:F.cwd})]},F.terminalId)),M.map(F=>h.jsxs("span",{children:[h.jsxs("b",{children:[F.command," ",h.jsxs("em",{children:["PID ",F.pid]})]}),h.jsx("small",{children:"Detected provider process on this server"})]},F.pid)),t.processCheckUnavailable&&!t.terminationAcknowledged?h.jsxs("span",{children:[h.jsx("b",{children:"Process check unavailable"}),h.jsx("small",{children:"Account changes stay blocked until this server can verify provider processes."})]}):null,t.terminationAcknowledged?h.jsxs("span",{children:[h.jsx("b",{children:"Proceeding after termination request"}),h.jsx("small",{children:"You can now change accounts even if a provider process takes time to exit."})]}):null,!t.processCheckUnavailable&&O?h.jsxs("button",{type:"button",className:"danger-button",disabled:!!n,onClick:C,children:["Exit all ",e==="codex"?"Codex":"Claude"," sessions"]}):null]}):null;return t.pendingLogin?h.jsxs(h.Fragment,{children:[W,h.jsxs("div",{className:"account-dialog-section",children:[h.jsx("p",{children:t.pendingLogin.ready?x?"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&&w?h.jsxs("label",{className:"account-dialog-label",children:["Account name",h.jsx("input",{value:o,onChange:F=>c(F.target.value),placeholder:`${e==="codex"?"Codex":"Claude"} account`,maxLength:80,autoFocus:!0})]}):null,h.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready&&w?h.jsx("button",{type:"button",className:"primary-button",disabled:!!n,onClick:_,children:"Save account"}):null,h.jsx("button",{type:"button",className:"secondary-button",disabled:!!n,onClick:b,children:"Cancel and restore previous"})]})]})]}):h.jsxs(h.Fragment,{children:[W,h.jsxs("div",{className:"account-dialog-section",children:[h.jsxs("div",{className:"account-dialog-section-heading",children:[h.jsx("span",{children:"Saved accounts"}),h.jsx("button",{type:"button",className:"primary-button",disabled:A||!!n,onClick:p,children:"Add account"})]}),t.profiles.length===0?h.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map(F=>{const U=F.id===t.activeProfileId;return h.jsxs("article",{className:`account-profile${U?" account-profile--active":""}`,children:[h.jsxs("div",{children:[h.jsx("strong",{children:F.label}),h.jsxs("small",{title:HM(F.expiresAt),children:[U?"Active":"Saved"," · ",zM(F.expiresAt,r)," · ",UM(F.updatedAt,r)]})]}),h.jsxs("div",{className:"account-profile-actions",children:[h.jsx("button",{type:"button",disabled:A||!!n||U,onClick:()=>u(F.id),children:"Use"}),h.jsx("button",{type:"button",disabled:U&&O||!!n,onClick:()=>g(F.id),children:"Refresh"}),h.jsx("button",{type:"button",className:"danger-button",disabled:!!n||U,onClick:()=>f(F.id),children:"Remove"})]})]},F.id)})]})]})}function PM({provider:e}){return h.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function zM(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 HM(e){return!e||!Number.isFinite(Date.parse(e))?"Session expiry timestamp unavailable":`Session expires ${new Date(e).toLocaleString()}`}function UM(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 Rh(e){return e instanceof dn?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",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 FM({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[f,g]=v.useState(null),[p,_]=v.useState(""),[b,C]=v.useState("");async function w(){try{const[A,W,F]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(W.networks),u(F.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(A){await e.revokeDevice(A),await w()}async function M(A){await e.removeNetwork(A),await w()}async function O(A){A.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),_(""),C(""),await w()}catch(W){g(W instanceof Error?W.message:"Failed to add network")}}return h.jsxs(h.Fragment,{children:[f?h.jsx("p",{className:"form-error",children:f}):null,h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Trusted devices"}),h.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?h.jsx("p",{className:"muted",children:"No trusted devices."}):h.jsx("ul",{className:"security-list",children:t.map(A=>h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsxs("span",{className:"security-item-label",children:[A.label,A.current?h.jsx("span",{className:"security-badge",children:"this device"}):null]}),h.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),h.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(A.id)},children:"revoke"})]},A.id))})]}),h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Trusted networks"}),h.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?h.jsx("p",{className:"muted",children:"No trusted networks."}):h.jsx("ul",{className:"security-list",children:r.map(A=>h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?h.jsx("span",{className:"security-item-meta",children:A.label}):null]}),h.jsx("button",{type:"button",className:"security-remove",onClick:()=>{M(A.id)},children:"remove"})]},A.id))}),h.jsxs("form",{className:"security-add-form",onSubmit:O,children:[h.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:A=>_(A.currentTarget.value),required:!0}),h.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>C(A.currentTarget.value)}),h.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Two-factor authentication"}),h.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."}),h.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const KM=1500,bb="nterminal.terminal.fontSize",yb="nterminal.terminal.fontFamily",yv="nterminal:terminal-font-size",Sv="nterminal:terminal-font-family",wv=11,Cv=20,Yo=14,Sf=[{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:[]}],sc="meslo";xv(sc);async function yg(e=Yo,t=sc){if(typeof document>"u"||!document.fonts)return;const n=Ox(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,KM)})])}function Ax(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Yo;const n=Math.round(t);return Math.max(wv,Math.min(Cv,n))}function Lx(e){return Sf.some(t=>t.id===e)?e:sc}function xv(e){return Ox(e).cssFamily}function Ox(e){return Sf.find(t=>t.id===e)??Sf[0]}function kv(){if(typeof window>"u")return Yo;try{const e=window.localStorage.getItem(bb);return e?Ax(e):Yo}catch{return Yo}}function Tv(){if(typeof window>"u")return sc;try{return Lx(window.localStorage.getItem(yb))}catch{return sc}}function Mh(e){const t=Ax(e);if(typeof window>"u")return t;try{window.localStorage.setItem(bb,String(t))}catch{}return window.dispatchEvent(new CustomEvent(yv,{detail:t})),t}function $M(e){const t=Lx(e);if(typeof window>"u")return t;try{window.localStorage.setItem(yb,t)}catch{}return window.dispatchEvent(new CustomEvent(Sv,{detail:t})),t}function Bx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===bb&&e()};return window.addEventListener(yv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(yv,e),window.removeEventListener("storage",t)}}function jx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===yb&&e()};return window.addEventListener(Sv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Sv,e),window.removeEventListener("storage",t)}}const Sb="nterminal.terminal.showScrollProgress",Ev="nterminal:terminal-scroll-progress",wb="nterminal.terminal.tmuxScrollback.shell",Cb="nterminal.terminal.tmuxScrollback.agent",xb="nterminal.terminal.tmuxScrollback.overrides",qu="nterminal:terminal-tmux-scrollback",WM=200;function Dv(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Sb)!=="false"}catch{return!0}}function qM(e){if(typeof window<"u"){try{window.localStorage.setItem(Sb,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Ev,{detail:e}))}return e}function Ix(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Sb&&e()};return window.addEventListener(Ev,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ev,e),window.removeEventListener("storage",t)}}function Rv(){return Px(wb,!0)}function VM(e){return zx(wb,e,qu)}function Mv(){return Px(Cb,!0)}function YM(e){return zx(Cb,e,qu)}function Xh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===wb||n.key===Cb||n.key===xb)&&e()};return window.addEventListener(qu,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qu,e),window.removeEventListener("storage",t)}}function Sg(e){const n=Hx()[e];return typeof n=="boolean"?n:null}function XM(e,t){if(typeof window<"u"){try{const n=Hx(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-WM);window.localStorage.setItem(xb,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(qu,{detail:{terminalId:e,enabled:t}}))}return t}function Px(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 zx(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 Hx(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(xb);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 kb="nterminal.shortcuts.workspace.v1",Nv="nterminal:workspace-shortcuts",Vu=[{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}],ip={"server.previous":di("ArrowUp",{ctrlKey:!0}),"server.next":di("ArrowDown",{ctrlKey:!0}),"tab.previous":di("ArrowLeft",{ctrlKey:!0}),"tab.next":di("ArrowRight",{ctrlKey:!0}),"tab.index":di("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":di("KeyH",{altKey:!0}),"subagents.toggle":di("KeyA",{altKey:!0}),"scrollback.toggle":di("KeyS",{altKey:!0}),"favorites.toggle":di("KeyF",{ctrlKey:!0,altKey:!0})},GM={"server.previous":di("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":di("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":di("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":di("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":di("Digit",{ctrlKey:!0,altKey:!0}),"split.right":di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":di("KeyH",{altKey:!0}),"subagents.toggle":di("KeyA",{altKey:!0}),"scrollback.toggle":di("KeyS",{altKey:!0}),"favorites.toggle":di("KeyF",{ctrlKey:!0,altKey:!0})};function Jo(){const e=Kx(ip);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(kb);if(!t)return e;const n=JSON.parse(t);for(const r of Vu){const o=n[r.id];if(sN(o)){const c=$x(o,r);nN(c,GM[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Uw(){return JSON.stringify(Jo())}function ZM(e,t){const n=Jo(),r=Vu.find(o=>o.id===e);return r&&(n[e]=$x(t,r),Tb(n)),n}function QM(e){const t=Jo();return t[e]={...ip[e]},Tb(t),t}function JM(){const e=Kx(ip);return Tb(e),e}function Bu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===kb&&e()};return window.addEventListener(Nv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Nv,e),window.removeEventListener("storage",t)}}function eN(e,t){const n=Vx(e);return!n||aN(n)||t.indexed&&qx(e)===null||t.requiresPrimaryModifier&&!Wx(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function Ux(e){const t=Jo();for(const n of Vu){const r=t[n.id];if(!(!r||!rN(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=qx(e);if(o!==null)return{id:n.id,index:o};continue}if(Vx(e)===r.code)return{id:n.id,index:null}}}return null}function ju(e){return Fx(Jo()[e])}function Fx(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(oN(e.code)),t.join("+")}const tN=()=>ju("split.right"),iN=()=>ju("split.down");function di(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Kx(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function nN(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Tb(e){if(!(typeof window>"u")){try{window.localStorage.setItem(kb,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Nv))}}function $x(e,t){return t.requiresPrimaryModifier&&!Wx(e)?{...ip[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Wx(e){return e.ctrlKey||e.altKey||e.metaKey}function sN(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 rN(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function qx(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 Vx(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 aN(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function oN(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 lN="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 cN(e="nterminal",t=new Date){return{reason:"permission",message:lN,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function uN(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 Yx=3600*1e3,dN="local",Av=new Set,Xa=new Map;let to={checking:!1,hasUpdates:!1,lastCheckedAt:null},Eb=null,Iu=null,wf=0,Ka=null;function hN(e){return Av.add(e),()=>{Av.delete(e)}}function Fw(){return to}function fN(e){const t=_N();Eb=e,Db(),Lv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!io(e,t))return;const r=to.lastCheckedAt;(r===null||Date.now()-r>=Yx)&&Lv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),io(e,t)&&vN()}}function pN(e,t){Xa.set(e,Xx(t)),rc({...to,hasUpdates:Rb(),lastCheckedAt:Date.now()})}function wg(e){e===void 0?Xa.clear():Xa.set(e,!1),rc({...to,hasUpdates:Rb()})}async function Lv(e,t){if(!io(e,t))return;if(Ka&&Ka.api===e&&Ka.runId===t)return Ka.promise;rc({...to,checking:!0});const n=mN(e,t).finally(()=>{Ka?.promise===n&&(Ka=null),io(e,t)&&(rc({...to,checking:!1,lastCheckedAt:Date.now()}),gN(e,t))});return Ka={api:e,runId:t,promise:n},n}async function mN(e,t){try{const n=await e.listAgents();if(!io(e,t))return;const r=[{key:dN,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,Xx(u))}catch{o.set(c.key,Xa.get(c.key)??!1)}})),!io(e,t))return;Xa.clear();for(const[c,u]of o)Xa.set(c,u);rc({...to,hasUpdates:Rb()})}catch{}}function gN(e,t){io(e,t)&&(Db(),Iu=window.setTimeout(()=>{Iu=null,io(e,t)&&Lv(e,t)},Yx))}function vN(){wf+=1,Db(),Eb=null,Ka=null,Xa.clear(),rc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Db(){Iu!==null&&(window.clearTimeout(Iu),Iu=null)}function _N(){return wf+=1,wf}function io(e,t){return Eb===e&&wf===t}function Xx(e){return e.updateAvailable===!0}function Rb(){return Array.from(Xa.values()).some(Boolean)}function rc(e){to=e;for(const t of Array.from(Av))t()}const bN=e=>new Promise(t=>setTimeout(t,e));function yN({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,p]=v.useState(null),[_,b]=v.useState(!1),[C,w]=v.useState({});function x(R,I){c(ue=>({...ue,[R]:{...ue[R],...I}}))}function M(R,I){w(ue=>({...ue,[R]:{status:ue[R]?.status??null,busy:ue[R]?.busy??!1,error:ue[R]?.error??null,...I}}))}const O=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),F=R=>R.id===null?e:Va(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async I=>{if(R)return;let ue="Local";try{ue=(await e.getMainInfo()).name?.trim()||ue}catch{}if(R)return;const xe=new Map(I.agents.map(K=>[K.id,K])),N=$r(I.serverOrder,I.agents).flatMap(K=>{if(K===ti)return[{key:"local",id:null,name:ue}];const de=xe.get(K);return de?[{key:de.id,id:de.id,name:de.name}]:[]});r(N);for(const K of N)O(K).then(de=>x(K.key,{version:de,manualUpdate:de.manualUpdate??null})).catch(de=>x(K.key,{error:de instanceof Error?de.message:"unreachable"})),Y(K)}).catch(()=>{}),()=>{R=!0}},[]);async function U(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const I=await A(R);pN(R.key,I),x(R.key,{latestVersion:I.latestVersion,updateAvailable:I.updateAvailable,status:ee(I),...I.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(I){x(R.key,{busy:!1,error:I instanceof Error?I.message:"check failed"})}}async function q(){f(!0),await Promise.all(n.map(R=>U(R))),f(!1)}async function ae(R,I){const ue=Date.now()+18e4;for(;Date.now()<ue;){await bN(3e3);try{const xe=await O(R);if(I&&xe.runningVersion!==I.runningVersion)return xe}catch{}}return null}async function P(R){let I=o[R.key]?.version;if(!I)try{I=await O(R),x(R.key,{version:I,manualUpdate:I.manualUpdate??null})}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let ue;try{ue=await W(R)}catch(N){return x(R.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!ue.ok){const N=ue.manualUpdate??(uN(ue.message)?cN():null);return N?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(x(R.key,{busy:!1,status:void 0,error:ue.message}),"failed")}if(!ue.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),wg(R.key),"unchanged";x(R.key,{status:"restarting…"});const xe=await ae(R,I);return xe?(x(R.key,{busy:!1,version:xe,updateAvailable:!1,status:"updated",manualUpdate:xe.manualUpdate??null}),wg(R.key),R.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(x(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
- `)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const ue=await e.uninstallAgent(R.id);r(xe=>xe.filter(N=>N.key!==R.key)),c(xe=>{const N={...xe};return delete N[R.key],N}),wg(R.key),t?.(R.id),p(ue.message)}catch(ue){x(R.key,{busy:!1,status:void 0,error:ue instanceof Error?ue.message:"delete failed"})}}}async function G(){f(!0),p(null);const R=n.filter(de=>de.id!==null),I=n.find(de=>de.id===null),ue=await Promise.all(R.map(de=>P(de))),xe=ue.filter(de=>de==="failed").length;let N=ue.filter(de=>de==="manual").length,K=null;if(I&&(K=await P(I),K==="manual"&&(N+=1),K==="updated")){xe>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),f(!1);return}xe>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):xe>0?p("Some secondary servers failed to update. Check their rows and retry."):N>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function ge(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 V(R){const I=R?.version;return I?`npm package v${I.runningVersion}`:""}async function Z(R,I){try{await wN(I),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(ue){x(R,{error:ue instanceof Error?ue.message:"copy failed"})}}async function Y(R,I=!1){try{const ue=await F(R).getCodeServerStatus(I?{checkLatest:!0}:void 0);M(R.key,{status:ue,error:null})}catch(ue){M(R.key,{error:ue instanceof Error?ue.message:"code-server status failed"})}}async function ie(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 ue=F(R);M(R.key,{busy:!0,error:null});try{if(I==="install"){const xe=await ue.installCodeServer();M(R.key,{status:xe.status})}else if(I==="update"){const xe=await ue.updateCodeServer();M(R.key,{status:xe.status})}else{const xe=await ue.uninstallCodeServer();M(R.key,{status:xe.status})}}catch(xe){M(R.key,{error:xe instanceof Error?xe.message:"code-server action failed"})}finally{M(R.key,{busy:!1})}}const B=n.filter(R=>C[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(ue=>C[ue.key]?.status?.job?.status==="running");if(R.length===0)return;const I=window.setInterval(()=>{for(const ue of R)Y(ue)},1e3);return()=>window.clearInterval(I)},[B]),h.jsxs("section",{className:"security-section",children:[h.jsx("h3",{children:"Servers"}),h.jsxs("div",{className:"update-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{q()},disabled:u,children:"Check for updates"}),h.jsx("button",{type:"button",onClick:()=>{G()},disabled:u,children:"Update all"})]}),g?h.jsx("p",{className:"settings-status",children:g}):null,_?h.jsxs("div",{className:"server-reload-required",role:"status",children:[h.jsx("span",{children:"Main server update is ready."}),h.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,h.jsx("ul",{className:"security-list",children:n.map(R=>{const I=o[R.key],ue=V(I),xe=I?.manualUpdate??null,N=C[R.key]??{status:null,busy:!1,error:null},K=I?.version!==void 0&&I?.updateAvailable!==!1&&!I?.busy&&!u,de=R.id!==null&&!I?.busy&&!u;return h.jsxs("li",{children:[h.jsxs("div",{className:"server-row-main",children:[h.jsxs("div",{children:[h.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?h.jsx("span",{className:"security-badge",children:"Main"}):null]}),h.jsxs("span",{className:"security-item-meta",children:[ue?`${ue} — `:"",ge(I)]})]}),xe?h.jsxs("div",{className:"server-manual-update",children:[h.jsx("span",{children:xe.message}),h.jsxs("div",{className:"server-manual-command",children:[h.jsx("code",{children:xe.command}),h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Z(R.key,xe.command)},children:I?.copiedCommand?"Copied":"Copy"})]})]}):null,h.jsx(SN,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{Y(R,!0)},onInstall:()=>{ie(R,"install")},onUpdate:()=>{ie(R,"update")},onUninstall:()=>{ie(R,"uninstall")}})]}),h.jsxs("div",{className:"server-row-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{P(R)},disabled:!K,children:I?.busy?"…":"Update"}),R.id!==null?h.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{te(R)},disabled:!de,children:"Delete"}):null]})]},R.key)})})]})}function SN({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onUninstall:u}){const f=e?.job??null,g=f?.status==="running",p=e!==null,_=e?.installed===!0,b=e?.supported!==!1,C=e===null&&!n;return h.jsxs("div",{className:"server-code-addon-inline",children:[h.jsxs("div",{className:"server-code-addon-summary",children:[h.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),h.jsxs("span",{className:"security-item-meta",children:[b?C?"checking...":_?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?h.jsx("p",{className:"settings-error",children:n}):null,f?h.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,h.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[h.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:"↗"}),_?h.jsxs(h.Fragment,{children:[e?.updateAvailable?h.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:"↑"}):h.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:"↻"}),h.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:"×"})]}):h.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:o,disabled:!p||C||t||g||!b,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function wN(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 Nh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function CN({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??Kf(),[t]),[u,f]=v.useState(()=>kv()),[g,p]=v.useState(()=>Tv()),[_,b]=v.useState(()=>Dv()),[C,w]=v.useState(()=>Rv()),[x,M]=v.useState(()=>Mv()),[O,A]=v.useState(()=>eo()),[W,F]=v.useState(()=>Jo()),[U,q]=v.useState(null),[ae,P]=v.useState(null),[te,G]=v.useState("appearance"),[ge,ee]=v.useState(()=>gb()),[V,Z]=v.useState(()=>Qo()),[Y,ie]=v.useState(()=>fc()),[B,R]=v.useState([]),[I,ue]=v.useState([]),[xe,N]=v.useState([]),[K,de]=v.useState(5*1024*1024),[ke,Ne]=v.useState(!1),[Re,Le]=v.useState(null),[Ae,We]=v.useState(null),[Pe,He]=v.useState(!1),[fe,D]=v.useState(null),[J,Ce]=v.useState(null),Ee=v.useRef(null),$=v.useRef(null),Te=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),_e=v.useMemo(()=>new Set(I),[I]),pe=!kN(I,xe),Ie=v.useMemo(()=>tp(),[]),Ue=Ae?.displayMode==="standalone"&&(Ae.deviceKind==="mobile"||Ae.deviceKind==="tablet");v.useEffect(()=>Bx(()=>f(kv())),[]),v.useEffect(()=>jx(()=>p(Tv())),[]),v.useEffect(()=>Ix(()=>b(Dv())),[]),v.useEffect(()=>Xh(()=>{w(Rv()),M(Mv())}),[]),v.useEffect(()=>tb(()=>A(eo())),[]),v.useEffect(()=>Bu(()=>F(Jo())),[]),v.useEffect(()=>Cx(()=>Z(Qo())),[]),v.useEffect(()=>{if(!U)return;const re=Vu.find(ct=>ct.id===U);if(!re)return;const Fe=ct=>{if(ct.preventDefault(),ct.stopPropagation(),ct.key==="Escape"){q(null),P(null);return}const ut=eN(ct,re);if(!ut){P(xN(re));return}F(ZM(U,ut)),q(null),P(null)};return window.addEventListener("keydown",Fe,!0),()=>window.removeEventListener("keydown",Fe,!0)},[U]),v.useEffect(()=>{let re=!1;return c.listNotificationAssets().then(Fe=>{re||$t(Fe)}).catch(Fe=>{re||Le(Kl(Fe))}),()=>{re=!0}},[c]),v.useEffect(()=>{let re=!1;return c.getPushNotificationStatus(Wr()).then(Fe=>{re||(We(Fe.currentDevice),D(null))}).catch(Fe=>{re||D(Kl(Fe))}),()=>{re=!0}},[c]);function Ke(re){f(Mh(Number(re)))}function nt(re){Z(Lw(Number(re)))}function Mt(re){G(re);const Fe=$.current,ct=Te.current[re];if(!Fe||!ct)return;const ut=Math.max(0,Kw(ct,Fe)-12);typeof Fe.scrollTo=="function"?Fe.scrollTo({top:ut,behavior:"smooth"}):Fe.scrollTop=ut}function ht(){const re=$.current;if(!re)return;if(re.scrollTop+re.clientHeight>=re.scrollHeight-2){G(Nh[Nh.length-1].id);return}let Fe="appearance";const ct=re.scrollTop+Math.min(180,Math.max(48,re.clientHeight*.28));for(const ut of Nh){const Lt=Te.current[ut.id];Lt&&Kw(Lt,re)<=ct&&(Fe=ut.id)}G(Fe)}function Dt(re){F(QM(re)),q(null),P(null)}function vt(){F(JM()),q(null),P(null)}function $t(re){const Fe=re.assets.filter(ct=>ct.enabled).map(ct=>ct.id);R(re.assets),ue(Fe),N(Fe),de(re.maxFileBytes),Le(null)}async function si(){if(ge){Aw(!1),ee(!1);return}let re=Y;re==="default"&&(re=await kx(),ie(re)),re==="granted"&&(Aw(!0),ee(!0))}async function Se(){He(!0),D(null),Ce(null);try{if(Ae)await mM(c),We(null);else{await hM(c,!1);const re=await c.getPushNotificationStatus(Wr());We(re.currentDevice)}}catch(re){D(xg(re))}finally{He(!1)}}async function Ve(re){He(!0),D(null),Ce(null);try{await gM(c,re);const Fe=await c.getPushNotificationStatus(Wr());We(Fe.currentDevice)}catch(Fe){D(xg(Fe))}finally{He(!1)}}async function rt(){He(!0),D(null),Ce(null);try{await c.testPushNotification({clientId:Wr()}),Ce("Test notification accepted by the push service.")}catch(re){D(xg(re))}finally{He(!1)}}async function tt(re){const Fe=re?.[0];if(Fe){if(Fe.size>K){Le(`File must be ${Cg(K)} or smaller.`),lt();return}if(Fe.type!=="video/mp4"&&Fe.type!=="video/webm"){Le("Upload an MP4 or WebM video."),lt();return}Ne(!0),Le(null);try{await c.uploadNotificationAsset(Fe),$t(await c.listNotificationAssets()),r?.()}catch(ct){Le(Kl(ct))}finally{Ne(!1),lt()}}}async function kt(re){Ne(!0),Le(null);try{await c.deleteNotificationAsset(re),$t(await c.listNotificationAssets()),r?.()}catch(Fe){Le(Kl(Fe))}finally{Ne(!1)}}function lt(){Ee.current&&(Ee.current.value="")}function qi(re,Fe){const ct=new Set(I);if(Fe?ct.add(re):ct.delete(re),ct.size===0){Le("Keep at least one toast video selected.");return}Le(null),ue(Array.from(ct))}async function li(){if(I.length===0){Le("Keep at least one toast video selected.");return}Ne(!0),Le(null);try{const re=await c.updateNotificationAssetSelection({enabledAssetIds:I});$t(re),r?.()}catch(re){Le(Kl(re))}finally{Ne(!1)}}return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:h.jsxs("div",{className:"security-panel settings-panel",onClick:re=>re.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{children:"Settings"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),h.jsxs("div",{className:"settings-layout",children:[h.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Nh.map(re=>h.jsxs("button",{type:"button","data-active":te===re.id?"true":"false","aria-current":te===re.id?"true":void 0,onClick:()=>Mt(re.id),children:[re.label,re.id==="servers"&&n?h.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},re.id))}),h.jsxs("div",{ref:$,className:"settings-content",onScroll:ht,children:[h.jsxs("section",{id:"settings-appearance",ref:re=>{Te.current.appearance=re},className:"security-section settings-section",children:[h.jsx("h3",{children:"Appearance"}),h.jsx("div",{className:"settings-section-heading",children:h.jsxs("div",{children:[h.jsx("span",{className:"settings-control-title",children:"Theme"}),h.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),h.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:ff.map(re=>h.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":O===re.id,"data-active":O===re.id?"true":"false",onClick:()=>A(z2(re.id)),style:{"--settings-theme-bg":re.tokens.bg,"--settings-theme-bg-2":re.tokens.bg2,"--settings-theme-sidebar":re.tokens.bgSidebar,"--settings-theme-line":re.tokens.line,"--settings-theme-fg":re.tokens.fg,"--settings-theme-fg-2":re.tokens.fg2,"--settings-theme-accent":re.tokens.accent,"--settings-theme-xterm-bg":re.xterm.background,"--settings-theme-xterm-fg":re.xterm.foreground,"--settings-theme-xterm-selection":re.xterm.selectionBackground},children:[h.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[h.jsxs("span",{className:"settings-theme-preview-sidebar",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]}),h.jsxs("span",{className:"settings-theme-preview-main",children:[h.jsxs("span",{className:"settings-theme-preview-tabs",children:[h.jsx("span",{}),h.jsx("span",{})]}),h.jsxs("span",{className:"settings-theme-preview-terminal",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]})]})]}),h.jsxs("span",{className:"settings-theme-card-copy",children:[h.jsx("strong",{children:re.label}),h.jsx("small",{children:re.description})]})]},re.id))}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Font size"}),h.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),h.jsx("input",{type:"range",min:wv,max:Cv,step:1,value:u,"aria-label":"Terminal font size",onChange:re=>Ke(re.currentTarget.value)})]}),h.jsxs("div",{className:"settings-stepper-row",children:[h.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Mh(u-1)),children:"-"}),h.jsx("input",{type:"number",min:wv,max:Cv,step:1,value:u,"aria-label":"Terminal font size value",onChange:re=>Ke(re.currentTarget.value)}),h.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Mh(u+1)),children:"+"}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Mh(Yo)),children:"Reset"})]}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Font family"}),h.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:re=>p($M(re.currentTarget.value)),children:Sf.map(re=>h.jsx("option",{value:re.id,children:re.label},re.id))})]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:_,onChange:re=>b(qM(re.currentTarget.checked))}),"Show scroll progress"]}),h.jsx("div",{className:"settings-section-heading",children:h.jsxs("div",{children:[h.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),h.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:C,onChange:re=>w(VM(re.currentTarget.checked))}),"Shell panes"]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:x,onChange:re=>M(YM(re.currentTarget.checked))}),"Codex/Claude panes"]})]}),h.jsxs("section",{id:"settings-shortcuts",ref:re=>{Te.current.shortcuts=re},className:"security-section settings-section",children:[h.jsxs("div",{className:"settings-section-heading",children:[h.jsx("h3",{children:"Shortcuts"}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:vt,children:"Reset all"})]}),h.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),ae?h.jsx("p",{className:"settings-error",children:ae}):null,h.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Vu.map(re=>{const Fe=U===re.id;return h.jsxs("li",{children:[h.jsxs("div",{children:[h.jsx("span",{className:"settings-shortcut-label",children:re.label}),h.jsx("span",{className:"settings-shortcut-group",children:re.group})]}),h.jsxs("div",{className:"settings-shortcut-actions",children:[h.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Fe?"true":"false",onClick:()=>{q(re.id),P(null)},children:Fe?"Press keys…":Fx(W[re.id])}),h.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Dt(re.id),children:"Reset"})]})]},re.id)})})]}),h.jsxs("section",{id:"settings-notifications",ref:re=>{Te.current.notifications=re},className:"security-section settings-section",children:[h.jsx("h3",{children:"Notifications"}),ep()?h.jsxs(h.Fragment,{children:[h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:ge&&Y==="granted",onChange:()=>{si()},disabled:Y==="denied"}),"System notification when page is hidden"]}),Y==="denied"?h.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."}):h.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):h.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),h.jsxs("div",{className:"settings-subsection",children:[h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:!!Ae,onChange:()=>{Se()},disabled:Pe||!Ie.supported}),"Installed app push notifications"]}),h.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."}),Ie.supported?null:h.jsx("p",{className:"muted",children:Gh(Ie.reason)}),Ae?h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:"muted",children:["Registered as ",Ae.label,". Last active ",new Date(Ae.lastActiveAt).toLocaleString(),"."]}),h.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{rt()},disabled:Pe,children:"Send test notification"})]}):null,Ue?h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:Ae?.alwaysNotify===!0,onChange:re=>{Ve(re.currentTarget.checked)},disabled:Pe||!Ae}),"Always notify this mobile device"]}):null,fe?h.jsx("p",{className:"form-error",children:fe}):null,J?h.jsx("p",{className:"muted",role:"status",children:J}):null]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:V.enabled,onChange:re=>Z(nM(re.currentTarget.checked))}),"Show animated completion toast"]}),h.jsxs("label",{className:"settings-control",children:[h.jsx("span",{children:"Toast duration"}),h.jsx("span",{className:"settings-control-value",children:V.persistUntilDismissed?"Until closed":`${V.durationSeconds}s`}),h.jsx("input",{type:"range",min:mv,max:gv,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:re=>nt(re.currentTarget.value)})]}),h.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[h.jsx("input",{type:"number",min:mv,max:gv,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:re=>nt(re.currentTarget.value)}),h.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!V.enabled||V.persistUntilDismissed,onClick:()=>Z(Lw(Ou)),children:"Reset"})]}),h.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[h.jsx("input",{type:"checkbox",checked:V.persistUntilDismissed,disabled:!V.enabled,onChange:re=>Z(sM(re.currentTarget.checked))}),"Keep toast until dismissed"]}),h.jsxs("div",{className:"settings-assets-header",children:[h.jsx("span",{children:"Toast videos"}),h.jsxs("span",{children:[Cg(K)," max"]})]}),h.jsx("input",{ref:Ee,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:re=>{tt(re.currentTarget.files)}}),h.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ke,onClick:()=>Ee.current?.click(),children:"Upload video"}),Re?h.jsx("p",{className:"settings-error",children:Re}):null,B.length>0?h.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:B.map(re=>h.jsxs("li",{"data-enabled":_e.has(re.id)?"true":"false",children:[h.jsxs("label",{className:"settings-asset-choice",children:[h.jsx("input",{type:"checkbox",checked:_e.has(re.id),disabled:ke,"aria-label":`Use ${re.filename}`,onChange:Fe=>qi(re.id,Fe.currentTarget.checked)}),h.jsx("video",{src:re.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),h.jsxs("span",{className:"settings-asset-copy",children:[h.jsx("span",{children:re.filename}),h.jsx("small",{children:re.source==="built-in"?"Built-in":Cg(re.size)})]})]}),re.source==="uploaded"?h.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ke,"aria-label":`Delete ${re.filename}`,onClick:()=>{kt(re.id)},children:"x"}):null]},re.id))}):h.jsx("p",{className:"muted",children:"Built-in videos will be used."}),h.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ke||B.length===0||!pe,onClick:()=>{li()},children:"Save selected videos"})]}),h.jsx("div",{id:"settings-security",ref:re=>{Te.current.security=re},className:"settings-section-group",children:h.jsx(FM,{api:c})}),h.jsx("div",{id:"settings-servers",ref:re=>{Te.current.servers=re},className:"settings-section-group",children:h.jsx(yN,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Kw(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Cg(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 Kl(e){return e instanceof Error?e.message:"Request failed."}function Gh(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 xg(e){const t=Kl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Gh("not_standalone"):t==="insecure"?Gh("insecure"):t==="not_mobile"?Gh("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 xN(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 kN(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const TN="modulepreload",EN=function(e){return"/"+e},$w={},Mb=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.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(p=>{if(p=EN(p),p in $w)return;$w[p]=!0;const _=p.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const C=document.createElement("link");if(C.rel=_?"stylesheet":TN,_||(C.as="script"),C.crossOrigin="",C.href=p,f&&C.setAttribute("nonce",f),document.head.appendChild(C),_)return new Promise((w,x)=>{C.addEventListener("load",w),C.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}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)})},DN=v.lazy(()=>Mb(()=>import("./MarkdownPreview-mvGPeEQn.js"),__vite__mapDeps([0,1])));function RN({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[f,g]=v.useState(""),[p,_]=v.useState({}),[b,C]=v.useState(()=>new Set),[w,x]=v.useState(null),[M,O]=v.useState({type:"empty"}),[A,W]=v.useState("idle"),[F,U]=v.useState(null),q=v.useRef(null),ae=v.useRef(null),P=v.useRef(!1),te=v.useRef(0),G=v.useRef(null);G.current===null&&t&&(G.current=t);const ge=G.current,ee=r?NN(r):t?Ww(t,n):null,V=c?[c.rootPath,f].filter(Boolean).join("/"):"",Z=w?.path??null;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,te.current+=1,He()}),[]),v.useEffect(()=>{G.current=t,ae.current=null,Y(ee)},[e]),v.useEffect(()=>{r&&ee!==ae.current&&ie(r,ee)},[r,ee]),v.useEffect(()=>{if(r||!ge||t!==ge)return;const $=Ww(ge,n);$!==ae.current&&B(ge,$)},[ge,t,n,r]);async function Y($=ee){if(r){await ie(r,$);return}await B(t,$)}async function ie($,Te=ee){const _e=fe();if(ae.current=Te,He(),u(null),g(""),_({}),C(new Set),x(null),O({type:"empty"}),U(null),!$){W("idle");return}W("loading");try{const pe=await e.createFileRoot({path:$});if(!D(_e))return;u({rootToken:pe.rootToken,rootPath:pe.rootPath});const Ie=await e.listFiles({rootToken:pe.rootToken,path:""});if(!D(_e))return;ue(Ie),W("idle")}catch(pe){D(_e)&&(U(Hr(pe)),W("idle"))}}async function B($,Te=ee){const _e=fe();if(ae.current=Te,He(),u(null),g(""),_({}),C(new Set),x(null),O({type:"empty"}),U(null),!$){W("idle");return}W("loading");try{const pe=await e.createFileRoot({terminalId:$});if(!D(_e))return;u({rootToken:pe.rootToken,rootPath:pe.rootPath});const Ie=await e.listFiles({rootToken:pe.rootToken,path:""});if(!D(_e))return;ue(Ie),W("idle")}catch(pe){if(await J(pe,_e))return;D(_e)&&(U(Hr(pe)),W("idle"))}}async function R($=f,Te=c){if(!Te)return;const _e=fe();W("loading"),U(null);try{const pe=await e.listFiles({rootToken:Te.rootToken,path:$});if(!D(_e))return;ue(pe),W("idle")}catch(pe){if(await J(pe,_e))return;D(_e)&&(U(Hr(pe)),W("idle"))}}async function I(){if(r){await ie(r,ee);return}G.current=t,await B(t,ee)}function ue($){_(Te=>({...Te,[$.path]:AN($.entries)}))}async function xe($){if(!(!kg($)||!c)){if(x($),U(null),$.kind==="directory"){g($.path),Pe(),await K($);return}if(g(Fo($.path)),$.editable){await ke($);return}$.previewKind!=="none"&&await Re($,$.previewKind)}}async function N($){if(!(!kg($)||!c)){if(x($),U(null),$.kind==="directory"){g($.path),Pe(),await K($);return}if(g(Fo($.path)),$.editable){await Ne($);return}$.previewKind!=="none"&&await Re($,$.previewKind)}}async function K($){if(b.has($.path)){C(Te=>{const _e=new Set(Te);return _e.delete($.path),_e});return}C(Te=>new Set(Te).add($.path)),await R($.path)}function de($,Te){$.key==="Enter"&&($.preventDefault(),N(Te))}async function ke($){if(!c)return;const Te=fe();W("loading"),He();try{const _e=await e.readFile({rootToken:c.rootToken,path:$.path});if(!D(Te))return;O({type:"text-preview",file:$,read:_e}),W("idle")}catch(_e){if(await J(_e,Te))return;D(Te)&&(U(Hr(_e)),W("idle"))}}async function Ne($){if(!c)return;const Te=fe();W("loading");try{await o({rootToken:c.rootToken,path:$.path,...t?{terminalId:t}:{}}),D(Te)&&W("idle")}catch(_e){if(await J(_e,Te))return;D(Te)&&(U(Hr(_e)),W("idle"))}}async function Re($,Te){if(!c)return;const _e=fe();W("loading"),He();try{const pe=await e.previewFile({rootToken:c.rootToken,path:$.path});if(!D(_e))return;const Ie=URL.createObjectURL(pe);if(!D(_e)){URL.revokeObjectURL(Ie);return}q.current=Ie,O({type:"preview",file:$,previewKind:Te,url:Ie}),W("idle")}catch(pe){if(await J(pe,_e))return;D(_e)&&(U(Hr(pe)),W("idle"))}}async function Le($){if(!c)return;const Te=$==="file"?"New file":"New folder",_e=window.prompt(Te,""),pe=w?w.kind==="directory"?w.path:Fo(w.path):f,Ie=qw(_e,pe);if(Ie){U(null);try{const Ue=await e.createFileEntry({rootToken:c.rootToken,path:Ie,kind:$});x(Ue.entry),await R(pe)}catch(Ue){if(await J(Ue))return;U(Hr(Ue))}}}async function Ae(){if(!c||!w)return;const $=window.prompt("Move selected entry",w.path),Te=qw($,"");if(!Te||Te===w.path)return;const _e=Fo(w.path),pe=Fo(Te);U(null);try{const Ie=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:Te});x(Ie.entry),g(Ie.entry.kind==="directory"?Ie.entry.path:Fo(Ie.entry.path)),Pe(),await R(_e),pe!==_e&&await R(pe)}catch(Ie){if(await J(Ie))return;U(Hr(Ie))}}async function We(){if(!c||!w)return;const $=w.path,Te=Fo($);U(null);try{const _e=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),pe=_e.descendantCount>0?` and ${_e.descendantCount} nested item${_e.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${_e.path}${pe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:_e.previewToken}),x(null),g(Te),C(Ie=>{const Ue=new Set(Ie);for(const Ke of Ie)(Ke===$||Ke.startsWith(`${$}/`))&&Ue.delete(Ke);return Ue}),Pe(),await R(Te)}catch(_e){if(await J(_e))return;U(Hr(_e))}}function Pe(){te.current+=1,He(),O({type:"empty"})}function He(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function fe(){return te.current+=1,te.current}function D($){return P.current&&$===te.current}async function J($,Te){return LN($)?(Te!==void 0&&!D(Te)||await Y(ee),!0):!1}function Ce($,Te){const _e=kg($),pe=$.kind==="directory"&&b.has($.path),Ie=p[$.path]??[],Ue={"--file-tree-depth":Te};return h.jsxs(jt.Fragment,{children:[h.jsxs("button",{type:"button",className:"file-entry-button","data-kind":$.kind,"data-expanded":pe,"data-active":Z===$.path,disabled:!_e,style:Ue,"aria-expanded":$.kind==="directory"?pe:void 0,"aria-label":`${$.kind==="directory"?"Open folder":"Open file"} ${$.name}`,title:$.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{xe($)},onDoubleClick:()=>{N($)},onKeyDown:Ke=>de(Ke,$),children:[h.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:$.kind==="directory"?pe?"▾":"▸":""}),h.jsx("span",{className:"file-entry-name",children:$.name}),h.jsx("small",{children:MN($)})]}),pe?h.jsx("div",{className:"file-tree-children",role:"group",children:Ie.map(Ke=>Ce(Ke,Te+1))}):null]},$.path)}const Ee=p[""]??[];return h.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[h.jsxs("header",{className:"file-explorer-header",children:[h.jsx("div",{className:"file-explorer-path",title:V,children:V||"No active pane"}),h.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[h.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{I()},children:"↻"}),h.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Le("file")},children:"+"}),h.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Le("directory")},children:"▣"})]})]}),F?h.jsx("div",{className:"file-explorer-alert",role:"alert",children:F}):null,h.jsxs("div",{className:"file-explorer-layout",children:[h.jsx("div",{className:"file-tree","aria-label":V?`Files in ${V}`:"Files",children:Ee.map($=>Ce($,0))}),h.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[h.jsxs("div",{className:"file-detail-header",children:[h.jsx("strong",{children:w?.name??"detail"}),h.jsxs("div",{className:"file-detail-actions",children:[h.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Ae()},children:"Move"}),h.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{We()},children:"Delete"})]})]}),A==="loading"?h.jsx("div",{className:"file-detail-empty",children:"loading"}):null,M.type==="empty"&&A!=="loading"?h.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,M.type==="preview"?h.jsxs("div",{className:"file-preview-frame",children:[M.previewKind==="image"?h.jsx("img",{src:M.url,alt:M.file.name}):null,M.previewKind==="pdf"?h.jsx("iframe",{src:M.url,title:M.file.name}):null]}):null,M.type==="text-preview"&&M.read.language==="markdown"?h.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${M.file.name}`,children:h.jsx(v.Suspense,{fallback:h.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:h.jsx(DN,{content:M.read.content})})}):null,M.type==="text-preview"&&M.read.language==="text"?h.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${M.file.name}`,children:M.read.content}):null]})]})]})}function kg(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function MN(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Ww(e,t){return`${e}\0${t??""}`}function NN(e){return`workspace\0${e}`}function AN(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 Fo(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function qw(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 Hr(e){return e instanceof Error?e.message:"Request failed"}function LN(e){return e instanceof dn&&e.status===409&&e.message==="terminal_cwd_changed"}const ON=v.lazy(()=>Mb(()=>import("./MarkdownPreview-mvGPeEQn.js"),__vite__mapDeps([0,1])));function Vw({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,f]=v.useState(t.read.content),[g,p]=v.useState("idle"),[_,b]=v.useState(null),[C,w]=v.useState(!1),[x,M]=v.useState("edit"),O=v.useRef(t),A=v.useRef(t.read),W=v.useRef(t.read.content),F=v.useRef(!1),U=v.useRef(!1),q=v.useRef(0),ae=u!==o.content&&g!=="saving"&&!C;v.useEffect(()=>(U.current=!0,()=>{U.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,F.current=!1,O.current=t,A.current=t.read,W.current=t.read.content,c(t.read),f(t.read.content),p("idle"),b(null),w(!1),M("edit")},[t.id,t.read]),v.useEffect(()=>{O.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{W.current=u},[u]),v.useEffect(()=>{if(u===o.content||C)return;const ee=window.setInterval(()=>{!F.current&&W.current!==A.current.content&&P()},1e3);return()=>window.clearInterval(ee)},[u===o.content,C,t.id]);async function P(){if(F.current)return;const ee=W.current,V=A.current;if(ee===V.content)return;const Z=O.current,Y=q.current;F.current=!0,p("saving"),b(null),w(!1);try{const ie=await e.writeFile({rootToken:Z.rootToken,path:Z.path,content:ee,expectedVersion:V.version});if(!U.current||Y!==q.current)return;const B={...V,content:ee,version:ie.version};A.current=B,c(B),p(W.current===ee?"saved":"idle")}catch(ie){if(!U.current||Y!==q.current)return;if(ie instanceof dn&&ie.status===409){w(!0),p("idle");return}b(BN(ie)),p("idle")}finally{Y===q.current&&(F.current=!1)}}const te=g==="saving"?"saving":g==="saved"?"saved":o.language,G=o.language==="markdown",ge=G&&x==="preview";return h.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[h.jsxs("header",{className:"editor-pane-header",children:[h.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),h.jsx("strong",{children:t.title}),h.jsx("span",{className:"terminal-pane-spacer"}),h.jsx("span",{className:"terminal-pane-state",children:te}),h.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ae,onClick:()=>{P()},children:"Save"}),G?h.jsx("button",{type:"button","aria-label":`${ge?"Edit":"Preview"} ${t.title}`,onClick:()=>M(ee=>ee==="preview"?"edit":"preview"),children:ge?"Edit":"Preview"}):null,n?h.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),_?h.jsx("div",{className:"editor-pane-alert",role:"alert",children:_}):null,C?h.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ge?h.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:h.jsx(v.Suspense,{fallback:h.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:h.jsx(ON,{content:u})})}):h.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ee=>{const V=ee.target.value;W.current=V,f(V),p("idle"),b(null),w(!1)}})]})}function BN(e){return e instanceof Error?e.message:"Request failed"}var jN=2,IN=1,PN=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,p=r-f,_=o-g-t;return{cols:Math.max(jN,Math.floor(_/e.css.cell.width)),rows:Math.max(IN,Math.floor(p/e.css.cell.height))}}};var Gx=Object.defineProperty,zN=Object.getOwnPropertyDescriptor,HN=(e,t)=>{for(var n in t)Gx(e,n,{get:t[n],enumerable:!0})},Si=(e,t,n,r)=>{for(var o=r>1?void 0:r?zN(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&&Gx(t,n,o),o},ze=(e,t)=>(n,r)=>t(n,r,e),Yw="Terminal input",Ov={get:()=>Yw,set:e=>Yw=e},Xw="Too much output to announce, navigate to rows manually to read",Bv={get:()=>Xw,set:e=>Xw=e};function UN(e){return e.replace(/\r?\n/g,"\r")}function FN(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function KN(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function $N(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Zx(o,t,n,r)}}function Zx(e,t,n,r){e=UN(e),e=FN(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Qx(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 Gw(e,t,n,r,o){Qx(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Wa(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function np(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 WN=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}},qN=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,p=0;if(this.interim[0]){let C=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,M;for(;(M=this.interim[++x]&63)&&x<4;)w<<=6,w|=M;let O=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=O-x;for(;p<A;){if(p>=n)return 0;if(M=e[p++],(M&192)!==128){p--,C=!0;break}else this.interim[x++]=M,w<<=6,w|=M&63}C||(O===2?w<128?p--:t[r++]=w:O===3?w<2048||w>=55296&&w<=57343||w===65279||(t[r++]=w):w<65536||w>1114111||(t[r++]=w)),this.interim.fill(0)}let _=n-4,b=p;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}},Jx="",Ya=" ",hd=class ek{constructor(){this.fg=0,this.bg=0,this.extended=new Cf}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 ek;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}},Cf=class tk{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 tk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ss=class ik extends hd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Cf,this.combinedData=""}static fromCharData(t){let n=new ik;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?Wa(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()]}},Zw="di$target",jv="di$dependencies",Tg=new Map;function VN(e){return e[jv]||[]}function tn(e){if(Tg.has(e))return Tg.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");YN(t,n,o)};return t._id=e,Tg.set(e,t),t}function YN(e,t,n){t[Zw]===t?t[jv].push({id:e,index:n}):(t[jv]=[{id:e,index:n}],t[Zw]=t)}var En=tn("BufferService"),nk=tn("CoreMouseService"),sl=tn("CoreService"),XN=tn("CharsetService"),Nb=tn("InstantiationService"),sk=tn("LogService"),Dn=tn("OptionsService"),rk=tn("OscLinkService"),GN=tn("UnicodeService"),fd=tn("DecorationService"),Iv=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 Ss,u=n.getTrimmedLength(),f=-1,g=-1,p=!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 p=c.extended.urlId!==f;else g!==-1&&(p=!0);if(p||g!==-1&&_===u-1){let b=this._oscLinkService.getLinkData(f)?.uri;if(b){let C={start:{x:g+1,y:e},end:{x:_+(!p&&_===u-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||r.push({text:b,range:C,activate:(x,M)=>o?o.activate(x,M,C):ZN(x,M),hover:(x,M)=>o?.hover?.(x,M,C),leave:(x,M)=>o?.leave?.(x,M,C)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=_,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};Iv=Si([ze(0,En),ze(1,Dn),ze(2,rk)],Iv);function ZN(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 sp=tn("CharSizeService"),Zr=tn("CoreBrowserService"),Ab=tn("MouseService"),Qr=tn("RenderService"),QN=tn("SelectionService"),ak=tn("CharacterJoinerService"),pc=tn("ThemeService"),ok=tn("LinkProviderService"),JN=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Qw.isErrorNoTelemetry(e)?new Qw(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)}},eA=new JN;function Zh(e){tA(e)||eA.onUnexpectedError(e)}var Pv="Canceled";function tA(e){return e instanceof iA?!0:e instanceof Error&&e.name===Pv&&e.message===Pv}var iA=class extends Error{constructor(){super(Pv),this.name=this.message}};function nA(e){return new Error(`Illegal argument: ${e}`)}var Qw=class zv extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof zv)return t;let n=new zv;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Hv=class lk extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,lk.prototype)}};function Kn(e,t=0){return e[e.length-(1+t)]}var sA;(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})(sA||={});function rA(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var ck;(e=>{function t(U){return U&&typeof U=="object"&&typeof U[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(U){yield U}e.single=o;function c(U){return t(U)?U:o(U)}e.wrap=c;function u(U){return U||n}e.from=u;function*f(U){for(let q=U.length-1;q>=0;q--)yield U[q]}e.reverse=f;function g(U){return!U||U[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(U){return U[Symbol.iterator]().next().value}e.first=p;function _(U,q){let ae=0;for(let P of U)if(q(P,ae++))return!0;return!1}e.some=_;function b(U,q){for(let ae of U)if(q(ae))return ae}e.find=b;function*C(U,q){for(let ae of U)q(ae)&&(yield ae)}e.filter=C;function*w(U,q){let ae=0;for(let P of U)yield q(P,ae++)}e.map=w;function*x(U,q){let ae=0;for(let P of U)yield*q(P,ae++)}e.flatMap=x;function*M(...U){for(let q of U)yield*q}e.concat=M;function O(U,q,ae){let P=ae;for(let te of U)P=q(P,te);return P}e.reduce=O;function*A(U,q,ae=U.length){for(q<0&&(q+=U.length),ae<0?ae+=U.length:ae>U.length&&(ae=U.length);q<ae;q++)yield U[q]}e.slice=A;function W(U,q=Number.POSITIVE_INFINITY){let ae=[];if(q===0)return[ae,U];let P=U[Symbol.iterator]();for(let te=0;te<q;te++){let G=P.next();if(G.done)return[ae,e.empty()];ae.push(G.value)}return[ae,{[Symbol.iterator](){return P}}]}e.consume=W;async function F(U){let q=[];for await(let ae of U)q.push(ae);return Promise.resolve(q)}e.asyncToArray=F})(ck||={});function el(e){if(ck.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 aA(...e){return hi(()=>el(e))}function hi(e){return{dispose:rA(()=>{e()})}}var uk=class dk{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{el(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?dk.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)}};uk.DISABLE_DISPOSED_WARNING=!1;var Ga=uk,yt=class{constructor(){this._store=new Ga,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 ac=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,Uv=class Fv{constructor(t){this.element=t,this.next=Fv.Undefined,this.prev=Fv.Undefined}};Uv.Undefined=new Uv(void 0);var pi=Uv,Jw=class{constructor(){this._first=pi.Undefined,this._last=pi.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===pi.Undefined}clear(){let e=this._first;for(;e!==pi.Undefined;){let t=e.next;e.prev=pi.Undefined,e.next=pi.Undefined,e=t}this._first=pi.Undefined,this._last=pi.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new pi(e);if(this._first===pi.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!==pi.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==pi.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==pi.Undefined&&e.next!==pi.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===pi.Undefined&&e.next===pi.Undefined?(this._first=pi.Undefined,this._last=pi.Undefined):e.next===pi.Undefined?(this._last=this._last.prev,this._last.next=pi.Undefined):e.prev===pi.Undefined&&(this._first=this._first.next,this._first.prev=pi.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==pi.Undefined;)yield e.element,e=e.next}},oA=globalThis.performance&&typeof globalThis.performance.now=="function",lA=class hk{static create(t){return new hk(t)}constructor(t){this._now=oA&&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}},hn;(e=>{e.None=()=>yt.None;function t(V,Z){return b(V,()=>{},0,void 0,!0,void 0,Z)}e.defer=t;function n(V){return(Z,Y=null,ie)=>{let B=!1,R;return R=V(I=>{if(!B)return R?R.dispose():B=!0,Z.call(Y,I)},null,ie),B&&R.dispose(),R}}e.once=n;function r(V,Z,Y){return p((ie,B=null,R)=>V(I=>ie.call(B,Z(I)),null,R),Y)}e.map=r;function o(V,Z,Y){return p((ie,B=null,R)=>V(I=>{Z(I),ie.call(B,I)},null,R),Y)}e.forEach=o;function c(V,Z,Y){return p((ie,B=null,R)=>V(I=>Z(I)&&ie.call(B,I),null,R),Y)}e.filter=c;function u(V){return V}e.signal=u;function f(...V){return(Z,Y=null,ie)=>{let B=aA(...V.map(R=>R(I=>Z.call(Y,I))));return _(B,ie)}}e.any=f;function g(V,Z,Y,ie){let B=Y;return r(V,R=>(B=Z(B,R),B),ie)}e.reduce=g;function p(V,Z){let Y,ie={onWillAddFirstListener(){Y=V(B.fire,B)},onDidRemoveLastListener(){Y?.dispose()}},B=new Oe(ie);return Z?.add(B),B.event}function _(V,Z){return Z instanceof Array?Z.push(V):Z&&Z.add(V),V}function b(V,Z,Y=100,ie=!1,B=!1,R,I){let ue,xe,N,K=0,de,ke={leakWarningThreshold:R,onWillAddFirstListener(){ue=V(Re=>{K++,xe=Z(xe,Re),ie&&!N&&(Ne.fire(xe),xe=void 0),de=()=>{let Le=xe;xe=void 0,N=void 0,(!ie||K>1)&&Ne.fire(Le),K=0},typeof Y=="number"?(clearTimeout(N),N=setTimeout(de,Y)):N===void 0&&(N=0,queueMicrotask(de))})},onWillRemoveListener(){B&&K>0&&de?.()},onDidRemoveLastListener(){de=void 0,ue.dispose()}},Ne=new Oe(ke);return I?.add(Ne),Ne.event}e.debounce=b;function C(V,Z=0,Y){return e.debounce(V,(ie,B)=>ie?(ie.push(B),ie):[B],Z,void 0,!0,void 0,Y)}e.accumulate=C;function w(V,Z=(ie,B)=>ie===B,Y){let ie=!0,B;return c(V,R=>{let I=ie||!Z(R,B);return ie=!1,B=R,I},Y)}e.latch=w;function x(V,Z,Y){return[e.filter(V,Z,Y),e.filter(V,ie=>!Z(ie),Y)]}e.split=x;function M(V,Z=!1,Y=[],ie){let B=Y.slice(),R=V(xe=>{B?B.push(xe):ue.fire(xe)});ie&&ie.add(R);let I=()=>{B?.forEach(xe=>ue.fire(xe)),B=null},ue=new Oe({onWillAddFirstListener(){R||(R=V(xe=>ue.fire(xe)),ie&&ie.add(R))},onDidAddFirstListener(){B&&(Z?setTimeout(I):I())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return ie&&ie.add(ue),ue.event}e.buffer=M;function O(V,Z){return(Y,ie,B)=>{let R=Z(new W);return V(function(I){let ue=R.evaluate(I);ue!==A&&Y.call(ie,ue)},void 0,B)}}e.chain=O;let A=Symbol("HaltChainable");class W{constructor(){this.steps=[]}map(Z){return this.steps.push(Z),this}forEach(Z){return this.steps.push(Y=>(Z(Y),Y)),this}filter(Z){return this.steps.push(Y=>Z(Y)?Y:A),this}reduce(Z,Y){let ie=Y;return this.steps.push(B=>(ie=Z(ie,B),ie)),this}latch(Z=(Y,ie)=>Y===ie){let Y=!0,ie;return this.steps.push(B=>{let R=Y||!Z(B,ie);return Y=!1,ie=B,R?B:A}),this}evaluate(Z){for(let Y of this.steps)if(Z=Y(Z),Z===A)break;return Z}}function F(V,Z,Y=ie=>ie){let ie=(...ue)=>I.fire(Y(...ue)),B=()=>V.on(Z,ie),R=()=>V.removeListener(Z,ie),I=new Oe({onWillAddFirstListener:B,onDidRemoveLastListener:R});return I.event}e.fromNodeEventEmitter=F;function U(V,Z,Y=ie=>ie){let ie=(...ue)=>I.fire(Y(...ue)),B=()=>V.addEventListener(Z,ie),R=()=>V.removeEventListener(Z,ie),I=new Oe({onWillAddFirstListener:B,onDidRemoveLastListener:R});return I.event}e.fromDOMEventEmitter=U;function q(V){return new Promise(Z=>n(V)(Z))}e.toPromise=q;function ae(V){let Z=new Oe;return V.then(Y=>{Z.fire(Y)},()=>{Z.fire(void 0)}).finally(()=>{Z.dispose()}),Z.event}e.fromPromise=ae;function P(V,Z){return V(Y=>Z.fire(Y))}e.forward=P;function te(V,Z,Y){return Z(Y),V(ie=>Z(ie))}e.runAndSubscribe=te;class G{constructor(Z,Y){this._observable=Z,this._counter=0,this._hasChanged=!1;let ie={onWillAddFirstListener:()=>{Z.addObserver(this)},onDidRemoveLastListener:()=>{Z.removeObserver(this)}};this.emitter=new Oe(ie),Y&&Y.add(this.emitter)}beginUpdate(Z){this._counter++}handlePossibleChange(Z){}handleChange(Z,Y){this._hasChanged=!0}endUpdate(Z){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ge(V,Z){return new G(V,Z).emitter.event}e.fromObservable=ge;function ee(V){return(Z,Y,ie)=>{let B=0,R=!1,I={beginUpdate(){B++},endUpdate(){B--,B===0&&(V.reportChanges(),R&&(R=!1,Z.call(Y)))},handlePossibleChange(){},handleChange(){R=!0}};V.addObserver(I),V.reportChanges();let ue={dispose(){V.removeObserver(I)}};return ie instanceof Ga?ie.add(ue):Array.isArray(ie)&&ie.push(ue),ue}}e.fromObservableLight=ee})(hn||={});var Kv=class $v{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${$v._idPool++}`,$v.all.add(this)}start(t){this._stopWatch=new lA,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}}};Kv.all=new Set,Kv._idPool=0;var cA=Kv,uA=-1,fk=class pk{constructor(t,n,r=(pk._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 fA(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}};fk._idPool=1;var dA=fk,hA=class mk{constructor(t){this.value=t}static create(){let t=new Error;return new mk(t.stack??"")}print(){console.warn(this.value.split(`
22
- `).slice(2).join(`
23
- `))}},fA=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},pA=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},mA=0,Eg=class{constructor(e){this.value=e,this.id=mA++}},gA=2,vA,Oe=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new dA(e?.onListenerError??Zh,this._options?.leakWarningThreshold??uA):void 0,this._perfMon=this._options?._profName?new cA(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 pA(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||Zh)(g),yt.None}if(this._disposed)return yt.None;t&&(e=e.bind(t));let r=new Eg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=hA.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Eg?(this._deliveryQueue??=new _A,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=hi(()=>{o?.(),this._removeListener(r)});return n instanceof Ga?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*gA<=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||Zh;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 Eg)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}},_A=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}},Wv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Oe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Oe,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}};Wv.INSTANCE=new Wv;var Lb=Wv;function bA(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Lb.INSTANCE.onDidChangeZoomLevel;function yA(e){return Lb.INSTANCE.getZoomFactor(e)}Lb.INSTANCE.onDidChangeFullscreen;var mc=typeof navigator=="object"?navigator.userAgent:"",qv=mc.indexOf("Firefox")>=0,SA=mc.indexOf("AppleWebKit")>=0,Ob=mc.indexOf("Chrome")>=0,wA=!Ob&&mc.indexOf("Safari")>=0;mc.indexOf("Electron/")>=0;mc.indexOf("Android")>=0;var Dg=!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)");Dg=e.matches,bA(qr,e,({matches:n})=>{Dg&&t.matches||(Dg=n)})}var Yl="en",Vv=!1,Yv=!1,Qh=!1,gk=!1,Ah,Jh=Yl,e1=Yl,CA,Fr,Xo=globalThis,qn;typeof Xo.vscode<"u"&&typeof Xo.vscode.process<"u"?qn=Xo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(qn=process);var xA=typeof qn?.versions?.electron=="string",kA=xA&&qn?.type==="renderer";if(typeof qn=="object"){Vv=qn.platform==="win32",Yv=qn.platform==="darwin",Qh=qn.platform==="linux",Qh&&qn.env.SNAP&&qn.env.SNAP_REVISION,qn.env.CI||qn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ah=Yl,Jh=Yl;let e=qn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ah=t.userLocale,e1=t.osLocale,Jh=t.resolvedLanguage||Yl,CA=t.languagePack?.translationsConfigFile}catch{}gk=!0}else typeof navigator=="object"&&!kA?(Fr=navigator.userAgent,Vv=Fr.indexOf("Windows")>=0,Yv=Fr.indexOf("Macintosh")>=0,(Fr.indexOf("Macintosh")>=0||Fr.indexOf("iPad")>=0||Fr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Qh=Fr.indexOf("Linux")>=0,Fr?.indexOf("Mobi")>=0,Jh=globalThis._VSCODE_NLS_LANGUAGE||Yl,Ah=navigator.language.toLowerCase(),e1=Ah):console.error("Unable to resolve platform.");var vk=Vv,dr=Yv,TA=Qh,t1=gk,fr=Fr,Ia=Jh,EA;(e=>{function t(){return Ia}e.value=t;function n(){return Ia.length===2?Ia==="en":Ia.length>=3?Ia[0]==="e"&&Ia[1]==="n"&&Ia[2]==="-":!1}e.isDefaultVariant=n;function r(){return Ia==="en"}e.isDefault=r})(EA||={});var DA=typeof Xo.postMessage=="function"&&!Xo.importScripts;(()=>{if(DA){let e=[];Xo.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}),Xo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var RA=!!(fr&&fr.indexOf("Chrome")>=0);fr&&fr.indexOf("Firefox")>=0;!RA&&fr&&fr.indexOf("Safari")>=0;fr&&fr.indexOf("Edg/")>=0;fr&&fr.indexOf("Android")>=0;var Hl=typeof navigator=="object"?navigator:{};t1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Hl&&Hl.clipboard&&Hl.clipboard.writeText,t1||Hl&&Hl.clipboard&&Hl.clipboard.readText;var Bb=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}},Rg=new Bb,i1=new Bb,n1=new Bb,MA=new Array(230),_k;(e=>{function t(f){return Rg.keyCodeToStr(f)}e.toString=t;function n(f){return Rg.strToKeyCode(f)}e.fromString=n;function r(f){return i1.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return n1.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return i1.strToKeyCode(f)||n1.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 Rg.keyCodeToStr(f)}e.toElectronAccelerator=u})(_k||={});var NA=class bk{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 bk&&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 AA([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},AA=class{constructor(e){if(e.length===0)throw nA("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 LA(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return _k.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(qv)switch(t){case 59:return 85;case 60:if(TA)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(dr)return 57;break}else if(SA&&(dr&&t===93||!dr&&t===92))return 57;return MA[t]||0}var OA=dr?256:2048,BA=512,jA=1024,IA=dr?2048:256,s1=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=LA(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|=OA),this.altKey&&(t|=BA),this.shiftKey&&(t|=jA),this.metaKey&&(t|=IA),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new NA(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},r1=new WeakMap;function PA(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 zA=class{static getSameOriginWindowChain(e){let t=r1.get(e);if(!t){t=[],r1.set(e,t);let n=e,r;do r=PA(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}}},Lh=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=zA.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},a1=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(Ob){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&&!dr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")wA&&vk?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&&!dr?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()}},yk=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),HA;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof UA?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:yk})})(HA||={});var UA=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?yk:(this._emitter||(this._emitter=new Oe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},jb=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 Hv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Hv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},FA=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 Hv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=hi(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},KA;(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})(KA||={});var o1=class gs{static fromArray(t){return new gs(n=>{n.emitMany(t)})}static fromPromise(t){return new gs(async n=>{n.emitMany(await t)})}static fromPromises(t){return new gs(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new gs(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 Oe,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 hn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new gs(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return gs.map(this,t)}static filter(t,n){return new gs(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return gs.filter(this,t)}static coalesce(t){return gs.filter(t,n=>!!n)}coalesce(){return gs.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return gs.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())}};o1.EMPTY=o1.fromArray([]);var{getWindow:ur,getWindowId:$A,onDidRegisterWindow:WA}=(function(){let e=new Map,t={window:qr,disposables:new Ga};e.set(qr.vscodeWindowId,t);let n=new Oe,r=new Oe,o=new Oe;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 Ga,g={window:u,disposables:f.add(new Ga)};return e.set(u.vscodeWindowId,g),f.add(hi(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),f.add(st(u,Gi.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 ur(u).document}}})(),qA=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 st(e,t,n,r){return new qA(e,t,n,r)}var l1=function(e,t,n,r){return st(e,t,n,r)},Ib,VA=class extends FA{constructor(e){super(),this.defaultTarget=e&&ur(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},c1=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){Zh(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(c1.sort),u.shift().execute();r.set(c,!1)};Ib=(c,u,f=0)=>{let g=$A(c),p=new c1(u,f),_=e.get(g);return _||(_=[],e.set(g,_)),_.push(p),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function YA(e){let t=e.getBoundingClientRect(),n=ur(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Gi={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"},XA=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=jn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=jn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=jn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=jn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=jn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=jn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=jn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=jn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=jn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=jn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=jn(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=jn(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=jn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=jn(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 jn(e){return typeof e=="number"?`${e}px`:e}function Pu(e){return new XA(e)}var Sk=class{constructor(){this._hooks=new Ga,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(hi(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=ur(e)}this._hooks.add(st(c,Gi.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(st(c,Gi.POINTER_UP,u=>this.stopMonitoring(!0)))}};function GA(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 lr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(lr||={});var Cu=class gn extends yt{constructor(){super(),this.dispatched=!1,this.targets=new Jw,this.ignoreTargets=new Jw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(hn.runAndSubscribe(WA,({window:t,disposables:n})=>{n.add(st(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(st(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(st(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:qr,disposables:this._store}))}static addTarget(t){if(!gn.isTouchDevice())return yt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.targets.push(t);return hi(n)}static ignoreTarget(t){if(!gn.isTouchDevice())return yt.None;gn.INSTANCE||(gn.INSTANCE=new gn);let n=gn.INSTANCE.ignoreTargets.push(t);return hi(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(lr.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],p=Date.now()-g.initialTimeStamp;if(p<gn.HOLD_DELAY&&Math.abs(g.initialPageX-Kn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Kn(g.rollingPageY))<30){let _=this.newGestureEvent(lr.Tap,g.initialTarget);_.pageX=Kn(g.rollingPageX),_.pageY=Kn(g.rollingPageY),this.dispatchEvent(_)}else if(p>=gn.HOLD_DELAY&&Math.abs(g.initialPageX-Kn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Kn(g.rollingPageY))<30){let _=this.newGestureEvent(lr.Contextmenu,g.initialTarget);_.pageX=Kn(g.rollingPageX),_.pageY=Kn(g.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=Kn(g.rollingPageX),b=Kn(g.rollingPageY),C=Kn(g.rollingTimestamps)-g.rollingTimestamps[0],w=_-g.rollingPageX[0],x=b-g.rollingPageY[0],M=[...this.targets].filter(O=>g.initialTarget instanceof Node&&O.contains(g.initialTarget));this.inertia(t,M,r,Math.abs(w)/C,w>0?1:-1,_,Math.abs(x)/C,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(lr.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===lr.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>gn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===lr.Change||t.type===lr.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,p){this.handle=Ib(t,()=>{let _=Date.now(),b=_-r,C=0,w=0,x=!0;o+=gn.SCROLL_FRICTION*b,f+=gn.SCROLL_FRICTION*b,o>0&&(x=!1,C=c*o*b),f>0&&(x=!1,w=g*f*b);let M=this.newGestureEvent(lr.Change);M.translationX=C,M.translationY=w,n.forEach(O=>O.dispatchEvent(M)),x||this.inertia(t,n,_,o,c,u+C,f,g,p+w)})}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(lr.Change,u.initialTarget);f.translationX=c.pageX-Kn(u.rollingPageX),f.translationY=c.pageY-Kn(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)}};Cu.SCROLL_FRICTION=-.005,Cu.HOLD_DELAY=700,Cu.CLEAR_TAP_COUNT_TIME=400,Si([GA],Cu,"isTouchDevice",1);var ZA=Cu,Pb=class extends yt{onclick(e,t){this._register(st(e,Gi.CLICK,n=>t(new Lh(ur(e),n))))}onmousedown(e,t){this._register(st(e,Gi.MOUSE_DOWN,n=>t(new Lh(ur(e),n))))}onmouseover(e,t){this._register(st(e,Gi.MOUSE_OVER,n=>t(new Lh(ur(e),n))))}onmouseleave(e,t){this._register(st(e,Gi.MOUSE_LEAVE,n=>t(new Lh(ur(e),n))))}onkeydown(e,t){this._register(st(e,Gi.KEY_DOWN,n=>t(new s1(n))))}onkeyup(e,t){this._register(st(e,Gi.KEY_UP,n=>t(new s1(n))))}oninput(e,t){this._register(st(e,Gi.INPUT,t))}onblur(e,t){this._register(st(e,Gi.BLUR,t))}onfocus(e,t){this._register(st(e,Gi.FOCUS,t))}onchange(e,t){this._register(st(e,Gi.CHANGE,t))}ignoreGesture(e){return ZA.ignoreTarget(e)}},u1=11,QA=class extends Pb{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=u1+"px",this.domNode.style.height=u1+"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 Sk),this._register(l1(this.bgDomNode,Gi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(l1(this.domNode,Gi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new VA),this._pointerdownScheduleRepeatTimer=this._register(new jb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ur(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()}},JA=class Xv{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 Xv(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 Xv(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}}},eL=class extends yt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new JA(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 h1(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=h1.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)))}},d1=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Mg(e,t){let n=t-e;return function(r){return e+n*nL(r)}}function tL(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var h1=class Gv{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),tL(Mg(t,o),Mg(c,n),.33)}return Mg(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 d1(r,o,!1)}return new d1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Gv.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new Gv(t,n,o,r)}};function iL(e){return Math.pow(e,3)}function nL(e){return 1-iL(1-e)}var sL=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 jb)}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":"")))}},rL=140,wk=class extends Pb{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 sL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Sk),this._shouldRender=!0,this.domNode=Pu(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(st(this.domNode.domNode,Gi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new QA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Pu(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(st(this.slider.domNode,Gi.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=YA(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(vk&&u>rL){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()}},Ck=class Zv{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 Zv(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 p=Math.round(Math.max(20,Math.floor(r*f/o))),_=(f-p)/(o-r),b=c*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:_,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Zv._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)}},aL=class extends wk{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Ck(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}},oL=class extends wk{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Ck(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}},lL=500,f1=50,cL=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Qv=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(Ob){let n=ur(t.browserEvent),r=yA(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 cL(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),p=Math.max(Math.min(c,f),1),_=Math.max(o,u),b=Math.max(c,f);_%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Qv.INSTANCE=new Qv;var uL=Qv,dL=class extends Pb{constructor(e,t,n){super(),this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Oe),this.onWillScroll=this._onWillScroll.event,this._options=fL(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 oL(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new aL(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=Pu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Pu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Pu(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 jb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=el(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,dr&&(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 a1(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=el(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new a1(n))};this._mouseWheelToDispose.push(st(this._listenOnDomNode,Gi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=uL.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=!dr&&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 p=f1*o,_=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,_)}if(c){let p=f1*c,_=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));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(),lL)}},hL=class extends dL{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 fL(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,dr&&(t.className+=" mac"),t}var Jv=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 Oe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new eL({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Ib(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hL(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(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(hn.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(hi(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(hi(()=>this._styleElement.remove())),this._register(hn.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(p=>this._handleScroll(p)))}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}};Jv=Si([ze(2,En),ze(3,Zr),ze(4,nk),ze(5,pc),ze(6,Dn),ze(7,Qr)],Jv);var e_=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(hi(()=>{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()}};e_=Si([ze(1,En),ze(2,Zr),ze(3,fd),ze(4,Qr)],e_);var pL=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)}},ar={full:0,left:0,center:0,right:0},Pa={full:0,left:0,center:0,right:0},du={full:0,left:0,center:0,right:0},xf=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 pL,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(hi(()=>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);Pa.full=this._canvas.width,Pa.left=e,Pa.center=t,Pa.right=e,this._refreshDrawHeightConstants(),du.full=1,du.left=1,du.center=1+Pa.left,du.right=1+Pa.left+Pa.center}_refreshDrawHeightConstants(){ar.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);ar.left=t,ar.center=t,ar.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ar.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ar.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ar.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ar.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(du[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ar[e.position||"full"]/2),Pa[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ar[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}))}};xf=Si([ze(2,En),ze(3,fd),ze(4,Qr),ze(5,Dn),ze(6,pc),ze(7,Zr)],xf);var we;(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=""))(we||={});var ef;(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="Ÿ"))(ef||={});var xk;(e=>e.ST=`${we.ESC}\\`)(xk||={});var t_=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(`${we.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)}}};t_=Si([ze(2,En),ze(3,Dn),ze(4,sl),ze(5,Qr)],t_);var Qi=0,Ji=0,en=0,yi=0,p1={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 oi;(e=>{function t(g,p){if(yi=(p.rgba&255)/255,yi===1)return{css:p.css,rgba:p.rgba};let _=p.rgba>>24&255,b=p.rgba>>16&255,C=p.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,M=g.rgba>>8&255;Qi=w+Math.round((_-w)*yi),Ji=x+Math.round((b-x)*yi),en=M+Math.round((C-M)*yi);let O=ji.toCss(Qi,Ji,en),A=ji.toRgba(Qi,Ji,en);return{css:O,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,_){let b=tf.ensureContrastRatio(g.rgba,p.rgba,_);if(b)return ji.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Qi,Ji,en]=tf.toChannels(p),{css:ji.toCss(Qi,Ji,en),rgba:p}}e.opaque=o;function c(g,p){return yi=Math.round(p*255),[Qi,Ji,en]=tf.toChannels(g.rgba),{css:ji.toCss(Qi,Ji,en,yi),rgba:ji.toRgba(Qi,Ji,en,yi)}}e.opacity=c;function u(g,p){return yi=g.rgba&255,c(g,yi*p/255)}e.multiplyOpacity=u;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(oi||={});var mi;(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 Qi=parseInt(o.slice(1,2).repeat(2),16),Ji=parseInt(o.slice(2,3).repeat(2),16),en=parseInt(o.slice(3,4).repeat(2),16),ji.toColor(Qi,Ji,en);case 5:return Qi=parseInt(o.slice(1,2).repeat(2),16),Ji=parseInt(o.slice(2,3).repeat(2),16),en=parseInt(o.slice(3,4).repeat(2),16),yi=parseInt(o.slice(4,5).repeat(2),16),ji.toColor(Qi,Ji,en,yi);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 Qi=parseInt(c[1]),Ji=parseInt(c[2]),en=parseInt(c[3]),yi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),ji.toColor(Qi,Ji,en,yi);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),[Qi,Ji,en,yi]=t.getImageData(0,0,1,1).data,yi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ji.toRgba(Qi,Ji,en,yi),css:o}}e.toColor=r})(mi||={});var kn;(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,p=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 p*.2126+_*.7152+b*.0722}e.relativeLuminance2=n})(kn||={});var tf;(e=>{function t(u,f){if(yi=(f&255)/255,yi===1)return f;let g=f>>24&255,p=f>>16&255,_=f>>8&255,b=u>>24&255,C=u>>16&255,w=u>>8&255;return Qi=b+Math.round((g-b)*yi),Ji=C+Math.round((p-C)*yi),en=w+Math.round((_-w)*yi),ji.toRgba(Qi,Ji,en)}e.blend=t;function n(u,f,g){let p=kn.relativeLuminance(u>>8),_=kn.relativeLuminance(f>>8);if(Ur(p,_)<g){if(_<p){let w=r(u,f,g),x=Ur(p,kn.relativeLuminance(w>>8));if(x<g){let M=o(u,f,g),O=Ur(p,kn.relativeLuminance(M>>8));return x>O?w:M}return w}let b=o(u,f,g),C=Ur(p,kn.relativeLuminance(b>>8));if(C<g){let w=r(u,f,g),x=Ur(p,kn.relativeLuminance(w>>8));return C>x?b:w}return b}}e.ensureContrastRatio=n;function r(u,f,g){let p=u>>24&255,_=u>>16&255,b=u>>8&255,C=f>>24&255,w=f>>16&255,x=f>>8&255,M=Ur(kn.relativeLuminance2(C,w,x),kn.relativeLuminance2(p,_,b));for(;M<g&&(C>0||w>0||x>0);)C-=Math.max(0,Math.ceil(C*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),M=Ur(kn.relativeLuminance2(C,w,x),kn.relativeLuminance2(p,_,b));return(C<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=r;function o(u,f,g){let p=u>>24&255,_=u>>16&255,b=u>>8&255,C=f>>24&255,w=f>>16&255,x=f>>8&255,M=Ur(kn.relativeLuminance2(C,w,x),kn.relativeLuminance2(p,_,b));for(;M<g&&(C<255||w<255||x<255);)C=Math.min(255,C+Math.ceil((255-C)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),M=Ur(kn.relativeLuminance2(C,w,x),kn.relativeLuminance2(p,_,b));return(C<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(tf||={});function Ko(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ur(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var mL=class extends hd{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()]}},kf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ss}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 p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(p-o>1){let _=this._getJoinedRanges(r,u,c,t,o);for(let b=0;b<_.length;b++)n.push(_[b])}o=p,u=c,f=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ya.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,u,c,t,o);for(let _=0;_<p.length;_++)n.push(p[_])}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 p=0;p<g.length;p++)kf._mergeRanges(u,g[p])}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),p=t.getString(f).length||Ya.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+=p}}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}};kf=Si([ze(0,En)],kf);function gL(e){return 57508<=e&&e<=57558}function vL(e){return 9472<=e&&e<=9631}function _L(e){return gL(e)||vL(e)}function bL(){return{css:{canvas:Oh(),cell:Oh()},device:{canvas:Oh(),cell:Oh(),char:{width:0,height:0,left:0,top:0}}}}function Oh(){return{width:0,height:0}}var i_=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 Ss,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,p,_){let b=[],C=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<c+1&&(x=c+1);let M,O=0,A="",W=0,F=0,U=0,q=0,ae=!1,P=0,te=!1,G=0,ge=0,ee=[],V=p!==-1&&_!==-1;for(let Z=0;Z<x;Z++){e.loadCell(Z,this._workCell);let Y=this._workCell.getWidth();if(Y===0)continue;let ie=!1,B=Z>=ge,R=Z,I=this._workCell;if(C.length>0&&Z===C[0][0]&&B){let D=C.shift(),J=this._isCellInSelection(D[0],t);for(W=D[0]+1;W<D[1];W++)B&&=J===this._isCellInSelection(W,t);B&&=!n||c<D[0]||c>=D[1],B?(ie=!0,I=new mL(this._workCell,e.translateToString(!0,D[0],D[1]),D[1]-D[0]),R=D[1]-1,Y=I.getWidth()):ge=D[1]}let ue=this._isCellInSelection(Z,t),xe=n&&Z===c,N=V&&Z>=p&&Z<=_,K=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,D=>{K=!0});let de=I.getChars()||Ya;if(de===" "&&(I.isUnderline()||I.isOverline())&&(de=" "),G=Y*f-g.get(de,I.isBold(),I.isItalic()),!M)M=this._document.createElement("span");else if(O&&(ue&&te||!ue&&!te&&I.bg===F)&&(ue&&te&&w.selectionForeground||I.fg===U)&&I.extended.ext===q&&N===ae&&G===P&&!xe&&!ie&&!K&&B){I.isInvisible()?A+=Ya:A+=de,O++;continue}else O&&(M.textContent=A),M=this._document.createElement("span"),O=0,A="";if(F=I.bg,U=I.fg,q=I.extended.ext,ae=N,P=G,te=ue,ie&&c>=Z&&c<=R&&(c=Z),!this._coreService.isCursorHidden&&xe&&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=Ya:A=I.getChars()||Ya,I.isUnderline()&&(ee.push(`xterm-underline-${I.extended.underlineStyle}`),A===" "&&(A=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())M.style.textDecorationColor=`rgb(${hd.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let D=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&D<8&&(D+=8),M.style.textDecorationColor=w.ansi[D].css}I.isOverline()&&(ee.push("xterm-overline"),A===" "&&(A=" ")),I.isStrikethrough()&&ee.push("xterm-strikethrough"),N&&(M.style.textDecoration="underline");let ke=I.getFgColor(),Ne=I.getFgColorMode(),Re=I.getBgColor(),Le=I.getBgColorMode(),Ae=!!I.isInverse();if(Ae){let D=ke;ke=Re,Re=D;let J=Ne;Ne=Le,Le=J}let We,Pe,He=!1;this._decorationService.forEachDecorationAtCell(Z,t,void 0,D=>{D.options.layer!=="top"&&He||(D.backgroundColorRGB&&(Le=50331648,Re=D.backgroundColorRGB.rgba>>8&16777215,We=D.backgroundColorRGB),D.foregroundColorRGB&&(Ne=50331648,ke=D.foregroundColorRGB.rgba>>8&16777215,Pe=D.foregroundColorRGB),He=D.options.layer==="top")}),!He&&ue&&(We=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Re=We.rgba>>8&16777215,Le=50331648,He=!0,w.selectionForeground&&(Ne=50331648,ke=w.selectionForeground.rgba>>8&16777215,Pe=w.selectionForeground)),He&&ee.push("xterm-decoration-top");let fe;switch(Le){case 16777216:case 33554432:fe=w.ansi[Re],ee.push(`xterm-bg-${Re}`);break;case 50331648:fe=ji.toColor(Re>>16,Re>>8&255,Re&255),this._addStyle(M,`background-color:#${m1((Re>>>0).toString(16),"0",6)}`);break;default:Ae?(fe=w.foreground,ee.push("xterm-bg-257")):fe=w.background}switch(We||I.isDim()&&(We=oi.multiplyOpacity(fe,.5)),Ne){case 16777216:case 33554432:I.isBold()&&ke<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ke+=8),this._applyMinimumContrast(M,fe,w.ansi[ke],I,We,void 0)||ee.push(`xterm-fg-${ke}`);break;case 50331648:let D=ji.toColor(ke>>16&255,ke>>8&255,ke&255);this._applyMinimumContrast(M,fe,D,I,We,Pe)||this._addStyle(M,`color:#${m1(ke.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(M,fe,w.foreground,I,We,Pe)||Ae&&ee.push("xterm-fg-257")}ee.length&&(M.className=ee.join(" "),ee.length=0),!xe&&!ie&&!K&&B?O++:M.textContent=A,G!==this.defaultSpacing&&(M.style.letterSpacing=`${G}px`),b.push(M),Z=R}return M&&O&&(M.textContent=A),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||_L(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=oi.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]}};i_=Si([ze(1,ak),ze(2,Dn),ze(3,Zr),ze(4,sl),ze(5,fd),ze(6,pc)],i_);function m1(e,t,n){for(;e.length<n;)e=t+e;return e}var yL=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}},SL=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 wL(){return new SL}var Ng="xterm-dom-renderer-owner-",ms="xterm-rows",Bh="xterm-fg-",g1="xterm-bg-",hu="xterm-focus",jh="xterm-selection",CL=1,n_=class extends yt{constructor(e,t,n,r,o,c,u,f,g,p,_,b,C,w){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=p,this._bufferService=_,this._coreService=b,this._coreBrowserService=C,this._themeService=w,this._terminalClass=CL++,this._rowElements=[],this._selectionRenderModel=wL(),this.onRequestRedraw=this._register(new Oe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ms),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(jh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=bL(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(i_,document),this._element.classList.add(Ng+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(hi(()=>{this._element.classList.remove(Ng+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yL(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} .${ms} 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} .${ms} { 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} .${ms} .xterm-dim { color: ${oi.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} .${ms}.${hu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${ms}.${hu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ms}.${hu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${ms} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ms} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ms} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ms} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ms} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${jh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${jh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${jh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Bh}${c} { color: ${u.css}; }${this._terminalSelector} .${Bh}${c}.xterm-dim { color: ${oi.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${g1}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Bh}257 { color: ${oi.opaque(e.background).css}; }${this._terminalSelector} .${Bh}257.xterm-dim { color: ${oi.multiplyOpacity(oi.opaque(e.background),.5).css}; }${this._terminalSelector} .${g1}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(hu),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(hu),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,p=c===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,g,p));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 p=g+n.ydisp,_=this._rowElements[g],b=n.lines.get(p);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,p,p===r,u,f,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ng}${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,p=Math.min(f.x,o-1),_=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,C=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=r;++w){let x=w+f.ydisp,M=this._rowElements[w],O=f.lines.get(x);if(!M||!O)break;M.replaceChildren(...this._rowFactory.createRow(O,x,x===g,b,C,p,_,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===r?t:o)-1:-1))}}};n_=Si([ze(7,Nb),ze(8,sp),ze(9,Dn),ze(10,En),ze(11,sl),ze(12,Zr),ze(13,pc)],n_);var s_=class extends yt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Oe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new kL(this._optionsService))}catch{this._measureStrategy=this._register(new xL(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())}};s_=Si([ze(2,Dn)],s_);var kk=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)}},xL=class extends kk{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}},kL=class extends kk{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}},TL=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 EL(this._window)),this._onDprChange=this._register(new Oe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Oe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(hn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(st(this._textarea,"focus",()=>this._isFocused=!0)),this._register(st(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}},EL=class extends yt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ac),this._onDprChange=this._register(new Oe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(hi(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=st(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)}},DL=class extends yt{constructor(){super(),this.linkProviders=[],this._register(hi(()=>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 zb(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 RL(e,t,n,r,o,c,u,f,g){if(!c)return;let p=zb(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var r_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return RL(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=zb(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])}}};r_=Si([ze(0,Qr),ze(1,sp)],r_);var ML=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=[]}},Tk={};HN(Tk,{getSafariVersion:()=>AL,isChromeOS:()=>Mk,isFirefox:()=>Ek,isIpad:()=>LL,isIphone:()=>OL,isLegacyEdge:()=>NL,isLinux:()=>Hb,isMac:()=>Tf,isNode:()=>rp,isSafari:()=>Dk,isWindows:()=>Rk});var rp=typeof process<"u"&&"title"in process,pd=rp?"node":navigator.userAgent,md=rp?"node":navigator.platform,Ek=pd.includes("Firefox"),NL=pd.includes("Edge"),Dk=/^((?!chrome|android).)*safari/i.test(pd);function AL(){if(!Dk)return 0;let e=pd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Tf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(md),LL=md==="iPad",OL=md==="iPhone",Rk=["Windows","Win16","Win32","WinCE"].includes(md),Hb=md.indexOf("Linux")>=0,Mk=/\bCrOS\b/.test(pd),Nk=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()}},BL=class extends Nk{_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())}}},jL=class extends Nk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ef=!rp&&"requestIdleCallback"in window?jL:BL,IL=class{constructor(){this._queue=new Ef}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},a_=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 ac),this._pausedResizeTask=new IL,this._observerDisposable=this._register(new ac),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 Oe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Oe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Oe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Oe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ML((p,_)=>this._renderRows(p,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new PL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(hi(()=>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(p=>this._registerIntersectionObserver(p,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=hi(()=>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()}};a_=Si([ze(2,Dn),ze(3,sp),ze(4,sl),ze(5,fd),ze(6,En),ze(7,Zr),ze(8,pc)],a_);var PL=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 zL(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return FL(o,c,e,t,n,r)+ap(c,t,n,r)+KL(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",Xu(Math.abs(o-e),Yu(u,r));u=c>t?"D":"C";let f=Math.abs(c-t),g=UL(c>t?e:o,n)+(f-1)*n.cols+1+HL(c>t?o:e);return Xu(g,Yu(u,r))}function HL(e,t){return e-1}function UL(e,t){return t.cols-e}function FL(e,t,n,r,o,c){return ap(t,r,o,c).length===0?"":Xu(Lk(e,t,e,t-tl(t,o),!1,o).length,Yu("D",c))}function ap(e,t,n,r){let o=e-tl(e,n),c=t-tl(t,n),u=Math.abs(o-c)-$L(e,t,n);return Xu(u,Yu(Ak(e,t),r))}function KL(e,t,n,r,o,c){let u;ap(t,r,o,c).length>0?u=r-tl(r,o):u=t;let f=r,g=WL(e,t,n,r,o,c);return Xu(Lk(e,u,n,f,g==="C",o).length,Yu(g,c))}function $L(e,t,n){let r=0,o=e-tl(e,n),c=t-tl(t,n);for(let u=0;u<Math.abs(o-c);u++){let f=Ak(e,t)==="A"?-1:1;n.buffer.lines.get(o+f*u)?.isWrapped&&r++}return r}function tl(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 WL(e,t,n,r,o,c){let u;return ap(n,r,o,c).length>0?u=r-tl(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function Ak(e,t){return e>t?"A":"B"}function Lk(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 Yu(e,t){let n=t?"O":"[";return we.ESC+n+e}function Xu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var qL=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 v1(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 Ag=50,VL=15,YL=50,XL=500,GL=" ",ZL=new RegExp(GL,"g"),o_=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 Ss,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Oe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Oe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Oe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Oe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new qL(this._bufferService),this._activeSelectionMode=0,this._register(hi(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.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(ZL," ")).join(Rk?`\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())),Hb&&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=v1(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=zb(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,-Ag),Ag),t/=Ag,t/Math.abs(t)+Math.round(t*(VL-1)))}shouldForceSelection(e){return Tf?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(),YL)}_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&&!(Tf&&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<XL&&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=zL(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,p=e[0]-f,_=0,b=0,C=0,w=0;if(u.charAt(f)===" "){for(;f>0&&u.charAt(f-1)===" ";)f--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let O=e[0],A=e[0];c.getWidth(O)===0&&(_++,O--),c.getWidth(A)===2&&(b++,A++);let W=c.getString(A).length;for(W>1&&(w+=W-1,g+=W-1);O>0&&f>0&&!this._isCharWordSeparator(c.loadCell(O-1,this._workCell));){c.loadCell(O-1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,O--):F>1&&(C+=F-1,f-=F-1),f--,O--}for(;A<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,A++):F>1&&(w+=F-1,g+=F-1),g++,A++}}g++;let x=f+p-_+C,M=Math.min(this._bufferService.cols,g-f+_+b-C-w);if(!(!t&&u.slice(f,g).trim()==="")){if(n&&x===0&&c.getCodePoint(0)!==32){let O=o.lines.get(e[1]-1);if(O&&c.isWrapped&&O.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;x-=W,M+=W}}}if(r&&x+M===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let O=o.lines.get(e[1]+1);if(O?.isWrapped&&O.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(M+=A.length)}}return{start:x,length:M}}}_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=v1(n,this._bufferService.cols)}};o_=Si([ze(3,En),ze(4,sl),ze(5,Ab),ze(6,Dn),ze(7,Qr),ze(8,Zr)],o_);var _1=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={}}},b1=class{constructor(){this._color=new _1,this._css=new _1}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()}},Fi=Object.freeze((()=>{let e=[mi.toColor("#2e3436"),mi.toColor("#cc0000"),mi.toColor("#4e9a06"),mi.toColor("#c4a000"),mi.toColor("#3465a4"),mi.toColor("#75507b"),mi.toColor("#06989a"),mi.toColor("#d3d7cf"),mi.toColor("#555753"),mi.toColor("#ef2929"),mi.toColor("#8ae234"),mi.toColor("#fce94f"),mi.toColor("#729fcf"),mi.toColor("#ad7fa8"),mi.toColor("#34e2e2"),mi.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})()),$o=mi.toColor("#ffffff"),xu=mi.toColor("#000000"),y1=mi.toColor("#ffffff"),S1=xu,fu={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},QL=$o,l_=class extends yt{constructor(e){super(),this._optionsService=e,this._contrastCache=new b1,this._halfContrastCache=new b1,this._onChangeColors=this._register(new Oe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:$o,background:xu,cursor:y1,cursorAccent:S1,selectionForeground:void 0,selectionBackgroundTransparent:fu,selectionBackgroundOpaque:oi.blend(xu,fu),selectionInactiveBackgroundTransparent:fu,selectionInactiveBackgroundOpaque:oi.blend(xu,fu),scrollbarSliderBackground:oi.opacity($o,.2),scrollbarSliderHoverBackground:oi.opacity($o,.4),scrollbarSliderActiveBackground:oi.opacity($o,.5),overviewRulerBorder:$o,ansi:Fi.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=Zt(e.foreground,$o),t.background=Zt(e.background,xu),t.cursor=oi.blend(t.background,Zt(e.cursor,y1)),t.cursorAccent=oi.blend(t.background,Zt(e.cursorAccent,S1)),t.selectionBackgroundTransparent=Zt(e.selectionBackground,fu),t.selectionBackgroundOpaque=oi.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Zt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=oi.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Zt(e.selectionForeground,p1):void 0,t.selectionForeground===p1&&(t.selectionForeground=void 0),oi.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=oi.opacity(t.selectionBackgroundTransparent,.3)),oi.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=oi.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Zt(e.scrollbarSliderBackground,oi.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Zt(e.scrollbarSliderHoverBackground,oi.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Zt(e.scrollbarSliderActiveBackground,oi.opacity(t.foreground,.5)),t.overviewRulerBorder=Zt(e.overviewRulerBorder,QL),t.ansi=Fi.slice(),t.ansi[0]=Zt(e.black,Fi[0]),t.ansi[1]=Zt(e.red,Fi[1]),t.ansi[2]=Zt(e.green,Fi[2]),t.ansi[3]=Zt(e.yellow,Fi[3]),t.ansi[4]=Zt(e.blue,Fi[4]),t.ansi[5]=Zt(e.magenta,Fi[5]),t.ansi[6]=Zt(e.cyan,Fi[6]),t.ansi[7]=Zt(e.white,Fi[7]),t.ansi[8]=Zt(e.brightBlack,Fi[8]),t.ansi[9]=Zt(e.brightRed,Fi[9]),t.ansi[10]=Zt(e.brightGreen,Fi[10]),t.ansi[11]=Zt(e.brightYellow,Fi[11]),t.ansi[12]=Zt(e.brightBlue,Fi[12]),t.ansi[13]=Zt(e.brightMagenta,Fi[13]),t.ansi[14]=Zt(e.brightCyan,Fi[14]),t.ansi[15]=Zt(e.brightWhite,Fi[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]=Zt(e.extendedAnsi[r],Fi[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()}}};l_=Si([ze(0,Dn)],l_);function Zt(e,t){if(e!==void 0)try{return mi.toColor(e)}catch{}return t}var JL=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)}},eO=class{constructor(){this._services=new JL,this._services.set(Nb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=VN(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)}},tO={trace:0,debug:1,info:2,warn:3,error:4,off:5},iO="xterm.js: ",c_=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=tO[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?"":iO)+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)}};c_=Si([ze(0,Dn)],c_);var w1=class extends yt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Oe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Oe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Oe),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 hd),Ih=0,Lg=2,ku=class Ok{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*bt);let o=n||Ss.fromCharData([0,Jx,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?Wa(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?Wa(n&2097151):""}isProtected(t){return this._data[t*bt+2]&536870912}loadCell(t,n){return Ih=t*bt,n.content=this._data[Ih+0],n.fg=this._data[Ih+1],n.bg=this._data[Ih+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]+=Wa(n):o&2097151?(this._combined[t]=Wa(o&2097151)+Wa(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 Ss;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 Ss;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*Lg<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*Lg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Lg<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 Ok(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 p=0;p<bt;p++)this._data[(r+g)*bt+p]=u[(n+g)*bt+p];u[(n+g)*bt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<bt;p++)this._data[(r+g)*bt+p]=u[(n+g)*bt+p];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 p=parseInt(f[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}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?Wa(f):Ya;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function nO(e,t,n,r,o,c){let u=[];for(let f=0;f<e.length-1;f++){let g=f,p=e.get(++g);if(!p.isWrapped)continue;let _=[e.get(f)];for(;g<e.length&&p.isWrapped;)_.push(p),p=e.get(++g);if(!c&&r>=f&&r<g){f+=_.length-1;continue}let b=0,C=Gu(_,b,t),w=1,x=0;for(;w<_.length;){let O=Gu(_,w,t),A=O-x,W=n-C,F=Math.min(A,W);_[b].copyCellsFrom(_[w],x,C,F,!1),C+=F,C===n&&(b++,C=0),x+=F,x===O&&(w++,x=0),C===0&&b!==0&&_[b-1].getWidth(n-1)===2&&(_[b].copyCellsFrom(_[b-1],n-1,C++,1,!1),_[b-1].setCell(n-1,o))}_[b].replaceCells(C,n,o);let M=0;for(let O=_.length-1;O>0&&(O>b||_[O].getTrimmedLength()===0);O--)M++;M>0&&(u.push(f+_.length-M),u.push(M)),f+=_.length-1}return u}function sO(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 rO(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 aO(e,t,n){let r=[],o=e.map((g,p)=>Gu(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,f=0;for(;f<o;){if(o-f<n){r.push(o-f);break}c+=n;let g=Gu(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let _=p?n-1:n;r.push(_),f+=_}return r}function Gu(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 Bk=class jk{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=jk._nextId++,this._onDispose=this.register(new Oe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),el(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Bk._nextId=1;var oO=Bk,Wi={},Wo=Wi.B;Wi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Wi.A={"#":"£"};Wi.B=void 0;Wi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Wi.C=Wi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Wi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Wi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Wi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Wi.E=Wi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Wi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Wi.H=Wi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var C1=4294967295,x1=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=Wo,this.markers=[],this._nullCell=Ss.fromCharData([0,Jx,1,0]),this._whitespaceCell=Ss.fromCharData([0,Ya,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ef,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new w1(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 Cf),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 Cf),this._whitespaceCell}getBlankLine(e,t){return new ku(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>C1?C1: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 w1(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 ku(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 ku(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=nO(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Bi),n);if(r.length>0){let o=sO(this.lines,r);rO(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 ku(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 F=this.ybase+this.y;if(F>=u&&F<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),_=aO(g,this._cols,e),b=_.length-g.length,C;this.ybase===0&&this.y!==this.lines.length-1?C=Math.max(0,this.y-this.lines.maxLength+b):C=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let F=0;F<b;F++){let U=this.getBlankLine(Bi,!0);w.push(U)}w.length>0&&(o.push({start:u+g.length+c,newLines:w}),c+=w.length),g.push(...w);let x=_.length-1,M=_[x];M===0&&(x--,M=_[x]);let O=g.length-b-1,A=p;for(;O>=0;){let F=Math.min(A,M);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[O],A-F,M-F,F,!0),M-=F,M===0&&(x--,M=_[x]),A-=F,A===0){O--;let U=Math.max(O,0);A=Gu(g,U,this._cols)}}for(let F=0;F<g.length;F++)_[F]<e&&g[F].setCell(_[F],r);let W=b-C;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 M=0;M<this.lines.length;M++)f.push(this.lines.get(M));let g=this.lines.length,p=g-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let C=0;for(let M=Math.min(this.lines.maxLength-1,g+c-1);M>=0;M--)if(b&&b.start>p+C){for(let O=b.newLines.length-1;O>=0;O--)this.lines.set(M--,b.newLines[O]);M++,u.push({index:p+1,amount:b.newLines.length}),C+=b.newLines.length,b=o[++_]}else this.lines.set(M,f[p--]);let w=0;for(let M=u.length-1;M>=0;M--)u[M].index+=w,this.lines.onInsertEmitter.fire(u[M]),w+=u[M].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}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 oO(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)}},lO=class extends yt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Oe),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 x1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new x1(!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)}},Ik=2,Pk=1,u_=class extends yt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Oe),this.onResize=this._onResize.event,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Ik),this.rows=Math.max(e.rawOptions.rows||0,Pk),this.buffers=this._register(new lO(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))}};u_=Si([ze(0,Dn)],u_);var Ul={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:Tf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},cO=["normal","bold","100","200","300","400","500","600","700","800","900"],uO=class extends yt{constructor(e){super(),this._onOptionChange=this._register(new Oe),this.onOptionChange=this._onOptionChange.event;let t={...Ul};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(hi(()=>{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 Ul))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in Ul))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=Ul[e]),!dO(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=cO.includes(t)?t:Ul[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 dO(e){return e==="block"||e==="underline"||e==="bar"}function Tu(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]&&Tu(e[r],t-1);return n}var k1=Object.freeze({insertMode:!1}),T1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),d_=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 Oe),this.onData=this._onData.event,this._onUserInput=this._register(new Oe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Oe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Oe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Tu(k1),this.decPrivateModes=Tu(T1)}reset(){this.modes=Tu(k1),this.decPrivateModes=Tu(T1)}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))}};d_=Si([ze(0,En),ze(1,sk),ze(2,Dn)],d_);var E1={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 Og(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 Bg=String.fromCharCode,D1={DEFAULT:e=>{let t=[Og(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Bg(t[0])}${Bg(t[1])}${Bg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Og(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Og(e,!0)};${e.x};${e.y}${t}`}},h_=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 Oe),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(E1))this.addProtocol(r,E1[r]);for(let r of Object.keys(D1))this.addEncoding(r,D1[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)}};h_=Si([ze(0,En),ze(1,sl),ze(2,Dn)],h_);var jg=[[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]],hO=[[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 fO(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 pO=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<jg.length;++e)Ki.fill(0,jg[e][0],jg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ki[e]:fO(e,hO)?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=qo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return qo.createPropertyValue(0,n,r)}},qo=class nf{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Oe,this.onChange=this._onChange.event;let t=new pO;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 p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let f=this.charProperties(u,r),g=nf.extractWidth(f);nf.extractShouldJoin(f)&&(g-=nf.extractWidth(r)),n+=g,r=f}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},mO=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 R1(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 pu=2147483647,gO=256,zk=class f_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>gO)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 f_;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 f_(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>pu?pu: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>pu?pu: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,pu):t}},mu=[],vO=class{constructor(){this._state=0,this._active=mu,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=mu}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=mu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||mu,!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",np(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=mu,this._id=-1,this._state=0}}},$n=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+=np(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}},gu=[],_O=class{constructor(){this._handlers=Object.create(null),this._active=gu,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gu}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=gu,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gu,!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",np(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=gu,this._ident=0}},Eu=new zk;Eu.addParam(0);var M1=class{constructor(e){this._handler=e,this._data="",this._params=Eu,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Eu,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=np(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=Eu,this._data="",this._hitLimit=!1,n));return this._params=Eu,this._data="",this._hitLimit=!1,t}},bO=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}},bs=160,yO=(function(){let e=new bO(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(bs,0,2,0),e.add(bs,8,5,8),e.add(bs,6,0,6),e.add(bs,11,0,11),e.add(bs,13,13,13),e})(),SO=class extends yt{constructor(e=yO){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 zk,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(hi(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new vO),this._dcsParser=this._register(new _O),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:bs)],o>>4){case 2:for(let C=f+1;;++C){if(C>=t||(r=e[C])<32||r>126&&r<bs){this._printHandler(e,f,C),f=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<bs){this._printHandler(e,f,C),f=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<bs){this._printHandler(e,f,C),f=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<bs){this._printHandler(e,f,C),f=C-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],p=g?g.length-1:-1;for(;p>=0&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,f),u;p<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 C=f+1;;++C)if(C>=t||(r=e[C])===24||r===26||r===27||r>127&&r<bs){this._dcsParser.put(e,f,C),f=C-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 C=f+1;;C++)if(C>=t||(r=e[C])<32||r>127&&r<bs){this._oscParser.put(e,f,C),f=C-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}}},wO=/^([\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})$/,CO=/^[\da-f]+$/;function N1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=wO.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),CO.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 Ig(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 xO(e,t=16){let[n,r,o]=e;return`rgb:${Ig(n,t)}/${Ig(r,t)}/${Ig(o,t)}`}var kO={"(":0,")":1,"*":2,"+":3,"-":1,".":2},za=131072,A1=10;function L1(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 O1=5e3,B1=0,TO=class extends yt{constructor(e,t,n,r,o,c,u,f,g=new SO){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 WN,this._utf8Decoder=new qN,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Bi.clone(),this._eraseAttrDataInternal=Bi.clone(),this._onRequestBell=this._register(new Oe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Oe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Oe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Oe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Oe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Oe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Oe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Oe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Oe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Oe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Oe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Oe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Oe),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 p_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:_.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,_,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:_,data:b})}),this._parser.setDcsHandlerFallback((p,_,b)=>{_==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:_,payload:b})}),this._parser.setPrintHandler((p,_,b)=>this.print(p,_,b)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(we.BEL,()=>this.bell()),this._parser.setExecuteHandler(we.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(we.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(we.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(we.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(we.BS,()=>this.backspace()),this._parser.setExecuteHandler(we.HT,()=>this.tab()),this._parser.setExecuteHandler(we.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(we.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ef.IND,()=>this.index()),this._parser.setExecuteHandler(ef.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ef.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new $n(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new $n(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new $n(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new $n(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new $n(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new $n(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new $n(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new $n(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new $n(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new $n(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new $n(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new $n(p=>this.restoreCursorColor(p))),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 p in Wi)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new M1((p,_)=>this.requestStatusString(p,_)))}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"),O1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${O1} 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>za&&(c=this._parseStack.position+za)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<za&&(this._parseBuffer=new Uint32Array(Math.min(e.length,za))),u||this._dirtyRowTracker.clearRange(),e.length>za)for(let p=c;p<e.length;p+=za){let _=p+za<e.length?p+za:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,_),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(n),n}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,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,p=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 C=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(r=e[w],r<127&&c){let A=c[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let x=this._unicodeService.charProperties(r,C);o=qo.extractWidth(x);let M=qo.extractShouldJoin(x),O=M?qo.extractWidth(C):0;if(C=x,u&&this._onA11yChar.fire(Wa(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-O>f){if(g){let A=b,W=this._activeBuffer.x-O;for(this._activeBuffer.x=O,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),O>0&&b instanceof ku&&b.copyCellsFrom(A,W,0,O,!1);W<f;)A.setCellFromCodepoint(W++,0,1,_)}else if(this._activeBuffer.x=f-1,o===2)continue}if(M&&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-O;--W>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-O,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=C,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=>L1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new M1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $n(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=qo.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 p=0;p<c.length;){let _=c.codePointAt(p)||0;u[f++]=_,p+=_>65535?2:1}let g=f;for(let p=1;p<n;++p)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(we.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(we.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(we.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(we.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(we.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,Wo),this._charsetService.setgCharset(1,Wo),this._charsetService.setgCharset(2,Wo),this._charsetService.setgCharset(3,Wo);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;(M=>(M[M.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",M[M.SET=1]="SET",M[M.RESET=2]="RESET",M[M.PERMANENTLY_SET=3]="PERMANENTLY_SET",M[M.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:p,alt:_}=f,b=this._optionsService.rawOptions,C=(M,O)=>(u.triggerDataEvent(`${we.ESC}[${t?"":"?"}${M};${O}$y`),!0),w=M=>M?1:2,x=e.params[0];return t?x===2?C(x,4):x===4?C(x,w(u.modes.insertMode)):x===12?C(x,3):x===20?C(x,w(b.convertEol)):C(x,0):x===1?C(x,w(r.applicationCursorKeys)):x===3?C(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?C(x,w(r.origin)):x===7?C(x,w(r.wraparound)):x===8?C(x,3):x===9?C(x,w(o==="X10")):x===12?C(x,w(b.cursorBlink)):x===25?C(x,w(!u.isCursorHidden)):x===45?C(x,w(r.reverseWraparound)):x===66?C(x,w(r.applicationKeypad)):x===67?C(x,4):x===1e3?C(x,w(o==="VT200")):x===1002?C(x,w(o==="DRAG")):x===1003?C(x,w(o==="ANY")):x===1004?C(x,w(r.sendFocus)):x===1005?C(x,4):x===1006?C(x,w(c==="SGR")):x===1015?C(x,4):x===1016?C(x,w(c==="SGR_PIXELS")):x===1048?C(x,1):x===47||x===1047||x===1049?C(x,w(p===_)):x===2004?C(x,w(r.bracketedPasteMode)):x===2026?C(x,w(r.synchronizedOutput)):C(x,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=hd.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(`${we.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${we.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(`${we.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(!L1(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(`${we.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>A1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>A1&&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(j1(c))if(o==="?")t.push({type:0,index:c});else{let u=N1(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=N1(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]);j1(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,Wo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(kO[e[0]],Wi[e[1]]||Wo),!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 Ss;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(`${we.ESC}${u}${we.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)}},p_=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&&(B1=e,e=t,t=B1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};p_=Si([ze(0,En)],p_);function j1(e){return 0<=e&&e<256}var EO=5e7,I1=12,DO=50,RO=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 Oe),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>EO)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>=I1?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>=I1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>DO&&(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()}},m_=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)))}};m_=Si([ze(0,En)],m_);var P1=!1,MO=class extends yt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ac),this._onBinary=this._register(new Oe),this.onBinary=this._onBinary.event,this._onData=this._register(new Oe),this.onData=this._onData.event,this._onLineFeed=this._register(new Oe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Oe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Oe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Oe),this._instantiationService=new eO,this.optionsService=this._register(new uO(e)),this._instantiationService.setService(Dn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(u_)),this._instantiationService.setService(En,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(c_)),this._instantiationService.setService(sk,this._logService),this.coreService=this._register(this._instantiationService.createInstance(d_)),this._instantiationService.setService(sl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(h_)),this._instantiationService.setService(nk,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(qo)),this._instantiationService.setService(GN,this.unicodeService),this._charsetService=this._instantiationService.createInstance(mO),this._instantiationService.setService(XN,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(m_),this._instantiationService.setService(rk,this._oscLinkService),this._inputHandler=this._register(new TO(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(hn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(hn.forward(this._bufferService.onResize,this._onResize)),this._register(hn.forward(this.coreService.onData,this._onData)),this._register(hn.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 RO((t,n)=>this._inputHandler.parse(t,n))),this._register(hn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Oe),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&&!P1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),P1=!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,Ik),t=Math.max(t,Pk),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(R1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(R1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=hi(()=>{for(let t of e)t.dispose()})}}},NO={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function AO(e,t,n,r){let 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=we.ESC+"OA":o.key=we.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=we.ESC+"OD":o.key=we.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=we.ESC+"OC":o.key=we.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=we.ESC+"OB":o.key=we.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":we.DEL,e.altKey&&(o.key=we.ESC+o.key);break;case 9:if(e.shiftKey){o.key=we.ESC+"[Z";break}o.key=we.HT,o.cancel=!0;break;case 13:o.key=e.altKey?we.ESC+we.CR:we.CR,o.cancel=!0;break;case 27:o.key=we.ESC,e.altKey&&(o.key=we.ESC+we.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=we.ESC+"[1;"+(c+1)+"D":t?o.key=we.ESC+"OD":o.key=we.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=we.ESC+"[1;"+(c+1)+"C":t?o.key=we.ESC+"OC":o.key=we.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=we.ESC+"[1;"+(c+1)+"A":t?o.key=we.ESC+"OA":o.key=we.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=we.ESC+"[1;"+(c+1)+"B":t?o.key=we.ESC+"OB":o.key=we.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=we.ESC+"[2~");break;case 46:c?o.key=we.ESC+"[3;"+(c+1)+"~":o.key=we.ESC+"[3~";break;case 36:c?o.key=we.ESC+"[1;"+(c+1)+"H":t?o.key=we.ESC+"OH":o.key=we.ESC+"[H";break;case 35:c?o.key=we.ESC+"[1;"+(c+1)+"F":t?o.key=we.ESC+"OF":o.key=we.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=we.ESC+"[5;"+(c+1)+"~":o.key=we.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=we.ESC+"[6;"+(c+1)+"~":o.key=we.ESC+"[6~";break;case 112:c?o.key=we.ESC+"[1;"+(c+1)+"P":o.key=we.ESC+"OP";break;case 113:c?o.key=we.ESC+"[1;"+(c+1)+"Q":o.key=we.ESC+"OQ";break;case 114:c?o.key=we.ESC+"[1;"+(c+1)+"R":o.key=we.ESC+"OR";break;case 115:c?o.key=we.ESC+"[1;"+(c+1)+"S":o.key=we.ESC+"OS";break;case 116:c?o.key=we.ESC+"[15;"+(c+1)+"~":o.key=we.ESC+"[15~";break;case 117:c?o.key=we.ESC+"[17;"+(c+1)+"~":o.key=we.ESC+"[17~";break;case 118:c?o.key=we.ESC+"[18;"+(c+1)+"~":o.key=we.ESC+"[18~";break;case 119:c?o.key=we.ESC+"[19;"+(c+1)+"~":o.key=we.ESC+"[19~";break;case 120:c?o.key=we.ESC+"[20;"+(c+1)+"~":o.key=we.ESC+"[20~";break;case 121:c?o.key=we.ESC+"[21;"+(c+1)+"~":o.key=we.ESC+"[21~";break;case 122:c?o.key=we.ESC+"[23;"+(c+1)+"~":o.key=we.ESC+"[23~";break;case 123:c?o.key=we.ESC+"[24;"+(c+1)+"~":o.key=we.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=we.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=we.DEL:e.keyCode===219?o.key=we.ESC:e.keyCode===220?o.key=we.FS:e.keyCode===221&&(o.key=we.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=NO[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=we.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=we.ESC+g}else if(e.keyCode===32)o.key=we.ESC+(e.ctrlKey?we.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=we.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=we.US),e.key==="@"&&(o.key=we.NUL));break}return o}var Ei=0,LO=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ef,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ef,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||(Ei=this._search(t),Ei===-1)||this._getKey(this._array[Ei])!==t)return!1;do if(this._array[Ei]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ei),!0;while(++Ei<this._array.length&&this._getKey(this._array[Ei])===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&&(Ei=this._search(e),!(Ei<0||Ei>=this._array.length)&&this._getKey(this._array[Ei])===e))do yield this._array[Ei];while(++Ei<this._array.length&&this._getKey(this._array[Ei])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ei=this._search(e),!(Ei<0||Ei>=this._array.length)&&this._getKey(this._array[Ei])===e))do t(this._array[Ei]);while(++Ei<this._array.length&&this._getKey(this._array[Ei])===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}},Pg=0,z1=0,OO=class extends yt{constructor(){super(),this._decorations=new LO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Oe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Oe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(hi(()=>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=>{Pg=o.options.x??0,z1=Pg+(o.options.width??1),e>=Pg&&e<z1&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},BO=class extends Ga{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Oe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Oe),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=mi.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=mi.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},jO=1e3,IO=class{constructor(e,t=jO){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)}},H1=20,Df=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 IO(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(st(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(hi(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<H1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
29
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===H1+1&&(this._liveRegion.textContent+=Bv.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(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}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 p=f instanceof Text?f.parentNode:f,_=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(_))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let C=g<b.length?b[g]:b.slice(-1)[0]+1;return C>=this._terminal.cols&&(++_,C=0),{row:_,column:C}},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})`}};Df=Si([ze(1,Nb),ze(2,Zr),ze(3,Qr)],Df);var g_=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 Oe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Oe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(hi(()=>{el(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(st(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(st(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(st(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(st(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 p=f;p<=g;p++){if(n.has(p)){o.splice(c--,1);break}n.add(p)}}}}_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&&PO(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,el(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}}};g_=Si([ze(1,Ab),ze(2,Qr),ze(3,En),ze(4,ok)],g_);function PO(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 zO=class extends MO{constructor(e={}){super(e),this._linkifier=this._register(new ac),this.browser=Tk,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ac),this._onCursorMove=this._register(new Oe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Oe),this.onKey=this._onKey.event,this._onRender=this._register(new Oe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Oe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Oe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Oe),this.onBell=this._onBell.event,this._onFocus=this._register(new Oe),this._onBlur=this._register(new Oe),this._onA11yCharEmitter=this._register(new Oe),this._onA11yTabEmitter=this._register(new Oe),this._onWillOpen=this._register(new Oe),this._setup(),this._decorationService=this._instantiationService.createInstance(OO),this._instantiationService.setService(fd,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(DL),this._instantiationService.setService(ok,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Iv)),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(hn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(hn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(hn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(hn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(hi(()=>{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=oi.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${we.ESC}]${r};${xO(o)}${xk.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(Df,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(we.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(we.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(st(this.element,"copy",t=>{this.hasSelection()&&KN(t,this._selectionService)}));let e=t=>$N(t,this.textarea,this.coreService,this.optionsService);this._register(st(this.textarea,"paste",e)),this._register(st(this.element,"paste",e)),Ek?this._register(st(this.element,"mousedown",t=>{t.button===2&&Gw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(st(this.element,"contextmenu",t=>{Gw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Hb&&this._register(st(this.element,"auxclick",t=>{t.button===1&&Qx(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(st(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(st(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(st(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(st(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(st(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(st(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(st(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(st(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",Ov.get()),Mk||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(TL,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Zr,this._coreBrowserService),this._register(st(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(st(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(s_,this._document,this._helperContainer),this._instantiationService.setService(sp,this._charSizeService),this._themeService=this._instantiationService.createInstance(l_),this._instantiationService.setService(pc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(kf),this._instantiationService.setService(ak,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(a_,this.rows,this.screenElement)),this._instantiationService.setService(Qr,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(t_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(r_),this._instantiationService.setService(Ab,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(g_,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(Jv,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(o_,this.element,this.screenElement,r)),this._instantiationService.setService(QN,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(hn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(e_,this.screenElement)),this._register(st(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(Df,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xf,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xf,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(n_,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 p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<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(st(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(st(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=we.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){Zx(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=AO(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===we.ETX||n.key===we.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)&&(HO(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(we.ESC+"[I"):this.coreService.triggerDataEvent(we.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(`${we.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(`${we.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function HO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var UO=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)}},FO=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 Ss)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},U1=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 FO(t)}getNullCell(){return new Ss}},KO=class extends yt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Oe),this.onBufferChange=this._onBufferChange.event,this._normal=new U1(this._core.buffers.normal,"normal"),this._alternate=new U1(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)}},$O=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)}},WO=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}},qO=["cols","rows"],or=0,VO=class extends yt{constructor(e){super(),this._core=this._register(new zO(e)),this._addonManager=this._register(new UO),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(qO.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 $O(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new WO(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 KO(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 Ov.get()},set promptLabel(e){Ov.set(e)},get tooMuchOutput(){return Bv.get()},set tooMuchOutput(e){Bv.set(e)}}}_verifyIntegers(...e){for(or of e)if(or===1/0||isNaN(or)||or%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(or of e)if(or&&(or===1/0||isNaN(or)||or%1!==0||or<0))throw new Error("This API only accepts positive integers")}};const YO=jt.lazy(()=>Mb(()=>import("./TranscriptMarkdownBody-B_ctyQyz.js"),__vite__mapDeps([2,1])));function Hk({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 p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let f=-1;return h.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,p)=>{const _=g.kind==="user"?++f:null,b=n===p?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return h.jsxs("section",{ref:C=>{C?u.current.set(p,C):u.current.delete(p)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":p,..._!==null?{"data-transcript-prompt-position":_}:{},children:[g.header?h.jsx("div",{className:"transcript-entry-header",children:Uk(g.header,t)}):null,g.body?h.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?h.jsx(F1,{text:g.body,searchQuery:t}):h.jsx(jt.Suspense,{fallback:h.jsx(F1,{text:g.body,searchQuery:t}),children:h.jsx(YO,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function F1({text:e,searchQuery:t}){const n=e.endsWith(`
31
- `)?e.slice(0,-1).split(`
32
- `):e.split(`
33
- `);return h.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>h.jsx("span",{className:`transcript-line transcript-line-${JO(r,o===0||n[o-1]?.trim()==="")}`,children:Uk(r,t)},o))})}function Uk(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(h.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 XO(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 Fk(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=GO(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=ZO(f);g?(u(),r=f,o=g):c.push(f)}return u(),n}function GO(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function ZO(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 QO(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=XO(c,t);for(let f=0;f<u;f+=1)n.push({entryIndex:r,matchIndexInEntry:f})}return n}function JO(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)||Wk(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 il(e){return e==="codex"?"Codex":"Claude"}function v_(e,t,n={}){const r=`[nterminal] ${il(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=Kk(o),u=n.includeTools?c:$k(c);return u?`${u}
42
- `:""}function Kk(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=e3(n);return r?`[${r}]`:t})}function e3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=vu(t.getMonth()+1),o=vu(t.getDate()),c=vu(t.getHours()),u=vu(t.getMinutes()),f=vu(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${f}`}function vu(e){return e.toString().padStart(2,"0")}function Rf(e,t){return e.map(n=>t?n:$k(n)).filter(Boolean).map(n=>n.endsWith(`
43
- `)?n:`${n}
44
- `).join("")}function $k(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?t3(u):null;if(g&&(r=g==="tool",o=!1),Wk(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 t3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function Wk(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Ub(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Ph(e,t){return e===null?t===null:t!==null&&Ub(e,t)}const i3=5e3,n3=200,s3=1200,r3=4,a3=jt.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),p=v.useRef(!1),_=v.useRef(null),b=v.useRef(!1),[C,w]=v.useState(null),[x,M]=v.useState(null),[O,A]=v.useState(null),[W,F]=v.useState(()=>new Set),[U,q]=v.useState(!1),[ae,P]=v.useState(!1),[te,G]=v.useState([]),[ge,ee]=v.useState(null),[V,Z]=v.useState(!1),[Y,ie]=v.useState(!1),[B,R]=v.useState(!1),[I,ue]=v.useState(null),xe=C?.find(D=>D.id===O)??null;v.useEffect(()=>{function D(J){J.key==="Escape"&&(J.preventDefault(),J.stopPropagation(),c())}return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[c]);const N=v.useCallback(async()=>{try{const D=await n.getTerminalSubagents(t);if(M(null),w(J=>J&&d3(J,D.subagents)?J:D.subagents),!b.current){const J=D.subagents.find(Ce=>Ce.hasTranscript);J&&(b.current=!0,A(Ce=>Ce??J.id))}}catch(D){M(D instanceof Error?D.message:"Failed to load subagents."),w(J=>J??[])}},[n,t]);v.useEffect(()=>{N();const D=window.setInterval(()=>{document.hidden||N()},i3);function J(){document.hidden||N()}return document.addEventListener("visibilitychange",J),()=>{window.clearInterval(D),document.removeEventListener("visibilitychange",J)}},[N]),v.useEffect(()=>{f.current+=1;const D=f.current;return g.current=!1,p.current=!0,_.current=null,G([]),ee(null),Z(!1),ue(null),O&&K(null,"initial",D),()=>{f.current===D&&(f.current+=1)}},[n,t,O,ae]),v.useLayoutEffect(()=>{const D=u.current;if(!D)return;if(p.current){if(Y||te.length===0)return;p.current=!1;const Ce=()=>{D.scrollTop=D.scrollHeight};Ce(),window.requestAnimationFrame?.(Ce);return}const J=_.current;J!==null&&(_.current=null,D.scrollTop+=D.scrollHeight-J)},[te,Y,ae]);async function K(D,J,Ce=f.current){const Ee=O;if(!(!Ee||g.current)){g.current=!0,J==="initial"?ie(!0):(R(!0),_.current=u.current?.scrollHeight??null),ue(null);try{let $=D,Te=0,_e=0,pe=[];for(;f.current===Ce;){const Ie=await n.getTerminalSubagentTranscriptHistory(t,Ee,{...$?{cursor:$}:{},limit:n3,maxLines:s3,includeTools:ae});if(f.current!==Ce)return;if(!Ie.source){if(_e<1){_e+=1,await new Promise(Ke=>setTimeout(Ke,600));continue}ue("Subagent transcript is unavailable.");return}const Ue=v_(Ie.output,Ie.source.provider,{includeTools:ae});if(ee(Ie.cursor),Z(!!(Ie.hasMore&&Ie.cursor)),Ue&&(pe=[Ue,...pe],Rf(pe,ae))){G(Ke=>J==="older"?[...pe,...Ke]:pe);return}if(!Ie.hasMore||!Ie.cursor||Te>=r3){pe.length>0&&G(Ke=>J==="older"?[...pe,...Ke]:pe);return}$=Ie.cursor,Te+=1}}catch($){if(f.current!==Ce)return;ue($ instanceof Error?$.message:"Failed to load subagent transcript.")}finally{f.current===Ce&&(g.current=!1,ie(!1),R(!1))}}}function de(){const D=u.current;D&&(D.scrollTop>72||!V||!ge||g.current||K(ge,"older"))}function ke(D){F(J=>{const Ce=new Set(J);return Ce.delete(D)||Ce.add(D),Ce})}function Ne(D){b.current=!0,q(!0),D.id!==O&&A(D.id),Re(D.id)}function Re(D){const J=c3(C??[],D);J.length!==0&&F(Ce=>{if(J.every($=>Ce.has($)))return Ce;const Ee=new Set(Ce);for(const $ of J)Ee.add($);return Ee})}function Le(){f.current+=1;const D=f.current;g.current=!1,p.current=!0,_.current=null,G([]),ee(null),Z(!1),ue(null),K(null,"initial",D)}const Ae=v.useMemo(()=>Rf(te,ae),[te,ae]),We=v.useMemo(()=>Fk(Ae),[Ae]),Pe=C===null;v.useEffect(()=>{if(Y||B||!V||!ge||g.current)return;const D=u.current;!D||te.length===0||D.scrollHeight<=D.clientHeight+4&&K(ge,"older")},[te,V,ge,Y,B]);const He=C?.filter(D=>D.state==="working").length??0,fe=v.useMemo(()=>Yk(o3(C??[]),W),[C,W]);return h.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),c()},children:h.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":U?"transcript":"list",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>D.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"transcript-dialog-title",children:[h.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",C&&C.length>0?h.jsx("span",{className:"subagents-count",children:He>0?`${He} working · ${C.length} total`:`${C.length} total`}):null]}),h.jsxs("span",{title:r.sessionId,children:[il(r.provider)," session ",r.sessionId]})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),h.jsxs("div",{className:"subagents-body",children:[h.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[Pe?h.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Pe&&x?h.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!Pe&&!x&&C!==null&&C.length===0?h.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,fe.map(D=>{const J=D.subagent,Ce=W.has(J.id);return h.jsxs("div",{className:"subagent-row-wrap",style:D.level>0?{paddingLeft:`${Math.min(D.level,4)*14}px`}:void 0,children:[D.nestedCount>0?h.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":Ce,"aria-label":`${Ce?"Collapse":"Expand"} ${D.nestedCount} nested subagents of ${J.name}`,title:D.nestedWorkingCount>0?`${D.nestedCount} nested · ${D.nestedWorkingCount} working`:`${D.nestedCount} nested`,onClick:()=>ke(J.id),children:[h.jsx("span",{"aria-hidden":"true",children:Ce?"▾":"▸"}),h.jsx("span",{className:"subagent-expander-count","data-working":D.nestedWorkingCount>0?"true":"false",children:D.nestedCount})]}):h.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),h.jsxs("button",{type:"button",className:"subagent-row","data-selected":J.id===O?"true":"false","data-state":J.state,disabled:!J.hasTranscript,title:J.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Ne(J),children:[h.jsx("span",{className:"subagent-row-dot","data-state":J.state,"aria-hidden":"true"}),h.jsxs("span",{className:"subagent-row-main",children:[h.jsxs("span",{className:"subagent-row-title",children:[h.jsx("strong",{children:J.name}),h.jsx("span",{className:"subagent-row-badge","data-kind":J.kind,children:J.kind==="cross"?il(J.provider):J.provider})]}),J.description?h.jsx("span",{className:"subagent-row-description",children:J.description}):null,h.jsxs("span",{className:"subagent-row-meta",children:[h3(J.state),J.model?` · ${J.model}`:"",J.updatedAt?` · ${f3(J.updatedAt)}`:"",D.nestedCount>0&&!Ce?` · ${D.nestedCount} nested${D.nestedWorkingCount>0?` (${D.nestedWorkingCount} working)`:""}`:""]})]})]})]},J.id)})]}),h.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[h.jsxs("div",{className:"subagents-transcript-controls",children:[h.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>q(!1),children:"‹ List"}),h.jsx("span",{className:"subagents-transcript-name",children:xe?xe.name:"Select a subagent"}),h.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[h.jsx("input",{type:"checkbox",checked:ae,onChange:D=>P(D.currentTarget.checked)}),"Show tool output"]}),h.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!xe,onClick:Le,children:"↻"})]}),xe?h.jsx("div",{className:"subagents-transcript-hint",children:u3(xe)}):null,h.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:de,children:[B?h.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!Y&&V?h.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Ae?h.jsx(Hk,{entries:We,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,Y?h.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!Y&&xe&&!Ae&&!I?V&&ge?h.jsxs("div",{className:"transcript-dialog-status",children:[ae?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",h.jsx("button",{type:"button",onClick:()=>{K(ge,"older")},disabled:B,children:"Search earlier entries"})]}):h.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!xe&&!Pe&&!Ae?h.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,I?h.jsx("div",{className:"transcript-dialog-error",children:I}):null]})]})]})]})})});function o3(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=l3(r,t);o?o.children.push(r):n.push(r)}for(const r of n)qk(r);return Vk(n),n}function l3(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 qk(e){let t=0,n=0;for(const r of e.children)qk(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,Vk(e.children)}function Vk(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 Yk(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(...Yk(o.children,t,n+1));return r}function c3(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 u3(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 d3(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 h3(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function f3(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 p3{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():Qk.has(t)?this.acceptConsonant(t):Jk.has(t)?this.acceptVowel(t):_3(t)&&this.canReplacePendingWith(t)?(this.pending=$1(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(eT.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=v3.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=g3.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=K1.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=W1({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=K1.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=$1(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=W1(this.pending);return this.pending=null,t}}const Mf=44032,Nf=21,Xl=28,m3=19*Nf*Xl,Xk=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Gk=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],Zk=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Qk=Fb(Xk),Jk=Fb(Gk),eT=Fb(Zk),g3=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),tT=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],v3=new Map(tT),K1=new Map(tT.map(([e,t])=>[t,[e[0],e[1]]]));function Fb(e){return new Map(e.map((t,n)=>[t,n]))}function _3(e){const t=e.codePointAt(0);return t!==void 0&&t>=Mf&&t<Mf+m3}function $1(e){const t=e.codePointAt(0)-Mf,n=Math.floor(t/(Nf*Xl)),r=Math.floor(t%(Nf*Xl)/Xl),o=t%Xl,c={initial:Xk[n],vowel:Gk[r]};return o===0?c:{...c,final:Zk[o]}}function W1(e){if(!e.vowel)return e.initial;const t=Qk.get(e.initial),n=Jk.get(e.vowel),r=e.final?eT.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Mf+(t*Nf+n)*Xl+r)}const b3=[{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 y3({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return h.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[h.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"}),b3.map(u=>h.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),h.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const S3={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function w3(e){return S3[e]}function C3(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const iT="--nterminal-viewport-height",nT="--nterminal-keyboard-inset-bottom",sT="data-nterminal-keyboard-visible",op="data-nterminal-compose-open",Af="nterminal:viewport-refresh",x3=120;function k3(e=window){const t=e.document.documentElement,n=e.visualViewport,r=N3(e);function o(){Kb(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(Af,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(Af,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(iT),t.style.removeProperty(nT),t.removeAttribute(sT)}}function Kb(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=__(e),o=T3(e,r);return o!==null&&q1(t,iT,`${o}px`),q1(t,nT,`${n}px`),E3(t,sT,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function __(e=window){const t=D3(e);return{keyboardInsetBottom:t,keyboardVisible:t>x3}}function T3(e,t){if((e.document.documentElement.hasAttribute(op)||t)&&Go(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Go(n)?n:Go(e.innerHeight)?e.innerHeight:null}function Go(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function q1(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function E3(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function D3(e){return Math.max(R3(e),M3(e))}function R3(e){const t=e.visualViewport?.height;if(!Go(t)||!Go(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 M3(e){if(!Go(e.innerHeight))return 0;const n=rT(e)?.boundingRect?.height;return!Go(n)||n>=e.innerHeight*.8?0:Math.round(n)}function rT(e){return e.navigator.virtualKeyboard}function N3(e){const t=rT(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const gd=new Map,Zu=new Map,A3=Object.freeze({open:!1,text:""});function L3(e){let t=Zu.get(e);return t||(t=new Set,Zu.set(e,t)),t}function aT(e){const t=Zu.get(e);if(t)for(const n of Array.from(t))n()}function ec(e){return gd.get(e)??A3}function O3(e,t){const n=L3(e);return n.add(t),()=>{n.delete(t)}}function B3(e,t){const n=ec(e);n.open!==t&&(gd.set(e,{...n,open:t}),aT(e))}function j3(e,t){const n=ec(e);n.text!==t&&(gd.set(e,{...n,text:t}),aT(e))}function _u(e){gd.delete(e),Zu.delete(e)}function V1(){gd.clear(),Zu.clear()}const no=new Map,Qu=new Map,Lf=new Map,I3=Object.freeze([]);function Ju(e){return no.get(e)??I3}function P3(e,t){let n=Qu.get(e);return n||(n=new Set,Qu.set(e,n)),n.add(t),()=>n?.delete(t)}function zg(e,t){t.length!==0&&(no.set(e,[...Ju(e),...t]),lp(e))}function Hg(e){const t=Lf.get(e)??1;return Lf.set(e,t+1),`attach${t}`}function b_(e){Lf.delete(e)}function bu(e,t,n){const r=Ju(e);r.length!==0&&(no.set(e,r.map(o=>t.has(o.id)?n(o):o)),lp(e))}function zh(e,t){const n=Ju(e);n.find(c=>c.id===t)?.cancel?.();const o=n.filter(c=>c.id!==t);o.length!==n.length&&(o.length===0?no.delete(e):no.set(e,o),lp(e))}function oT(e){const t=no.get(e);if(t){for(const n of t)n.cancel?.();no.delete(e),lp(e)}}function $l(e){oT(e),b_(e),Qu.delete(e)}function Y1(){for(const e of Array.from(no.keys()))$l(e);Qu.clear(),Lf.clear()}function lp(e){for(const t of Array.from(Qu.get(e)??[]))t()}class z3 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Gl(e){return e?Array.from(e.types??[]).includes("Files")||Wb(e.items).some(n=>n.kind==="file")?!0:hT(e.files).length>0:!1}async function lT(e){const t=Wb(e.items).filter(n=>n.kind==="file");return t.length>0?U3(t):cT(e.files)}function H3(e){const t=Wb(e.items).filter(o=>o.kind==="file").flatMap(o=>{const c=o.getAsFile();return c?[{relativePath:$b(c),file:c}]:[]}),n=cT(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=>W3(c.file,o.file))||r.push(o);return r}async function U3(e){const t=[];for(const n of e){const r=q3(n);if(r){await uT(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:$b(o),file:o});continue}throw new z3("Folder upload is not supported by this browser.")}return t}function cT(e){return hT(e).map(t=>({relativePath:$b(t),file:t}))}async function uT(e,t,n){const r=Y3(t,e.name);if(e.isFile){const u=await F3(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await K3(o);for(const u of c)await uT(u,r,n)}function F3(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function K3(e){const t=[];for(;;){const n=await $3(e);if(n.length===0)return t;t.push(...n)}}function $3(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function $b(e){const t=e.webkitRelativePath;return dT(typeof t=="string"&&t?t:e.name)}function W3(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified}function q3(e){const t=e.webkitGetAsEntry?.();return V3(t)?t:null}function V3(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 Y3(e,t){return dT(e?`${e}/${t}`:t)}function dT(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Wb(e){return e?Array.from(e):[]}function hT(e){return e?Array.from(e):[]}const X3=120,G3="\x1B[200~",Z3="\x1B[201~";function Ug(e,t){const n=t.stripTrailingLineBreaks===!1?e:qb(e),r=J3(n);return r?t.bracketedPasteMode?`${G3}${r}${Z3}`:r:""}function Q3(e){return e==="queue"?" ":"\r"}function qb(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function J3(e){return e.replace(/\r\n/g,`
49
- `).replace(/\r/g,`
50
- `).replace(/\n/g,"\r")}const eB=420,tB=3e3,X1=650,iB=80,nB=3,sB=10,rB=50*1024*1024,aB=100*1024*1024,oB=2,lB={maxFiles:sB,maxFileBytes:rB,maxBatchBytes:aB},sf=new Set;let tc=null;function cB({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const f=v.useMemo(()=>D=>O3(e,D),[e]),g=v.useMemo(()=>()=>ec(e),[e]),p=v.useSyncExternalStore(f,g,g),{open:_,text:b}=p,C=v.useMemo(()=>D=>P3(e,D),[e]),w=v.useMemo(()=>()=>Ju(e),[e]),x=v.useSyncExternalStore(C,w,w),[M,O]=v.useState(lB),[A,W]=v.useState(!1),F=v.useRef(null),U=v.useRef(null),q=v.useRef(null),ae=v.useRef(null),P=v.useRef(new Map),te=v.useRef(c),G=v.useRef(u),ge=v.useRef(null),ee=v.useRef({start:0,end:0});te.current=c,G.current=u,v.useEffect(()=>()=>{ge.current?.(),ge.current=null},[]),v.useEffect(()=>{if(!_||!te.current)return;let D=!0;return te.current().then(J=>{D&&O(J)}).catch(()=>{}),()=>{D=!1}},[_,e]),v.useLayoutEffect(()=>{if(!(!_||!rf()))return vB(e),()=>_B(e)},[_,e]),v.useLayoutEffect(()=>{const D=F.current?.closest(".terminal-pane");if(!D)return;function J(){D?.removeAttribute("data-compose-open"),D?.style.removeProperty("--compose-drawer-panel-height")}if(!_){J();return}const Ce=U.current;D.setAttribute("data-compose-open","true");function Ee(){const pe=Ce?.getBoundingClientRect().height??0;pe>0&&D?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(pe)}px`)}Ee();const $=[window.setTimeout(Ee,0),window.setTimeout(Ee,180),window.setTimeout(Ee,260)],Te=window.requestAnimationFrame?.(Ee)??null,_e=typeof ResizeObserver=="function"&&Ce?new ResizeObserver(Ee):null;return _e&&Ce&&_e.observe(Ce),()=>{for(const pe of $)window.clearTimeout(pe);Te!==null&&window.cancelAnimationFrame?.(Te),_e?.disconnect(),J()}},[_]),v.useEffect(()=>{if(!_){ge.current?.(),ge.current=null;return}Wg(q.current),Pe()},[_]);function V(D){B3(e,D)}function Z(D){j3(e,D)}function Y(){gB(F.current),V(!1),Q1()}function ie(D="send"){const J=x.filter(Ee=>Ee.status==="uploaded"&&Ee.path);if(r||x.some(Ee=>Ee.status==="uploading"||Ee.status==="failed")||!b&&J.length===0)return;const Ce=hB(b,x);if(Ce.parts.some(Ee=>Ee.kind==="image"||Ee.value.trim())&&t(Ce,D)){if(Z(""),oT(e),b_(e),rf()){q.current?.blur(),Q1();return}window.setTimeout(()=>q.current?.focus(),X3+20)}}async function B(D){if(r||D.length===0)return;const J=Ju(e).filter(Ue=>Ue.status!=="failed"),Ce=J.reduce((Ue,Ke)=>Ue+Ke.file.size,0);let Ee=0,$=J.length;const Te=[],_e=D.filter((Ue,Ke)=>{const nt=Ce+Ee+Ue.file.size,Mt=Ue.file.size>M.maxFileBytes?`File exceeds the ${Z1(M.maxFileBytes)} attachment limit.`:$>=M.maxFiles?`A compose message can include up to ${M.maxFiles} attachments.`:nt>M.maxBatchBytes?`Compose attachments cannot exceed ${Z1(M.maxBatchBytes)} in total.`:null;return Mt?(Te.push({id:Kg(Ke),reference:Hg(e),file:Ue.file,relativePath:G1(Ue.relativePath,Ue.file.name),status:"failed",error:Mt}),!1):($+=1,Ee+=Ue.file.size,!0)});if(Te.length>0&&zg(e,Te),_e.length===0)return;const pe=new Map,Ie=_e.map((Ue,Ke)=>{const nt=Kg(Ke),Mt=new AbortController;return pe.set(nt,Mt),{id:nt,reference:Hg(e),file:Ue.file,relativePath:G1(Ue.relativePath,Ue.file.name),status:"uploading",loaded:0,total:Ue.file.size,cancel:()=>Mt.abort()}});zg(e,Ie),He(Ie.map(Ue=>Ue.reference));for(const Ue of Ie)P.current.set(Ue.id,pe.get(Ue.id));await mB(Ie,oB,async Ue=>{const Ke=pe.get(Ue.id),nt=new Set([Ue.id]);try{const ht=(await o([{relativePath:Ue.relativePath,file:Ue.file}],{signal:Ke.signal,onProgress:Dt=>{bu(e,nt,vt=>({...vt,loaded:Dt.loaded,total:Dt.total}))}})).results[0];if(Ke.signal.aborted){const Dt=G.current;ht?.status==="uploaded"&&ht.attachmentId&&Dt&&Dt([ht.attachmentId]).catch(()=>{});return}bu(e,nt,Dt=>{const{error:vt,cancel:$t,...si}=Dt;return ht?.status==="uploaded"&&ht.path?{...si,status:"uploaded",...ht.attachmentId?{attachmentId:ht.attachmentId}:{},path:ht.path,loaded:ht.size??Dt.file.size,total:ht.size??Dt.file.size}:{...si,status:"failed",error:ht?.error??"upload_failed"}})}catch(Mt){const ht=Ke.signal.aborted?"Upload canceled.":$g(Mt);bu(e,nt,Dt=>{const{cancel:vt,...$t}=Dt;return{...$t,status:"failed",error:ht}})}finally{P.current.get(Ue.id)===Ke&&P.current.delete(Ue.id)}})}function R(D){if(D.status!=="removing"){if(fe(D.reference),D.status!=="uploaded"&&D.status!=="failed"||!D.attachmentId||!G.current){P.current.delete(D.id),zh(e,D.id);return}ue([D])}}function I(){Z(""),b_(e);const D=x.filter(J=>!!(J.path&&J.attachmentId));for(const J of x)D.includes(J)||(P.current.delete(J.id),zh(e,J.id));D.length>0&&ue(D)}function ue(D){const J=D.flatMap(Ee=>Ee.attachmentId?[Ee.attachmentId]:[]);if(J.length===0||!G.current){for(const Ee of D)zh(e,Ee.id);return}const Ce=new Set(D.map(Ee=>Ee.id));bu(e,Ce,Ee=>{const{error:$,...Te}=Ee;return{...Te,status:"removing"}}),G.current(J).then(()=>{for(const Ee of D)zh(e,Ee.id)}).catch(Ee=>{bu(e,Ce,$=>({...$,status:"failed",error:`Could not remove attachment: ${$g(Ee)}`}))})}function xe(D){const J=Array.from(D.currentTarget.files??[]).map(Ce=>({relativePath:Ce.name,file:Ce}));D.currentTarget.value="",B(J)}function N(D){const J=H3(D.clipboardData);J.length!==0&&(D.preventDefault(),B(J))}function K(D){r||!Gl(D.dataTransfer)||(D.preventDefault(),D.stopPropagation(),D.dataTransfer.dropEffect="copy",W(!0))}function de(D){r||!Gl(D.dataTransfer)||(D.preventDefault(),D.stopPropagation(),W(!0))}function ke(D){if(!Gl(D.dataTransfer))return;const J=D.relatedTarget;J instanceof Node&&D.currentTarget.contains(J)||W(!1)}function Ne(D){Gl(D.dataTransfer)&&(D.preventDefault(),D.stopPropagation(),W(!1),lT(D.dataTransfer).then(B).catch(J=>{const Ce={id:Kg(0),reference:Hg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:$g(J)};zg(e,[Ce])}))}const Re=x.some(D=>D.status==="uploading"),Le=x.some(D=>D.status==="failed"),Ae=x.filter(D=>D.status==="uploaded"&&D.path).length,We=!r&&!Re&&!Le&&(!!b||Ae>0);function Pe(){rf()&&(ge.current?.(),ge.current=bB())}function He(D){if(D.length===0)return;const J=D.map(Mt=>`@${Mt}`).join(" "),Ce=ec(e).text,Ee=Math.min(ee.current.start,Ce.length),$=Math.min(Math.max(Ee,ee.current.end),Ce.length),Te=Ce.slice(0,Ee),_e=Ce.slice($),pe=Te&&!/\s$/.test(Te)?" ":"",Ie=_e&&!/^\s/.test(_e)?" ":"",Ue=`${pe}${J}${Ie}`,Ke=`${Te}${Ue}${_e}`,nt=Te.length+Ue.length;ee.current={start:nt,end:nt},Z(Ke),window.requestAnimationFrame(()=>{const Mt=q.current;Mt&&(Wg(Mt),Mt.setSelectionRange(nt,nt))})}function fe(D){const J=ec(e).text,Ce=J.replace(new RegExp(`@${pB(D)}(?![A-Za-z0-9_])`,"g"),"");Ce!==J&&Z(Ce.replace(/[ \t]{2,}/g," "))}return h.jsxs("div",{ref:F,className:"compose-drawer","data-open":_?"true":"false",children:[h.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:()=>V(!0),children:[h.jsx("span",{"aria-hidden":"true",children:"▴"}),h.jsx("span",{children:"compose"}),b||x.length>0?h.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),h.jsxs("div",{ref:U,className:"compose-drawer-panel","aria-hidden":_?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:de,onDragOver:K,onDragLeave:ke,onDrop:Ne,children:[A?h.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,h.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:Y,children:[h.jsx("span",{"aria-hidden":"true",children:"▾"}),h.jsx("span",{className:"compose-drawer-title",children:"compose"}),h.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"}),h.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),h.jsx("textarea",{ref:q,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:_?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:D=>{ee.current={start:D.target.selectionStart,end:D.target.selectionEnd},Z(D.target.value)},onSelect:D=>{ee.current={start:D.currentTarget.selectionStart,end:D.currentTarget.selectionEnd}},onPaste:N,onFocus:Pe,onKeyDown:D=>{if(D.key==="Enter"&&(D.metaKey||D.ctrlKey)){if(D.preventDefault(),D.shiftKey){n&&ie("queue");return}ie("send");return}D.key==="Escape"&&(D.preventDefault(),Y())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),h.jsx("input",{ref:ae,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:xe}),x.length>0?h.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:x.map(D=>h.jsx(uB,{attachment:D,onRemove:()=>R(D)},D.id))}):null,h.jsxs("div",{className:"compose-drawer-actions",children:[h.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:_?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>ae.current?.click(),disabled:r,children:"+"}),h.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:_?0:-1,onClick:()=>{I(),Wg(q.current),Pe()},disabled:!b&&x.length===0,children:"Clear"}),n?h.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:()=>ie("queue"),disabled:!We,children:"Queue"}):null,h.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:_?0:-1,title:Le?"Remove failed attachments before sending.":void 0,onClick:()=>ie("send"),disabled:!We,children:"Send"})]})]})]})}function uB({attachment:e,onRemove:t}){const n=dB(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 h.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?h.jsx("img",{src:n,alt:""}):h.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),h.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),h.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),h.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"}),h.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function dB(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 hB(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&&(Fg(r,e.slice(c,u.index)),f.status==="uploaded"&&f.path&&(fB(f)?r.push({kind:"image",path:f.path}):Fg(r,f.path)),c=o.lastIndex)}return Fg(r,e.slice(c)),{parts:r}}function Fg(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 fB(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function pB(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G1(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Kg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function $g(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function Z1(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 mB(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 gB(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Wg(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function rf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Q1(){if(!rf())return;const e=Zl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function vB(e){tc!==null&&(window.clearTimeout(tc),tc=null),sf.add(e),document.documentElement.setAttribute(op,"true"),Zl()}function _B(e){if(sf.delete(e),sf.size>0||tc!==null){Zl();return}tc=window.setTimeout(()=>{if(tc=null,sf.size>0){Zl();return}document.documentElement.removeAttribute(op),Zl()},eB),Zl()}function bB(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,f=yB();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),f?.removeEventListener("geometrychange",b))}function _(C){if(!e){if(C<X1&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,iB)}}function b(){if(e)return;g();const C=Kb(),w=Date.now()-c;if(C.keyboardInsetBottom>0&&C.keyboardInsetBottom===r?o+=1:(o=C.keyboardInsetBottom>0?1:0,r=C.keyboardInsetBottom),w>=tB||w>=X1&&o>=nB){p();return}_(w)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),f?.addEventListener("geometrychange",b),b(),p}function Zl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Kb()}function yB(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function SB(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(xB(u))return u.preventDefault(),u.stopPropagation(),wB(e),!1;if(CB(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(kB(u)){const f=y_(e);return f?(u.preventDefault(),u.stopPropagation(),S_(f),!1):!0}return TB(u)?(u.preventDefault(),u.stopPropagation(),EB(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const f=y_(e);if(f){if(u.clipboardData){u.clipboardData.setData("text/plain",f),u.preventDefault();return}u.preventDefault(),S_(f)}},c=u=>{const f=u.clipboardData?.getData("text/plain");if(!f)return;const g=qb(f);u.preventDefault(),u.stopImmediatePropagation(),fT(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 wB(e){const t=y_(e);t&&await S_(t)}function CB(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function xB(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 kB(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function TB(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 EB(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;fT(e,qb(n),t)}catch{}}function fT(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function y_(e){return e.hasSelection()?e.getSelection():DB(e.element??null)}function DB(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 S_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}RB(e)}function RB(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 MB=[4,10,11,12];function NB(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>J1(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>J1(r)),e.parser.registerCsiHandler({final:"n"},r=>AB(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>LB(r)),e.parser.registerCsiHandler({final:"t"},r=>OB(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...MB.map(r=>e.parser.registerOscHandler(r,o=>BB(o)))];return{dispose(){for(const r of n)r.dispose()}}}function J1(e){return cp(e)===0}function AB(e){const t=cp(e);return t===5||t===6}function LB(e){return cp(e)===6}function OB(e){const t=cp(e);return t===14||t===16||t===18}function BB(e){return e.split(";").some(t=>t==="?")}function cp(e){const t=e[0];return typeof t=="number"?t:0}const Ks=new Map,qg=2*1024*1024,jB=1500,eC=25e3,IB=2500,PB=2500,zB=1e3,HB=2e3,UB=3e4,FB=16*1024*1024,w_=256,pT=AR-3e4,KB=3e3,mT=1e4,$B=3e3,C_=16*1024*1024,up=4*1024*1024,Of=25,WB=1e3,qB=3e3,Vg=8,VB=100,gT=1e3,tC=[2e3,5e3,15e3,6e4];let YB=0,XB=0,Yg=0,Xg=null,af=!1,x_=0,of=0,Za=!1,iC=!1,zu=null,nC=!1,k_=0,ed=document.visibilityState!=="hidden";const Bf=new Set;let ic=null,Hu=0;const GB=new TextEncoder,ZB=b5();function QB(e,t){e5(),o5(),Jf()&&Vr(0);let n=Ks.get(e);n||(n=n5(e),Ks.set(e,n),gc(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Yb(n));const o=(f,g)=>c5(n,f,g),c=f=>{f?(n.foregroundAttachments.add(r),jf(),bT(n)):(n.foregroundAttachments.delete(r),T_())},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),T_()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function Wl(e){const t=Ks.get(e);t&&(_5(t),Ks.delete(e),T_())}function JB(e){const t=Ks.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),ao(t),Hs(t),pr(t),oo(t),hr(t,"reconnecting"),co(t);const n=t.socket;return t.socket=null,qa(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),gc(t),!0}function e5(){if(nC)return;nC=!0;const e=()=>{if(document.visibilityState==="hidden"){ed=!1,k_+=1,yT(),_T(),t5();return}Vb(),Hu=Date.now(),jf()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),jf()}function jf(){ic!==null||document.visibilityState==="hidden"||!vT()||typeof window.requestAnimationFrame!="function"||(ic=window.requestAnimationFrame(()=>{if(ic=null,document.visibilityState==="hidden")return;const e=Date.now(),t=Hu>0?e-Hu:0;if(Hu=e,t>=HB){for(const n of Ks.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&so("terminal.connection.foreground_gap",n,{gapMs:t});Vb(void 0,{foregroundOnly:!0})}jf()}))}function vT(){for(const e of Ks.values())if(e.foregroundAttachments.size>0)return!0;return!1}function T_(){vT()||(_T(),Hu=0)}function _T(){ic!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(ic),ic=null}function bT(e){if(document.visibilityState!=="hidden"){if(!ed||e?.heartbeatSuspended){Vb(e);return}e&&E_(e)}}function Vb(e,t={}){if(document.visibilityState==="hidden")return;ed=!0;const n=++k_;yT();const r=Array.from(Ks.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=r.filter(f=>f===e||f.foregroundAttachments.size>0||d5(f)),c=new Set(o),u=r.filter(f=>!c.has(f));for(const f of o)E_(f);if(!t.foregroundOnly)for(let f=0;f<u.length;f+=Vg){const g=u.slice(f,f+Vg),p=Math.floor(f/Vg)*VB,_=window.setTimeout(()=>{if(Bf.delete(_),!(n!==k_||!ed||document.visibilityState==="hidden"))for(const b of g)E_(b)},p);Bf.add(_)}}function yT(){for(const e of Bf)window.clearTimeout(e);Bf.clear()}function E_(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,gc(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<zB)return Promise.resolve("alive");hr(e,"reconnecting"),co(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++YB).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||(so("terminal.connection.resume_timeout",e,{pendingInputs:Qa(e)}),hr(e,"reconnecting"),Ja(e))},IB);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{hr(e,"reconnecting"),Ja(e)}return c}function t5(){ed=!1;for(const e of Ks.values())e.heartbeatSuspended=!0,ao(e),Hs(e),pr(e),oo(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,hr(e,"skipped"),co(e)}function i5(){Za=!1,Jf()&&Vr(0);for(const e of Ks.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),ao(e),Hs(e),pr(e),oo(e),hr(e,"reconnecting"),co(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,qa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),gc(e)}}function Gg(){for(const e of Array.from(Ks.keys()))Wl(e)}function n5(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:Of,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 gc(e){if(!e.reconnectEnabled)return;qa(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Hs(e),pr(e),oo(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,ao(e),Hs(e),qa(e,"connected"),ro(e,t),ST(e,t),e.isAlive=!0,sC(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(E5(c)){D5(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),Za&&(Za=!1,Jf()&&Vr(0));return}if(e.inputProtocolMode==="unknown"&&xT(e,t),c.type==="pong"){e.isAlive=!0;const f=e.resumeProbe;f?.socket===t&&f.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),Qa(e)>0&&so("terminal.connection.resume_alive",e,{pendingInputs:Qa(e)}),hr(e,"alive"),ro(e,t),sC(e),nl(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(id(e),so("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:Qa(e)}),Ja(e));return}if(c.type==="input_ack"){C5(e,t,c);return}if(c.type==="input_received"){x5(e,t,c);return}if(c.type==="error"&&k5(e,c),c.type==="input_ack_confirmed"){M5(e,c);return}const u=r5(e,c);if(td(e,{type:"message",message:u}),c.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;Yb(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",ao(e),Hs(e),pr(e),oo(e),hr(e,"reconnecting"),co(e),r.code===1008){e.reconnectEnabled=!1,qa(e,s5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=UB)&&(e.lastUpgradeAuthProbeAt=o,td(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){qa(e,"closed");return}qa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,gc(e)},jB)}}),t.addEventListener("error",()=>{})}function sC(e){if(co(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>eC*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)}))},eC)}function co(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function s5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function r5(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+Gr(r),0),rC(e),e.exited&&lf(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Gr(t.data),rC(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,lf(e)),t):(t.type==="exit"&&(e.exited=!0,lf(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function rC(e){for(;e.outputBytes>qg&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Gr(t)}e.outputBytes>qg&&e.output.length===1&&(e.output[0]=A5(e.output[0],qg),e.outputBytes=Gr(e.output[0]))}function qa(e,t){e.status!==t&&(e.status=t,td(e,{type:"status",status:t}))}function td(e,t){for(const n of Array.from(e.listeners))n(t)}function Qa(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function a5(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 so(e,t,n={}){vn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:Qa(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??a5(t)}),x_+=1,of=0,Vr(gT)}function o5(){if(iC)return;iC=!0;const e=()=>{document.visibilityState==="hidden"||Za||Jf()&&Vr(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Vr(e){if(af){zu=zu===null?e:Math.min(zu,e);return}Xg!==null||Za||document.visibilityState==="hidden"||navigator.onLine===!1||(Xg=window.setTimeout(()=>{Xg=null,l5()},e))}async function l5(){if(af||Za||document.visibilityState==="hidden"||navigator.onLine===!1)return;af=!0;const e=x_;try{const t=await PR();if(t.outcome==="auth_blocked"){Za=!0;return}if(t.outcome==="retryable"){const n=tC[Math.min(of,tC.length-1)];of+=1,Vr(n);return}if(of=0,t.outcome==="sent"&&t.hasMore){Vr(0);return}}finally{af=!1;const t=zu;zu=null,t!==null&&Vr(t),x_!==e&&!Za&&Vr(gT)}}function c5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=S5(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=Gr(o);if(c>FB)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(!w5(e,f))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(so("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:Qa(e)}),bT(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>up))return!u&&r.type==="input"?"rejected":u5(e,r)?(p&&g&&ro(e,g),"queued"):e.pendingOut.length>=w_||e.pendingOutBytes+c>C_?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=c,oC(e,f),p&&g&&ro(e,g),"queued");if(p){oC(e,f);try{return g.send(o),CT(e,f),"sent"}catch{if(b&&u&&e.pendingOut.length<w_&&e.pendingOutBytes+c<=C_)return e.pendingOut.push(f),e.pendingOutBytes+=c,g.close(),"queued";rl(e,f),g.close()}}return"rejected"}function ro(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Hs(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>up){N5(e,t),f5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){ST(e,t);return}try{t.send(r.encoded),CT(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=Of,n=!0}e.outboundFlushDelayMs=Of,Hs(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&td(e,{type:"outbound_flushed"})})}function u5(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=Gr(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function ao(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=Of}function Hs(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function If(e){return e.pendingOut.some(t=>t.message.type==="input")}function d5(e){return If(e)||e.unackedInputs.size>0}function h5(e){if(!If(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 f5(e,t){e.outboundStallWatchdog!==null||!If(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!If(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>up;if(!n&&!r){ro(e,t);return}h5(e),Ja(e)},qB))}function pr(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function ST(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)&&Ja(e)},$B))}function wT(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function id(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function oo(e){wT(e),id(e)}function nl(e){wT(e),D_(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=aC(e),r=p5(e),o=g5(e);if(n===null&&r===null&&o===null){id(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+KB,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(D_(e,{notifyImmediately:!0})){nl(e);return}if(m5(e),aC(e)===null){nl(e);return}v5(e,t)},u)}function p5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+mT;t=t===null?r:Math.min(t,r)}return t}function m5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<mT||(n.writeSlowReported=!0,so("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function aC(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 g5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+pT;t=t===null?r:Math.min(t,r)}return t}function v5(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>up){Ja(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++XB).toString(36)}`;so("terminal.input.delivery_probe_started",e,{pendingInputs:Qa(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(so("terminal.input.delivery_probe_timeout",e,{pendingInputs:Qa(e)}),id(e),Ja(e))},PB);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{id(e),Ja(e)}}function hr(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Ja(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),ao(e),Hs(e),pr(e),oo(e),hr(e,"reconnecting"),co(e);const t=e.socket;e.socket=null,qa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),gc(e)}function _5(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),ao(e),Hs(e),pr(e),oo(e),hr(e,"skipped"),co(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),lf(e),e.listeners.clear()}function b5(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function y5(){return Yg=(Yg+1)%Number.MAX_SAFE_INTEGER,`${ZB}-${Yg.toString(36)}`.slice(0,px)}function S5(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=y5();return n.length===0||n.length>px?null:{...t,messageId:n}}function w5(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<w_&&e.unackedInputBytes+t.bytes<=C_)}function oC(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function rl(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 C5(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&&R_(e,t,c);return}if(rl(e,r),nl(e),!Xb(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),R_(e,t,o)}function x5(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",nl(e))}function k5(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(rl(e,n),nl(e))}function CT(e,t){if(t.message.type!=="input"||!t.message.messageId||!Xb(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",nl(e)}function T5(e){if(D_(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){rl(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 D_(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>=pT&&(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&&rl(e,u)}return o>0&&(TT(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&&Yb(e)),!0}function E5(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function D5(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){xT(e,t);return}pr(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(T5(e),R5(e,t)):c!==null&&(kT(e),ET(e)),ro(e,t)}function xT(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",pr(e),e.serverInstanceId=null,kT(e),ET(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;rl(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=Gr(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}ro(e,t)}}function kT(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&&rl(e,o)}n>0&&TT(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 TT(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Yb(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)td(e,{type:"message",message:{type:"error",message:n.message}})}}function lf(e){ao(e),Hs(e),pr(e),oo(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function R_(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Xb(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Xb(e){return e==="ack"||e==="receipt-ack"}function R5(e,t){for(const n of e.pendingAckReceipts.values())if(R_(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function M5(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function ET(e){e.pendingAckReceipts.clear()}function N5(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(WB,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,ro(e,t)},n)}function Gr(e){return GB.encode(e).byteLength}function A5(e,t){if(Gr(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);Gr(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 L5=[0,50,150,350],O5=[100,300,750],B5=2,j5=[300,1200,2500],I5=1e3,P5=1e5,z5="",M_="\x1B[?1049l\x1B[?1047l\x1B[?47l",H5=new Set(["47","1047","1049"]),U5=400,F5=9,K5=9,$5=32,W5=1.42,q5=2,V5=24,Y5=720,X5=60,G5=1260,Z5=6,Q5=2,lC=[500,1500,3e3,5e3,8e3],cC=15e3,J5=2,e4=1e3,uC="Do not take action. Wait for my next input.",Pf=6e4,t4=Pf+5*6e4,dC=Pf+6e4,i4=40,Hh=240,n4=5e3,Uu=new Map,ql=new Map;function hC({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:f,onSelect:g,onClose:p,onExit:_,onSnapshot:b,onAuthClose:C}){const w=v.useSyncExternalStore(Bx,kv,()=>Yo),x=v.useSyncExternalStore(jx,Tv,()=>sc),M=v.useSyncExternalStore(Ix,Dv,()=>!0),O=v.useSyncExternalStore(Xh,Rv,()=>!0),A=v.useSyncExternalStore(Xh,Mv,()=>!0),W=v.useSyncExternalStore(tb,eo,()=>nc),F=v.useSyncExternalStore(Bu,()=>ju("history.toggle"),()=>"Alt+H"),U=v.useSyncExternalStore(Bu,()=>ju("scrollback.toggle"),()=>"Alt+S"),q=v.useSyncExternalStore(Bu,()=>ju("subagents.toggle"),()=>"Alt+A"),ae=v.useRef(null),P=v.useRef(null),te=v.useRef(null),G=v.useRef(null),ge=v.useRef(null),ee=v.useRef(e.id),V=v.useRef({onExit:_,onSnapshot:b}),Z=v.useRef(t.createWebSocketUrl),Y=v.useRef(C),ie=v.useRef(null),B=v.useRef(null),R=v.useRef(null),I=v.useRef(!1),ue=v.useRef(new Map),xe=v.useRef(new Map),N=v.useRef(new Set),K=v.useRef([]),de=v.useRef(!1),ke=v.useRef(null),Ne=v.useRef(0),Re=v.useRef(!1),Le=v.useRef(!1),Ae=v.useRef(!1),We=v.useRef({terminalId:e.id,enabled:!1}),Pe=v.useRef([]),He=v.useRef([]),fe=v.useRef(0),D=v.useRef(!1),J=v.useRef(null),Ce=v.useRef(0),Ee=v.useRef(0),$=v.useRef(null),Te=v.useRef(null),_e=v.useRef(!1),pe=v.useRef(!1),Ie=v.useRef(!1),Ue=v.useRef(null),Ke=v.useRef(!1),nt=v.useRef(null),Mt=v.useRef(null),ht=v.useRef(!1),Dt=v.useRef(!1),vt=v.useRef(!1),$t=v.useRef(!1),si=v.useRef(!1),Se=v.useRef(!1),Ve=v.useRef(!1),rt=v.useRef(n),tt=v.useRef(r),kt=v.useRef(c),lt=v.useRef(w),qi=v.useRef(x),li=v.useRef(!1),re=v.useRef(!1),Fe=v.useRef(null),ct=v.useRef(0),ut=v.useRef(0),Lt=v.useRef(e.id),fi=v.useRef(()=>{}),wi=v.useRef(null),at=v.useRef(null),Tt=v.useRef(!1),zt=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),Di=v.useRef(0),Wt=v.useRef(null),nn=v.useRef(0),ii=v.useRef(null),sn=v.useRef(0),_n=v.useRef(!1),Rn=v.useRef(!1),gi=v.useRef(null),fn=v.useRef(null),[,Ri]=v.useState("connecting"),[qt,Qt]=v.useState(!1),[bn,ws]=v.useState(null),[Cs,xs]=v.useState(!1),[Ws,Vn]=v.useState(null),[Yn,ks]=v.useState(!1),[Ts,Xn]=v.useState(!1),[Es,Ht]=v.useState(!1),[uo,qs]=v.useState(!1),[Vt,yn]=v.useState(null),Sn=e.agentCache&&Vt&&e.agentCache.source.provider===Vt.provider&&e.agentCache.source.sessionId===Vt.sessionId?e.agentCache:null,[Jr,ho]=v.useState(()=>Date.now()),[gr,Ds]=v.useState(!1),[ea,pn]=v.useState(null),[Vi,Gn]=v.useState(!1),[fo,Rs]=v.useState(!1),[rn,Ms]=v.useState(null),[_c,Yi]=v.useState(!1),[ta,vr]=v.useState(!1),[ia,an]=v.useState(null),[po,Vs]=v.useState(null),Ci=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[na,sa]=v.useState(()=>Sg(e.id)),Ns=Vt?.provider??e.agentStatus?.provider??null,_r=Ns!==null||Vl(e.currentCommand),ra=Ns==="claude"||AT(e.currentCommand),bc=Ns!==null||Vl(e.currentCommand),As=e.capabilities?.tmuxScrollback===!0,Pi=As&&(na??(bc?A:O)),[mo,Ls]=v.useState(!1);v.useLayoutEffect(()=>{rt.current=n},[n]),v.useLayoutEffect(()=>{tt.current=r},[r]),v.useLayoutEffect(()=>{kt.current=c},[c]),v.useLayoutEffect(()=>{lt.current=w},[w]),v.useLayoutEffect(()=>{qi.current=x},[x]),v.useLayoutEffect(()=>{li.current=Vi},[Vi]),v.useLayoutEffect(()=>{re.current=fo},[fo]),v.useLayoutEffect(()=>{Fe.current=Vt},[Vt]);const Mi=v.useCallback((k,z={})=>{!k&&z.preserveOnNull||(Ph(Fe.current,k)||(ut.current+=1),Fe.current=k,yn(Me=>Me&&k&&Me.provider===k.provider&&Me.sessionId===k.sessionId?Me:k))},[]),br=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),yr=v.useCallback(()=>{const k=Fe.current,z=ut.current;k&&(async()=>{let Me=k;try{Me=await br()??Me}catch{}Me&&Lt.current===e.id&&ut.current===z&&Ph(k,Fe.current)&&(Mi(Me,{preserveOnNull:!0}),wi.current=Jg(e.id,Me),Rs(!1),Gn(!0))})()},[Mi,br,e.id]),go=v.useCallback(()=>{Fe.current&&(Gn(!1),Rs(!0))},[]),wn=v.useCallback(async(k={})=>{const z=await pC(Ci,t,k);return Ms(z),z},[Ci,t]),xi=v.useCallback((k,z="info")=>{ii.current!==null&&window.clearTimeout(ii.current),Vs({id:nn.current++,message:k,tone:z}),ii.current=window.setTimeout(()=>{Vs(null),ii.current=null},3200)},[]),Mn=v.useCallback(()=>{const k=f?.serverKey.trim()||"local",z=f?.serverName.trim()||"Local",Me=f?.tabName.trim()||e.title||"Terminal",Xe=rn?.instances.find(ft=>ft.cwd===e.cwd);if(Xe&&mC(Uh(k,Xe.id))){xi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Xe&&Zg(Uh(k,Xe.id),Xe.url)){xi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let qe=null;const it=()=>((!qe||RT(qe))&&(qe=window.open("about:blank","_blank"),s4(qe)),qe);rn?.installed!==!0&&it(),vr(!0),an(null),(async()=>{let ft=rn;if(ft?.installed||(ft=await wn({force:!0})),!ft?.installed||ft.supported===!1){Qg(qe),Yi(!0);return}const gt=ft.instances.find(Ut=>Ut.cwd===e.cwd);if(gt){const Ut=Uh(k,gt.id);if(gC(qe,Ut,gt.url)||Zg(Ut,gt.url)!==null){xi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Ge=it();return{response:await t.openCodeServer({terminalId:e.id,serverName:z,tabName:Me}),targetPopup:Ge}})().then(ft=>{if(!ft)return;const{response:gt,targetPopup:Ge}=ft;N_(Ci,gt.status),Ms(gt.status);const Jt=Uh(k,gt.instance.id);if(mC(Jt)){Qg(Ge),xi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}gC(Ge,Jt,gt.url)||Zg(Jt,gt.url)?xi("Opening VS Code..."):xi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ft=>{Qg(qe),Yi(!0),an(Fh(ft))}).finally(()=>vr(!1))},[f?.serverName,f?.tabName,Ci,rn,wn,t,xi,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return pC(Ci,t).then(z=>{k||Ms(z)}).catch(()=>{}),()=>{k=!0}},[Ci,t]),v.useEffect(()=>{if(rn?.job?.status!=="running")return;const k=window.setInterval(()=>{wn({force:!0}).catch(z=>an(Fh(z)))},1e3);return()=>window.clearInterval(k)},[rn?.job?.status,wn]),v.useEffect(()=>()=>{ii.current!==null&&window.clearTimeout(ii.current)},[]),v.useLayoutEffect(()=>{fi.current=yr},[yr]),v.useLayoutEffect(()=>{at.current=Sn},[Sn]),v.useLayoutEffect(()=>{Tt.current=gr},[gr]),v.useLayoutEffect(()=>{_n.current=_r},[_r]),v.useLayoutEffect(()=>{Rn.current=ra},[ra]),v.useLayoutEffect(()=>{const k=We.current;Le.current=Pi,Ae.current=As,We.current={terminalId:e.id,enabled:Pi},_C(ae.current,Pi),k.terminalId===e.id&&k.enabled&&!Pi&&ko(),Pi||Ht(!1)},[e.id,Pi,As]),v.useEffect(()=>{sa(Sg(e.id)),Ne.current=0,Re.current=!1,Ht(!1),xo()},[e.id]),v.useEffect(()=>Xh(()=>{sa(Sg(e.id))}),[e.id]),v.useEffect(()=>()=>{hl()},[]),v.useEffect(()=>{ge.current?.(r&&e.status==="running"),r&&e.status==="running"&&Os()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&Bs("auto")},[n,r,e.status]),v.useEffect(()=>{V.current={onExit:_,onSnapshot:b}},[_,b]),v.useLayoutEffect(()=>{Z.current=t.createWebSocketUrl,Y.current=C},[t,C]),v.useLayoutEffect(()=>{ee.current=e.id,Ve.current=!1,qs(!1)},[e.id]),v.useEffect(()=>{let k=!1,z=null,Me=0;const Xe=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",qe=Xe||T4(e.currentCommand),it=Xe||Vl(e.currentCommand);function ft(){z!==null&&(window.clearTimeout(z),z=null)}function gt(Jt){if(k)return;let Ut;if(Jt)Ut=cC;else if(Me<lC.length){if(!qe)return;Ut=lC[Me++]}else{if(!it)return;Ut=cC}z=window.setTimeout(()=>{z=null,Ge()},Ut)}async function Ge(){try{const Jt=Fe.current!==null,Ut=await br();if(k)return;if(Ut){ct.current=0,Mi(Ut),gt(!0);return}ct.current+=1;const Pt=!!(Jt&&qe&&ct.current<J5);Mi(null,{preserveOnNull:Pt}),gt(Pt)}catch(Jt){if(k)return;ev(Jt)&&Mi(null),gt(!1)}}return Lt.current!==e.id&&(Lt.current=e.id,ut.current+=1,Fe.current=null,ct.current=0,yn(null)),e.status!=="running"?(ut.current+=1,Fe.current=null,ct.current=0,yn(null),()=>{k=!0,ft()}):(Ge(),()=>{k=!0,ft()})},[Mi,br,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=Jg(e.id,Vt),z=wi.current;z!==null&&k!==null&&z!==k&&(Te.current=null,_e.current=!1,pe.current=!1,li.current&&Gn(!1),Rs(!1)),wi.current=k},[e.id,Vt?.provider,Vt?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!Vt){Ds(!1);return}const k=window.setInterval(()=>{ho(Date.now())},e4);return()=>{window.clearInterval(k)}},[e.status,Vt?.provider,Vt?.sessionId]),v.useEffect(()=>{const k=o4(Sn);zt.current.key!==k&&(zt.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[Sn?.expiresAt,Sn?.source?.provider,Sn?.source?.sessionId]),v.useEffect(()=>{if(!gr||!Sn||Sn.status!=="ready")return;const k=MT(Sn,Jr);if(k===null||k<=0)return;const z=zt.current;!z.warnedFiveMinutes&&k<=t4&&k>dC&&(z.warnedFiveMinutes=!0,as({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."})),!z.warnedOneMinute&&k<=dC&&k>Pf&&(z.warnedOneMinute=!0,as({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!z.sent&&!z.skipped&&k<=Pf&&Tc()},[gr,Jr,Sn,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(z){if(!rt.current||!tt.current||z.isComposing||z.key==="Process"||u4(z.target))return;const Me=Ux(z);if(Me?.id==="history.toggle"&&Fe.current){z.preventDefault(),z.stopPropagation(),li.current?Gn(!1):fi.current();return}if(Me?.id==="subagents.toggle"&&Fe.current){z.preventDefault(),z.stopPropagation(),re.current?Rs(!1):go();return}if(Me?.id==="scrollback.toggle"&&Ae.current){z.preventDefault(),z.stopPropagation(),kc();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"&&Ri("closed")},[e.status]),v.useEffect(()=>{const k=P.current;k&&(k.options.fontSize=w,yg(w,qi.current).then(()=>{lt.current===w&&Hi()}))},[w]),v.useEffect(()=>{const k=P.current;k&&(k.options.fontFamily=xv(x),yg(lt.current,x).then(()=>{qi.current===x&&Hi()}))},[x]),v.useEffect(()=>{const k=P.current;k&&(k.options.theme=fC(W))},[W]),v.useEffect(()=>{const k=ae.current;if(!k)return;let z=!1,Me=null,Xe=null,qe=null,it=null,ft=null,gt=null,Ge=null;ie.current=null,si.current=!1,Se.current=!1,Ke.current=!1,ll(),da(),Qe(),de.current=!1;const Jt=lt.current,Ut=qi.current,Pt=new VO({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:xv(Ut),fontSize:Jt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:P5,theme:{...fC(eo())}}),er=new PN;return Pt.loadAddon(er),it=NB(Pt),P.current=Pt,te.current=er,yg(Jt,Ut).then(()=>{if(z)return;Pt.open(k),_C(k,Le.current),si.current=!0,Me=SB(Pt,{onPasteText:bp,onInterrupt:_p,shouldInterruptPlainCtrlC:()=>Rn.current}),tt.current&&rt.current&&e.status==="running"&&Bs("auto"),Hi(),ft=A4(k,Pt,()=>lt.current*1.2,ns,tr=>{Sr(tr)},Be,je,()=>Le.current,fa),gt=R4(k,Pt,ns,tr=>{Sr(tr)},Be,je,()=>Le.current,fa);const fl=new p3;Xe=Pt.onData(tr=>{if(Ve.current){const Dc=C3(tr);if(Dc){Eo(!1),Cr(Dc);return}}const Ec=fl.accept(tr);Ec&&Cr(Ec)}),qe=Pt.onScroll(tr=>{if(Dt.current||$t.current||vt.current){ni();return}Co(),Wn(Pt)&&T({scrollToBottom:!0}),ns(),!Le.current&&tr<=3&&Sr()}),Ge=new ResizeObserver(()=>{Qs()}),Ge.observe(k),Se.current&&(Xs(),Se.current=!1,Hi()),So()}),()=>{bd(G.current,{updateUi:!1}),z=!0,si.current=!1,Se.current=!1,ll(),da(),B.current=null,R.current=null,I.current=!1,cl(),de.current=!1,ul(),vt.current=!1,D.current=!1,Ce.current+=1,Ee.current+=1,J.current=null,gi.current=null,fn.current=null,Ie.current=!1,Ue.current=null,Qt(!1),ft?.(),gt?.(),Ge?.disconnect(),Me?.dispose(),Xe?.dispose(),qe?.dispose(),it?.dispose(),Pt.dispose(),P.current=null,te.current=null}},[e.id]),v.useEffect(()=>{const k=Z.current(e.id),z=QB(k,Ys);return G.current=z.send,ge.current=z.setForeground,z.setForeground(tt.current&&e.status==="running"),Ri(z.status),z.status==="connected"&&Hi(),z.snapshot&&(V.current.onSnapshot(z.snapshot,{notifyCompletion:!1}),P.current&&(Hi(),Qn(z.output,z.history),Hi())),()=>{bd(z.send,{updateUi:!1}),z.setForeground(!1),z.detach(),G.current=null,ge.current=null}},[e.id,e.status]);function Ys(k){if(k.type==="status"){Ri(k.status),k.status==="unauthorized"&&Y.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(Hi(),wr());return}if(k.type==="upgrade_rejected"){Y.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){de.current&&(de.current=!1,pa());return}yc(k.message)}function Qe(k=[],z=null){Pe.current=[],He.current=Kh(k),fe.current=0,D.current=!1,J.current=null,vt.current=!1,Ce.current+=1,$.current=z,Te.current=null,_e.current=!1,pe.current=!1,Ie.current=!1,Ue.current=null,Se.current=!1,gi.current=null,fn.current=null,nt.current=null,ht.current=!1,Qt(!1),ws(null),xs(!1),Vn(null),ks(!1),Xn(!1)}function Qn(k=[],z=null){if(vt.current||D.current){fn.current={output:k,history:z,appendFromLiveOutputIndex:He.current.length};return}Qe(k,z),aa()}function Jn(){if(vt.current||D.current)return!1;const k=fn.current;if(!k)return!1;const z=He.current.slice(k.appendFromLiveOutputIndex);return fn.current=null,Qe([...k.output,...z],k.history),aa(),!0}function aa(){if(!P.current||!si.current){Se.current=!0;return}Se.current=!1,Xs()}async function Xs(){const k=P.current;if(!k)return;const z=$h(k,ht.current),Me=z?He.current.length:fe.current,Xe=await Gs(k,{liveOutputLimit:Me,scrollToBottom:z});P.current===k&&(ni(),Xe&&wr())}function Gs(k,z={}){return new Promise(Me=>{vt.current=!0,D.current=!1;const Xe=Ce.current+1;Ce.current=Xe;const qe=Math.max(0,Math.min(z.liveOutputLimit??He.current.length,He.current.length)),it=z.historyPages??Pe.current,ft=()=>P.current===k&&Ce.current===Xe,gt=()=>ft()&&(z.isCurrent?.()??!0),Ge=()=>{ft()&&(vt.current=!1),Me(!1)},Jt=()=>{if(!gt()){Ge();return}try{fe.current=qe,z.scrollToBottom&&_t(k)}finally{if(vt.current=!1,Jn()){Me(!1);return}const Pt=S();Pt?T(Pt):z.applyDeferredSnapshot!==!1&&be(),Me(!0)}},Ut=()=>{if(!gt()){Ge();return}k.clear();const Pt=Kh([...it,...He.current.slice(0,qe)]);if(Pt.length===0){Jt();return}for(let er=0;er<Pt.length;er+=1){const fl=Pt[er];er===Pt.length-1?k.write(fl,Jt):k.write(fl)}};if(k.buffer.active.type==="alternate"){k.write(M_,Ut);return}Ut()})}async function Sr(k=0){const z=P.current;if(Ie.current||!z)return;if(L(z)){ni();return}const Me=$.current,Xe=Ee.current,qe=Symbol("history-load"),it=()=>P.current===z&&Ee.current===Xe;Ue.current=qe,Ie.current=!0,Qt(!0);const ft=z.buffer.active.viewportY;try{let gt=!!(Me&&!Me.hasMore);if(!gt)try{const Ge=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:I5});if(!it()||$.current!==Me)return;const Jt=()=>it()&&$.current===Me;if(Ge.invalidated){Zs();return}const Ut=Ge.hasMore&&Ge.snapshotHistorySize!==void 0&&Ge.snapshotPaneWidth!==void 0,Pt={startLine:Ge.startLine,endLine:Ge.endLine,hasMore:Ut,...Ge.snapshotHistorySize!==void 0?{snapshotHistorySize:Ge.snapshotHistorySize}:{},...Ge.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ge.snapshotHistoryLimit}:{},...Ge.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ge.snapshotHistoryToken}:{},...Ge.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ge.snapshotPaneWidth}:{}};if(Ge.output.length>0){await es(z,Ge.output,ft,k)&&Jt()&&($.current=Pt);return}if(!Jt())return;$.current=Pt,gt=!Ut}catch(Ge){gt=it()&&ev(Ge)}if(gt){if(!it()||L(z)){ni();return}await zi(z,ft,k,it)}}catch{}finally{Ue.current===qe&&(Ue.current=null,Ie.current=!1,Qt(!1))}}async function zi(k,z,Me,Xe){if(!Xe()||_e.current||pe.current)return;const qe=Fe.current,it=ut.current,ft=Te.current,gt=()=>Xe()&&ut.current===it&&Ph(qe,Fe.current)&&Te.current===ft;try{const Ge=await t.getTerminalTranscriptHistory(e.id,{...ft?{cursor:ft}:{},limit:U5}),Jt=Ge.output.map(Kk);if(!Ge.source||Ge.terminalId!==e.id||!gt())return;if(qe&&!Ub(qe,Ge.source)){Te.current=null,_e.current=!1,pe.current=!1,Mi(Ge.source);return}if(Jt.length===0){Mi(Ge.source),Te.current=Ge.cursor,pe.current=!Ge.hasMore||!Ge.cursor;return}await es(k,Jt,z,Me,gt)&&gt()&&(Mi(Ge.source),Te.current=Ge.cursor,pe.current=!Ge.hasMore||!Ge.cursor)}catch(Ge){gt()&&ev(Ge)&&(_e.current=!0)}}async function es(k,z,Me,Xe,qe){if(L(k)||qe&&!qe())return ni(),!1;const it=Pe.current,ft=[...z,...it],gt=E4(z),Ge=Ce.current+1,Jt=await Gs(k,{liveOutputLimit:fe.current,scrollToBottom:!1,historyPages:ft,applyDeferredSnapshot:!1,...qe?{isCurrent:qe}:{}}),Ut=qe!==void 0&&!qe();return!Jt||Ut||P.current!==k?(Ut&&P.current===k&&Ce.current===Ge&&await Gs(k,{liveOutputLimit:fe.current,scrollToBottom:!1,historyPages:it,applyDeferredSnapshot:!1})&&P.current===k&&(It(k,Me),ht.current=!Wn(k),ns()),!1):(Pe.current=ft,It(k,Math.max(0,Me+gt+Math.min(0,Xe))),ht.current=!Wn(k),ns(),!0)}v.useEffect(()=>{const k=window.visualViewport;function z(){document.visibilityState!=="hidden"&&Os()}function Me(){Os()}function Xe(){Os()}function qe(){Qs()}function it(){bo()}return document.addEventListener("visibilitychange",z),window.addEventListener("pageshow",Me),window.addEventListener("online",Xe),window.addEventListener("resize",qe),window.addEventListener(Af,it),k?.addEventListener("resize",qe),k?.addEventListener("scroll",qe),()=>{document.removeEventListener("visibilitychange",z),window.removeEventListener("pageshow",Me),window.removeEventListener("online",Xe),window.removeEventListener("resize",qe),window.removeEventListener(Af,it),k?.removeEventListener("resize",qe),k?.removeEventListener("scroll",qe)}},[e.id]);function Os(){document.visibilityState==="hidden"||!tt.current||(wr(),Hi())}function Zs(){const k=Z.current(e.id);Ee.current+=1,Ke.current=!0,gi.current=null,Ri("reconnecting"),Hi(),JB(k)}function yc(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Ee.current+=1,V.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Me=Ke.current;Ke.current=!1;const Xe=P.current;if(!Xe)return;if(Hi(),Me){vo(k.output,k.history??null);return}if(Q(Xe,k.terminal)){ce(k.output,k.history??null),ni(),Hi();return}Qn(k.output,k.history??null),Hi();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){V.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Me=LT(k.data);if(!Me)return;He.current.push(Me),P.current&&si.current?T({scrollToBottom:!0}):Se.current=!0;return}const z=P.current;if(z){if(k.type==="exit"&&k.terminalId===e.id){V.current.onExit(k.exitCode),Ri("closed");return}k.type==="error"&&z.writeln(`\r
51
- [nterminal] ${k.message}`)}}function vo(k,z){Qn(k,z),Hi()}function _o(k=25){if(document.visibilityState==="hidden"||!tt.current||ue.current.has(k))return;const z=window.setTimeout(()=>{ue.current.delete(k),!ts()&&mp()},k);ue.current.set(k,z)}function Qs(){ts()||So()}function ts(){const k=la();return k&&is(k)?(I.current=!0,R.current=k,!0):k&&oa(k)?(I.current=!1,R.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(I.current=!1,R.current=null),!1)}function bo(){if(!I.current)return;const k=la();k&&(k.composeOpen||k.keyboardVisible)||(I.current=!1,R.current=null)}function is(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const z=B.current;return z?Js(k.windowWidth,z.windowWidth)&&Js(k.visualViewportWidth,z.visualViewportWidth)&&Js(k.containerWidth,z.containerWidth):!1}function oa(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const z=R.current;return!z||!z.composeOpen&&!z.keyboardVisible?!1:Js(k.windowWidth,z.windowWidth)&&Js(k.visualViewportWidth,z.visualViewportWidth)&&Js(k.containerWidth,z.containerWidth)}function la(){const k=ae.current;if(!k||k.isConnected===!1)return null;const z=k.getBoundingClientRect(),Me=ca(window.innerWidth)??0,Xe=ca(window.visualViewport?.width)??Me,qe=ca(z.width)??ca(k.clientWidth)??Me;if(Me<=0||Xe<=0||qe<=0)return null;const{keyboardVisible:it}=__(),ft=document.documentElement.hasAttribute(op),gt=yo()||it;return{windowWidth:Me,visualViewportWidth:Xe,containerWidth:qe,composeOpen:ft,keyboardVisible:it,mobileLike:gt}}function yo(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Sc(){return __().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function ca(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function Js(k,z){return Math.abs(k-z)<=B5}function So(){for(const k of L5)_o(k)}function Hi(){ie.current=null,So()}function wr(){if(ua(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{N.current.delete(k),ua();const z=window.requestAnimationFrame(()=>{N.current.delete(z),ua()});N.current.add(z)});N.current.add(k)}for(const k of O5){if(xe.current.has(k))continue;const z=window.setTimeout(()=>{xe.current.delete(k),ua()},k);xe.current.set(k,z)}}function ua(){const k=P.current;if(!(!k||!si.current||document.visibilityState==="hidden"||!tt.current||ae.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function ll(){for(const k of ue.current.values())window.clearTimeout(k);ue.current.clear()}function da(){for(const k of xe.current.values())window.clearTimeout(k);xe.current.clear();for(const k of N.current)window.cancelAnimationFrame(k);N.current.clear()}function cl(){for(const k of K.current)window.clearTimeout(k);K.current=[]}function ns(){if(ni(),!nt.current){xs(!1);return}xs(!0),ul(),Mt.current=window.setTimeout(()=>{Mt.current=null,xs(!1)},1200)}function ni(){const k=P.current,z=k?D4(k):null;if(nt.current=z,ws(z),Xn(!!(k&&z)),ks(!!(k&&z&&!Wn(k))),z||!k||!wo()){Vn(null);return}Vn({alternate:k.buffer.active.type==="alternate"})}function wo(){const k=$.current;return Pe.current.length>0||!!k?.hasMore}function ul(){Mt.current!==null&&(window.clearTimeout(Mt.current),Mt.current=null)}function Co(){const k=P.current;k&&(ht.current=!Wn(k),ni())}function dl(k){J.current=tv(J.current,k)}function wc(k){const z=J.current;return J.current=null,tv(z,k)}function S(){const k=J.current;return J.current=null,k}function T(k={}){const z=P.current;if(!z||!si.current){Se.current=!0;return}if(gi.current&&!vt.current&&!D.current&&Wn(z)){be();return}if(vt.current){dl(k);return}if(D.current){dl(k);return}const Me=wc(k);if(!Me.force&&!$h(z,ht.current)){ni();return}D.current=!0;const Xe=Ce.current,qe=()=>{if(P.current!==z||Ce.current!==Xe)return;if(!Me.force&&!$h(z,ht.current)){if(D.current=!1,Jn())return;ni();return}const it=fe.current,ft=He.current[it];if(ft===void 0){if(D.current=!1,Jn())return;Me.scrollToBottom&&_t(z),ni();const gt=S();gt?T(tv(Me,gt)):be();return}z.write(ft,()=>{P.current!==z||Ce.current!==Xe||(fe.current=it+1,qe())})};qe()}function L(k){return gi.current!==null||!Wn(k)&&(le()||D.current||vt.current)}function Q(k,z){return(z?.agentStatus?.provider==="codex"||z?.agentStatus?.provider==="claude"||_n.current||Vl(z?.currentCommand))&&!Wn(k)}function le(){return fe.current<He.current.length}function ce(k,z){gi.current={output:k,history:z,appendFromLiveOutputIndex:He.current.length}}function be(){const k=P.current,z=gi.current;if(!k||!z||!Wn(k)||D.current||vt.current)return;const Me=Kh(z.output),Xe=Kh(He.current.slice(z.appendFromLiveOutputIndex));gi.current=null,Qn([...Me,...Xe],z.history),Hi()}function Be(){$t.current=!0}function je(){Co(),$t.current=!1;const k=P.current;k&&Wn(k)&&T({scrollToBottom:!0})}function _t(k){ss(()=>bC(k))&&(ht.current=!1)}function It(k,z){ss(()=>(k.scrollToLine(z),!0))}function ss(k){Dt.current=!0;try{return k()}finally{Dt.current=!1}}function ci(){const k=P.current;if(!k)return;const z=()=>{Le.current&&(To(G.current),Ht(!1)),bC(k),ht.current=!1,ni(),T({force:!0,scrollToBottom:!0}),Bs("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(M_,z);return}z()}function rs(k){const z=P.current,Me=ae.current;if(!z||!Me)return;const Xe=Me.getBoundingClientRect();if(Xe.height<=0)return;const qe=Math.max(0,Math.min(1,(k-Xe.top)/Xe.height)),it=Math.round(z.buffer.active.baseY*qe);Be();try{z.scrollToLine(it)}finally{je()}ht.current=!Wn(z),ni(),ns(),it<=3&&Sr()}function vd(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),rs(k.clientY)}function ha(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),rs(k.clientY))}function mp(){const k=P.current,z=te.current;if(!(!k||!z)&&!(document.visibilityState==="hidden"||!tt.current||ae.current?.isConnected===!1))try{const Me=$h(k,ht.current),Xe=la();z.fit(),Xe&&(B.current=Xe),Me&&_t(k),k.refresh(0,Math.max(0,k.rows-1)),ni();const qe={cols:k.cols,rows:k.rows},it=ie.current;if(it&&it.cols===qe.cols&&it.rows===qe.rows)return;Cc({type:"resize",terminalId:e.id,cols:qe.cols,rows:qe.rows})&&(ie.current=qe)}catch{}}function _d(k,z){const Me=G.current;return Me?Me(k,z):"rejected"}function Cc(k){return _d(k)!=="rejected"}function xo(){ke.current!==null&&(window.clearTimeout(ke.current),ke.current=null)}function xc(){xo();const k=Math.max(-Hh,Math.min(Hh,Ne.current));if(Ne.current=0,k===0)return!1;const z=Cc({type:"scrollback_scroll",terminalId:e.id,lines:k});return z&&(Re.current=!0,k<0&&Ht(!0)),z}function fa(k){if(!Le.current||k===0)return;const z=Ne.current+k;Ne.current=Math.max(-Hh,Math.min(Hh,z)),ke.current===null&&(ke.current=window.setTimeout(()=>{ke.current=null,xc()},i4))}function ko(){To(G.current)}function bd(k=G.current,z={}){const Me=Re.current;xo(),Ne.current=0,Re.current=!1,z.updateUi!==!1&&Ht(!1),Me&&k?.({type:"cancel_scrollback",terminalId:e.id})}function To(k){xo(),Ne.current=0,Re.current=!1,Ht(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function kc(){if(!Ae.current)return;const k=!Le.current;sa(XM(ee.current,k)),vp()}function yd(){const k=!Tt.current;Tt.current=k,Ds(k),as({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 hl(){Wt.current!==null&&(window.clearTimeout(Wt.current),Wt.current=null)}function as(k,z={}){hl();const Me=Di.current+1;Di.current=Me,pn({...k,id:Me}),!z.sticky&&(Wt.current=window.setTimeout(()=>{Wt.current=null,pn(Xe=>Xe?.id===Me?null:Xe)},12e3))}function Sd(){zt.current.skipped=!0,as({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function wd(){Tt.current=!1,Ds(!1),as({tone:"skipped",message:"Cache keep-alive off"})}async function Tc(){const k=zt.current;if(k.sent||k.skipped)return;const z=gp();if(k.sent=!0,z){as({tone:"skipped",message:"Skipped cache keep-alive",detail:z});return}if(Cr(`${uC}\r`,{userInitiated:!1})==="rejected"){as({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}as({tone:"success",message:"Cache keep-alive sent",detail:uC})}function gp(){const k=at.current,z=Fe.current;return Tt.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!z?"Transcript cache status is unavailable.":k.source.provider!==z.provider||k.source.sessionId!==z.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${il(z.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":ec(e.id).text.trim()?"Compose has an unsent draft.":d4(ae.current)?"Pane input is focused.":Date.now()-sn.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function vp(){const k=P.current;k&&(_t(k),ni())}function Cr(k,z={}){xc();const Me=Re.current;T({force:!0,scrollToBottom:!0});const Xe=_d({type:"input",terminalId:e.id,data:k,...Me?{cancelScrollbackMode:!0}:{}},{durability:z.userInitiated===!1?"live-only":"durable"});return Xe==="rejected"?(z.userInitiated!==!1&&xi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Xe):(z.userInitiated!==!1&&(sn.current=Date.now()),Me&&(Re.current=!1,Ht(!1)),k4(k)&&(Xe==="sent"?pa():Xe==="queued"&&(de.current=!0)),Xe)}function _p(){Ve.current&&Eo(!1),Cr(z5)}function bp(k){const z=Ug(k,{bracketedPasteMode:P.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});z&&Cr(z)}function Cn(k,z){const Me=P.current?.modes.bracketedPasteMode===!0,Xe=Ns==="codex"||Ns==="claude"||Vl(e.currentCommand),qe=k.parts.map(it=>it.kind==="image"&&Xe?Ug(it.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Ug(it.kind==="image"?it.path:it.value,{bracketedPasteMode:Me,stripTrailingLineBreaks:!1})).join("");return qe?Cr(`${qe}${Q3(z)}`)!=="rejected":!1}function pa(){!kt.current||!rt.current||(cl(),K.current=j5.map(k=>{const z=window.setTimeout(()=>{K.current=K.current.filter(Me=>Me!==z),kt.current&&rt.current&&Cc({type:"refresh_cwd",terminalId:e.id})},k);return z}))}function Bs(k="terminal-interaction"){li.current||Sc()&&(k==="auto"||k==="scroll-action")||P.current?.focus()}const Cd=v.useCallback(()=>{Gn(!1)},[]),xd=v.useCallback(async()=>{const k=Fe.current,z=ut.current;try{const Me=await t.getTerminalTranscriptSource(e.id);if(!Me.source||Lt.current!==e.id||ut.current!==z||!Ph(k,Fe.current))return;Te.current=null,_e.current=!1,pe.current=!1,Mi(Me.source),wi.current=Jg(e.id,Me.source)}catch{}},[Mi,t,e.id]);function kd(){qs(k=>{const z=!k;return Ve.current=z,z}),Bs("input-action")}function Eo(k){Ve.current=k,qs(k)}function yp(k){Ve.current&&Eo(!1),Cr(w3(k)),Bs("input-action")}async function xr(k="install"){vr(!0),an(null);try{const z=k==="update"?await t.updateCodeServer():await t.installCodeServer();N_(Ci,z.status),Ms(z.status)}catch(z){an(Fh(z))}finally{vr(!1)}}return h.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Pi?"true":"false",onMouseDown:()=>{n||g()},children:[h.jsx(h4,{terminal:e,canClose:o,tabId:u,transcriptSource:Vt,transcriptShortcutLabel:F,subagentsShortcutLabel:q,transcriptCacheStatus:Sn,transcriptCacheNow:Jr,cacheKeepAliveEnabled:gr,codeServerAvailable:!0,codeServerInstallState:rn===null?"unknown":rn.installed?"installed":"missing",codeServerBusy:ta||rn?.job?.status==="running",codeServerSupported:rn?.supported!==!1,scrollbackShortcutLabel:U,tmuxScrollbackSupported:As,tmuxScrollbackEnabled:Pi,onToggleCacheKeepAlive:yd,onOpenCodeServer:Mn,onToggleTmuxScrollback:kc,onOpenTranscript:yr,onOpenSubagents:go,onReload:Zs,onClose:p}),h.jsx("div",{className:"xterm-container",ref:ae}),qt?h.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:h.jsx("span",{"aria-hidden":"true"})}):null,M&&!Pi&&bn?h.jsxs("div",{className:"terminal-scroll-progress","data-active":Cs,"aria-hidden":"true",children:[bn.current,"/",bn.total]}):M&&!Pi&&Ws?h.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ws.alternate?"alternate":"normal","aria-hidden":"true",children:[Ws.alternate?"alt ":"","0/?"]}):null,Yn||Pi&&Es?h.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(),ci()},children:"↓"}):null,Ts&&!Pi?h.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:vd,onPointerMove:ha,children:h.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?mo?h.jsx(y3,{ctrlActive:uo,onCtrl:kd,onStandaloneKey:yp,onPreserveFocus:()=>Bs("input-action"),onHide:()=>Ls(!1)}):h.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(),Bs("input-action")},onPointerDown:k=>{k.stopPropagation(),Bs("input-action")},onClick:()=>Ls(!0),children:"⌨"}):null,h.jsx(cB,{terminalId:e.id,onSubmit:Cn,onUploadAttachments:(k,z)=>t.uploadComposeAttachments({terminalId:e.id,files:k,signal:z.signal,onProgress:z.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:k=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:k})}:{},queueAvailable:Ns==="codex"||NT(e.currentCommand),disabled:e.status!=="running"}),h.jsx(g4,{toast:ea,onSendNow:()=>{Tc()},onSkipOnce:Sd,onTurnOff:wd,onDismiss:()=>pn(null)}),Vi&&Vt?h.jsx(v4,{terminalId:e.id,serverApi:t,source:Vt,fontSize:w,onClose:Cd,onReloadLatest:xd}):null,fo&&Vt?h.jsx(a3,{terminalId:e.id,serverApi:t,source:Vt,fontSize:w,onClose:()=>Rs(!1)}):null,po?h.jsx(p4,{notice:po}):null,_c?h.jsx(f4,{status:rn,busy:ta,error:ia,onInstall:()=>{xr("install")},onUpdate:()=>{xr("update")},onOpen:Mn,onRefresh:()=>{wn({checkLatest:!0}).catch(k=>an(Fh(k)))},onClose:()=>Yi(!1)}):null]})}function fC(e){return H2(e)}async function pC(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=ql.get(e);if(!o&&u?.status&&c-u.fetchedAt<=n4)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=>(N_(e,g),g)).catch(g=>{const p=ql.get(e);throw p?.inflight===f&&(p.status?ql.set(e,{status:p.status,fetchedAt:p.fetchedAt}):ql.delete(e)),g}),ql.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:f,inflightCheckLatest:r}),f}function N_(e,t){ql.set(e,{status:t,fetchedAt:Date.now()})}function Uh(e,t){return`${e}:${t}`}function DT(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function mC(e){const t=Uu.get(e);if(!t)return!1;try{return t.closed?(Uu.delete(e),!1):(t.focus(),!0)}catch{return Uu.delete(e),!1}}function Zg(e,t){const n=window.open(t,DT(e));if(!n)return null;Uu.set(e,n);try{n.focus()}catch{}return n}function gC(e,t,n){if(!e||RT(e))return!1;try{return e.name=DT(t),e.location.href=n,Uu.set(t,e),e.focus(),!0}catch{return!1}}function s4(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 RT(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Qg(e){if(e)try{e.closed||e.close()}catch{}}function r4(e,t,n){const r=a4(e,t),o=vC(r*Math.max(1,n),X5,G5);return{limit:vC(Math.ceil(o/q5),V5,Y5),maxLines:o}}function a4(e,t){const n=e?.clientHeight??0;if(n<=0)return $5;const r=Math.max(10,t*W5);return Math.max(1,Math.floor(n/r))}function vC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function o4(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Jg(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function MT(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 l4(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function c4(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 u4(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Fh(e){return e instanceof dn||e instanceof Error?e.message:"Something went wrong."}function d4(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function h4({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:f,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:_,codeServerBusy:b,codeServerSupported:C,scrollbackShortcutLabel:w,tmuxScrollbackSupported:x,tmuxScrollbackEnabled:M,onToggleCacheKeepAlive:O,onOpenCodeServer:A,onToggleTmuxScrollback:W,onOpenTranscript:F,onOpenSubagents:U,onReload:q,onClose:ae}){const P=ub({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 h.jsxs("header",{ref:P.setNodeRef,className:"terminal-pane-header",style:te,"data-dragging":P.isDragging,...P.attributes,...P.listeners,children:[h.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),h.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),h.jsx("span",{className:"terminal-pane-spacer"}),p?h.jsx("button",{type:"button",className:"terminal-pane-code","data-state":_,"data-busy":b?"true":"false",disabled:!C||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:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),A()},children:h.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?h.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${il(r.provider)} transcript history`,"aria-label":`View ${il(r.provider)} transcript history`,onPointerDown:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),F()},children:[h.jsx("span",{className:"pane-button-label-full",children:"View history"}),h.jsx("span",{className:"pane-button-label-short",children:"History"}),h.jsx("kbd",{children:o})]}):null,r?h.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:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),U()},children:[h.jsx("span",{className:"pane-button-label-full",children:"View agents"}),h.jsx("span",{className:"pane-button-label-short",children:"Agents"}),h.jsx("kbd",{children:c})]}):null,r?h.jsx(m4,{status:u,now:f,keepAliveEnabled:g,onToggle:O}):null,e.status==="exited"?h.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,x&&e.status==="running"?h.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":M?"true":"false","aria-pressed":M,"aria-label":`Toggle tmux scrollback (${w})`,title:M?`Scroll input uses tmux scrollback (${w}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${w}).`,onPointerDown:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),W()},children:[M?h.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.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"}),h.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"})]}):h.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.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"}),h.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),h.jsx("kbd",{children:w})]}):null,e.status==="running"?h.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),q()},children:"↻"}):null,t?h.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:G=>G.stopPropagation(),onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),ae()},children:"x"}):null]})}function f4({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:f}){const g=e?.job??null,p=g?.status==="running",_=e?.installed===!0,b=e?.supported!==!1,C=e===null&&t,w=e?.updateAvailable===!0,x=_?"VS Code add-on":"Install VS Code add-on";return h.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:f,children:h.jsxs("section",{className:"security-panel code-server-dialog",onClick:M=>M.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{children:[h.jsx("h2",{children:x}),h.jsx("p",{children:C?"Checking code-server status...":_?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),h.jsxs("div",{className:"code-server-dialog-scroll",children:[h.jsxs("div",{className:"code-server-dialog-body",children:[h.jsxs("p",{children:["NTerminal installs code-server under ",h.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),C?h.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:h.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?h.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?h.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[h.jsxs("div",{className:"code-server-progress-heading",children:[h.jsx("span",{children:g.action}),h.jsx("strong",{children:g.status})]}),h.jsx("pre",{children:g.logs.length>0?g.logs.join(`
52
- `):"Preparing..."})]}):null]}),h.jsxs("div",{className:"code-server-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!b,children:"Check"}),_?h.jsxs(h.Fragment,{children:[w?h.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:"Update"}):null,h.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):h.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function p4({notice:e}){return h.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function m4({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=MT(e,t),c=l4(e,o),u=o===null?"?":c4(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 h.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:[h.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[h.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),h.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),h.jsx("span",{children:u})]})}function g4({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return h.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[h.jsxs("header",{children:[h.jsx("strong",{children:e.message}),h.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?h.jsx("p",{children:e.detail}):null,c?h.jsxs("div",{className:"cache-keepalive-toast-actions",children:[h.jsx("button",{type:"button",onClick:t,children:"Send now"}),h.jsx("button",{type:"button",onClick:n,children:"Skip once"}),h.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const v4=jt.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const f=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),_=v.useRef(!1),b=v.useRef(null),C=v.useRef(""),w=v.useRef(null),x=v.useRef(null),[M,O]=v.useState([]),[A,W]=v.useState(!1),[F,U]=v.useState(""),[q,ae]=v.useState(-1),[P,te]=v.useState(!1),[G,ge]=v.useState(-1),[ee,V]=v.useState(null),[Z,Y]=v.useState(null),[ie,B]=v.useState(!1),[R,I]=v.useState(!0),[ue,xe]=v.useState(!1),[N,K]=v.useState(null),[de,ke]=v.useState(!1);v.useEffect(()=>{function Se(Ve){Ve.key==="Escape"&&(Ve.preventDefault(),Ve.stopPropagation(),c())}return document.addEventListener("keydown",Se,!0),()=>document.removeEventListener("keydown",Se,!0)},[c]),v.useEffect(()=>{g.current+=1;const Se=g.current;return p.current=!1,_.current=!0,b.current=null,w.current=null,x.current=null,O([]),Y(null),B(!1),K(null),ke(!1),ae(-1),ge(-1),V(null),Ke(null,"initial",Se),()=>{g.current===Se&&(g.current+=1)}},[n,A,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const Se=f.current;if(!Se)return;if(_.current){if(R||M.length===0)return;_.current=!1;const rt=()=>{Se.scrollTop=Se.scrollHeight};rt(),window.requestAnimationFrame?.(rt);return}const Ve=b.current;Ve!==null&&(b.current=null,Se.scrollTop+=Se.scrollHeight-Ve)},[M,R,A]);const Ne=il(r.provider),Re=Rf(M,A),Le=Fk(Re),Ae=_4(Le),We=Ae.map(Se=>Se.key).join(""),Pe=ee?Ae.find(Se=>Se.key===ee)?.entryIndex??null:null,He=F.trim().length>0,fe=QO(Le,F),D=fe.length,J=D>0?q>=0&&q<D?q:0:-1,Ce=J>=0?fe[J]?.entryIndex??null:null,Ee=J>=0?fe[J]??null:null,$=He?Ce:Pe,Te=He?Ce===null?null:"search":Pe===null?null:"prompt",_e=Re?Re.split(`
53
- `).length-1:0,pe=Ae.length>0&&G>=0&&G<Ae.length?G:Ae.length-1,Ie=ee??(pe>=0?Ae[pe]?.key??null:null),Ue=He?D>0?`${J+1}/${D} ${D===1?"match":"matches"} · ${_e} ${_e===1?"line":"lines"}`:`0 matches · ${_e} ${_e===1?"line":"lines"}`:Ae.length>0?`${pe+1}/${Ae.length} prompts · ${_e} ${_e===1?"line":"lines"}`:`0 prompts · ${_e} ${_e===1?"line":"lines"}`;v.useEffect(()=>{const Se=F.trim().toLowerCase();ae(Ve=>!Se||D===0?-1:C.current!==Se?0:Ve>=0&&Ve<D?Ve:0),C.current=Se},[F,D]),v.useEffect(()=>{if(He){V(null);return}ee&&!Ae.some(Se=>Se.key===ee)&&V(null),ge(Se=>{if(Ae.length===0)return x.current=null,-1;const Ve=x.current?Ae.findIndex(tt=>tt.key===x.current):-1,rt=Ve>=0?Ve:Se>=0&&Se<Ae.length?Se:Ae.length-1;return x.current=Ae[rt]?.key??null,rt})},[ee,He,We]),v.useEffect(()=>{const Se=w.current;if(!Se||Ae.length===0)return;w.current=null;const Ve=Se.anchorKey?Ae.findIndex(tt=>tt.key===Se.anchorKey):-1,rt=Ve>0?Ve-1:0;vt(rt)},[We]);async function Ke(Se,Ve,rt=g.current){if(!p.current){p.current=!0,Ve==="initial"?I(!0):(xe(!0),b.current=f.current?.scrollHeight??null),K(null);try{await nt(Se,Ve,rt)}catch(tt){if(g.current!==rt)return;K(tt instanceof Error?tt.message:"Failed to load transcript history.")}finally{g.current===rt&&(p.current=!1,I(!1),xe(!1))}}}async function nt(Se,Ve,rt){let tt=Se,kt=0,lt=[];const qi=Ve==="initial"&&r.provider!=="claude"?Q5:Z5;for(;g.current===rt;){const li=await n.getTerminalTranscriptHistory(t,{...tt?{cursor:tt}:{},...r4(f.current,o,Ve==="initial"?F5:K5),includeTools:A});if(g.current!==rt)return;if(!li.source){K("Transcript source is temporarily unavailable.");return}if(!Ub(r,li.source)){ke(!0),B(!1);return}const re=v_(li.output,r.provider,{includeTools:A}),Fe=Mt(li,Ve,lt,re);if(re&&(lt=[re,...lt],Fe))return;if(!li.hasMore||!li.cursor||kt>=qi){lt.length>0&&O(ct=>Ve==="older"?[...lt,...ct]:lt);return}tt=li.cursor,kt+=1}}function Mt(Se,Ve,rt,tt=v_(Se.output,r.provider,{includeTools:A})){if(Y(Se.cursor),B(!!(Se.hasMore&&Se.cursor)),!tt)return!1;const kt=[tt,...rt];return Rf(kt,A)?(O(lt=>Ve==="older"?[...kt,...lt]:kt),!0):!1}function ht(){const Se=f.current;Se&&(si(),!(Se.scrollTop>72||!ie||!Z||p.current)&&Ke(Z,"older"))}function Dt(Se){D!==0&&ae(Ve=>{const rt=J>=0?J:Se>0?-1:0;return((Ve>=0&&Ve<D?Ve:rt)+Se+D)%D})}function vt(Se){const Ve=Ae[Se];Ve&&(x.current=Ve.key,ge(Se),V(Ve.key))}async function $t(Se){if(Ae.length===0){Se<0&&ie&&Z&&!p.current&&(w.current={anchorKey:null},await Ke(Z,"older"));return}const rt=(G>=0&&G<Ae.length?G:Se<0?Ae.length-1:-1)+Se;if(rt>=0&&rt<Ae.length){vt(rt);return}Se<0&&rt<0&&ie&&Z&&!p.current&&(w.current={anchorKey:Ae[0]?.key??null},await Ke(Z,"older"))}function si(){if(He)return;const Se=f.current;if(!Se)return;const rt=Se.getBoundingClientRect().top+Math.min(140,Math.max(48,Se.clientHeight*.28));let tt=null;for(const kt of C4(Se)){const lt=x4(kt);if(lt!==null)if(kt.getBoundingClientRect().top<=rt)tt=lt;else break}if(tt!==null){const kt=Ae[tt]?.key??null;x.current=kt,ge(tt),ee&&ee!==kt&&V(null)}}return h.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:Se=>Se.stopPropagation(),onMouseDown:Se=>Se.stopPropagation(),onClick:Se=>{Se.stopPropagation(),c()},children:h.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:Se=>Se.stopPropagation(),onMouseDown:Se=>Se.stopPropagation(),onClick:Se=>Se.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsxs("div",{className:"transcript-dialog-title",children:[h.jsxs("h2",{id:"transcript-dialog-title",children:[Ne," JSONL"]}),h.jsx("span",{title:r.sessionId,children:r.sessionId})]}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),h.jsxs("div",{className:"transcript-dialog-controls",children:[h.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[h.jsx("input",{type:"checkbox",checked:A,onChange:Se=>W(Se.currentTarget.checked)}),"Show tool output"]}),h.jsx("label",{className:"transcript-search",children:h.jsx("input",{type:"search",value:F,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:Se=>U(Se.currentTarget.value),onKeyDown:Se=>{Se.key==="Enter"&&(Se.preventDefault(),He?Dt(Se.shiftKey?-1:1):$t(Se.shiftKey?-1:1))}})}),h.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":P,"aria-label":"Toggle prompt list",onClick:()=>te(Se=>!Se),disabled:Ae.length===0,children:"List"}),h.jsxs("div",{className:"transcript-search-actions","aria-label":He?"Search result navigation":"Prompt navigation",children:[h.jsx("button",{type:"button",onClick:()=>He?Dt(-1):void $t(-1),disabled:He?D===0:Ae.length===0&&!ie,"aria-label":He?"Previous search match":"Previous user prompt",title:He?"Previous search match":"Previous user prompt",children:"Prev"}),h.jsx("button",{type:"button",onClick:()=>He?Dt(1):void $t(1),disabled:He?D===0:Ae.length===0,"aria-label":He?"Next search match":"Next user prompt",title:He?"Next search match":"Next user prompt",children:"Next"})]}),h.jsx("span",{className:"transcript-result-count",children:Ue})]}),P?h.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ae.length>0?Ae.map((Se,Ve)=>h.jsxs("button",{type:"button",className:Ie===Se.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>vt(Ve),children:[h.jsx("span",{children:Se.timestampLabel}),h.jsx("strong",{children:Se.snippet})]},`${Se.key}:${Ve}`)):h.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,h.jsxs("div",{ref:f,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:ht,children:[ue?h.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&ie?h.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Re?h.jsx(Hk,{entries:Le,searchQuery:F,activeEntryIndex:$,activeEntryMode:Te,activeSearchMatch:Ee,fontSize:o}):null,R?h.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,de?h.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",h.jsx("button",{type:"button",onClick:()=>{u()},children:"Load current session"})]}):null,!de&&!R&&!Re&&!N?ie&&Z?h.jsxs("div",{className:"transcript-dialog-status",children:[A?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",h.jsx("button",{type:"button",onClick:()=>{Ke(Z,"older")},disabled:ue,children:"Search earlier entries"})]}):h.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,N?h.jsx("div",{className:"transcript-dialog-error",children:N}):null]})]})})});function _4(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:b4(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:S4(o.entry.body),timestampLabel:w4(o.entry.header)}))}function b4(e){return JSON.stringify([e.header??"",e.body.length,y4(e.body)])}function y4(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 S4(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function w4(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function C4(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function x4(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 k4(e){return e.includes("\r")||e.includes(`
54
- `)}function ev(e){return e instanceof dn&&e.status===404}function Vl(e){return NT(e)||AT(e)}function NT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function AT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function T4(e){if(Vl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function E4(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 Kh(e){const t=[];for(const n of e){const r=LT(n);r&&t.push(r)}return t}function LT(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!H5.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function tv(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function D4(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 _C(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 Wn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function $h(e,t){return!t||Wn(e)}function bC(e){return Wn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function R4(e,t,n,r,o,c,u,f){const g=p=>{const _=N4(p);if(_!==0){if(u()){if(O4(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(_);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),M4(t,_,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function M4(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(M_,u);return}u()}function N4(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 A4(e,t,n,r,o,c,u,f,g){let p=null,_=0;const b={passive:!1};function C(M){p=iv(M),_=0}function w(M){const O=iv(M);if(O===null){p=null,_=0;return}if(p===null){p=O;return}const A=O.clientY-p.clientY;if(p=O,M.cancelable&&M.preventDefault(),A===0)return;if(L4(t)&&B4(t,O,-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 x(M){if(M.touches.length>0){p=iv(M);return}p=null,_=0}return e.addEventListener("touchstart",C,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",C,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function iv(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function L4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function O4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function B4(e,t,n){const r=e.element;return r?(r.dispatchEvent(j4(t,n)),!0):!1}function j4(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 A_({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:f,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:_=null,mobileFocusLeafKey:b=null,path:C=[],totalPanes:w,onSelect:x,onClose:M,onResize:O,onExit:A,onSnapshot:W,onCloseEditor:F,onAuthClose:U}){const q=w??L_(e);if(C.length===0&&b){const G=O_(e),ge=G.some(ee=>ee.key===b)?b:G[0]?.key;if(G.length>1&&ge)return h.jsx("div",{className:"mobile-focused-split",children:G.map(ee=>{const V=ee.key===ge;if(ee.type==="editor"){const Y=n[ee.editorId];return h.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:Y?h.jsx(Vw,{api:r,editor:Y,canClose:q>1,onClose:()=>F(ee.editorId)}):h.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ee.key)}const Z=t[ee.terminalId];return Z?h.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:h.jsx(hC,{terminal:Z,serverApi:r,active:V,visible:c&&V,canClose:q>1,refreshCwdOnEnter:u&&V,tabId:f,codeServerContext:g,onSelect:()=>x(ee.terminalId),onClose:()=>M(ee.terminalId),onExit:Y=>A(ee.terminalId,Y),onSnapshot:W,...U?{onAuthClose:U}:{}})},ee.key):h.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:h.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ee.key)})})}if(e.type==="pane"){const G=t[e.terminalId];if(!G)return h.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ge=h.jsx(hC,{terminal:G,serverApi:r,active:e.terminalId===o,visible:c,canClose:q>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:f,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>M(e.terminalId),onExit:V=>A(e.terminalId,V),onSnapshot:W,...U?{onAuthClose:U}:{}});return p&&_!==e.terminalId?h.jsxs("div",{className:"pane-drop-host",children:[ge,h.jsx(Wh,{terminalId:e.terminalId,side:"top"}),h.jsx(Wh,{terminalId:e.terminalId,side:"right"}),h.jsx(Wh,{terminalId:e.terminalId,side:"bottom"}),h.jsx(Wh,{terminalId:e.terminalId,side:"left"})]}):ge}if(e.type==="editor"){const G=n[e.editorId];return G?h.jsx(Vw,{api:r,editor:G,canClose:q>1,onClose:()=>F(e.editorId)}):h.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const ae=Math.max(.1,Math.min(.9,e.ratio)),P=1-ae,te=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${ae}fr) 1px minmax(0, ${P}fr)`}:{gridTemplateRows:`minmax(0, ${ae}fr) 1px minmax(0, ${P}fr)`};return h.jsxs("div",{className:"split-pane","data-direction":e.direction,style:te,children:[h.jsx("div",{className:"split-cell",children:h.jsx(A_,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...C,0],totalPanes:q,onSelect:x,onClose:M,onResize:O,onExit:A,onSnapshot:W,onCloseEditor:F,...U?{onAuthClose:U}:{}})}),h.jsx(I4,{direction:e.direction,path:C,onResize:O}),h.jsx("div",{className:"split-cell",children:h.jsx(A_,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...C,1],totalPanes:q,onSelect:x,onClose:M,onResize:O,onExit:A,onSnapshot:W,onCloseEditor:F,...U?{onAuthClose:U}:{}})})]})}function Wh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=Gf({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return h.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function I4({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 p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return h.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:h.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function L_(e){return e.type==="pane"||e.type==="editor"?1:L_(e.first)+L_(e.second)}function O_(e){return e.type==="pane"?[{key:P4(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:z4(e.editorId),type:"editor",editorId:e.editorId}]:[...O_(e.first),...O_(e.second)]}function P4(e){return`terminal:${e}`}function z4(e){return`editor:${e}`}const dp="workspace-default",H4="NTerminal";function U4(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function F4(e,t){switch(t.type){case"workspace.hydrated":return B_(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return K4(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return V4(e,t.workspaceId);case"workspace.selected":return OT(e,t.workspaceId);case"workspace.renamed":return $4(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return W4(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return q4(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return BT(e,t.terminal);case"terminal.split":return Y4(e,t.terminal,t.direction);case"terminal.updated":return rj(e,t.terminal);case"terminal.exited":return aj(e,t.terminalId,t.exitCode);case"terminal.closed":return PT(e,t.terminalId);case"terminal.detached":return oj(e,t.terminalId,t.workspaceId);case"editor.split":return X4(e,t.editorId,t.title,t.direction);case"editor.closed":return lj(e,t.editorId);case"pane.selected":return nj(e,t.terminalId);case"pane.resized":return sj(e,t.path,t.ratio);case"tab.selected":return Z4(e,t.tabId);case"tab.renamed":return ij(e,t.tabId,t.title);case"tab.reordered":return Gb(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return Q4(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return jT(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return IT(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return J4(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return G4(e);default:return e}}function K4(e,t){if(e.workspaces.some(r=>r.id===t.id))return OT(e,t.id);const n={id:t.id,title:t.title,defaultCwd:$s(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function OT(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function $4(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 W4(e,t,n){const r=$s(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 q4(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 p=r==="before"?g:g+1,_=u.slice();return _.splice(p,0,f),tj(e.workspaces,_)?e:{...e,workspaces:_}}function V4(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?Hf(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 BT(e,t){const n=HT(e),r=al(n)??fp(),o=WT(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??$s(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:$T(c,t.id))}}function Y4(e,t,n){const r=al(e),o=r?hp(r):void 0;if(!r||!o)return BT(e,t);const c=o.activeTerminalId,u=nd(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??$s(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)}:$T(f,t.id))}}function X4(e,t,n,r){const o=al(e),c=o?hp(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,f=nd(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(p=>p.id===c.id?{...p,root:f,activeTerminalId:u}:p)}:g)}}function G4(e){const t=al(e),n=t?hp(t):void 0;return n?PT(e,n.activeTerminalId):e}function Z4(e,t){const n=al(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 Gb(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)),p=u.slice();return p.splice(g,0,f),ej(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function Q4(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(x=>x.id===t);if(p<0)return g;const _=g.tabs[p];if(!_)return g;const b=oc(_.root,n);if(!b){const x=g.tabs.filter((M,O)=>O!==p);return{...g,tabs:x}}const C={..._,root:b,activeTerminalId:Ii(b)[0]??_.activeTerminalId},w=g.tabs.slice();return w[p]=C,{...g,tabs:w}});const u=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(M=>Ii(M.root).includes(r));if(p<0)return g;const _=g.tabs[p];if(!_)return g;const b={type:"pane",terminalId:n},C={type:"split",direction:u,ratio:.5,first:f?b:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:b},w=nd(_.root,r,C),x=g.tabs.slice();return x[p]={..._,root:w,activeTerminalId:n},{...g,tabs:x,activeTabId:_.id}}),HT({...e,workspaces:c})}function jT(e,t,n,r){let o=-1,c=-1;for(let O=0;O<e.workspaces.length;O+=1){const A=e.workspaces[O].tabs.findIndex(W=>W.id===t);if(A>=0){o=O,c=A;break}}if(o<0)return e;const u=e.workspaces[o],f=u.tabs[c],g=Ii(f.root);if(!g.includes(n))return e;if(g.length===1)return Gb(e,t,r);const p=oc(f.root,n);if(!p)return e;const _={...f,root:p,activeTerminalId:Ii(p)[0]??f.activeTerminalId},b=e.terminals[n],C={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=u.tabs.slice();w[c]=_;const x=Math.max(0,Math.min(w.length,r));w.splice(x,0,C);const M=e.workspaces.slice();return M[o]={...u,tabs:w,activeTabId:C.id},{...e,workspaces:M}}function IT(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=UT(e.workspaces,t),c=e.workspaces.find(p=>p.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:Gb(e,t,r);const u=Ii(o.tab.root),f=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return ol({...p,tabs:p.tabs.filter(_=>_.id!==t)});if(p.id===n){const _=p.tabs.slice(),b=Math.max(0,Math.min(_.length,r));return _.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??$s(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(C=>!u.includes(C)),tabs:_,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function J4(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===r),u=UT(e.workspaces,t);if(!c||!u||!e.terminals[n]||!Ii(u.tab.root).includes(n))return e;if(u.workspace.id===r)return jT(e,t,n,o);if(Ii(u.tab.root).length===1)return IT(e,t,r,o);const g=oc(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:Ii(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}},C=e.workspaces.map(w=>{if(w.id===u.workspace.id)return ol({...w,tabs:w.tabs.map(x=>x.id===t?p:x)});if(w.id===r){const x=w.tabs.slice(),M=Math.max(0,Math.min(x.length,o));return x.splice(M,0,b),{...w,defaultCwd:w.defaultCwd??$s(_.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(O=>O!==n),tabs:x,activeTabId:b.id}}return w});return{...e,workspaces:C,activeWorkspaceId:r}}function ej(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 tj(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 ij(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(p=>p.id!==t||p.title===r?p:(o=!0,f=!0,{...p,title:r}));return f?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function nj(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>lc(c.root,t))),r=n?.tabs.find(o=>lc(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 sj(e,t,n){const r=al(e),o=r?hp(r):void 0;if(!r||!o)return e;const c=H_(o.root,t,YT(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 B_(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=>qT(b))||t&&t.some(b=>VT(b)));let g=cj(t,n,c,u);g.length===0&&(g=[fp()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,_=p??g[0]?.id??dp;for(const b of e)if(!u.has(b.id)){if(f)g=hj(g,_,b.id,b);else{const C=WT(b);g=pj(g,_,C,b)}u.add(b.id)}return{workspaces:g.map(b=>ol(fj(b,o))),activeWorkspaceId:p,terminals:o}}function Vo(e){return Ii(e.root)}function zf(e){return U_(e.root)}function Hf(e){return Zb([...e.tabs.flatMap(t=>Ii(t.root)),...e.detachedTerminalIds])}function nv(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=P_(o.root);return c?[{...o,root:c}]:[]});return ol({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function rj(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>lc(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function aj(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function PT(e,t){const n={...e.terminals};return delete n[t],zT(e,t,n)}function oj(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??uj(e,t)?.id??dj(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??dp,o=e.workspaces.find(c=>c.id===r);return!o||!KT(o,t)?e:zT(e,t,{...e.terminals},{detachToWorkspaceId:r})}function zT(e,t,n,r={}){let o=e.workspaces.map(u=>{const f=[];for(const g of u.tabs){const p=oc(g.root,t);if(!p)continue;const _=Ii(p),b=_.includes(g.activeTerminalId)?g.activeTerminalId:_[0];b&&f.push({...g,root:p,activeTerminalId:b})}return ol({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?FT(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 lj(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const f=j_(u.root,t);if(!f)continue;const g=Ii(f),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:f,activeTerminalId:p})}return ol({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function cj(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)qT(c)&&o.push(yC(c,n,r));if(o.length>0)return o}return[yC({...fp(),tabs:e??[]},n,r)]}function yC(e,t,n){const r=[];for(const c of e.tabs){if(!VT(c))continue;const u=I_(c.root,t);if(!u)continue;const f=Ii(u);for(const p of f)n.add(p);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 ol({...e,defaultCwd:$s(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function HT(e){return al(e)?e:{...e,workspaces:[fp()],activeWorkspaceId:dp}}function al(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function hp(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function UT(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 uj(e,t){return e.workspaces.find(n=>n.tabs.some(r=>lc(r.root,t)))}function dj(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function hj(e,t,n,r){return e.map(o=>o.id===t?FT(o,n,r):o)}function FT(e,t,n){return KT(e,t)?{...e,defaultCwd:e.defaultCwd??$s(n?.cwd),detachedTerminalIds:Zb([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function KT(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<hc}function $T(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function fj(e,t){if(e.defaultCwd)return e;const n=Hf(e).find(o=>!!t[o]),r=n?$s(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function fp(){return{id:dp,title:H4,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ol(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:$s(e.defaultCwd),detachedTerminalIds:Zb(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function pj(e,t,n,r){const o=Ii(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??$s(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function WT(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function nd(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:nd(e.first,t,n),second:nd(e.second,t,n)}}function oc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=oc(e.first,t),r=oc(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function j_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=j_(e.first,t),r=j_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function I_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=I_(e.first,t),r=I_(e.second,t);return n&&r?{...e,ratio:YT(e.ratio),first:n,second:r}:n??r}function P_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=P_(e.first),n=P_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function qT(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 VT(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&z_(t.root)}function z_(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")&&z_(t.first)&&z_(t.second):!1}function H_(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=H_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=H_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function YT(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function $s(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Zb(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function lc(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:lc(e.first,t)||lc(e.second,t)}function Ii(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ii(e.first),...Ii(e.second)]}function U_(e){return e.type==="pane"||e.type==="editor"?1:U_(e.first)+U_(e.second)}const mr=new Map,sd=new Map,rd=new Map,ad=new Map,od=new Map,F_=new Set;let XT=0;function lo(e){return e??"__local__"}function mj(e){return{agentId:e,state:U4(),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 Rt(e){const t=lo(e);let n=mr.get(t);return n||(n=mj(e),mr.set(t,n)),n}function gj(e){return mr.get(lo(e))??null}function GT(e,t){const n=lo(e);let r=sd.get(n);return r||(r=new Set,sd.set(n,r)),r.add(t),()=>{r.delete(t)}}function vj(e){const t=lo(e),n=sd.get(t);if(n)for(const r of Array.from(n))r()}function vc(e,t,n=!0){const r=mr.get(lo(e)),o=n&&SC(r)!==SC(t);mr.set(lo(e),t),vj(e),o&&Jb()}function K_(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function Qb(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 Ii(u.root))r.add(f);let o=0,c=0;for(const u of r)K_(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(c+=1);return{workingTerminalCount:o,unreadCompletionCount:c}}function SC(e){return e?e.state.workspaces.map(t=>{const n=Qb(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function ZT(e){return!!(e&&e.state.workspaces.some(t=>{const n=Qb(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function Jb(){XT+=1;for(const e of Array.from(F_))e()}function _j(e){return F_.add(e),()=>{F_.delete(e)}}function wC(){return XT}function bj(e,t){return Qb(Rt(e),t)}const $_=new Set;function yj(e){return $_.add(e),()=>{$_.delete(e)}}function Ha(e,t){const n=Rt(e),r=lo(e),o=wj(n.state,t);t.type==="workspace.hydrated"&&(rd.delete(r),ad.delete(r),od.delete(r));const c=F4(n.state,t);let u=n.unreadCompletions,f=null;if(t.type==="terminal.updated"){const _=n.state.terminals[t.terminal.id],b=Rj(r),C=Mj(r),w=Cj(r);if(t.terminal.agentStatus){const x=t.terminal.agentStatus.state,M=t.terminal.agentStatus.sessionId,O=w.get(t.terminal.id),A=!!(_&&(_.currentCommand!==t.terminal.currentCommand||_.agentStatus?.provider!==t.terminal.agentStatus.provider||Sj(O,M)));A&&(C.delete(t.terminal.id),b.delete(t.terminal.id),w.delete(t.terminal.id)),M&&w.set(t.terminal.id,M),t.notifyCompletion===!0&&(x==="working"?(C.add(t.terminal.id),b.delete(t.terminal.id)):x==="unknown"&&t.terminal.activity==="busy"&&b.add(t.terminal.id)),!A&&(x==="done"||x==="stopped")&&(C.has(t.terminal.id)||b.has(t.terminal.id))&&(f=kC(c,t.terminal.id,_?.currentCommand??null,x==="stopped"?"stopped":"finished"),C.delete(t.terminal.id),b.delete(t.terminal.id)),x==="idle"&&(C.delete(t.terminal.id),b.delete(t.terminal.id))}else{_?.agentStatus&&(C.delete(t.terminal.id),w.delete(t.terminal.id));const x=_?.activity==="busy",M=t.terminal.activity==="busy",O=t.terminal.activity==="idle";t.notifyCompletion===!0&&M&&b.add(t.terminal.id),t.notifyCompletion===!0&&x&&O&&b.has(t.terminal.id)&&(f=kC(c,t.terminal.id,_?.currentCommand??null,"finished")),(O||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(f){const x=QT(c,t.terminal.id);x&&(x.workspace.activeTabId!==x.tab.id||x.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),C.delete(t.terminal.id),w.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let _=null;if(t.type==="tab.selected")_=xj(c,t.tabId)?.tab??null;else{const C=c.workspaces.find(w=>w.id===t.workspaceId);_=C?.tabs.find(w=>w.id===C.activeTabId)??null}const b=_?Ii(_.root):[];if(b.some(C=>u.has(C))){const C=new Set(u);for(const w of b)C.delete(w);u=C}}const g=c!==n.state,p=u!==n.unreadCompletions;if((g||p)&&vc(e,{...n,state:c,unreadCompletions:u},o||p),p&&pp(),f)for(const _ of Array.from($_))_({agentId:e,...f})}function Sj(e,t){return e!==void 0&&t!==void 0&&e!==t}function wj(e,t){switch(t.type){case"terminal.updated":return K_(e.terminals[t.terminal.id])!==K_(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 Cj(e){let t=od.get(e);return t||(t=new Map,od.set(e,t)),t}function QT(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Ii(r.root).includes(t))return{workspace:n,tab:r};return null}function xj(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 W_=new Set;function kj(e){return W_.add(e),()=>{W_.delete(e)}}function Tj(){let e=0;for(const t of mr.values())e+=t.unreadCompletions.size;return e}function pp(){for(const e of Array.from(W_))e()}function CC(e,t){const n=Rt(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),vc(e,{...n,unreadCompletions:r}),pp()}function xC(e,t){const n=Rt(e);t!==n.state&&vc(e,{...n,state:t})}function sv(e,t){const n=Rt(e),r=t(n.editors);r!==n.editors&&vc(e,{...n,editors:r},!1)}function Ua(e,t,n){const r=Rt(e);r.loaded===t&&r.error===n||vc(e,{...r,loaded:t,error:n},!1)}function yu(e,t,n){const r=Rt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||vc(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1)}function Ej(e){const t=Rt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function Dj(e){const t=lo(e),n=mr.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=ZT(n);mr.delete(t),sd.delete(t),rd.delete(t),ad.delete(t),od.delete(t),r&&pp(),o&&Jb()}function rv(){let e=!1,t=!1;for(const n of mr.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),ZT(n)&&(t=!0)}mr.clear(),sd.clear(),rd.clear(),ad.clear(),od.clear(),e&&pp(),t&&Jb()}function Rj(e){let t=rd.get(e);return t||(t=new Set,rd.set(e,t)),t}function Mj(e){let t=ad.get(e);return t||(t=new Set,ad.set(e,t)),t}function kC(e,t,n,r){const o=QT(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function q_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of Vo(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 ey(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function V_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function Nj(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 Aj({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,onSelectTab:u,onCreateTab:f,onToggleWorkspaces:g,onCloseTerminals:p,onReattachTerminal:_,onDeleteTerminal:b,onSplitVertical:C,onSplitHorizontal:w,onRenameTab:x,onToggleFavorite:M,onOpenFavorites:O,activePaneAvailable:A}){const[W,F]=v.useState(null),[U,q]=v.useState(!1),[ae,P]=v.useState(null),te=v.useRef(null),G=e.findIndex(R=>R.id===t),ge=G>=0?e[G]:e[0]??null,ee=ge?q_(ge,n):null,V=ge?zf(ge):0,Z=ge?V_(ge,n):"No tab";v.useEffect(()=>{te.current?.focus(),te.current?.select()},[W?.tabId]),v.useEffect(()=>{if(!U)return;const R=I=>{I.key==="Escape"&&q(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[U]),v.useEffect(()=>{U&&e.length===0&&q(!1)},[U,e.length]);function Y(R,I){F({tabId:R,title:I})}function ie(){if(!W)return;const R=W.title.trim();R&&x(W.tabId,R),F(null)}function B(){return h.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[h.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${tN()}`,onClick:C,disabled:!A,children:h.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),h.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${iN()}`,onClick:w,disabled:!A,children:h.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return h.jsxs(h.Fragment,{children:[h.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[h.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:g,children:h.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[h.jsx("span",{}),h.jsx("span",{}),h.jsx("span",{})]})}),h.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Z,onClick:()=>q(!0),disabled:e.length===0,children:[ee?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":ee.state,"aria-hidden":"true",title:ey(ee)}):null,h.jsx("span",{children:Z}),h.jsxs("small",{children:[G>=0?G+1:0,"/",e.length||0,V>1?` / ${V}`:""]})]}),h.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,I)=>{const ue=Vo(R),xe=zf(R),N=V_(R,n),K=R.id===t,de=W?.tabId===R.id,ke=q_(R,n),Ne=r?.has(R.id)??!1;return h.jsxs(jt.Fragment,{children:[h.jsx(TC,{index:I}),h.jsx(Lj,{tab:R,active:K,editing:de,title:N,paneCount:xe,terminalIds:ue,canClose:e.length>1,editValue:de?W.title:null,editInputRef:de?te:null,activity:ke,unread:Ne,favorite:o?.has(R.id)??!1,onSelect:()=>u(R.id),onBeginRename:()=>Y(R.id,N),onCloseAll:()=>p(ue),onCommitRename:ie,onCancelRename:()=>F(null),onRenameChange:Re=>F({tabId:R.id,title:Re}),onToggleFavorite:()=>M?.(R)})]},R.id)}),h.jsx(TC,{index:e.length}),h.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),h.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>O?.(),children:"★"}),(c?.length??0)>0?h.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(c??[]).map(R=>h.jsx(Bj,{terminal:R,onReattach:()=>_?.(R.id),onDelete:()=>P(R)},R.id))}):null]}),h.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),A?B():null]}),U?h.jsx(Oj,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:W,editInputRef:te,onClose:()=>q(!1),onSelectTab:R=>{u(R),q(!1)},onCreateTab:()=>{f(),q(!1)},onBeginRename:Y,onCloseTerminals:R=>{p(R),q(!1)},onCommitRename:ie,onCancelRename:()=>F(null),onRenameChange:(R,I)=>F({tabId:R,title:I}),onToggleFavorite:M,onOpenFavorites:O,onReattachTerminal:R=>{_?.(R),q(!1)},onDeleteTerminal:R=>{P(R),q(!1)}}):null,ae?h.jsx(jj,{terminal:ae,onCancel:()=>P(null),onConfirm:()=>{b?.(ae.id),P(null)}}):null]})}function Lj({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:f,activity:g,unread:p,favorite:_,onSelect:b,onBeginRename:C,onCloseAll:w,onCommitRename:x,onCancelRename:M,onRenameChange:O,onToggleFavorite:A}){const{attributes:W,listeners:F,setNodeRef:U,transform:q,isDragging:ae}=ub({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),P={transform:Xr.Translate.toString(q),opacity:ae?.4:void 0,zIndex:ae?2:void 0};return h.jsxs("div",{ref:U,className:"terminal-tab","data-active":t,"data-dragging":ae,"data-unread":p?"true":void 0,style:P,...W,...F,children:[g?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:ey(g)}):null,n&&f&&u!==null?h.jsxs("form",{className:"terminal-tab-editor",onSubmit:te=>{te.preventDefault(),x()},children:[h.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:u,onBlur:x,onChange:te=>O(te.target.value),onKeyDown:te=>{if(te.key==="Enter"){te.preventDefault(),x();return}te.key==="Escape"&&(te.preventDefault(),M())}}),h.jsx("small",{children:o})]}):h.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:b,onDoubleClick:te=>{te.preventDefault(),C()},children:[h.jsx("span",{children:r}),h.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),n?null:h.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?h.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),w()},children:"x"}):null]})}function Oj({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:u,editInputRef:f,onClose:g,onSelectTab:p,onCreateTab:_,onBeginRename:b,onCloseTerminals:C,onCommitRename:w,onCancelRename:x,onRenameChange:M,onToggleFavorite:O,onOpenFavorites:A,onReattachTerminal:W,onDeleteTerminal:F}){const U=v.useRef(null);return v.useEffect(()=>{U.current?.scrollIntoView?.({block:"nearest"})},[t]),h.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:g,children:h.jsxs("section",{className:"mobile-tab-sheet",onClick:q=>q.stopPropagation(),children:[h.jsxs("header",{children:[h.jsxs("div",{children:[h.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),h.jsxs("small",{children:[e.length," open"]})]}),h.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[h.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:_,children:"+"}),h.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{g(),A?.()},children:"★"}),h.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:g,children:"×"})]})]}),h.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((q,ae)=>{const P=Vo(q),te=zf(q),G=V_(q,n),ge=q.id===t,ee=u?.tabId===q.id,V=q_(q,n),Z=r?.has(q.id)??!1,Y=o?.has(q.id)??!1;return h.jsxs("div",{ref:ge?U:null,className:"mobile-tab-sheet-row","data-active":ge,"data-unread":Z?"true":void 0,children:[ee&&u?h.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),w()},children:h.jsx("input",{ref:f,"aria-label":`Rename ${G}`,value:u.title,onBlur:w,onChange:ie=>M(q.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),w();return}ie.key==="Escape"&&(ie.preventDefault(),x())}})}):h.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${G}`,onClick:()=>p(q.id),children:[h.jsx("span",{className:"mobile-tab-sheet-index",children:ae+1}),h.jsxs("span",{className:"mobile-tab-sheet-copy",children:[h.jsx("strong",{children:G}),h.jsx("small",{children:Nj(q,n,te,V)})]}),h.jsxs("span",{className:"mobile-tab-sheet-meta",children:[V?h.jsx("span",{className:"terminal-tab-status-dot","data-activity":V.state,"aria-hidden":"true",title:ey(V)}):null,h.jsx("span",{children:te})]})]}),h.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ee?h.jsx("button",{type:"button","aria-label":`Done renaming ${G}`,onClick:w,children:"Done"}):h.jsx("button",{type:"button","aria-label":`Rename ${G}`,onClick:()=>b(q.id,G),children:"Rename"}),ee?null:h.jsx("button",{type:"button","aria-label":Y?`Remove ${G} from favorites`:`Add ${G} to favorites`,title:Y?"Remove from favorites":"Add to favorites",onClick:()=>O?.(q),children:Y?"★":"☆"}),e.length>1?h.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${G}`,onClick:()=>C(P),children:"×"}):null]})]},q.id)}),(c?.length??0)>0?h.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[h.jsx("span",{children:"Detached"}),(c??[]).map(q=>{const ae=q.title||q.cwd||q.id.slice(0,8);return h.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[h.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${ae}`,onClick:()=>W(q.id),children:[h.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),h.jsxs("span",{className:"mobile-tab-sheet-copy",children:[h.jsx("strong",{children:ae}),h.jsx("small",{children:q.cwd})]}),h.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),h.jsx("div",{className:"mobile-tab-sheet-actions",children:h.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${ae}`,onClick:()=>F(q),children:"×"})})]},q.id)})]}):null]})]})})}function TC({index:e}){const{setNodeRef:t,isOver:n}=Gf({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return h.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function Bj({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 h.jsxs("span",{className:"terminal-detached-pill",title:o,children:[h.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),h.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 jj({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:h.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),h.jsxs("section",{className:"terminal-delete-dialog-body",children:[h.jsx("p",{children:"Delete this terminal?"}),h.jsx("span",{children:r}),h.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),h.jsxs("div",{className:"terminal-delete-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),h.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function JT(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Ij(e,t){return e.reduce((n,r,o)=>{const c=t.get(r);return c&&(n[o]=c),n},Array(e.length))}function qh(e){return e!==null&&e>=0}function Pj(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 zj(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const ty=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const c=JT(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}},Vh={scaleX:1,scaleY:1},Hj=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 p=c[u];return p?{x:0,y:n<u?p.top+p.height-(f.top+f.height):p.top-f.top,...Vh}:null}const g=Uj(c,o,n);return o>n&&o<=u?{x:0,y:-f.height-g,...Vh}:o<n&&o>=u?{x:0,y:f.height+g,...Vh}:{x:0,y:0,...Vh}};function Uj(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 eE="Sortable",tE=jt.createContext({activeIndex:-1,containerId:eE,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ty,disabled:{draggable:!1,droppable:!1}});function Fj(e){let{children:t,id:n,items:r,strategy:o=ty,disabled:c=!1}=e;const{active:u,dragOverlay:f,droppableRects:g,over:p,measureDroppableContainers:_}=ux(),b=ud(eE,n),C=f.rect!==null,w=v.useMemo(()=>r.map(ae=>typeof ae=="object"&&"id"in ae?ae.id:ae),[r]),x=u!=null,M=u?w.indexOf(u.id):-1,O=p?w.indexOf(p.id):-1,A=v.useRef(w),W=!Pj(w,A.current),F=O!==-1&&M===-1||W,U=zj(c);Us(()=>{W&&x&&_(w)},[W,w,x,_]),v.useEffect(()=>{A.current=w},[w]);const q=v.useMemo(()=>({activeIndex:M,containerId:b,disabled:U,disableTransforms:F,items:w,overIndex:O,useDragOverlay:C,sortedRects:Ij(w,g),strategy:o}),[M,b,U.draggable,U.droppable,F,w,O,g,C,o]);return jt.createElement(tE.Provider,{value:q},t)}const Kj=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return JT(n,r,o).indexOf(t)},$j=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:c,newIndex:u,previousItems:f,previousContainerId:g,transition:p}=e;return!p||!r||f!==c&&o===u?!1:n?!0:u!==o&&t===g},Wj={duration:200,easing:"ease"},iE="transform",qj=Xr.Transition.toString({property:iE,duration:0,easing:"linear"}),Vj={roleDescription:"sortable"};function Yj(e){let{disabled:t,index:n,node:r,rect:o}=e;const[c,u]=v.useState(null),f=v.useRef(n);return Us(()=>{if(!t&&n!==f.current&&r.current){const g=o.current;if(g){const p=dc(r.current,{ignoreTransform:!0}),_={x:g.left-p.left,y:g.top-p.top,scaleX:g.width/p.width,scaleY:g.height/p.height};(_.x||_.y)&&u(_)}}n!==f.current&&(f.current=n)},[t,n,r,o]),v.useEffect(()=>{c&&u(null)},[c]),c}function Xj(e){let{animateLayoutChanges:t=$j,attributes:n,disabled:r,data:o,getNewIndex:c=Kj,id:u,strategy:f,resizeObserverConfig:g,transition:p=Wj}=e;const{items:_,containerId:b,activeIndex:C,disabled:w,disableTransforms:x,sortedRects:M,overIndex:O,useDragOverlay:A,strategy:W}=v.useContext(tE),F=Gj(r,w),U=_.indexOf(u),q=v.useMemo(()=>({sortable:{containerId:b,index:U,items:_},...o}),[b,o,U,_]),ae=v.useMemo(()=>_.slice(_.indexOf(u)),[_,u]),{rect:P,node:te,isOver:G,setNodeRef:ge}=Gf({id:u,data:q,disabled:F.droppable,resizeObserverConfig:{updateMeasurementsFor:ae,...g}}),{active:ee,activatorEvent:V,activeNodeRect:Z,attributes:Y,setNodeRef:ie,listeners:B,isDragging:R,over:I,setActivatorNodeRef:ue,transform:xe}=ub({id:u,data:q,attributes:{...Vj,...n},disabled:F.draggable}),N=$2(ge,ie),K=!!ee,de=K&&!x&&qh(C)&&qh(O),ke=!A&&R,Ne=ke&&de?xe:null,Le=de?Ne??(f??W)({rects:M,activeNodeRect:Z,activeIndex:C,overIndex:O,index:U}):null,Ae=qh(C)&&qh(O)?c({id:u,items:_,activeIndex:C,overIndex:O}):U,We=ee?.id,Pe=v.useRef({activeId:We,items:_,newIndex:Ae,containerId:b}),He=_!==Pe.current.items,fe=t({active:ee,containerId:b,isDragging:R,isSorting:K,id:u,index:U,items:_,newIndex:Pe.current.newIndex,previousItems:Pe.current.items,previousContainerId:Pe.current.containerId,transition:p,wasDragging:Pe.current.activeId!=null}),D=Yj({disabled:!fe,index:U,node:te,rect:P});return v.useEffect(()=>{K&&Pe.current.newIndex!==Ae&&(Pe.current.newIndex=Ae),b!==Pe.current.containerId&&(Pe.current.containerId=b),_!==Pe.current.items&&(Pe.current.items=_)},[K,Ae,b,_]),v.useEffect(()=>{if(We===Pe.current.activeId)return;if(We!=null&&Pe.current.activeId==null){Pe.current.activeId=We;return}const Ce=setTimeout(()=>{Pe.current.activeId=We},50);return()=>clearTimeout(Ce)},[We]),{active:ee,activeIndex:C,attributes:Y,data:q,rect:P,index:U,newIndex:Ae,items:_,isOver:G,isSorting:K,isDragging:R,listeners:B,node:te,overIndex:O,over:I,setNodeRef:N,setActivatorNodeRef:ue,setDroppableNodeRef:ge,setDraggableNodeRef:ie,transform:D??Le,transition:J()};function J(){if(D||He&&Pe.current.newIndex===U)return qj;if(!(ke&&!Vf(V)||!p)&&(K||fe))return Xr.Transition.toString({...p,property:iE})}}function Gj(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}}Bt.Down,Bt.Right,Bt.Up,Bt.Left;function Zj({favorites:e,unavailableFavoriteIds:t,busy:n=!1,error:r=null,getRuntimeStatus:o,onClose:c,onOpen:u,onRemove:f,onReorder:g}){const p=v.useRef(null),[_,b]=v.useState(()=>Date.now()),[C,w]=v.useState("grid"),[x,M]=v.useState(null),O=WC(bf(ob,{activationConstraint:{distance:6}}),bf(lb,{activationConstraint:{delay:180,tolerance:8}})),A=v.useMemo(()=>e.map(zs),[e]),W=v.useMemo(()=>new Map(e.map(P=>[zs(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 G=te.target;if((G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement)&&p.current?.contains(G)||te.ctrlKey||te.altKey||te.metaKey)return;const ge=Number.parseInt(te.key,10)-1;ge>=0&&ge<Math.min(9,e.length)&&(te.preventDefault(),te.stopImmediatePropagation(),u(e[ge]))};return window.addEventListener("keydown",P,!0),()=>window.removeEventListener("keydown",P,!0)},[e,c,u]);const F=P=>{M(null);const te=String(P.active.id),G=P.over?String(P.over.id):null;if(!G||te===G)return;const ge=e.find(V=>zs(V)===te),ee=e.find(V=>zs(V)===G);ge&&ee&&g(ge,ee)},U=P=>M({activeId:String(P.active.id),overId:null}),q=P=>{const te=String(P.active.id),G=P.over?String(P.over.id):null;M(ge=>ge?.activeId===te&&ge.overId===G?ge:{activeId:te,overId:G})},ae=x?e.find(P=>zs(P)===x.activeId)??null:null;return h.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:c,children:h.jsxs("section",{ref:p,className:"favorite-tabs-dialog",onClick:P=>P.stopPropagation(),children:[h.jsxs("header",{className:"favorite-tabs-header",children:[h.jsxs("div",{children:[h.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",h.jsx("span",{children:e.length})]}),h.jsx("p",{children:"Press 1–9 to open a favorite"})]}),h.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[h.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":C==="grid",onClick:()=>w("grid"),children:"▦"}),h.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":C==="list",onClick:()=>w("list"),children:"☷"}),h.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:c,children:"×"})]})]}),h.jsxs(cx,{sensors:O,collisionDetection:cD,onDragStart:U,onDragOver:q,onDragEnd:F,onDragCancel:()=>M(null),children:[h.jsxs("div",{className:"favorite-tabs-list","data-view":C,children:[r?h.jsx("p",{className:"favorite-tabs-error",role:"alert",children:r}):null,e.length===0?h.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):h.jsx(Fj,{items:A,strategy:C==="grid"?ty:Hj,children:e.map((P,te)=>h.jsx(Qj,{favorite:P,index:te,busy:n,unavailable:t?.has(zs(P))??!1,runtimeStatus:W.get(zs(P))??null,now:_,isDropTarget:x?.overId===zs(P)&&x.activeId!==zs(P),onOpen:u,onRemove:f},zs(P)))})]}),h.jsx(vR,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:ae?h.jsx(Jj,{favorite:ae}):null})]})]})})}const Qj=v.memo(function({favorite:t,index:n,busy:r,unavailable:o,runtimeStatus:c,now:u,isDropTarget:f,onOpen:g,onRemove:p}){const _=zs(t),{attributes:b,listeners:C,setActivatorNodeRef:w,setNodeRef:x,transform:M,transition:O,isDragging:A}=Xj({id:_,disabled:r,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),W={transform:Xr.Transform.toString(M),transition:O,zIndex:A?1:void 0,opacity:A?.16:void 0};return h.jsxs("div",{ref:x,className:"favorite-tab-row","data-dragging":A||void 0,"data-drop-target":f||void 0,style:W,children:[h.jsx("button",{ref:w,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${n+1}`,title:"Drag to reorder",onClick:F=>F.stopPropagation(),...b,...C,children:"⋮⋮"}),h.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>g(t),disabled:r||o,title:o?"Server is no longer registered":void 0,children:[h.jsx("span",{className:"favorite-tab-index",children:n<9?n+1:"·"}),h.jsxs("span",{className:"favorite-tab-copy",children:[h.jsx("strong",{children:t.tabName}),h.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),c&&!o?h.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${c.state}`,title:"Last observed terminal status",children:[h.jsx("i",{"aria-hidden":"true"}),e6(c.state),c.lastActivityAt?` · ${t6(c.lastActivityAt,u)}`:""]}):null]}),h.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(F=>h.jsx("img",{src:`/brand/${F}.webp`,alt:"","aria-hidden":"true"},F)),h.jsx("em",{children:t.paneCount})]})]}),h.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:r,onClick:()=>p(t),children:"×"})]})}),Jj=v.memo(function({favorite:t}){return h.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[h.jsx("span",{className:"favorite-tab-index",children:"★"}),h.jsxs("span",{className:"favorite-tab-copy",children:[h.jsx("strong",{children:t.tabName}),h.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),h.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(n=>h.jsx("img",{src:`/brand/${n}.webp`,alt:""},n)),h.jsx("em",{children:t.paneCount})]})]})});function zs(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function e6(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function t6(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 i6({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 h.jsxs("aside",{className:`upload-toast upload-toast-${o6(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[h.jsxs("header",{className:"upload-toast-header",children:[h.jsx("strong",{children:e.length===1?cf(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),h.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),h.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>h.jsx(n6,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function n6({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 h.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":cf(e),children:[h.jsxs("div",{className:"upload-queue-item-header",children:[h.jsx("strong",{children:cf(e)}),h.jsxs("div",{className:"upload-queue-actions",children:[f?h.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?h.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,h.jsx("button",{type:"button","aria-label":`Dismiss ${cf(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?h.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?h.jsx(s6,{toast:e}):null,c&&"message"in e&&e.message?h.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?h.jsx(r6,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?h.jsx("p",{children:e.message}):null]})}function s6({toast:e}){const t=e.percent===null?l6(e.loaded):`${e.percent}%`;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"upload-progress-row",children:[h.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),h.jsx("span",{children:t})]}),h.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:h.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function r6({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 h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?h.jsx("ul",{className:"upload-result-list",children:c.map((u,f)=>h.jsx(a6,{result:u},`${u.relativePath}-${f}`))}):null,e.results.length>c.length?h.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function a6({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return h.jsxs("li",{"data-status":e.status,children:[h.jsx("span",{className:"upload-result-path",children:t}),n?h.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?h.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function cf(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 o6(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 l6(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function c6({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 h.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:f,children:[h.jsxs("header",{className:"completion-toast-header",children:[h.jsxs("div",{className:"completion-toast-copy",children:[h.jsx("strong",{children:r.tabTitle}),h.jsx("span",{children:c})]}),h.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),h.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const u6=Ru(0,0,1,1),Kr=1e-6;function d6(e){return nE(e).map(t=>t.terminalId)}function nE(e){return Du(e,u6).sort(m6).map((t,n)=>({...t,index:n+1}))}function h6(e,t,n){const r=nE(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>p6(o,u,n)).filter(u=>u!==null).sort(g6)[0]?.entry.terminalId??null:null}function f6(e,t){return!Number.isInteger(t)||t<1?null:d6(e)[t-1]??null}function Du(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=v6(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Du(e.first,Ru(t.left,t.top,o,t.bottom)),...Du(e.second,Ru(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...Du(e.first,Ru(t.left,t.top,t.right,r)),...Du(e.second,Ru(t.left,r,t.right,t.bottom))]}function p6(e,t,n){const r=e.bounds,o=t.bounds,c=EC(r.left,r.right,o.left,o.right),u=EC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Kr||u<=Kr?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+Kr||u<=Kr?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-Kr||c<=Kr?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+Kr||c<=Kr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function m6(e,t){return Ql(e.bounds.top,t.bounds.top)||Ql(e.bounds.left,t.bounds.left)}function g6(e,t){return Ql(e.primaryDistance,t.primaryDistance)||Ql(e.perpendicularDistance,t.perpendicularDistance)||Ql(t.overlap,e.overlap)||Ql(e.entry.index,t.entry.index)}function Ql(e,t){const n=e-t;return Math.abs(n)<=Kr?0:n}function EC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function Ru(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function v6(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const DC="nterminal.terminalWorkspaces.v2",sE="nterminal.sidebarCollapsed.v1",_6=75,RC=fx.map(e=>e.url),b6=fx[0].url,y6=6;function S6({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??Kf(),[e]),p=v.useMemo(()=>t??Va(null),[t]),_=v.useMemo(()=>$6(n),[n]),b=v.useMemo(()=>S=>GT(n,S),[n]),C=v.useMemo(()=>()=>Rt(n),[n]),w=v.useSyncExternalStore(b,C,C),x=w.state,M=w.editors,O=!w.loaded,A=w.error,[W,F]=v.useState(!1),[U,q]=v.useState(()=>Z6()),[ae,P]=v.useState("servers"),[te,G]=v.useState(!1),[ge,ee]=v.useState(!1),[V,Z]=v.useState([]),[Y,ie]=v.useState(!1),[B,R]=v.useState(null),[I,ue]=v.useState(null),xe=v.useMemo(()=>Va(I?.agentId??null),[I?.agentId]),N=v.useSyncExternalStore(hN,Fw,Fw);v.useSyncExternalStore(Bu,Uw,Uw);const[K,de]=v.useState(0),[ke,Ne]=v.useState(null),[Re,Le]=v.useState(()=>[null]),[Ae,We]=v.useState(()=>({[ti]:"Local"})),[Pe,He]=v.useState(0),[fe,D]=v.useState(()=>[n]),[J,Ce]=v.useState(()=>new Set),[Ee,$]=v.useState({}),[Te,_e]=v.useState(null),pe=v.useRef(0),Ie=v.useRef(0),[Ue,Ke]=v.useState(null),[nt,Mt]=v.useState(null),ht=v.useRef(null),Dt=v.useRef(0),vt=v.useRef(null),$t=v.useRef(null),si=v.useRef(null),Se=v.useRef(null),Ve=v.useRef([]),rt=v.useRef(0),tt=v.useRef(!1),kt=v.useRef(0),lt=v.useRef(0),qi=v.useRef([]),li=v.useRef(null),re=v.useRef(()=>{}),[Fe,ct]=v.useState(null),ut=WC(bf(ob,{activationConstraint:{distance:8}}),bf(lb,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>fN(g),[g]);function Lt(S){const T=S.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){ct({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&ct({tabId:T.sourceTabId,terminalId:T.terminalId})}}function fi(S){ct(null);const T=S.active.data.current,L=S.over?.data.current;if(!(!T||!L||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(L.kind==="tab-position"&&typeof L.index=="number"){Qe({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:L.index});return}if(L.kind==="workspace"&&typeof L.workspaceId=="string"){Qe({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:L.workspaceId});return}L.kind==="pane-zone"&&typeof L.terminalId=="string"&&(L.side==="top"||L.side==="right"||L.side==="bottom"||L.side==="left")&&Qe({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:L.terminalId,side:L.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(L.kind==="tab-position"&&typeof L.index=="number"){Qe({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:L.index});return}if(L.kind==="workspace"&&typeof L.workspaceId=="string"){Qe({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:L.workspaceId});return}L.kind==="pane-zone"&&typeof L.terminalId=="string"&&(L.side==="top"||L.side==="right"||L.side==="bottom"||L.side==="left")&&Qe({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:L.terminalId,side:L.side})}}}function wi(){ct(null)}const at=x.workspaces.find(S=>S.id===x.activeWorkspaceId)??x.workspaces[0],Tt=at?.tabs.find(S=>S.id===at.activeTabId)??at?.tabs[0],zt=Tt?.activeTerminalId??null,Di=zt?x.terminals[zt]:void 0,Wt=P6("(max-width: 760px)"),nn=v.useMemo(()=>Tt?Uf(Tt.root):[],[Tt]),ii=at&&Tt?Mu(n,at.id,Tt.id):null,sn=Tt?rE(nn,Tt.activeTerminalId,ii?Ee[ii]:void 0):null,_n=Wt&&nn.length>1,Rn=v.useMemo(()=>(at?.detachedTerminalIds??[]).flatMap(S=>{const T=x.terminals[S];return T?[T]:[]}),[at?.detachedTerminalIds,x.terminals]),gi=v.useMemo(()=>{const S=new Set;for(const T of at?.tabs??[])Vo(T).some(L=>w.unreadCompletions.has(L))&&S.add(T.id);return S},[at?.tabs,w.unreadCompletions]);v.useSyncExternalStore(_j,wC,wC);const[fn,Ri]=v.useState([]),qt=v.useRef([]),Qt=v.useRef(null),[bn,ws]=v.useState(null),[Cs,xs]=v.useState(null),[Ws,Vn]=v.useState([]),[Yn,ks]=v.useState(()=>Qo()),Ts=v.useRef(0),Xn=v.useRef(n),Es=v.useRef(RC),Ht=v.useRef(Yn),uo=v.useRef(()=>{});uo.current=Sr,re.current=Hi;const qs=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();Vn(S.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Vn([])}},[g]),Vt=v.useCallback(S=>{We(T=>{const L={...T};for(const Q of S)L[hf(Q.agentId)]=Q.label;return av(T,L)?T:L})},[]);v.useEffect(()=>{const S=lt.current+1;lt.current=S;const T=kt.current;g.getFavorites().then(L=>{S!==lt.current||T!==kt.current||(Vs(L.favorites,L.revision),na(L.favorites,n,x))}).catch(()=>{})},[g]),v.useEffect(()=>{na(Ve.current,n,x)},[n,Ae]),v.useEffect(()=>{D(S=>S.some(T=>bi(T,n))?S:[...S,n])},[n]);const yn=v.useCallback(S=>{const T=Rt(S),L=Va(S);for(const Q of Object.keys(T.state.terminals))Wl(L.createWebSocketUrl(Q)),_u(Q),$l(Q);Dj(S),D(Q=>Q.filter(le=>!bi(le,S))),Ce(Q=>{const le=`${df(S)}:`;let ce=!1;const be=new Set;for(const Be of Q){if(Be.startsWith(le)){ce=!0;continue}be.add(Be)}return ce?be:Q}),$(Q=>{const le=`${df(S)}:`;let ce=!1;const be={};for(const[Be,je]of Object.entries(Q)){if(Be.startsWith(le)){ce=!0;continue}be[Be]=je}return ce?be:Q})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(T=>{if(S)return;const L=T.name?.trim()||"Local";We(Q=>{const le={...Q,[ti]:L};return av(Q,le)?Q:le})}).catch(()=>{}),g.listAgents().then(T=>{if(!S){const L=T.agents.map(ce=>ce.id),Q=CM(T.serverOrder,T.agents);We(ce=>{const be={[ti]:ce[ti]??"Local"};for(const Be of T.agents)be[Be.id]=Be.name;return av(ce,be)?ce:be}),n!==null&&!L.includes(n)&&(yn(n),r?.(null));const le=Se.current;le&&le.serverId!==ti&&!L.includes(le.serverId)&&(Se.current=null,R(`${le.serverName} is no longer registered.`),ee(!0)),Le(Q)}}).catch(()=>{}),()=>{S=!0}},[n,g,yn,r,Pe]);const Sn=v.useCallback(S=>{yn(S),He(T=>T+1),bi(S,Xn.current)&&r?.(null)},[yn,r]);v.useEffect(()=>{Le(S=>S.some(T=>bi(T,n))?S:[...S,n])},[n]),v.useEffect(()=>{Xn.current=n},[n]),v.useEffect(()=>{Ne(null)},[n]),v.useEffect(()=>{const S=vt.current;if(!S)return;if(!bi(S.agentId,n)){vt.current=null;return}if(!w.loaded||x.workspaces.length===0)return;vt.current=null;const T=S.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];T&&T.id!==x.activeWorkspaceId&&Qe({type:"workspace.selected",workspaceId:T.id})},[n,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const S=$t.current;if(S){if(!bi(S.agentId,n)){$t.current=null;return}w.loaded&&($t.current=null,x.workspaces.some(T=>T.id===S.workspaceId)&&Qe({type:"workspace.selected",workspaceId:S.workspaceId}))}},[n,w.loaded,x.workspaces]),v.useEffect(()=>{const S=si.current;if(S){if(!bi(S.agentId,n)){si.current=null;return}w.loaded&&(si.current=null,w.error||Ds())}},[n,w.error,w.loaded]),v.useEffect(()=>{const S=Se.current;if(!(!S||!bi(S.serverId===ti?null:S.serverId,n)||!w.loaded)){if(Se.current=null,w.error){R(`Could not reach ${S.serverName}.`),ee(!0);return}_r(S)}},[n,w.loaded]),v.useEffect(()=>{wr()},[n,w.loaded,x]),v.useEffect(()=>{const S=()=>{const Q=H6();Q&&re.current(Q)},T=Q=>{const le=U6(Q.data);le&&re.current(le)},L=Q=>{const le=Zf(Q.detail);le&&re.current(le)};return S(),window.addEventListener("hashchange",S),window.addEventListener(pv,L),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",S),window.removeEventListener(pv,L),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{qs()},[qs]),v.useEffect(()=>Cx(()=>ks(Qo())),[]),v.useEffect(()=>{const S=T=>{uo.current(T)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{Es.current=Ws.length>0?Ws:RC},[Ws]),v.useEffect(()=>{Ht.current=Yn},[Yn]),v.useEffect(()=>{if(!w.loaded||!at||!Tt)return;const S=Mu(n,at.id,Tt.id);Ce(T=>{if(T.has(S))return T;const L=new Set(T);return L.add(S),L})},[n,w.loaded,at?.id,Tt?.id]),v.useEffect(()=>()=>{ll()},[]),v.useEffect(()=>{const S=pM(g),T=vM(g);return()=>{S(),T()}},[g]),v.useEffect(()=>yj(S=>{const T=Rt(S.agentId).state,L=T.workspaces.flatMap(be=>be.tabs).find(be=>be.id===S.tabId),Q=T.terminals[S.terminalId],le=L?.title?.trim()||Q?.title||S.commandName||"terminal",ce=document.visibilityState==="visible"&&bi(S.agentId,Xn.current)&&S.tabId===K6(T);if(ce||lM({agentId:S.agentId,tabTitle:le,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!ce&&document.visibilityState==="visible"&&Ht.current.enabled){const be=Ts.current+1;Ts.current=be;const Be=Es.current;ws({id:be,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:le,commandName:S.commandName,outcome:S.outcome,assetSrc:Be[Math.floor(Math.random()*Be.length)]??b6})}}),[]),v.useEffect(()=>{if(!bn||Yn.persistUntilDismissed)return;const S=window.setTimeout(()=>{ws(T=>T?.id===bn.id?null:T)},Yn.durationSeconds*1e3);return()=>window.clearTimeout(S)},[bn,Yn]),v.useEffect(()=>{Q6(U),U&&ho()},[U]),v.useEffect(()=>{let S=!1;async function T(){if(!Rt(n).loaded){Ua(n,!1,null);try{let Q=null,le=null;try{Q=W6(_)}catch(je){if(!(je instanceof Ff))throw je;le=je}const[ce,be]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Be=ce.terminals.length>0?ce.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!S){const je=be.layout?oE(be.layout):null;if(!je&&le)throw le;const _t=je??Q??{},It=B_(Be,void 0,_t.savedWorkspaces,_t.savedActiveWorkspaceId),ss=nv(It);xC(n,It),yu(n,be.revision,JSON.stringify(ss)),Ua(n,!0,null),!je&&Q&&da(ss,{baseRevision:be.revision})}}catch(Q){!S&&!Ys(Q)&&Ua(n,!0,Fa(Q))}}}return T(),()=>{S=!0}},[n,p,K]);function Jr(){Ua(n,!1,null),de(S=>S+1)}function ho(){pe.current+=1,Ie.current+=1,_e(null)}function gr(S){pe.current+=1,Ie.current+=1,_e(T=>T&&{...T,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Ds(){pe.current+=1,Ie.current+=1;const S=x.workspaces.length+1,T=Vi();_e({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&Gn(T)}function ea(S){if(bi(S,n)){Ds();return}si.current={agentId:S},r?.(S)}function pn(S){if(U&&!W)return;const T=x.workspaces.find(Q=>Q.id===S);if(!T)return;pe.current+=1,Ie.current+=1;const L=T.defaultCwd??Di?.cwd??"";_e({mode:"edit",workspaceId:S,title:T.title,cwd:L,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),L&&Gn(L)}function Vi(){return at?.defaultCwd??Di?.cwd??""}async function Gn(S){const T=pe.current+1;pe.current=T;const L=S.trim();if(_e(Q=>Q&&{...Q,cwd:S,browseStatus:L?"loading":"idle",browseRoot:null,browseEntries:[],error:L?null:"Choose a default working directory."}),!!L)try{const Q=await p.createFileRoot({path:L}),le=await p.listFiles({rootToken:Q.rootToken,path:""});if(pe.current!==T)return;_e(ce=>ce&&{...ce,cwd:Q.rootPath,browseRoot:{rootToken:Q.rootToken,rootPath:Q.rootPath},browseEntries:le.entries.filter(be=>be.kind==="directory"),browseStatus:"idle",error:null})}catch(Q){if(pe.current!==T)return;_e(le=>le&&{...le,browseStatus:"idle",error:Fa(Q)})}}async function fo(){const S=Te;if(!S)return;const T=S.title.trim(),L=S.cwd.trim();if(!T||!L){_e({...S,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const Q=Ie.current+1;Ie.current=Q,_e({...S,submitStatus:"submitting",error:null});try{const le=await p.createFileRoot({path:L});if(Ie.current!==Q)return;if(S.mode==="create"){const ce=x.workspaces.length+1;Qe({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ce}`,title:T,defaultCwd:le.rootPath})}else S.workspaceId&&(Qe({type:"workspace.renamed",workspaceId:S.workspaceId,title:T}),Qe({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:le.rootPath}));_e(null)}catch(le){if(Ie.current!==Q)return;_e(ce=>ce&&{...ce,submitStatus:"idle",error:Fa(le)})}}function Rs(S){Ie.current+=1,_e(S)}function rn(S,T,L){if(S===T)return;const Q=x.workspaces.some(ce=>ce.id===S),le=x.workspaces.some(ce=>ce.id===T);!Q||!le||Qe({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:T,placement:L})}function Ms(S,T){const L=x.workspaces.findIndex(le=>le.id===S),Q=x.workspaces[L+T];L<0||!Q||rn(S,Q.id,T<0?"before":"after")}function _c(S,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),ht.current={sourceId:S,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function Yi(S){const T=ht.current;if(!T||T.pointerId!==S.pointerId)return;const L=Math.hypot(S.clientX-T.startX,S.clientY-T.startY);if(!T.active){if(L<y6)return;T.active=!0,Ke(T.sourceId)}const le=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),ce=le?.dataset.workspaceId??null;if(!le||!ce||ce===T.sourceId||!x.workspaces.some(je=>je.id===ce)){T.targetId=null,Mt(null);return}const be=le.getBoundingClientRect(),Be=S.clientY<be.top+be.height/2?"before":"after";T.targetId=ce,T.placement=Be,Mt({workspaceId:ce,placement:Be})}function ta(S){const T=ht.current;!T||T.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),ht.current=null,Ke(null),Mt(null),T.active&&T.targetId&&rn(T.sourceId,T.targetId,T.placement))}function vr(S){const T=ht.current;T&&T.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),ht.current=null,Ke(null),Mt(null)}async function ia(){await Mn(async()=>{const S=at?.defaultCwd?{cols:80,rows:24,cwd:at.defaultCwd}:{cols:80,rows:24},T=await p.createTerminal(S);Qe({type:"terminal.created",terminal:T.terminal})})}function an(S,T=at,L=x,Q=n){const le=L.terminals[S.activeTerminalId],ce=Array.from(new Set(Vo(S).flatMap(be=>{const Be=L.terminals[be]?.agentStatus?.provider;return Be==="codex"||Be==="claude"?[Be]:[]})));return{serverId:Q??ti,workspaceId:T.id,tabId:S.id,serverName:Ae[hf(Q)]??"Local",workspaceName:T.title,tabName:S.title||le?.title||"Terminal",cwd:le?.cwd||T.defaultCwd,paneCount:zf(S),providers:ce}}function po(S){const T=S.serverId===ti?null:S.serverId,L=gj(T);if(!L?.loaded||L.error)return null;const Q=L.state,ce=Q.workspaces.find(je=>je.tabs.some(_t=>_t.id===S.tabId))?.tabs.find(je=>je.id===S.tabId);if(!ce)return null;const be=Vo(ce).flatMap(je=>{const _t=Q.terminals[je];return _t?[_t]:[]});if(be.length===0)return null;const Be=be.reduce((je,_t)=>{const It=_t.agentCache?.lastCallAt;return It&&(!je||Date.parse(It)>Date.parse(je))?It:je},null);return be.some(je=>je.status==="running"&&(je.agentStatus?.state==="working"||!je.agentStatus&&je.activity==="busy"))?{state:"working",lastActivityAt:Be}:be.some(je=>je.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Be}:be.some(je=>je.agentStatus?.state==="done")?{state:"done",lastActivityAt:Be}:be.every(je=>je.status==="exited")?{state:"exited",lastActivityAt:Be}:{state:"idle",lastActivityAt:Be}}function Vs(S,T){Ve.current=S,rt.current=T,Z(S)}function Ci(S){kt.current+=1,qi.current.push(S),!tt.current&&(tt.current=!0,ie(!0),R(null),(async()=>{try{for(;qi.current.length>0;){const T=qi.current.shift();let L=0;for(;L<2;){const Q=T(Ve.current);if(NC(Q,Ve.current))break;Vs(Q,rt.current);try{const le=await g.saveFavorites({favorites:Q,baseRevision:rt.current});Vs(le.favorites,le.revision);break}catch(le){const ce=await g.getFavorites().catch(()=>null);if(ce&&Vs(ce.favorites,ce.revision),le instanceof dn&&le.status===409&&ce){L+=1;continue}qi.current=[],R("Could not save favorites. Please try again.");return}}if(L>=2){qi.current=[],R("Favorites changed on another device. Please try again.");return}}}finally{tt.current=!1,ie(!1)}})())}function na(S,T,L){const Q=T??ti,le=S.map(ce=>{if(ce.serverId!==Q)return ce;const be=L.workspaces.find(je=>je.tabs.some(_t=>_t.id===ce.tabId)),Be=be?.tabs.find(je=>je.id===ce.tabId);return be&&Be?an(Be,be,L,T):ce});NC(S,le)||Ci(()=>le)}function sa(S){const T=n??ti,L=Ve.current.find(le=>le.serverId===T&&le.tabId===S.id);if(L){const le=vs(L);Ci(ce=>ce.filter(be=>vs(be)!==le));return}if(!at||Ve.current.length>=100)return;const Q=an(S);Ci(le=>le.length>=100?le:[...le,Q])}function Ns(S){const T=S.serverId===ti?null:S.serverId;if(T!==null&&!Re.some(L=>bi(L,T))){R(`${S.serverName} is no longer registered.`);return}if(R(null),ee(!1),!bi(T,n)){Se.current=S,r?.(T);return}_r(S)}async function _r(S){const T=Rt(n).state,L=T.workspaces.find(le=>le.tabs.some(ce=>ce.id===S.tabId));if(L){Qe({type:"workspace.selected",workspaceId:L.id}),Qe({type:"tab.selected",tabId:S.tabId});return}let Q=T.workspaces.find(le=>le.id===S.workspaceId);if(!Q){const le=`workspace-favorite-${Date.now().toString(36)}`;Qe({type:"workspace.created",workspaceId:le,title:S.workspaceName,defaultCwd:S.cwd}),Q=Rt(n).state.workspaces.find(ce=>ce.id===le)}Q&&Qe({type:"workspace.selected",workspaceId:Q.id}),await Mn(async()=>{const le=await p.createTerminal(S.cwd?{cols:80,rows:24,cwd:S.cwd}:{cols:80,rows:24});Qe({type:"terminal.created",terminal:le.terminal});const be=Rt(n).state.workspaces.find(ci=>ci.tabs.some(rs=>rs.activeTerminalId===le.terminal.id)),Be=be?.tabs.find(ci=>ci.activeTerminalId===le.terminal.id);if(!Be||!be)return;Be.title!==S.tabName&&Qe({type:"tab.renamed",tabId:Be.id,title:S.tabName});const je=Rt(n).state,_t=je.workspaces.find(ci=>ci.id===be.id)??be,It=_t.tabs.find(ci=>ci.id===Be.id)??Be,ss=an(It,_t,je);Ci(ci=>ci.map(rs=>rs.serverId===S.serverId&&rs.workspaceId===S.workspaceId&&rs.tabId===S.tabId?ss:rs))})}async function ra(S){await Mn(async()=>{const T=zt?{parentTerminalId:zt,cols:80,rows:24}:at?.defaultCwd?{cols:80,rows:24,cwd:at.defaultCwd}:{cols:80,rows:24},L=await p.createTerminal(T);Qe({type:"terminal.split",terminal:L.terminal,direction:S})})}async function bc(S){let T=zt,L=ii;const Q=at?.defaultCwd?.trim();if(!T&&!Q)throw new Error("No active pane is available.");const le=await p.readFile(S);if(!T&&Q){const Be=await p.createTerminal({cols:80,rows:24,cwd:Q});T=Be.terminal.id,Qe({type:"terminal.created",terminal:Be.terminal})}if(T){Qe({type:"pane.selected",terminalId:T});const Be=Rt(n).state,je=Be.workspaces.find(It=>It.id===Be.activeWorkspaceId)??Be.workspaces[0],_t=je?.tabs.find(It=>It.id===je.activeTabId)??je?.tabs[0];L=je&&_t?Mu(n,je.id,_t.id):null}const ce=`editor-${Date.now().toString(36)}-${Ej(n)}`,be=G6(le.path);sv(n,Be=>({...Be,[ce]:{id:ce,title:be,rootToken:S.rootToken,path:le.path,read:le}})),L&&$(Be=>({...Be,[L]:aE(ce)})),Qe({type:"editor.split",editorId:ce,title:be,direction:"vertical"})}function As(S){sv(n,T=>{const L={...T};return delete L[S],L}),Qe({type:"editor.closed",editorId:S})}function Zn(S){Pi([S])}function Pi(S){const T=[...new Set(S)].filter(Q=>x.terminals[Q]);if(T.length===0)return;const L=T.length===1?x.terminals[T[0]]?.title||x.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;Ne(null),xs({terminalIds:T,label:L,workspaceId:at?.id??x.activeWorkspaceId??null})}function mo(S,T){const L=Zs(S,T);if(!L)return!1;const Q=S.filter(le=>!L.detachedTerminalIds.includes(le));if(L.detachedTerminalIds.length+Q.length>hc)return Ne(V6(L.detachedTerminalIds.length)),!1;Ne(null);for(const le of S)Qe(L.id?{type:"terminal.detached",terminalId:le,workspaceId:L.id}:{type:"terminal.detached",terminalId:le});return!0}async function Ls(S){await Mn(async()=>{for(const T of S)await wn(T),Wl(p.createWebSocketUrl(T)),_u(T),$l(T),Qe({type:"terminal.closed",terminalId:T})})}async function Mi(S){const T=x.workspaces.find(L=>L.id===S);!T||x.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Mn(async()=>{const L=Hf(T),Q=[];let le=null;for(const be of L)try{await wn(be)}catch(Be){Q.push(Fa(Be)),Be instanceof dn&&Be.status===401&&!p.isAgent&&(le=Be)}finally{Wl(p.createWebSocketUrl(be)),_u(be),$l(be)}const ce=T.tabs.flatMap(be=>Y_(be.root));if(ce.length>0){const be=new Set(ce);sv(n,Be=>{const je={...Be};for(const _t of be)delete je[_t];return je})}if(Qe({type:"workspace.closed",workspaceId:S}),le)throw le;if(Q.length>0)throw new Error(`Workspace was removed, but ${Q.length} terminal session${Q.length===1?"":"s"} may still be running. ${Q[0]}`)})}async function br(S){await Mn(async()=>{await wn(S),Wl(p.createWebSocketUrl(S)),_u(S),$l(S),Qe({type:"terminal.closed",terminalId:S})})}async function yr(S,T){const L=T.trim();if(!L)return;let Q=null;for(const le of x.workspaces){const ce=le.tabs.find(be=>be.id===S);if(ce){Q=ce.activeTerminalId;break}}if(Qe({type:"tab.renamed",tabId:S,title:L}),!!Q)try{const le=await p.renameTerminal(Q,L);Qn({type:"terminal.updated",terminal:le.terminal})}catch(le){Ua(n,!0,Fa(le))}}function go(S){const T=x.terminals[S];T&&Qe({type:"terminal.created",terminal:T})}async function wn(S){try{await p.closeTerminal(S)}catch(T){if(T instanceof dn&&T.status===404)return;throw T}}async function xi(){await Mn(async()=>{await u()})}async function Mn(S){Ua(n,!0,null);try{await S()}catch(T){if(Ys(T))return;Ua(n,!0,Fa(T))}}function Ys(S){return S instanceof dn&&S.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function Qe(S){Ha(n,S);const T=Rt(n),L=T.state;if(na(Ve.current,n,L),!T.loaded||L.workspaces.length===0)return;const Q=nv(L);JSON.stringify(Q)!==T.lastPersistedLayoutJson&&ua(Q)}function Qn(S){Ha(n,S),na(Ve.current,n,Rt(n).state)}function Jn(S,T,L,Q){const le=Mu(S,T,L);$(ce=>({...ce,[le]:Q}))}function aa(S){ii&&$(T=>({...T,[ii]:S}))}function Xs(S,T){const L=Fu(S);T?Jn(n,T.workspaceId,T.tabId,L):aa(L),Qe({type:"pane.selected",terminalId:S})}function Gs(S){aa(S.key),S.type==="terminal"&&Qe({type:"pane.selected",terminalId:S.terminalId})}function Sr(S){if(te||Cs||S.isComposing||S.key==="Process"||E6(S.target))return;const T=C6(S);if(!T)return;if(S.preventDefault(),S.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){es(T.type==="server.next"?1:-1);return}if(T.type==="favorites.toggle"){ee(!0);return}const L=Rt(n).state,Q=L.workspaces.find(be=>be.id===L.activeWorkspaceId)??L.workspaces[0],le=Q?.tabs.find(be=>be.id===Q.activeTabId)??Q?.tabs[0];if(T.type==="split"){if(!le)return;ra(T.direction);return}if(!Q||!le)return;if(T.type==="tab.previous"||T.type==="tab.next"){const be=T6(Q.tabs,le.id,T.type==="tab.next"?1:-1);be&&Qe({type:"tab.selected",tabId:be.id});return}if(T.type==="tab.index"){const be=Q.tabs[T.index-1];be&&Qe({type:"tab.selected",tabId:be.id});return}const ce=x6(le.root,le.activeTerminalId,T);ce&&Xs(ce,{workspaceId:Q.id,tabId:le.id})}function zi(S,T){if(!r||Re.length===0)return;const L=Re.findIndex(be=>bi(be,n)),le=((L===-1?0:L)+S+Re.length)%Re.length,ce=Re[le]??null;bi(ce,n)||(T&&(vt.current={agentId:ce,edge:T}),r(ce))}function es(S){const T=Rt(n).state,L=T.workspaces;if(L.length===0){zi(S,S===1?"first":"last");return}const Q=L.findIndex(be=>be.id===T.activeWorkspaceId),ce=(Q===-1?0:Q)+S;if(ce>=0&&ce<L.length){Qe({type:"workspace.selected",workspaceId:L[ce].id});return}zi(S,S===1?"first":"last")}function Os(S,T){if(bi(S,n)){Qe({type:"workspace.selected",workspaceId:T});return}$t.current={agentId:S,workspaceId:T},r?.(S)}function Zs(S,T){if(T)return x.workspaces.find(L=>L.id===T)??null;for(const L of S){const Q=x.workspaces.find(ce=>ce.tabs.some(be=>Vo(be).includes(L)));if(Q)return Q;const le=x.workspaces.find(ce=>ce.detachedTerminalIds.includes(L));if(le)return le}return x.workspaces.find(L=>L.id===x.activeWorkspaceId)??x.workspaces[0]??null}function yc(S){Gl(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function vo(S){if(!Gl(S.dataTransfer))return;S.preventDefault();const T=Y6(Rt(n).state),L=Dt.current+1;if(Dt.current=L,!T){bo({id:L,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}bo({id:L,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),_o(L,T.id,S.dataTransfer)}async function _o(S,T,L){try{const Q=await lT(L);if(Q.length===0)throw new Error("No files were found in the drop.");is(S,{id:S,status:"queued",fileCount:Q.length,message:"Queued"},{terminalId:T,files:Q})}catch(Q){is(S,{id:S,status:"failed",fileCount:0,message:Fa(Q)},{terminalId:T})}finally{ts()}}async function Qs(S){const T=qt.current.find(ce=>ce.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const L=T.terminalId,Q=T.files,le=new AbortController;Qt.current=S,is(S,{id:S,status:"uploading",fileCount:Q.length,loaded:0,total:null,percent:null},{terminalId:L,files:Q,abortController:le});try{const ce=await jC({terminalId:L,files:Q,signal:le.signal,onProgress:_t=>{is(S,{id:S,status:"uploading",fileCount:Q.length,loaded:_t.loaded,total:_t.total,percent:_t.percent},{terminalId:L,files:Q,abortController:le})}}),be=ce.failed>0?ce.uploaded>0?"partial":"failed":"success",Be=ce.failed>0?X6(ce):void 0,je={id:S,status:be,fileCount:Q.length,response:ce};Be&&(je.message=Be),is(S,je,{terminalId:L,files:Q})}catch(ce){is(S,{id:S,status:"failed",fileCount:Q.length,message:le.signal.aborted?"Upload canceled.":Fa(ce)},{terminalId:L,files:Q})}finally{Qt.current===S&&(Qt.current=null),ts()}}function ts(){if(Qt.current!==null)return;const S=qt.current.find(T=>T.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&Qs(S.id)}function bo(S){oa(T=>[...T,S])}function is(S,T,L={}){oa(Q=>Q.map(le=>{if(le.id!==S)return le;const ce={...T},be=L.terminalId??le.terminalId,Be=L.files??le.files;return be!==void 0&&(ce.terminalId=be),Be!==void 0&&(ce.files=Be),L.abortController!==void 0&&(ce.abortController=L.abortController),ce}))}function oa(S){const T=S(qt.current);qt.current=T,Ri(T)}function la(S){qt.current.find(L=>L.id===S)?.abortController?.abort(),Qt.current===S&&(Qt.current=null),oa(L=>L.filter(Q=>Q.id!==S)),ts()}function yo(){for(const S of qt.current)S.abortController?.abort();Qt.current=null,oa(()=>[])}function Sc(S){const T=qt.current.find(L=>L.id===S);if(T){if(T.status==="queued"){la(S);return}T.abortController?.abort()}}function ca(S){const T=qt.current.find(Q=>Q.id===S);if(!T?.terminalId||!T.files||T.files.length===0)return;const L=Js(T);if(L.length===0){is(S,{id:S,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}is(S,{id:S,status:"queued",fileCount:L.length,message:"Queued"},{terminalId:T.terminalId,files:L}),ts()}function Js(S){const T=S.files??[],L="response"in S?S.response:void 0;if(!L)return T;const Q=L.results.filter(be=>be.status==="failed").map(be=>be.relativePath);if(Q.length===0)return[];const le=new Map;for(const be of T){const Be=le.get(be.relativePath)??[];Be.push(be),le.set(be.relativePath,Be)}const ce=[];for(const be of Q){const je=le.get(be)?.shift();je&&ce.push(je)}return ce}function So(S){const L=Rt(S.agentId).state.workspaces.find(Q=>Q.tabs.some(le=>le.id===S.tabId));L&&Jn(S.agentId,L.id,S.tabId,Fu(S.terminalId)),Ha(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),CC(S.agentId,S.terminalId),bi(S.agentId,n)||r?.(S.agentId),ws(null)}function Hi(S){if(li.current=S,!bi(S.agentId,n)){r?r(S.agentId):li.current=null;return}wr()}function wr(){const S=li.current;if(!S||!bi(S.agentId,n)||!w.loaded)return;const T=Rt(S.agentId),L=F6(T.state,S.terminalId);li.current=null,L&&(Jn(S.agentId,L.workspaceId,L.tabId,Fu(S.terminalId)),Ha(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),CC(S.agentId,S.terminalId))}function ua(S){const T=Rt(n).mutable.saveCoord;T.pendingLayoutSave=S,Su(S,_),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const L=T.pendingLayoutSave;T.pendingLayoutSave=null,L&&da(L)},_6)}function ll(){const S=Rt(n).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const T=S.pendingLayoutSave;S.pendingLayoutSave=null,T&&(Su(T,_),da(T))}function da(S,T={}){const L=Rt(n).mutable.saveCoord;L.nextPersistLayout=S,T.baseRevision!==void 0&&(L.queuedBaseRevision=T.baseRevision),!L.nextPersistQueued&&(L.nextPersistQueued=!0,L.persistChain=L.persistChain.then(async()=>{L.nextPersistQueued=!1;const Q=L.nextPersistLayout,le=L.queuedBaseRevision;L.nextPersistLayout=null,L.queuedBaseRevision=void 0,Q&&await cl(Q,le!==void 0?{baseRevision:le}:{})}))}async function cl(S,T={}){const L=Rt(n),Q=T.baseRevision??L.layoutRevision,le={layout:S,...typeof Q=="number"?{baseRevision:Q}:{}};try{const ce=await p.saveTerminalLayout(le),be=ce.layout??S;yu(n,ce.revision,JSON.stringify(be)),Su(be,_);return}catch(ce){if(ce instanceof dn&&ce.status===400&&ce.message===yR){q6(n,_),Ua(n,!0,lE());return}if(ce instanceof dn&&ce.status===409)try{const be=await p.getTerminalLayout(),Be=Rt(n).mutable.saveCoord;if(Be.nextPersistLayout||Be.pendingLayoutSave){const je=be.layout?JSON.stringify(be.layout):Rt(n).lastPersistedLayoutJson;yu(n,be.revision,je);return}if(be.layout){const je=Rt(n).state,_t=B_(Object.values(je.terminals),void 0,be.layout.workspaces,be.layout.activeWorkspaceId),It=nv(_t);xC(n,_t),yu(n,be.revision,JSON.stringify(It)),Su(It,_)}else yu(n,be.revision,L.lastPersistedLayoutJson);return}catch{}Su(S,_)}}const ns=J6(o),ni=!U||W,wo=ni?ae:"servers";function ul(S){const T=S.active?w:Rt(S.agentId),L=S.active?x:T.state,Q=S.active?w.loaded:T.loaded,le=S.active?A:T.error;return h.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[h.jsxs("div",{className:"workspace-list-header",children:[h.jsx("span",{children:"Workspaces"}),h.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>ea(S.agentId),children:"+"})]}),Q?le?h.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(S.agentId),children:le}):h.jsx("div",{className:"workspace-list-items",children:L.workspaces.map(ce=>{const be=S.active&&ce.id===at?.id,Be=Hf(ce).length,je=bj(S.agentId,ce.id),_t=A6(je),It=S.active&&L.workspaces.length>1,ss=nt?.workspaceId===ce.id&&Ue!==ce.id?nt.placement:null;return h.jsxs(O6,{workspaceId:ce.id,active:be,disabled:!S.active,reorderable:It,dragging:Ue===ce.id,dropPlacement:ss,working:je.workingTerminalCount>0,unread:je.unreadCompletionCount>0,children:[It?h.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":Ue===ce.id,onPointerDown:ci=>_c(ce.id,ci),onPointerMove:Yi,onPointerUp:ta,onPointerCancel:vr,onKeyDown:ci=>{(ci.key==="ArrowUp"||ci.key==="ArrowDown")&&(ci.preventDefault(),ci.stopPropagation(),Ms(ce.id,ci.key==="ArrowUp"?-1:1))},onClick:ci=>ci.stopPropagation(),children:"::"}):null,h.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":be?"page":void 0,title:ce.defaultCwd??void 0,onClick:()=>Os(S.agentId,ce.id),onDoubleClick:()=>{S.active&&pn(ce.id)},children:[h.jsxs("span",{className:"workspace-list-title-row",children:[h.jsx("span",{className:"workspace-list-name",children:ce.title}),je.workingTerminalCount>0||je.unreadCompletionCount>0?h.jsxs("span",{className:"workspace-list-attention",title:_t,"aria-label":_t,children:[je.workingTerminalCount>0?h.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,je.unreadCompletionCount>0?h.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:N6(je.unreadCompletionCount)}):null]}):null]}),h.jsxs("small",{children:[ce.defaultCwd??"No folder"," · ",Be," ",Be===1?"session":"sessions"]})]}),S.active?h.jsxs("div",{className:"workspace-list-actions",children:[h.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ce.title}`,title:"Edit workspace",onClick:()=>pn(ce.id),children:"..."}),h.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ce.title}`,title:"Delete workspace",disabled:L.workspaces.length<=1,onClick:()=>{Mi(ce.id)},children:"x"})]}):null]},ce.id)})}):h.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(S.agentId),children:"Open server to load workspaces"})]})}function Co(S,T){ue({...S,provider:T})}function dl(S,T){if(bi(S,n)){Qe({type:"terminal.created",terminal:T});return}Ha(S,{type:"terminal.created",terminal:T}),r?.(S)}async function wc(S,T){const L=Va(S);try{await L.closeTerminal(T)}catch(Q){if(!(Q instanceof dn)||Q.status!==404)throw Q}if(Wl(L.createWebSocketUrl(T)),_u(T),$l(T),bi(S,n)){Qe({type:"terminal.closed",terminalId:T});return}Ha(S,{type:"terminal.closed",terminalId:T})}return h.jsx(cx,{sensors:ut,onDragStart:Lt,onDragEnd:fi,onDragCancel:wi,children:h.jsxs("main",{className:"terminal-shell","data-collapsed":U,"data-sidebar-open":W,onDragOver:yc,onDrop:vo,children:[h.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>F(!1)}),h.jsxs("aside",{className:"workspace-sidebar",children:[h.jsxs("header",{className:"workspace-brand",children:[h.jsxs("div",{className:"workspace-brand-lockup",children:[ni?h.jsx(UC,{height:20}):h.jsx(HC,{size:24}),c&&ni?h.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),h.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":U?"Expand sidebar":"Collapse sidebar",title:U?"Expand sidebar":"Collapse sidebar",onClick:()=>q(S=>!S),children:U?">":"<"}),h.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>F(!1),children:"x"})]}),h.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${wo==="files"?"files":"servers"}`,children:[ni?h.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[h.jsx("button",{type:"button",role:"tab","aria-selected":ae==="servers",onClick:()=>{P("servers")},children:"Workspaces"}),h.jsx("button",{type:"button",role:"tab","aria-selected":ae==="files",onClick:()=>{P("files")},children:"Files"})]}):null,wo==="servers"&&ni?h.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:h.jsx(Hw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:Pe,onServerLabelsChange:Vt,onManageAccounts:Co,renderServerChildren:ul})}):null,ni?null:h.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:h.jsx(Hw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:Pe,onServerLabelsChange:Vt,compact:!0})}),wo==="files"?h.jsx(RN,{api:p,activeTerminalId:zt,activeTerminalCwd:Di?.cwd??null,workspaceRootPath:zt?null:at?.defaultCwd??null,onOpenFile:bc},`${n??"local"}:${at?.id??"no-workspace"}`):null]}),h.jsxs("div",{className:"workspace-sidebar-footer",children:[ni?h.jsx("span",{children:ns}):null,h.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[h.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>G(!0),children:[h.jsx(AC,{name:"settings"}),N.hasUpdates?h.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),ni?h.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{xi()},children:h.jsx(AC,{name:"logout"})}):null]})]})]}),te?h.jsx(CN,{api:g,onClose:()=>G(!1),updateAvailable:N.hasUpdates,onNotificationAssetsChanged:()=>{qs()},onAgentRemoved:Sn}):null,I?h.jsx(jM,{provider:I.provider,serverLabel:I.label,api:xe,onClose:()=>ue(null),onLoginStarted:S=>dl(I.agentId,S),onLoginFinished:S=>wc(I.agentId,S)}):null,Te?h.jsx(D6,{dialog:Te,activePaneCwd:Di?.cwd??null,activeWorkspaceCwd:at?.defaultCwd??null,onChange:Rs,onManualCwdChange:gr,onBrowse:Gn,onCancel:ho,onSubmit:()=>{fo()}}):null,h.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":_n?"true":void 0,children:[h.jsx(Aj,{tabs:at?.tabs??[],activeTabId:at?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:gi,favoriteTabIds:new Set(V.filter(S=>S.serverId===(n??ti)).map(S=>S.tabId)),detachedTerminals:Rn,onSelectTab:S=>Qe({type:"tab.selected",tabId:S}),onCreateTab:()=>{ia()},onToggleWorkspaces:()=>F(S=>!S),onCloseTerminals:S=>Pi(S),onReattachTerminal:S=>go(S),onDeleteTerminal:S=>{br(S)},onSplitVertical:()=>{ra("vertical")},onSplitHorizontal:()=>{ra("horizontal")},onRenameTab:(S,T)=>{yr(S,T)},onToggleFavorite:sa,onOpenFavorites:()=>ee(!0),activePaneAvailable:!!zt}),ge?h.jsx(Zj,{favorites:V,unavailableFavoriteIds:new Set(V.filter(S=>S.serverId!==ti&&!Re.some(T=>bi(T,S.serverId))).map(vs)),busy:Y,error:B,getRuntimeStatus:po,onClose:()=>{ee(!1),R(null)},onOpen:Ns,onRemove:S=>{Ci(T=>T.filter(L=>vs(L)!==vs(S)))},onReorder:(S,T)=>{const L=vs(S),Q=vs(T);Ci(le=>{const ce=le.findIndex(It=>vs(It)===L),be=le.findIndex(It=>vs(It)===Q);if(ce<0||be<0||ce===be)return le;const Be=le.slice(),[je]=Be.splice(ce,1),_t=Be.findIndex(It=>vs(It)===Q);return je&&_t>=0&&Be.splice(_t,0,je),Be})}}):null,_n?h.jsx(j6,{targets:nn,activeLeafKey:sn,terminals:x.terminals,editors:M,onSelect:Gs}):null,A?h.jsxs("div",{className:"workspace-error",role:"alert",children:[h.jsx("span",{children:A}),h.jsxs("div",{className:"workspace-error-actions",children:[h.jsx("button",{type:"button",onClick:Jr,children:"Retry"}),n!==null&&r?h.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,h.jsxs("section",{className:"workspace-body","aria-busy":O,children:[O?h.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!O&&!Tt?h.jsx(L6,{onCreate:()=>{ia()}}):null,fe.map(S=>{const T=bi(S,n);return h.jsx(w6,{agentId:S,serverName:Ae[hf(S)]??(S===null?"Local":"Server"),active:T,activeServerApi:T?p:void 0,visitedTabKeys:J,refreshCwdOnEnter:T,draggingTab:T?Fe:null,mobileSplitFocus:Wt,mobileFocusedLeafByTabKey:Ee,onSelect:L=>{T&&Xs(L)},onClose:L=>{T&&Zn(L)},onCloseEditor:L=>{T&&As(L)},onResize:(L,Q)=>{T&&Qe({type:"pane.resized",path:L,ratio:Q})},onExit:(L,Q)=>{T?Qn({type:"terminal.exited",terminalId:L,exitCode:Q}):Ha(S,{type:"terminal.exited",terminalId:L,exitCode:Q})},onSnapshot:(L,Q)=>{const le={type:"terminal.updated",terminal:L,notifyCompletion:Q?.notifyCompletion===!0};T?Qn(le):Ha(S,le)},...f?{onAuthClose:L=>f({...L,source:L?.source??"terminal-ws-1008",activeAgentId:S})}:{}},df(S))})]}),Cs?h.jsx(B6,{label:Cs.label,count:Cs.terminalIds.length,warning:ke,onCancel:()=>{Ne(null),xs(null)},onHide:()=>{mo(Cs.terminalIds,Cs.workspaceId)&&xs(null)},onDelete:()=>{const S=Cs.terminalIds;Ne(null),xs(null),Ls(S)}}):null,h.jsx(c6,{toast:bn,onActivate:So,onDismiss:()=>ws(null)}),h.jsx(i6,{uploads:fn,onDismiss:la,onDismissAll:yo,onRetry:ca,onCancel:Sc})]})]})})}function w6({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:f,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:_,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,onAuthClose:M}){const O=v.useMemo(()=>ge=>GT(e,ge),[e]),A=v.useMemo(()=>()=>Rt(e),[e]),W=v.useSyncExternalStore(O,A,A),F=v.useMemo(()=>Va(e),[e]),U=r??F,q=W.state,ae=q.workspaces.find(ge=>ge.id===q.activeWorkspaceId)??q.workspaces[0],P=ae?.id??null,G=(ae?.tabs.find(ge=>ge.id===ae.activeTabId)??ae?.tabs[0])?.id??null;return!W.loaded||q.workspaces.length===0?null:h.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:q.workspaces.flatMap(ge=>ge.tabs.map(ee=>{const V=n&&ge.id===P&&ee.id===G,Z=Mu(e,ge.id,ee.id),Y=Uf(ee.root),ie=f&&Y.length>1?rE(Y,ee.activeTerminalId,g[Z]):null;return!V&&!o.has(Z)?null:h.jsx("div",{className:"workspace-tab-surface","data-active":V,"aria-hidden":!V,children:h.jsx(A_,{node:ee.root,terminals:q.terminals,editors:W.editors,api:U,activeTerminalId:ee.activeTerminalId,visible:V,refreshCwdOnEnter:V&&c,tabId:ee.id,codeServerContext:{serverKey:hf(e),serverName:t,tabName:ee.title||q.terminals[ee.activeTerminalId]?.title||"Terminal"},dropZoneActive:V&&u!==null,draggingTerminalId:V?u?.terminalId??null:null,mobileFocusLeafKey:ie,onSelect:p,onClose:_,onCloseEditor:b,onResize:C,onExit:w,onSnapshot:x,...M?{onAuthClose:M}:{}})},ee.id)}))})}function C6(e){const t=Ux(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=k6(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function x6(e,t,n){switch(n.type){case"pane.direction":return h6(e,t,n.direction);case"pane.index":return f6(e,n.index);default:return null}}function k6(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function T6(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 Uf(e){return e.type==="pane"?[{key:Fu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:aE(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Uf(e.first),...Uf(e.second)]}function Y_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Y_(e.first),...Y_(e.second)]}function rE(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?Fu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function Fu(e){return`terminal:${e}`}function aE(e){return`editor:${e}`}function E6(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 D6({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(w=>w.kind==="directory"),_=e.submitStatus==="submitting";function b(w){r(x=>x&&{...x,...w})}function C(w){w&&(b({cwd:w,error:null}),c(w))}return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:h.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),_||f()},children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),h.jsxs("section",{className:"workspace-dialog-body",children:[h.jsxs("label",{className:"workspace-dialog-field",children:[h.jsx("span",{children:"Name"}),h.jsx("input",{value:e.title,autoFocus:!0,disabled:_,onChange:w=>b({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),h.jsxs("label",{className:"workspace-dialog-field",children:[h.jsx("span",{children:"Default cwd"}),h.jsxs("div",{className:"workspace-dialog-path-row",children:[h.jsx("input",{value:e.cwd,disabled:_,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),h.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:_||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),h.jsxs("div",{className:"workspace-dialog-quick-actions",children:[h.jsx("button",{type:"button",onClick:()=>C(t),disabled:_||!t,children:"Use active pane"}),h.jsx("button",{type:"button",onClick:()=>C(n),disabled:_||!n,children:"Use current workspace"})]}),h.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[h.jsxs("div",{className:"workspace-dialog-browser-header",children:[h.jsx("span",{title:g,children:g||"No folder selected"}),h.jsx("button",{type:"button",onClick:()=>{c(M6(g))},disabled:_||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?h.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?h.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?h.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(w=>h.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:_,onClick:()=>{c(R6(g,w.path))},children:[h.jsx("span",{children:w.name}),h.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?h.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),h.jsxs("div",{className:"workspace-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),h.jsx("button",{type:"submit",className:"primary-button",disabled:_||e.browseStatus==="loading",children:_?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function R6(e,t){return t?t.startsWith("/")?uf(t):uf(`${e||"/"}/${t}`):uf(e)}function M6(e){const t=uf(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function uf(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function N6(e){return e>99?"99+":String(e)}function A6(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 L6({onCreate:e}){return h.jsxs("div",{className:"empty-workspace",children:[h.jsx("span",{children:"No terminal is open."}),h.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function O6({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:p,isOver:_}=Gf({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 h.jsx("div",{ref:p,className:b,"data-workspace-id":e,"data-drop-over":_?"true":void 0,children:g})}function B6({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return h.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:h.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[h.jsxs("header",{className:"security-panel-header",children:[h.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),h.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),h.jsxs("section",{className:"terminal-delete-dialog-body",children:[h.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),h.jsx("span",{children:e}),h.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?h.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),h.jsxs("div",{className:"terminal-delete-dialog-actions",children:[h.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),h.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function j6({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(C=>C.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],_=MC(p,n,r);function b(C){const w=(g+C+e.length)%e.length,x=e[w];x&&o(x)}return h.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[h.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),h.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," | ",_]}),h.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?h.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:h.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:C=>C.stopPropagation(),children:[h.jsxs("header",{children:[h.jsx("strong",{children:"Panes"}),h.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),h.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((C,w)=>{const x=MC(C,n,r),M=I6(C,n,r),O=C.key===p.key;return h.jsxs("button",{type:"button","data-active":O,onClick:()=>{o(C),u(!1)},children:[h.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),h.jsxs("span",{className:"mobile-pane-sheet-copy",children:[h.jsx("strong",{children:x}),h.jsx("small",{children:M})]}),h.jsx("span",{className:"mobile-pane-sheet-type",children:C.type})]},C.key)})})]})}):null]})}function MC(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 I6(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 P6(e){const[t,n]=v.useState(()=>z6(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 z6(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function H6(){if(typeof window>"u")return null;const e=NR(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 U6(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Zf(t.focus)}function F6(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Ii(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function bi(e,t){return e===t}function vs(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function NC(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o!==void 0&&vs(n)===vs(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 K6(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 df(e){return e??"__local__"}function Mu(e,t,n){return`${df(e)}:${t}:${n}`}class Ff extends Error{constructor(){super(lE())}}function $6(e){return e?{workspaceKey:`${DC}:${e}`}:{workspaceKey:DC}}function W6(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(hx(n))throw new Ff;const r=dx(n);return r?oE(r):null}catch(n){if(n instanceof Ff)throw n;return null}}function oE(e){if(hx(e))throw new Ff;const t=dx(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Su(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function q6(e,t){const n=Rt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function V6(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${hc}. Re-open or delete hidden sessions before hiding more.`}function lE(){return`A saved terminal layout has more than ${hc} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function Y6(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 X6(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function G6(e){return e.split("/").filter(Boolean).pop()??e}function Z6(){try{return localStorage.getItem(sE)==="true"}catch{return!1}}function Q6(e){try{localStorage.setItem(sE,e?"true":"false")}catch{}}function hf(e){return e??ti}function av(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function J6(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 AC({name:e}){return h.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h9"}),h.jsx("path",{d:"M17 7h3"}),h.jsx("circle",{cx:"15",cy:"7",r:"2"}),h.jsx("path",{d:"M4 12h3"}),h.jsx("path",{d:"M11 12h9"}),h.jsx("circle",{cx:"9",cy:"12",r:"2"}),h.jsx("path",{d:"M4 17h9"}),h.jsx("path",{d:"M17 17h3"}),h.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M10 6H6v12h4"}),h.jsx("path",{d:"M13 8l4 4-4 4"}),h.jsx("path",{d:"M8 12h9"})]}):null]})}function Fa(e){return e instanceof Error?e.message:"Request failed"}function eI({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,f]=v.useState(""),[g,p]=v.useState(!1),[_,b]=v.useState(null),[C,w]=v.useState(null);v.useEffect(()=>{let M=!1;return e.setupTotp().then(O=>{M||(r(O.qrDataUrl),c(O.secret))}).catch(O=>{M||w(O instanceof Error?O.message:"Failed to generate QR code")}),()=>{M=!0}},[e]);async function x(M){if(M.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(O){b(O instanceof Error?O.message:"Verification failed")}finally{p(!1)}}}return C?h.jsx("p",{className:"form-error",children:C}):!n||!o?h.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):h.jsxs("div",{className:"totp-setup",children:[h.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."}),h.jsx("div",{className:"totp-qr-container",children:h.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),h.jsxs("details",{className:"totp-secret-details",children:[h.jsx("summary",{children:"Can't scan? Enter manually"}),h.jsx("p",{className:"totp-secret-text",children:o})]}),h.jsxs("form",{className:"auth-form",onSubmit:x,children:[h.jsxs("label",{children:["Verification code",h.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:M=>f(M.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),_?h.jsx("p",{className:"form-error",children:_}):null,h.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function tI(e){return{source:ov(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:ov(e.terminalId)}:{},...e?.detail?{detail:ov(e.detail)}:{}}}function iI(e){return{invalidationSource:e.source}}function nI(e){vn("auth.session_invalid.request",cE(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),hb("session-invalid-request").catch(()=>{}))}function sI(e,t){vn("auth.session_invalid.result",{...cE(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),hb("session-invalid-result").catch(()=>{}))}function cE(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 ov(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function rI({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??Kf(),[e]),c=v.useMemo(()=>t??Va(null),[t]),[u,f]=v.useState(null),[g,p]=v.useState(null),_=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(W=>{A||(f(W),p(null))}).catch(W=>{A||(p(Zo(W)),f(null))}),()=>{A=!0}},[o]);const C=cI(u);v.useEffect(()=>{const A=b.current;vn("auth.view",{view:C,previousView:A,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),A==="workspace"&&C!=="workspace"&&hb(`auth-left-workspace-${C}`).catch(()=>{}),b.current=C},[u,C]);async function w(){const A=await o.getSession();f(A),p(null)}async function x(){Gg(),rv(),V1(),Y1(),p(null),f(null);try{await w()}catch(A){p(Zo(A))}}function M(A){const W=tI(A);if(nI(W),_.current)return _.current;const F=(async()=>{p(null);try{const U=await o.getSession(iI(W));if(sI(W,U.authenticated),f(U),U.authenticated){i5();return}Gg(),rv(),V1(),Y1()}catch(U){p(Zo(U))}finally{_.current=null}})();return _.current=F,F}if(C==="workspace")return h.jsx(S6,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:A=>{M(A)},onLogout:async()=>{Gg(),rv();const A=await o.logout();f(A)}});const O={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return h.jsxs("main",{className:"auth-screen",children:[h.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[h.jsx("div",{className:"auth-grid"}),h.jsx("div",{className:"auth-glow"})]}),h.jsxs("section",{className:"auth-panel","aria-busy":C==="loading",children:[h.jsxs("header",{className:"auth-header",children:[h.jsxs("div",{className:"auth-brand",children:[h.jsx(HC,{size:26}),h.jsxs("div",{children:[h.jsx(UC,{height:17}),h.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),h.jsx("h1",{children:O[C]})]}),g?h.jsx("p",{className:"form-error",children:g}):null,C==="loading"?h.jsx("p",{className:"muted",children:"Checking session..."}):null,C==="loading"&&g?h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,C==="setup_password"?h.jsx(aI,{api:o,onSession:A=>{f(A)}}):null,C==="setup_totp"?h.jsx(eI,{api:o,onDone:()=>{w()}}):null,C==="login"?h.jsx(oI,{api:o,session:u,onSession:f,onRefresh:w}):null,C==="reauth"?h.jsx(lI,{api:o,session:u,onSession:f,onFullLogin:()=>f(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function aI({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,f]=v.useState(!1),[g,p]=v.useState(null);async function _(b){b.preventDefault(),f(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(C){p(Zo(C))}finally{f(!1)}}return h.jsxs("form",{className:"auth-form",onSubmit:_,children:[h.jsxs("label",{children:["Password",h.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),h.jsxs("label",{children:["Confirm password",h.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?h.jsx("p",{className:"form-error",children:g}):null,h.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function oI({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,f]=v.useState(""),[g,p]=v.useState(!1),[_,b]=v.useState(!1),[C,w]=v.useState(null),x=t?.totpEnabled??!1,M=t?.currentIpWhitelisted??!1;async function O(A){A.preventDefault(),b(!0),w(null);try{n(await e.login({password:o,...x?{otp:u}:{},rememberNetwork:g}))}catch(W){w(Zo(W))}finally{b(!1)}}return h.jsxs("form",{className:"auth-form",onSubmit:O,children:[h.jsxs("label",{children:["Password",h.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),x?h.jsxs("label",{children:["Authenticator code",h.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,M?null:h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:g,onChange:A=>p(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),C?h.jsx("p",{className:"form-error",children:C}):null,h.jsxs("div",{className:"button-row",children:[h.jsx("button",{type:"submit",disabled:_||o.length===0||x&&u.length!==6,children:"Unlock"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:_,children:"Refresh"})]})]})}function lI({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[f,g]=v.useState(!1),[p,_]=v.useState(!1),[b,C]=v.useState(!1),[w,x]=v.useState(!1),[M,O]=v.useState(null),A=jt.useCallback(async(F,U)=>{_(!0),O(null);try{n(await e.reauth({...F?{otp:F}:{},rememberNetwork:U}))}catch(q){O(Zo(q))}finally{_(!1)}},[e,n]);v.useEffect(()=>{if(o){let F=!1;C(!0),x(!1),O(null);const U=window.setTimeout(()=>{F||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{F||n(q)}).catch(q=>{F||(O(Zo(q)),x(!0))}).finally(()=>{window.clearTimeout(U),F||C(!1)}),()=>{F=!0,window.clearTimeout(U)}}},[e,o,n]);async function W(F){F.preventDefault(),await A(c,f)}return o&&b&&!w&&!M?h.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):h.jsxs("form",{className:"auth-form",onSubmit:W,children:[o&&w&&!M?h.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,h.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),h.jsxs("label",{children:["Authenticator code",h.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:F=>u(F.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),h.jsxs("label",{className:"auth-checkbox",children:[h.jsx("input",{type:"checkbox",checked:f,onChange:F=>g(F.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),M?h.jsx("p",{className:"form-error",children:M}):null,h.jsxs("div",{className:"button-row",children:[h.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),h.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function cI(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Zo(e){return e instanceof Error?e.message:"Request failed"}const LC="NTerminal",X_="nterminal.activeAgentId";function uI(){const[e,t]=v.useState(()=>dI()),n=v.useMemo(()=>Kf(),[]),r=v.useMemo(()=>Va(e),[e]);v.useEffect(()=>{const c=()=>{const u=Tj();document.title=u>0?`(${u}) ${LC}`:LC};return c(),kj(c)},[]);function o(c){hI(c),t(c)}return h.jsx(rI,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function dI(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(X_);return e&&e.trim()?e:null}catch{return null}}function hI(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(X_,e);return}window.localStorage.removeItem(X_)}catch{}}const OC=["gesturestart","gesturechange","gestureend"],fI=[".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 pI(e=window){if(!gI(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||!mI(c.target))&&r(c)}for(const c of OC)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of OC)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function mI(e){return e instanceof Element&&e.closest(fI)!==null}function gI(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}IR();k3();pI();eb();j2.createRoot(document.getElementById("root")).render(h.jsx(jt.StrictMode,{children:h.jsx(uI,{})}));export{jt as R,E2 as g,h as j};