nterminal 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/MarkdownPreview-DjDO4lEl.js +1 -0
- package/dist/client/assets/TranscriptMarkdownBody-H8ZsISc6.js +3 -0
- package/dist/client/assets/{index-DTTX24tu.css → index-CIYazAGv.css} +1 -1
- package/dist/client/assets/index-DwvLN_WJ.js +56 -0
- package/dist/client/assets/{index-DDCpqDNb.js → index-DxfBq-4P.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/terminal/TmuxPtyAdapter.js +5 -1
- package/dist/server/terminal/TmuxPtyAdapter.js.map +1 -1
- package/dist/server/terminal/codexTranscriptSource.js +16 -13
- package/dist/server/terminal/codexTranscriptSource.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-CWK2qIZp.js +0 -1
- package/dist/client/assets/TranscriptMarkdownBody-Ddi-rw6X.js +0 -3
- package/dist/client/assets/index-CcAQThtj.js +0 -56
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-DjDO4lEl.js","assets/index-DxfBq-4P.js","assets/TranscriptMarkdownBody-H8ZsISc6.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 i(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=i(o);fetch(o.href,c)}})();function eD(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pg={exports:{}},pu={};var hw;function tD(){if(hw)return pu;hw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(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 pu.Fragment=t,pu.jsx=i,pu.jsxs=i,pu}var fw;function nD(){return fw||(fw=1,pg.exports=tD()),pg.exports}var d=nD(),mg={exports:{}},dt={};var pw;function iD(){if(pw)return dt;pw=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=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"),w=Symbol.iterator;function x(A){return A===null||typeof A!="object"?null:(A=w&&A[w]||A["@@iterator"],typeof A=="function"?A:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,L={};function M(A,V,de){this.props=A,this.context=V,this.refs=L,this.updater=de||C}M.prototype.isReactComponent={},M.prototype.setState=function(A,V){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,V,"setState")},M.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function U(){}U.prototype=M.prototype;function P(A,V,de){this.props=A,this.context=V,this.refs=L,this.updater=de||C}var H=P.prototype=new U;H.constructor=P,N(H,M.prototype),H.isPureReactComponent=!0;var K=Array.isArray;function ee(){}var j={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function fe(A,V,de){var Z=de.ref;return{$$typeof:e,type:A,key:V,ref:Z!==void 0?Z:null,props:de}}function ie(A,V){return fe(A.type,V,A.props)}function te(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Y(A){var V={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(de){return V[de]})}var Q=/\/+/g;function q(A,V){return typeof A=="object"&&A!==null&&A.key!=null?Y(""+A.key):V.toString(36)}function ae(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(ee,ee):(A.status="pending",A.then(function(V){A.status==="pending"&&(A.status="fulfilled",A.value=V)},function(V){A.status==="pending"&&(A.status="rejected",A.reason=V)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function O(A,V,de,Z,Se){var ye=typeof A;(ye==="undefined"||ye==="boolean")&&(A=null);var Me=!1;if(A===null)Me=!0;else switch(ye){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(A.$$typeof){case e:case t:Me=!0;break;case _:return Me=A._init,O(Me(A._payload),V,de,Z,Se)}}if(Me)return Se=Se(A),Me=Z===""?"."+q(A,0):Z,K(Se)?(de="",Me!=null&&(de=Me.replace(Q,"$&/")+"/"),O(Se,V,de,"",function(Ue){return Ue})):Se!=null&&(te(Se)&&(Se=ie(Se,de+(Se.key==null||A&&A.key===Se.key?"":(""+Se.key).replace(Q,"$&/")+"/")+Me)),V.push(Se)),1;Me=0;var He=Z===""?".":Z+":";if(K(A))for(var Fe=0;Fe<A.length;Fe++)Z=A[Fe],ye=He+q(Z,Fe),Me+=O(Z,V,de,ye,Se);else if(Fe=x(A),typeof Fe=="function")for(A=Fe.call(A),Fe=0;!(Z=A.next()).done;)Z=Z.value,ye=He+q(Z,Fe++),Me+=O(Z,V,de,ye,Se);else if(ye==="object"){if(typeof A.then=="function")return O(ae(A),V,de,Z,Se);throw V=String(A),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return Me}function R(A,V,de){if(A==null)return A;var Z=[],Se=0;return O(A,Z,"","",function(ye){return V.call(de,ye,Se++)}),Z}function z(A){if(A._status===-1){var V=A._result;V=V(),V.then(function(de){(A._status===0||A._status===-1)&&(A._status=1,A._result=de)},function(de){(A._status===0||A._status===-1)&&(A._status=2,A._result=de)}),A._status===-1&&(A._status=0,A._result=V)}if(A._status===1)return A._result.default;throw A._result}var ce=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},ve={map:R,forEach:function(A,V,de){R(A,function(){V.apply(this,arguments)},de)},count:function(A){var V=0;return R(A,function(){V++}),V},toArray:function(A){return R(A,function(V){return V})||[]},only:function(A){if(!te(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};return dt.Activity=b,dt.Children=ve,dt.Component=M,dt.Fragment=i,dt.Profiler=o,dt.PureComponent=P,dt.StrictMode=r,dt.Suspense=g,dt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,dt.__COMPILER_RUNTIME={__proto__:null,c:function(A){return j.H.useMemoCache(A)}},dt.cache=function(A){return function(){return A.apply(null,arguments)}},dt.cacheSignal=function(){return null},dt.cloneElement=function(A,V,de){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var Z=N({},A.props),Se=A.key;if(V!=null)for(ye in V.key!==void 0&&(Se=""+V.key),V)!J.call(V,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&V.ref===void 0||(Z[ye]=V[ye]);var ye=arguments.length-2;if(ye===1)Z.children=de;else if(1<ye){for(var Me=Array(ye),He=0;He<ye;He++)Me[He]=arguments[He+2];Z.children=Me}return fe(A.type,Se,Z)},dt.createContext=function(A){return A={$$typeof:u,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:c,_context:A},A},dt.createElement=function(A,V,de){var Z,Se={},ye=null;if(V!=null)for(Z in V.key!==void 0&&(ye=""+V.key),V)J.call(V,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(Se[Z]=V[Z]);var Me=arguments.length-2;if(Me===1)Se.children=de;else if(1<Me){for(var He=Array(Me),Fe=0;Fe<Me;Fe++)He[Fe]=arguments[Fe+2];Se.children=He}if(A&&A.defaultProps)for(Z in Me=A.defaultProps,Me)Se[Z]===void 0&&(Se[Z]=Me[Z]);return fe(A,ye,Se)},dt.createRef=function(){return{current:null}},dt.forwardRef=function(A){return{$$typeof:f,render:A}},dt.isValidElement=te,dt.lazy=function(A){return{$$typeof:_,_payload:{_status:-1,_result:A},_init:z}},dt.memo=function(A,V){return{$$typeof:p,type:A,compare:V===void 0?null:V}},dt.startTransition=function(A){var V=j.T,de={};j.T=de;try{var Z=A(),Se=j.S;Se!==null&&Se(de,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(ee,ce)}catch(ye){ce(ye)}finally{V!==null&&de.types!==null&&(V.types=de.types),j.T=V}},dt.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},dt.use=function(A){return j.H.use(A)},dt.useActionState=function(A,V,de){return j.H.useActionState(A,V,de)},dt.useCallback=function(A,V){return j.H.useCallback(A,V)},dt.useContext=function(A){return j.H.useContext(A)},dt.useDebugValue=function(){},dt.useDeferredValue=function(A,V){return j.H.useDeferredValue(A,V)},dt.useEffect=function(A,V){return j.H.useEffect(A,V)},dt.useEffectEvent=function(A){return j.H.useEffectEvent(A)},dt.useId=function(){return j.H.useId()},dt.useImperativeHandle=function(A,V,de){return j.H.useImperativeHandle(A,V,de)},dt.useInsertionEffect=function(A,V){return j.H.useInsertionEffect(A,V)},dt.useLayoutEffect=function(A,V){return j.H.useLayoutEffect(A,V)},dt.useMemo=function(A,V){return j.H.useMemo(A,V)},dt.useOptimistic=function(A,V){return j.H.useOptimistic(A,V)},dt.useReducer=function(A,V,de){return j.H.useReducer(A,V,de)},dt.useRef=function(A){return j.H.useRef(A)},dt.useState=function(A){return j.H.useState(A)},dt.useSyncExternalStore=function(A,V,de){return j.H.useSyncExternalStore(A,V,de)},dt.useTransition=function(){return j.H.useTransition()},dt.version="19.2.6",dt}var mw;function sb(){return mw||(mw=1,mg.exports=iD()),mg.exports}var v=sb();const Nt=eD(v);var gg={exports:{}},mu={},vg={exports:{}},_g={};var gw;function sD(){return gw||(gw=1,(function(e){function t(O,R){var z=O.length;O.push(R);e:for(;0<z;){var ce=z-1>>>1,ve=O[ce];if(0<o(ve,R))O[ce]=R,O[z]=ve,z=ce;else break e}}function i(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var R=O[0],z=O.pop();if(z!==R){O[0]=z;e:for(var ce=0,ve=O.length,A=ve>>>1;ce<A;){var V=2*(ce+1)-1,de=O[V],Z=V+1,Se=O[Z];if(0>o(de,z))Z<ve&&0>o(Se,de)?(O[ce]=Se,O[Z]=z,ce=Z):(O[ce]=de,O[V]=z,ce=V);else if(Z<ve&&0>o(Se,z))O[ce]=Se,O[Z]=z,ce=Z;else break e}}return R}function o(O,R){var z=O.sortIndex-R.sortIndex;return z!==0?z:O.id-R.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var g=[],p=[],_=1,b=null,w=3,x=!1,C=!1,N=!1,L=!1,M=typeof setTimeout=="function"?setTimeout:null,U=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function H(O){for(var R=i(p);R!==null;){if(R.callback===null)r(p);else if(R.startTime<=O)r(p),R.sortIndex=R.expirationTime,t(g,R);else break;R=i(p)}}function K(O){if(N=!1,H(O),!C)if(i(g)!==null)C=!0,ee||(ee=!0,Y());else{var R=i(p);R!==null&&ae(K,R.startTime-O)}}var ee=!1,j=-1,J=5,fe=-1;function ie(){return L?!0:!(e.unstable_now()-fe<J)}function te(){if(L=!1,ee){var O=e.unstable_now();fe=O;var R=!0;try{e:{C=!1,N&&(N=!1,U(j),j=-1),x=!0;var z=w;try{t:{for(H(O),b=i(g);b!==null&&!(b.expirationTime>O&&ie());){var ce=b.callback;if(typeof ce=="function"){b.callback=null,w=b.priorityLevel;var ve=ce(b.expirationTime<=O);if(O=e.unstable_now(),typeof ve=="function"){b.callback=ve,H(O),R=!0;break t}b===i(g)&&r(g),H(O)}else r(g);b=i(g)}if(b!==null)R=!0;else{var A=i(p);A!==null&&ae(K,A.startTime-O),R=!1}}break e}finally{b=null,w=z,x=!1}R=void 0}}finally{R?Y():ee=!1}}}var Y;if(typeof P=="function")Y=function(){P(te)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,q=Q.port2;Q.port1.onmessage=te,Y=function(){q.postMessage(null)}}else Y=function(){M(te,0)};function ae(O,R){j=M(function(){O(e.unstable_now())},R)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(O){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var z=w;w=R;try{return O()}finally{w=z}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(O,R){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var z=w;w=O;try{return R()}finally{w=z}},e.unstable_scheduleCallback=function(O,R,z){var ce=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?ce+z:ce):z=ce,O){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=z+ve,O={id:_++,callback:R,priorityLevel:O,startTime:z,expirationTime:ve,sortIndex:-1},z>ce?(O.sortIndex=z,t(p,O),i(g)===null&&O===i(p)&&(N?(U(j),j=-1):N=!0,ae(K,z-ce))):(O.sortIndex=ve,t(g,O),C||x||(C=!0,ee||(ee=!0,Y()))),O},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(O){var R=w;return function(){var z=w;w=R;try{return O.apply(this,arguments)}finally{w=z}}}})(_g)),_g}var vw;function rD(){return vw||(vw=1,vg.exports=sD()),vg.exports}var bg={exports:{}},Si={};var _w;function aD(){if(_w)return Si;_w=1;var e=sb();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 i(){}var r={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},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 Si.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Si.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,_)},Si.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()}},Si.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))},Si.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Si.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var _=p.as,b=f(_,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,x=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;_==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:x}):_==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:x,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Si.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)},Si.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})}},Si.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)},Si.requestFormReset=function(g){r.d.r(g)},Si.unstable_batchedUpdates=function(g,p){return g(p)},Si.useFormState=function(g,p,_){return u.H.useFormState(g,p,_)},Si.useFormStatus=function(){return u.H.useHostTransitionStatus()},Si.version="19.2.6",Si}var bw;function Yx(){if(bw)return bg.exports;bw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),bg.exports=aD(),bg.exports}var yw;function oD(){if(yw)return mu;yw=1;var e=rD(),t=sb(),i=Yx();function r(n){var s="https://react.dev/errors/"+n;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 #"+n+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function c(n){var s=n,a=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(a=s.return),n=s.return;while(n)}return s.tag===3?a:null}function u(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function f(n){if(n.tag===31){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function g(n){if(c(n)!==n)throw Error(r(188))}function p(n){var s=n.alternate;if(!s){if(s=c(n),s===null)throw Error(r(188));return s!==n?null:n}for(var a=n,l=s;;){var h=a.return;if(h===null)break;var m=h.alternate;if(m===null){if(l=h.return,l!==null){a=l;continue}break}if(h.child===m.child){for(m=h.child;m;){if(m===a)return g(h),n;if(m===l)return g(h),s;m=m.sibling}throw Error(r(188))}if(a.return!==l.return)a=h,l=m;else{for(var y=!1,E=h.child;E;){if(E===a){y=!0,a=h,l=m;break}if(E===l){y=!0,l=h,a=m;break}E=E.sibling}if(!y){for(E=m.child;E;){if(E===a){y=!0,a=m,l=h;break}if(E===l){y=!0,l=m,a=h;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?n:s}function _(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n;for(n=n.child;n!==null;){if(s=_(n),s!==null)return s;n=n.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),P=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),fe=Symbol.for("react.activity"),ie=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function Y(n){return n===null||typeof n!="object"?null:(n=te&&n[te]||n["@@iterator"],typeof n=="function"?n:null)}var Q=Symbol.for("react.client.reference");function q(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===Q?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case M:return"Profiler";case L:return"StrictMode";case K:return"Suspense";case ee:return"SuspenseList";case fe:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case C:return"Portal";case P:return n.displayName||"Context";case U:return(n._context.displayName||"Context")+".Consumer";case H:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case j:return s=n.displayName||null,s!==null?s:q(n.type)||"Memo";case J:s=n._payload,n=n._init;try{return q(n(s))}catch{}}return null}var ae=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z={pending:!1,data:null,method:null,action:null},ce=[],ve=-1;function A(n){return{current:n}}function V(n){0>ve||(n.current=ce[ve],ce[ve]=null,ve--)}function de(n,s){ve++,ce[ve]=n.current,n.current=s}var Z=A(null),Se=A(null),ye=A(null),Me=A(null);function He(n,s){switch(de(ye,s),de(Se,n),de(Z,null),s.nodeType){case 9:case 11:n=(n=s.documentElement)&&(n=n.namespaceURI)?B0(n):0;break;default:if(n=s.tagName,s=s.namespaceURI)s=B0(s),n=j0(s,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}V(Z),de(Z,n)}function Fe(){V(Z),V(Se),V(ye)}function Ue(n){n.memoizedState!==null&&de(Me,n);var s=Z.current,a=j0(s,n.type);s!==a&&(de(Se,n),de(Z,a))}function Ve(n){Se.current===n&&(V(Z),V(Se)),Me.current===n&&(V(Me),uu._currentValue=z)}var Ye,D;function $(n){if(Ye===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);Ye=s&&s[1]||"",D=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Ye+n+D}var pe=!1;function Ne(n,s){if(!n||pe)return"";pe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(me){var ue=me}Reflect.construct(n,[],Ce)}else{try{Ce.call()}catch(me){ue=me}n.call(Ce.prototype)}}else{try{throw Error()}catch(me){ue=me}(Ce=n())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(me){if(me&&ue&&typeof me.stack=="string")return[me.stack,ue.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=l.DetermineComponentFrameRoot(),y=m[0],E=m[1];if(y&&E){var I=y.split(`
|
|
5
|
+
`),re=E.split(`
|
|
6
|
+
`);for(h=l=0;l<I.length&&!I[l].includes("DetermineComponentFrameRoot");)l++;for(;h<re.length&&!re[h].includes("DetermineComponentFrameRoot");)h++;if(l===I.length||h===re.length)for(l=I.length-1,h=re.length-1;1<=l&&0<=h&&I[l]!==re[h];)h--;for(;1<=l&&0<=h;l--,h--)if(I[l]!==re[h]){if(l!==1||h!==1)do if(l--,h--,0>h||I[l]!==re[h]){var be=`
|
|
7
|
+
`+I[l].replace(" at new "," at ");return n.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",n.displayName)),be}while(1<=l&&0<=h);break}}}finally{pe=!1,Error.prepareStackTrace=a}return(a=n?n.displayName||n.name:"")?$(a):""}function ne(n,s){switch(n.tag){case 26:case 27:case 5:return $(n.type);case 16:return $("Lazy");case 13:return n.child!==s&&s!==null?$("Suspense Fallback"):$("Suspense");case 19:return $("SuspenseList");case 0:case 15:return Ne(n.type,!1);case 11:return Ne(n.type.render,!1);case 1:return Ne(n.type,!0);case 31:return $("Activity");default:return""}}function ge(n){try{var s="",a=null;do s+=ne(n,a),a=n,n=n.return;while(n);return s}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var Ee=Object.prototype.hasOwnProperty,Re=e.unstable_scheduleCallback,Te=e.unstable_cancelCallback,je=e.unstable_shouldYield,Ze=e.unstable_requestPaint,Ae=e.unstable_now,_t=e.unstable_getCurrentPriorityLevel,bt=e.unstable_ImmediatePriority,at=e.unstable_UserBlockingPriority,ot=e.unstable_NormalPriority,Bt=e.unstable_LowPriority,ln=e.unstable_IdlePriority,Ht=e.log,On=e.unstable_setDisableYieldValue,Ut=null,kt=null;function $t(n){if(typeof Ht=="function"&&On(n),kt&&typeof kt.setStrictMode=="function")try{kt.setStrictMode(Ut,n)}catch{}}var At=Math.clz32?Math.clz32:le,kn=Math.log,mi=Math.LN2;function le(n){return n>>>=0,n===0?32:31-(kn(n)/mi|0)|0}var Ge=256,it=262144,ct=4194304;function Dt(n){var s=n&42;if(s!==0)return s;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function jt(n,s,a){var l=n.pendingLanes;if(l===0)return 0;var h=0,m=n.suspendedLanes,y=n.pingedLanes;n=n.warmLanes;var E=l&134217727;return E!==0?(l=E&~m,l!==0?h=Dt(l):(y&=E,y!==0?h=Dt(y):a||(a=E&~n,a!==0&&(h=Dt(a))))):(E=l&~m,E!==0?h=Dt(E):y!==0?h=Dt(y):a||(a=l&~n,a!==0&&(h=Dt(a)))),h===0?0:s!==0&&s!==h&&(s&m)===0&&(m=h&-h,a=s&-s,m>=a||m===32&&(a&4194048)!==0)?s:h}function hn(n,s){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&s)===0}function Tn(n,s){switch(n){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 _e(){var n=ct;return ct<<=1,(ct&62914560)===0&&(ct=4194304),n}function ze(n){for(var s=[],a=0;31>a;a++)s.push(n);return s}function Ie(n,s){n.pendingLanes|=s,s!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function We(n,s,a,l,h,m){var y=n.pendingLanes;n.pendingLanes=a,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=a,n.entangledLanes&=a,n.errorRecoveryDisabledLanes&=a,n.shellSuspendCounter=0;var E=n.entanglements,I=n.expirationTimes,re=n.hiddenUpdates;for(a=y&~a;0<a;){var be=31-At(a),Ce=1<<be;E[be]=0,I[be]=-1;var ue=re[be];if(ue!==null)for(re[be]=null,be=0;be<ue.length;be++){var me=ue[be];me!==null&&(me.lane&=-536870913)}a&=~Ce}l!==0&&Je(n,l,0),m!==0&&h===0&&n.tag!==0&&(n.suspendedLanes|=m&~(y&~s))}function Je(n,s,a){n.pendingLanes|=s,n.suspendedLanes&=~s;var l=31-At(s);n.entangledLanes|=s,n.entanglements[l]=n.entanglements[l]|1073741824|a&261930}function It(n,s){var a=n.entangledLanes|=s;for(n=n.entanglements;a;){var l=31-At(a),h=1<<l;h&s|n[l]&s&&(n[l]|=s),a&=~h}}function Ft(n,s){var a=s&-s;return a=(a&42)!==0?1:Gn(a),(a&(n.suspendedLanes|s))!==0?0:a}function Gn(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function en(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function Bn(){var n=R.p;return n!==0?n:(n=window.event,n===void 0?32:rw(n.type))}function vn(n,s){var a=R.p;try{return R.p=n,s()}finally{R.p=a}}var _n=Math.random().toString(36).slice(2),sn="__reactFiber$"+_n,Zn="__reactProps$"+_n,Ki="__reactContainer$"+_n,gi="__reactEvents$"+_n,os="__reactListeners$"+_n,sa="__reactHandles$"+_n,ls="__reactResources$"+_n,oi="__reactMarker$"+_n;function cs(n){delete n[sn],delete n[Zn],delete n[gi],delete n[os],delete n[sa]}function us(n){var s=n[sn];if(s)return s;for(var a=n.parentNode;a;){if(s=a[Ki]||a[sn]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(n=F0(n);n!==null;){if(a=n[sn])return a;n=F0(n)}return s}n=a,a=n.parentNode}return null}function ds(n){if(n=n[sn]||n[Ki]){var s=n.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return n}return null}function Mi(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n.stateNode;throw Error(r(33))}function Bs(n){var s=n[ls];return s||(s=n[ls]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function fn(n){n[oi]=!0}var Ai=new Set,fo={};function Li(n,s){tn(n,s),tn(n+"Capture",s)}function tn(n,s){for(fo[n]=s,n=0;n<s.length;n++)Ai.add(s[n])}var wr=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]*$"),ra={},Xs={};function po(n){return Ee.call(Xs,n)?!0:Ee.call(ra,n)?!1:wr.test(n)?Xs[n]=!0:(ra[n]=!0,!1)}function Qn(n,s,a){if(po(s))if(a===null)n.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":n.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){n.removeAttribute(s);return}}n.setAttribute(s,""+a)}}function js(n,s,a){if(a===null)n.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(s);return}n.setAttribute(s,""+a)}}function Wi(n,s,a,l){if(l===null)n.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(a);return}n.setAttributeNS(s,a,""+l)}}function En(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function aa(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function cl(n,s,a){var l=Object.getOwnPropertyDescriptor(n.constructor.prototype,s);if(!n.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var h=l.get,m=l.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return h.call(this)},set:function(y){a=""+y,m.call(this,y)}}),Object.defineProperty(n,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(y){a=""+y},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function xr(n){if(!n._valueTracker){var s=aa(n)?"checked":"value";n._valueTracker=cl(n,s,""+n[s])}}function Gs(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return n&&(l=aa(n)?n.checked?"true":"false":n.value),n=l,n!==a?(s.setValue(n),!0):!1}function Is(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var mo=/[\n"\\]/g;function Dn(n){return n.replace(mo,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function li(n,s,a,l,h,m,y,E){n.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?n.type=y:n.removeAttribute("type"),s!=null?y==="number"?(s===0&&n.value===""||n.value!=s)&&(n.value=""+En(s)):n.value!==""+En(s)&&(n.value=""+En(s)):y!=="submit"&&y!=="reset"||n.removeAttribute("value"),s!=null?go(n,y,En(s)):a!=null?go(n,y,En(a)):l!=null&&n.removeAttribute("value"),h==null&&m!=null&&(n.defaultChecked=!!m),h!=null&&(n.checked=h&&typeof h!="function"&&typeof h!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?n.name=""+En(E):n.removeAttribute("name")}function Cr(n,s,a,l,h,m,y,E){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(n.type=m),s!=null||a!=null){if(!(m!=="submit"&&m!=="reset"||s!=null)){xr(n);return}a=a!=null?""+En(a):"",s=s!=null?""+En(s):a,E||s===n.value||(n.value=s),n.defaultValue=s}l=l??h,l=typeof l!="function"&&typeof l!="symbol"&&!!l,n.checked=E?n.checked:!!l,n.defaultChecked=!!l,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(n.name=y),xr(n)}function go(n,s,a){s==="number"&&Is(n.ownerDocument)===n||n.defaultValue===""+a||(n.defaultValue=""+a)}function hs(n,s,a,l){if(n=n.options,s){s={};for(var h=0;h<a.length;h++)s["$"+a[h]]=!0;for(a=0;a<n.length;a++)h=s.hasOwnProperty("$"+n[a].value),n[a].selected!==h&&(n[a].selected=h),h&&l&&(n[a].defaultSelected=!0)}else{for(a=""+En(a),s=null,h=0;h<n.length;h++){if(n[h].value===a){n[h].selected=!0,l&&(n[h].defaultSelected=!0);return}s!==null||n[h].disabled||(s=n[h])}s!==null&&(s.selected=!0)}}function vo(n,s,a){if(s!=null&&(s=""+En(s),s!==n.value&&(n.value=s),a==null)){n.defaultValue!==s&&(n.defaultValue=s);return}n.defaultValue=a!=null?""+En(a):""}function Zs(n,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(ae(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=En(s),n.defaultValue=a,l=n.textContent,l===a&&l!==""&&l!==null&&(n.value=l),xr(n)}function fs(n,s){if(s){var a=n.firstChild;if(a&&a===n.lastChild&&a.nodeType===3){a.nodeValue=s;return}}n.textContent=s}var Ps=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 Qs(n,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?n.setProperty(s,""):s==="float"?n.cssFloat="":n[s]="":l?n.setProperty(s,a):typeof a!="number"||a===0||Ps.has(s)?s==="float"?n.cssFloat=a:n[s]=(""+a).trim():n[s]=a+"px"}function ps(n,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(n=n.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?n.setProperty(l,""):l==="float"?n.cssFloat="":n[l]="");for(var h in s)l=s[h],s.hasOwnProperty(h)&&a[h]!==l&&Qs(n,h,l)}else for(var m in s)s.hasOwnProperty(m)&&Qs(n,m,s[m])}function vi(n){if(n.indexOf("-")===-1)return!1;switch(n){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 kc=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"]]),oa=/^[\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 Oi(n){return oa.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function _i(){}var la=null;function _o(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var qi=null,Js=null;function ci(n){var s=ds(n);if(s&&(n=s.stateNode)){var a=n[Zn]||null;e:switch(n=s.stateNode,s.type){case"input":if(li(n,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Dn(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==n&&l.form===n.form){var h=l[Zn]||null;if(!h)throw Error(r(90));li(l,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===n.form&&Gs(l)}break e;case"textarea":vo(n,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&hs(n,!!a.multiple,s,!1)}}}var bo=!1;function yo(n,s,a){if(bo)return n(s,a);bo=!0;try{var l=n(s);return l}finally{if(bo=!1,(qi!==null||Js!==null)&&(dh(),qi&&(s=qi,n=Js,Js=qi=null,ci(s),n)))for(s=0;s<n.length;s++)ci(n[s])}}function Ci(n,s){var a=n.stateNode;if(a===null)return null;var l=a[Zn]||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)||(n=n.type,l=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!l;break e;default:n=!1}if(n)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var Bi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),kr=!1;if(Bi)try{var ms={};Object.defineProperty(ms,"passive",{get:function(){kr=!0}}),window.addEventListener("test",ms,ms),window.removeEventListener("test",ms,ms)}catch{kr=!1}var bi=null,Rn=null,er=null;function ut(){if(er)return er;var n,s=Rn,a=s.length,l,h="value"in bi?bi.value:bi.textContent,m=h.length;for(n=0;n<a&&s[n]===h[n];n++);var y=a-n;for(l=1;l<=y&&s[a-l]===h[m-l];l++);return er=h.slice(n,1<l?1-l:void 0)}function gs(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function Vi(){return!0}function Tr(){return!1}function jn(n){function s(a,l,h,m,y){this._reactName=a,this._targetInst=h,this.type=l,this.nativeEvent=m,this.target=y,this.currentTarget=null;for(var E in n)n.hasOwnProperty(E)&&(a=n[E],this[E]=a?a(m):m[E]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Vi:Tr,this.isPropagationStopped=Tr,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=Vi)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Vi)},persist:function(){},isPersistent:Vi}),s}var vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tr=jn(vs),Yi=b({},vs,{view:0,detail:0}),Tc=jn(Yi),ca,nr,ir,ua=b({},Yi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rr,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==ir&&(ir&&n.type==="mousemove"?(ca=n.screenX-ir.screenX,nr=n.screenY-ir.screenY):nr=ca=0,ir=n),ca)},movementY:function(n){return"movementY"in n?n.movementY:nr}}),ul=jn(ua),Ec=b({},ua,{dataTransfer:0}),Er=jn(Ec),So=b({},Yi,{relatedTarget:0}),ji=jn(So),da=b({},vs,{animationName:0,elapsedTime:0,pseudoElement:0}),dl=jn(da),wo=b({},vs,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Dc=jn(wo),Rc=b({},vs,{data:0}),Dr=jn(Rc),sr={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ha={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"},In={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xo(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=In[n])?!!s[n]:!1}function rr(){return xo}var fa=b({},Yi,{key:function(n){if(n.key){var s=sr[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=gs(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?ha[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rr,charCode:function(n){return n.type==="keypress"?gs(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?gs(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),hl=jn(fa),fl=b({},ua,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jn=jn(fl),Nn=b({},Yi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rr}),Nc=jn(Nn),pl=b({},vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),ml=jn(pl),gl=b({},ua,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Mc=jn(gl),S=b({},vs,{newState:0,oldState:0}),k=jn(S),B=[9,13,27,32],X=Bi&&"CompositionEvent"in window,oe=null;Bi&&"documentMode"in document&&(oe=document.documentMode);var he=Bi&&"TextEvent"in window&&!oe,xe=Bi&&(!X||oe&&8<oe&&11>=oe),Oe=" ",Pe=!1;function ht(n,s){switch(n){case"keyup":return B.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mt(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var yi=!1;function pn(n,s){switch(n){case"compositionend":return Mt(s);case"keypress":return s.which!==32?null:(Pe=!0,Oe);case"textInput":return n=s.data,n===Oe&&Pe?null:n;default:return null}}function zs(n,s){if(yi)return n==="compositionend"||!X&&ht(n,s)?(n=ut(),er=Rn=bi=null,yi=!1,n):null;switch(n){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 xe&&s.locale!=="ko"?null:s.data;default:return null}}var xp={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 Cd(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!xp[n.type]:s==="textarea"}function kd(n,s,a,l){qi?Js?Js.push(l):Js=[l]:qi=l,s=_h(s,"onChange"),0<s.length&&(a=new tr("onChange","change",null,a,l),n.push({event:a,listeners:s}))}var pa=null,Rr=null;function vl(n){R0(n,0)}function Co(n){var s=Mi(n);if(Gs(s))return n}function Ac(n,s){if(n==="change")return s}var Td=!1;if(Bi){var _l;if(Bi){var bl="oninput"in document;if(!bl){var Lc=document.createElement("div");Lc.setAttribute("oninput","return;"),bl=typeof Lc.oninput=="function"}_l=bl}else _l=!1;Td=_l&&(!document.documentMode||9<document.documentMode)}function Ed(){pa&&(pa.detachEvent("onpropertychange",Oc),Rr=pa=null)}function Oc(n){if(n.propertyName==="value"&&Co(Rr)){var s=[];kd(s,Rr,n,_o(n)),yo(vl,s)}}function ar(n,s,a){n==="focusin"?(Ed(),pa=s,Rr=a,pa.attachEvent("onpropertychange",Oc)):n==="focusout"&&Ed()}function Cp(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Co(Rr)}function kp(n,s){if(n==="click")return Co(s)}function Dd(n,s){if(n==="input"||n==="change")return Co(s)}function Tp(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var ki=typeof Object.is=="function"?Object.is:Tp;function Xi(n,s){if(ki(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var a=Object.keys(n),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var h=a[l];if(!Ee.call(s,h)||!ki(n[h],s[h]))return!1}return!0}function Rd(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Nd(n,s){var a=Rd(n);n=0;for(var l;a;){if(a.nodeType===3){if(l=n+a.textContent.length,n<=s&&l>=s)return{node:a,offset:s-n};n=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Rd(a)}}function Md(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?Md(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function Bc(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var s=Is(n.document);s instanceof n.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)n=s.contentWindow;else break;s=Is(n.document)}return s}function _s(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}var Ep=Bi&&"documentMode"in document&&11>=document.documentMode,ma=null,ko=null,To=null,yl=!1;function T(n,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;yl||ma==null||ma!==Is(l)||(l=ma,"selectionStart"in l&&_s(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}),To&&Xi(To,l)||(To=l,l=_h(ko,"onSelect"),0<l.length&&(s=new tr("onSelect","select",null,s,a),n.push({event:s,listeners:l}),s.target=ma)))}function F(n,s){var a={};return a[n.toLowerCase()]=s.toLowerCase(),a["Webkit"+n]="webkit"+s,a["Moz"+n]="moz"+s,a}var Le={animationend:F("Animation","AnimationEnd"),animationiteration:F("Animation","AnimationIteration"),animationstart:F("Animation","AnimationStart"),transitionrun:F("Transition","TransitionRun"),transitionstart:F("Transition","TransitionStart"),transitioncancel:F("Transition","TransitionCancel"),transitionend:F("Transition","TransitionEnd")},Xe={},Qe={};Bi&&(Qe=document.createElement("div").style,"AnimationEvent"in window||(delete Le.animationend.animation,delete Le.animationiteration.animation,delete Le.animationstart.animation),"TransitionEvent"in window||delete Le.transitionend.transition);function rt(n){if(Xe[n])return Xe[n];if(!Le[n])return n;var s=Le[n],a;for(a in s)if(s.hasOwnProperty(a)&&a in Qe)return Xe[n]=s[a];return n}var gt=rt("animationend"),vt=rt("animationiteration"),nt=rt("animationstart"),nn=rt("transitionrun"),Yt=rt("transitionstart"),Kt=rt("transitioncancel"),Hs=rt("transitionend"),Eo=new Map,bs="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(" ");bs.push("scrollEnd");function Ii(n,s){Eo.set(n,s),Li(s,[n])}var Do=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=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(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},ys=[],Sl=0,Dp=0;function Ad(){for(var n=Sl,s=Dp=Sl=0;s<n;){var a=ys[s];ys[s++]=null;var l=ys[s];ys[s++]=null;var h=ys[s];ys[s++]=null;var m=ys[s];if(ys[s++]=null,l!==null&&h!==null){var y=l.pending;y===null?h.next=h:(h.next=y.next,y.next=h),l.pending=h}m!==0&&uy(a,h,m)}}function Ld(n,s,a,l){ys[Sl++]=n,ys[Sl++]=s,ys[Sl++]=a,ys[Sl++]=l,Dp|=l,n.lanes|=l,n=n.alternate,n!==null&&(n.lanes|=l)}function Rp(n,s,a,l){return Ld(n,s,a,l),Od(n)}function Ro(n,s){return Ld(n,null,null,s),Od(n)}function uy(n,s,a){n.lanes|=a;var l=n.alternate;l!==null&&(l.lanes|=a);for(var h=!1,m=n.return;m!==null;)m.childLanes|=a,l=m.alternate,l!==null&&(l.childLanes|=a),m.tag===22&&(n=m.stateNode,n===null||n._visibility&1||(h=!0)),n=m,m=m.return;return n.tag===3?(m=n.stateNode,h&&s!==null&&(h=31-At(a),n=m.hiddenUpdates,l=n[h],l===null?n[h]=[s]:l.push(s),s.lane=a|536870912),m):null}function Od(n){if(50<iu)throw iu=0,Pm=null,Error(r(185));for(var s=n.return;s!==null;)n=s,s=n.return;return n.tag===3?n.stateNode:null}var wl={};function IE(n,s,a,l){this.tag=n,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 Gi(n,s,a,l){return new IE(n,s,a,l)}function Np(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Nr(n,s){var a=n.alternate;return a===null?(a=Gi(n.tag,s,n.key,n.mode),a.elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=s,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=n.flags&65011712,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,s=n.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a.refCleanup=n.refCleanup,a}function dy(n,s){n.flags&=65011714;var a=n.alternate;return a===null?(n.childLanes=0,n.lanes=s,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=a.childLanes,n.lanes=a.lanes,n.child=a.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=a.memoizedProps,n.memoizedState=a.memoizedState,n.updateQueue=a.updateQueue,n.type=a.type,s=a.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),n}function Bd(n,s,a,l,h,m){var y=0;if(l=n,typeof n=="function")Np(n)&&(y=1);else if(typeof n=="string")y=$2(n,a,Z.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case fe:return n=Gi(31,a,s,h),n.elementType=fe,n.lanes=m,n;case N:return No(a.children,h,m,s);case L:y=8,h|=24;break;case M:return n=Gi(12,a,s,h|2),n.elementType=M,n.lanes=m,n;case K:return n=Gi(13,a,s,h),n.elementType=K,n.lanes=m,n;case ee:return n=Gi(19,a,s,h),n.elementType=ee,n.lanes=m,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case P:y=10;break e;case U:y=9;break e;case H:y=11;break e;case j:y=14;break e;case J:y=16,l=null;break e}y=29,a=Error(r(130,n===null?"null":typeof n,"")),l=null}return s=Gi(y,a,s,h),s.elementType=n,s.type=l,s.lanes=m,s}function No(n,s,a,l){return n=Gi(7,n,l,s),n.lanes=a,n}function Mp(n,s,a){return n=Gi(6,n,null,s),n.lanes=a,n}function hy(n){var s=Gi(18,null,null,0);return s.stateNode=n,s}function Ap(n,s,a){return s=Gi(4,n.children!==null?n.children:[],n.key,s),s.lanes=a,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}var fy=new WeakMap;function Ss(n,s){if(typeof n=="object"&&n!==null){var a=fy.get(n);return a!==void 0?a:(s={value:n,source:s,stack:ge(s)},fy.set(n,s),s)}return{value:n,source:s,stack:ge(s)}}var xl=[],Cl=0,jd=null,jc=0,ws=[],xs=0,ga=null,or=1,lr="";function Mr(n,s){xl[Cl++]=jc,xl[Cl++]=jd,jd=n,jc=s}function py(n,s,a){ws[xs++]=or,ws[xs++]=lr,ws[xs++]=ga,ga=n;var l=or;n=lr;var h=32-At(l)-1;l&=~(1<<h),a+=1;var m=32-At(s)+h;if(30<m){var y=h-h%5;m=(l&(1<<y)-1).toString(32),l>>=y,h-=y,or=1<<32-At(s)+h|a<<h|l,lr=m+n}else or=1<<m|a<<h|l,lr=n}function Lp(n){n.return!==null&&(Mr(n,1),py(n,1,0))}function Op(n){for(;n===jd;)jd=xl[--Cl],xl[Cl]=null,jc=xl[--Cl],xl[Cl]=null;for(;n===ga;)ga=ws[--xs],ws[xs]=null,lr=ws[--xs],ws[xs]=null,or=ws[--xs],ws[xs]=null}function my(n,s){ws[xs++]=or,ws[xs++]=lr,ws[xs++]=ga,or=s.id,lr=s.overflow,ga=n}var ui=null,rn=null,Rt=!1,va=null,Cs=!1,Bp=Error(r(519));function _a(n){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ic(Ss(s,n)),Bp}function gy(n){var s=n.stateNode,a=n.type,l=n.memoizedProps;switch(s[sn]=n,s[Zn]=l,a){case"dialog":Ct("cancel",s),Ct("close",s);break;case"iframe":case"object":case"embed":Ct("load",s);break;case"video":case"audio":for(a=0;a<ru.length;a++)Ct(ru[a],s);break;case"source":Ct("error",s);break;case"img":case"image":case"link":Ct("error",s),Ct("load",s);break;case"details":Ct("toggle",s);break;case"input":Ct("invalid",s),Cr(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":Ct("invalid",s);break;case"textarea":Ct("invalid",s),Zs(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||L0(s.textContent,a)?(l.popover!=null&&(Ct("beforetoggle",s),Ct("toggle",s)),l.onScroll!=null&&Ct("scroll",s),l.onScrollEnd!=null&&Ct("scrollend",s),l.onClick!=null&&(s.onclick=_i),s=!0):s=!1,s||_a(n,!0)}function vy(n){for(ui=n.return;ui;)switch(ui.tag){case 5:case 31:case 13:Cs=!1;return;case 27:case 3:Cs=!0;return;default:ui=ui.return}}function kl(n){if(n!==ui)return!1;if(!Rt)return vy(n),Rt=!0,!1;var s=n.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=n.type,a=!(a!=="form"&&a!=="button")||Jm(n.type,n.memoizedProps)),a=!a),a&&rn&&_a(n),vy(n),s===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));rn=$0(n)}else if(s===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));rn=$0(n)}else s===27?(s=rn,Aa(n.type)?(n=sg,sg=null,rn=n):rn=s):rn=ui?Ts(n.stateNode.nextSibling):null;return!0}function Mo(){rn=ui=null,Rt=!1}function jp(){var n=va;return n!==null&&(Ui===null?Ui=n:Ui.push.apply(Ui,n),va=null),n}function Ic(n){va===null?va=[n]:va.push(n)}var Ip=A(null),Ao=null,Ar=null;function ba(n,s,a){de(Ip,s._currentValue),s._currentValue=a}function Lr(n){n._currentValue=Ip.current,V(Ip)}function Pp(n,s,a){for(;n!==null;){var l=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),n===a)break;n=n.return}}function zp(n,s,a,l){var h=n.child;for(h!==null&&(h.return=n);h!==null;){var m=h.dependencies;if(m!==null){var y=h.child;m=m.firstContext;e:for(;m!==null;){var E=m;m=h;for(var I=0;I<s.length;I++)if(E.context===s[I]){m.lanes|=a,E=m.alternate,E!==null&&(E.lanes|=a),Pp(m.return,a,n),l||(y=null);break e}m=E.next}}else if(h.tag===18){if(y=h.return,y===null)throw Error(r(341));y.lanes|=a,m=y.alternate,m!==null&&(m.lanes|=a),Pp(y,a,n),y=null}else y=h.child;if(y!==null)y.return=h;else for(y=h;y!==null;){if(y===n){y=null;break}if(h=y.sibling,h!==null){h.return=y.return,y=h;break}y=y.return}h=y}}function Tl(n,s,a,l){n=null;for(var h=s,m=!1;h!==null;){if(!m){if((h.flags&524288)!==0)m=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var y=h.alternate;if(y===null)throw Error(r(387));if(y=y.memoizedProps,y!==null){var E=h.type;ki(h.pendingProps.value,y.value)||(n!==null?n.push(E):n=[E])}}else if(h===Me.current){if(y=h.alternate,y===null)throw Error(r(387));y.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(n!==null?n.push(uu):n=[uu])}h=h.return}n!==null&&zp(s,n,a,l),s.flags|=262144}function Id(n){for(n=n.firstContext;n!==null;){if(!ki(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Lo(n){Ao=n,Ar=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function di(n){return _y(Ao,n)}function Pd(n,s){return Ao===null&&Lo(n),_y(n,s)}function _y(n,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},Ar===null){if(n===null)throw Error(r(308));Ar=s,n.dependencies={lanes:0,firstContext:s},n.flags|=524288}else Ar=Ar.next=s;return a}var PE=typeof AbortController<"u"?AbortController:function(){var n=[],s=this.signal={aborted:!1,addEventListener:function(a,l){n.push(l)}};this.abort=function(){s.aborted=!0,n.forEach(function(a){return a()})}},zE=e.unstable_scheduleCallback,HE=e.unstable_NormalPriority,Pn={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Hp(){return{controller:new PE,data:new Map,refCount:0}}function Pc(n){n.refCount--,n.refCount===0&&zE(HE,function(){n.controller.abort()})}var zc=null,Up=0,El=0,Dl=null;function UE(n,s){if(zc===null){var a=zc=[];Up=0,El=Km(),Dl={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Up++,s.then(by,by),s}function by(){if(--Up===0&&zc!==null){Dl!==null&&(Dl.status="fulfilled");var n=zc;zc=null,El=0,Dl=null;for(var s=0;s<n.length;s++)(0,n[s])()}}function $E(n,s){var a=[],l={status:"pending",value:null,reason:null,then:function(h){a.push(h)}};return n.then(function(){l.status="fulfilled",l.value=s;for(var h=0;h<a.length;h++)(0,a[h])(s)},function(h){for(l.status="rejected",l.reason=h,h=0;h<a.length;h++)(0,a[h])(void 0)}),l}var yy=O.S;O.S=function(n,s){i0=Ae(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&UE(n,s),yy!==null&&yy(n,s)};var Oo=A(null);function $p(){var n=Oo.current;return n!==null?n:Jt.pooledCache}function zd(n,s){s===null?de(Oo,Oo.current):de(Oo,s.pool)}function Sy(){var n=$p();return n===null?null:{parent:Pn._currentValue,pool:n}}var Rl=Error(r(460)),Fp=Error(r(474)),Hd=Error(r(542)),Ud={then:function(){}};function wy(n){return n=n.status,n==="fulfilled"||n==="rejected"}function xy(n,s,a){switch(a=n[a],a===void 0?n.push(s):a!==s&&(s.then(_i,_i),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw n=s.reason,ky(n),n;default:if(typeof s.status=="string")s.then(_i,_i);else{if(n=Jt,n!==null&&100<n.shellSuspendCounter)throw Error(r(482));n=s,n.status="pending",n.then(function(l){if(s.status==="pending"){var h=s;h.status="fulfilled",h.value=l}},function(l){if(s.status==="pending"){var h=s;h.status="rejected",h.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw n=s.reason,ky(n),n}throw jo=s,Rl}}function Bo(n){try{var s=n._init;return s(n._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(jo=a,Rl):a}}var jo=null;function Cy(){if(jo===null)throw Error(r(459));var n=jo;return jo=null,n}function ky(n){if(n===Rl||n===Hd)throw Error(r(483))}var Nl=null,Hc=0;function $d(n){var s=Hc;return Hc+=1,Nl===null&&(Nl=[]),xy(Nl,n,s)}function Uc(n,s){s=s.props.ref,n.ref=s!==void 0?s:null}function Fd(n,s){throw s.$$typeof===w?Error(r(525)):(n=Object.prototype.toString.call(s),Error(r(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n)))}function Ty(n){function s(G,W){if(n){var se=G.deletions;se===null?(G.deletions=[W],G.flags|=16):se.push(W)}}function a(G,W){if(!n)return null;for(;W!==null;)s(G,W),W=W.sibling;return null}function l(G){for(var W=new Map;G!==null;)G.key!==null?W.set(G.key,G):W.set(G.index,G),G=G.sibling;return W}function h(G,W){return G=Nr(G,W),G.index=0,G.sibling=null,G}function m(G,W,se){return G.index=se,n?(se=G.alternate,se!==null?(se=se.index,se<W?(G.flags|=67108866,W):se):(G.flags|=67108866,W)):(G.flags|=1048576,W)}function y(G){return n&&G.alternate===null&&(G.flags|=67108866),G}function E(G,W,se,we){return W===null||W.tag!==6?(W=Mp(se,G.mode,we),W.return=G,W):(W=h(W,se),W.return=G,W)}function I(G,W,se,we){var et=se.type;return et===N?be(G,W,se.props.children,we,se.key):W!==null&&(W.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===J&&Bo(et)===W.type)?(W=h(W,se.props),Uc(W,se),W.return=G,W):(W=Bd(se.type,se.key,se.props,null,G.mode,we),Uc(W,se),W.return=G,W)}function re(G,W,se,we){return W===null||W.tag!==4||W.stateNode.containerInfo!==se.containerInfo||W.stateNode.implementation!==se.implementation?(W=Ap(se,G.mode,we),W.return=G,W):(W=h(W,se.children||[]),W.return=G,W)}function be(G,W,se,we,et){return W===null||W.tag!==7?(W=No(se,G.mode,we,et),W.return=G,W):(W=h(W,se),W.return=G,W)}function Ce(G,W,se){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Mp(""+W,G.mode,se),W.return=G,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case x:return se=Bd(W.type,W.key,W.props,null,G.mode,se),Uc(se,W),se.return=G,se;case C:return W=Ap(W,G.mode,se),W.return=G,W;case J:return W=Bo(W),Ce(G,W,se)}if(ae(W)||Y(W))return W=No(W,G.mode,se,null),W.return=G,W;if(typeof W.then=="function")return Ce(G,$d(W),se);if(W.$$typeof===P)return Ce(G,Pd(G,W),se);Fd(G,W)}return null}function ue(G,W,se,we){var et=W!==null?W.key:null;if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return et!==null?null:E(G,W,""+se,we);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case x:return se.key===et?I(G,W,se,we):null;case C:return se.key===et?re(G,W,se,we):null;case J:return se=Bo(se),ue(G,W,se,we)}if(ae(se)||Y(se))return et!==null?null:be(G,W,se,we,null);if(typeof se.then=="function")return ue(G,W,$d(se),we);if(se.$$typeof===P)return ue(G,W,Pd(G,se),we);Fd(G,se)}return null}function me(G,W,se,we,et){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return G=G.get(se)||null,E(W,G,""+we,et);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case x:return G=G.get(we.key===null?se:we.key)||null,I(W,G,we,et);case C:return G=G.get(we.key===null?se:we.key)||null,re(W,G,we,et);case J:return we=Bo(we),me(G,W,se,we,et)}if(ae(we)||Y(we))return G=G.get(se)||null,be(W,G,we,et,null);if(typeof we.then=="function")return me(G,W,se,$d(we),et);if(we.$$typeof===P)return me(G,W,se,Pd(W,we),et);Fd(W,we)}return null}function Ke(G,W,se,we){for(var et=null,Lt=null,qe=W,pt=W=0,Et=null;qe!==null&&pt<se.length;pt++){qe.index>pt?(Et=qe,qe=null):Et=qe.sibling;var Ot=ue(G,qe,se[pt],we);if(Ot===null){qe===null&&(qe=Et);break}n&&qe&&Ot.alternate===null&&s(G,qe),W=m(Ot,W,pt),Lt===null?et=Ot:Lt.sibling=Ot,Lt=Ot,qe=Et}if(pt===se.length)return a(G,qe),Rt&&Mr(G,pt),et;if(qe===null){for(;pt<se.length;pt++)qe=Ce(G,se[pt],we),qe!==null&&(W=m(qe,W,pt),Lt===null?et=qe:Lt.sibling=qe,Lt=qe);return Rt&&Mr(G,pt),et}for(qe=l(qe);pt<se.length;pt++)Et=me(qe,G,pt,se[pt],we),Et!==null&&(n&&Et.alternate!==null&&qe.delete(Et.key===null?pt:Et.key),W=m(Et,W,pt),Lt===null?et=Et:Lt.sibling=Et,Lt=Et);return n&&qe.forEach(function(Ia){return s(G,Ia)}),Rt&&Mr(G,pt),et}function st(G,W,se,we){if(se==null)throw Error(r(151));for(var et=null,Lt=null,qe=W,pt=W=0,Et=null,Ot=se.next();qe!==null&&!Ot.done;pt++,Ot=se.next()){qe.index>pt?(Et=qe,qe=null):Et=qe.sibling;var Ia=ue(G,qe,Ot.value,we);if(Ia===null){qe===null&&(qe=Et);break}n&&qe&&Ia.alternate===null&&s(G,qe),W=m(Ia,W,pt),Lt===null?et=Ia:Lt.sibling=Ia,Lt=Ia,qe=Et}if(Ot.done)return a(G,qe),Rt&&Mr(G,pt),et;if(qe===null){for(;!Ot.done;pt++,Ot=se.next())Ot=Ce(G,Ot.value,we),Ot!==null&&(W=m(Ot,W,pt),Lt===null?et=Ot:Lt.sibling=Ot,Lt=Ot);return Rt&&Mr(G,pt),et}for(qe=l(qe);!Ot.done;pt++,Ot=se.next())Ot=me(qe,G,pt,Ot.value,we),Ot!==null&&(n&&Ot.alternate!==null&&qe.delete(Ot.key===null?pt:Ot.key),W=m(Ot,W,pt),Lt===null?et=Ot:Lt.sibling=Ot,Lt=Ot);return n&&qe.forEach(function(J2){return s(G,J2)}),Rt&&Mr(G,pt),et}function Zt(G,W,se,we){if(typeof se=="object"&&se!==null&&se.type===N&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case x:e:{for(var et=se.key;W!==null;){if(W.key===et){if(et=se.type,et===N){if(W.tag===7){a(G,W.sibling),we=h(W,se.props.children),we.return=G,G=we;break e}}else if(W.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===J&&Bo(et)===W.type){a(G,W.sibling),we=h(W,se.props),Uc(we,se),we.return=G,G=we;break e}a(G,W);break}else s(G,W);W=W.sibling}se.type===N?(we=No(se.props.children,G.mode,we,se.key),we.return=G,G=we):(we=Bd(se.type,se.key,se.props,null,G.mode,we),Uc(we,se),we.return=G,G=we)}return y(G);case C:e:{for(et=se.key;W!==null;){if(W.key===et)if(W.tag===4&&W.stateNode.containerInfo===se.containerInfo&&W.stateNode.implementation===se.implementation){a(G,W.sibling),we=h(W,se.children||[]),we.return=G,G=we;break e}else{a(G,W);break}else s(G,W);W=W.sibling}we=Ap(se,G.mode,we),we.return=G,G=we}return y(G);case J:return se=Bo(se),Zt(G,W,se,we)}if(ae(se))return Ke(G,W,se,we);if(Y(se)){if(et=Y(se),typeof et!="function")throw Error(r(150));return se=et.call(se),st(G,W,se,we)}if(typeof se.then=="function")return Zt(G,W,$d(se),we);if(se.$$typeof===P)return Zt(G,W,Pd(G,se),we);Fd(G,se)}return typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint"?(se=""+se,W!==null&&W.tag===6?(a(G,W.sibling),we=h(W,se),we.return=G,G=we):(a(G,W),we=Mp(se,G.mode,we),we.return=G,G=we),y(G)):a(G,W)}return function(G,W,se,we){try{Hc=0;var et=Zt(G,W,se,we);return Nl=null,et}catch(qe){if(qe===Rl||qe===Hd)throw qe;var Lt=Gi(29,qe,null,G.mode);return Lt.lanes=we,Lt.return=G,Lt}}}var Io=Ty(!0),Ey=Ty(!1),ya=!1;function Kp(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Sa(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function wa(n,s,a){var l=n.updateQueue;if(l===null)return null;if(l=l.shared,(Pt&2)!==0){var h=l.pending;return h===null?s.next=s:(s.next=h.next,h.next=s),l.pending=s,s=Od(n),uy(n,null,a),s}return Ld(n,l,s,a),Od(n)}function $c(n,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=n.pendingLanes,a|=l,s.lanes=a,It(n,a)}}function qp(n,s){var a=n.updateQueue,l=n.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var h=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?h=m=y:m=m.next=y,a=a.next}while(a!==null);m===null?h=m=s:m=m.next=s}else h=m=s;a={baseState:l.baseState,firstBaseUpdate:h,lastBaseUpdate:m,shared:l.shared,callbacks:l.callbacks},n.updateQueue=a;return}n=a.lastBaseUpdate,n===null?a.firstBaseUpdate=s:n.next=s,a.lastBaseUpdate=s}var Vp=!1;function Fc(){if(Vp){var n=Dl;if(n!==null)throw n}}function Kc(n,s,a,l){Vp=!1;var h=n.updateQueue;ya=!1;var m=h.firstBaseUpdate,y=h.lastBaseUpdate,E=h.shared.pending;if(E!==null){h.shared.pending=null;var I=E,re=I.next;I.next=null,y===null?m=re:y.next=re,y=I;var be=n.alternate;be!==null&&(be=be.updateQueue,E=be.lastBaseUpdate,E!==y&&(E===null?be.firstBaseUpdate=re:E.next=re,be.lastBaseUpdate=I))}if(m!==null){var Ce=h.baseState;y=0,be=re=I=null,E=m;do{var ue=E.lane&-536870913,me=ue!==E.lane;if(me?(Tt&ue)===ue:(l&ue)===ue){ue!==0&&ue===El&&(Vp=!0),be!==null&&(be=be.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ke=n,st=E;ue=s;var Zt=a;switch(st.tag){case 1:if(Ke=st.payload,typeof Ke=="function"){Ce=Ke.call(Zt,Ce,ue);break e}Ce=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=st.payload,ue=typeof Ke=="function"?Ke.call(Zt,Ce,ue):Ke,ue==null)break e;Ce=b({},Ce,ue);break e;case 2:ya=!0}}ue=E.callback,ue!==null&&(n.flags|=64,me&&(n.flags|=8192),me=h.callbacks,me===null?h.callbacks=[ue]:me.push(ue))}else me={lane:ue,tag:E.tag,payload:E.payload,callback:E.callback,next:null},be===null?(re=be=me,I=Ce):be=be.next=me,y|=ue;if(E=E.next,E===null){if(E=h.shared.pending,E===null)break;me=E,E=me.next,me.next=null,h.lastBaseUpdate=me,h.shared.pending=null}}while(!0);be===null&&(I=Ce),h.baseState=I,h.firstBaseUpdate=re,h.lastBaseUpdate=be,m===null&&(h.shared.lanes=0),Ea|=y,n.lanes=y,n.memoizedState=Ce}}function Dy(n,s){if(typeof n!="function")throw Error(r(191,n));n.call(s)}function Ry(n,s){var a=n.callbacks;if(a!==null)for(n.callbacks=null,n=0;n<a.length;n++)Dy(a[n],s)}var Ml=A(null),Kd=A(0);function Ny(n,s){n=$r,de(Kd,n),de(Ml,s),$r=n|s.baseLanes}function Yp(){de(Kd,$r),de(Ml,Ml.current)}function Xp(){$r=Kd.current,V(Ml),V(Kd)}var Zi=A(null),ks=null;function xa(n){var s=n.alternate;de(Mn,Mn.current&1),de(Zi,n),ks===null&&(s===null||Ml.current!==null||s.memoizedState!==null)&&(ks=n)}function Gp(n){de(Mn,Mn.current),de(Zi,n),ks===null&&(ks=n)}function My(n){n.tag===22?(de(Mn,Mn.current),de(Zi,n),ks===null&&(ks=n)):Ca()}function Ca(){de(Mn,Mn.current),de(Zi,Zi.current)}function Qi(n){V(Zi),ks===n&&(ks=null),V(Mn)}var Mn=A(0);function Wd(n){for(var s=n;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||ng(a)||ig(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===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Or=0,ft=null,Xt=null,zn=null,qd=!1,Al=!1,Po=!1,Vd=0,Wc=0,Ll=null,FE=0;function bn(){throw Error(r(321))}function Zp(n,s){if(s===null)return!1;for(var a=0;a<s.length&&a<n.length;a++)if(!ki(n[a],s[a]))return!1;return!0}function Qp(n,s,a,l,h,m){return Or=m,ft=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,O.H=n===null||n.memoizedState===null?pS:fm,Po=!1,m=a(l,h),Po=!1,Al&&(m=Ly(s,a,l,h)),Ay(n),m}function Ay(n){O.H=Yc;var s=Xt!==null&&Xt.next!==null;if(Or=0,zn=Xt=ft=null,qd=!1,Wc=0,Ll=null,s)throw Error(r(300));n===null||Hn||(n=n.dependencies,n!==null&&Id(n)&&(Hn=!0))}function Ly(n,s,a,l){ft=n;var h=0;do{if(Al&&(Ll=null),Wc=0,Al=!1,25<=h)throw Error(r(301));if(h+=1,zn=Xt=null,n.updateQueue!=null){var m=n.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}O.H=mS,m=s(a,l)}while(Al);return m}function KE(){var n=O.H,s=n.useState()[0];return s=typeof s.then=="function"?qc(s):s,n=n.useState()[0],(Xt!==null?Xt.memoizedState:null)!==n&&(ft.flags|=1024),s}function Jp(){var n=Vd!==0;return Vd=0,n}function em(n,s,a){s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~a}function tm(n){if(qd){for(n=n.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}qd=!1}Or=0,zn=Xt=ft=null,Al=!1,Wc=Vd=0,Ll=null}function Ti(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zn===null?ft.memoizedState=zn=n:zn=zn.next=n,zn}function An(){if(Xt===null){var n=ft.alternate;n=n!==null?n.memoizedState:null}else n=Xt.next;var s=zn===null?ft.memoizedState:zn.next;if(s!==null)zn=s,Xt=n;else{if(n===null)throw ft.alternate===null?Error(r(467)):Error(r(310));Xt=n,n={memoizedState:Xt.memoizedState,baseState:Xt.baseState,baseQueue:Xt.baseQueue,queue:Xt.queue,next:null},zn===null?ft.memoizedState=zn=n:zn=zn.next=n}return zn}function Yd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function qc(n){var s=Wc;return Wc+=1,Ll===null&&(Ll=[]),n=xy(Ll,n,s),s=ft,(zn===null?s.memoizedState:zn.next)===null&&(s=s.alternate,O.H=s===null||s.memoizedState===null?pS:fm),n}function Xd(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return qc(n);if(n.$$typeof===P)return di(n)}throw Error(r(438,String(n)))}function nm(n){var s=null,a=ft.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=ft.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(h){return h.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Yd(),ft.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(n),l=0;l<n;l++)a[l]=ie;return s.index++,a}function Br(n,s){return typeof s=="function"?s(n):s}function Gd(n){var s=An();return im(s,Xt,n)}function im(n,s,a){var l=n.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var h=n.baseQueue,m=l.pending;if(m!==null){if(h!==null){var y=h.next;h.next=m.next,m.next=y}s.baseQueue=h=m,l.pending=null}if(m=n.baseState,h===null)n.memoizedState=m;else{s=h.next;var E=y=null,I=null,re=s,be=!1;do{var Ce=re.lane&-536870913;if(Ce!==re.lane?(Tt&Ce)===Ce:(Or&Ce)===Ce){var ue=re.revertLane;if(ue===0)I!==null&&(I=I.next={lane:0,revertLane:0,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),Ce===El&&(be=!0);else if((Or&ue)===ue){re=re.next,ue===El&&(be=!0);continue}else Ce={lane:0,revertLane:re.revertLane,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},I===null?(E=I=Ce,y=m):I=I.next=Ce,ft.lanes|=ue,Ea|=ue;Ce=re.action,Po&&a(m,Ce),m=re.hasEagerState?re.eagerState:a(m,Ce)}else ue={lane:Ce,revertLane:re.revertLane,gesture:re.gesture,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},I===null?(E=I=ue,y=m):I=I.next=ue,ft.lanes|=Ce,Ea|=Ce;re=re.next}while(re!==null&&re!==s);if(I===null?y=m:I.next=E,!ki(m,n.memoizedState)&&(Hn=!0,be&&(a=Dl,a!==null)))throw a;n.memoizedState=m,n.baseState=y,n.baseQueue=I,l.lastRenderedState=m}return h===null&&(l.lanes=0),[n.memoizedState,l.dispatch]}function sm(n){var s=An(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=n;var l=a.dispatch,h=a.pending,m=s.memoizedState;if(h!==null){a.pending=null;var y=h=h.next;do m=n(m,y.action),y=y.next;while(y!==h);ki(m,s.memoizedState)||(Hn=!0),s.memoizedState=m,s.baseQueue===null&&(s.baseState=m),a.lastRenderedState=m}return[m,l]}function Oy(n,s,a){var l=ft,h=An(),m=Rt;if(m){if(a===void 0)throw Error(r(407));a=a()}else a=s();var y=!ki((Xt||h).memoizedState,a);if(y&&(h.memoizedState=a,Hn=!0),h=h.queue,om(Iy.bind(null,l,h,n),[n]),h.getSnapshot!==s||y||zn!==null&&zn.memoizedState.tag&1){if(l.flags|=2048,Ol(9,{destroy:void 0},jy.bind(null,l,h,a,s),null),Jt===null)throw Error(r(349));m||(Or&127)!==0||By(l,s,a)}return a}function By(n,s,a){n.flags|=16384,n={getSnapshot:s,value:a},s=ft.updateQueue,s===null?(s=Yd(),ft.updateQueue=s,s.stores=[n]):(a=s.stores,a===null?s.stores=[n]:a.push(n))}function jy(n,s,a,l){s.value=a,s.getSnapshot=l,Py(s)&&zy(n)}function Iy(n,s,a){return a(function(){Py(s)&&zy(n)})}function Py(n){var s=n.getSnapshot;n=n.value;try{var a=s();return!ki(n,a)}catch{return!0}}function zy(n){var s=Ro(n,2);s!==null&&$i(s,n,2)}function rm(n){var s=Ti();if(typeof n=="function"){var a=n;if(n=a(),Po){$t(!0);try{a()}finally{$t(!1)}}}return s.memoizedState=s.baseState=n,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:n},s}function Hy(n,s,a,l){return n.baseState=a,im(n,Xt,typeof l=="function"?l:Br)}function WE(n,s,a,l,h){if(Jd(n))throw Error(r(485));if(n=s.action,n!==null){var m={payload:h,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){m.listeners.push(y)}};O.T!==null?a(!0):m.isTransition=!1,l(m),a=s.pending,a===null?(m.next=s.pending=m,Uy(s,m)):(m.next=a.next,s.pending=a.next=m)}}function Uy(n,s){var a=s.action,l=s.payload,h=n.state;if(s.isTransition){var m=O.T,y={};O.T=y;try{var E=a(h,l),I=O.S;I!==null&&I(y,E),$y(n,s,E)}catch(re){am(n,s,re)}finally{m!==null&&y.types!==null&&(m.types=y.types),O.T=m}}else try{m=a(h,l),$y(n,s,m)}catch(re){am(n,s,re)}}function $y(n,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Fy(n,s,l)},function(l){return am(n,s,l)}):Fy(n,s,a)}function Fy(n,s,a){s.status="fulfilled",s.value=a,Ky(s),n.state=a,s=n.pending,s!==null&&(a=s.next,a===s?n.pending=null:(a=a.next,s.next=a,Uy(n,a)))}function am(n,s,a){var l=n.pending;if(n.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,Ky(s),s=s.next;while(s!==l)}n.action=null}function Ky(n){n=n.listeners;for(var s=0;s<n.length;s++)(0,n[s])()}function Wy(n,s){return s}function qy(n,s){if(Rt){var a=Jt.formState;if(a!==null){e:{var l=ft;if(Rt){if(rn){t:{for(var h=rn,m=Cs;h.nodeType!==8;){if(!m){h=null;break t}if(h=Ts(h.nextSibling),h===null){h=null;break t}}m=h.data,h=m==="F!"||m==="F"?h:null}if(h){rn=Ts(h.nextSibling),l=h.data==="F!";break e}}_a(l)}l=!1}l&&(s=a[0])}}return a=Ti(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wy,lastRenderedState:s},a.queue=l,a=dS.bind(null,ft,l),l.dispatch=a,l=rm(!1),m=hm.bind(null,ft,!1,l.queue),l=Ti(),h={state:s,dispatch:null,action:n,pending:null},l.queue=h,a=WE.bind(null,ft,h,m,a),h.dispatch=a,l.memoizedState=n,[s,a,!1]}function Vy(n){var s=An();return Yy(s,Xt,n)}function Yy(n,s,a){if(s=im(n,s,Wy)[0],n=Gd(Br)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=qc(s)}catch(y){throw y===Rl?Hd:y}else l=s;s=An();var h=s.queue,m=h.dispatch;return a!==s.memoizedState&&(ft.flags|=2048,Ol(9,{destroy:void 0},qE.bind(null,h,a),null)),[l,m,n]}function qE(n,s){n.action=s}function Xy(n){var s=An(),a=Xt;if(a!==null)return Yy(s,a,n);An(),s=s.memoizedState,a=An();var l=a.queue.dispatch;return a.memoizedState=n,[s,l,!1]}function Ol(n,s,a,l){return n={tag:n,create:a,deps:l,inst:s,next:null},s=ft.updateQueue,s===null&&(s=Yd(),ft.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=n.next=n:(l=a.next,a.next=n,n.next=l,s.lastEffect=n),n}function Gy(){return An().memoizedState}function Zd(n,s,a,l){var h=Ti();ft.flags|=n,h.memoizedState=Ol(1|s,{destroy:void 0},a,l===void 0?null:l)}function Qd(n,s,a,l){var h=An();l=l===void 0?null:l;var m=h.memoizedState.inst;Xt!==null&&l!==null&&Zp(l,Xt.memoizedState.deps)?h.memoizedState=Ol(s,m,a,l):(ft.flags|=n,h.memoizedState=Ol(1|s,m,a,l))}function Zy(n,s){Zd(8390656,8,n,s)}function om(n,s){Qd(2048,8,n,s)}function VE(n){ft.flags|=4;var s=ft.updateQueue;if(s===null)s=Yd(),ft.updateQueue=s,s.events=[n];else{var a=s.events;a===null?s.events=[n]:a.push(n)}}function Qy(n){var s=An().memoizedState;return VE({ref:s,nextImpl:n}),function(){if((Pt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Jy(n,s){return Qd(4,2,n,s)}function eS(n,s){return Qd(4,4,n,s)}function tS(n,s){if(typeof s=="function"){n=n();var a=s(n);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function nS(n,s,a){a=a!=null?a.concat([n]):null,Qd(4,4,tS.bind(null,s,n),a)}function lm(){}function iS(n,s){var a=An();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Zp(s,l[1])?l[0]:(a.memoizedState=[n,s],n)}function sS(n,s){var a=An();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Zp(s,l[1]))return l[0];if(l=n(),Po){$t(!0);try{n()}finally{$t(!1)}}return a.memoizedState=[l,s],l}function cm(n,s,a){return a===void 0||(Or&1073741824)!==0&&(Tt&261930)===0?n.memoizedState=s:(n.memoizedState=a,n=r0(),ft.lanes|=n,Ea|=n,a)}function rS(n,s,a,l){return ki(a,s)?a:Ml.current!==null?(n=cm(n,a,l),ki(n,s)||(Hn=!0),n):(Or&42)===0||(Or&1073741824)!==0&&(Tt&261930)===0?(Hn=!0,n.memoizedState=a):(n=r0(),ft.lanes|=n,Ea|=n,s)}function aS(n,s,a,l,h){var m=R.p;R.p=m!==0&&8>m?m:8;var y=O.T,E={};O.T=E,hm(n,!1,s,a);try{var I=h(),re=O.S;if(re!==null&&re(E,I),I!==null&&typeof I=="object"&&typeof I.then=="function"){var be=$E(I,l);Vc(n,s,be,ts(n))}else Vc(n,s,l,ts(n))}catch(Ce){Vc(n,s,{then:function(){},status:"rejected",reason:Ce},ts())}finally{R.p=m,y!==null&&E.types!==null&&(y.types=E.types),O.T=y}}function YE(){}function um(n,s,a,l){if(n.tag!==5)throw Error(r(476));var h=oS(n).queue;aS(n,h,s,z,a===null?YE:function(){return lS(n),a(l)})}function oS(n){var s=n.memoizedState;if(s!==null)return s;s={memoizedState:z,baseState:z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:z},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:a},next:null},n.memoizedState=s,n=n.alternate,n!==null&&(n.memoizedState=s),s}function lS(n){var s=oS(n);s.next===null&&(s=n.alternate.memoizedState),Vc(n,s.next.queue,{},ts())}function dm(){return di(uu)}function cS(){return An().memoizedState}function uS(){return An().memoizedState}function XE(n){for(var s=n.return;s!==null;){switch(s.tag){case 24:case 3:var a=ts();n=Sa(a);var l=wa(s,n,a);l!==null&&($i(l,s,a),$c(l,s,a)),s={cache:Hp()},n.payload=s;return}s=s.return}}function GE(n,s,a){var l=ts();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Jd(n)?hS(s,a):(a=Rp(n,s,a,l),a!==null&&($i(a,n,l),fS(a,s,l)))}function dS(n,s,a){var l=ts();Vc(n,s,a,l)}function Vc(n,s,a,l){var h={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Jd(n))hS(s,h);else{var m=n.alternate;if(n.lanes===0&&(m===null||m.lanes===0)&&(m=s.lastRenderedReducer,m!==null))try{var y=s.lastRenderedState,E=m(y,a);if(h.hasEagerState=!0,h.eagerState=E,ki(E,y))return Ld(n,s,h,0),Jt===null&&Ad(),!1}catch{}if(a=Rp(n,s,h,l),a!==null)return $i(a,n,l),fS(a,s,l),!0}return!1}function hm(n,s,a,l){if(l={lane:2,revertLane:Km(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Jd(n)){if(s)throw Error(r(479))}else s=Rp(n,a,l,2),s!==null&&$i(s,n,2)}function Jd(n){var s=n.alternate;return n===ft||s!==null&&s===ft}function hS(n,s){Al=qd=!0;var a=n.pending;a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s}function fS(n,s,a){if((a&4194048)!==0){var l=s.lanes;l&=n.pendingLanes,a|=l,s.lanes=a,It(n,a)}}var Yc={readContext:di,use:Xd,useCallback:bn,useContext:bn,useEffect:bn,useImperativeHandle:bn,useLayoutEffect:bn,useInsertionEffect:bn,useMemo:bn,useReducer:bn,useRef:bn,useState:bn,useDebugValue:bn,useDeferredValue:bn,useTransition:bn,useSyncExternalStore:bn,useId:bn,useHostTransitionStatus:bn,useFormState:bn,useActionState:bn,useOptimistic:bn,useMemoCache:bn,useCacheRefresh:bn};Yc.useEffectEvent=bn;var pS={readContext:di,use:Xd,useCallback:function(n,s){return Ti().memoizedState=[n,s===void 0?null:s],n},useContext:di,useEffect:Zy,useImperativeHandle:function(n,s,a){a=a!=null?a.concat([n]):null,Zd(4194308,4,tS.bind(null,s,n),a)},useLayoutEffect:function(n,s){return Zd(4194308,4,n,s)},useInsertionEffect:function(n,s){Zd(4,2,n,s)},useMemo:function(n,s){var a=Ti();s=s===void 0?null:s;var l=n();if(Po){$t(!0);try{n()}finally{$t(!1)}}return a.memoizedState=[l,s],l},useReducer:function(n,s,a){var l=Ti();if(a!==void 0){var h=a(s);if(Po){$t(!0);try{a(s)}finally{$t(!1)}}}else h=s;return l.memoizedState=l.baseState=h,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:h},l.queue=n,n=n.dispatch=GE.bind(null,ft,n),[l.memoizedState,n]},useRef:function(n){var s=Ti();return n={current:n},s.memoizedState=n},useState:function(n){n=rm(n);var s=n.queue,a=dS.bind(null,ft,s);return s.dispatch=a,[n.memoizedState,a]},useDebugValue:lm,useDeferredValue:function(n,s){var a=Ti();return cm(a,n,s)},useTransition:function(){var n=rm(!1);return n=aS.bind(null,ft,n.queue,!0,!1),Ti().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,s,a){var l=ft,h=Ti();if(Rt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Jt===null)throw Error(r(349));(Tt&127)!==0||By(l,s,a)}h.memoizedState=a;var m={value:a,getSnapshot:s};return h.queue=m,Zy(Iy.bind(null,l,m,n),[n]),l.flags|=2048,Ol(9,{destroy:void 0},jy.bind(null,l,m,a,s),null),a},useId:function(){var n=Ti(),s=Jt.identifierPrefix;if(Rt){var a=lr,l=or;a=(l&~(1<<32-At(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Vd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=FE++,s="_"+s+"r_"+a.toString(32)+"_";return n.memoizedState=s},useHostTransitionStatus:dm,useFormState:qy,useActionState:qy,useOptimistic:function(n){var s=Ti();s.memoizedState=s.baseState=n;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=hm.bind(null,ft,!0,a),a.dispatch=s,[n,s]},useMemoCache:nm,useCacheRefresh:function(){return Ti().memoizedState=XE.bind(null,ft)},useEffectEvent:function(n){var s=Ti(),a={impl:n};return s.memoizedState=a,function(){if((Pt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},fm={readContext:di,use:Xd,useCallback:iS,useContext:di,useEffect:om,useImperativeHandle:nS,useInsertionEffect:Jy,useLayoutEffect:eS,useMemo:sS,useReducer:Gd,useRef:Gy,useState:function(){return Gd(Br)},useDebugValue:lm,useDeferredValue:function(n,s){var a=An();return rS(a,Xt.memoizedState,n,s)},useTransition:function(){var n=Gd(Br)[0],s=An().memoizedState;return[typeof n=="boolean"?n:qc(n),s]},useSyncExternalStore:Oy,useId:cS,useHostTransitionStatus:dm,useFormState:Vy,useActionState:Vy,useOptimistic:function(n,s){var a=An();return Hy(a,Xt,n,s)},useMemoCache:nm,useCacheRefresh:uS};fm.useEffectEvent=Qy;var mS={readContext:di,use:Xd,useCallback:iS,useContext:di,useEffect:om,useImperativeHandle:nS,useInsertionEffect:Jy,useLayoutEffect:eS,useMemo:sS,useReducer:sm,useRef:Gy,useState:function(){return sm(Br)},useDebugValue:lm,useDeferredValue:function(n,s){var a=An();return Xt===null?cm(a,n,s):rS(a,Xt.memoizedState,n,s)},useTransition:function(){var n=sm(Br)[0],s=An().memoizedState;return[typeof n=="boolean"?n:qc(n),s]},useSyncExternalStore:Oy,useId:cS,useHostTransitionStatus:dm,useFormState:Xy,useActionState:Xy,useOptimistic:function(n,s){var a=An();return Xt!==null?Hy(a,Xt,n,s):(a.baseState=n,[n,a.queue.dispatch])},useMemoCache:nm,useCacheRefresh:uS};mS.useEffectEvent=Qy;function pm(n,s,a,l){s=n.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),n.memoizedState=a,n.lanes===0&&(n.updateQueue.baseState=a)}var mm={enqueueSetState:function(n,s,a){n=n._reactInternals;var l=ts(),h=Sa(l);h.payload=s,a!=null&&(h.callback=a),s=wa(n,h,l),s!==null&&($i(s,n,l),$c(s,n,l))},enqueueReplaceState:function(n,s,a){n=n._reactInternals;var l=ts(),h=Sa(l);h.tag=1,h.payload=s,a!=null&&(h.callback=a),s=wa(n,h,l),s!==null&&($i(s,n,l),$c(s,n,l))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var a=ts(),l=Sa(a);l.tag=2,s!=null&&(l.callback=s),s=wa(n,l,a),s!==null&&($i(s,n,a),$c(s,n,a))}};function gS(n,s,a,l,h,m,y){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(l,m,y):s.prototype&&s.prototype.isPureReactComponent?!Xi(a,l)||!Xi(h,m):!0}function vS(n,s,a,l){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==n&&mm.enqueueReplaceState(s,s.state,null)}function zo(n,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(n=n.defaultProps){a===s&&(a=b({},a));for(var h in n)a[h]===void 0&&(a[h]=n[h])}return a}function _S(n){Do(n)}function bS(n){console.error(n)}function yS(n){Do(n)}function eh(n,s){try{var a=n.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function SS(n,s,a){try{var l=n.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function gm(n,s,a){return a=Sa(a),a.tag=3,a.payload={element:null},a.callback=function(){eh(n,s)},a}function wS(n){return n=Sa(n),n.tag=3,n}function xS(n,s,a,l){var h=a.type.getDerivedStateFromError;if(typeof h=="function"){var m=l.value;n.payload=function(){return h(m)},n.callback=function(){SS(s,a,l)}}var y=a.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(n.callback=function(){SS(s,a,l),typeof h!="function"&&(Da===null?Da=new Set([this]):Da.add(this));var E=l.stack;this.componentDidCatch(l.value,{componentStack:E!==null?E:""})})}function ZE(n,s,a,l,h){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Tl(s,a,h,!0),a=Zi.current,a!==null){switch(a.tag){case 31:case 13:return ks===null?hh():a.alternate===null&&yn===0&&(yn=3),a.flags&=-257,a.flags|=65536,a.lanes=h,l===Ud?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),Um(n,l,h)),!1;case 22:return a.flags|=65536,l===Ud?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)),Um(n,l,h)),!1}throw Error(r(435,a.tag))}return Um(n,l,h),hh(),!1}if(Rt)return s=Zi.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=h,l!==Bp&&(n=Error(r(422),{cause:l}),Ic(Ss(n,a)))):(l!==Bp&&(s=Error(r(423),{cause:l}),Ic(Ss(s,a))),n=n.current.alternate,n.flags|=65536,h&=-h,n.lanes|=h,l=Ss(l,a),h=gm(n.stateNode,l,h),qp(n,h),yn!==4&&(yn=2)),!1;var m=Error(r(520),{cause:l});if(m=Ss(m,a),nu===null?nu=[m]:nu.push(m),yn!==4&&(yn=2),s===null)return!0;l=Ss(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,n=h&-h,a.lanes|=n,n=gm(a.stateNode,l,n),qp(a,n),!1;case 1:if(s=a.type,m=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Da===null||!Da.has(m))))return a.flags|=65536,h&=-h,a.lanes|=h,h=wS(h),xS(h,n,a,l),qp(a,h),!1}a=a.return}while(a!==null);return!1}var vm=Error(r(461)),Hn=!1;function hi(n,s,a,l){s.child=n===null?Ey(s,null,a,l):Io(s,n.child,a,l)}function CS(n,s,a,l,h){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 Lo(s),l=Qp(n,s,a,y,m,h),E=Jp(),n!==null&&!Hn?(em(n,s,h),jr(n,s,h)):(Rt&&E&&Lp(s),s.flags|=1,hi(n,s,l,h),s.child)}function kS(n,s,a,l,h){if(n===null){var m=a.type;return typeof m=="function"&&!Np(m)&&m.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=m,TS(n,s,m,l,h)):(n=Bd(a.type,null,l,s,s.mode,h),n.ref=s.ref,n.return=s,s.child=n)}if(m=n.child,!km(n,h)){var y=m.memoizedProps;if(a=a.compare,a=a!==null?a:Xi,a(y,l)&&n.ref===s.ref)return jr(n,s,h)}return s.flags|=1,n=Nr(m,l),n.ref=s.ref,n.return=s,s.child=n}function TS(n,s,a,l,h){if(n!==null){var m=n.memoizedProps;if(Xi(m,l)&&n.ref===s.ref)if(Hn=!1,s.pendingProps=l=m,km(n,h))(n.flags&131072)!==0&&(Hn=!0);else return s.lanes=n.lanes,jr(n,s,h)}return _m(n,s,a,l,h)}function ES(n,s,a,l){var h=l.children,m=n!==null?n.memoizedState:null;if(n===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,n!==null){for(l=s.child=n.child,h=0;l!==null;)h=h|l.lanes|l.childLanes,l=l.sibling;l=h&~m}else l=0,s.child=null;return DS(n,s,m,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},n!==null&&zd(s,m!==null?m.cachePool:null),m!==null?Ny(s,m):Yp(),My(s);else return l=s.lanes=536870912,DS(n,s,m!==null?m.baseLanes|a:a,a,l)}else m!==null?(zd(s,m.cachePool),Ny(s,m),Ca(),s.memoizedState=null):(n!==null&&zd(s,null),Yp(),Ca());return hi(n,s,h,a),s.child}function Xc(n,s){return n!==null&&n.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function DS(n,s,a,l,h){var m=$p();return m=m===null?null:{parent:Pn._currentValue,pool:m},s.memoizedState={baseLanes:a,cachePool:m},n!==null&&zd(s,null),Yp(),My(s),n!==null&&Tl(n,s,l,!0),s.childLanes=h,null}function th(n,s){return s=ih({mode:s.mode,children:s.children},n.mode),s.ref=n.ref,n.child=s,s.return=n,s}function RS(n,s,a){return Io(s,n.child,null,a),n=th(s,s.pendingProps),n.flags|=2,Qi(s),s.memoizedState=null,n}function QE(n,s,a){var l=s.pendingProps,h=(s.flags&128)!==0;if(s.flags&=-129,n===null){if(Rt){if(l.mode==="hidden")return n=th(s,l),s.lanes=536870912,Xc(null,n);if(Gp(s),(n=rn)?(n=U0(n,Cs),n=n!==null&&n.data==="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:ga!==null?{id:or,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},a=hy(n),a.return=s,s.child=a,ui=s,rn=null)):n=null,n===null)throw _a(s);return s.lanes=536870912,null}return th(s,l)}var m=n.memoizedState;if(m!==null){var y=m.dehydrated;if(Gp(s),h)if(s.flags&256)s.flags&=-257,s=RS(n,s,a);else if(s.memoizedState!==null)s.child=n.child,s.flags|=128,s=null;else throw Error(r(558));else if(Hn||Tl(n,s,a,!1),h=(a&n.childLanes)!==0,Hn||h){if(l=Jt,l!==null&&(y=Ft(l,a),y!==0&&y!==m.retryLane))throw m.retryLane=y,Ro(n,y),$i(l,n,y),vm;hh(),s=RS(n,s,a)}else n=m.treeContext,rn=Ts(y.nextSibling),ui=s,Rt=!0,va=null,Cs=!1,n!==null&&my(s,n),s=th(s,l),s.flags|=4096;return s}return n=Nr(n.child,{mode:l.mode,children:l.children}),n.ref=s.ref,s.child=n,n.return=s,n}function nh(n,s){var a=s.ref;if(a===null)n!==null&&n.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(n===null||n.ref!==a)&&(s.flags|=4194816)}}function _m(n,s,a,l,h){return Lo(s),a=Qp(n,s,a,l,void 0,h),l=Jp(),n!==null&&!Hn?(em(n,s,h),jr(n,s,h)):(Rt&&l&&Lp(s),s.flags|=1,hi(n,s,a,h),s.child)}function NS(n,s,a,l,h,m){return Lo(s),s.updateQueue=null,a=Ly(s,l,a,h),Ay(n),l=Jp(),n!==null&&!Hn?(em(n,s,m),jr(n,s,m)):(Rt&&l&&Lp(s),s.flags|=1,hi(n,s,a,m),s.child)}function MS(n,s,a,l,h){if(Lo(s),s.stateNode===null){var m=wl,y=a.contextType;typeof y=="object"&&y!==null&&(m=di(y)),m=new a(l,m),s.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=mm,s.stateNode=m,m._reactInternals=s,m=s.stateNode,m.props=l,m.state=s.memoizedState,m.refs={},Kp(s),y=a.contextType,m.context=typeof y=="object"&&y!==null?di(y):wl,m.state=s.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(pm(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&&mm.enqueueReplaceState(m,m.state,null),Kc(s,l,m,h),Fc(),m.state=s.memoizedState),typeof m.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(n===null){m=s.stateNode;var E=s.memoizedProps,I=zo(a,E);m.props=I;var re=m.context,be=a.contextType;y=wl,typeof be=="object"&&be!==null&&(y=di(be));var Ce=a.getDerivedStateFromProps;be=typeof Ce=="function"||typeof m.getSnapshotBeforeUpdate=="function",E=s.pendingProps!==E,be||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(E||re!==y)&&vS(s,m,l,y),ya=!1;var ue=s.memoizedState;m.state=ue,Kc(s,l,m,h),Fc(),re=s.memoizedState,E||ue!==re||ya?(typeof Ce=="function"&&(pm(s,a,Ce,l),re=s.memoizedState),(I=ya||gS(s,a,I,l,ue,re,y))?(be||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=re),m.props=l,m.state=re,m.context=y,l=I):(typeof m.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{m=s.stateNode,Wp(n,s),y=s.memoizedProps,be=zo(a,y),m.props=be,Ce=s.pendingProps,ue=m.context,re=a.contextType,I=wl,typeof re=="object"&&re!==null&&(I=di(re)),E=a.getDerivedStateFromProps,(re=typeof E=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(y!==Ce||ue!==I)&&vS(s,m,l,I),ya=!1,ue=s.memoizedState,m.state=ue,Kc(s,l,m,h),Fc();var me=s.memoizedState;y!==Ce||ue!==me||ya||n!==null&&n.dependencies!==null&&Id(n.dependencies)?(typeof E=="function"&&(pm(s,a,E,l),me=s.memoizedState),(be=ya||gS(s,a,be,l,ue,me,I)||n!==null&&n.dependencies!==null&&Id(n.dependencies))?(re||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(l,me,I),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(l,me,I)),typeof m.componentDidUpdate=="function"&&(s.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof m.componentDidUpdate!="function"||y===n.memoizedProps&&ue===n.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&ue===n.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=me),m.props=l,m.state=me,m.context=I,l=be):(typeof m.componentDidUpdate!="function"||y===n.memoizedProps&&ue===n.memoizedState||(s.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||y===n.memoizedProps&&ue===n.memoizedState||(s.flags|=1024),l=!1)}return m=l,nh(n,s),l=(s.flags&128)!==0,m||l?(m=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:m.render(),s.flags|=1,n!==null&&l?(s.child=Io(s,n.child,null,h),s.child=Io(s,null,a,h)):hi(n,s,a,h),s.memoizedState=m.state,n=s.child):n=jr(n,s,h),n}function AS(n,s,a,l){return Mo(),s.flags|=256,hi(n,s,a,l),s.child}var bm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ym(n){return{baseLanes:n,cachePool:Sy()}}function Sm(n,s,a){return n=n!==null?n.childLanes&~a:0,s&&(n|=es),n}function LS(n,s,a){var l=s.pendingProps,h=!1,m=(s.flags&128)!==0,y;if((y=m)||(y=n!==null&&n.memoizedState===null?!1:(Mn.current&2)!==0),y&&(h=!0,s.flags&=-129),y=(s.flags&32)!==0,s.flags&=-33,n===null){if(Rt){if(h?xa(s):Ca(),(n=rn)?(n=U0(n,Cs),n=n!==null&&n.data!=="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:ga!==null?{id:or,overflow:lr}:null,retryLane:536870912,hydrationErrors:null},a=hy(n),a.return=s,s.child=a,ui=s,rn=null)):n=null,n===null)throw _a(s);return ig(n)?s.lanes=32:s.lanes=536870912,null}var E=l.children;return l=l.fallback,h?(Ca(),h=s.mode,E=ih({mode:"hidden",children:E},h),l=No(l,h,a,null),E.return=s,l.return=s,E.sibling=l,s.child=E,l=s.child,l.memoizedState=ym(a),l.childLanes=Sm(n,y,a),s.memoizedState=bm,Xc(null,l)):(xa(s),wm(s,E))}var I=n.memoizedState;if(I!==null&&(E=I.dehydrated,E!==null)){if(m)s.flags&256?(xa(s),s.flags&=-257,s=xm(n,s,a)):s.memoizedState!==null?(Ca(),s.child=n.child,s.flags|=128,s=null):(Ca(),E=l.fallback,h=s.mode,l=ih({mode:"visible",children:l.children},h),E=No(E,h,a,null),E.flags|=2,l.return=s,E.return=s,l.sibling=E,s.child=l,Io(s,n.child,null,a),l=s.child,l.memoizedState=ym(a),l.childLanes=Sm(n,y,a),s.memoizedState=bm,s=Xc(null,l));else if(xa(s),ig(E)){if(y=E.nextSibling&&E.nextSibling.dataset,y)var re=y.dgst;y=re,l=Error(r(419)),l.stack="",l.digest=y,Ic({value:l,source:null,stack:null}),s=xm(n,s,a)}else if(Hn||Tl(n,s,a,!1),y=(a&n.childLanes)!==0,Hn||y){if(y=Jt,y!==null&&(l=Ft(y,a),l!==0&&l!==I.retryLane))throw I.retryLane=l,Ro(n,l),$i(y,n,l),vm;ng(E)||hh(),s=xm(n,s,a)}else ng(E)?(s.flags|=192,s.child=n.child,s=null):(n=I.treeContext,rn=Ts(E.nextSibling),ui=s,Rt=!0,va=null,Cs=!1,n!==null&&my(s,n),s=wm(s,l.children),s.flags|=4096);return s}return h?(Ca(),E=l.fallback,h=s.mode,I=n.child,re=I.sibling,l=Nr(I,{mode:"hidden",children:l.children}),l.subtreeFlags=I.subtreeFlags&65011712,re!==null?E=Nr(re,E):(E=No(E,h,a,null),E.flags|=2),E.return=s,l.return=s,l.sibling=E,s.child=l,Xc(null,l),l=s.child,E=n.child.memoizedState,E===null?E=ym(a):(h=E.cachePool,h!==null?(I=Pn._currentValue,h=h.parent!==I?{parent:I,pool:I}:h):h=Sy(),E={baseLanes:E.baseLanes|a,cachePool:h}),l.memoizedState=E,l.childLanes=Sm(n,y,a),s.memoizedState=bm,Xc(n.child,l)):(xa(s),a=n.child,n=a.sibling,a=Nr(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,n!==null&&(y=s.deletions,y===null?(s.deletions=[n],s.flags|=16):y.push(n)),s.child=a,s.memoizedState=null,a)}function wm(n,s){return s=ih({mode:"visible",children:s},n.mode),s.return=n,n.child=s}function ih(n,s){return n=Gi(22,n,null,s),n.lanes=0,n}function xm(n,s,a){return Io(s,n.child,null,a),n=wm(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function OS(n,s,a){n.lanes|=s;var l=n.alternate;l!==null&&(l.lanes|=s),Pp(n.return,s,a)}function Cm(n,s,a,l,h,m){var y=n.memoizedState;y===null?n.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:h,treeForkCount:m}:(y.isBackwards=s,y.rendering=null,y.renderingStartTime=0,y.last=l,y.tail=a,y.tailMode=h,y.treeForkCount=m)}function BS(n,s,a){var l=s.pendingProps,h=l.revealOrder,m=l.tail;l=l.children;var y=Mn.current,E=(y&2)!==0;if(E?(y=y&1|2,s.flags|=128):y&=1,de(Mn,y),hi(n,s,l,a),l=Rt?jc:0,!E&&n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&OS(n,a,s);else if(n.tag===19)OS(n,a,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(h){case"forwards":for(a=s.child,h=null;a!==null;)n=a.alternate,n!==null&&Wd(n)===null&&(h=a),a=a.sibling;a=h,a===null?(h=s.child,s.child=null):(h=a.sibling,a.sibling=null),Cm(s,!1,h,a,m,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,h=s.child,s.child=null;h!==null;){if(n=h.alternate,n!==null&&Wd(n)===null){s.child=h;break}n=h.sibling,h.sibling=a,a=h,h=n}Cm(s,!0,a,null,m,l);break;case"together":Cm(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function jr(n,s,a){if(n!==null&&(s.dependencies=n.dependencies),Ea|=s.lanes,(a&s.childLanes)===0)if(n!==null){if(Tl(n,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(n!==null&&s.child!==n.child)throw Error(r(153));if(s.child!==null){for(n=s.child,a=Nr(n,n.pendingProps),s.child=a,a.return=s;n.sibling!==null;)n=n.sibling,a=a.sibling=Nr(n,n.pendingProps),a.return=s;a.sibling=null}return s.child}function km(n,s){return(n.lanes&s)!==0?!0:(n=n.dependencies,!!(n!==null&&Id(n)))}function JE(n,s,a){switch(s.tag){case 3:He(s,s.stateNode.containerInfo),ba(s,Pn,n.memoizedState.cache),Mo();break;case 27:case 5:Ue(s);break;case 4:He(s,s.stateNode.containerInfo);break;case 10:ba(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Gp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(xa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?LS(n,s,a):(xa(s),n=jr(n,s,a),n!==null?n.sibling:null);xa(s);break;case 19:var h=(n.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Tl(n,s,a,!1),l=(a&s.childLanes)!==0),h){if(l)return BS(n,s,a);s.flags|=128}if(h=s.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),de(Mn,Mn.current),l)break;return null;case 22:return s.lanes=0,ES(n,s,a,s.pendingProps);case 24:ba(s,Pn,n.memoizedState.cache)}return jr(n,s,a)}function jS(n,s,a){if(n!==null)if(n.memoizedProps!==s.pendingProps)Hn=!0;else{if(!km(n,a)&&(s.flags&128)===0)return Hn=!1,JE(n,s,a);Hn=(n.flags&131072)!==0}else Hn=!1,Rt&&(s.flags&1048576)!==0&&py(s,jc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(n=Bo(s.elementType),s.type=n,typeof n=="function")Np(n)?(l=zo(n,l),s.tag=1,s=MS(null,s,n,l,a)):(s.tag=0,s=_m(null,s,n,l,a));else{if(n!=null){var h=n.$$typeof;if(h===H){s.tag=11,s=CS(null,s,n,l,a);break e}else if(h===j){s.tag=14,s=kS(null,s,n,l,a);break e}}throw s=q(n)||n,Error(r(306,s,""))}}return s;case 0:return _m(n,s,s.type,s.pendingProps,a);case 1:return l=s.type,h=zo(l,s.pendingProps),MS(n,s,l,h,a);case 3:e:{if(He(s,s.stateNode.containerInfo),n===null)throw Error(r(387));l=s.pendingProps;var m=s.memoizedState;h=m.element,Wp(n,s),Kc(s,l,null,a);var y=s.memoizedState;if(l=y.cache,ba(s,Pn,l),l!==m.cache&&zp(s,[Pn],a,!0),Fc(),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=AS(n,s,l,a);break e}else if(l!==h){h=Ss(Error(r(424)),s),Ic(h),s=AS(n,s,l,a);break e}else for(n=s.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,rn=Ts(n.firstChild),ui=s,Rt=!0,va=null,Cs=!0,a=Ey(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Mo(),l===h){s=jr(n,s,a);break e}hi(n,s,l,a)}s=s.child}return s;case 26:return nh(n,s),n===null?(a=V0(s.type,null,s.pendingProps,null))?s.memoizedState=a:Rt||(a=s.type,n=s.pendingProps,l=bh(ye.current).createElement(a),l[sn]=s,l[Zn]=n,fi(l,a,n),fn(l),s.stateNode=l):s.memoizedState=V0(s.type,n.memoizedProps,s.pendingProps,n.memoizedState),null;case 27:return Ue(s),n===null&&Rt&&(l=s.stateNode=K0(s.type,s.pendingProps,ye.current),ui=s,Cs=!0,h=rn,Aa(s.type)?(sg=h,rn=Ts(l.firstChild)):rn=h),hi(n,s,s.pendingProps.children,a),nh(n,s),n===null&&(s.flags|=4194304),s.child;case 5:return n===null&&Rt&&((h=l=rn)&&(l=R2(l,s.type,s.pendingProps,Cs),l!==null?(s.stateNode=l,ui=s,rn=Ts(l.firstChild),Cs=!1,h=!0):h=!1),h||_a(s)),Ue(s),h=s.type,m=s.pendingProps,y=n!==null?n.memoizedProps:null,l=m.children,Jm(h,m)?l=null:y!==null&&Jm(h,y)&&(s.flags|=32),s.memoizedState!==null&&(h=Qp(n,s,KE,null,null,a),uu._currentValue=h),nh(n,s),hi(n,s,l,a),s.child;case 6:return n===null&&Rt&&((n=a=rn)&&(a=N2(a,s.pendingProps,Cs),a!==null?(s.stateNode=a,ui=s,rn=null,n=!0):n=!1),n||_a(s)),null;case 13:return LS(n,s,a);case 4:return He(s,s.stateNode.containerInfo),l=s.pendingProps,n===null?s.child=Io(s,null,l,a):hi(n,s,l,a),s.child;case 11:return CS(n,s,s.type,s.pendingProps,a);case 7:return hi(n,s,s.pendingProps,a),s.child;case 8:return hi(n,s,s.pendingProps.children,a),s.child;case 12:return hi(n,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,ba(s,s.type,l.value),hi(n,s,l.children,a),s.child;case 9:return h=s.type._context,l=s.pendingProps.children,Lo(s),h=di(h),l=l(h),s.flags|=1,hi(n,s,l,a),s.child;case 14:return kS(n,s,s.type,s.pendingProps,a);case 15:return TS(n,s,s.type,s.pendingProps,a);case 19:return BS(n,s,a);case 31:return QE(n,s,a);case 22:return ES(n,s,a,s.pendingProps);case 24:return Lo(s),l=di(Pn),n===null?(h=$p(),h===null&&(h=Jt,m=Hp(),h.pooledCache=m,m.refCount++,m!==null&&(h.pooledCacheLanes|=a),h=m),s.memoizedState={parent:l,cache:h},Kp(s),ba(s,Pn,h)):((n.lanes&a)!==0&&(Wp(n,s),Kc(s,null,null,a),Fc()),h=n.memoizedState,m=s.memoizedState,h.parent!==l?(h={parent:l,cache:l},s.memoizedState=h,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=h),ba(s,Pn,l)):(l=m.cache,ba(s,Pn,l),l!==h.cache&&zp(s,[Pn],a,!0))),hi(n,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function Ir(n){n.flags|=4}function Tm(n,s,a,l,h){if((s=(n.mode&32)!==0)&&(s=!1),s){if(n.flags|=16777216,(h&335544128)===h)if(n.stateNode.complete)n.flags|=8192;else if(c0())n.flags|=8192;else throw jo=Ud,Fp}else n.flags&=-16777217}function IS(n,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!Q0(s))if(c0())n.flags|=8192;else throw jo=Ud,Fp}function sh(n,s){s!==null&&(n.flags|=4),n.flags&16384&&(s=n.tag!==22?_e():536870912,n.lanes|=s,Pl|=s)}function Gc(n,s){if(!Rt)switch(n.tailMode){case"hidden":s=n.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:l.sibling=null}}function an(n){var s=n.alternate!==null&&n.alternate.child===n.child,a=0,l=0;if(s)for(var h=n.child;h!==null;)a|=h.lanes|h.childLanes,l|=h.subtreeFlags&65011712,l|=h.flags&65011712,h.return=n,h=h.sibling;else for(h=n.child;h!==null;)a|=h.lanes|h.childLanes,l|=h.subtreeFlags,l|=h.flags,h.return=n,h=h.sibling;return n.subtreeFlags|=l,n.childLanes=a,s}function e2(n,s,a){var l=s.pendingProps;switch(Op(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return an(s),null;case 1:return an(s),null;case 3:return a=s.stateNode,l=null,n!==null&&(l=n.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),Lr(Pn),Fe(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(n===null||n.child===null)&&(kl(s)?Ir(s):n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,jp())),an(s),null;case 26:var h=s.type,m=s.memoizedState;return n===null?(Ir(s),m!==null?(an(s),IS(s,m)):(an(s),Tm(s,h,null,l,a))):m?m!==n.memoizedState?(Ir(s),an(s),IS(s,m)):(an(s),s.flags&=-16777217):(n=n.memoizedProps,n!==l&&Ir(s),an(s),Tm(s,h,n,l,a)),null;case 27:if(Ve(s),a=ye.current,h=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==l&&Ir(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return an(s),null}n=Z.current,kl(s)?gy(s):(n=K0(h,l,a),s.stateNode=n,Ir(s))}return an(s),null;case 5:if(Ve(s),h=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==l&&Ir(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return an(s),null}if(m=Z.current,kl(s))gy(s);else{var y=bh(ye.current);switch(m){case 1:m=y.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:m=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":m=y.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":m=y.createElementNS("http://www.w3.org/1998/Math/MathML",h);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(h,{is:l.is}):y.createElement(h)}}m[sn]=s,m[Zn]=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(fi(m,h,l),h){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Ir(s)}}return an(s),Tm(s,s.type,n===null?null:n.memoizedProps,s.pendingProps,a),null;case 6:if(n&&s.stateNode!=null)n.memoizedProps!==l&&Ir(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(n=ye.current,kl(s)){if(n=s.stateNode,a=s.memoizedProps,l=null,h=ui,h!==null)switch(h.tag){case 27:case 5:l=h.memoizedProps}n[sn]=s,n=!!(n.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||L0(n.nodeValue,a)),n||_a(s,!0)}else n=bh(n).createTextNode(l),n[sn]=s,s.stateNode=n}return an(s),null;case 31:if(a=s.memoizedState,n===null||n.memoizedState!==null){if(l=kl(s),a!==null){if(n===null){if(!l)throw Error(r(318));if(n=s.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(557));n[sn]=s}else Mo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;an(s),n=!1}else a=jp(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=a),n=!0;if(!n)return s.flags&256?(Qi(s),s):(Qi(s),null);if((s.flags&128)!==0)throw Error(r(558))}return an(s),null;case 13:if(l=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(h=kl(s),l!==null&&l.dehydrated!==null){if(n===null){if(!h)throw Error(r(318));if(h=s.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));h[sn]=s}else Mo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;an(s),h=!1}else h=jp(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=h),h=!0;if(!h)return s.flags&256?(Qi(s),s):(Qi(s),null)}return Qi(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,n=n!==null&&n.memoizedState!==null,a&&(l=s.child,h=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(h=l.alternate.memoizedState.cachePool.pool),m=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),m!==h&&(l.flags|=2048)),a!==n&&a&&(s.child.flags|=8192),sh(s,s.updateQueue),an(s),null);case 4:return Fe(),n===null&&Ym(s.stateNode.containerInfo),an(s),null;case 10:return Lr(s.type),an(s),null;case 19:if(V(Mn),l=s.memoizedState,l===null)return an(s),null;if(h=(s.flags&128)!==0,m=l.rendering,m===null)if(h)Gc(l,!1);else{if(yn!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(m=Wd(n),m!==null){for(s.flags|=128,Gc(l,!1),n=m.updateQueue,s.updateQueue=n,sh(s,n),s.subtreeFlags=0,n=a,a=s.child;a!==null;)dy(a,n),a=a.sibling;return de(Mn,Mn.current&1|2),Rt&&Mr(s,l.treeForkCount),s.child}n=n.sibling}l.tail!==null&&Ae()>ch&&(s.flags|=128,h=!0,Gc(l,!1),s.lanes=4194304)}else{if(!h)if(n=Wd(m),n!==null){if(s.flags|=128,h=!0,n=n.updateQueue,s.updateQueue=n,sh(s,n),Gc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!m.alternate&&!Rt)return an(s),null}else 2*Ae()-l.renderingStartTime>ch&&a!==536870912&&(s.flags|=128,h=!0,Gc(l,!1),s.lanes=4194304);l.isBackwards?(m.sibling=s.child,s.child=m):(n=l.last,n!==null?n.sibling=m:s.child=m,l.last=m)}return l.tail!==null?(n=l.tail,l.rendering=n,l.tail=n.sibling,l.renderingStartTime=Ae(),n.sibling=null,a=Mn.current,de(Mn,h?a&1|2:a&1),Rt&&Mr(s,l.treeForkCount),n):(an(s),null);case 22:case 23:return Qi(s),Xp(),l=s.memoizedState!==null,n!==null?n.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(an(s),s.subtreeFlags&6&&(s.flags|=8192)):an(s),a=s.updateQueue,a!==null&&sh(s,a.retryQueue),a=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(a=n.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),n!==null&&V(Oo),null;case 24:return a=null,n!==null&&(a=n.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),Lr(Pn),an(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function t2(n,s){switch(Op(s),s.tag){case 1:return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return Lr(Pn),Fe(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 26:case 27:case 5:return Ve(s),null;case 31:if(s.memoizedState!==null){if(Qi(s),s.alternate===null)throw Error(r(340));Mo()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 13:if(Qi(s),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(r(340));Mo()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return V(Mn),null;case 4:return Fe(),null;case 10:return Lr(s.type),null;case 22:case 23:return Qi(s),Xp(),n!==null&&V(Oo),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 24:return Lr(Pn),null;case 25:return null;default:return null}}function PS(n,s){switch(Op(s),s.tag){case 3:Lr(Pn),Fe();break;case 26:case 27:case 5:Ve(s);break;case 4:Fe();break;case 31:s.memoizedState!==null&&Qi(s);break;case 13:Qi(s);break;case 19:V(Mn);break;case 10:Lr(s.type);break;case 22:case 23:Qi(s),Xp(),n!==null&&V(Oo);break;case 24:Lr(Pn)}}function Zc(n,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var h=l.next;a=h;do{if((a.tag&n)===n){l=void 0;var m=a.create,y=a.inst;l=m(),y.destroy=l}a=a.next}while(a!==h)}}catch(E){qt(s,s.return,E)}}function ka(n,s,a){try{var l=s.updateQueue,h=l!==null?l.lastEffect:null;if(h!==null){var m=h.next;l=m;do{if((l.tag&n)===n){var y=l.inst,E=y.destroy;if(E!==void 0){y.destroy=void 0,h=s;var I=a,re=E;try{re()}catch(be){qt(h,I,be)}}}l=l.next}while(l!==m)}}catch(be){qt(s,s.return,be)}}function zS(n){var s=n.updateQueue;if(s!==null){var a=n.stateNode;try{Ry(s,a)}catch(l){qt(n,n.return,l)}}}function HS(n,s,a){a.props=zo(n.type,n.memoizedProps),a.state=n.memoizedState;try{a.componentWillUnmount()}catch(l){qt(n,s,l)}}function Qc(n,s){try{var a=n.ref;if(a!==null){switch(n.tag){case 26:case 27:case 5:var l=n.stateNode;break;case 30:l=n.stateNode;break;default:l=n.stateNode}typeof a=="function"?n.refCleanup=a(l):a.current=l}}catch(h){qt(n,s,h)}}function cr(n,s){var a=n.ref,l=n.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(h){qt(n,s,h)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(h){qt(n,s,h)}else a.current=null}function US(n){var s=n.type,a=n.memoizedProps,l=n.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(h){qt(n,n.return,h)}}function Em(n,s,a){try{var l=n.stateNode;x2(l,n.type,a,s),l[Zn]=s}catch(h){qt(n,n.return,h)}}function $S(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Aa(n.type)||n.tag===4}function Dm(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||$S(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Aa(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Rm(n,s,a){var l=n.tag;if(l===5||l===6)n=n.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(n,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(n),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=_i));else if(l!==4&&(l===27&&Aa(n.type)&&(a=n.stateNode,s=null),n=n.child,n!==null))for(Rm(n,s,a),n=n.sibling;n!==null;)Rm(n,s,a),n=n.sibling}function rh(n,s,a){var l=n.tag;if(l===5||l===6)n=n.stateNode,s?a.insertBefore(n,s):a.appendChild(n);else if(l!==4&&(l===27&&Aa(n.type)&&(a=n.stateNode),n=n.child,n!==null))for(rh(n,s,a),n=n.sibling;n!==null;)rh(n,s,a),n=n.sibling}function FS(n){var s=n.stateNode,a=n.memoizedProps;try{for(var l=n.type,h=s.attributes;h.length;)s.removeAttributeNode(h[0]);fi(s,l,a),s[sn]=n,s[Zn]=a}catch(m){qt(n,n.return,m)}}var Pr=!1,Un=!1,Nm=!1,KS=typeof WeakSet=="function"?WeakSet:Set,ei=null;function n2(n,s){if(n=n.containerInfo,Zm=Th,n=Bc(n),_s(n)){if("selectionStart"in n)var a={start:n.selectionStart,end:n.selectionEnd};else e:{a=(a=n.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var h=l.anchorOffset,m=l.focusNode;l=l.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var y=0,E=-1,I=-1,re=0,be=0,Ce=n,ue=null;t:for(;;){for(var me;Ce!==a||h!==0&&Ce.nodeType!==3||(E=y+h),Ce!==m||l!==0&&Ce.nodeType!==3||(I=y+l),Ce.nodeType===3&&(y+=Ce.nodeValue.length),(me=Ce.firstChild)!==null;)ue=Ce,Ce=me;for(;;){if(Ce===n)break t;if(ue===a&&++re===h&&(E=y),ue===m&&++be===l&&(I=y),(me=Ce.nextSibling)!==null)break;Ce=ue,ue=Ce.parentNode}Ce=me}a=E===-1||I===-1?null:{start:E,end:I}}else a=null}a=a||{start:0,end:0}}else a=null;for(Qm={focusedElem:n,selectionRange:a},Th=!1,ei=s;ei!==null;)if(s=ei,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,ei=n;else for(;ei!==null;){switch(s=ei,m=s.alternate,n=s.flags,s.tag){case 0:if((n&4)!==0&&(n=s.updateQueue,n=n!==null?n.events:null,n!==null))for(a=0;a<n.length;a++)h=n[a],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&m!==null){n=void 0,a=s,h=m.memoizedProps,m=m.memoizedState,l=a.stateNode;try{var Ke=zo(a.type,h);n=l.getSnapshotBeforeUpdate(Ke,m),l.__reactInternalSnapshotBeforeUpdate=n}catch(st){qt(a,a.return,st)}}break;case 3:if((n&1024)!==0){if(n=s.stateNode.containerInfo,a=n.nodeType,a===9)tg(n);else if(a===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":tg(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(r(163))}if(n=s.sibling,n!==null){n.return=s.return,ei=n;break}ei=s.return}}function WS(n,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Hr(n,a),l&4&&Zc(5,a);break;case 1:if(Hr(n,a),l&4)if(n=a.stateNode,s===null)try{n.componentDidMount()}catch(y){qt(a,a.return,y)}else{var h=zo(a.type,s.memoizedProps);s=s.memoizedState;try{n.componentDidUpdate(h,s,n.__reactInternalSnapshotBeforeUpdate)}catch(y){qt(a,a.return,y)}}l&64&&zS(a),l&512&&Qc(a,a.return);break;case 3:if(Hr(n,a),l&64&&(n=a.updateQueue,n!==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{Ry(n,s)}catch(y){qt(a,a.return,y)}}break;case 27:s===null&&l&4&&FS(a);case 26:case 5:Hr(n,a),s===null&&l&4&&US(a),l&512&&Qc(a,a.return);break;case 12:Hr(n,a);break;case 31:Hr(n,a),l&4&&YS(n,a);break;case 13:Hr(n,a),l&4&&XS(n,a),l&64&&(n=a.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(a=d2.bind(null,a),M2(n,a))));break;case 22:if(l=a.memoizedState!==null||Pr,!l){s=s!==null&&s.memoizedState!==null||Un,h=Pr;var m=Un;Pr=l,(Un=s)&&!m?Ur(n,a,(a.subtreeFlags&8772)!==0):Hr(n,a),Pr=h,Un=m}break;case 30:break;default:Hr(n,a)}}function qS(n){var s=n.alternate;s!==null&&(n.alternate=null,qS(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&cs(s)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var cn=null,Pi=!1;function zr(n,s,a){for(a=a.child;a!==null;)VS(n,s,a),a=a.sibling}function VS(n,s,a){if(kt&&typeof kt.onCommitFiberUnmount=="function")try{kt.onCommitFiberUnmount(Ut,a)}catch{}switch(a.tag){case 26:Un||cr(a,s),zr(n,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Un||cr(a,s);var l=cn,h=Pi;Aa(a.type)&&(cn=a.stateNode,Pi=!1),zr(n,s,a),ou(a.stateNode),cn=l,Pi=h;break;case 5:Un||cr(a,s);case 6:if(l=cn,h=Pi,cn=null,zr(n,s,a),cn=l,Pi=h,cn!==null)if(Pi)try{(cn.nodeType===9?cn.body:cn.nodeName==="HTML"?cn.ownerDocument.body:cn).removeChild(a.stateNode)}catch(m){qt(a,s,m)}else try{cn.removeChild(a.stateNode)}catch(m){qt(a,s,m)}break;case 18:cn!==null&&(Pi?(n=cn,z0(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,a.stateNode),ql(n)):z0(cn,a.stateNode));break;case 4:l=cn,h=Pi,cn=a.stateNode.containerInfo,Pi=!0,zr(n,s,a),cn=l,Pi=h;break;case 0:case 11:case 14:case 15:ka(2,a,s),Un||ka(4,a,s),zr(n,s,a);break;case 1:Un||(cr(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&HS(a,s,l)),zr(n,s,a);break;case 21:zr(n,s,a);break;case 22:Un=(l=Un)||a.memoizedState!==null,zr(n,s,a),Un=l;break;default:zr(n,s,a)}}function YS(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{ql(n)}catch(a){qt(s,s.return,a)}}}function XS(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{ql(n)}catch(a){qt(s,s.return,a)}}function i2(n){switch(n.tag){case 31:case 13:case 19:var s=n.stateNode;return s===null&&(s=n.stateNode=new KS),s;case 22:return n=n.stateNode,s=n._retryCache,s===null&&(s=n._retryCache=new KS),s;default:throw Error(r(435,n.tag))}}function ah(n,s){var a=i2(n);s.forEach(function(l){if(!a.has(l)){a.add(l);var h=h2.bind(null,n,l);l.then(h,h)}})}function zi(n,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var h=a[l],m=n,y=s,E=y;e:for(;E!==null;){switch(E.tag){case 27:if(Aa(E.type)){cn=E.stateNode,Pi=!1;break e}break;case 5:cn=E.stateNode,Pi=!1;break e;case 3:case 4:cn=E.stateNode.containerInfo,Pi=!0;break e}E=E.return}if(cn===null)throw Error(r(160));VS(m,y,h),cn=null,Pi=!1,m=h.alternate,m!==null&&(m.return=null),h.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)GS(s,n),s=s.sibling}var Us=null;function GS(n,s){var a=n.alternate,l=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:zi(s,n),Hi(n),l&4&&(ka(3,n,n.return),Zc(3,n),ka(5,n,n.return));break;case 1:zi(s,n),Hi(n),l&512&&(Un||a===null||cr(a,a.return)),l&64&&Pr&&(n=n.updateQueue,n!==null&&(l=n.callbacks,l!==null&&(a=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var h=Us;if(zi(s,n),Hi(n),l&512&&(Un||a===null||cr(a,a.return)),l&4){var m=a!==null?a.memoizedState:null;if(l=n.memoizedState,a===null)if(l===null)if(n.stateNode===null){e:{l=n.type,a=n.memoizedProps,h=h.ownerDocument||h;t:switch(l){case"title":m=h.getElementsByTagName("title")[0],(!m||m[oi]||m[sn]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=h.createElement(l),h.head.insertBefore(m,h.querySelector("head > title"))),fi(m,l,a),m[sn]=n,fn(m),l=m;break e;case"link":var y=G0("link","href",h).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=h.createElement(l),fi(m,l,a),h.head.appendChild(m);break;case"meta":if(y=G0("meta","content",h).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=h.createElement(l),fi(m,l,a),h.head.appendChild(m);break;default:throw Error(r(468,l))}m[sn]=n,fn(m),l=m}n.stateNode=l}else Z0(h,n.type,n.stateNode);else n.stateNode=X0(h,l,n.memoizedProps);else m!==l?(m===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):m.count--,l===null?Z0(h,n.type,n.stateNode):X0(h,l,n.memoizedProps)):l===null&&n.stateNode!==null&&Em(n,n.memoizedProps,a.memoizedProps)}break;case 27:zi(s,n),Hi(n),l&512&&(Un||a===null||cr(a,a.return)),a!==null&&l&4&&Em(n,n.memoizedProps,a.memoizedProps);break;case 5:if(zi(s,n),Hi(n),l&512&&(Un||a===null||cr(a,a.return)),n.flags&32){h=n.stateNode;try{fs(h,"")}catch(Ke){qt(n,n.return,Ke)}}l&4&&n.stateNode!=null&&(h=n.memoizedProps,Em(n,h,a!==null?a.memoizedProps:h)),l&1024&&(Nm=!0);break;case 6:if(zi(s,n),Hi(n),l&4){if(n.stateNode===null)throw Error(r(162));l=n.memoizedProps,a=n.stateNode;try{a.nodeValue=l}catch(Ke){qt(n,n.return,Ke)}}break;case 3:if(wh=null,h=Us,Us=yh(s.containerInfo),zi(s,n),Us=h,Hi(n),l&4&&a!==null&&a.memoizedState.isDehydrated)try{ql(s.containerInfo)}catch(Ke){qt(n,n.return,Ke)}Nm&&(Nm=!1,ZS(n));break;case 4:l=Us,Us=yh(n.stateNode.containerInfo),zi(s,n),Hi(n),Us=l;break;case 12:zi(s,n),Hi(n);break;case 31:zi(s,n),Hi(n),l&4&&(l=n.updateQueue,l!==null&&(n.updateQueue=null,ah(n,l)));break;case 13:zi(s,n),Hi(n),n.child.flags&8192&&n.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(lh=Ae()),l&4&&(l=n.updateQueue,l!==null&&(n.updateQueue=null,ah(n,l)));break;case 22:h=n.memoizedState!==null;var I=a!==null&&a.memoizedState!==null,re=Pr,be=Un;if(Pr=re||h,Un=be||I,zi(s,n),Un=be,Pr=re,Hi(n),l&8192)e:for(s=n.stateNode,s._visibility=h?s._visibility&-2:s._visibility|1,h&&(a===null||I||Pr||Un||Ho(n)),a=null,s=n;;){if(s.tag===5||s.tag===26){if(a===null){I=a=s;try{if(m=I.stateNode,h)y=m.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{E=I.stateNode;var Ce=I.memoizedProps.style,ue=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;E.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ke){qt(I,I.return,Ke)}}}else if(s.tag===6){if(a===null){I=s;try{I.stateNode.nodeValue=h?"":I.memoizedProps}catch(Ke){qt(I,I.return,Ke)}}}else if(s.tag===18){if(a===null){I=s;try{var me=I.stateNode;h?H0(me,!0):H0(I.stateNode,!1)}catch(Ke){qt(I,I.return,Ke)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===n)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break e;for(;s.sibling===null;){if(s.return===null||s.return===n)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=n.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,ah(n,a))));break;case 19:zi(s,n),Hi(n),l&4&&(l=n.updateQueue,l!==null&&(n.updateQueue=null,ah(n,l)));break;case 30:break;case 21:break;default:zi(s,n),Hi(n)}}function Hi(n){var s=n.flags;if(s&2){try{for(var a,l=n.return;l!==null;){if($S(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var h=a.stateNode,m=Dm(n);rh(n,m,h);break;case 5:var y=a.stateNode;a.flags&32&&(fs(y,""),a.flags&=-33);var E=Dm(n);rh(n,E,y);break;case 3:case 4:var I=a.stateNode.containerInfo,re=Dm(n);Rm(n,re,I);break;default:throw Error(r(161))}}catch(be){qt(n,n.return,be)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function ZS(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var s=n;ZS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),n=n.sibling}}function Hr(n,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)WS(n,s.alternate,s),s=s.sibling}function Ho(n){for(n=n.child;n!==null;){var s=n;switch(s.tag){case 0:case 11:case 14:case 15:ka(4,s,s.return),Ho(s);break;case 1:cr(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&HS(s,s.return,a),Ho(s);break;case 27:ou(s.stateNode);case 26:case 5:cr(s,s.return),Ho(s);break;case 22:s.memoizedState===null&&Ho(s);break;case 30:Ho(s);break;default:Ho(s)}n=n.sibling}}function Ur(n,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,h=n,m=s,y=m.flags;switch(m.tag){case 0:case 11:case 15:Ur(h,m,a),Zc(4,m);break;case 1:if(Ur(h,m,a),l=m,h=l.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(re){qt(l,l.return,re)}if(l=m,h=l.updateQueue,h!==null){var E=l.stateNode;try{var I=h.shared.hiddenCallbacks;if(I!==null)for(h.shared.hiddenCallbacks=null,h=0;h<I.length;h++)Dy(I[h],E)}catch(re){qt(l,l.return,re)}}a&&y&64&&zS(m),Qc(m,m.return);break;case 27:FS(m);case 26:case 5:Ur(h,m,a),a&&l===null&&y&4&&US(m),Qc(m,m.return);break;case 12:Ur(h,m,a);break;case 31:Ur(h,m,a),a&&y&4&&YS(h,m);break;case 13:Ur(h,m,a),a&&y&4&&XS(h,m);break;case 22:m.memoizedState===null&&Ur(h,m,a),Qc(m,m.return);break;case 30:break;default:Ur(h,m,a)}s=s.sibling}}function Mm(n,s){var a=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(a=n.memoizedState.cachePool.pool),n=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(n=s.memoizedState.cachePool.pool),n!==a&&(n!=null&&n.refCount++,a!=null&&Pc(a))}function Am(n,s){n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&Pc(n))}function $s(n,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)QS(n,s,a,l),s=s.sibling}function QS(n,s,a,l){var h=s.flags;switch(s.tag){case 0:case 11:case 15:$s(n,s,a,l),h&2048&&Zc(9,s);break;case 1:$s(n,s,a,l);break;case 3:$s(n,s,a,l),h&2048&&(n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&Pc(n)));break;case 12:if(h&2048){$s(n,s,a,l),n=s.stateNode;try{var m=s.memoizedProps,y=m.id,E=m.onPostCommit;typeof E=="function"&&E(y,s.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(I){qt(s,s.return,I)}}else $s(n,s,a,l);break;case 31:$s(n,s,a,l);break;case 13:$s(n,s,a,l);break;case 23:break;case 22:m=s.stateNode,y=s.alternate,s.memoizedState!==null?m._visibility&2?$s(n,s,a,l):Jc(n,s):m._visibility&2?$s(n,s,a,l):(m._visibility|=2,Bl(n,s,a,l,(s.subtreeFlags&10256)!==0||!1)),h&2048&&Mm(y,s);break;case 24:$s(n,s,a,l),h&2048&&Am(s.alternate,s);break;default:$s(n,s,a,l)}}function Bl(n,s,a,l,h){for(h=h&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var m=n,y=s,E=a,I=l,re=y.flags;switch(y.tag){case 0:case 11:case 15:Bl(m,y,E,I,h),Zc(8,y);break;case 23:break;case 22:var be=y.stateNode;y.memoizedState!==null?be._visibility&2?Bl(m,y,E,I,h):Jc(m,y):(be._visibility|=2,Bl(m,y,E,I,h)),h&&re&2048&&Mm(y.alternate,y);break;case 24:Bl(m,y,E,I,h),h&&re&2048&&Am(y.alternate,y);break;default:Bl(m,y,E,I,h)}s=s.sibling}}function Jc(n,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=n,l=s,h=l.flags;switch(l.tag){case 22:Jc(a,l),h&2048&&Mm(l.alternate,l);break;case 24:Jc(a,l),h&2048&&Am(l.alternate,l);break;default:Jc(a,l)}s=s.sibling}}var eu=8192;function jl(n,s,a){if(n.subtreeFlags&eu)for(n=n.child;n!==null;)JS(n,s,a),n=n.sibling}function JS(n,s,a){switch(n.tag){case 26:jl(n,s,a),n.flags&eu&&n.memoizedState!==null&&F2(a,Us,n.memoizedState,n.memoizedProps);break;case 5:jl(n,s,a);break;case 3:case 4:var l=Us;Us=yh(n.stateNode.containerInfo),jl(n,s,a),Us=l;break;case 22:n.memoizedState===null&&(l=n.alternate,l!==null&&l.memoizedState!==null?(l=eu,eu=16777216,jl(n,s,a),eu=l):jl(n,s,a));break;default:jl(n,s,a)}}function e0(n){var s=n.alternate;if(s!==null&&(n=s.child,n!==null)){s.child=null;do s=n.sibling,n.sibling=null,n=s;while(n!==null)}}function tu(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];ei=l,n0(l,n)}e0(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)t0(n),n=n.sibling}function t0(n){switch(n.tag){case 0:case 11:case 15:tu(n),n.flags&2048&&ka(9,n,n.return);break;case 3:tu(n);break;case 12:tu(n);break;case 22:var s=n.stateNode;n.memoizedState!==null&&s._visibility&2&&(n.return===null||n.return.tag!==13)?(s._visibility&=-3,oh(n)):tu(n);break;default:tu(n)}}function oh(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];ei=l,n0(l,n)}e0(n)}for(n=n.child;n!==null;){switch(s=n,s.tag){case 0:case 11:case 15:ka(8,s,s.return),oh(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,oh(s));break;default:oh(s)}n=n.sibling}}function n0(n,s){for(;ei!==null;){var a=ei;switch(a.tag){case 0:case 11:case 15:ka(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:Pc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,ei=l;else e:for(a=n;ei!==null;){l=ei;var h=l.sibling,m=l.return;if(qS(l),l===a){ei=null;break e}if(h!==null){h.return=m,ei=h;break e}ei=m}}}var s2={getCacheForType:function(n){var s=di(Pn),a=s.data.get(n);return a===void 0&&(a=n(),s.data.set(n,a)),a},cacheSignal:function(){return di(Pn).controller.signal}},r2=typeof WeakMap=="function"?WeakMap:Map,Pt=0,Jt=null,xt=null,Tt=0,Wt=0,Ji=null,Ta=!1,Il=!1,Lm=!1,$r=0,yn=0,Ea=0,Uo=0,Om=0,es=0,Pl=0,nu=null,Ui=null,Bm=!1,lh=0,i0=0,ch=1/0,uh=null,Da=null,Kn=0,Ra=null,zl=null,Fr=0,jm=0,Im=null,s0=null,iu=0,Pm=null;function ts(){return(Pt&2)!==0&&Tt!==0?Tt&-Tt:O.T!==null?Km():Bn()}function r0(){if(es===0)if((Tt&536870912)===0||Rt){var n=it;it<<=1,(it&3932160)===0&&(it=262144),es=n}else es=536870912;return n=Zi.current,n!==null&&(n.flags|=32),es}function $i(n,s,a){(n===Jt&&(Wt===2||Wt===9)||n.cancelPendingCommit!==null)&&(Hl(n,0),Na(n,Tt,es,!1)),Ie(n,a),((Pt&2)===0||n!==Jt)&&(n===Jt&&((Pt&2)===0&&(Uo|=a),yn===4&&Na(n,Tt,es,!1)),ur(n))}function a0(n,s,a){if((Pt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&n.expiredLanes)===0||hn(n,s),h=l?l2(n,s):Hm(n,s,!0),m=l;do{if(h===0){Il&&!l&&Na(n,s,0,!1);break}else{if(a=n.current.alternate,m&&!a2(a)){h=Hm(n,s,!1),m=!1;continue}if(h===2){if(m=s,n.errorRecoveryDisabledLanes&m)var y=0;else y=n.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){s=y;e:{var E=n;h=nu;var I=E.current.memoizedState.isDehydrated;if(I&&(Hl(E,y).flags|=256),y=Hm(E,y,!1),y!==2){if(Lm&&!I){E.errorRecoveryDisabledLanes|=m,Uo|=m,h=4;break e}m=Ui,Ui=h,m!==null&&(Ui===null?Ui=m:Ui.push.apply(Ui,m))}h=y}if(m=!1,h!==2)continue}}if(h===1){Hl(n,0),Na(n,s,0,!0);break}e:{switch(l=n,m=h,m){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:Na(l,s,es,!Ta);break e;case 2:Ui=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(h=lh+300-Ae(),10<h)){if(Na(l,s,es,!Ta),jt(l,0,!0)!==0)break e;Fr=s,l.timeoutHandle=I0(o0.bind(null,l,a,Ui,uh,Bm,s,es,Uo,Pl,Ta,m,"Throttled",-0,0),h);break e}o0(l,a,Ui,uh,Bm,s,es,Uo,Pl,Ta,m,null,-0,0)}}break}while(!0);ur(n)}function o0(n,s,a,l,h,m,y,E,I,re,be,Ce,ue,me){if(n.timeoutHandle=-1,Ce=s.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_i},JS(s,m,Ce);var Ke=(m&62914560)===m?lh-Ae():(m&4194048)===m?i0-Ae():0;if(Ke=K2(Ce,Ke),Ke!==null){Fr=m,n.cancelPendingCommit=Ke(m0.bind(null,n,s,m,a,l,h,y,E,I,be,Ce,null,ue,me)),Na(n,m,y,!re);return}}m0(n,s,m,a,l,h,y,E,I)}function a2(n){for(var s=n;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var h=a[l],m=h.getSnapshot;h=h.value;try{if(!ki(m(),h))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Na(n,s,a,l){s&=~Om,s&=~Uo,n.suspendedLanes|=s,n.pingedLanes&=~s,l&&(n.warmLanes|=s),l=n.expirationTimes;for(var h=s;0<h;){var m=31-At(h),y=1<<m;l[m]=-1,h&=~y}a!==0&&Je(n,a,s)}function dh(){return(Pt&6)===0?(su(0),!1):!0}function zm(){if(xt!==null){if(Wt===0)var n=xt.return;else n=xt,Ar=Ao=null,tm(n),Nl=null,Hc=0,n=xt;for(;n!==null;)PS(n.alternate,n),n=n.return;xt=null}}function Hl(n,s){var a=n.timeoutHandle;a!==-1&&(n.timeoutHandle=-1,T2(a)),a=n.cancelPendingCommit,a!==null&&(n.cancelPendingCommit=null,a()),Fr=0,zm(),Jt=n,xt=a=Nr(n.current,null),Tt=s,Wt=0,Ji=null,Ta=!1,Il=hn(n,s),Lm=!1,Pl=es=Om=Uo=Ea=yn=0,Ui=nu=null,Bm=!1,(s&8)!==0&&(s|=s&32);var l=n.entangledLanes;if(l!==0)for(n=n.entanglements,l&=s;0<l;){var h=31-At(l),m=1<<h;s|=n[h],l&=~m}return $r=s,Ad(),a}function l0(n,s){ft=null,O.H=Yc,s===Rl||s===Hd?(s=Cy(),Wt=3):s===Fp?(s=Cy(),Wt=4):Wt=s===vm?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Ji=s,xt===null&&(yn=1,eh(n,Ss(s,n.current)))}function c0(){var n=Zi.current;return n===null?!0:(Tt&4194048)===Tt?ks===null:(Tt&62914560)===Tt||(Tt&536870912)!==0?n===ks:!1}function u0(){var n=O.H;return O.H=Yc,n===null?Yc:n}function d0(){var n=O.A;return O.A=s2,n}function hh(){yn=4,Ta||(Tt&4194048)!==Tt&&Zi.current!==null||(Il=!0),(Ea&134217727)===0&&(Uo&134217727)===0||Jt===null||Na(Jt,Tt,es,!1)}function Hm(n,s,a){var l=Pt;Pt|=2;var h=u0(),m=d0();(Jt!==n||Tt!==s)&&(uh=null,Hl(n,s)),s=!1;var y=yn;e:do try{if(Wt!==0&&xt!==null){var E=xt,I=Ji;switch(Wt){case 8:zm(),y=6;break e;case 3:case 2:case 9:case 6:Zi.current===null&&(s=!0);var re=Wt;if(Wt=0,Ji=null,Ul(n,E,I,re),a&&Il){y=0;break e}break;default:re=Wt,Wt=0,Ji=null,Ul(n,E,I,re)}}o2(),y=yn;break}catch(be){l0(n,be)}while(!0);return s&&n.shellSuspendCounter++,Ar=Ao=null,Pt=l,O.H=h,O.A=m,xt===null&&(Jt=null,Tt=0,Ad()),y}function o2(){for(;xt!==null;)h0(xt)}function l2(n,s){var a=Pt;Pt|=2;var l=u0(),h=d0();Jt!==n||Tt!==s?(uh=null,ch=Ae()+500,Hl(n,s)):Il=hn(n,s);e:do try{if(Wt!==0&&xt!==null){s=xt;var m=Ji;t:switch(Wt){case 1:Wt=0,Ji=null,Ul(n,s,m,1);break;case 2:case 9:if(wy(m)){Wt=0,Ji=null,f0(s);break}s=function(){Wt!==2&&Wt!==9||Jt!==n||(Wt=7),ur(n)},m.then(s,s);break e;case 3:Wt=7;break e;case 4:Wt=5;break e;case 7:wy(m)?(Wt=0,Ji=null,f0(s)):(Wt=0,Ji=null,Ul(n,s,m,7));break;case 5:var y=null;switch(xt.tag){case 26:y=xt.memoizedState;case 5:case 27:var E=xt;if(y?Q0(y):E.stateNode.complete){Wt=0,Ji=null;var I=E.sibling;if(I!==null)xt=I;else{var re=E.return;re!==null?(xt=re,fh(re)):xt=null}break t}}Wt=0,Ji=null,Ul(n,s,m,5);break;case 6:Wt=0,Ji=null,Ul(n,s,m,6);break;case 8:zm(),yn=6;break e;default:throw Error(r(462))}}c2();break}catch(be){l0(n,be)}while(!0);return Ar=Ao=null,O.H=l,O.A=h,Pt=a,xt!==null?0:(Jt=null,Tt=0,Ad(),yn)}function c2(){for(;xt!==null&&!je();)h0(xt)}function h0(n){var s=jS(n.alternate,n,$r);n.memoizedProps=n.pendingProps,s===null?fh(n):xt=s}function f0(n){var s=n,a=s.alternate;switch(s.tag){case 15:case 0:s=NS(a,s,s.pendingProps,s.type,void 0,Tt);break;case 11:s=NS(a,s,s.pendingProps,s.type.render,s.ref,Tt);break;case 5:tm(s);default:PS(a,s),s=xt=dy(s,$r),s=jS(a,s,$r)}n.memoizedProps=n.pendingProps,s===null?fh(n):xt=s}function Ul(n,s,a,l){Ar=Ao=null,tm(s),Nl=null,Hc=0;var h=s.return;try{if(ZE(n,h,s,a,Tt)){yn=1,eh(n,Ss(a,n.current)),xt=null;return}}catch(m){if(h!==null)throw xt=h,m;yn=1,eh(n,Ss(a,n.current)),xt=null;return}s.flags&32768?(Rt||l===1?n=!0:Il||(Tt&536870912)!==0?n=!1:(Ta=n=!0,(l===2||l===9||l===3||l===6)&&(l=Zi.current,l!==null&&l.tag===13&&(l.flags|=16384))),p0(s,n)):fh(s)}function fh(n){var s=n;do{if((s.flags&32768)!==0){p0(s,Ta);return}n=s.return;var a=e2(s.alternate,s,$r);if(a!==null){xt=a;return}if(s=s.sibling,s!==null){xt=s;return}xt=s=n}while(s!==null);yn===0&&(yn=5)}function p0(n,s){do{var a=t2(n.alternate,n);if(a!==null){a.flags&=32767,xt=a;return}if(a=n.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(n=n.sibling,n!==null)){xt=n;return}xt=n=a}while(n!==null);yn=6,xt=null}function m0(n,s,a,l,h,m,y,E,I){n.cancelPendingCommit=null;do ph();while(Kn!==0);if((Pt&6)!==0)throw Error(r(327));if(s!==null){if(s===n.current)throw Error(r(177));if(m=s.lanes|s.childLanes,m|=Dp,We(n,a,m,y,E,I),n===Jt&&(xt=Jt=null,Tt=0),zl=s,Ra=n,Fr=a,jm=m,Im=h,s0=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,f2(ot,function(){return y0(),null})):(n.callbackNode=null,n.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=O.T,O.T=null,h=R.p,R.p=2,y=Pt,Pt|=4;try{n2(n,s,a)}finally{Pt=y,R.p=h,O.T=l}}Kn=1,g0(),v0(),_0()}}function g0(){if(Kn===1){Kn=0;var n=Ra,s=zl,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var l=R.p;R.p=2;var h=Pt;Pt|=4;try{GS(s,n);var m=Qm,y=Bc(n.containerInfo),E=m.focusedElem,I=m.selectionRange;if(y!==E&&E&&E.ownerDocument&&Md(E.ownerDocument.documentElement,E)){if(I!==null&&_s(E)){var re=I.start,be=I.end;if(be===void 0&&(be=re),"selectionStart"in E)E.selectionStart=re,E.selectionEnd=Math.min(be,E.value.length);else{var Ce=E.ownerDocument||document,ue=Ce&&Ce.defaultView||window;if(ue.getSelection){var me=ue.getSelection(),Ke=E.textContent.length,st=Math.min(I.start,Ke),Zt=I.end===void 0?st:Math.min(I.end,Ke);!me.extend&&st>Zt&&(y=Zt,Zt=st,st=y);var G=Nd(E,st),W=Nd(E,Zt);if(G&&W&&(me.rangeCount!==1||me.anchorNode!==G.node||me.anchorOffset!==G.offset||me.focusNode!==W.node||me.focusOffset!==W.offset)){var se=Ce.createRange();se.setStart(G.node,G.offset),me.removeAllRanges(),st>Zt?(me.addRange(se),me.extend(W.node,W.offset)):(se.setEnd(W.node,W.offset),me.addRange(se))}}}}for(Ce=[],me=E;me=me.parentNode;)me.nodeType===1&&Ce.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<Ce.length;E++){var we=Ce[E];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}Th=!!Zm,Qm=Zm=null}finally{Pt=h,R.p=l,O.T=a}}n.current=s,Kn=2}}function v0(){if(Kn===2){Kn=0;var n=Ra,s=zl,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var l=R.p;R.p=2;var h=Pt;Pt|=4;try{WS(n,s.alternate,s)}finally{Pt=h,R.p=l,O.T=a}}Kn=3}}function _0(){if(Kn===4||Kn===3){Kn=0,Ze();var n=Ra,s=zl,a=Fr,l=s0;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Kn=5:(Kn=0,zl=Ra=null,b0(n,n.pendingLanes));var h=n.pendingLanes;if(h===0&&(Da=null),en(a),s=s.stateNode,kt&&typeof kt.onCommitFiberRoot=="function")try{kt.onCommitFiberRoot(Ut,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=O.T,h=R.p,R.p=2,O.T=null;try{for(var m=n.onRecoverableError,y=0;y<l.length;y++){var E=l[y];m(E.value,{componentStack:E.stack})}}finally{O.T=s,R.p=h}}(Fr&3)!==0&&ph(),ur(n),h=n.pendingLanes,(a&261930)!==0&&(h&42)!==0?n===Pm?iu++:(iu=0,Pm=n):iu=0,su(0)}}function b0(n,s){(n.pooledCacheLanes&=s)===0&&(s=n.pooledCache,s!=null&&(n.pooledCache=null,Pc(s)))}function ph(){return g0(),v0(),_0(),y0()}function y0(){if(Kn!==5)return!1;var n=Ra,s=jm;jm=0;var a=en(Fr),l=O.T,h=R.p;try{R.p=32>a?32:a,O.T=null,a=Im,Im=null;var m=Ra,y=Fr;if(Kn=0,zl=Ra=null,Fr=0,(Pt&6)!==0)throw Error(r(331));var E=Pt;if(Pt|=4,t0(m.current),QS(m,m.current,y,a),Pt=E,su(0,!1),kt&&typeof kt.onPostCommitFiberRoot=="function")try{kt.onPostCommitFiberRoot(Ut,m)}catch{}return!0}finally{R.p=h,O.T=l,b0(n,s)}}function S0(n,s,a){s=Ss(a,s),s=gm(n.stateNode,s,2),n=wa(n,s,2),n!==null&&(Ie(n,2),ur(n))}function qt(n,s,a){if(n.tag===3)S0(n,n,a);else for(;s!==null;){if(s.tag===3){S0(s,n,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(Da===null||!Da.has(l))){n=Ss(a,n),a=wS(2),l=wa(s,a,2),l!==null&&(xS(a,l,s,n),Ie(l,2),ur(l));break}}s=s.return}}function Um(n,s,a){var l=n.pingCache;if(l===null){l=n.pingCache=new r2;var h=new Set;l.set(s,h)}else h=l.get(s),h===void 0&&(h=new Set,l.set(s,h));h.has(a)||(Lm=!0,h.add(a),n=u2.bind(null,n,s,a),s.then(n,n))}function u2(n,s,a){var l=n.pingCache;l!==null&&l.delete(s),n.pingedLanes|=n.suspendedLanes&a,n.warmLanes&=~a,Jt===n&&(Tt&a)===a&&(yn===4||yn===3&&(Tt&62914560)===Tt&&300>Ae()-lh?(Pt&2)===0&&Hl(n,0):Om|=a,Pl===Tt&&(Pl=0)),ur(n)}function w0(n,s){s===0&&(s=_e()),n=Ro(n,s),n!==null&&(Ie(n,s),ur(n))}function d2(n){var s=n.memoizedState,a=0;s!==null&&(a=s.retryLane),w0(n,a)}function h2(n,s){var a=0;switch(n.tag){case 31:case 13:var l=n.stateNode,h=n.memoizedState;h!==null&&(a=h.retryLane);break;case 19:l=n.stateNode;break;case 22:l=n.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),w0(n,a)}function f2(n,s){return Re(n,s)}var mh=null,$l=null,$m=!1,gh=!1,Fm=!1,Ma=0;function ur(n){n!==$l&&n.next===null&&($l===null?mh=$l=n:$l=$l.next=n),gh=!0,$m||($m=!0,m2())}function su(n,s){if(!Fm&&gh){Fm=!0;do for(var a=!1,l=mh;l!==null;){if(n!==0){var h=l.pendingLanes;if(h===0)var m=0;else{var y=l.suspendedLanes,E=l.pingedLanes;m=(1<<31-At(42|n)+1)-1,m&=h&~(y&~E),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(a=!0,T0(l,m))}else m=Tt,m=jt(l,l===Jt?m:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(m&3)===0||hn(l,m)||(a=!0,T0(l,m));l=l.next}while(a);Fm=!1}}function p2(){x0()}function x0(){gh=$m=!1;var n=0;Ma!==0&&k2()&&(n=Ma);for(var s=Ae(),a=null,l=mh;l!==null;){var h=l.next,m=C0(l,s);m===0?(l.next=null,a===null?mh=h:a.next=h,h===null&&($l=a)):(a=l,(n!==0||(m&3)!==0)&&(gh=!0)),l=h}Kn!==0&&Kn!==5||su(n),Ma!==0&&(Ma=0)}function C0(n,s){for(var a=n.suspendedLanes,l=n.pingedLanes,h=n.expirationTimes,m=n.pendingLanes&-62914561;0<m;){var y=31-At(m),E=1<<y,I=h[y];I===-1?((E&a)===0||(E&l)!==0)&&(h[y]=Tn(E,s)):I<=s&&(n.expiredLanes|=E),m&=~E}if(s=Jt,a=Tt,a=jt(n,n===s?a:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),l=n.callbackNode,a===0||n===s&&(Wt===2||Wt===9)||n.cancelPendingCommit!==null)return l!==null&&l!==null&&Te(l),n.callbackNode=null,n.callbackPriority=0;if((a&3)===0||hn(n,a)){if(s=a&-a,s===n.callbackPriority)return s;switch(l!==null&&Te(l),en(a)){case 2:case 8:a=at;break;case 32:a=ot;break;case 268435456:a=ln;break;default:a=ot}return l=k0.bind(null,n),a=Re(a,l),n.callbackPriority=s,n.callbackNode=a,s}return l!==null&&l!==null&&Te(l),n.callbackPriority=2,n.callbackNode=null,2}function k0(n,s){if(Kn!==0&&Kn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var a=n.callbackNode;if(ph()&&n.callbackNode!==a)return null;var l=Tt;return l=jt(n,n===Jt?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),l===0?null:(a0(n,l,s),C0(n,Ae()),n.callbackNode!=null&&n.callbackNode===a?k0.bind(null,n):null)}function T0(n,s){if(ph())return null;a0(n,s,!0)}function m2(){E2(function(){(Pt&6)!==0?Re(bt,p2):x0()})}function Km(){if(Ma===0){var n=El;n===0&&(n=Ge,Ge<<=1,(Ge&261888)===0&&(Ge=256)),Ma=n}return Ma}function E0(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Oi(""+n)}function D0(n,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,n.id&&a.setAttribute("form",n.id),s.parentNode.insertBefore(a,s),n=new FormData(n),a.parentNode.removeChild(a),n}function g2(n,s,a,l,h){if(s==="submit"&&a&&a.stateNode===h){var m=E0((h[Zn]||null).action),y=l.submitter;y&&(s=(s=y[Zn]||null)?E0(s.formAction):y.getAttribute("formAction"),s!==null&&(m=s,y=null));var E=new tr("action","action",null,l,h);n.push({event:E,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Ma!==0){var I=y?D0(h,y):new FormData(h);um(a,{pending:!0,data:I,method:h.method,action:m},null,I)}}else typeof m=="function"&&(E.preventDefault(),I=y?D0(h,y):new FormData(h),um(a,{pending:!0,data:I,method:h.method,action:m},m,I))},currentTarget:h}]})}}for(var Wm=0;Wm<bs.length;Wm++){var qm=bs[Wm],v2=qm.toLowerCase(),_2=qm[0].toUpperCase()+qm.slice(1);Ii(v2,"on"+_2)}Ii(gt,"onAnimationEnd"),Ii(vt,"onAnimationIteration"),Ii(nt,"onAnimationStart"),Ii("dblclick","onDoubleClick"),Ii("focusin","onFocus"),Ii("focusout","onBlur"),Ii(nn,"onTransitionRun"),Ii(Yt,"onTransitionStart"),Ii(Kt,"onTransitionCancel"),Ii(Hs,"onTransitionEnd"),tn("onMouseEnter",["mouseout","mouseover"]),tn("onMouseLeave",["mouseout","mouseover"]),tn("onPointerEnter",["pointerout","pointerover"]),tn("onPointerLeave",["pointerout","pointerover"]),Li("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Li("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Li("onBeforeInput",["compositionend","keypress","textInput","paste"]),Li("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Li("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Li("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ru="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(" "),b2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ru));function R0(n,s){s=(s&4)!==0;for(var a=0;a<n.length;a++){var l=n[a],h=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],I=E.instance,re=E.currentTarget;if(E=E.listener,I!==m&&h.isPropagationStopped())break e;m=E,h.currentTarget=re;try{m(h)}catch(be){Do(be)}h.currentTarget=null,m=I}else for(y=0;y<l.length;y++){if(E=l[y],I=E.instance,re=E.currentTarget,E=E.listener,I!==m&&h.isPropagationStopped())break e;m=E,h.currentTarget=re;try{m(h)}catch(be){Do(be)}h.currentTarget=null,m=I}}}}function Ct(n,s){var a=s[gi];a===void 0&&(a=s[gi]=new Set);var l=n+"__bubble";a.has(l)||(N0(s,n,2,!1),a.add(l))}function Vm(n,s,a){var l=0;s&&(l|=4),N0(a,n,l,s)}var vh="_reactListening"+Math.random().toString(36).slice(2);function Ym(n){if(!n[vh]){n[vh]=!0,Ai.forEach(function(a){a!=="selectionchange"&&(b2.has(a)||Vm(a,!1,n),Vm(a,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[vh]||(s[vh]=!0,Vm("selectionchange",!1,s))}}function N0(n,s,a,l){switch(rw(s)){case 2:var h=V2;break;case 8:h=Y2;break;default:h=cg}a=h.bind(null,s,a,n),h=void 0,!kr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(h=!0),l?h!==void 0?n.addEventListener(s,a,{capture:!0,passive:h}):n.addEventListener(s,a,!0):h!==void 0?n.addEventListener(s,a,{passive:h}):n.addEventListener(s,a,!1)}function Xm(n,s,a,l,h){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===h)break;if(y===4)for(y=l.return;y!==null;){var I=y.tag;if((I===3||I===4)&&y.stateNode.containerInfo===h)return;y=y.return}for(;E!==null;){if(y=us(E),y===null)return;if(I=y.tag,I===5||I===6||I===26||I===27){l=m=y;continue e}E=E.parentNode}}l=l.return}yo(function(){var re=m,be=_o(a),Ce=[];e:{var ue=Eo.get(n);if(ue!==void 0){var me=tr,Ke=n;switch(n){case"keypress":if(gs(a)===0)break e;case"keydown":case"keyup":me=hl;break;case"focusin":Ke="focus",me=ji;break;case"focusout":Ke="blur",me=ji;break;case"beforeblur":case"afterblur":me=ji;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":me=ul;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=Er;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=Nc;break;case gt:case vt:case nt:me=dl;break;case Hs:me=ml;break;case"scroll":case"scrollend":me=Tc;break;case"wheel":me=Mc;break;case"copy":case"cut":case"paste":me=Dc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=Jn;break;case"toggle":case"beforetoggle":me=k}var st=(s&4)!==0,Zt=!st&&(n==="scroll"||n==="scrollend"),G=st?ue!==null?ue+"Capture":null:ue;st=[];for(var W=re,se;W!==null;){var we=W;if(se=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||se===null||G===null||(we=Ci(W,G),we!=null&&st.push(au(W,we,se))),Zt)break;W=W.return}0<st.length&&(ue=new me(ue,Ke,null,a,be),Ce.push({event:ue,listeners:st}))}}if((s&7)===0){e:{if(ue=n==="mouseover"||n==="pointerover",me=n==="mouseout"||n==="pointerout",ue&&a!==la&&(Ke=a.relatedTarget||a.fromElement)&&(us(Ke)||Ke[Ki]))break e;if((me||ue)&&(ue=be.window===be?be:(ue=be.ownerDocument)?ue.defaultView||ue.parentWindow:window,me?(Ke=a.relatedTarget||a.toElement,me=re,Ke=Ke?us(Ke):null,Ke!==null&&(Zt=c(Ke),st=Ke.tag,Ke!==Zt||st!==5&&st!==27&&st!==6)&&(Ke=null)):(me=null,Ke=re),me!==Ke)){if(st=ul,we="onMouseLeave",G="onMouseEnter",W="mouse",(n==="pointerout"||n==="pointerover")&&(st=Jn,we="onPointerLeave",G="onPointerEnter",W="pointer"),Zt=me==null?ue:Mi(me),se=Ke==null?ue:Mi(Ke),ue=new st(we,W+"leave",me,a,be),ue.target=Zt,ue.relatedTarget=se,we=null,us(be)===re&&(st=new st(G,W+"enter",Ke,a,be),st.target=se,st.relatedTarget=Zt,we=st),Zt=we,me&&Ke)t:{for(st=y2,G=me,W=Ke,se=0,we=G;we;we=st(we))se++;we=0;for(var et=W;et;et=st(et))we++;for(;0<se-we;)G=st(G),se--;for(;0<we-se;)W=st(W),we--;for(;se--;){if(G===W||W!==null&&G===W.alternate){st=G;break t}G=st(G),W=st(W)}st=null}else st=null;me!==null&&M0(Ce,ue,me,st,!1),Ke!==null&&Zt!==null&&M0(Ce,Zt,Ke,st,!0)}}e:{if(ue=re?Mi(re):window,me=ue.nodeName&&ue.nodeName.toLowerCase(),me==="select"||me==="input"&&ue.type==="file")var Lt=Ac;else if(Cd(ue))if(Td)Lt=Dd;else{Lt=Cp;var qe=ar}else me=ue.nodeName,!me||me.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?re&&vi(re.elementType)&&(Lt=Ac):Lt=kp;if(Lt&&(Lt=Lt(n,re))){kd(Ce,Lt,a,be);break e}qe&&qe(n,ue,re),n==="focusout"&&re&&ue.type==="number"&&re.memoizedProps.value!=null&&go(ue,"number",ue.value)}switch(qe=re?Mi(re):window,n){case"focusin":(Cd(qe)||qe.contentEditable==="true")&&(ma=qe,ko=re,To=null);break;case"focusout":To=ko=ma=null;break;case"mousedown":yl=!0;break;case"contextmenu":case"mouseup":case"dragend":yl=!1,T(Ce,a,be);break;case"selectionchange":if(Ep)break;case"keydown":case"keyup":T(Ce,a,be)}var pt;if(X)e:{switch(n){case"compositionstart":var Et="onCompositionStart";break e;case"compositionend":Et="onCompositionEnd";break e;case"compositionupdate":Et="onCompositionUpdate";break e}Et=void 0}else yi?ht(n,a)&&(Et="onCompositionEnd"):n==="keydown"&&a.keyCode===229&&(Et="onCompositionStart");Et&&(xe&&a.locale!=="ko"&&(yi||Et!=="onCompositionStart"?Et==="onCompositionEnd"&&yi&&(pt=ut()):(bi=be,Rn="value"in bi?bi.value:bi.textContent,yi=!0)),qe=_h(re,Et),0<qe.length&&(Et=new Dr(Et,n,null,a,be),Ce.push({event:Et,listeners:qe}),pt?Et.data=pt:(pt=Mt(a),pt!==null&&(Et.data=pt)))),(pt=he?pn(n,a):zs(n,a))&&(Et=_h(re,"onBeforeInput"),0<Et.length&&(qe=new Dr("onBeforeInput","beforeinput",null,a,be),Ce.push({event:qe,listeners:Et}),qe.data=pt)),g2(Ce,n,re,a,be)}R0(Ce,s)})}function au(n,s,a){return{instance:n,listener:s,currentTarget:a}}function _h(n,s){for(var a=s+"Capture",l=[];n!==null;){var h=n,m=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||m===null||(h=Ci(n,a),h!=null&&l.unshift(au(n,h,m)),h=Ci(n,s),h!=null&&l.push(au(n,h,m))),n.tag===3)return l;n=n.return}return[]}function y2(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function M0(n,s,a,l,h){for(var m=s._reactName,y=[];a!==null&&a!==l;){var E=a,I=E.alternate,re=E.stateNode;if(E=E.tag,I!==null&&I===l)break;E!==5&&E!==26&&E!==27||re===null||(I=re,h?(re=Ci(a,m),re!=null&&y.unshift(au(a,re,I))):h||(re=Ci(a,m),re!=null&&y.push(au(a,re,I)))),a=a.return}y.length!==0&&n.push({event:s,listeners:y})}var S2=/\r\n?/g,w2=/\u0000|\uFFFD/g;function A0(n){return(typeof n=="string"?n:""+n).replace(S2,`
|
|
10
|
+
`).replace(w2,"")}function L0(n,s){return s=A0(s),A0(n)===s}function Gt(n,s,a,l,h,m){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||fs(n,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&fs(n,""+l);break;case"className":js(n,"class",l);break;case"tabIndex":js(n,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":js(n,a,l);break;case"style":ps(n,l,m);break;case"data":if(s!=="object"){js(n,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){n.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){n.removeAttribute(a);break}l=Oi(""+l),n.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){n.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"&&Gt(n,s,"name",h.name,h,null),Gt(n,s,"formEncType",h.formEncType,h,null),Gt(n,s,"formMethod",h.formMethod,h,null),Gt(n,s,"formTarget",h.formTarget,h,null)):(Gt(n,s,"encType",h.encType,h,null),Gt(n,s,"method",h.method,h,null),Gt(n,s,"target",h.target,h,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){n.removeAttribute(a);break}l=Oi(""+l),n.setAttribute(a,l);break;case"onClick":l!=null&&(n.onclick=_i);break;case"onScroll":l!=null&&Ct("scroll",n);break;case"onScrollEnd":l!=null&&Ct("scrollend",n);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(h.children!=null)throw Error(r(60));n.innerHTML=a}}break;case"multiple":n.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":n.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"){n.removeAttribute("xlink:href");break}a=Oi(""+l),n.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"?n.setAttribute(a,""+l):n.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"?n.setAttribute(a,""):n.removeAttribute(a);break;case"capture":case"download":l===!0?n.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?n.setAttribute(a,l):n.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?n.setAttribute(a,l):n.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?n.removeAttribute(a):n.setAttribute(a,l);break;case"popover":Ct("beforetoggle",n),Ct("toggle",n),Qn(n,"popover",l);break;case"xlinkActuate":Wi(n,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Wi(n,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Wi(n,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Wi(n,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Wi(n,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Wi(n,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Wi(n,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Wi(n,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Wi(n,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Qn(n,"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=kc.get(a)||a,Qn(n,a,l))}}function Gm(n,s,a,l,h,m){switch(a){case"style":ps(n,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(h.children!=null)throw Error(r(60));n.innerHTML=a}}break;case"children":typeof l=="string"?fs(n,l):(typeof l=="number"||typeof l=="bigint")&&fs(n,""+l);break;case"onScroll":l!=null&&Ct("scroll",n);break;case"onScrollEnd":l!=null&&Ct("scrollend",n);break;case"onClick":l!=null&&(n.onclick=_i);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!fo.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(h=a.endsWith("Capture"),s=a.slice(2,h?a.length-7:void 0),m=n[Zn]||null,m=m!=null?m[a]:null,typeof m=="function"&&n.removeEventListener(s,m,h),typeof l=="function")){typeof m!="function"&&m!==null&&(a in n?n[a]=null:n.hasAttribute(a)&&n.removeAttribute(a)),n.addEventListener(s,l,h);break e}a in n?n[a]=l:l===!0?n.setAttribute(a,""):Qn(n,a,l)}}}function fi(n,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ct("error",n),Ct("load",n);var l=!1,h=!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":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Gt(n,s,m,y,a,null)}}h&&Gt(n,s,"srcSet",a.srcSet,a,null),l&&Gt(n,s,"src",a.src,a,null);return;case"input":Ct("invalid",n);var E=m=y=h=null,I=null,re=null;for(l in a)if(a.hasOwnProperty(l)){var be=a[l];if(be!=null)switch(l){case"name":h=be;break;case"type":y=be;break;case"checked":I=be;break;case"defaultChecked":re=be;break;case"value":m=be;break;case"defaultValue":E=be;break;case"children":case"dangerouslySetInnerHTML":if(be!=null)throw Error(r(137,s));break;default:Gt(n,s,l,be,a,null)}}Cr(n,m,E,I,re,y,h,!1);return;case"select":Ct("invalid",n),l=y=m=null;for(h in a)if(a.hasOwnProperty(h)&&(E=a[h],E!=null))switch(h){case"value":m=E;break;case"defaultValue":y=E;break;case"multiple":l=E;default:Gt(n,s,h,E,a,null)}s=m,a=y,n.multiple=!!l,s!=null?hs(n,!!l,s,!1):a!=null&&hs(n,!!l,a,!0);return;case"textarea":Ct("invalid",n),m=h=l=null;for(y in a)if(a.hasOwnProperty(y)&&(E=a[y],E!=null))switch(y){case"value":l=E;break;case"defaultValue":h=E;break;case"children":m=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(r(91));break;default:Gt(n,s,y,E,a,null)}Zs(n,l,h,m);return;case"option":for(I in a)a.hasOwnProperty(I)&&(l=a[I],l!=null)&&(I==="selected"?n.selected=l&&typeof l!="function"&&typeof l!="symbol":Gt(n,s,I,l,a,null));return;case"dialog":Ct("beforetoggle",n),Ct("toggle",n),Ct("cancel",n),Ct("close",n);break;case"iframe":case"object":Ct("load",n);break;case"video":case"audio":for(l=0;l<ru.length;l++)Ct(ru[l],n);break;case"image":Ct("error",n),Ct("load",n);break;case"details":Ct("toggle",n);break;case"embed":case"source":case"link":Ct("error",n),Ct("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(re in a)if(a.hasOwnProperty(re)&&(l=a[re],l!=null))switch(re){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Gt(n,s,re,l,a,null)}return;default:if(vi(s)){for(be in a)a.hasOwnProperty(be)&&(l=a[be],l!==void 0&&Gm(n,s,be,l,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(l=a[E],l!=null&&Gt(n,s,E,l,a,null))}function x2(n,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,m=null,y=null,E=null,I=null,re=null,be=null;for(me in a){var Ce=a[me];if(a.hasOwnProperty(me)&&Ce!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":I=Ce;default:l.hasOwnProperty(me)||Gt(n,s,me,null,l,Ce)}}for(var ue in l){var me=l[ue];if(Ce=a[ue],l.hasOwnProperty(ue)&&(me!=null||Ce!=null))switch(ue){case"type":m=me;break;case"name":h=me;break;case"checked":re=me;break;case"defaultChecked":be=me;break;case"value":y=me;break;case"defaultValue":E=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(r(137,s));break;default:me!==Ce&&Gt(n,s,ue,me,l,Ce)}}li(n,y,E,I,re,be,m,h);return;case"select":me=y=E=ue=null;for(m in a)if(I=a[m],a.hasOwnProperty(m)&&I!=null)switch(m){case"value":break;case"multiple":me=I;default:l.hasOwnProperty(m)||Gt(n,s,m,null,l,I)}for(h in l)if(m=l[h],I=a[h],l.hasOwnProperty(h)&&(m!=null||I!=null))switch(h){case"value":ue=m;break;case"defaultValue":E=m;break;case"multiple":y=m;default:m!==I&&Gt(n,s,h,m,l,I)}s=E,a=y,l=me,ue!=null?hs(n,!!a,ue,!1):!!l!=!!a&&(s!=null?hs(n,!!a,s,!0):hs(n,!!a,a?[]:"",!1));return;case"textarea":me=ue=null;for(E in a)if(h=a[E],a.hasOwnProperty(E)&&h!=null&&!l.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:Gt(n,s,E,null,l,h)}for(y in l)if(h=l[y],m=a[y],l.hasOwnProperty(y)&&(h!=null||m!=null))switch(y){case"value":ue=h;break;case"defaultValue":me=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(91));break;default:h!==m&&Gt(n,s,y,h,l,m)}vo(n,ue,me);return;case"option":for(var Ke in a)ue=a[Ke],a.hasOwnProperty(Ke)&&ue!=null&&!l.hasOwnProperty(Ke)&&(Ke==="selected"?n.selected=!1:Gt(n,s,Ke,null,l,ue));for(I in l)ue=l[I],me=a[I],l.hasOwnProperty(I)&&ue!==me&&(ue!=null||me!=null)&&(I==="selected"?n.selected=ue&&typeof ue!="function"&&typeof ue!="symbol":Gt(n,s,I,ue,l,me));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 st in a)ue=a[st],a.hasOwnProperty(st)&&ue!=null&&!l.hasOwnProperty(st)&&Gt(n,s,st,null,l,ue);for(re in l)if(ue=l[re],me=a[re],l.hasOwnProperty(re)&&ue!==me&&(ue!=null||me!=null))switch(re){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(r(137,s));break;default:Gt(n,s,re,ue,l,me)}return;default:if(vi(s)){for(var Zt in a)ue=a[Zt],a.hasOwnProperty(Zt)&&ue!==void 0&&!l.hasOwnProperty(Zt)&&Gm(n,s,Zt,void 0,l,ue);for(be in l)ue=l[be],me=a[be],!l.hasOwnProperty(be)||ue===me||ue===void 0&&me===void 0||Gm(n,s,be,ue,l,me);return}}for(var G in a)ue=a[G],a.hasOwnProperty(G)&&ue!=null&&!l.hasOwnProperty(G)&&Gt(n,s,G,null,l,ue);for(Ce in l)ue=l[Ce],me=a[Ce],!l.hasOwnProperty(Ce)||ue===me||ue==null&&me==null||Gt(n,s,Ce,ue,l,me)}function O0(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function C2(){if(typeof performance.getEntriesByType=="function"){for(var n=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var h=a[l],m=h.transferSize,y=h.initiatorType,E=h.duration;if(m&&E&&O0(y)){for(y=0,E=h.responseEnd,l+=1;l<a.length;l++){var I=a[l],re=I.startTime;if(re>E)break;var be=I.transferSize,Ce=I.initiatorType;be&&O0(Ce)&&(I=I.responseEnd,y+=be*(I<E?1:(E-re)/(I-re)))}if(--l,s+=8*(m+y)/(h.duration/1e3),n++,10<n)break}}if(0<n)return s/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Zm=null,Qm=null;function bh(n){return n.nodeType===9?n:n.ownerDocument}function B0(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function j0(n,s){if(n===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&s==="foreignObject"?0:n}function Jm(n,s){return n==="textarea"||n==="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 eg=null;function k2(){var n=window.event;return n&&n.type==="popstate"?n===eg?!1:(eg=n,!0):(eg=null,!1)}var I0=typeof setTimeout=="function"?setTimeout:void 0,T2=typeof clearTimeout=="function"?clearTimeout:void 0,P0=typeof Promise=="function"?Promise:void 0,E2=typeof queueMicrotask=="function"?queueMicrotask:typeof P0<"u"?function(n){return P0.resolve(null).then(n).catch(D2)}:I0;function D2(n){setTimeout(function(){throw n})}function Aa(n){return n==="head"}function z0(n,s){var a=s,l=0;do{var h=a.nextSibling;if(n.removeChild(a),h&&h.nodeType===8)if(a=h.data,a==="/$"||a==="/&"){if(l===0){n.removeChild(h),ql(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")ou(n.ownerDocument.documentElement);else if(a==="head"){a=n.ownerDocument.head,ou(a);for(var m=a.firstChild;m;){var y=m.nextSibling,E=m.nodeName;m[oi]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&m.rel.toLowerCase()==="stylesheet"||a.removeChild(m),m=y}}else a==="body"&&ou(n.ownerDocument.body);a=h}while(a);ql(s)}function H0(n,s){var a=n;n=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(n===0)break;n--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||n++;a=l}while(a)}function tg(n){var s=n.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":tg(a),cs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}n.removeChild(a)}}function R2(n,s,a,l){for(;n.nodeType===1;){var h=a;if(n.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(l){if(!n[oi])switch(s){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(m=n.getAttribute("rel"),m==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(m!==h.rel||n.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||n.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||n.getAttribute("title")!==(h.title==null?null:h.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(m=n.getAttribute("src"),(m!==(h.src==null?null:h.src)||n.getAttribute("type")!==(h.type==null?null:h.type)||n.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&m&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(s==="input"&&n.type==="hidden"){var m=h.name==null?null:""+h.name;if(h.type==="hidden"&&n.getAttribute("name")===m)return n}else return n;if(n=Ts(n.nextSibling),n===null)break}return null}function N2(n,s,a){if(s==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!a||(n=Ts(n.nextSibling),n===null))return null;return n}function U0(n,s){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!s||(n=Ts(n.nextSibling),n===null))return null;return n}function ng(n){return n.data==="$?"||n.data==="$~"}function ig(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function M2(n,s){var a=n.ownerDocument;if(n.data==="$~")n._reactRetry=s;else if(n.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),n._reactRetry=l}}function Ts(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return n}var sg=null;function $0(n){n=n.nextSibling;for(var s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="/$"||a==="/&"){if(s===0)return Ts(n.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}n=n.nextSibling}return null}function F0(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var a=n.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return n;s--}else a!=="/$"&&a!=="/&"||s++}n=n.previousSibling}return null}function K0(n,s,a){switch(s=bh(a),n){case"html":if(n=s.documentElement,!n)throw Error(r(452));return n;case"head":if(n=s.head,!n)throw Error(r(453));return n;case"body":if(n=s.body,!n)throw Error(r(454));return n;default:throw Error(r(451))}}function ou(n){for(var s=n.attributes;s.length;)n.removeAttributeNode(s[0]);cs(n)}var Es=new Map,W0=new Set;function yh(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Kr=R.d;R.d={f:A2,r:L2,D:O2,C:B2,L:j2,m:I2,X:z2,S:P2,M:H2};function A2(){var n=Kr.f(),s=dh();return n||s}function L2(n){var s=ds(n);s!==null&&s.tag===5&&s.type==="form"?lS(s):Kr.r(n)}var Fl=typeof document>"u"?null:document;function q0(n,s,a){var l=Fl;if(l&&typeof s=="string"&&s){var h=Dn(s);h='link[rel="'+n+'"][href="'+h+'"]',typeof a=="string"&&(h+='[crossorigin="'+a+'"]'),W0.has(h)||(W0.add(h),n={rel:n,crossOrigin:a,href:s},l.querySelector(h)===null&&(s=l.createElement("link"),fi(s,"link",n),fn(s),l.head.appendChild(s)))}}function O2(n){Kr.D(n),q0("dns-prefetch",n,null)}function B2(n,s){Kr.C(n,s),q0("preconnect",n,s)}function j2(n,s,a){Kr.L(n,s,a);var l=Fl;if(l&&n&&s){var h='link[rel="preload"][as="'+Dn(s)+'"]';s==="image"&&a&&a.imageSrcSet?(h+='[imagesrcset="'+Dn(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(h+='[imagesizes="'+Dn(a.imageSizes)+'"]')):h+='[href="'+Dn(n)+'"]';var m=h;switch(s){case"style":m=Kl(n);break;case"script":m=Wl(n)}Es.has(m)||(n=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:n,as:s},a),Es.set(m,n),l.querySelector(h)!==null||s==="style"&&l.querySelector(lu(m))||s==="script"&&l.querySelector(cu(m))||(s=l.createElement("link"),fi(s,"link",n),fn(s),l.head.appendChild(s)))}}function I2(n,s){Kr.m(n,s);var a=Fl;if(a&&n){var l=s&&typeof s.as=="string"?s.as:"script",h='link[rel="modulepreload"][as="'+Dn(l)+'"][href="'+Dn(n)+'"]',m=h;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Wl(n)}if(!Es.has(m)&&(n=b({rel:"modulepreload",href:n},s),Es.set(m,n),a.querySelector(h)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(cu(m)))return}l=a.createElement("link"),fi(l,"link",n),fn(l),a.head.appendChild(l)}}}function P2(n,s,a){Kr.S(n,s,a);var l=Fl;if(l&&n){var h=Bs(l).hoistableStyles,m=Kl(n);s=s||"default";var y=h.get(m);if(!y){var E={loading:0,preload:null};if(y=l.querySelector(lu(m)))E.loading=5;else{n=b({rel:"stylesheet",href:n,"data-precedence":s},a),(a=Es.get(m))&&rg(n,a);var I=y=l.createElement("link");fn(I),fi(I,"link",n),I._p=new Promise(function(re,be){I.onload=re,I.onerror=be}),I.addEventListener("load",function(){E.loading|=1}),I.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Sh(y,s,l)}y={type:"stylesheet",instance:y,count:1,state:E},h.set(m,y)}}}function z2(n,s){Kr.X(n,s);var a=Fl;if(a&&n){var l=Bs(a).hoistableScripts,h=Wl(n),m=l.get(h);m||(m=a.querySelector(cu(h)),m||(n=b({src:n,async:!0},s),(s=Es.get(h))&&ag(n,s),m=a.createElement("script"),fn(m),fi(m,"link",n),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},l.set(h,m))}}function H2(n,s){Kr.M(n,s);var a=Fl;if(a&&n){var l=Bs(a).hoistableScripts,h=Wl(n),m=l.get(h);m||(m=a.querySelector(cu(h)),m||(n=b({src:n,async:!0,type:"module"},s),(s=Es.get(h))&&ag(n,s),m=a.createElement("script"),fn(m),fi(m,"link",n),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},l.set(h,m))}}function V0(n,s,a,l){var h=(h=ye.current)?yh(h):null;if(!h)throw Error(r(446));switch(n){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=Kl(a.href),a=Bs(h).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){n=Kl(a.href);var m=Bs(h).hoistableStyles,y=m.get(n);if(y||(h=h.ownerDocument||h,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(n,y),(m=h.querySelector(lu(n)))&&!m._p&&(y.instance=m,y.state.loading=5),Es.has(n)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Es.set(n,a),m||U2(h,n,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=Wl(a),a=Bs(h).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,n))}}function Kl(n){return'href="'+Dn(n)+'"'}function lu(n){return'link[rel="stylesheet"]['+n+"]"}function Y0(n){return b({},n,{"data-precedence":n.precedence,precedence:null})}function U2(n,s,a,l){n.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=n.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),fi(s,"link",a),fn(s),n.head.appendChild(s))}function Wl(n){return'[src="'+Dn(n)+'"]'}function cu(n){return"script[async]"+n}function X0(n,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=n.querySelector('style[data-href~="'+Dn(a.href)+'"]');if(l)return s.instance=l,fn(l),l;var h=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(n.ownerDocument||n).createElement("style"),fn(l),fi(l,"style",h),Sh(l,a.precedence,n),s.instance=l;case"stylesheet":h=Kl(a.href);var m=n.querySelector(lu(h));if(m)return s.state.loading|=4,s.instance=m,fn(m),m;l=Y0(a),(h=Es.get(h))&&rg(l,h),m=(n.ownerDocument||n).createElement("link"),fn(m);var y=m;return y._p=new Promise(function(E,I){y.onload=E,y.onerror=I}),fi(m,"link",l),s.state.loading|=4,Sh(m,a.precedence,n),s.instance=m;case"script":return m=Wl(a.src),(h=n.querySelector(cu(m)))?(s.instance=h,fn(h),h):(l=a,(h=Es.get(m))&&(l=b({},a),ag(l,h)),n=n.ownerDocument||n,h=n.createElement("script"),fn(h),fi(h,"link",l),n.head.appendChild(h),s.instance=h);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,Sh(l,a.precedence,n));return s.instance}function Sh(n,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=l.length?l[l.length-1]:null,m=h,y=0;y<l.length;y++){var E=l[y];if(E.dataset.precedence===s)m=E;else if(m!==h)break}m?m.parentNode.insertBefore(n,m.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(n,s.firstChild))}function rg(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.title==null&&(n.title=s.title)}function ag(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.integrity==null&&(n.integrity=s.integrity)}var wh=null;function G0(n,s,a){if(wh===null){var l=new Map,h=wh=new Map;h.set(a,l)}else h=wh,l=h.get(a),l||(l=new Map,h.set(a,l));if(l.has(n))return l;for(l.set(n,null),a=a.getElementsByTagName(n),h=0;h<a.length;h++){var m=a[h];if(!(m[oi]||m[sn]||n==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var y=m.getAttribute(s)||"";y=n+y;var E=l.get(y);E?E.push(m):l.set(y,[m])}}return l}function Z0(n,s,a){n=n.ownerDocument||n,n.head.insertBefore(a,s==="title"?n.querySelector("head > title"):null)}function $2(n,s,a){if(a===1||s.itemProp!=null)return!1;switch(n){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"?(n=s.disabled,typeof s.precedence=="string"&&n==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 Q0(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function F2(n,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var h=Kl(l.href),m=s.querySelector(lu(h));if(m){s=m._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(n.count++,n=xh.bind(n),s.then(n,n)),a.state.loading|=4,a.instance=m,fn(m);return}m=s.ownerDocument||s,l=Y0(l),(h=Es.get(h))&&rg(l,h),m=m.createElement("link"),fn(m);var y=m;y._p=new Promise(function(E,I){y.onload=E,y.onerror=I}),fi(m,"link",l),a.instance=m}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(n.count++,a=xh.bind(n),s.addEventListener("load",a),s.addEventListener("error",a))}}var og=0;function K2(n,s){return n.stylesheets&&n.count===0&&kh(n,n.stylesheets),0<n.count||0<n.imgCount?function(a){var l=setTimeout(function(){if(n.stylesheets&&kh(n,n.stylesheets),n.unsuspend){var m=n.unsuspend;n.unsuspend=null,m()}},6e4+s);0<n.imgBytes&&og===0&&(og=62500*C2());var h=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&kh(n,n.stylesheets),n.unsuspend)){var m=n.unsuspend;n.unsuspend=null,m()}},(n.imgBytes>og?50:800)+s);return n.unsuspend=a,function(){n.unsuspend=null,clearTimeout(l),clearTimeout(h)}}:null}function xh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)kh(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Ch=null;function kh(n,s){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Ch=new Map,s.forEach(W2,n),Ch=null,xh.call(n))}function W2(n,s){if(!(s.state.loading&4)){var a=Ch.get(n);if(a)var l=a.get(null);else{a=new Map,Ch.set(n,a);for(var h=n.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<h.length;m++){var y=h[m];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(a.set(y.dataset.precedence,y),l=y)}l&&a.set(null,l)}h=s.instance,y=h.getAttribute("data-precedence"),m=a.get(y)||l,m===l&&a.set(null,h),a.set(y,h),this.count++,l=xh.bind(this),h.addEventListener("load",l),h.addEventListener("error",l),m?m.parentNode.insertBefore(h,m.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(h,n.firstChild)),s.state.loading|=4}}var uu={$$typeof:P,Provider:null,Consumer:null,_currentValue:z,_currentValue2:z,_threadCount:0};function q2(n,s,a,l,h,m,y,E,I){this.tag=1,this.containerInfo=n,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=ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ze(0),this.hiddenUpdates=ze(null),this.identifierPrefix=l,this.onUncaughtError=h,this.onCaughtError=m,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function J0(n,s,a,l,h,m,y,E,I,re,be,Ce){return n=new q2(n,s,a,y,I,re,be,Ce,E),s=1,m===!0&&(s|=24),m=Gi(3,null,null,s),n.current=m,m.stateNode=n,s=Hp(),s.refCount++,n.pooledCache=s,s.refCount++,m.memoizedState={element:l,isDehydrated:a,cache:s},Kp(m),n}function ew(n){return n?(n=wl,n):wl}function tw(n,s,a,l,h,m){h=ew(h),l.context===null?l.context=h:l.pendingContext=h,l=Sa(s),l.payload={element:a},m=m===void 0?null:m,m!==null&&(l.callback=m),a=wa(n,l,s),a!==null&&($i(a,n,s),$c(a,n,s))}function nw(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var a=n.retryLane;n.retryLane=a!==0&&a<s?a:s}}function lg(n,s){nw(n,s),(n=n.alternate)&&nw(n,s)}function iw(n){if(n.tag===13||n.tag===31){var s=Ro(n,67108864);s!==null&&$i(s,n,67108864),lg(n,67108864)}}function sw(n){if(n.tag===13||n.tag===31){var s=ts();s=Gn(s);var a=Ro(n,s);a!==null&&$i(a,n,s),lg(n,s)}}var Th=!0;function V2(n,s,a,l){var h=O.T;O.T=null;var m=R.p;try{R.p=2,cg(n,s,a,l)}finally{R.p=m,O.T=h}}function Y2(n,s,a,l){var h=O.T;O.T=null;var m=R.p;try{R.p=8,cg(n,s,a,l)}finally{R.p=m,O.T=h}}function cg(n,s,a,l){if(Th){var h=ug(l);if(h===null)Xm(n,s,l,Eh,a),aw(n,l);else if(G2(h,n,s,a,l))l.stopPropagation();else if(aw(n,l),s&4&&-1<X2.indexOf(n)){for(;h!==null;){var m=ds(h);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var y=Dt(m.pendingLanes);if(y!==0){var E=m;for(E.pendingLanes|=2,E.entangledLanes|=2;y;){var I=1<<31-At(y);E.entanglements[1]|=I,y&=~I}ur(m),(Pt&6)===0&&(ch=Ae()+500,su(0))}}break;case 31:case 13:E=Ro(m,2),E!==null&&$i(E,m,2),dh(),lg(m,2)}if(m=ug(l),m===null&&Xm(n,s,l,Eh,a),m===h)break;h=m}h!==null&&l.stopPropagation()}else Xm(n,s,l,null,a)}}function ug(n){return n=_o(n),dg(n)}var Eh=null;function dg(n){if(Eh=null,n=us(n),n!==null){var s=c(n);if(s===null)n=null;else{var a=s.tag;if(a===13){if(n=u(s),n!==null)return n;n=null}else if(a===31){if(n=f(s),n!==null)return n;n=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null)}}return Eh=n,null}function rw(n){switch(n){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(_t()){case bt:return 2;case at:return 8;case ot:case Bt:return 32;case ln:return 268435456;default:return 32}default:return 32}}var hg=!1,La=null,Oa=null,Ba=null,du=new Map,hu=new Map,ja=[],X2="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 aw(n,s){switch(n){case"focusin":case"focusout":La=null;break;case"dragenter":case"dragleave":Oa=null;break;case"mouseover":case"mouseout":Ba=null;break;case"pointerover":case"pointerout":du.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":hu.delete(s.pointerId)}}function fu(n,s,a,l,h,m){return n===null||n.nativeEvent!==m?(n={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:m,targetContainers:[h]},s!==null&&(s=ds(s),s!==null&&iw(s)),n):(n.eventSystemFlags|=l,s=n.targetContainers,h!==null&&s.indexOf(h)===-1&&s.push(h),n)}function G2(n,s,a,l,h){switch(s){case"focusin":return La=fu(La,n,s,a,l,h),!0;case"dragenter":return Oa=fu(Oa,n,s,a,l,h),!0;case"mouseover":return Ba=fu(Ba,n,s,a,l,h),!0;case"pointerover":var m=h.pointerId;return du.set(m,fu(du.get(m)||null,n,s,a,l,h)),!0;case"gotpointercapture":return m=h.pointerId,hu.set(m,fu(hu.get(m)||null,n,s,a,l,h)),!0}return!1}function ow(n){var s=us(n.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){n.blockedOn=s,vn(n.priority,function(){sw(a)});return}}else if(s===31){if(s=f(a),s!==null){n.blockedOn=s,vn(n.priority,function(){sw(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){n.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Dh(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var a=ug(n.nativeEvent);if(a===null){a=n.nativeEvent;var l=new a.constructor(a.type,a);la=l,a.target.dispatchEvent(l),la=null}else return s=ds(a),s!==null&&iw(s),n.blockedOn=a,!1;s.shift()}return!0}function lw(n,s,a){Dh(n)&&a.delete(s)}function Z2(){hg=!1,La!==null&&Dh(La)&&(La=null),Oa!==null&&Dh(Oa)&&(Oa=null),Ba!==null&&Dh(Ba)&&(Ba=null),du.forEach(lw),hu.forEach(lw)}function Rh(n,s){n.blockedOn===s&&(n.blockedOn=null,hg||(hg=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Z2)))}var Nh=null;function cw(n){Nh!==n&&(Nh=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Nh===n&&(Nh=null);for(var s=0;s<n.length;s+=3){var a=n[s],l=n[s+1],h=n[s+2];if(typeof l!="function"){if(dg(l||a)===null)continue;break}var m=ds(a);m!==null&&(n.splice(s,3),s-=3,um(m,{pending:!0,data:h,method:a.method,action:l},l,h))}}))}function ql(n){function s(I){return Rh(I,n)}La!==null&&Rh(La,n),Oa!==null&&Rh(Oa,n),Ba!==null&&Rh(Ba,n),du.forEach(s),hu.forEach(s);for(var a=0;a<ja.length;a++){var l=ja[a];l.blockedOn===n&&(l.blockedOn=null)}for(;0<ja.length&&(a=ja[0],a.blockedOn===null);)ow(a),a.blockedOn===null&&ja.shift();if(a=(n.ownerDocument||n).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var h=a[l],m=a[l+1],y=h[Zn]||null;if(typeof m=="function")y||cw(a);else if(y){var E=null;if(m&&m.hasAttribute("formAction")){if(h=m,y=m[Zn]||null)E=y.formAction;else if(dg(h)!==null)continue}else E=y.action;typeof E=="function"?a[l+1]=E:(a.splice(l,3),l-=3),cw(a)}}}function uw(){function n(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(y){return h=y})},focusReset:"manual",scroll:"manual"})}function s(){h!==null&&(h(),h=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var 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,h=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),h!==null&&(h(),h=null)}}}function fg(n){this._internalRoot=n}Mh.prototype.render=fg.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=ts();tw(a,l,n,s,null,null)},Mh.prototype.unmount=fg.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;tw(n.current,2,null,n,null,null),dh(),s[Ki]=null}};function Mh(n){this._internalRoot=n}Mh.prototype.unstable_scheduleHydration=function(n){if(n){var s=Bn();n={blockedOn:null,target:n,priority:s};for(var a=0;a<ja.length&&s!==0&&s<ja[a].priority;a++);ja.splice(a,0,n),a===0&&ow(n)}};var dw=t.version;if(dw!=="19.2.6")throw Error(r(527,dw,"19.2.6"));R.findDOMNode=function(n){var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(r(188)):(n=Object.keys(n).join(","),Error(r(268,n)));return n=p(s),n=n!==null?_(n):null,n=n===null?null:n.stateNode,n};var Q2={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ah=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ah.isDisabled&&Ah.supportsFiber)try{Ut=Ah.inject(Q2),kt=Ah}catch{}}return mu.createRoot=function(n,s){if(!o(n))throw Error(r(299));var a=!1,l="",h=_S,m=bS,y=yS;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(h=s.onUncaughtError),s.onCaughtError!==void 0&&(m=s.onCaughtError),s.onRecoverableError!==void 0&&(y=s.onRecoverableError)),s=J0(n,1,!1,null,null,a,l,null,h,m,y,uw),n[Ki]=s.current,Ym(n),new fg(s)},mu.hydrateRoot=function(n,s,a){if(!o(n))throw Error(r(299));var l=!1,h="",m=_S,y=bS,E=yS,I=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(h=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&&(I=a.formState)),s=J0(n,1,!0,s,a??null,l,h,I,m,y,E,uw),s.context=ew(null),a=s.current,l=ts(),l=Gn(l),h=Sa(l),h.callback=null,wa(a,h,l),a=l,s.current.lanes=a,Ie(s,a),ur(s),n[Ki]=s.current,Ym(n),new Mh(s)},mu.version="19.2.6",mu}var Sw;function lD(){if(Sw)return gg.exports;Sw=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),gg.exports=oD(),gg.exports}var cD=lD();class $o extends Error{constructor(t,i){super(i),this.status=t,this.name="UploadClientError"}status}function Xx(e){const t=e.createXhr?.()??new XMLHttpRequest,i=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));i.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())i.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 $o(0,"Upload aborted."))};if(e.signal?.aborted){p(new $o(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 $o(t.status,"Invalid upload response."))}return}p(new $o(t.status,uD(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new $o(0,"Upload failed.")),t.onabort=()=>p(new $o(0,"Upload aborted.")),t.ontimeout=()=>p(new $o(0,"Upload timed out.")),t.send(i)})}function uD(e,t){try{const i=JSON.parse(e),r=typeof i.error=="string"?i.error:i.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class Vn extends Error{constructor(t,i){super(i),this.status=t,this.name="ApiError"}status}function Gf(e=fetch){return{getSession:(t={})=>De(e,`/api/auth/session${mr(t)}`),setupPassword:t=>De(e,"/api/auth/password",tt("POST",t)),login:t=>De(e,"/api/auth/login",tt("POST",t)),reauth:t=>De(e,"/api/auth/reauth",tt("POST",t)),logout:()=>De(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>De(e,"/api/client-diagnostics",tt("POST",t)),setupTotp:()=>De(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>De(e,"/api/auth/totp/activate",tt("POST",t)),disableTotp:()=>De(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>De(e,"/api/auth/devices"),revokeDevice:async t=>{await Xl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>De(e,"/api/auth/networks"),addNetwork:t=>De(e,"/api/auth/networks",tt("POST",t)),removeNetwork:async t=>{await Xl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>De(e,"/api/agents"),addAgent:t=>De(e,"/api/agents",tt("POST",t)),reorderAgents:t=>De(e,"/api/agents/order",tt("PUT",{serverIds:t})),renameAgent:(t,i)=>De(e,`/api/agents/${encodeURIComponent(t)}`,tt("PATCH",{name:i})),getMainInfo:()=>De(e,"/api/main"),renameMain:t=>De(e,"/api/main",tt("PATCH",{name:t})),removeAgent:async t=>{await Xl(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${mr(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",tt("POST",t)),stopCodeServer:(t={})=>De(e,"/api/code-server/stop",tt("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",tt("PUT",t)),listTerminals:()=>De(e,"/api/terminals"),getTerminalLayout:()=>De(e,"/api/terminal-layout"),saveTerminalLayout:t=>De(e,"/api/terminal-layout",tt("PUT",t)),createFileRoot:t=>De(e,"/api/files/root",tt("POST",t)),listFiles:t=>De(e,"/api/files/list",tt("POST",t)),readFile:t=>De(e,"/api/files/read",tt("POST",t)),writeFile:t=>De(e,"/api/files/write",tt("POST",t)),createFileEntry:t=>De(e,"/api/files/create",tt("POST",t)),moveFileEntry:t=>De(e,"/api/files/move",tt("POST",t)),previewDeleteFileEntry:t=>De(e,"/api/files/delete-preview",tt("POST",t)),deleteFileEntry:t=>De(e,"/api/files/delete",tt("POST",t)),openFileInTerminal:t=>De(e,"/api/files/open",tt("POST",t)),previewFile:t=>Gx(e,"/api/files/preview",tt("POST",t)),createTerminal:(t={})=>De(e,"/api/terminals",tt("POST",t)),closeTerminal:async t=>{await Xl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,i)=>De(e,`/api/terminals/${encodeURIComponent(t)}`,tt("PATCH",{title:i})),getTerminalHistory:(t,i={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/history${mr(i)}`),getTerminalTranscriptHistory:(t,i={},r)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${mr(i)}`,r?{signal:r}:void 0),searchTerminalTranscript:(t,i,r)=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-search`,{...tt("POST",i),...r?{signal:r}:{}}),getTerminalTranscriptSource:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,i,r={})=>De(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(i)}/transcript-history${mr(r)}`),listNotificationAssets:()=>De(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const i=new FormData;return i.append("asset",t),De(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:i})},updateNotificationAssetSelection:t=>De(e,"/api/notification-assets/selection",tt("PUT",t)),deleteNotificationAsset:async t=>{await Xl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,i)=>De(e,`/api/push-notifications/status${t||i?mr({...t!==void 0?{clientId:t}:{},...i!==void 0?{endpointHash:i}:{}}):""}`),preparePushNotifications:t=>De(e,"/api/push-notifications/prepare",tt("POST",{clientId:t})),subscribePushNotifications:t=>De(e,"/api/push-notifications/subscription",tt("POST",t)),updatePushNotificationDevice:t=>De(e,"/api/push-notifications/device",tt("PATCH",t)),unsubscribePushNotifications:t=>De(e,"/api/push-notifications/unsubscribe",tt("POST",t)),updatePushPresence:t=>De(e,"/api/push-notifications/presence",tt("POST",t)),testPushNotification:t=>De(e,"/api/push-notifications/test",tt("POST",t))}}function pr(e,t=fetch){const i=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>De(t,i("terminals")),createTerminal:(r={})=>De(t,i("terminals"),tt("POST",r)),closeTerminal:async r=>{await Xl(t,i(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>De(t,i(`terminals/${encodeURIComponent(r)}`),tt("PATCH",{title:o})),getTerminalHistory:(r,o={})=>De(t,`${i(`terminals/${encodeURIComponent(r)}/history`)}${mr(o)}`),getTerminalTranscriptHistory:(r,o={},c)=>De(t,`${i(`terminals/${encodeURIComponent(r)}/transcript-history`)}${mr(o)}`,c?{signal:c}:void 0),searchTerminalTranscript:(r,o,c)=>De(t,i(`terminals/${encodeURIComponent(r)}/transcript-search`),{...tt("POST",o),...c?{signal:c}:{}}),getTerminalTranscriptSource:r=>De(t,i(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>De(t,i(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>De(t,`${i(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${mr(c)}`),getTerminalLayout:()=>De(t,i("terminal-layout")),saveTerminalLayout:r=>De(t,i("terminal-layout"),tt("PUT",r)),createFileRoot:r=>De(t,i("files/root"),tt("POST",r)),listFiles:r=>De(t,i("files/list"),tt("POST",r)),readFile:r=>De(t,i("files/read"),tt("POST",r)),writeFile:r=>De(t,i("files/write"),tt("POST",r)),createFileEntry:r=>De(t,i("files/create"),tt("POST",r)),moveFileEntry:r=>De(t,i("files/move"),tt("POST",r)),previewDeleteFileEntry:r=>De(t,i("files/delete-preview"),tt("POST",r)),deleteFileEntry:r=>De(t,i("files/delete"),tt("POST",r)),openFileInTerminal:r=>De(t,i("files/open"),tt("POST",r)),previewFile:r=>Gx(t,i("files/preview"),tt("POST",r)),uploadComposeAttachments:r=>Xx({...r,endpoint:i("attachments")}),getComposeAttachmentLimits:()=>De(t,i("attachments/limits")),deleteComposeAttachments:r=>De(t,i("attachments/delete"),tt("POST",r)),getCodeServerStatus:(r={})=>De(t,`${i("code-server/status")}${mr(r)}`),installCodeServer:()=>De(t,i("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>De(t,i("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>De(t,i("code-server/open"),tt("POST",r)),stopCodeServer:(r={})=>De(t,i("code-server/stop"),tt("POST",r)),uninstallCodeServer:()=>De(t,i("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),getAccounts:()=>De(t,i("accounts")),getServerProcesses:()=>De(t,i("server-info/processes")),renameServerProject:(r,o)=>De(t,i("server-info/project-name"),tt("POST",{path:r,name:o})),getServerExternalIp:(r=!1)=>De(t,i("server-info/external-ip")+(r?"?refresh=1":"")),selectAccount:(r,o)=>De(t,i(`accounts/${r}/select`),tt("POST",{profileId:o})),removeAccount:(r,o)=>De(t,i(`accounts/${r}/${encodeURIComponent(o)}`),{method:"DELETE",credentials:"same-origin"}),beginAccountLogin:r=>De(t,i(`accounts/${r}/login`),{method:"POST",credentials:"same-origin"}),completeAccountLogin:(r,o)=>De(t,i(`accounts/${r}/login/complete`),tt("POST",{label:o})),cancelAccountLogin:r=>De(t,i(`accounts/${r}/login/cancel`),{method:"POST",credentials:"same-origin"}),refreshAccount:(r,o)=>De(t,i(`accounts/${r}/refresh`),tt("POST",o?{profileId:o}:{})),terminateProviderSessions:r=>De(t,i(`accounts/${r}/terminate`),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>dD(i(`terminals/${encodeURIComponent(r)}/ws`),o)}}function dD(e,t){const i=new URL(t);return i.protocol=i.protocol==="https:"?"wss:":"ws:",i.pathname=e,i.search="",i.hash="",i.toString()}function tt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function mr(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.candidateId!==void 0&&t.set("candidateId",e.candidateId),e.expectedSessionId!==void 0&&t.set("expectedSessionId",e.expectedSessionId),e.around!==void 0&&t.set("around",e.around),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 i=t.toString();return i?`?${i}`:""}async function De(e,t,i){const r=await e(t,i??{credentials:"same-origin"});await rb(r);try{return await r.json()}catch{throw new Vn(r.status,"invalid_json_response")}}async function Xl(e,t,i){const r=await e(t,i);await rb(r)}async function Gx(e,t,i){const r=await e(t,i);return await rb(r),r.blob()}async function rb(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const i=await e.json(),r=typeof i.error=="string"?i.error:i.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Vn(e.status,t)}const ab="nterminal.theme.id",Zx="nterminal.theme.accent",pv="nterminal:theme",bf=[{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",...ww({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",...ww({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],uc="midnight";function Zf(e){return bf.some(t=>t.id===e)?e:uc}function ob(e){return bf.find(t=>t.id===e)??bf[0]}function no(){if(typeof window>"u")return uc;try{const e=window.localStorage.getItem(ab);return e?Zf(e):gD(window.localStorage.getItem(Zx))}catch{return uc}}function hD(e){const t=Zf(e);if(typeof window<"u"){try{window.localStorage.setItem(ab,t)}catch{}lb(t),window.dispatchEvent(new CustomEvent(pv,{detail:t}))}return t}function lb(e=no()){if(typeof document>"u")return;const t=ob(Zf(e)),i=document.documentElement;i.dataset.ntTheme=t.id,i.style.setProperty("color-scheme",t.mode),mt(i,"--nt-bg",t.tokens.bg),mt(i,"--nt-bg-2",t.tokens.bg2),mt(i,"--nt-bg-sidebar",t.tokens.bgSidebar),mt(i,"--nt-line",t.tokens.line),mt(i,"--nt-line-2",t.tokens.line2),mt(i,"--nt-fg",t.tokens.fg),mt(i,"--nt-fg-2",t.tokens.fg2),mt(i,"--nt-fg-3",t.tokens.fg3),mt(i,"--nt-fg-4",t.tokens.fg4),mt(i,"--nt-accent",t.tokens.accent),mt(i,"--nt-accent-soft",t.tokens.accentSoft),mt(i,"--nt-accent-glow",t.tokens.accentGlow),mt(i,"--nt-on-accent",t.tokens.onAccent),mt(i,"--nt-ok",t.tokens.ok),mt(i,"--nt-danger",t.tokens.danger),mt(i,"--nt-on-danger",t.tokens.onDanger),mt(i,"--nt-danger-soft",t.tokens.dangerSoft),mt(i,"--nt-danger-line",t.tokens.dangerLine),mt(i,"--nt-warning",t.tokens.warning),mt(i,"--nt-warn",t.tokens.warning),mt(i,"--nt-warning-soft",t.tokens.warningSoft),mt(i,"--nt-warning-glow",t.tokens.warningGlow),mt(i,"--nt-scrim",t.tokens.scrim),mt(i,"--nt-scrim-soft",t.tokens.scrimSoft),mt(i,"--nt-shadow",t.tokens.shadow),mt(i,"--nt-shadow-strong",t.tokens.shadowStrong),mt(i,"--nt-floating-bg",t.tokens.floatingBg),mt(i,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),mt(i,"--nt-floating-bg-hover",t.tokens.floatingBgHover),mt(i,"--nt-subtle-fill",t.tokens.subtleFill),mt(i,"--nt-hover-fill",t.tokens.hoverFill),mt(i,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),mt(i,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),mt(i,"--nt-transcript-user",t.tokens.transcriptUser),mt(i,"--nt-transcript-assistant",t.tokens.transcriptAssistant),mt(i,"--nt-transcript-tool",t.tokens.transcriptTool),mt(i,"--nt-transcript-command",t.tokens.transcriptCommand),mt(i,"--nt-transcript-code",t.tokens.transcriptCode),mt(i,"--nt-transcript-search",t.tokens.transcriptSearch),mt(i,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),mt(i,"--nt-qr-bg",t.tokens.qrBg)}function fD(e=no()){return ob(Zf(e)).xterm}function cb(e){if(typeof window>"u")return()=>{};const t=i=>{(i.key===ab||i.key===Zx)&&(lb(no()),e())};return window.addEventListener(pv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(pv,e),window.removeEventListener("storage",t)}}function mt(e,t,i){e.style.setProperty(t,i)}function ww(e){const t=pD(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 pD(e){const t=[];for(let i=16;i<=e;i+=1)t.push(mD(i));return t}function mD(e){if(e>=16&&e<=231){const t=e-16,i=[0,95,135,175,215,255],r=i[Math.floor(t/36)%6],o=i[Math.floor(t/6)%6],c=i[t%6];return xw(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return xw(t,t,t)}return"#000000"}function xw(e,t,i){return`#${yg(e)}${yg(t)}${yg(i)}`}function yg(e){return e.toString(16).padStart(2,"0")}function gD(e){return e==="signal-red"?"signal-red":uc}function Qx(){const e=v.useSyncExternalStore(cb,no,()=>uc);return ob(e).mode==="light"?"-light":""}function Jx({size:e=22}){const t=Qx();return d.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function eC({height:e=18}){const t=Qx(),i=Math.round(243/34*e);return d.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:i,height:e,alt:"NTerminal"})}var Ru=Yx();function vD(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return v.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const Qf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function gc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ub(e){return"nodeType"in e}function Di(e){var t,i;return e?gc(e)?e:ub(e)&&(t=(i=e.ownerDocument)==null?void 0:i.defaultView)!=null?t:window:window}function db(e){const{Document:t}=Di(e);return e instanceof t}function md(e){return gc(e)?!1:e instanceof Di(e).HTMLElement}function tC(e){return e instanceof Di(e).SVGElement}function vc(e){return e?gc(e)?e.document:ub(e)?db(e)?e:md(e)||tC(e)?e.ownerDocument:document:document:document}const Ws=Qf?v.useLayoutEffect:v.useEffect;function Jf(e){const t=v.useRef(e);return Ws(()=>{t.current=e}),v.useCallback(function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function _D(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),i=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,i]}function Gu(e,t){t===void 0&&(t=[e]);const i=v.useRef(e);return Ws(()=>{i.current!==e&&(i.current=e)},t),i}function gd(e,t){const i=v.useRef();return v.useMemo(()=>{const r=e(i.current);return i.current=r,r},[...t])}function yf(e){const t=Jf(e),i=v.useRef(null),r=v.useCallback(o=>{o!==i.current&&t?.(o,i.current),i.current=o},[]);return[i,r]}function Sf(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Sg={};function vd(e,t){return v.useMemo(()=>{if(t)return t;const i=Sg[e]==null?0:Sg[e]+1;return Sg[e]=i,e+"-"+i},[e,t])}function nC(e){return function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;o<i;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 ac=nC(1),wf=nC(-1);function bD(e){return"clientX"in e&&"clientY"in e}function ep(e){if(!e)return!1;const{KeyboardEvent:t}=Di(e.target);return t&&e instanceof t}function yD(e){if(!e)return!1;const{TouchEvent:t}=Di(e.target);return t&&e instanceof t}function xf(e){if(yD(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:i}=e.touches[0];return{x:t,y:i}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:i}=e.changedTouches[0];return{x:t,y:i}}}return bD(e)?{x:e.clientX,y:e.clientY}:null}const ea=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:i}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(i?Math.round(i):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:i}=e;return"scaleX("+t+") scaleY("+i+")"}},Transform:{toString(e){if(e)return[ea.Translate.toString(e),ea.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:i,easing:r}=e;return t+" "+i+"ms "+r}}}),Cw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function SD(e){return e.matches(Cw)?e:e.querySelector(Cw)}const wD={display:"none"};function xD(e){let{id:t,value:i}=e;return Nt.createElement("div",{id:t,style:wD},i)}function CD(e){let{id:t,announcement:i,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 Nt.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},i)}function kD(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const iC=v.createContext(null);function TD(e){const t=v.useContext(iC);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 DD={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
|
+
`},RD={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:i}=e;return i?"Draggable item "+t.id+" was moved over droppable area "+i.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:i}=e;return i?"Draggable item "+t.id+" was dropped over droppable area "+i.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=RD,container:i,hiddenTextDescribedById:r,screenReaderInstructions:o=DD}=e;const{announce:c,announcement:u}=kD(),f=vd("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),TD(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:x}=b;t.onDragMove&&c(t.onDragMove({active:w,over:x}))},onDragOver(b){let{active:w,over:x}=b;c(t.onDragOver({active:w,over:x}))},onDragEnd(b){let{active:w,over:x}=b;c(t.onDragEnd({active:w,over:x}))},onDragCancel(b){let{active:w,over:x}=b;c(t.onDragCancel({active:w,over:x}))}}),[c,t])),!g)return null;const _=Nt.createElement(Nt.Fragment,null,Nt.createElement(xD,{id:r,value:o.draggable}),Nt.createElement(CD,{id:f,announcement:u}));return i?Ru.createPortal(_,i):_}var Yn;(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"})(Yn||(Yn={}));function Cf(){}function kf(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function sC(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const qs=Object.freeze({x:0,y:0});function MD(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function AD(e,t){const i=xf(e);if(!i)return"0 0";const r={x:(i.x-t.left)/t.width*100,y:(i.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function LD(e,t){let{data:{value:i}}=e,{data:{value:r}}=t;return i-r}function OD(e,t){let{data:{value:i}}=e,{data:{value:r}}=t;return r-i}function BD(e,t){if(!e||e.length===0)return null;const[i]=e;return i[t]}function kw(e,t,i){return t===void 0&&(t=e.left),i===void 0&&(i=e.top),{x:t+e.width*.5,y:i+e.height*.5}}const jD=e=>{let{collisionRect:t,droppableRects:i,droppableContainers:r}=e;const o=kw(t,t.left,t.top),c=[];for(const u of r){const{id:f}=u,g=i.get(f);if(g){const p=MD(kw(g),o);c.push({id:f,data:{droppableContainer:u,value:p}})}}return c.sort(LD)};function ID(e,t){const i=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-i;if(r<o&&i<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 PD=e=>{let{collisionRect:t,droppableRects:i,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,f=i.get(u);if(f){const g=ID(f,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(OD)};function zD(e,t,i){return{...e,scaleX:t&&i?t.width/i.width:1,scaleY:t&&i?t.height/i.height:1}}function rC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:qs}function HD(e){return function(i){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}),{...i})}}const UD=HD(1);function aC(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 $D(e,t,i){const r=aC(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:f}=r,g=e.left-u-(1-o)*parseFloat(i),p=e.top-f-(1-c)*parseFloat(i.slice(i.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 FD={ignoreTransform:!1};function _c(e,t){t===void 0&&(t=FD);let i=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:_}=Di(e).getComputedStyle(e);p&&(i=$D(i,p,_))}const{top:r,left:o,width:c,height:u,bottom:f,right:g}=i;return{top:r,left:o,width:c,height:u,bottom:f,right:g}}function Tw(e){return _c(e,{ignoreTransform:!0})}function KD(e){const t=e.innerWidth,i=e.innerHeight;return{top:0,left:0,right:t,bottom:i,width:t,height:i}}function WD(e,t){return t===void 0&&(t=Di(e).getComputedStyle(e)),t.position==="fixed"}function qD(e,t){t===void 0&&(t=Di(e).getComputedStyle(e));const i=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?i.test(c):!1})}function hb(e,t){const i=[];function r(o){if(t!=null&&i.length>=t||!o)return i;if(db(o)&&o.scrollingElement!=null&&!i.includes(o.scrollingElement))return i.push(o.scrollingElement),i;if(!md(o)||tC(o)||i.includes(o))return i;const c=Di(e).getComputedStyle(o);return o!==e&&qD(o,c)&&i.push(o),WD(o,c)?i:r(o.parentNode)}return e?r(e):i}function oC(e){const[t]=hb(e,1);return t??null}function wg(e){return!Qf||!e?null:gc(e)?e:ub(e)?db(e)||e===vc(e).scrollingElement?window:md(e)?e:null:null}function lC(e){return gc(e)?e.scrollX:e.scrollLeft}function cC(e){return gc(e)?e.scrollY:e.scrollTop}function mv(e){return{x:lC(e),y:cC(e)}}var ni;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ni||(ni={}));function uC(e){return!Qf||!e?!1:e===document.scrollingElement}function dC(e){const t={x:0,y:0},i=uC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-i.width,y:e.scrollHeight-i.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 VD={x:.2,y:.2};function YD(e,t,i,r,o){let{top:c,left:u,right:f,bottom:g}=i;r===void 0&&(r=10),o===void 0&&(o=VD);const{isTop:p,isBottom:_,isLeft:b,isRight:w}=dC(e),x={x:0,y:0},C={x:0,y:0},N={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+N.height?(x.y=ni.Backward,C.y=r*Math.abs((t.top+N.height-c)/N.height)):!_&&g>=t.bottom-N.height&&(x.y=ni.Forward,C.y=r*Math.abs((t.bottom-N.height-g)/N.height)),!w&&f>=t.right-N.width?(x.x=ni.Forward,C.x=r*Math.abs((t.right-N.width-f)/N.width)):!b&&u<=t.left+N.width&&(x.x=ni.Backward,C.x=r*Math.abs((t.left+N.width-u)/N.width)),{direction:x,speed:C}}function XD(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:i,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:i,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function hC(e){return e.reduce((t,i)=>ac(t,mv(i)),qs)}function GD(e){return e.reduce((t,i)=>t+lC(i),0)}function ZD(e){return e.reduce((t,i)=>t+cC(i),0)}function fC(e,t){if(t===void 0&&(t=_c),!e)return;const{top:i,left:r,bottom:o,right:c}=t(e);oC(e)&&(o<=0||c<=0||i>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const QD=[["x",["left","right"],GD],["y",["top","bottom"],ZD]];class fb{constructor(t,i){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=hb(i),o=hC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,f]of QD)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 Pu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(i=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...i)})},this.target=t}add(t,i,r){var o;(o=this.target)==null||o.addEventListener(t,i,r),this.listeners.push([t,i,r])}}function JD(e){const{EventTarget:t}=Di(e);return e instanceof t?e:vc(e)}function xg(e,t){const i=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(i**2+r**2)>t:"x"in t&&"y"in t?i>t.x&&r>t.y:"x"in t?i>t.x:"y"in t?r>t.y:!1}var Ms;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Ms||(Ms={}));function Ew(e){e.preventDefault()}function eR(e){e.stopPropagation()}var zt;(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"})(zt||(zt={}));const pC={start:[zt.Space,zt.Enter],cancel:[zt.Esc],end:[zt.Space,zt.Enter,zt.Tab]},tR=(e,t)=>{let{currentCoordinates:i}=t;switch(e.code){case zt.Right:return{...i,x:i.x+25};case zt.Left:return{...i,x:i.x-25};case zt.Down:return{...i,y:i.y+25};case zt.Up:return{...i,y:i.y-25}}};class mC{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:i}}=t;this.props=t,this.listeners=new Pu(vc(i)),this.windowListeners=new Pu(Di(i)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ms.Resize,this.handleCancel),this.windowListeners.add(Ms.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ms.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:i}=this.props,r=t.node.current;r&&fC(r),i(qs)}handleKeyDown(t){if(ep(t)){const{active:i,context:r,options:o}=this.props,{keyboardCodes:c=pC,coordinateGetter:u=tR,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}:qs;this.referenceCoordinates||(this.referenceCoordinates=_);const b=u(t,{active:i,context:r.current,currentCoordinates:_});if(b){const w=wf(b,_),x={x:0,y:0},{scrollableAncestors:C}=r.current;for(const N of C){const L=t.code,{isTop:M,isRight:U,isLeft:P,isBottom:H,maxScroll:K,minScroll:ee}=dC(N),j=XD(N),J={x:Math.min(L===zt.Right?j.right-j.width/2:j.right,Math.max(L===zt.Right?j.left:j.left+j.width/2,b.x)),y:Math.min(L===zt.Down?j.bottom-j.height/2:j.bottom,Math.max(L===zt.Down?j.top:j.top+j.height/2,b.y))},fe=L===zt.Right&&!U||L===zt.Left&&!P,ie=L===zt.Down&&!H||L===zt.Up&&!M;if(fe&&J.x!==b.x){const te=N.scrollLeft+w.x,Y=L===zt.Right&&te<=K.x||L===zt.Left&&te>=ee.x;if(Y&&!w.y){N.scrollTo({left:te,behavior:f});return}Y?x.x=N.scrollLeft-te:x.x=L===zt.Right?N.scrollLeft-K.x:N.scrollLeft-ee.x,x.x&&N.scrollBy({left:-x.x,behavior:f});break}else if(ie&&J.y!==b.y){const te=N.scrollTop+w.y,Y=L===zt.Down&&te<=K.y||L===zt.Up&&te>=ee.y;if(Y&&!w.x){N.scrollTo({top:te,behavior:f});return}Y?x.y=N.scrollTop-te:x.y=L===zt.Down?N.scrollTop-K.y:N.scrollTop-ee.y,x.y&&N.scrollBy({top:-x.y,behavior:f});break}}this.handleMove(t,ac(wf(b,this.referenceCoordinates),x))}}}handleMove(t,i){const{onMove:r}=this.props;t.preventDefault(),r(i)}handleEnd(t){const{onEnd:i}=this.props;t.preventDefault(),this.detach(),i()}handleCancel(t){const{onCancel:i}=this.props;t.preventDefault(),this.detach(),i()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}mC.activators=[{eventName:"onKeyDown",handler:(e,t,i)=>{let{keyboardCodes:r=pC,onActivation:o}=t,{active:c}=i;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 Dw(e){return!!(e&&"distance"in e)}function Rw(e){return!!(e&&"delay"in e)}class pb{constructor(t,i,r){var o;r===void 0&&(r=JD(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=i;const{event:c}=t,{target:u}=c;this.props=t,this.events=i,this.document=vc(u),this.documentListeners=new Pu(this.document),this.listeners=new Pu(r),this.windowListeners=new Pu(Di(u)),this.initialCoordinates=(o=xf(c))!=null?o:qs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:i,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(Ms.Resize,this.handleCancel),this.windowListeners.add(Ms.DragStart,Ew),this.windowListeners.add(Ms.VisibilityChange,this.handleCancel),this.windowListeners.add(Ms.ContextMenu,Ew),this.documentListeners.add(Ms.Keydown,this.handleKeydown),i){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Rw(i)){this.timeoutId=setTimeout(this.handleStart,i.delay),this.handlePending(i);return}if(Dw(i)){this.handlePending(i);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,i){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,i)}handleStart(){const{initialCoordinates:t}=this,{onStart:i}=this.props;t&&(this.activated=!0,this.documentListeners.add(Ms.Click,eR,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ms.SelectionChange,this.removeTextSelection),i(t))}handleMove(t){var i;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:f}}=c;if(!o)return;const g=(i=xf(t))!=null?i:qs,p=wf(o,g);if(!r&&f){if(Dw(f)){if(f.tolerance!=null&&xg(p,f.tolerance))return this.handleCancel();if(xg(p,f.distance))return this.handleStart()}if(Rw(f)&&xg(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:i}=this.props;this.detach(),this.activated||t(this.props.active),i()}handleCancel(){const{onAbort:t,onCancel:i}=this.props;this.detach(),this.activated||t(this.props.active),i()}handleKeydown(t){t.code===zt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const nR={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gC extends pb{constructor(t){const{event:i}=t,r=vc(i.target);super(t,nR,r)}}gC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:i}=e,{onActivation:r}=t;return!i.isPrimary||i.button!==0?!1:(r?.({event:i}),!0)}}];const iR={move:{name:"mousemove"},end:{name:"mouseup"}};var gv;(function(e){e[e.RightClick=2]="RightClick"})(gv||(gv={}));class mb extends pb{constructor(t){super(t,iR,vc(t.event.target))}}mb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:i}=e,{onActivation:r}=t;return i.button===gv.RightClick?!1:(r?.({event:i}),!0)}}];const Cg={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gb extends pb{constructor(t){super(t,Cg)}static setup(){return window.addEventListener(Cg.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Cg.move.name,t)};function t(){}}}gb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:i}=e,{onActivation:r}=t;const{touches:o}=i;return o.length>1?!1:(r?.({event:i}),!0)}}];var zu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(zu||(zu={}));var Tf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Tf||(Tf={}));function sR(e){let{acceleration:t,activator:i=zu.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:f=Tf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:_,delta:b,threshold:w}=e;const x=aR({delta:b,disabled:!c}),[C,N]=_D(),L=v.useRef({x:0,y:0}),M=v.useRef({x:0,y:0}),U=v.useMemo(()=>{switch(i){case zu.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case zu.DraggableRect:return o}},[i,o,g]),P=v.useRef(null),H=v.useCallback(()=>{const ee=P.current;if(!ee)return;const j=L.current.x*M.current.x,J=L.current.y*M.current.y;ee.scrollBy(j,J)},[]),K=v.useMemo(()=>f===Tf.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!c||!p.length||!U){N();return}for(const ee of K){if(r?.(ee)===!1)continue;const j=p.indexOf(ee),J=_[j];if(!J)continue;const{direction:fe,speed:ie}=YD(ee,J,U,t,w);for(const te of["x","y"])x[te][fe[te]]||(ie[te]=0,fe[te]=0);if(ie.x>0||ie.y>0){N(),P.current=ee,C(H,u),L.current=ie,M.current=fe;return}}L.current={x:0,y:0},M.current={x:0,y:0},N()},[t,H,r,N,c,u,JSON.stringify(U),JSON.stringify(x),C,p,K,_,JSON.stringify(w)])}const rR={x:{[ni.Backward]:!1,[ni.Forward]:!1},y:{[ni.Backward]:!1,[ni.Forward]:!1}};function aR(e){let{delta:t,disabled:i}=e;const r=Sf(t);return gd(o=>{if(i||!r||!o)return rR;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ni.Backward]:o.x[ni.Backward]||c.x===-1,[ni.Forward]:o.x[ni.Forward]||c.x===1},y:{[ni.Backward]:o.y[ni.Backward]||c.y===-1,[ni.Forward]:o.y[ni.Forward]||c.y===1}}},[i,t,r])}function oR(e,t){const i=t!=null?e.get(t):void 0,r=i?i.node.current:null;return gd(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function lR(e,t){return v.useMemo(()=>e.reduce((i,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...i,...c]},[]),[e,t])}var Zu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Zu||(Zu={}));var vv;(function(e){e.Optimized="optimized"})(vv||(vv={}));const Nw=new Map;function cR(e,t){let{dragging:i,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,_=v.useRef(e),b=L(),w=Gu(b),x=v.useCallback(function(M){M===void 0&&(M=[]),!w.current&&u(U=>U===null?M:U.concat(M.filter(P=>!U.includes(P))))},[w]),C=v.useRef(null),N=gd(M=>{if(b&&!i)return Nw;if(!M||M===Nw||_.current!==e||c!=null){const U=new Map;for(let P of e){if(!P)continue;if(c&&c.length>0&&!c.includes(P.id)&&P.rect.current){U.set(P.id,P.rect.current);continue}const H=P.node.current,K=H?new fb(g(H),H):null;P.rect.current=K,K&&U.set(P.id,K)}return U}return M},[e,c,i,b,g]);return v.useEffect(()=>{_.current=e},[e]),v.useEffect(()=>{b||x()},[i,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof f!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},f))},[f,b,x,...r]),{droppableRects:N,measureDroppableContainers:x,measuringScheduled:c!=null};function L(){switch(p){case Zu.Always:return!1;case Zu.BeforeDragging:return i;default:return!i}}}function vb(e,t){return gd(i=>e?i||(typeof t=="function"?t(e):e):null,[t,e])}function uR(e,t){return vb(e,t)}function dR(e){let{callback:t,disabled:i}=e;const r=Jf(t),o=v.useMemo(()=>{if(i||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,i]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function tp(e){let{callback:t,disabled:i}=e;const r=Jf(t),o=v.useMemo(()=>{if(i||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[i]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function hR(e){return new fb(_c(e),e)}function Mw(e,t,i){t===void 0&&(t=hR);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??i)!=null?p:null}const _=t(e);return JSON.stringify(g)===JSON.stringify(_)?g:_})}const u=dR({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=tp({callback:c});return Ws(()=>{c(),e?(f?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),u?.disconnect())},[e]),r}function fR(e){const t=vb(e);return rC(e,t)}const Aw=[];function pR(e){const t=v.useRef(e),i=gd(r=>e?r&&r!==Aw&&e&&t.current&&e.parentNode===t.current.parentNode?r:hb(e):Aw,[e]);return v.useEffect(()=>{t.current=e},[e]),i}function mR(e){const[t,i]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=wg(c.target);u&&i(f=>f?(f.set(u,mv(u)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const f=e.map(g=>{const p=wg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,mv(p)]):null}).filter(g=>g!=null);i(f.length?new Map(f):null),r.current=e}return()=>{u(e),u(c)};function u(f){f.forEach(g=>{const p=wg(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>ac(c,u),qs):hC(e):qs,[e,t])}function Lw(e,t){t===void 0&&(t=[]);const i=v.useRef(null);return v.useEffect(()=>{i.current=null},t),v.useEffect(()=>{const r=e!==qs;r&&!i.current&&(i.current=e),!r&&i.current&&(i.current=null)},[e]),i.current?wf(e,i.current):qs}function gR(e){v.useEffect(()=>{if(!Qf)return;const t=e.map(i=>{let{sensor:r}=i;return r.setup==null?void 0:r.setup()});return()=>{for(const i of t)i?.()}},e.map(t=>{let{sensor:i}=t;return i}))}function vR(e,t){return v.useMemo(()=>e.reduce((i,r)=>{let{eventName:o,handler:c}=r;return i[o]=u=>{c(u,t)},i},{}),[e,t])}function vC(e){return v.useMemo(()=>e?KD(e):null,[e])}const Ow=[];function _R(e,t){t===void 0&&(t=_c);const[i]=e,r=vC(i?Di(i):null),[o,c]=v.useState(Ow);function u(){c(()=>e.length?e.map(g=>uC(g)?r:new fb(t(g),g)):Ow)}const f=tp({callback:u});return Ws(()=>{f?.disconnect(),u(),e.forEach(g=>f?.observe(g))},[e]),o}function _C(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return md(t)?t:e}function bR(e){let{measure:t}=e;const[i,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:_}of p)if(md(_)){r(b=>{const w=t(_);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=tp({callback:o}),u=v.useCallback(p=>{const _=_C(p);c?.disconnect(),_&&c?.observe(_),r(_?t(_):null)},[t,c]),[f,g]=yf(u);return v.useMemo(()=>({nodeRef:f,rect:i,setRef:g}),[i,f,g])}const yR=[{sensor:gC,options:{}},{sensor:mC,options:{}}],SR={current:{}},Qh={draggable:{measure:Tw},droppable:{measure:Tw,strategy:Zu.WhileDragging,frequency:vv.Optimized},dragOverlay:{measure:_c}};class Hu extends Map{get(t){var i;return t!=null&&(i=super.get(t))!=null?i:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:i}=t;return!i})}getNodeFor(t){var i,r;return(i=(r=this.get(t))==null?void 0:r.node.current)!=null?i:void 0}}const wR={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Hu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Cf},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Qh,measureDroppableContainers:Cf,windowRect:null,measuringScheduled:!1},bC={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Cf,draggableNodes:new Map,over:null,measureDroppableContainers:Cf},_d=v.createContext(bC),yC=v.createContext(wR);function xR(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Hu}}}function CR(e,t){switch(t.type){case Yn.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Yn.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 Yn.DragEnd:case Yn.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Yn.RegisterDroppable:{const{element:i}=t,{id:r}=i,o=new Hu(e.droppable.containers);return o.set(r,i),{...e,droppable:{...e.droppable,containers:o}}}case Yn.SetDroppableDisabled:{const{id:i,key:r,disabled:o}=t,c=e.droppable.containers.get(i);if(!c||r!==c.key)return e;const u=new Hu(e.droppable.containers);return u.set(i,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case Yn.UnregisterDroppable:{const{id:i,key:r}=t,o=e.droppable.containers.get(i);if(!o||r!==o.key)return e;const c=new Hu(e.droppable.containers);return c.delete(i),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function kR(e){let{disabled:t}=e;const{active:i,activatorEvent:r,draggableNodes:o}=v.useContext(_d),c=Sf(r),u=Sf(i?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!ep(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=SD(_);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function SC(e,t){let{transform:i,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),i):i}function TR(e){return v.useMemo(()=>({draggable:{...Qh.draggable,...e?.draggable},droppable:{...Qh.droppable,...e?.droppable},dragOverlay:{...Qh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function ER(e){let{activeNode:t,measure:i,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:f}=typeof o=="boolean"?{x:o,y:o}:o;Ws(()=>{if(!u&&!f||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const _=i(p),b=rC(_,r);if(u||(b.x=0),f||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=oC(p);w&&w.scrollBy({top:b.y,left:b.x})}},[t,u,f,r,i])}const np=v.createContext({...qs,scaleX:1,scaleY:1});var Wa;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Wa||(Wa={}));const wC=v.memo(function(t){var i,r,o,c;let{id:u,accessibility:f,autoScroll:g=!0,children:p,sensors:_=yR,collisionDetection:b=PD,measuring:w,modifiers:x,...C}=t;const N=v.useReducer(CR,void 0,xR),[L,M]=N,[U,P]=ED(),[H,K]=v.useState(Wa.Uninitialized),ee=H===Wa.Initialized,{draggable:{active:j,nodes:J,translate:fe},droppable:{containers:ie}}=L,te=j!=null?J.get(j):null,Y=v.useRef({initial:null,translated:null}),Q=v.useMemo(()=>{var ct;return j!=null?{id:j,data:(ct=te?.data)!=null?ct:SR,rect:Y}:null},[j,te]),q=v.useRef(null),[ae,O]=v.useState(null),[R,z]=v.useState(null),ce=Gu(C,Object.values(C)),ve=vd("DndDescribedBy",u),A=v.useMemo(()=>ie.getEnabled(),[ie]),V=TR(w),{droppableRects:de,measureDroppableContainers:Z,measuringScheduled:Se}=cR(A,{dragging:ee,dependencies:[fe.x,fe.y],config:V.droppable}),ye=oR(J,j),Me=v.useMemo(()=>R?xf(R):null,[R]),He=it(),Fe=uR(ye,V.draggable.measure);ER({activeNode:j!=null?J.get(j):null,config:He.layoutShiftCompensation,initialRect:Fe,measure:V.draggable.measure});const Ue=Mw(ye,V.draggable.measure,Fe),Ve=Mw(ye?ye.parentElement:null),Ye=v.useRef({activatorEvent:null,active:null,activeNode:ye,collisionRect:null,collisions:null,droppableRects:de,draggableNodes:J,draggingNode:null,draggingNodeRect:null,droppableContainers:ie,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),D=ie.getNodeFor((i=Ye.current.over)==null?void 0:i.id),$=bR({measure:V.dragOverlay.measure}),pe=(r=$.nodeRef.current)!=null?r:ye,Ne=ee?(o=$.rect)!=null?o:Ue:null,ne=!!($.nodeRef.current&&$.rect),ge=fR(ne?null:Ue),Ee=vC(pe?Di(pe):null),Re=pR(ee?D??ye:null),Te=_R(Re),je=SC(x,{transform:{x:fe.x-ge.x,y:fe.y-ge.y,scaleX:1,scaleY:1},activatorEvent:R,active:Q,activeNodeRect:Ue,containerNodeRect:Ve,draggingNodeRect:Ne,over:Ye.current.over,overlayNodeRect:$.rect,scrollableAncestors:Re,scrollableAncestorRects:Te,windowRect:Ee}),Ze=Me?ac(Me,fe):null,Ae=mR(Re),_t=Lw(Ae),bt=Lw(Ae,[Ue]),at=ac(je,_t),ot=Ne?UD(Ne,je):null,Bt=Q&&ot?b({active:Q,collisionRect:ot,droppableRects:de,droppableContainers:A,pointerCoordinates:Ze}):null,ln=BD(Bt,"id"),[Ht,On]=v.useState(null),Ut=ne?je:ac(je,bt),kt=zD(Ut,(c=Ht?.rect)!=null?c:null,Ue),$t=v.useRef(null),At=v.useCallback((ct,Dt)=>{let{sensor:jt,options:hn}=Dt;if(q.current==null)return;const Tn=J.get(q.current);if(!Tn)return;const _e=ct.nativeEvent,ze=new jt({active:q.current,activeNode:Tn,event:_e,options:hn,context:Ye,onAbort(We){if(!J.get(We))return;const{onDragAbort:It}=ce.current,Ft={id:We};It?.(Ft),U({type:"onDragAbort",event:Ft})},onPending(We,Je,It,Ft){if(!J.get(We))return;const{onDragPending:en}=ce.current,Bn={id:We,constraint:Je,initialCoordinates:It,offset:Ft};en?.(Bn),U({type:"onDragPending",event:Bn})},onStart(We){const Je=q.current;if(Je==null)return;const It=J.get(Je);if(!It)return;const{onDragStart:Ft}=ce.current,Gn={activatorEvent:_e,active:{id:Je,data:It.data,rect:Y}};Ru.unstable_batchedUpdates(()=>{Ft?.(Gn),K(Wa.Initializing),M({type:Yn.DragStart,initialCoordinates:We,active:Je}),U({type:"onDragStart",event:Gn}),O($t.current),z(_e)})},onMove(We){M({type:Yn.DragMove,coordinates:We})},onEnd:Ie(Yn.DragEnd),onCancel:Ie(Yn.DragCancel)});$t.current=ze;function Ie(We){return async function(){const{active:It,collisions:Ft,over:Gn,scrollAdjustedTranslate:en}=Ye.current;let Bn=null;if(It&&en){const{cancelDrop:vn}=ce.current;Bn={activatorEvent:_e,active:It,collisions:Ft,delta:en,over:Gn},We===Yn.DragEnd&&typeof vn=="function"&&await Promise.resolve(vn(Bn))&&(We=Yn.DragCancel)}q.current=null,Ru.unstable_batchedUpdates(()=>{M({type:We}),K(Wa.Uninitialized),On(null),O(null),z(null),$t.current=null;const vn=We===Yn.DragEnd?"onDragEnd":"onDragCancel";if(Bn){const _n=ce.current[vn];_n?.(Bn),U({type:vn,event:Bn})}})}}},[J]),kn=v.useCallback((ct,Dt)=>(jt,hn)=>{const Tn=jt.nativeEvent,_e=J.get(hn);if(q.current!==null||!_e||Tn.dndKit||Tn.defaultPrevented)return;const ze={active:_e};ct(jt,Dt.options,ze)===!0&&(Tn.dndKit={capturedBy:Dt.sensor},q.current=hn,At(jt,Dt))},[J,At]),mi=lR(_,kn);gR(_),Ws(()=>{Ue&&H===Wa.Initializing&&K(Wa.Initialized)},[Ue,H]),v.useEffect(()=>{const{onDragMove:ct}=ce.current,{active:Dt,activatorEvent:jt,collisions:hn,over:Tn}=Ye.current;if(!Dt||!jt)return;const _e={active:Dt,activatorEvent:jt,collisions:hn,delta:{x:at.x,y:at.y},over:Tn};Ru.unstable_batchedUpdates(()=>{ct?.(_e),U({type:"onDragMove",event:_e})})},[at.x,at.y]),v.useEffect(()=>{const{active:ct,activatorEvent:Dt,collisions:jt,droppableContainers:hn,scrollAdjustedTranslate:Tn}=Ye.current;if(!ct||q.current==null||!Dt||!Tn)return;const{onDragOver:_e}=ce.current,ze=hn.get(ln),Ie=ze&&ze.rect.current?{id:ze.id,rect:ze.rect.current,data:ze.data,disabled:ze.disabled}:null,We={active:ct,activatorEvent:Dt,collisions:jt,delta:{x:Tn.x,y:Tn.y},over:Ie};Ru.unstable_batchedUpdates(()=>{On(Ie),_e?.(We),U({type:"onDragOver",event:We})})},[ln]),Ws(()=>{Ye.current={activatorEvent:R,active:Q,activeNode:ye,collisionRect:ot,collisions:Bt,droppableRects:de,draggableNodes:J,draggingNode:pe,draggingNodeRect:Ne,droppableContainers:ie,over:Ht,scrollableAncestors:Re,scrollAdjustedTranslate:at},Y.current={initial:Ne,translated:ot}},[Q,ye,Bt,ot,J,pe,Ne,de,ie,Ht,Re,at]),sR({...He,delta:fe,draggingRect:ot,pointerCoordinates:Ze,scrollableAncestors:Re,scrollableAncestorRects:Te});const le=v.useMemo(()=>({active:Q,activeNode:ye,activeNodeRect:Ue,activatorEvent:R,collisions:Bt,containerNodeRect:Ve,dragOverlay:$,draggableNodes:J,droppableContainers:ie,droppableRects:de,over:Ht,measureDroppableContainers:Z,scrollableAncestors:Re,scrollableAncestorRects:Te,measuringConfiguration:V,measuringScheduled:Se,windowRect:Ee}),[Q,ye,Ue,R,Bt,Ve,$,J,ie,de,Ht,Z,Re,Te,V,Se,Ee]),Ge=v.useMemo(()=>({activatorEvent:R,activators:mi,active:Q,activeNodeRect:Ue,ariaDescribedById:{draggable:ve},dispatch:M,draggableNodes:J,over:Ht,measureDroppableContainers:Z}),[R,mi,Q,Ue,M,ve,J,Ht,Z]);return Nt.createElement(iC.Provider,{value:P},Nt.createElement(_d.Provider,{value:Ge},Nt.createElement(yC.Provider,{value:le},Nt.createElement(np.Provider,{value:kt},p)),Nt.createElement(kR,{disabled:f?.restoreFocus===!1})),Nt.createElement(ND,{...f,hiddenTextDescribedById:ve}));function it(){const ct=ae?.autoScrollEnabled===!1,Dt=typeof g=="object"?g.enabled===!1:g===!1,jt=ee&&!ct&&!Dt;return typeof g=="object"?{...g,enabled:jt}:{enabled:jt}}}),DR=v.createContext(null),Bw="button",RR="Draggable";function _b(e){let{id:t,data:i,disabled:r=!1,attributes:o}=e;const c=vd(RR),{activators:u,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:_,draggableNodes:b,over:w}=v.useContext(_d),{role:x=Bw,roleDescription:C="draggable",tabIndex:N=0}=o??{},L=g?.id===t,M=v.useContext(L?np:DR),[U,P]=yf(),[H,K]=yf(),ee=vR(u,t),j=Gu(i);Ws(()=>(b.set(t,{id:t,key:c,node:U,activatorNode:H,data:j}),()=>{const fe=b.get(t);fe&&fe.key===c&&b.delete(t)}),[b,t]);const J=v.useMemo(()=>({role:x,tabIndex:N,"aria-disabled":r,"aria-pressed":L&&x===Bw?!0:void 0,"aria-roledescription":C,"aria-describedby":_.draggable}),[r,x,N,L,C,_.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:J,isDragging:L,listeners:r?void 0:ee,node:U,over:w,setNodeRef:P,setActivatorNodeRef:K,transform:M}}function xC(){return v.useContext(yC)}const NR="Droppable",MR={timeout:25};function ip(e){let{data:t,disabled:i=!1,id:r,resizeObserverConfig:o}=e;const c=vd(NR),{active:u,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(_d),_=v.useRef({disabled:i}),b=v.useRef(!1),w=v.useRef(null),x=v.useRef(null),{disabled:C,updateMeasurementsFor:N,timeout:L}={...MR,...o},M=Gu(N??r),U=v.useCallback(()=>{if(!b.current){b.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{p(Array.isArray(M.current)?M.current:[M.current]),x.current=null},L)},[L]),P=tp({callback:U,disabled:C||!u}),H=v.useCallback((J,fe)=>{P&&(fe&&(P.unobserve(fe),b.current=!1),J&&P.observe(J))},[P]),[K,ee]=yf(H),j=Gu(t);return v.useEffect(()=>{!P||!K.current||(P.disconnect(),b.current=!1,P.observe(K.current))},[K,P]),v.useEffect(()=>(f({type:Yn.RegisterDroppable,element:{id:r,key:c,disabled:i,node:K,rect:w,data:j}}),()=>f({type:Yn.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{i!==_.current.disabled&&(f({type:Yn.SetDroppableDisabled,id:r,key:c,disabled:i}),_.current.disabled=i)},[r,c,i,f]),{active:u,rect:w,isOver:g?.id===r,node:K,over:g,setNodeRef:ee}}function AR(e){let{animation:t,children:i}=e;const[r,o]=v.useState(null),[c,u]=v.useState(null),f=Sf(i);return!i&&!r&&f&&o(f),Ws(()=>{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]),Nt.createElement(Nt.Fragment,null,i,r?v.cloneElement(r,{ref:u}):null)}const LR={x:0,y:0,scaleX:1,scaleY:1};function OR(e){let{children:t}=e;return Nt.createElement(_d.Provider,{value:bC},Nt.createElement(np.Provider,{value:LR},t))}const BR={position:"fixed",touchAction:"none"},jR=e=>ep(e)?"transform 250ms ease":void 0,IR=v.forwardRef((e,t)=>{let{as:i,activatorEvent:r,adjustScale:o,children:c,className:u,rect:f,style:g,transform:p,transition:_=jR}=e;if(!f)return null;const b=o?p:{...p,scaleX:1,scaleY:1},w={...BR,width:f.width,height:f.height,top:f.top,left:f.left,transform:ea.Transform.toString(b),transformOrigin:o&&r?AD(r,f):void 0,transition:typeof _=="function"?_(r):_,...g};return Nt.createElement(i,{className:u,style:w,ref:t},c)}),PR=e=>t=>{let{active:i,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]=i.node.style.getPropertyValue(f),i.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&&i.node.classList.add(u.active),u!=null&&u.dragOverlay&&r.node.classList.add(u.dragOverlay),function(){for(const[g,p]of Object.entries(o))i.node.style.setProperty(g,p);u!=null&&u.active&&i.node.classList.remove(u.active)}},zR=e=>{let{transform:{initial:t,final:i}}=e;return[{transform:ea.Transform.toString(t)},{transform:ea.Transform.toString(i)}]},HR={duration:250,easing:"ease",keyframes:zR,sideEffects:PR({styles:{active:{opacity:"0"}}})};function UR(e){let{config:t,draggableNodes:i,droppableContainers:r,measuringConfiguration:o}=e;return Jf((c,u)=>{if(t===null)return;const f=i.get(c);if(!f)return;const g=f.node.current;if(!g)return;const p=_C(u);if(!p)return;const{transform:_}=Di(u).getComputedStyle(u),b=aC(_);if(!b)return;const w=typeof t=="function"?t:$R(t);return fC(g,o.draggable.measure),w({active:{id:c,data:f.data,node:g,rect:o.draggable.measure(g)},draggableNodes:i,dragOverlay:{node:u,rect:o.dragOverlay.measure(p)},droppableContainers:r,measuringConfiguration:o,transform:b})})}function $R(e){const{duration:t,easing:i,sideEffects:r,keyframes:o}={...HR,...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},w={x:g.x-_.x,y:g.y-_.y,...b},x=o({...p,active:u,dragOverlay:f,transform:{initial:g,final:w}}),[C]=x,N=x[x.length-1];if(JSON.stringify(C)===JSON.stringify(N))return;const L=r?.({active:u,dragOverlay:f,...p}),M=f.node.animate(x,{duration:t,easing:i,fill:"forwards"});return new Promise(U=>{M.onfinish=()=>{L?.(),U()}})}}let jw=0;function FR(e){return v.useMemo(()=>{if(e!=null)return jw++,jw},[e])}const KR=Nt.memo(e=>{let{adjustScale:t=!1,children:i,dropAnimation:r,style:o,transition:c,modifiers:u,wrapperElement:f="div",className:g,zIndex:p=999}=e;const{activatorEvent:_,active:b,activeNodeRect:w,containerNodeRect:x,draggableNodes:C,droppableContainers:N,dragOverlay:L,over:M,measuringConfiguration:U,scrollableAncestors:P,scrollableAncestorRects:H,windowRect:K}=xC(),ee=v.useContext(np),j=FR(b?.id),J=SC(u,{activatorEvent:_,active:b,activeNodeRect:w,containerNodeRect:x,draggingNodeRect:L.rect,over:M,overlayNodeRect:L.rect,scrollableAncestors:P,scrollableAncestorRects:H,transform:ee,windowRect:K}),fe=vb(w),ie=UR({config:r,draggableNodes:C,droppableContainers:N,measuringConfiguration:U}),te=fe?L.setRef:void 0;return Nt.createElement(OR,null,Nt.createElement(AR,{animation:ie},b&&j?Nt.createElement(IR,{key:j,id:b.id,ref:te,as:f,activatorEvent:_,adjustScale:t,className:g,transition:c,rect:fe,style:{zIndex:p,...o},transform:J},i):null))}),WR=128,qR=512,bc=100,VR="too_many_detached_terminals",YR=64,XR=4096;function CC(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>WR)return null;const i=t.workspaces.map(GR);if(i.some(u=>u===null))return null;const r=i,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 kC(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(i=>{if(!i||typeof i!="object")return!1;const r=i.detachedTerminalIds;return Array.isArray(r)&&r.length>bc}):!1}function GR(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>qR)return null;const i=t.tabs.map(ZR);if(i.some(o=>o===null))return null;const r=tN(t.detachedTerminalIds,bc);return r===null?null:{id:t.id,title:t.title,defaultCwd:eN(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:i}}function ZR(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 i=QR(t.root);return i?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:i}:null}function QR(e){if(!e||typeof e!="object")return null;let t=0;return _v(e,1,()=>(t+=1,t<=XR))}function _v(e,t,i){if(!e||typeof e!="object"||t>YR||!i())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=_v(r.first,t+1,i),c=_v(r.second,t+1,i);return!o||!c?null:{type:"split",direction:r.direction,ratio:JR(r.ratio),first:o,second:c}}function JR(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function eN(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function tN(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const i=new Set,r=[];for(const o of e)typeof o!="string"||!o||i.has(o)||(i.add(o),r.push(o));return r}const TC=[{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"}],nN="nterminal-focus",iN=/^[A-Za-z0-9_.:-]{1,128}$/;function sN(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(nN)!=="terminal"?null:sp({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function sp(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!Iw(t.terminalId))return null;const i=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return i!==null&&!Iw(i)?null:{kind:"terminal",agentId:i,terminalId:t.terminalId}}function Iw(e){return typeof e=="string"&&iN.test(e)}const Vt="__main__",EC=128,rN=600*1e3,DC="nterminal.clientDiagnostics.v1",RC="nterminal.terminalDiagnosticsCursor.v1",rp=150,aN=24,oN=160,lN=48*1024,cN="terminal-connection-recovery";let Pw=!1,gu=null,vu=null,kg=0;function uN(){Pw||typeof window>"u"||(Pw=!0,xi("page.load",{navigation:EN(),visibility:document.visibilityState,online:navigator.onLine,viewport:OC(),standalone:TN()}),document.addEventListener("visibilitychange",()=>{xi("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{xi("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{xi("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>xi("network.online")),window.addEventListener("offline",()=>xi("network.offline")),window.addEventListener("focus",()=>xi("window.focus")),window.addEventListener("blur",()=>xi("window.blur")),window.addEventListener("error",e=>{xi("runtime.error",{message:e.message,source:DN(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{xi("runtime.unhandledrejection",{reason:RN(e.reason)})}))}function xi(e,t={}){const i={id:bN(),at:new Date().toISOString(),event:Qu(e,80),data:LC({...t,visibility:t.visibility??CN(),online:t.online??kN(),viewport:t.viewport??OC()})},r=bb();return r.push(i),vN(r.slice(-rp)),i}function bb(){try{const e=window.localStorage.getItem(DC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(_N).filter(i=>i!==null).slice(-rp):[]}catch{return[]}}async function yb(e,t=fetch){if(gu)return gu;const i=bb(),r={reason:Qu(e,80),events:i},o=JSON.stringify(r);gu=(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 gu}finally{gu=null}}function ap(){return NC().events.length>0}async function dN(e=fetch){if(vu)return vu;vu=hN(e);try{return await vu}finally{vu=null}}async function hN(e){const t=NC();if(t.events.length===0)return{outcome:"empty"};try{const i=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return i.ok?(gN(t.events),{outcome:"sent",hasMore:t.hasMore}):i.status===401||i.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function NC(){const e=MC(),t=bb().filter(o=>fN(o)&&mN(o,e)),i=[];let r=zw([]);for(const o of t){const c=[...i,o],u=zw(c);if(pN(u)>lN)break;i.push(o),r=u}return{events:i,body:r,hasMore:i.length<t.length}}function zw(e){return JSON.stringify({reason:cN,events:e})}function fN(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function pN(e){return new TextEncoder().encode(e).byteLength}function mN(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(AC(e))}function MC(){try{const e=window.localStorage.getItem(RC);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(i=>typeof i=="string").slice(-rp):[]}}catch{return null}}function gN(e){const t=e.at(-1);if(!t)return;const i=MC(),r=new Set(i?.at===t.at?i.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(AC(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-rp)};try{window.localStorage.setItem(RC,JSON.stringify(o))}catch{}}function vN(e){try{window.localStorage.setItem(DC,JSON.stringify(e))}catch{}}function _N(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:Qu(t.id,128)}:{},at:t.at.slice(0,40),event:Qu(t.event,80),...t.data&&typeof t.data=="object"?{data:LC(t.data)}:{}}}function bN(){return kg=(kg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${kg.toString(36)}`.slice(0,128)}function AC(e){if(e.id)return e.id;let t=2166136261;const i=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<i.length;r+=1)t^=i.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function LC(e){const t={};for(const[i,r]of Object.entries(e).slice(0,aN)){const o=Qu(i,64);if(!o||yN(o))continue;const c=SN(r);c!==void 0&&(t[o]=c)}return t}function yN(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function SN(e){if(typeof e=="string")return wN(e,oN);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Qu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function wN(e,t){return xN(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function xN(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 CN(){return typeof document>"u"?void 0:document.visibilityState}function kN(){return typeof navigator>"u"?void 0:navigator.onLine}function OC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function TN(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function EN(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function DN(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 RN(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const BC="nterminal.notifications.completionEnabled",Sb="nterminal.notifications.completionToastEnabled",wb="nterminal.notifications.completionToastDurationSeconds",xb="nterminal.notifications.completionToastPersistent",bv="nterminal:completion-toast-display",yv="nterminal:notification-focus",Uu=6.5,Sv=2,wv=60;function op(){return typeof window<"u"&&"Notification"in window}function Cb(){try{return window.localStorage.getItem(BC)==="true"}catch{return!1}}function Hw(e){try{window.localStorage.setItem(BC,e?"true":"false")}catch{}}function el(){return{enabled:LN(),durationSeconds:AN(),persistUntilDismissed:ON()}}function NN(e){if(typeof window<"u"){try{window.localStorage.setItem(Sb,e?"true":"false")}catch{}kb()}return el()}function Uw(e){const t=IC(e);if(typeof window<"u"){try{window.localStorage.setItem(wb,String(t))}catch{}kb()}return el()}function MN(e){if(typeof window<"u"){try{window.localStorage.setItem(xb,e?"true":"false")}catch{}kb()}return el()}function jC(e){if(typeof window>"u")return()=>{};const t=i=>{(i.key===Sb||i.key===wb||i.key===xb)&&e()};return window.addEventListener(bv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(bv,e),window.removeEventListener("storage",t)}}function yc(){return op()?window.Notification.permission:"unsupported"}function AN(){if(typeof window>"u")return Uu;try{const e=window.localStorage.getItem(wb);return e===null?Uu:IC(Number(e))}catch{return Uu}}function LN(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Sb)!=="false"}catch{return!0}}function ON(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(xb)==="true"}catch{return!1}}function IC(e){if(!Number.isFinite(e))return Uu;const t=Math.round(e*2)/2;return Math.max(Sv,Math.min(wv,t))}function kb(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(bv))}async function PC(){if(!op())return"unsupported";try{return await window.Notification.requestPermission()}catch{return yc()}}function BN(e){if(!op()||yc()!=="granted"||!Cb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",i=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=sp({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:i,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),jN(r)})}catch{}}function jN(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(yv,{detail:e}))}const $w="nterminal.push.clientId",IN=2e4,Fw=[5e3,3e4,12e4];function Gr(){try{const e=window.localStorage.getItem($w);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Cv()}`;return window.localStorage.setItem($w,t),t}catch{return`client-${Cv()}`}}function PN(){return`page-${Cv()}`}function lp(){const e=typeof window<"u"&&window.isSecureContext===!0,t=WN(),i=qN(),r=i==="mobile"||i==="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:i,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function zN(e,t){const i=lp();if(!i.supported)throw new Error(i.reason);if((yc()==="granted"?"granted":await PC())!=="granted")throw new Error("permission_denied");const o=Gr(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await YN(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:UC(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:HC(g),deviceKind:i.deviceKind,displayMode:i.displayMode,label:zC(i.deviceKind),alwaysNotify:t})}async function HN(e){const t=lp();if(!t.supported||yc()!=="granted")return!1;const i=await navigator.serviceWorker.getRegistration(),r=await i?.pushManager.getSubscription();if(!i||!r)return!1;const o=Gr(),c=await XN(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&xv(r,u.vapidPublicKey))return!1;const f=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&xv(r,f.publicKey);g||await r.unsubscribe();const p=g?r:await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:UC(f.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:HC(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:zC(t.deviceKind),alwaysNotify:!1}),!0}function UN(e){let t=!1,i=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=_=>{t||i||(i=!0,HN(e).then(b=>{r=0,b&&xi("push.subscription.reconciled",{trigger:_})}).catch(b=>{if(xi("push.subscription.reconcile_failed",{trigger:_,reason:b instanceof Error?b.message:String(b)}),!t&&r<Fw.length){const w=Fw[r++];o=window.setTimeout(()=>{o=null,u("retry")},w)}}).finally(()=>{i=!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 $N(e){const t=Gr();let i;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();i=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...i?{endpoint:i}:{}})}async function FN(e,t){await e.updatePushNotificationDevice({clientId:Gr(),alwaysNotify:t})}function KN(e){if(typeof window>"u")return()=>{};const t=Gr(),i=PN();let r=null,o=!1;const c=(p=!0)=>{const _=lp();e.updatePushPresence({clientId:t,pageId:i,visibilityState:VN(),focused:document.hasFocus(),deviceKind:_.deviceKind,displayMode:_.displayMode,browserNotificationsEnabled:Cb()&&yc()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),IN))},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 WN(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function qN(){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 zC(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function VN(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function HC(e){const t=e.toJSON(),i=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!i||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:i,auth:r}}}async function YN(e,t){const i=await e.pushManager.getSubscription();return i?xv(i,t)?i:(await i.unsubscribe(),null):null}function xv(e,t){const i=e.options.applicationServerKey;return i?$C(i)===t:!0}async function XN(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return $C(t)}function UC(e){const t="=".repeat((4-e.length%4)%4),i=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(i),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 $C(e){const t=new Uint8Array(e);let i="";for(const r of t)i+=String.fromCharCode(r);return window.btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Cv(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const GN=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function ZN(e,t,i=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:GN(e),size:24,node:t,...i.length>0?{aliases:i}:{}}}const QN=e=>{let t="",i=!1;for(const r of e){if(r==="-"||r==="_"||r<=" "){i=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=i?r.toUpperCase():r,i=!1}return t};const JN=e=>{const t=QN(e);return t.charAt(0).toUpperCase()+t.slice(1)};const kv=(...e)=>e.filter((t,i,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===i).join(" ").trim();const Fo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Tg(e){return e!=null}function eM(e,t={}){const i=t.attributeNames??{},r=w=>i[w]??w,o=e.size??e.width??Fo.width,c=e.size??e.height??Fo.height,u=e.aliases?.filter(w=>typeof w=="string"&&w.trim()!=="").map(w=>`lucide-${w}`)??[],f=[...e.name?[`lucide-${e.name}`]:[],...u],g=t.className?.split(" ").filter(Boolean)??[],p=t.includeDefaultClasses===!1?kv(...g):kv("lucide",...f,...g),_=t.absoluteStrokeWidth?Number(t.strokeWidth??Fo["stroke-width"])*Number(e.size??e.width??Fo.width)/Number(t.size??t.width??Fo.width):t.strokeWidth??Fo["stroke-width"];return["svg",{...Object.entries(Fo).reduce((w,[x,C])=>(w[r(x)]=C,w),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&Tg(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&Tg(t.width)&&{[r("width")]:t.width},..."height"in t&&Tg(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:_,...p&&{[r("class")]:p},[r("viewBox")]:`0 0 ${o} ${c}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(w=>{const[x,C,N]=w,L=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...C}:C;return N?[x,L,N]:[x,L]})]}function tM(e,t={}){return eM(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const nM=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},iM=v.createContext({}),sM=()=>v.useContext(iM),rM=v.forwardRef(({color:e,size:t,width:i,height:r,strokeWidth:o,absoluteStrokeWidth:c,nonScalingStroke:u,className:f="",children:g,iconNode:p=[],icon:_={node:p,aliases:[],size:24},...b},w)=>{const{size:x=24,strokeWidth:C=2,absoluteStrokeWidth:N=!1,nonScalingStroke:L=!1,color:M="currentColor",className:U=""}=sM()??{},P=!!g||nM(b),[H,K,ee=[]]=tM(_,{color:e??M,width:i??t??x,height:r??t??x,strokeWidth:o??C,absoluteStrokeWidth:c??N,nonScalingStroke:u??L,className:kv(U,f),hasA11yProp:P,attributes:b});return v.createElement(H,{ref:w,...K},[...ee.map(([j,J])=>v.createElement(j,J)),...Array.isArray(g)?g:[g]])});function as(e,t=[],i=[]){const r=typeof e=="string"?ZN(e,t,i):e,o=v.forwardRef(({className:c,...u},f)=>v.createElement(rM,{ref:f,icon:r,className:c,...u}));return r.name&&(o.displayName=JN(r.name)),o}const FC={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};FC.node;const aM=as(FC);const KC={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};KC.node;const oM=as(KC);const WC={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};WC.node;const lM=as(WC);const qC={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};qC.node;const VC=as(qC);const YC={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};YC.node;const cM=as(YC);const XC={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};XC.node;const GC=as(XC);const ZC={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};ZC.node;const Kw=as(ZC);const QC={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};QC.node;const uM=as(QC);const JC={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};JC.node;const dM=as(JC);const ek={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]};ek.node;const hM=as(ek);const tk={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};tk.node;const fM=as(tk);const nk={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};nk.node;const Ef=as(nk);const ik={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};ik.node;const Ww=as(ik);function Xr(e,t){const i=[Vt,...t.map(u=>u.id)],r=new Set(i),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 i)o.has(u)||c.push(u);return c}function pM(e,t){return Xr(e,t).map(i=>i===Vt?null:i)}function mM(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function gM(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const qw="Local",vM=3e4,_M=2,bM=6,sk="nterminal.serverList.viewMode.v1";function yM(){try{return window.localStorage.getItem(sk)==="list"?"list":"stats"}catch{return"stats"}}function SM(e){try{window.localStorage.setItem(sk,e)}catch{}}function wM(e,t){const i=new Map(e.map(r=>[r.id,r]));return Xr(t,e).flatMap(r=>{if(r===Vt)return[{kind:"main",id:Vt}];const o=i.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Vw(e,t){return e.length===t.length&&e.every((i,r)=>i===t[r])}function rk(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${Ls(e.value.cpuPercent)} ${Tb(e.value)}`,`MEM ${Ls(e.value.memoryPercent)} ${Jr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${Ls(e.value.diskPercent)} ${Jr(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${Ls(e.value.swapPercent)} ${Jr(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function Yw(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${Ls(e.value.cpuPercent)} (${Tb(e.value)})`,`RAM ${Ls(e.value.memoryPercent)} (${Jr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${Ls(e.value.diskPercent)} (${Jr(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${Ls(e.value.swapPercent)} (${Jr(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function xM(e,t){const i=rk(t);return`${e}${i?` — ${i}`:""}. Double-click to rename.`}function Ls(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Tb(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`:`${Tv(e.cpuPercent/100*t)}/${t} cores`}function Jr(e,t){return!Xw(e)||!Xw(t)?"–/–":CM(e,t)}function CM(e,t){const i=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=i==="GB"?1024**3:i==="MB"?1024**2:1024;return`${Tv(e/r)}/${Tv(t/r)} ${i}`}function Tv(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Xw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Lh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function kM(e){return[{label:"CPU",percent:Ls(e.cpuPercent),detail:Tb(e),tone:Lh(e.cpuPercent)},{label:"MEM",percent:Ls(e.memoryPercent),detail:Jr(e.memoryUsedBytes,e.memoryTotalBytes),tone:Lh(e.memoryPercent)},{label:"DISK",percent:Ls(e.diskPercent),detail:Jr(e.diskUsedBytes,e.diskTotalBytes),tone:Lh(e.diskPercent)},{label:"SWAP",percent:Ls(e.swapPercent),detail:Jr(e.swapUsedBytes,e.swapTotalBytes),tone:Lh(e.swapPercent)}]}function TM({entry:e}){return e?.status==="offline"?d.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?d.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t}),d.jsx("span",{className:"server-list-stat-value",children:"–"})]}),d.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):d.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:Yw(e),"aria-label":Yw(e),children:kM(e.value).map(t=>d.jsxs("span",{className:"server-list-stat-cell",children:[d.jsxs("span",{className:"server-list-stat-head",children:[d.jsx("span",{className:"server-list-stat-label",children:t.label}),d.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),d.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function Gw({api:e,activeAgentId:t,onSelectServer:i,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,onManageAccounts:u,onServerInfo:f,renderServerChildren:g,compact:p=!1}){const[_,b]=v.useState([]),[w,x]=v.useState([Vt]),[C,N]=v.useState(null),[L,M]=v.useState(null),[U,P]=v.useState(""),H=v.useRef(null),[K,ee]=v.useState(()=>yM()),[j,J]=v.useState(null),[fe,ie]=v.useState(null),[te,Y]=v.useState({}),Q=v.useRef({}),q=v.useRef(0),ae=v.useRef([]),O=v.useRef([Vt]),R=v.useRef(null);v.useEffect(()=>{ae.current=_},[_]),v.useEffect(()=>{const D=Xr(w,_);O.current=D,Vw(D,w)||x(D)},[_,w]),v.useEffect(()=>{let D=!1;return e.listAgents().then($=>{D||(b($.agents),x(Xr($.serverOrder,$.agents)))}).catch(()=>{}),e.getMainInfo().then($=>{D||N($.name)}).catch(()=>{}),()=>{D=!0}},[e,o]),v.useEffect(()=>{L&&(H.current?.focus(),H.current?.select())},[L]),v.useEffect(()=>{let D=!1;function $(){const Ne=[{key:Vt,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},..._.map(ge=>({key:ge.id,load:()=>e.getAgentStats(ge.id),probe:async()=>(await e.pingAgent(ge.id)).ok}))],ne=new Set(Ne.map(ge=>ge.key));for(const ge of Object.keys(Q.current))ne.has(ge)||delete Q.current[ge];Y(ge=>{const Ee={};for(const Re of ne)Re in ge&&(Ee[Re]=ge[Re]);return Ee});for(const ge of Ne)ge.load().then(Ee=>{D||(Q.current[ge.key]=0,Y(Re=>ne.has(ge.key)?{...Re,[ge.key]:{status:"online",value:Ee,stale:!1}}:Re))}).catch(async Ee=>{if(D)return;if(Ee instanceof Vn&&Ee.status===401&&ge.key===Vt){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(ge.key===Vt&&Ee instanceof Vn){Q.current[ge.key]=0,Y(Te=>{if(!ne.has(ge.key))return Te;const je=Te[ge.key];return{...Te,[ge.key]:{status:"online",value:je?.value??null,stale:!0}}});return}if(ge.probe)try{if(await ge.probe()){if(D)return;Q.current[ge.key]=0,Y(Te=>{if(!ne.has(ge.key))return Te;const je=Te[ge.key];return{...Te,[ge.key]:{status:"online",value:je?.value??null,stale:!0}}});return}}catch(Te){if(D)return;if(Te instanceof Vn&&Te.status===401){r?.({source:ge.key===Vt?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const Re=(Q.current[ge.key]??0)+1;Q.current[ge.key]=Re,Re>=_M&&Y(Te=>ne.has(ge.key)?{...Te,[ge.key]:{status:"offline",value:Te[ge.key]?.value??null,stale:!0}}:Te)})}$();const pe=window.setInterval($,vM);return()=>{D=!0,window.clearInterval(pe)}},[e,_,r]);function z(D){D==="main"?(P(C??""),M({kind:"main"})):(P(D.name),M({kind:"agent",id:D.id}))}async function ce(){if(!L)return;const D=U.trim(),$=L;if(M(null),$.kind==="main"){const pe=D||"";try{const Ne=await e.renameMain(pe);N(Ne.name)}catch{}}else{if(!D)return;const pe=_.find(Ne=>Ne.id===$.id)?.name;b(Ne=>Ne.map(ne=>ne.id===$.id?{...ne,name:D}:ne));try{await e.renameAgent($.id,D)}catch{pe!==void 0&&b(Ne=>Ne.map(ne=>ne.id===$.id?{...ne,name:pe}:ne))}}}function ve(){M(null)}function A(D){ee(D),SM(D)}function V(D,$,pe){if(D===$)return;const Ne=Xr(O.current,ae.current),ne=Ne.findIndex(Ae=>Ae===D),ge=Ne.findIndex(Ae=>Ae===$);if(ne<0||ge<0)return;const Ee=[...Ne],[Re]=Ee.splice(ne,1);if(!Re)return;const Te=Ee.findIndex(Ae=>Ae===$);if(Te<0)return;const je=pe==="before"?Te:Te+1;if(Ee.splice(je,0,Re),Vw(Ee,Ne))return;const Ze=q.current+1;q.current=Ze,O.current=Ee,x(Ee),e.reorderAgents(Ee).then(Ae=>{if(q.current===Ze){ae.current=Ae.agents;const _t=Xr(Ae.serverOrder,Ae.agents);O.current=_t,b(Ae.agents),x(_t)}}).catch(async()=>{if(q.current===Ze)try{const Ae=await e.listAgents();if(q.current===Ze){ae.current=Ae.agents;const _t=Xr(Ae.serverOrder,Ae.agents);O.current=_t,b(Ae.agents),x(_t)}}catch{q.current===Ze&&(O.current=Ne,x(Ne))}})}function de(D,$){const pe=Xr(O.current,ae.current),Ne=pe.findIndex(ge=>ge===D),ne=pe[Ne+$];Ne<0||!ne||V(D,ne,$<0?"before":"after")}function Z(D,$){$.pointerType==="mouse"&&$.button!==0||($.stopPropagation(),R.current={sourceId:D,pointerId:$.pointerId,startX:$.clientX,startY:$.clientY,active:!1,targetId:null,placement:"after"},$.currentTarget.setPointerCapture?.($.pointerId))}function Se(D){const $=R.current;if(!$||$.pointerId!==D.pointerId)return;const pe=Math.hypot(D.clientX-$.startX,D.clientY-$.startY);if(!$.active){if(pe<bM)return;$.active=!0,J($.sourceId)}const ne=document.elementFromPoint(D.clientX,D.clientY)?.closest("[data-server-id]"),ge=ne?.dataset.serverId??null;if(!ne||!ge||ge===$.sourceId){$.targetId=null,ie(null);return}const Ee=ne.getBoundingClientRect(),Re=D.clientY<Ee.top+Ee.height/2?"before":"after";$.targetId=ge,$.placement=Re,ie({serverId:ge,placement:Re})}function ye(D){const $=R.current;!$||$.pointerId!==D.pointerId||(D.stopPropagation(),D.currentTarget.releasePointerCapture?.(D.pointerId),R.current=null,J(null),ie(null),$.active&&$.targetId&&V($.sourceId,$.targetId,$.placement))}function Me(D){const $=R.current;$&&$.pointerId===D.pointerId&&D.currentTarget.releasePointerCapture?.(D.pointerId),R.current=null,J(null),ie(null)}const He=C?.trim()||qw,Fe=L?.kind==="main",Ue=K==="stats",Ve=wM(_,w),Ye=Ve.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:He},..._.map(D=>({agentId:D.id,label:D.name}))])},[_,He,c]),p?d.jsx("div",{className:"server-list server-list--compact",children:Ve.map(D=>{const $=D.kind==="main",pe=$?He:D.agent.name,Ne=$?Vt:D.id,ne=te[Ne],ge=rk(ne);return d.jsxs("button",{type:"button",className:`server-list-chip${($?t===null:t===D.id)?" server-list-chip--active":""}`,onClick:()=>i($?null:D.id),"aria-label":`${pe}${ge?` — ${ge}`:""}`,title:`${pe}${ge?` — ${ge}`:""}`,children:[d.jsx("span",{className:"server-list-chip-initial",children:gM(pe)}),d.jsx("span",{className:"server-list-chip-pip","data-status":mM(ne)})]},D.id)})}):d.jsxs("div",{className:`server-list server-list--${K}`,children:[d.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="list",onClick:()=>A("list"),title:"Show server names only",children:"List"}),d.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":K==="stats",onClick:()=>A("stats"),title:"Show resource usage",children:"Stats"})]}),Ve.map(D=>{const $=D.kind==="main",pe=$?He:D.agent.name,Ne=$?Vt:D.id,ne=$?t===null:t===D.id,ge=$?Fe:L?.kind==="agent"&&L.id===D.id,Ee=g?.({agentId:$?null:D.id,serverId:D.id,label:pe,active:ne}),Re=fe?.serverId===D.id&&j!==D.id?` server-list-section--drop-target server-list-section--drop-${fe.placement}`:"";return d.jsxs("section",{className:`server-list-section${Re}`,"aria-label":`${pe} server`,children:[d.jsx("div",{className:["server-list-row",j===D.id?"server-list-row--dragging":"",fe?.serverId===D.id&&j!==D.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":D.id,children:ge?d.jsxs(d.Fragment,{children:[Ye?d.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,d.jsx("form",{className:"server-list-editor",onSubmit:Te=>{Te.preventDefault(),ce()},children:d.jsx("input",{ref:H,"aria-label":$?"Rename main server":`Rename ${pe}`,value:U,onChange:Te=>P(Te.target.value),onBlur:()=>{ce()},onKeyDown:Te=>{Te.key==="Escape"&&(Te.preventDefault(),ve())},placeholder:$?qw:void 0})})]}):d.jsxs(d.Fragment,{children:[Ye?d.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":D.id,title:"Drag to reorder","aria-label":`Reorder ${pe}`,"aria-grabbed":j===D.id,onPointerDown:Te=>Z(D.id,Te),onPointerMove:Se,onPointerUp:ye,onPointerCancel:Me,onKeyDown:Te=>{(Te.key==="ArrowUp"||Te.key==="ArrowDown")&&(Te.preventDefault(),Te.stopPropagation(),de(D.id,Te.key==="ArrowUp"?-1:1))},onClick:Te=>Te.stopPropagation(),children:"::"}):null,d.jsxs("div",{className:`server-list-item${ne?" server-list-item--active":""}`,title:xM(pe,te[Ne]),children:[d.jsxs("div",{className:"server-list-item-header",children:[d.jsxs("button",{type:"button",className:"server-list-item-select server-list-item-select--header",onClick:()=>i($?null:D.id),onDoubleClick:Te=>{Te.preventDefault(),z($?"main":{id:D.id,name:pe})},children:[d.jsx("span",{className:"server-list-dot"}),d.jsx("span",{className:"server-list-name",title:$?void 0:D.agent.url??"Outbound connection to main",children:pe})]}),u?d.jsx("span",{className:"server-list-provider-actions","aria-label":`${pe} account management`,children:["codex","claude"].map(Te=>d.jsx("button",{type:"button",className:"server-list-provider-button",title:`Manage ${Te==="codex"?"Codex":"Claude"} accounts`,"aria-label":`Manage ${Te==="codex"?"Codex":"Claude"} accounts on ${pe}`,onClick:()=>u({agentId:$?null:D.id,label:pe},Te),children:d.jsx("img",{src:`/brand/${Te}.webp`,alt:""})},Te))}):null,f&&d.jsx("button",{type:"button",className:"server-list-provider-button",title:"Server information","aria-label":`Server information: ${pe}`,onClick:()=>f({agentId:$?null:D.id,label:pe}),children:d.jsx(dM,{size:17})})]}),Ue?d.jsx("button",{type:"button",className:"server-list-item-select server-list-item-select--stats",onClick:()=>i($?null:D.id),children:d.jsx(TM,{entry:te[Ne]})}):null]})]})}),Ee?d.jsx("div",{className:"server-list-children",children:Ee}):null]},D.id)})]})}function EM({provider:e,serverLabel:t,api:i,onClose:r,onLoginStarted:o,onLoginFinished:c}){const[u,f]=v.useState(null),[g,p]=v.useState(!0),[_,b]=v.useState(null),[w,x]=v.useState(null),[C,N]=v.useState(""),[L,M]=v.useState(!1),[U,P]=v.useState(null),[H,K]=v.useState(!1),[ee,j]=v.useState(()=>Date.now()),J=v.useRef(0),fe=v.useCallback(async(q=!1)=>{const ae=++J.current;q||(p(!0),x(null));try{const O=await i.getAccounts();ae===J.current&&f(O)}catch(O){ae===J.current&&!q&&x(Oh(O))}finally{ae===J.current&&!q&&p(!1)}},[i]),ie=v.useMemo(()=>u?.providers.find(q=>q.provider===e)??null,[e,u]);v.useEffect(()=>(fe(),()=>{J.current+=1}),[fe]),v.useEffect(()=>{const q=ae=>{ae.key==="Escape"&&!_&&(L?M(!1):r())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[r,_,L]),v.useEffect(()=>{const q=window.setInterval(()=>j(Date.now()),6e4);return()=>window.clearInterval(q)},[]),v.useEffect(()=>{if(!ie?.pendingLogin||_)return;const ae=window.setInterval(()=>{fe(!0)},1500);return()=>window.clearInterval(ae)},[_,ie?.pendingLogin,fe]),v.useEffect(()=>{const q=ie?.pendingLogin;!q?.ready||!q.terminalId||q.terminalId===U||H||(K(!0),c(q.terminalId).then(()=>{P(q.terminalId)}).catch(ae=>{x(Oh(ae))}).finally(()=>{K(!1)}))},[U,H,c,ie?.pendingLogin]);async function te(q,ae){const O=++J.current;p(!1),b(q),x(null);try{const R=await ae();O===J.current&&f(R)}catch(R){O===J.current&&x(Oh(R))}finally{O===J.current&&b(null)}}async function Y(){b("login"),x(null);try{const q=await i.beginAccountLogin(e);o(q.terminal),await fe()}catch(q){x(Oh(q))}finally{b(null)}}const Q=e==="codex"?"Codex":"Claude";return d.jsxs("div",{className:"account-dialog-backdrop",role:"presentation",onMouseDown:q=>{q.target===q.currentTarget&&!_&&r()},children:[d.jsxs("section",{className:"account-dialog",role:"dialog","aria-modal":"true","aria-label":`${Q} accounts on ${t}`,children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"account-dialog-title",children:[d.jsx(RM,{provider:e}),d.jsxs("div",{children:[d.jsxs("h2",{children:[Q," accounts"]}),d.jsx("p",{children:t})]})]}),d.jsx("button",{type:"button",className:"security-panel-close","aria-label":"Close accounts",onClick:r,disabled:!!_,children:"x"})]}),d.jsxs("div",{className:"account-dialog-scroll",children:[g?d.jsx("p",{className:"account-dialog-muted",children:"Loading account metadata..."}):null,!g&&ie?d.jsx(DM,{provider:e,status:ie,pendingAction:_,clock:ee,label:C,onLabelChange:N,onSelect:q=>{te(`select:${q}`,()=>i.selectAccount(e,q))},onDelete:q=>{te(`delete:${q}`,()=>i.removeAccount(e,q))},onRefresh:q=>{te(`refresh:${q}`,()=>i.refreshAccount(e,q))},onBeginLogin:()=>{Y()},onCompleteLogin:()=>{te("complete",()=>i.completeAccountLogin(e,C))},onCancelLogin:()=>{te("cancel",()=>i.cancelAccountLogin(e))},onRequestTerminate:()=>M(!0),loginPaneClosed:!ie.pendingLogin?.terminalId||U===ie.pendingLogin.terminalId,loginPaneClosing:H}):null,w?d.jsx("p",{className:"account-dialog-error",role:"alert",children:w}):null]}),d.jsxs("footer",{className:"account-dialog-footer",children:[d.jsx("button",{type:"button",onClick:()=>{fe()},disabled:g||!!_,children:"Refresh"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:!!_,children:"Close"})]})]}),L?d.jsx("div",{className:"account-terminate-backdrop",role:"presentation",onMouseDown:q=>{q.target===q.currentTarget&&!_&&M(!1)},children:d.jsxs("section",{className:"account-terminate-dialog",role:"alertdialog","aria-modal":"true","aria-label":`Exit all ${Q} sessions`,children:[d.jsxs("h3",{children:["Exit all ",Q," sessions?"]}),d.jsxs("p",{children:["This stops detected ",Q," processes on ",t,", but keeps their terminal panes open. Unsaved work in those sessions may be lost."]}),e==="codex"?d.jsx("p",{children:"The shared Codex daemon will also stop. All Codex work using that daemon is affected."}):null,d.jsxs("div",{children:[d.jsx("button",{type:"button",onClick:()=>M(!1),disabled:!!_,children:"Cancel"}),d.jsx("button",{type:"button",className:"danger-button",disabled:!!_,onClick:()=>{M(!1),te("terminate",()=>i.terminateProviderSessions(e))},children:"Exit all sessions"})]})]})}):null]})}function DM({provider:e,status:t,pendingAction:i,clock:r,label:o,onLabelChange:c,onSelect:u,onDelete:f,onRefresh:g,onBeginLogin:p,onCompleteLogin:_,onCancelLogin:b,onRequestTerminate:w,loginPaneClosed:x,loginPaneClosing:C}){const N=t.runningProcesses??[],L=t.runningPanes.length>0||N.length>0||t.processCheckUnavailable===!0,M=(e==="codex"||!t.terminationAcknowledged)&&L,U=L||t.terminationAcknowledged?d.jsxs("div",{className:"account-dialog-running",role:"status",children:[d.jsx("strong",{children:t.terminationAcknowledged?"Termination requested.":`Exit ${e==="codex"?"Codex":"Claude"} before changing accounts.`}),t.runningPanes.map(P=>d.jsxs("span",{children:[d.jsx("b",{children:P.title}),d.jsx("small",{children:P.cwd})]},P.terminalId)),N.map(P=>d.jsxs("span",{children:[d.jsxs("b",{children:[P.command," ",d.jsxs("em",{children:["PID ",P.pid]})]}),d.jsx("small",{children:P.role==="daemon"?"Shared Codex daemon / manager":"Detected provider process on this server"})]},P.pid)),t.processCheckUnavailable&&!t.terminationAcknowledged?d.jsxs("span",{children:[d.jsx("b",{children:"Process check unavailable"}),d.jsx("small",{children:"Account changes stay blocked until this server can verify provider processes."})]}):null,t.terminationAcknowledged?d.jsxs("span",{children:[d.jsx("b",{children:"Proceeding after termination request"}),d.jsx("small",{children:"You can now change accounts even if a provider process takes time to exit."})]}):null,!t.processCheckUnavailable&&L?d.jsxs("button",{type:"button",className:"danger-button",disabled:!!i,onClick:w,children:["Exit all ",e==="codex"?"Codex":"Claude"," sessions"]}):null]}):null;return t.pendingLogin?d.jsxs(d.Fragment,{children:[U,d.jsxs("div",{className:"account-dialog-section",children:[d.jsx("p",{children:t.pendingLogin.ready?C?"Sign-in completed. Closing the login terminal...":"Sign-in completed. Name this account to save it in the server vault.":"Complete sign-in in the login terminal. This dialog will continue automatically."}),t.pendingLogin.ready&&x?d.jsxs("label",{className:"account-dialog-label",children:["Account name",d.jsx("input",{value:o,onChange:P=>c(P.target.value),placeholder:`${e==="codex"?"Codex":"Claude"} account`,maxLength:80,autoFocus:!0})]}):null,d.jsxs("div",{className:"account-dialog-inline-actions",children:[t.pendingLogin.ready&&x?d.jsx("button",{type:"button",className:"primary-button",disabled:!!i,onClick:_,children:"Save account"}):null,d.jsx("button",{type:"button",className:"secondary-button",disabled:!!i,onClick:b,children:"Cancel and restore previous"})]})]})]}):d.jsxs(d.Fragment,{children:[U,d.jsxs("div",{className:"account-dialog-section",children:[d.jsxs("div",{className:"account-dialog-section-heading",children:[d.jsx("span",{children:"Saved accounts"}),d.jsx("button",{type:"button",className:"primary-button",disabled:M||!!i,onClick:p,children:"Add account"})]}),t.profiles.length===0?d.jsx("p",{className:"account-dialog-muted",children:"No saved account on this server."}):t.profiles.map(P=>{const H=P.id===t.activeProfileId;return d.jsxs("article",{className:`account-profile${H?" account-profile--active":""}`,children:[d.jsxs("div",{children:[d.jsx("strong",{children:P.label}),d.jsxs("small",{title:MM(P.expiresAt),children:[H?"Active":"Saved"," · ",NM(P.expiresAt,r)," · ",AM(P.updatedAt,r)]})]}),d.jsxs("div",{className:"account-profile-actions",children:[d.jsx("button",{type:"button",disabled:M||!!i||H,onClick:()=>u(P.id),children:"Use"}),d.jsx("button",{type:"button",disabled:H&&L||!!i,onClick:()=>g(P.id),children:"Refresh"}),d.jsx("button",{type:"button",className:"danger-button",disabled:!!i||H,onClick:()=>f(P.id),children:"Remove"})]})]},P.id)})]})]})}function RM({provider:e}){return d.jsx("img",{className:"account-provider-mark",src:`/brand/${e}.webp`,alt:""})}function NM(e,t=Date.now()){if(!e||!Number.isFinite(Date.parse(e)))return"Session expiry unavailable";const i=Math.ceil((Date.parse(e)-t)/6e4);if(i<=0)return"Session expired";const r=Math.floor(i/1440),o=Math.floor(i%1440/60),c=i%60;return`Session ${[r?`${r}d`:null,o?`${o}h`:null,`${c}m`].filter(Boolean).join(" ")} remaining`}function MM(e){return!e||!Number.isFinite(Date.parse(e))?"Session expiry timestamp unavailable":`Session expires ${new Date(e).toLocaleString()}`}function AM(e,t=Date.now()){const i=Math.max(0,Math.floor((t-Date.parse(e))/6e4));return!Number.isFinite(i)||i>1440?"Updated earlier":i===0?"Updated now":i<60?`Updated ${i}m ago`:`Updated ${Math.floor(i/60)}h ago`}function Oh(e){return e instanceof Vn?{provider_panes_running:"Exit this provider in every terminal, including SSH sessions, before changing accounts.",codex_daemon_stop_failed:"Could not stop the shared Codex daemon. No account was switched. Stop the daemon and try again.",account_operation_busy:"Another account operation is in progress. Try again shortly.",account_process_check_unavailable:"Could not verify running CLI processes. No account was switched.",account_credential_changed:"Credentials changed during refresh. Refresh the account list before trying again.",account_login_already_pending:"Finish or cancel the current sign-in first.",account_login_not_complete:"The provider login has not finished yet.",account_refresh_failed:"The provider rejected this refresh. Sign in again to update the account.",account_refresh_unavailable:"The provider refresh endpoint is temporarily unavailable.",preview_mode:"Account changes are disabled in preview mode."}[e.message]??"The account operation could not be completed.":"The account operation could not be completed."}function LM(e){const t=new Map(e.map(c=>[c.pid,{process:c,children:[],count:1,cpuPercent:c.cpuPercent,memoryBytes:c.memoryBytes}])),i=[];for(const c of t.values()){const u=t.get(c.process.ppid);u&&u!==c?u.children.push(c):i.push(c)}const r=[...i],o=new Set;for(let c=0;c<r.length;c++){const u=r[c];o.add(u.process.pid);for(const f of u.children)r.push(f)}for(const c of t.values())o.has(c.process.pid)||(c.children=[],i.push(c));for(let c=r.length-1;c>=0;c--){const u=r[c];for(const f of u.children)u.count+=f.count,u.cpuPercent+=f.cpuPercent,u.memoryBytes+=f.memoryBytes}return i}const Ev=e=>e>=1024**3?`${(e/1024**3).toFixed(1)} GiB`:`${Math.round(e/1024**2)} MiB`;function OM({api:e,label:t,main:i,favorites:r,targets:o,onClose:c,onFavorite:u,onTarget:f,getRuntimeStatus:g,targetStatus:p}){const[_,b]=v.useState(null),[w,x]=v.useState(null),[C,N]=v.useState(!0),[L,M]=v.useState(!0),[U,P]=v.useState(null),[H,K]=v.useState(!1),[ee,j]=v.useState(null),[J,fe]=v.useState(""),[ie,te]=v.useState(!1),[Y,Q]=v.useState(null),q=v.useRef(null),ae=v.useRef(c);ae.current=c;const O=v.useRef(!0);async function R(Z=!1){N(!0);try{const Se=await e.getServerExternalIp(Z);O.current&&b(Se)}catch{O.current&&b(Se=>({address:Se?.address??null,checkedAt:Se?.checkedAt??null,error:"Server unavailable. Could not retrieve IPv4."}))}finally{O.current&&N(!1)}}async function z(){M(!0),P(null);try{const Z=await e.getServerProcesses();O.current&&x(Z)}catch{O.current&&P("Could not retrieve processes. The server may be offline or need an update.")}finally{O.current&&M(!1)}}v.useEffect(()=>(O.current=!0,R(),z(),()=>{O.current=!1}),[e]),v.useEffect(()=>{const Z=document.activeElement;q.current?.focus();const Se=ye=>{if(ye.key==="Escape"){ye.preventDefault(),ye.stopImmediatePropagation(),ae.current();return}if(ye.key==="Tab"){const Me=[...q.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), summary, select")??[]].filter(Fe=>Fe.getClientRects().length>0),He=Me.indexOf(document.activeElement);Me.length&&(He<0||(ye.shiftKey?He===0:He===Me.length-1))&&(ye.preventDefault(),Me[ye.shiftKey?Me.length-1:0]?.focus()),ye.stopPropagation();return}q.current?.contains(ye.target)||(ye.preventDefault(),ye.stopImmediatePropagation())};return window.addEventListener("keydown",Se,!0),()=>{window.removeEventListener("keydown",Se,!0),Z instanceof HTMLButtonElement&&Z.isConnected&&Z.focus({preventScroll:!0})}},[]);async function ce(Z){try{await navigator.clipboard.writeText(Z),K(!1)}catch{K(!0)}}async function ve(Z){if(!(ie||!J.trim())){te(!0),Q(null);try{const Se=await e.renameServerProject(Z,J.trim());if(!O.current)return;x(ye=>ye&&{...ye,projects:ye.projects.map(Me=>Me.path===Z?{...Me,name:Se.name}:Me)}),j(null)}catch{O.current&&Q("Could not save project name.")}finally{O.current&&te(!1)}}}const A=v.useMemo(()=>w?.projects.filter(Z=>Z.category!=="services")??[],[w]),V=v.useMemo(()=>{const Z=w?.projects.filter(Se=>Se.category==="services")??[];return A.length?[...Z,{name:"Development tools",path:"",category:"tools",cpuPercent:A.reduce((Se,ye)=>Se+ye.cpuPercent,0),memoryBytes:A.reduce((Se,ye)=>Se+ye.memoryBytes,0),processes:A.flatMap(Se=>Se.processes)}]:Z},[w,A]);function de(Z){const Se=Z.path?o.filter(ye=>ye.cwd===Z.path||ye.cwd.startsWith(Z.path.replace(/\/$/,"")+"/")):[];return d.jsxs(d.Fragment,{children:[Z.category!=="services"&&d.jsxs("div",{className:"server-info-tool-name",children:[d.jsx(uM,{size:15,"aria-hidden":"true"}),d.jsx("strong",{children:Z.path?Z.name:"Shared tools"})]}),d.jsxs("div",{className:"server-info-path",children:[d.jsx("code",{children:Z.path||"Shared across projects"}),Z.path&&d.jsxs(d.Fragment,{children:[d.jsx("button",{title:"Copy project path","aria-label":"Copy project path",onClick:()=>{ce(Z.path)},children:d.jsx(Kw,{size:14})}),d.jsx("button",{disabled:L||ie,title:"Rename project","aria-label":`Rename ${Z.name}`,onClick:()=>{j(`${Z.category}:${Z.path}`),fe(Z.name),Q(null)},children:d.jsx(fM,{size:14})})]})]}),ee===`${Z.category}:${Z.path}`&&d.jsxs("form",{className:"server-info-rename",onSubmit:ye=>{ye.preventDefault(),ve(Z.path)},children:[d.jsx("input",{"aria-label":"Project display name",maxLength:80,value:J,disabled:ie,onChange:ye=>fe(ye.target.value)}),d.jsx("button",{type:"submit",title:"Save name","aria-label":"Save project name",disabled:ie||!J.trim(),children:d.jsx(VC,{size:16})}),d.jsx("button",{type:"button",title:"Cancel rename","aria-label":"Cancel rename",disabled:ie,onClick:()=>j(null),children:d.jsx(Ww,{size:16})}),Y&&d.jsx("small",{role:"alert",className:"server-info-error",children:Y})]}),Z.path&&d.jsx("div",{className:"server-info-targets",children:Se.length?Se.map(ye=>d.jsxs("button",{onClick:()=>f(ye),title:`Open ${ye.label}`,children:[d.jsx(oM,{size:14}),ye.label]},ye.terminalId)):d.jsx("button",{disabled:!0,children:p??"No open tab"})}),d.jsx(BM,{processes:Z.processes})]})}return d.jsx("div",{className:"server-info-backdrop",onMouseDown:Z=>{Z.target===Z.currentTarget&&c()},children:d.jsxs("section",{className:"server-info",role:"dialog","aria-modal":"true","aria-label":`Server information: ${t}`,tabIndex:-1,ref:q,onKeyDown:Z=>Z.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("h2",{children:t}),d.jsx("small",{children:i?"Main":"Secondary"})]}),d.jsx("button",{title:"Close","aria-label":"Close server information",onClick:c,children:d.jsx(Ww,{size:18})})]}),d.jsxs("div",{className:"server-info-body",children:[d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-ip",children:[d.jsx("h3",{title:"External IPv4",children:"IPv4"}),d.jsx("code",{title:_?.checkedAt?`Checked ${new Date(_.checkedAt).toLocaleString()}`:void 0,children:_?.address??(C?"Loading...":"Unavailable")}),d.jsxs("span",{className:"server-info-ip-actions",children:[_?.address&&d.jsx("button",{title:"Copy IPv4","aria-label":"Copy IPv4",onClick:()=>{ce(_.address)},children:d.jsx(Kw,{size:16})}),d.jsx("button",{disabled:C,title:"Refresh external IPv4","aria-label":"Refresh external IPv4",onClick:()=>{R(!0)},children:d.jsx(Ef,{size:16})})]})]}),_?.error&&d.jsx("p",{role:"status",className:"server-info-error",children:_.error})]}),d.jsxs("section",{children:[d.jsx("h3",{children:"Favorites"}),d.jsx("div",{className:"server-info-favorites",children:r.map(Z=>d.jsxs("button",{onClick:()=>u(Z),children:[d.jsx("strong",{children:Z.tabName}),d.jsxs("small",{children:[Z.workspaceName," · ",g?.(Z)?.state??"Not loaded"]}),d.jsx("span",{children:Z.providers.map(Se=>d.jsx("img",{alt:Se,src:`/brand/${Se}.webp`},Se))})]},`${Z.workspaceId}:${Z.tabId}`))}),!r.length&&d.jsx("small",{children:"No favorite tabs on this server."})]}),d.jsxs("section",{children:[d.jsxs("div",{className:"server-info-heading",children:[d.jsx("h3",{children:"Projects"}),d.jsx("button",{disabled:L||ie,title:"Refresh processes","aria-label":"Refresh processes",onClick:()=>{z()},children:d.jsx(Ef,{size:16})})]}),L&&d.jsx("p",{role:"status",children:"Sampling processes..."}),U&&d.jsx("p",{role:"alert",className:"server-info-error",children:U}),w&&d.jsxs("small",{children:["Sampled ",new Date(w.checkedAt).toLocaleTimeString()," · CPU: 100% = 1 core · Memory: summed RSS"]}),V.map(Z=>d.jsxs(ok,{className:"server-info-project",children:[d.jsxs("summary",{children:[d.jsxs("span",{className:"server-info-project-label",children:[d.jsx(GC,{className:"server-info-chevron",size:16,"aria-hidden":"true"}),d.jsx("strong",{title:Z.name,children:Z.name}),d.jsx("small",{className:"server-info-project-location",title:Z.path,children:Z.path}),d.jsx("small",{className:"server-info-project-count",title:`${Z.processes.length} processes`,children:Z.processes.length})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[Z.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Ev(Z.memoryBytes)})]})]}),d.jsx("div",{className:"server-info-project-body",children:Z.category==="services"?de(Z):A.map(Se=>d.jsx("div",{className:"server-info-tool-project",children:de(Se)},`${Se.category}:${Se.path}`))})]},`${Z.category}:${Z.path}`)),w&&!w.projects.length&&d.jsx("p",{children:"No processes found for the runtime user."})]}),H&&d.jsx("p",{role:"status",children:"Clipboard unavailable. Select the address or path to copy."})]})]})})}function BM({processes:e}){const t=v.useMemo(()=>LM(e),[e]);return d.jsx("div",{className:"server-info-process-list",children:t.map(i=>d.jsx("div",{className:"server-info-process-root",children:d.jsx(ak,{node:i})},i.process.pid))})}function ak({node:e}){const t=e.process,i=d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"server-info-process-label",children:[e.children.length?d.jsx(GC,{className:"server-info-chevron",size:14,"aria-hidden":"true"}):d.jsx("span",{className:"server-info-process-dot","aria-hidden":"true"}),d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · ",t.manager??"Unmanaged",e.count>1?` · ${e.count} processes · Total`:""]})]})]}),d.jsxs("span",{className:"server-info-metrics",title:e.count>1?"Total for this process and its descendants":"Process usage",children:[d.jsxs("span",{children:[e.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Ev(e.memoryBytes)})]})]});return e.children.length?d.jsxs(ok,{className:"server-info-process-group",children:[d.jsx("summary",{className:"server-info-process",children:i}),d.jsxs("div",{className:"server-info-process-children",children:[d.jsxs("div",{className:"server-info-process",children:[d.jsxs("span",{children:[d.jsx("strong",{children:t.name}),d.jsxs("small",{children:["PID ",t.pid," · Parent"]})]}),d.jsxs("span",{className:"server-info-metrics",children:[d.jsxs("span",{children:[t.cpuPercent.toFixed(1),"%"]}),d.jsx("span",{children:Ev(t.memoryBytes)})]})]}),e.children.map(r=>d.jsx(ak,{node:r},r.process.pid))]})]}):d.jsx("div",{className:"server-info-process",children:i})}function ok({children:e,className:t}){const[i,r]=v.useState(!1),[o,...c]=Nt.Children.toArray(e);return d.jsxs("details",{className:t,onToggle:u=>{u.target===u.currentTarget&&r(u.currentTarget.open)},children:[o,i?c:null]})}function jM({api:e}){const[t,i]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[f,g]=v.useState(null),[p,_]=v.useState(""),[b,w]=v.useState("");async function x(){try{const[M,U,P]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);i(M.devices),o(U.networks),u(P.totpEnabled),g(null)}catch(M){g(M instanceof Error?M.message:"Failed to load")}}v.useEffect(()=>{x()},[]);async function C(M){await e.revokeDevice(M),await x()}async function N(M){await e.removeNetwork(M),await x()}async function L(M){M.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),_(""),w(""),await x()}catch(U){g(U instanceof Error?U.message:"Failed to add network")}}return d.jsxs(d.Fragment,{children:[f?d.jsx("p",{className:"form-error",children:f}):null,d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted devices"}),d.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?d.jsx("p",{className:"muted",children:"No trusted devices."}):d.jsx("ul",{className:"security-list",children:t.map(M=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[M.label,M.current?d.jsx("span",{className:"security-badge",children:"this device"}):null]}),d.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(M.lastSeenAt).toLocaleString()]})]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(M.id)},children:"revoke"})]},M.id))})]}),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Trusted networks"}),d.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?d.jsx("p",{className:"muted",children:"No trusted networks."}):d.jsx("ul",{className:"security-list",children:r.map(M=>d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"security-item-label",children:M.value}),M.label!==M.value?d.jsx("span",{className:"security-item-meta",children:M.label}):null]}),d.jsx("button",{type:"button",className:"security-remove",onClick:()=>{N(M.id)},children:"remove"})]},M.id))}),d.jsxs("form",{className:"security-add-form",onSubmit:L,children:[d.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:M=>_(M.currentTarget.value),required:!0}),d.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:M=>w(M.currentTarget.value)}),d.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Two-factor authentication"}),d.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),d.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const IM=1500,Eb="nterminal.terminal.fontSize",Db="nterminal.terminal.fontFamily",Dv="nterminal:terminal-font-size",Rv="nterminal:terminal-font-family",Nv=11,Mv=20,Go=14,Df=[{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:[]}],dc="meslo";Av(dc);async function Eg(e=Go,t=dc){if(typeof document>"u"||!document.fonts)return;const i=uk(t).webFontFamilies;if(i.length===0)return;const r=Promise.all(i.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,IM)})])}function lk(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Go;const i=Math.round(t);return Math.max(Nv,Math.min(Mv,i))}function ck(e){return Df.some(t=>t.id===e)?e:dc}function Av(e){return uk(e).cssFamily}function uk(e){return Df.find(t=>t.id===e)??Df[0]}function Lv(){if(typeof window>"u")return Go;try{const e=window.localStorage.getItem(Eb);return e?lk(e):Go}catch{return Go}}function Ov(){if(typeof window>"u")return dc;try{return ck(window.localStorage.getItem(Db))}catch{return dc}}function Bh(e){const t=lk(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Eb,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Dv,{detail:t})),t}function PM(e){const t=ck(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Db,t)}catch{}return window.dispatchEvent(new CustomEvent(Rv,{detail:t})),t}function dk(e){if(typeof window>"u")return()=>{};const t=i=>{i.key===Eb&&e()};return window.addEventListener(Dv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Dv,e),window.removeEventListener("storage",t)}}function hk(e){if(typeof window>"u")return()=>{};const t=i=>{i.key===Db&&e()};return window.addEventListener(Rv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Rv,e),window.removeEventListener("storage",t)}}const Rb="nterminal.terminal.showScrollProgress",Bv="nterminal:terminal-scroll-progress",Nb="nterminal.terminal.tmuxScrollback.shell",Mb="nterminal.terminal.tmuxScrollback.agent",Ab="nterminal.terminal.tmuxScrollback.overrides",Ju="nterminal:terminal-tmux-scrollback",zM=200;function jv(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Rb)!=="false"}catch{return!0}}function HM(e){if(typeof window<"u"){try{window.localStorage.setItem(Rb,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Bv,{detail:e}))}return e}function fk(e){if(typeof window>"u")return()=>{};const t=i=>{i.key===Rb&&e()};return window.addEventListener(Bv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bv,e),window.removeEventListener("storage",t)}}function Iv(){return pk(Nb,!0)}function UM(e){return mk(Nb,e,Ju)}function Pv(){return pk(Mb,!0)}function $M(e){return mk(Mb,e,Ju)}function Jh(e){if(typeof window>"u")return()=>{};const t=i=>{(i.key===Nb||i.key===Mb||i.key===Ab)&&e()};return window.addEventListener(Ju,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ju,e),window.removeEventListener("storage",t)}}function Dg(e){const i=gk()[e];return typeof i=="boolean"?i:null}function FM(e,t){if(typeof window<"u"){try{const i=gk(),r=Object.entries(i).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-zM);window.localStorage.setItem(Ab,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Ju,{detail:{terminalId:e,enabled:t}}))}return t}function pk(e,t){if(typeof window>"u")return t;try{const i=window.localStorage.getItem(e);if(i==="true")return!0;if(i==="false")return!1}catch{}return t}function mk(e,t,i){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(i,{detail:t}))}return t}function gk(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Ab);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(i[r]=o);return i}catch{return{}}}const Lb="nterminal.shortcuts.workspace.v1",zv="nterminal:workspace-shortcuts",ed=[{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}],cp={"server.previous":un("ArrowUp",{ctrlKey:!0}),"server.next":un("ArrowDown",{ctrlKey:!0}),"tab.previous":un("ArrowLeft",{ctrlKey:!0}),"tab.next":un("ArrowRight",{ctrlKey:!0}),"tab.index":un("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":un("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":un("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":un("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":un("KeyH",{altKey:!0}),"subagents.toggle":un("KeyA",{altKey:!0}),"scrollback.toggle":un("KeyS",{altKey:!0}),"favorites.toggle":un("KeyF",{ctrlKey:!0,altKey:!0})},KM={"server.previous":un("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":un("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":un("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":un("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":un("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":un("Digit",{ctrlKey:!0,altKey:!0}),"split.right":un("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":un("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":un("KeyH",{altKey:!0}),"subagents.toggle":un("KeyA",{altKey:!0}),"scrollback.toggle":un("KeyS",{altKey:!0}),"favorites.toggle":un("KeyF",{ctrlKey:!0,altKey:!0})};function tl(){const e=bk(cp);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Lb);if(!t)return e;const i=JSON.parse(t);for(const r of ed){const o=i[r.id];if(QM(o)){const c=yk(o,r);ZM(c,KM[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Zw(){return JSON.stringify(tl())}function WM(e,t){const i=tl(),r=ed.find(o=>o.id===e);return r&&(i[e]=yk(t,r),Ob(i)),i}function qM(e){const t=tl();return t[e]={...cp[e]},Ob(t),t}function VM(){const e=bk(cp);return Ob(e),e}function $u(e){if(typeof window>"u")return()=>{};const t=i=>{i.key===Lb&&e()};return window.addEventListener(zv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zv,e),window.removeEventListener("storage",t)}}function YM(e,t){const i=xk(e);return!i||eA(i)||t.indexed&&wk(e)===null||t.requiresPrimaryModifier&&!Sk(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":i}}function vk(e){const t=tl();for(const i of ed){const r=t[i.id];if(!(!r||!JM(e,r))){if(i.indexed){if(r.code!=="Digit")continue;const o=wk(e);if(o!==null)return{id:i.id,index:o};continue}if(xk(e)===r.code)return{id:i.id,index:null}}}return null}function Fu(e){return _k(tl()[e])}function _k(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(tA(e.code)),t.join("+")}const XM=()=>Fu("split.right"),GM=()=>Fu("split.down");function un(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function bk(e){return Object.fromEntries(Object.entries(e).map(([t,i])=>[t,{...i}]))}function ZM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Ob(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Lb,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(zv))}}function yk(e,t){return t.requiresPrimaryModifier&&!Sk(e)?{...cp[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Sk(e){return e.ctrlKey||e.altKey||e.metaKey}function QM(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 JM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function wk(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 xk(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 eA(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function tA(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const i=/^Key([A-Z])$/.exec(e);if(i?.[1])return i[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 nA="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 iA(e="nterminal",t=new Date){return{reason:"permission",message:nA,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function sA(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 Ck=3600*1e3,rA="local",Hv=new Set,Ga=new Map;let io={checking:!1,hasUpdates:!1,lastCheckedAt:null},Bb=null,Ku=null,Rf=0,Ka=null;function aA(e){return Hv.add(e),()=>{Hv.delete(e)}}function Qw(){return io}function oA(e){const t=hA();Bb=e,jb(),Uv(e,t);const i=()=>{if(document.visibilityState!=="visible"||!so(e,t))return;const r=io.lastCheckedAt;(r===null||Date.now()-r>=Ck)&&Uv(e,t)};return document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i),so(e,t)&&dA()}}function lA(e,t){Ga.set(e,kk(t)),hc({...io,hasUpdates:Ib(),lastCheckedAt:Date.now()})}function Rg(e){e===void 0?Ga.clear():Ga.set(e,!1),hc({...io,hasUpdates:Ib()})}async function Uv(e,t){if(!so(e,t))return;if(Ka&&Ka.api===e&&Ka.runId===t)return Ka.promise;hc({...io,checking:!0});const i=cA(e,t).finally(()=>{Ka?.promise===i&&(Ka=null),so(e,t)&&(hc({...io,checking:!1,lastCheckedAt:Date.now()}),uA(e,t))});return Ka={api:e,runId:t,promise:i},i}async function cA(e,t){try{const i=await e.listAgents();if(!so(e,t))return;const r=[{key:rA,check:()=>e.checkUpdate()},...i.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,kk(u))}catch{o.set(c.key,Ga.get(c.key)??!1)}})),!so(e,t))return;Ga.clear();for(const[c,u]of o)Ga.set(c,u);hc({...io,hasUpdates:Ib()})}catch{}}function uA(e,t){so(e,t)&&(jb(),Ku=window.setTimeout(()=>{Ku=null,so(e,t)&&Uv(e,t)},Ck))}function dA(){Rf+=1,jb(),Bb=null,Ka=null,Ga.clear(),hc({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function jb(){Ku!==null&&(window.clearTimeout(Ku),Ku=null)}function hA(){return Rf+=1,Rf}function so(e,t){return Bb===e&&Rf===t}function kk(e){return e.updateAvailable===!0}function Ib(){return Array.from(Ga.values()).some(Boolean)}function hc(e){io=e;for(const t of Array.from(Hv))t()}const fA=e=>new Promise(t=>setTimeout(t,e));function pA({api:e,onAgentRemoved:t}){const[i,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),[w,x]=v.useState({});function C(R,z){c(ce=>({...ce,[R]:{...ce[R],...z}}))}function N(R,z){x(ce=>({...ce,[R]:{status:ce[R]?.status??null,busy:ce[R]?.busy??!1,error:ce[R]?.error??null,...z}}))}const L=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),M=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),U=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),P=R=>R.id===null?e:pr(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async z=>{if(R)return;let ce="Local";try{ce=(await e.getMainInfo()).name?.trim()||ce}catch{}if(R)return;const ve=new Map(z.agents.map(V=>[V.id,V])),A=Xr(z.serverOrder,z.agents).flatMap(V=>{if(V===Vt)return[{key:"local",id:null,name:ce}];const de=ve.get(V);return de?[{key:de.id,id:de.id,name:de.name}]:[]});r(A);for(const V of A)L(V).then(de=>C(V.key,{version:de,manualUpdate:de.manualUpdate??null})).catch(de=>C(V.key,{error:de instanceof Error?de.message:"unreachable"})),q(V)}).catch(()=>{}),()=>{R=!0}},[]);async function H(R){C(R.key,{busy:!0,status:"checking…",error:void 0});try{const z=await M(R);lA(R.key,z),C(R.key,{latestVersion:z.latestVersion,updateAvailable:z.updateAvailable,status:te(z),...z.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(z){C(R.key,{busy:!1,error:z instanceof Error?z.message:"check failed"})}}async function K(){f(!0),await Promise.all(i.map(R=>H(R))),f(!1)}async function ee(R,z){const ce=Date.now()+18e4;for(;Date.now()<ce;){await fA(3e3);try{const ve=await L(R);if(z&&ve.runningVersion!==z.runningVersion)return ve}catch{}}return null}async function j(R){let z=o[R.key]?.version;if(!z)try{z=await L(R),C(R.key,{version:z,manualUpdate:z.manualUpdate??null})}catch(A){return C(R.key,{busy:!1,error:A instanceof Error?A.message:"version check failed"}),"failed"}C(R.key,{busy:!0,status:"updating…",error:void 0});let ce;try{ce=await U(R)}catch(A){return C(R.key,{busy:!1,error:A instanceof Error?A.message:"update failed"}),"failed"}if(!ce.ok){const A=ce.manualUpdate??(sA(ce.message)?iA():null);return A?(C(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:A}),"manual"):(C(R.key,{busy:!1,status:void 0,error:ce.message}),"failed")}if(!ce.changed)return C(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Rg(R.key),"unchanged";C(R.key,{status:"restarting…"});const ve=await ee(R,z);return ve?(C(R.key,{busy:!1,version:ve,updateAvailable:!1,status:"updated",manualUpdate:ve.manualUpdate??null}),Rg(R.key),R.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(C(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function J(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){C(R.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const ce=await e.uninstallAgent(R.id);r(ve=>ve.filter(A=>A.key!==R.key)),c(ve=>{const A={...ve};return delete A[R.key],A}),Rg(R.key),t?.(R.id),p(ce.message)}catch(ce){C(R.key,{busy:!1,status:void 0,error:ce instanceof Error?ce.message:"delete failed"})}}}async function fe(){f(!0),p(null);const R=i.filter(de=>de.id!==null),z=i.find(de=>de.id===null),ce=await Promise.all(R.map(de=>j(de))),ve=ce.filter(de=>de==="failed").length;let A=ce.filter(de=>de==="manual").length,V=null;if(z&&(V=await j(z),V==="manual"&&(A+=1),V==="updated")){ve>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}ve>0&&A>0?p("Some servers failed and some need manual update. Check each marked row."):ve>0?p("Some secondary servers failed to update. Check their rows and retry."):A>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function ie(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function te(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function Y(R){const z=R?.version;return z?`npm package v${z.runningVersion}`:""}async function Q(R,z){try{await gA(z),C(R,{copiedCommand:!0}),window.setTimeout(()=>C(R,{copiedCommand:!1}),1800)}catch(ce){C(R,{error:ce instanceof Error?ce.message:"copy failed"})}}async function q(R,z=!1){try{const ce=await P(R).getCodeServerStatus(z?{checkLatest:!0}:void 0);N(R.key,{status:ce,error:null})}catch(ce){N(R.key,{error:ce instanceof Error?ce.message:"code-server status failed"})}}async function ae(R,z){if(z==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const ce=P(R);N(R.key,{busy:!0,error:null});try{if(z==="install"){const ve=await ce.installCodeServer();N(R.key,{status:ve.status})}else if(z==="update"){const ve=await ce.updateCodeServer();N(R.key,{status:ve.status})}else{const ve=await ce.uninstallCodeServer();N(R.key,{status:ve.status})}}catch(ve){N(R.key,{error:ve instanceof Error?ve.message:"code-server action failed"})}finally{N(R.key,{busy:!1})}}const O=i.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=i.filter(ce=>w[ce.key]?.status?.job?.status==="running");if(R.length===0)return;const z=window.setInterval(()=>{for(const ce of R)q(ce)},1e3);return()=>window.clearInterval(z)},[O]),d.jsxs("section",{className:"security-section",children:[d.jsx("h3",{children:"Servers"}),d.jsxs("div",{className:"update-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{K()},disabled:u,children:"Check for updates"}),d.jsx("button",{type:"button",onClick:()=>{fe()},disabled:u,children:"Update all"})]}),g?d.jsx("p",{className:"settings-status",children:g}):null,_?d.jsxs("div",{className:"server-reload-required",role:"status",children:[d.jsx("span",{children:"Main server update is ready."}),d.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,d.jsx("ul",{className:"security-list",children:i.map(R=>{const z=o[R.key],ce=Y(z),ve=z?.manualUpdate??null,A=w[R.key]??{status:null,busy:!1,error:null},V=z?.version!==void 0&&z?.updateAvailable!==!1&&!z?.busy&&!u,de=R.id!==null&&!z?.busy&&!u;return d.jsxs("li",{children:[d.jsxs("div",{className:"server-row-main",children:[d.jsxs("div",{children:[d.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?d.jsx("span",{className:"security-badge",children:"Main"}):null]}),d.jsxs("span",{className:"security-item-meta",children:[ce?`${ce} — `:"",ie(z)]})]}),ve?d.jsxs("div",{className:"server-manual-update",children:[d.jsx("span",{children:ve.message}),d.jsxs("div",{className:"server-manual-command",children:[d.jsx("code",{children:ve.command}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Q(R.key,ve.command)},children:z?.copiedCommand?"Copied":"Copy"})]})]}):null,d.jsx(mA,{status:A.status,busy:A.busy,error:A.error,onCheck:()=>{q(R,!0)},onInstall:()=>{ae(R,"install")},onUpdate:()=>{ae(R,"update")},onUninstall:()=>{ae(R,"uninstall")}})]}),d.jsxs("div",{className:"server-row-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{j(R)},disabled:!V,children:z?.busy?"…":"Update"}),R.id!==null?d.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{J(R)},disabled:!de,children:"Delete"}):null]})]},R.key)})})]})}function mA({status:e,busy:t,error:i,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,w=e===null&&!i;return d.jsxs("div",{className:"server-code-addon-inline",children:[d.jsxs("div",{className:"server-code-addon-summary",children:[d.jsx("img",{className:"server-code-addon-mark",src:"/brand/vscode.png",width:"14",height:"14",alt:"","aria-hidden":"true",draggable:!1}),d.jsxs("span",{className:"security-item-meta",children:[b?w?"checking...":_?`code-server v${e?.version??"unknown"}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),i?d.jsx("p",{className:"settings-error",children:i}):null,f?d.jsx("span",{className:"server-code-addon-job",children:f.status==="running"?`${f.action}...`:`${f.action} ${f.status}`}):null,d.jsxs("div",{className:"server-code-addon-actions","aria-label":"VS Code add-on actions",children:[d.jsx("a",{className:"server-code-addon-icon-button",href:"https://github.com/coder/code-server",target:"_blank",rel:"noreferrer",title:"Open code-server on GitHub","aria-label":"Open code-server on GitHub",children:"↗"}),_?d.jsxs(d.Fragment,{children:[e?.updateAvailable?d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:c,disabled:t||g||!b,title:"Update code-server","aria-label":"Update code-server",children:"↑"}):d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:r,disabled:t||g||!b,title:"Check code-server updates","aria-label":"Check code-server updates",children:"↻"}),d.jsx("button",{type:"button",className:"server-code-addon-icon-button server-code-addon-icon-button--delete",onClick:u,disabled:t||g,title:"Uninstall code-server","aria-label":"Uninstall code-server",children:"×"})]}):d.jsx("button",{type:"button",className:"server-code-addon-icon-button",onClick:o,disabled:!p||w||t||g||!b,title:"Install code-server","aria-label":"Install code-server",children:"↓"})]})]})}async function gA(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 jh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function vA({onClose:e,api:t,updateAvailable:i=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??Gf(),[t]),[u,f]=v.useState(()=>Lv()),[g,p]=v.useState(()=>Ov()),[_,b]=v.useState(()=>jv()),[w,x]=v.useState(()=>Iv()),[C,N]=v.useState(()=>Pv()),[L,M]=v.useState(()=>no()),[U,P]=v.useState(()=>tl()),[H,K]=v.useState(null),[ee,j]=v.useState(null),[J,fe]=v.useState("appearance"),[ie,te]=v.useState(()=>Cb()),[Y,Q]=v.useState(()=>el()),[q,ae]=v.useState(()=>yc()),[O,R]=v.useState([]),[z,ce]=v.useState([]),[ve,A]=v.useState([]),[V,de]=v.useState(5*1024*1024),[Z,Se]=v.useState(!1),[ye,Me]=v.useState(null),[He,Fe]=v.useState(null),[Ue,Ve]=v.useState(!1),[Ye,D]=v.useState(null),[$,pe]=v.useState(null),Ne=v.useRef(null),ne=v.useRef(null),ge=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),Ee=v.useMemo(()=>new Set(z),[z]),Re=!bA(z,ve),Te=v.useMemo(()=>lp(),[]),je=He?.displayMode==="standalone"&&(He.deviceKind==="mobile"||He.deviceKind==="tablet");v.useEffect(()=>dk(()=>f(Lv())),[]),v.useEffect(()=>hk(()=>p(Ov())),[]),v.useEffect(()=>fk(()=>b(jv())),[]),v.useEffect(()=>Jh(()=>{x(Iv()),N(Pv())}),[]),v.useEffect(()=>cb(()=>M(no())),[]),v.useEffect(()=>$u(()=>P(tl())),[]),v.useEffect(()=>jC(()=>Q(el())),[]),v.useEffect(()=>{if(!H)return;const le=ed.find(it=>it.id===H);if(!le)return;const Ge=it=>{if(it.preventDefault(),it.stopPropagation(),it.key==="Escape"){K(null),j(null);return}const ct=YM(it,le);if(!ct){j(_A(le));return}P(WM(H,ct)),K(null),j(null)};return window.addEventListener("keydown",Ge,!0),()=>window.removeEventListener("keydown",Ge,!0)},[H]),v.useEffect(()=>{let le=!1;return c.listNotificationAssets().then(Ge=>{le||Bt(Ge)}).catch(Ge=>{le||Me(Gl(Ge))}),()=>{le=!0}},[c]),v.useEffect(()=>{let le=!1;return c.getPushNotificationStatus(Gr()).then(Ge=>{le||(Fe(Ge.currentDevice),D(null))}).catch(Ge=>{le||D(Gl(Ge))}),()=>{le=!0}},[c]);function Ze(le){f(Bh(Number(le)))}function Ae(le){Q(Uw(Number(le)))}function _t(le){fe(le);const Ge=ne.current,it=ge.current[le];if(!Ge||!it)return;const ct=Math.max(0,Jw(it,Ge)-12);typeof Ge.scrollTo=="function"?Ge.scrollTo({top:ct,behavior:"smooth"}):Ge.scrollTop=ct}function bt(){const le=ne.current;if(!le)return;if(le.scrollTop+le.clientHeight>=le.scrollHeight-2){fe(jh[jh.length-1].id);return}let Ge="appearance";const it=le.scrollTop+Math.min(180,Math.max(48,le.clientHeight*.28));for(const ct of jh){const Dt=ge.current[ct.id];Dt&&Jw(Dt,le)<=it&&(Ge=ct.id)}fe(Ge)}function at(le){P(qM(le)),K(null),j(null)}function ot(){P(VM()),K(null),j(null)}function Bt(le){const Ge=le.assets.filter(it=>it.enabled).map(it=>it.id);R(le.assets),ce(Ge),A(Ge),de(le.maxFileBytes),Me(null)}async function ln(){if(ie){Hw(!1),te(!1);return}let le=q;le==="default"&&(le=await PC(),ae(le)),le==="granted"&&(Hw(!0),te(!0))}async function Ht(){Ve(!0),D(null),pe(null);try{if(He)await $N(c),Fe(null);else{await zN(c,!1);const le=await c.getPushNotificationStatus(Gr());Fe(le.currentDevice)}}catch(le){D(Mg(le))}finally{Ve(!1)}}async function On(le){Ve(!0),D(null),pe(null);try{await FN(c,le);const Ge=await c.getPushNotificationStatus(Gr());Fe(Ge.currentDevice)}catch(Ge){D(Mg(Ge))}finally{Ve(!1)}}async function Ut(){Ve(!0),D(null),pe(null);try{await c.testPushNotification({clientId:Gr()}),pe("Test notification accepted by the push service.")}catch(le){D(Mg(le))}finally{Ve(!1)}}async function kt(le){const Ge=le?.[0];if(Ge){if(Ge.size>V){Me(`File must be ${Ng(V)} or smaller.`),At();return}if(Ge.type!=="video/mp4"&&Ge.type!=="video/webm"){Me("Upload an MP4 or WebM video."),At();return}Se(!0),Me(null);try{await c.uploadNotificationAsset(Ge),Bt(await c.listNotificationAssets()),r?.()}catch(it){Me(Gl(it))}finally{Se(!1),At()}}}async function $t(le){Se(!0),Me(null);try{await c.deleteNotificationAsset(le),Bt(await c.listNotificationAssets()),r?.()}catch(Ge){Me(Gl(Ge))}finally{Se(!1)}}function At(){Ne.current&&(Ne.current.value="")}function kn(le,Ge){const it=new Set(z);if(Ge?it.add(le):it.delete(le),it.size===0){Me("Keep at least one toast video selected.");return}Me(null),ce(Array.from(it))}async function mi(){if(z.length===0){Me("Keep at least one toast video selected.");return}Se(!0),Me(null);try{const le=await c.updateNotificationAssetSelection({enabledAssetIds:z});Bt(le),r?.()}catch(le){Me(Gl(le))}finally{Se(!1)}}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:d.jsxs("div",{className:"security-panel settings-panel",onClick:le=>le.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{children:"Settings"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),d.jsxs("div",{className:"settings-layout",children:[d.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:jh.map(le=>d.jsxs("button",{type:"button","data-active":J===le.id?"true":"false","aria-current":J===le.id?"true":void 0,onClick:()=>_t(le.id),children:[le.label,le.id==="servers"&&i?d.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},le.id))}),d.jsxs("div",{ref:ne,className:"settings-content",onScroll:bt,children:[d.jsxs("section",{id:"settings-appearance",ref:le=>{ge.current.appearance=le},className:"security-section settings-section",children:[d.jsx("h3",{children:"Appearance"}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Theme"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),d.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:bf.map(le=>d.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===le.id,"data-active":L===le.id?"true":"false",onClick:()=>M(hD(le.id)),style:{"--settings-theme-bg":le.tokens.bg,"--settings-theme-bg-2":le.tokens.bg2,"--settings-theme-sidebar":le.tokens.bgSidebar,"--settings-theme-line":le.tokens.line,"--settings-theme-fg":le.tokens.fg,"--settings-theme-fg-2":le.tokens.fg2,"--settings-theme-accent":le.tokens.accent,"--settings-theme-xterm-bg":le.xterm.background,"--settings-theme-xterm-fg":le.xterm.foreground,"--settings-theme-xterm-selection":le.xterm.selectionBackground},children:[d.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[d.jsxs("span",{className:"settings-theme-preview-sidebar",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-main",children:[d.jsxs("span",{className:"settings-theme-preview-tabs",children:[d.jsx("span",{}),d.jsx("span",{})]}),d.jsxs("span",{className:"settings-theme-preview-terminal",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})]})]}),d.jsxs("span",{className:"settings-theme-card-copy",children:[d.jsx("strong",{children:le.label}),d.jsx("small",{children:le.description})]})]},le.id))}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font size"}),d.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),d.jsx("input",{type:"range",min:Nv,max:Mv,step:1,value:u,"aria-label":"Terminal font size",onChange:le=>Ze(le.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row",children:[d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Bh(u-1)),children:"-"}),d.jsx("input",{type:"number",min:Nv,max:Mv,step:1,value:u,"aria-label":"Terminal font size value",onChange:le=>Ze(le.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(Bh(u+1)),children:"+"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(Bh(Go)),children:"Reset"})]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Font family"}),d.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:le=>p(PM(le.currentTarget.value)),children:Df.map(le=>d.jsx("option",{value:le.id,children:le.label},le.id))})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:_,onChange:le=>b(HM(le.currentTarget.checked))}),"Show scroll progress"]}),d.jsx("div",{className:"settings-section-heading",children:d.jsxs("div",{children:[d.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),d.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:w,onChange:le=>x(UM(le.currentTarget.checked))}),"Shell panes"]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:C,onChange:le=>N($M(le.currentTarget.checked))}),"Codex/Claude panes"]})]}),d.jsxs("section",{id:"settings-shortcuts",ref:le=>{ge.current.shortcuts=le},className:"security-section settings-section",children:[d.jsxs("div",{className:"settings-section-heading",children:[d.jsx("h3",{children:"Shortcuts"}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ot,children:"Reset all"})]}),d.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),ee?d.jsx("p",{className:"settings-error",children:ee}):null,d.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ed.map(le=>{const Ge=H===le.id;return d.jsxs("li",{children:[d.jsxs("div",{children:[d.jsx("span",{className:"settings-shortcut-label",children:le.label}),d.jsx("span",{className:"settings-shortcut-group",children:le.group})]}),d.jsxs("div",{className:"settings-shortcut-actions",children:[d.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ge?"true":"false",onClick:()=>{K(le.id),j(null)},children:Ge?"Press keys…":_k(U[le.id])}),d.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>at(le.id),children:"Reset"})]})]},le.id)})})]}),d.jsxs("section",{id:"settings-notifications",ref:le=>{ge.current.notifications=le},className:"security-section settings-section",children:[d.jsx("h3",{children:"Notifications"}),op()?d.jsxs(d.Fragment,{children:[d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:ie&&q==="granted",onChange:()=>{ln()},disabled:q==="denied"}),"System notification when page is hidden"]}),q==="denied"?d.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):d.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):d.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),d.jsxs("div",{className:"settings-subsection",children:[d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:!!He,onChange:()=>{Ht()},disabled:Ue||!Te.supported}),"Installed app push notifications"]}),d.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Te.supported?null:d.jsx("p",{className:"muted",children:ef(Te.reason)}),He?d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"muted",children:["Registered as ",He.label,". Last active ",new Date(He.lastActiveAt).toLocaleString(),"."]}),d.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{Ut()},disabled:Ue,children:"Send test notification"})]}):null,je?d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:He?.alwaysNotify===!0,onChange:le=>{On(le.currentTarget.checked)},disabled:Ue||!He}),"Always notify this mobile device"]}):null,Ye?d.jsx("p",{className:"form-error",children:Ye}):null,$?d.jsx("p",{className:"muted",role:"status",children:$}):null]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:Y.enabled,onChange:le=>Q(NN(le.currentTarget.checked))}),"Show animated completion toast"]}),d.jsxs("label",{className:"settings-control",children:[d.jsx("span",{children:"Toast duration"}),d.jsx("span",{className:"settings-control-value",children:Y.persistUntilDismissed?"Until closed":`${Y.durationSeconds}s`}),d.jsx("input",{type:"range",min:Sv,max:wv,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:le=>Ae(le.currentTarget.value)})]}),d.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[d.jsx("input",{type:"number",min:Sv,max:wv,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:le=>Ae(le.currentTarget.value)}),d.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!Y.enabled||Y.persistUntilDismissed,onClick:()=>Q(Uw(Uu)),children:"Reset"})]}),d.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[d.jsx("input",{type:"checkbox",checked:Y.persistUntilDismissed,disabled:!Y.enabled,onChange:le=>Q(MN(le.currentTarget.checked))}),"Keep toast until dismissed"]}),d.jsxs("div",{className:"settings-assets-header",children:[d.jsx("span",{children:"Toast videos"}),d.jsxs("span",{children:[Ng(V)," max"]})]}),d.jsx("input",{ref:Ne,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:le=>{kt(le.currentTarget.files)}}),d.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Z,onClick:()=>Ne.current?.click(),children:"Upload video"}),ye?d.jsx("p",{className:"settings-error",children:ye}):null,O.length>0?d.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(le=>d.jsxs("li",{"data-enabled":Ee.has(le.id)?"true":"false",children:[d.jsxs("label",{className:"settings-asset-choice",children:[d.jsx("input",{type:"checkbox",checked:Ee.has(le.id),disabled:Z,"aria-label":`Use ${le.filename}`,onChange:Ge=>kn(le.id,Ge.currentTarget.checked)}),d.jsx("video",{src:le.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),d.jsxs("span",{className:"settings-asset-copy",children:[d.jsx("span",{children:le.filename}),d.jsx("small",{children:le.source==="built-in"?"Built-in":Ng(le.size)})]})]}),le.source==="uploaded"?d.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Z,"aria-label":`Delete ${le.filename}`,onClick:()=>{$t(le.id)},children:"x"}):null]},le.id))}):d.jsx("p",{className:"muted",children:"Built-in videos will be used."}),d.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Z||O.length===0||!Re,onClick:()=>{mi()},children:"Save selected videos"})]}),d.jsx("div",{id:"settings-security",ref:le=>{ge.current.security=le},className:"settings-section-group",children:d.jsx(jM,{api:c})}),d.jsx("div",{id:"settings-servers",ref:le=>{ge.current.servers=le},className:"settings-section-group",children:d.jsx(pA,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Jw(e,t){const i=e.getBoundingClientRect(),r=t.getBoundingClientRect();return i.top-r.top+t.scrollTop}function Ng(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 Gl(e){return e instanceof Error?e.message:"Request failed."}function ef(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 Mg(e){const t=Gl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?ef("not_standalone"):t==="insecure"?ef("insecure"):t==="not_mobile"?ef("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 _A(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 bA(e,t){if(e.length!==t.length)return!1;const i=new Set(t);return e.every(r=>i.has(r))}const yA="modulepreload",SA=function(e){return"/"+e},e1={},Pb=function(t,i,r){let o=Promise.resolve();if(i&&i.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(i.map(p=>{if(p=SA(p),p in e1)return;e1[p]=!0;const _=p.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const w=document.createElement("link");if(w.rel=_?"stylesheet":yA,_||(w.as="script"),w.crossOrigin="",w.href=p,f&&w.setAttribute("nonce",f),document.head.appendChild(w),_)return new Promise((x,C)=>{w.addEventListener("load",x),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${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)})},wA=v.lazy(()=>Pb(()=>import("./MarkdownPreview-DjDO4lEl.js"),__vite__mapDeps([0,1])));function xA({api:e,activeTerminalId:t,activeTerminalCwd:i,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[f,g]=v.useState(""),[p,_]=v.useState({}),[b,w]=v.useState(()=>new Set),[x,C]=v.useState(null),[N,L]=v.useState({type:"empty"}),[M,U]=v.useState("idle"),[P,H]=v.useState(null),K=v.useRef(null),ee=v.useRef(null),j=v.useRef(!1),J=v.useRef(0),fe=v.useRef(null);fe.current===null&&t&&(fe.current=t);const ie=fe.current,te=r?kA(r):t?t1(t,i):null,Y=c?[c.rootPath,f].filter(Boolean).join("/"):"",Q=x?.path??null;v.useEffect(()=>(j.current=!0,()=>{j.current=!1,J.current+=1,Ve()}),[]),v.useEffect(()=>{fe.current=t,ee.current=null,q(te)},[e]),v.useEffect(()=>{r&&te!==ee.current&&ae(r,te)},[r,te]),v.useEffect(()=>{if(r||!ie||t!==ie)return;const ne=t1(ie,i);ne!==ee.current&&O(ie,ne)},[ie,t,i,r]);async function q(ne=te){if(r){await ae(r,ne);return}await O(t,ne)}async function ae(ne,ge=te){const Ee=Ye();if(ee.current=ge,Ve(),u(null),g(""),_({}),w(new Set),C(null),L({type:"empty"}),H(null),!ne){U("idle");return}U("loading");try{const Re=await e.createFileRoot({path:ne});if(!D(Ee))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Te=await e.listFiles({rootToken:Re.rootToken,path:""});if(!D(Ee))return;ce(Te),U("idle")}catch(Re){D(Ee)&&(H(Wr(Re)),U("idle"))}}async function O(ne,ge=te){const Ee=Ye();if(ee.current=ge,Ve(),u(null),g(""),_({}),w(new Set),C(null),L({type:"empty"}),H(null),!ne){U("idle");return}U("loading");try{const Re=await e.createFileRoot({terminalId:ne});if(!D(Ee))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Te=await e.listFiles({rootToken:Re.rootToken,path:""});if(!D(Ee))return;ce(Te),U("idle")}catch(Re){if(await $(Re,Ee))return;D(Ee)&&(H(Wr(Re)),U("idle"))}}async function R(ne=f,ge=c){if(!ge)return;const Ee=Ye();U("loading"),H(null);try{const Re=await e.listFiles({rootToken:ge.rootToken,path:ne});if(!D(Ee))return;ce(Re),U("idle")}catch(Re){if(await $(Re,Ee))return;D(Ee)&&(H(Wr(Re)),U("idle"))}}async function z(){if(r){await ae(r,te);return}fe.current=t,await O(t,te)}function ce(ne){_(ge=>({...ge,[ne.path]:TA(ne.entries)}))}async function ve(ne){if(!(!Ag(ne)||!c)){if(C(ne),H(null),ne.kind==="directory"){g(ne.path),Ue(),await V(ne);return}if(g(Ko(ne.path)),ne.editable){await Z(ne);return}ne.previewKind!=="none"&&await ye(ne,ne.previewKind)}}async function A(ne){if(!(!Ag(ne)||!c)){if(C(ne),H(null),ne.kind==="directory"){g(ne.path),Ue(),await V(ne);return}if(g(Ko(ne.path)),ne.editable){await Se(ne);return}ne.previewKind!=="none"&&await ye(ne,ne.previewKind)}}async function V(ne){if(b.has(ne.path)){w(ge=>{const Ee=new Set(ge);return Ee.delete(ne.path),Ee});return}w(ge=>new Set(ge).add(ne.path)),await R(ne.path)}function de(ne,ge){ne.key==="Enter"&&(ne.preventDefault(),A(ge))}async function Z(ne){if(!c)return;const ge=Ye();U("loading"),Ve();try{const Ee=await e.readFile({rootToken:c.rootToken,path:ne.path});if(!D(ge))return;L({type:"text-preview",file:ne,read:Ee}),U("idle")}catch(Ee){if(await $(Ee,ge))return;D(ge)&&(H(Wr(Ee)),U("idle"))}}async function Se(ne){if(!c)return;const ge=Ye();U("loading");try{await o({rootToken:c.rootToken,path:ne.path,...t?{terminalId:t}:{}}),D(ge)&&U("idle")}catch(Ee){if(await $(Ee,ge))return;D(ge)&&(H(Wr(Ee)),U("idle"))}}async function ye(ne,ge){if(!c)return;const Ee=Ye();U("loading"),Ve();try{const Re=await e.previewFile({rootToken:c.rootToken,path:ne.path});if(!D(Ee))return;const Te=URL.createObjectURL(Re);if(!D(Ee)){URL.revokeObjectURL(Te);return}K.current=Te,L({type:"preview",file:ne,previewKind:ge,url:Te}),U("idle")}catch(Re){if(await $(Re,Ee))return;D(Ee)&&(H(Wr(Re)),U("idle"))}}async function Me(ne){if(!c)return;const ge=ne==="file"?"New file":"New folder",Ee=window.prompt(ge,""),Re=x?x.kind==="directory"?x.path:Ko(x.path):f,Te=n1(Ee,Re);if(Te){H(null);try{const je=await e.createFileEntry({rootToken:c.rootToken,path:Te,kind:ne});C(je.entry),await R(Re)}catch(je){if(await $(je))return;H(Wr(je))}}}async function He(){if(!c||!x)return;const ne=window.prompt("Move selected entry",x.path),ge=n1(ne,"");if(!ge||ge===x.path)return;const Ee=Ko(x.path),Re=Ko(ge);H(null);try{const Te=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:x.path,destinationPath:ge});C(Te.entry),g(Te.entry.kind==="directory"?Te.entry.path:Ko(Te.entry.path)),Ue(),await R(Ee),Re!==Ee&&await R(Re)}catch(Te){if(await $(Te))return;H(Wr(Te))}}async function Fe(){if(!c||!x)return;const ne=x.path,ge=Ko(ne);H(null);try{const Ee=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:x.path}),Re=Ee.descendantCount>0?` and ${Ee.descendantCount} nested item${Ee.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Ee.path}${Re}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:x.path,previewToken:Ee.previewToken}),C(null),g(ge),w(Te=>{const je=new Set(Te);for(const Ze of Te)(Ze===ne||Ze.startsWith(`${ne}/`))&&je.delete(Ze);return je}),Ue(),await R(ge)}catch(Ee){if(await $(Ee))return;H(Wr(Ee))}}function Ue(){J.current+=1,Ve(),L({type:"empty"})}function Ve(){K.current&&(URL.revokeObjectURL(K.current),K.current=null)}function Ye(){return J.current+=1,J.current}function D(ne){return j.current&&ne===J.current}async function $(ne,ge){return EA(ne)?(ge!==void 0&&!D(ge)||await q(te),!0):!1}function pe(ne,ge){const Ee=Ag(ne),Re=ne.kind==="directory"&&b.has(ne.path),Te=p[ne.path]??[],je={"--file-tree-depth":ge};return d.jsxs(Nt.Fragment,{children:[d.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ne.kind,"data-expanded":Re,"data-active":Q===ne.path,disabled:!Ee,style:je,"aria-expanded":ne.kind==="directory"?Re:void 0,"aria-label":`${ne.kind==="directory"?"Open folder":"Open file"} ${ne.name}`,title:ne.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ve(ne)},onDoubleClick:()=>{A(ne)},onKeyDown:Ze=>de(Ze,ne),children:[d.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ne.kind==="directory"?Re?"▾":"▸":""}),d.jsx("span",{className:"file-entry-name",children:ne.name}),d.jsx("small",{children:CA(ne)})]}),Re?d.jsx("div",{className:"file-tree-children",role:"group",children:Te.map(Ze=>pe(Ze,ge+1))}):null]},ne.path)}const Ne=p[""]??[];return d.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":M==="loading",children:[d.jsxs("header",{className:"file-explorer-header",children:[d.jsx("div",{className:"file-explorer-path",title:Y,children:Y||"No active pane"}),d.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[d.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{z()},children:"↻"}),d.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Me("file")},children:"+"}),d.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Me("directory")},children:"▣"})]})]}),P?d.jsx("div",{className:"file-explorer-alert",role:"alert",children:P}):null,d.jsxs("div",{className:"file-explorer-layout",children:[d.jsx("div",{className:"file-tree","aria-label":Y?`Files in ${Y}`:"Files",children:Ne.map(ne=>pe(ne,0))}),d.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[d.jsxs("div",{className:"file-detail-header",children:[d.jsx("strong",{children:x?.name??"detail"}),d.jsxs("div",{className:"file-detail-actions",children:[d.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!x,onClick:()=>{He()},children:"Move"}),d.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!x,onClick:()=>{Fe()},children:"Delete"})]})]}),M==="loading"?d.jsx("div",{className:"file-detail-empty",children:"loading"}):null,N.type==="empty"&&M!=="loading"?d.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,N.type==="preview"?d.jsxs("div",{className:"file-preview-frame",children:[N.previewKind==="image"?d.jsx("img",{src:N.url,alt:N.file.name}):null,N.previewKind==="pdf"?d.jsx("iframe",{src:N.url,title:N.file.name}):null]}):null,N.type==="text-preview"&&N.read.language==="markdown"?d.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${N.file.name}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:d.jsx(wA,{content:N.read.content})})}):null,N.type==="text-preview"&&N.read.language==="text"?d.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${N.file.name}`,children:N.read.content}):null]})]})]})}function Ag(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function CA(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function t1(e,t){return`${e}\0${t??""}`}function kA(e){return`workspace\0${e}`}function TA(e){return[...e].sort((t,i)=>t.kind==="directory"&&i.kind!=="directory"?-1:t.kind!=="directory"&&i.kind==="directory"?1:t.name.localeCompare(i.name))}function Ko(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function n1(e,t){if(e===null)return null;const i=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return i?!t||i.includes("/")?i:`${t}/${i}`:null}function Wr(e){return e instanceof Error?e.message:"Request failed"}function EA(e){return e instanceof Vn&&e.status===409&&e.message==="terminal_cwd_changed"}const DA=v.lazy(()=>Pb(()=>import("./MarkdownPreview-DjDO4lEl.js"),__vite__mapDeps([0,1])));function i1({api:e,editor:t,canClose:i,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),[w,x]=v.useState(!1),[C,N]=v.useState("edit"),L=v.useRef(t),M=v.useRef(t.read),U=v.useRef(t.read.content),P=v.useRef(!1),H=v.useRef(!1),K=v.useRef(0),ee=u!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(H.current=!0,()=>{H.current=!1,K.current+=1}),[]),v.useEffect(()=>{K.current+=1,P.current=!1,L.current=t,M.current=t.read,U.current=t.read.content,c(t.read),f(t.read.content),p("idle"),b(null),x(!1),N("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{M.current=o},[o]),v.useEffect(()=>{U.current=u},[u]),v.useEffect(()=>{if(u===o.content||w)return;const te=window.setInterval(()=>{!P.current&&U.current!==M.current.content&&j()},1e3);return()=>window.clearInterval(te)},[u===o.content,w,t.id]);async function j(){if(P.current)return;const te=U.current,Y=M.current;if(te===Y.content)return;const Q=L.current,q=K.current;P.current=!0,p("saving"),b(null),x(!1);try{const ae=await e.writeFile({rootToken:Q.rootToken,path:Q.path,content:te,expectedVersion:Y.version});if(!H.current||q!==K.current)return;const O={...Y,content:te,version:ae.version};M.current=O,c(O),p(U.current===te?"saved":"idle")}catch(ae){if(!H.current||q!==K.current)return;if(ae instanceof Vn&&ae.status===409){x(!0),p("idle");return}b(RA(ae)),p("idle")}finally{q===K.current&&(P.current=!1)}}const J=g==="saving"?"saving":g==="saved"?"saved":o.language,fe=o.language==="markdown",ie=fe&&C==="preview";return d.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[d.jsxs("header",{className:"editor-pane-header",children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("strong",{children:t.title}),d.jsx("span",{className:"terminal-pane-spacer"}),d.jsx("span",{className:"terminal-pane-state",children:J}),d.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ee,onClick:()=>{j()},children:"Save"}),fe?d.jsx("button",{type:"button","aria-label":`${ie?"Edit":"Preview"} ${t.title}`,onClick:()=>N(te=>te==="preview"?"edit":"preview"),children:ie?"Edit":"Preview"}):null,i?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),_?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:_}):null,w?d.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ie?d.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:d.jsx(v.Suspense,{fallback:d.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:d.jsx(DA,{content:u})})}):d.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:te=>{const Y=te.target.value;U.current=Y,f(Y),p("idle"),b(null),x(!1)}})]})}function RA(e){return e instanceof Error?e.message:"Request failed"}var NA=2,MA=1,AA=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,i=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.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(NA,Math.floor(_/e.css.cell.width)),rows:Math.max(MA,Math.floor(p/e.css.cell.height))}}};var Tk=Object.defineProperty,LA=Object.getOwnPropertyDescriptor,OA=(e,t)=>{for(var i in t)Tk(e,i,{get:t[i],enumerable:!0})},Cn=(e,t,i,r)=>{for(var o=r>1?void 0:r?LA(t,i):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,i,o):u(o))||o);return r&&o&&Tk(t,i,o),o},$e=(e,t)=>(i,r)=>t(i,r,e),s1="Terminal input",$v={get:()=>s1,set:e=>s1=e},r1="Too much output to announce, navigate to rows manually to read",Fv={get:()=>r1,set:e=>r1=e};function BA(e){return e.replace(/\r?\n/g,"\r")}function jA(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function IA(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function PA(e,t,i,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Ek(o,t,i,r)}}function Ek(e,t,i,r){e=BA(e),e=jA(e,i.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Dk(e,t,i){let r=i.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 a1(e,t,i,r,o){Dk(e,t,i),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function qa(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function up(e,t=0,i=e.length){let r="";for(let o=t;o<i;++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 zA=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)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<i;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=i)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}},HA=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let r=0,o,c,u,f,g=0,p=0;if(this.interim[0]){let w=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,N;for(;(N=this.interim[++C]&63)&&C<4;)x<<=6,x|=N;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,M=L-C;for(;p<M;){if(p>=i)return 0;if(N=e[p++],(N&192)!==128){p--,w=!0;break}else this.interim[C++]=N,x<<=6,x|=N&63}w||(L===2?x<128?p--:t[r++]=x:L===3?x<2048||x>=55296&&x<=57343||x===65279||(t[r++]=x):x<65536||x>1114111||(t[r++]=x)),this.interim.fill(0)}let _=i-4,b=p;for(;b<i;){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>=i)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>=i)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=i)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>=i)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=i)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}},Rk="",Ya=" ",bd=class Nk{constructor(){this.fg=0,this.bg=0,this.extended=new Nf}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 Nk;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}},Nf=class Mk{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 Mk(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Os=class Ak extends bd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Nf,this.combinedData=""}static fromCharData(t){let i=new Ak;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?qa(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 i=!1;if(t[1].length>2)i=!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:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},o1="di$target",Kv="di$dependencies",Lg=new Map;function UA(e){return e[Kv]||[]}function ai(e){if(Lg.has(e))return Lg.get(e);let t=function(i,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");$A(t,i,o)};return t._id=e,Lg.set(e,t),t}function $A(e,t,i){t[o1]===t?t[Kv].push({id:e,index:i}):(t[Kv]=[{id:e,index:i}],t[o1]=t)}var Ri=ai("BufferService"),Lk=ai("CoreMouseService"),rl=ai("CoreService"),FA=ai("CharsetService"),zb=ai("InstantiationService"),Ok=ai("LogService"),Ni=ai("OptionsService"),Bk=ai("OscLinkService"),KA=ai("UnicodeService"),yd=ai("DecorationService"),Wv=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new Os,u=i.getTrimmedLength(),f=-1,g=-1,p=!1;for(let _=0;_<u;_++)if(!(g===-1&&!i.hasContent(_))){if(i.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 w={start:{x:g+1,y:e},end:{x:_+(!p&&_===u-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(b);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||r.push({text:b,range:w,activate:(C,N)=>o?o.activate(C,N,w):WA(C,N),hover:(C,N)=>o?.hover?.(C,N,w),leave:(C,N)=>o?.leave?.(C,N,w)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=_,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};Wv=Cn([$e(0,Ri),$e(1,Ni),$e(2,Bk)],Wv);function WA(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var dp=ai("CharSizeService"),na=ai("CoreBrowserService"),Hb=ai("MouseService"),ia=ai("RenderService"),qA=ai("SelectionService"),jk=ai("CharacterJoinerService"),Sc=ai("ThemeService"),Ik=ai("LinkProviderService"),VA=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?l1.isErrorNoTelemetry(e)?new l1(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)}},YA=new VA;function tf(e){XA(e)||YA.onUnexpectedError(e)}var qv="Canceled";function XA(e){return e instanceof GA?!0:e instanceof Error&&e.name===qv&&e.message===qv}var GA=class extends Error{constructor(){super(qv),this.name=this.message}};function ZA(e){return new Error(`Illegal argument: ${e}`)}var l1=class Vv extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Vv)return t;let i=new Vv;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Yv=class Pk extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Pk.prototype)}};function ns(e,t=0){return e[e.length-(1+t)]}var QA;(e=>{function t(c){return c<0}e.isLessThan=t;function i(c){return c<=0}e.isLessThanOrEqual=i;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})(QA||={});function JA(e,t){let i=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(i,arguments))),o}}var zk;(e=>{function t(H){return H&&typeof H=="object"&&typeof H[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function r(){return i}e.empty=r;function*o(H){yield H}e.single=o;function c(H){return t(H)?H:o(H)}e.wrap=c;function u(H){return H||i}e.from=u;function*f(H){for(let K=H.length-1;K>=0;K--)yield H[K]}e.reverse=f;function g(H){return!H||H[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(H){return H[Symbol.iterator]().next().value}e.first=p;function _(H,K){let ee=0;for(let j of H)if(K(j,ee++))return!0;return!1}e.some=_;function b(H,K){for(let ee of H)if(K(ee))return ee}e.find=b;function*w(H,K){for(let ee of H)K(ee)&&(yield ee)}e.filter=w;function*x(H,K){let ee=0;for(let j of H)yield K(j,ee++)}e.map=x;function*C(H,K){let ee=0;for(let j of H)yield*K(j,ee++)}e.flatMap=C;function*N(...H){for(let K of H)yield*K}e.concat=N;function L(H,K,ee){let j=ee;for(let J of H)j=K(j,J);return j}e.reduce=L;function*M(H,K,ee=H.length){for(K<0&&(K+=H.length),ee<0?ee+=H.length:ee>H.length&&(ee=H.length);K<ee;K++)yield H[K]}e.slice=M;function U(H,K=Number.POSITIVE_INFINITY){let ee=[];if(K===0)return[ee,H];let j=H[Symbol.iterator]();for(let J=0;J<K;J++){let fe=j.next();if(fe.done)return[ee,e.empty()];ee.push(fe.value)}return[ee,{[Symbol.iterator](){return j}}]}e.consume=U;async function P(H){let K=[];for await(let ee of H)K.push(ee);return Promise.resolve(K)}e.asyncToArray=P})(zk||={});function nl(e){if(zk.is(e)){let t=[];for(let i of e)if(i)try{i.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 eL(...e){return dn(()=>nl(e))}function dn(e){return{dispose:JA(()=>{e()})}}var Hk=class Uk{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{nl(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?Uk.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)}};Hk.DISABLE_DISPOSED_WARNING=!1;var Za=Hk,St=class{constructor(){this._store=new Za,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)}};St.None=Object.freeze({dispose(){}});var fc=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}},Zr=typeof window=="object"?window:globalThis,Xv=class Gv{constructor(t){this.element=t,this.next=Gv.Undefined,this.prev=Gv.Undefined}};Xv.Undefined=new Xv(void 0);var mn=Xv,c1=class{constructor(){this._first=mn.Undefined,this._last=mn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mn.Undefined}clear(){let e=this._first;for(;e!==mn.Undefined;){let t=e.next;e.prev=mn.Undefined,e.next=mn.Undefined,e=t}this._first=mn.Undefined,this._last=mn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new mn(e);if(this._first===mn.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(i))}}shift(){if(this._first!==mn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mn.Undefined&&e.next!==mn.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mn.Undefined&&e.next===mn.Undefined?(this._first=mn.Undefined,this._last=mn.Undefined):e.next===mn.Undefined?(this._last=this._last.prev,this._last.next=mn.Undefined):e.prev===mn.Undefined&&(this._first=this._first.next,this._first.prev=mn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==mn.Undefined;)yield e.element,e=e.next}},tL=globalThis.performance&&typeof globalThis.performance.now=="function",nL=class $k{static create(t){return new $k(t)}constructor(t){this._now=tL&&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}},pi;(e=>{e.None=()=>St.None;function t(Y,Q){return b(Y,()=>{},0,void 0,!0,void 0,Q)}e.defer=t;function i(Y){return(Q,q=null,ae)=>{let O=!1,R;return R=Y(z=>{if(!O)return R?R.dispose():O=!0,Q.call(q,z)},null,ae),O&&R.dispose(),R}}e.once=i;function r(Y,Q,q){return p((ae,O=null,R)=>Y(z=>ae.call(O,Q(z)),null,R),q)}e.map=r;function o(Y,Q,q){return p((ae,O=null,R)=>Y(z=>{Q(z),ae.call(O,z)},null,R),q)}e.forEach=o;function c(Y,Q,q){return p((ae,O=null,R)=>Y(z=>Q(z)&&ae.call(O,z),null,R),q)}e.filter=c;function u(Y){return Y}e.signal=u;function f(...Y){return(Q,q=null,ae)=>{let O=eL(...Y.map(R=>R(z=>Q.call(q,z))));return _(O,ae)}}e.any=f;function g(Y,Q,q,ae){let O=q;return r(Y,R=>(O=Q(O,R),O),ae)}e.reduce=g;function p(Y,Q){let q,ae={onWillAddFirstListener(){q=Y(O.fire,O)},onDidRemoveLastListener(){q?.dispose()}},O=new Be(ae);return Q?.add(O),O.event}function _(Y,Q){return Q instanceof Array?Q.push(Y):Q&&Q.add(Y),Y}function b(Y,Q,q=100,ae=!1,O=!1,R,z){let ce,ve,A,V=0,de,Z={leakWarningThreshold:R,onWillAddFirstListener(){ce=Y(ye=>{V++,ve=Q(ve,ye),ae&&!A&&(Se.fire(ve),ve=void 0),de=()=>{let Me=ve;ve=void 0,A=void 0,(!ae||V>1)&&Se.fire(Me),V=0},typeof q=="number"?(clearTimeout(A),A=setTimeout(de,q)):A===void 0&&(A=0,queueMicrotask(de))})},onWillRemoveListener(){O&&V>0&&de?.()},onDidRemoveLastListener(){de=void 0,ce.dispose()}},Se=new Be(Z);return z?.add(Se),Se.event}e.debounce=b;function w(Y,Q=0,q){return e.debounce(Y,(ae,O)=>ae?(ae.push(O),ae):[O],Q,void 0,!0,void 0,q)}e.accumulate=w;function x(Y,Q=(ae,O)=>ae===O,q){let ae=!0,O;return c(Y,R=>{let z=ae||!Q(R,O);return ae=!1,O=R,z},q)}e.latch=x;function C(Y,Q,q){return[e.filter(Y,Q,q),e.filter(Y,ae=>!Q(ae),q)]}e.split=C;function N(Y,Q=!1,q=[],ae){let O=q.slice(),R=Y(ve=>{O?O.push(ve):ce.fire(ve)});ae&&ae.add(R);let z=()=>{O?.forEach(ve=>ce.fire(ve)),O=null},ce=new Be({onWillAddFirstListener(){R||(R=Y(ve=>ce.fire(ve)),ae&&ae.add(R))},onDidAddFirstListener(){O&&(Q?setTimeout(z):z())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return ae&&ae.add(ce),ce.event}e.buffer=N;function L(Y,Q){return(q,ae,O)=>{let R=Q(new U);return Y(function(z){let ce=R.evaluate(z);ce!==M&&q.call(ae,ce)},void 0,O)}}e.chain=L;let M=Symbol("HaltChainable");class U{constructor(){this.steps=[]}map(Q){return this.steps.push(Q),this}forEach(Q){return this.steps.push(q=>(Q(q),q)),this}filter(Q){return this.steps.push(q=>Q(q)?q:M),this}reduce(Q,q){let ae=q;return this.steps.push(O=>(ae=Q(ae,O),ae)),this}latch(Q=(q,ae)=>q===ae){let q=!0,ae;return this.steps.push(O=>{let R=q||!Q(O,ae);return q=!1,ae=O,R?O:M}),this}evaluate(Q){for(let q of this.steps)if(Q=q(Q),Q===M)break;return Q}}function P(Y,Q,q=ae=>ae){let ae=(...ce)=>z.fire(q(...ce)),O=()=>Y.on(Q,ae),R=()=>Y.removeListener(Q,ae),z=new Be({onWillAddFirstListener:O,onDidRemoveLastListener:R});return z.event}e.fromNodeEventEmitter=P;function H(Y,Q,q=ae=>ae){let ae=(...ce)=>z.fire(q(...ce)),O=()=>Y.addEventListener(Q,ae),R=()=>Y.removeEventListener(Q,ae),z=new Be({onWillAddFirstListener:O,onDidRemoveLastListener:R});return z.event}e.fromDOMEventEmitter=H;function K(Y){return new Promise(Q=>i(Y)(Q))}e.toPromise=K;function ee(Y){let Q=new Be;return Y.then(q=>{Q.fire(q)},()=>{Q.fire(void 0)}).finally(()=>{Q.dispose()}),Q.event}e.fromPromise=ee;function j(Y,Q){return Y(q=>Q.fire(q))}e.forward=j;function J(Y,Q,q){return Q(q),Y(ae=>Q(ae))}e.runAndSubscribe=J;class fe{constructor(Q,q){this._observable=Q,this._counter=0,this._hasChanged=!1;let ae={onWillAddFirstListener:()=>{Q.addObserver(this)},onDidRemoveLastListener:()=>{Q.removeObserver(this)}};this.emitter=new Be(ae),q&&q.add(this.emitter)}beginUpdate(Q){this._counter++}handlePossibleChange(Q){}handleChange(Q,q){this._hasChanged=!0}endUpdate(Q){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ie(Y,Q){return new fe(Y,Q).emitter.event}e.fromObservable=ie;function te(Y){return(Q,q,ae)=>{let O=0,R=!1,z={beginUpdate(){O++},endUpdate(){O--,O===0&&(Y.reportChanges(),R&&(R=!1,Q.call(q)))},handlePossibleChange(){},handleChange(){R=!0}};Y.addObserver(z),Y.reportChanges();let ce={dispose(){Y.removeObserver(z)}};return ae instanceof Za?ae.add(ce):Array.isArray(ae)&&ae.push(ce),ce}}e.fromObservableLight=te})(pi||={});var Zv=class Qv{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Qv._idPool++}`,Qv.all.add(this)}start(t){this._stopWatch=new nL,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}}};Zv.all=new Set,Zv._idPool=0;var iL=Zv,sL=-1,Fk=class Kk{constructor(t,i,r=(Kk._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let r=this.threshold;if(r<=0||i<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 ${i} listeners already. MOST frequent listener (${u}):`;console.warn(f),console.warn(c);let g=new oL(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,i=0;for(let[r,o]of this._stacks)(!t||i<o)&&(t=[r,o],i=o);return t}};Fk._idPool=1;var rL=Fk,aL=class Wk{constructor(t){this.value=t}static create(){let t=new Error;return new Wk(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},oL=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},lL=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},cL=0,Og=class{constructor(e){this.value=e,this.id=cL++}},uL=2,dL,Be=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new rL(e?.onListenerError??tf,this._options?.leakWarningThreshold??sL):void 0,this._perfMon=this._options?._profName?new iL(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,i)=>{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 lL(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||tf)(g),St.None}if(this._disposed)return St.None;t&&(e=e.bind(t));let r=new Og(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=aL.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Og?(this._deliveryQueue??=new hL,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=dn(()=>{o?.(),this._removeListener(r)});return i instanceof Za?i.add(c):Array.isArray(i)&&i.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,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*uL<=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 i=this._options?.onListenerError||tf;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(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 Og)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}},hL=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Jv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Be,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Be,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let r=this.getWindowId(i);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Jv.INSTANCE=new Jv;var Ub=Jv;function fL(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Ub.INSTANCE.onDidChangeZoomLevel;function pL(e){return Ub.INSTANCE.getZoomFactor(e)}Ub.INSTANCE.onDidChangeFullscreen;var wc=typeof navigator=="object"?navigator.userAgent:"",e_=wc.indexOf("Firefox")>=0,mL=wc.indexOf("AppleWebKit")>=0,$b=wc.indexOf("Chrome")>=0,gL=!$b&&wc.indexOf("Safari")>=0;wc.indexOf("Electron/")>=0;wc.indexOf("Android")>=0;var Bg=!1;if(typeof Zr.matchMedia=="function"){let e=Zr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Zr.matchMedia("(display-mode: fullscreen)");Bg=e.matches,fL(Zr,e,({matches:i})=>{Bg&&t.matches||(Bg=i)})}var tc="en",t_=!1,n_=!1,nf=!1,qk=!1,Ih,sf=tc,u1=tc,vL,Vr,Zo=globalThis,rs;typeof Zo.vscode<"u"&&typeof Zo.vscode.process<"u"?rs=Zo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(rs=process);var _L=typeof rs?.versions?.electron=="string",bL=_L&&rs?.type==="renderer";if(typeof rs=="object"){t_=rs.platform==="win32",n_=rs.platform==="darwin",nf=rs.platform==="linux",nf&&rs.env.SNAP&&rs.env.SNAP_REVISION,rs.env.CI||rs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ih=tc,sf=tc;let e=rs.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ih=t.userLocale,u1=t.osLocale,sf=t.resolvedLanguage||tc,vL=t.languagePack?.translationsConfigFile}catch{}qk=!0}else typeof navigator=="object"&&!bL?(Vr=navigator.userAgent,t_=Vr.indexOf("Windows")>=0,n_=Vr.indexOf("Macintosh")>=0,(Vr.indexOf("Macintosh")>=0||Vr.indexOf("iPad")>=0||Vr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,nf=Vr.indexOf("Linux")>=0,Vr?.indexOf("Mobi")>=0,sf=globalThis._VSCODE_NLS_LANGUAGE||tc,Ih=navigator.language.toLowerCase(),u1=Ih):console.error("Unable to resolve platform.");var Vk=t_,vr=n_,yL=nf,d1=qk,br=Vr,Pa=sf,SL;(e=>{function t(){return Pa}e.value=t;function i(){return Pa.length===2?Pa==="en":Pa.length>=3?Pa[0]==="e"&&Pa[1]==="n"&&Pa[2]==="-":!1}e.isDefaultVariant=i;function r(){return Pa==="en"}e.isDefault=r})(SL||={});var wL=typeof Zo.postMessage=="function"&&!Zo.importScripts;(()=>{if(wL){let e=[];Zo.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===i.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),Zo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var xL=!!(br&&br.indexOf("Chrome")>=0);br&&br.indexOf("Firefox")>=0;!xL&&br&&br.indexOf("Safari")>=0;br&&br.indexOf("Edg/")>=0;br&&br.indexOf("Android")>=0;var Vl=typeof navigator=="object"?navigator:{};d1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Vl&&Vl.clipboard&&Vl.clipboard.writeText,d1||Vl&&Vl.clipboard&&Vl.clipboard.readText;var Fb=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}},jg=new Fb,h1=new Fb,f1=new Fb,CL=new Array(230),Yk;(e=>{function t(f){return jg.keyCodeToStr(f)}e.toString=t;function i(f){return jg.strToKeyCode(f)}e.fromString=i;function r(f){return h1.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return f1.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return h1.strToKeyCode(f)||f1.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 jg.keyCodeToStr(f)}e.toElectronAccelerator=u})(Yk||={});var kL=class Xk{constructor(t,i,r,o,c){this.ctrlKey=t,this.shiftKey=i,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Xk&&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",i=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new TL([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},TL=class{constructor(e){if(e.length===0)throw ZA("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 EL(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Yk.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(e_)switch(t){case 59:return 85;case 60:if(yL)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vr)return 57;break}else if(mL&&(vr&&t===93||!vr&&t===92))return 57;return CL[t]||0}var DL=vr?256:2048,RL=512,NL=1024,ML=vr?2048:256,p1=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=EL(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|=DL),this.altKey&&(t|=RL),this.shiftKey&&(t|=NL),this.metaKey&&(t|=ML),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new kL(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},m1=new WeakMap;function AL(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var LL=class{static getSameOriginWindowChain(e){let t=m1.get(e);if(!t){t=[],m1.set(e,t);let i=e,r;do r=AL(i),r?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=r;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(i+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let f=c.iframeElement.getBoundingClientRect();i+=f.top,r+=f.left}return{top:i,left:r}}},Ph=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 i=LL.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},g1=class{constructor(e,t=0,i=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let r=!1;if($b){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?e_&&!vr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")gL&&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?e_&&!vr?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()}},Gk=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),OL;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof BL?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:pi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gk})})(OL||={});var BL=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?Gk:(this._emitter||(this._emitter=new Be),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Kb=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 Yv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Yv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},jL=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Yv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=i.setInterval(()=>{e()},t);this.disposable=dn(()=>{i.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},IL;(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 i(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(u){c(u)}})}e.withAsyncBody=i})(IL||={});var v1=class Rs{static fromArray(t){return new Rs(i=>{i.emitMany(t)})}static fromPromise(t){return new Rs(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Rs(async i=>{await Promise.all(t.map(async r=>i.emitOne(await r)))})}static merge(t){return new Rs(async i=>{await Promise.all(t.map(async r=>{for await(let o of r)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Be,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await pi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new Rs(async r=>{for await(let o of t)r.emitOne(i(o))})}map(t){return Rs.map(this,t)}static filter(t,i){return new Rs(async r=>{for await(let o of t)i(o)&&r.emitOne(o)})}filter(t){return Rs.filter(this,t)}static coalesce(t){return Rs.filter(t,i=>!!i)}coalesce(){return Rs.coalesce(this)}static async toPromise(t){let i=[];for await(let r of t)i.push(r);return i}toPromise(){return Rs.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())}};v1.EMPTY=v1.fromArray([]);var{getWindow:gr,getWindowId:PL,onDidRegisterWindow:zL}=(function(){let e=new Map,t={window:Zr,disposables:new Za};e.set(Zr.vscodeWindowId,t);let i=new Be,r=new Be,o=new Be;function c(u,f){return(typeof u=="number"?e.get(u):void 0)??(f?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return St.None;let f=new Za,g={window:u,disposables:f.add(new Za)};return e.set(u.vscodeWindowId,g),f.add(dn(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),f.add(lt(u,ti.BEFORE_UNLOAD,()=>{o.fire(u)})),i.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:Zr},getDocument(u){return gr(u).document}}})(),HL=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,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 lt(e,t,i,r){return new HL(e,t,i,r)}var _1=function(e,t,i,r){return lt(e,t,i,r)},Wb,UL=class extends jL{constructor(e){super(),this.defaultTarget=e&&gr(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},b1=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){tf(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,r=new Map,o=c=>{i.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(b1.sort),u.shift().execute();r.set(c,!1)};Wb=(c,u,f=0)=>{let g=PL(c),p=new b1(u,f),_=e.get(g);return _||(_=[],e.set(g,_)),_.push(p),i.get(g)||(i.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function $L(e){let t=e.getBoundingClientRect(),i=gr(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var ti={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"},FL=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=Fi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Fi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Fi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Fi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Fi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Fi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Fi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Fi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Fi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Fi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Fi(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=Fi(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=Fi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Fi(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 Fi(e){return typeof e=="number"?`${e}px`:e}function Wu(e){return new FL(e)}var Zk=class{constructor(){this._hooks=new Za,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(dn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=gr(e)}this._hooks.add(lt(c,ti.POINTER_MOVE,u=>{if(u.buttons!==i){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(lt(c,ti.POINTER_UP,u=>this.stopMonitoring(!0)))}};function KL(e,t,i){let r=null,o=null;if(typeof i.value=="function"?(r="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(r="get",o=i.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;i[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 fr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(fr||={});var Nu=class wi extends St{constructor(){super(),this.dispatched=!1,this.targets=new c1,this.ignoreTargets=new c1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(pi.runAndSubscribe(zL,({window:t,disposables:i})=>{i.add(lt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),i.add(lt(t.document,"touchend",r=>this.onTouchEnd(t,r))),i.add(lt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Zr,disposables:this._store}))}static addTarget(t){if(!wi.isTouchDevice())return St.None;wi.INSTANCE||(wi.INSTANCE=new wi);let i=wi.INSTANCE.targets.push(t);return dn(i)}static ignoreTarget(t){if(!wi.isTouchDevice())return St.None;wi.INSTANCE||(wi.INSTANCE=new wi);let i=wi.INSTANCE.ignoreTargets.push(t);return dn(i)}static isTouchDevice(){return"ontouchstart"in Zr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=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:i,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[i],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let u=this.newGestureEvent(fr.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,i){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=i.changedTouches.length;c<u;c++){let f=i.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<wi.HOLD_DELAY&&Math.abs(g.initialPageX-ns(g.rollingPageX))<30&&Math.abs(g.initialPageY-ns(g.rollingPageY))<30){let _=this.newGestureEvent(fr.Tap,g.initialTarget);_.pageX=ns(g.rollingPageX),_.pageY=ns(g.rollingPageY),this.dispatchEvent(_)}else if(p>=wi.HOLD_DELAY&&Math.abs(g.initialPageX-ns(g.rollingPageX))<30&&Math.abs(g.initialPageY-ns(g.rollingPageY))<30){let _=this.newGestureEvent(fr.Contextmenu,g.initialTarget);_.pageX=ns(g.rollingPageX),_.pageY=ns(g.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=ns(g.rollingPageX),b=ns(g.rollingPageY),w=ns(g.rollingTimestamps)-g.rollingTimestamps[0],x=_-g.rollingPageX[0],C=b-g.rollingPageY[0],N=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,N,r,Math.abs(x)/w,x>0?1:-1,_,Math.abs(C)/w,C>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(fr.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=i,r.tapCount=0,r}dispatchEvent(t){if(t.type===fr.Tap){let i=new Date().getTime(),r=0;i-this._lastSetTapCountTime>wi.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=i,t.tapCount=r}else(t.type===fr.Change||t.type===fr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let i=[];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;i.push([o,r])}i.sort((r,o)=>r[0]-o[0]);for(let[r,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,r,o,c,u,f,g,p){this.handle=Wb(t,()=>{let _=Date.now(),b=_-r,w=0,x=0,C=!0;o+=wi.SCROLL_FRICTION*b,f+=wi.SCROLL_FRICTION*b,o>0&&(C=!1,w=c*o*b),f>0&&(C=!1,x=g*f*b);let N=this.newGestureEvent(fr.Change);N.translationX=w,N.translationY=x,i.forEach(L=>L.dispatchEvent(N)),C||this.inertia(t,i,_,o,c,u+w,f,g,p+x)})}onTouchMove(t){let i=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(fr.Change,u.initialTarget);f.translationX=c.pageX-ns(u.rollingPageX),f.translationY=c.pageY-ns(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(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Nu.SCROLL_FRICTION=-.005,Nu.HOLD_DELAY=700,Nu.CLEAR_TAP_COUNT_TIME=400,Cn([KL],Nu,"isTouchDevice",1);var WL=Nu,qb=class extends St{onclick(e,t){this._register(lt(e,ti.CLICK,i=>t(new Ph(gr(e),i))))}onmousedown(e,t){this._register(lt(e,ti.MOUSE_DOWN,i=>t(new Ph(gr(e),i))))}onmouseover(e,t){this._register(lt(e,ti.MOUSE_OVER,i=>t(new Ph(gr(e),i))))}onmouseleave(e,t){this._register(lt(e,ti.MOUSE_LEAVE,i=>t(new Ph(gr(e),i))))}onkeydown(e,t){this._register(lt(e,ti.KEY_DOWN,i=>t(new p1(i))))}onkeyup(e,t){this._register(lt(e,ti.KEY_UP,i=>t(new p1(i))))}oninput(e,t){this._register(lt(e,ti.INPUT,t))}onblur(e,t){this._register(lt(e,ti.BLUR,t))}onfocus(e,t){this._register(lt(e,ti.FOCUS,t))}onchange(e,t){this._register(lt(e,ti.CHANGE,t))}ignoreGesture(e){return WL.ignoreTarget(e)}},y1=11,qL=class extends qb{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=y1+"px",this.domNode.style.height=y1+"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 Zk),this._register(_1(this.bgDomNode,ti.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(_1(this.domNode,ti.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new UL),this._pointerdownScheduleRepeatTimer=this._register(new Kb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,gr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},VL=class i_{constructor(t,i,r,o,c,u,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,r=r|0,o=o|0,c=c|0,u=u|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,i<0&&(i=0),o+i>r&&(o=r-i),o<0&&(o=0),c<0&&(c=0),f+c>u&&(f=u-c),f<0&&(f=0),this.width=i,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,i){return new i_(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new i_(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,i){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:i,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}}},YL=class extends St{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new VL(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 i=this._state.withScrollDimensions(e,t);this._setState(i,!!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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let r;t?r=new w1(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=w1.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},S1=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ig(e,t){let i=t-e;return function(r){return e+i*ZL(r)}}function XL(e,t,i){return function(r){return r<i?e(r/i):t((r-i)/(1-i))}}var w1=class s_{constructor(t,i,r,o){this.from=t,this.to=i,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,i,r){if(Math.abs(t-i)>2.5*r){let o,c;return t<i?(o=t+.75*r,c=i-.75*r):(o=t-.75*r,c=i+.75*r),XL(Ig(t,o),Ig(c,i),.33)}return Ig(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let r=this.scrollLeft(i),o=this.scrollTop(i);return new S1(r,o,!1)}return new S1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,r){return s_.start(t,i,r)}static start(t,i,r){r=r+10;let o=Date.now()-10;return new s_(t,i,o,r)}};function GL(e){return Math.pow(e,3)}function ZL(e){return 1-GL(1-e)}var QL=class extends St{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Kb)}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":"")))}},JL=140,Qk=class extends qb{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 QL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Zk),this._shouldRender=!0,this.domNode=Wu(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(lt(this.domNode.domNode,ti.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new qL(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,r){this.slider=Wu(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(lt(this.slider.domNode,ti.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,i=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=$L(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,i);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),i=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-i);if(Vk&&u>JL){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()}},Jk=class r_{constructor(t,i,r,o,c,u){this._scrollbarSize=Math.round(i),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 r_(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,r,o,c){let u=Math.max(0,r-t),f=Math.max(0,u-2*i),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=r_._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,r=this._scrollPosition;return i<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},e3=class extends Qk{constructor(e,t,i){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Jk(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}},t3=class extends Qk{constructor(e,t,i){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Jk(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}},n3=500,x1=50,i3=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},a_=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,i=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,i+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if($b){let i=gr(t.browserEvent),r=pL(i);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,r){let o=null,c=new i3(t,i,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,i){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),i){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(i.deltaX),f=Math.abs(i.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}};a_.INSTANCE=new a_;var s3=a_,r3=class extends qb{constructor(e,t,i){super(),this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Be),this.onWillScroll=this._onWillScroll.event,this._options=o3(t),this._scrollable=i,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 t3(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new e3(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=Wu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Wu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Wu(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 Kb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=nl(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,vr&&(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 g1(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=nl(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new g1(i))};this._mouseWheelToDispose.push(lt(this._listenOnDomNode,ti.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=s3.INSTANCE;t.acceptStandardWheelEvent(e);let i=!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=!vr&&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=x1*o,_=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,_)}if(c){let p=x1*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),i=!0)}let r=i;!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,i=e.scrollLeft>0,r=i?" left":"",o=t?" top":"",c=i||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(),n3)}},a3=class extends r3{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function o3(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,vr&&(t.className+=" mac"),t}var o_=class extends St{constructor(e,t,i,r,o,c,u,f){super(),this._bufferService=i,this._optionsService=u,this._renderService=f,this._onRequestScrollLines=this._register(new Be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new YL({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Wb(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new a3(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(pi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(dn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(dn(()=>this._styleElement.remove())),this._register(pi.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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};o_=Cn([$e(2,Ri),$e(3,na),$e(4,Lk),$e(5,Sc),$e(6,Ni),$e(7,ia)],o_);var l_=class extends St{constructor(e,t,i,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,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(dn(()=>{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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};l_=Cn([$e(1,Ri),$e(2,na),$e(3,yd),$e(4,ia)],l_);var l3=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},dr={full:0,left:0,center:0,right:0},za={full:0,left:0,center:0,right:0},_u={full:0,left:0,center:0,right:0},Mf=class extends St{constructor(e,t,i,r,o,c,u,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=f,this._colorZoneStore=new l3,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(dn(()=>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);za.full=this._canvas.width,za.left=e,za.center=t,za.right=e,this._refreshDrawHeightConstants(),_u.full=1,_u.left=1,_u.center=1+za.left,_u.right=1+za.left+za.center}_refreshDrawHeightConstants(){dr.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);dr.left=t,dr.center=t,dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dr.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(_u[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dr[e.position||"full"]/2),za[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dr[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}))}};Mf=Cn([$e(2,Ri),$e(3,yd),$e(4,ia),$e(5,Ni),$e(6,Sc),$e(7,na)],Mf);var ke;(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=""))(ke||={});var rf;(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=""))(rf||={});var eT;(e=>e.ST=`${ke.ESC}\\`)(eT||={});var c_=class{constructor(e,t,i,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=i,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ke.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),i=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=i+"px",this._compositionView.style.lineHeight=i+"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)}}};c_=Cn([$e(2,Ri),$e(3,Ni),$e(4,rl),$e(5,ia)],c_);var ii=0,si=0,ri=0,wn=0,C1={css:"#00000000",rgba:0},Fn;(e=>{function t(o,c,u,f){return f!==void 0?`#${Wo(o)}${Wo(c)}${Wo(u)}${Wo(f)}`:`#${Wo(o)}${Wo(c)}${Wo(u)}`}e.toCss=t;function i(o,c,u,f=255){return(o<<24|c<<16|u<<8|f)>>>0}e.toRgba=i;function r(o,c,u,f){return{css:e.toCss(o,c,u,f),rgba:e.toRgba(o,c,u,f)}}e.toColor=r})(Fn||={});var on;(e=>{function t(g,p){if(wn=(p.rgba&255)/255,wn===1)return{css:p.css,rgba:p.rgba};let _=p.rgba>>24&255,b=p.rgba>>16&255,w=p.rgba>>8&255,x=g.rgba>>24&255,C=g.rgba>>16&255,N=g.rgba>>8&255;ii=x+Math.round((_-x)*wn),si=C+Math.round((b-C)*wn),ri=N+Math.round((w-N)*wn);let L=Fn.toCss(ii,si,ri),M=Fn.toRgba(ii,si,ri);return{css:L,rgba:M}}e.blend=t;function i(g){return(g.rgba&255)===255}e.isOpaque=i;function r(g,p,_){let b=af.ensureContrastRatio(g.rgba,p.rgba,_);if(b)return Fn.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[ii,si,ri]=af.toChannels(p),{css:Fn.toCss(ii,si,ri),rgba:p}}e.opaque=o;function c(g,p){return wn=Math.round(p*255),[ii,si,ri]=af.toChannels(g.rgba),{css:Fn.toCss(ii,si,ri,wn),rgba:Fn.toRgba(ii,si,ri,wn)}}e.opacity=c;function u(g,p){return wn=g.rgba&255,c(g,wn*p/255)}e.multiplyOpacity=u;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(on||={});var gn;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return ii=parseInt(o.slice(1,2).repeat(2),16),si=parseInt(o.slice(2,3).repeat(2),16),ri=parseInt(o.slice(3,4).repeat(2),16),Fn.toColor(ii,si,ri);case 5:return ii=parseInt(o.slice(1,2).repeat(2),16),si=parseInt(o.slice(2,3).repeat(2),16),ri=parseInt(o.slice(3,4).repeat(2),16),wn=parseInt(o.slice(4,5).repeat(2),16),Fn.toColor(ii,si,ri,wn);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 ii=parseInt(c[1]),si=parseInt(c[2]),ri=parseInt(c[3]),wn=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Fn.toColor(ii,si,ri,wn);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ii,si,ri,wn]=t.getImageData(0,0,1,1).data,wn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Fn.toRgba(ii,si,ri,wn),css:o}}e.toColor=r})(gn||={});var Ei;(e=>{function t(r){return i(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function i(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=i})(Ei||={});var af;(e=>{function t(u,f){if(wn=(f&255)/255,wn===1)return f;let g=f>>24&255,p=f>>16&255,_=f>>8&255,b=u>>24&255,w=u>>16&255,x=u>>8&255;return ii=b+Math.round((g-b)*wn),si=w+Math.round((p-w)*wn),ri=x+Math.round((_-x)*wn),Fn.toRgba(ii,si,ri)}e.blend=t;function i(u,f,g){let p=Ei.relativeLuminance(u>>8),_=Ei.relativeLuminance(f>>8);if(qr(p,_)<g){if(_<p){let x=r(u,f,g),C=qr(p,Ei.relativeLuminance(x>>8));if(C<g){let N=o(u,f,g),L=qr(p,Ei.relativeLuminance(N>>8));return C>L?x:N}return x}let b=o(u,f,g),w=qr(p,Ei.relativeLuminance(b>>8));if(w<g){let x=r(u,f,g),C=qr(p,Ei.relativeLuminance(x>>8));return w>C?b:x}return b}}e.ensureContrastRatio=i;function r(u,f,g){let p=u>>24&255,_=u>>16&255,b=u>>8&255,w=f>>24&255,x=f>>16&255,C=f>>8&255,N=qr(Ei.relativeLuminance2(w,x,C),Ei.relativeLuminance2(p,_,b));for(;N<g&&(w>0||x>0||C>0);)w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),C-=Math.max(0,Math.ceil(C*.1)),N=qr(Ei.relativeLuminance2(w,x,C),Ei.relativeLuminance2(p,_,b));return(w<<24|x<<16|C<<8|255)>>>0}e.reduceLuminance=r;function o(u,f,g){let p=u>>24&255,_=u>>16&255,b=u>>8&255,w=f>>24&255,x=f>>16&255,C=f>>8&255,N=qr(Ei.relativeLuminance2(w,x,C),Ei.relativeLuminance2(p,_,b));for(;N<g&&(w<255||x<255||C<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),N=qr(Ei.relativeLuminance2(w,x,C),Ei.relativeLuminance2(p,_,b));return(w<<24|x<<16|C<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(af||={});function Wo(e){let t=e.toString(16);return t.length<2?"0"+t:t}function qr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var c3=class extends bd{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},Af=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Os}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 i=[],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++)i.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;_++)i.push(p[_])}return i}_getJoinedRanges(e,t,i,r,o){let c=e.substring(t,i),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++)Af._mergeRanges(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,i){let r=0,o=!1,c=0,u=e[r];if(u){for(let f=i;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 i=!1;for(let r=0;r<e.length;r++){let o=e[r];if(i){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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Af=Cn([$e(0,Ri)],Af);function u3(e){return 57508<=e&&e<=57558}function d3(e){return 9472<=e&&e<=9631}function h3(e){return u3(e)||d3(e)}function f3(){return{css:{canvas:zh(),cell:zh()},device:{canvas:zh(),cell:zh(),char:{width:0,height:0,left:0,top:0}}}}function zh(){return{width:0,height:0}}var u_=class{constructor(e,t,i,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new Os,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,r,o,c,u,f,g,p,_){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),x=this._themeService.colors,C=e.getNoBgTrimmedLength();i&&C<c+1&&(C=c+1);let N,L=0,M="",U=0,P=0,H=0,K=0,ee=!1,j=0,J=!1,fe=0,ie=0,te=[],Y=p!==-1&&_!==-1;for(let Q=0;Q<C;Q++){e.loadCell(Q,this._workCell);let q=this._workCell.getWidth();if(q===0)continue;let ae=!1,O=Q>=ie,R=Q,z=this._workCell;if(w.length>0&&Q===w[0][0]&&O){let D=w.shift(),$=this._isCellInSelection(D[0],t);for(U=D[0]+1;U<D[1];U++)O&&=$===this._isCellInSelection(U,t);O&&=!i||c<D[0]||c>=D[1],O?(ae=!0,z=new c3(this._workCell,e.translateToString(!0,D[0],D[1]),D[1]-D[0]),R=D[1]-1,q=z.getWidth()):ie=D[1]}let ce=this._isCellInSelection(Q,t),ve=i&&Q===c,A=Y&&Q>=p&&Q<=_,V=!1;this._decorationService.forEachDecorationAtCell(Q,t,void 0,D=>{V=!0});let de=z.getChars()||Ya;if(de===" "&&(z.isUnderline()||z.isOverline())&&(de=" "),fe=q*f-g.get(de,z.isBold(),z.isItalic()),!N)N=this._document.createElement("span");else if(L&&(ce&&J||!ce&&!J&&z.bg===P)&&(ce&&J&&x.selectionForeground||z.fg===H)&&z.extended.ext===K&&A===ee&&fe===j&&!ve&&!ae&&!V&&O){z.isInvisible()?M+=Ya:M+=de,L++;continue}else L&&(N.textContent=M),N=this._document.createElement("span"),L=0,M="";if(P=z.bg,H=z.fg,K=z.extended.ext,ee=A,j=fe,J=ce,ae&&c>=Q&&c<=R&&(c=Q),!this._coreService.isCursorHidden&&ve&&this._coreService.isCursorInitialized){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&te.push("xterm-cursor-blink"),te.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline");break}}if(z.isBold()&&te.push("xterm-bold"),z.isItalic()&&te.push("xterm-italic"),z.isDim()&&te.push("xterm-dim"),z.isInvisible()?M=Ya:M=z.getChars()||Ya,z.isUnderline()&&(te.push(`xterm-underline-${z.extended.underlineStyle}`),M===" "&&(M=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${bd.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let D=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&D<8&&(D+=8),N.style.textDecorationColor=x.ansi[D].css}z.isOverline()&&(te.push("xterm-overline"),M===" "&&(M=" ")),z.isStrikethrough()&&te.push("xterm-strikethrough"),A&&(N.style.textDecoration="underline");let Z=z.getFgColor(),Se=z.getFgColorMode(),ye=z.getBgColor(),Me=z.getBgColorMode(),He=!!z.isInverse();if(He){let D=Z;Z=ye,ye=D;let $=Se;Se=Me,Me=$}let Fe,Ue,Ve=!1;this._decorationService.forEachDecorationAtCell(Q,t,void 0,D=>{D.options.layer!=="top"&&Ve||(D.backgroundColorRGB&&(Me=50331648,ye=D.backgroundColorRGB.rgba>>8&16777215,Fe=D.backgroundColorRGB),D.foregroundColorRGB&&(Se=50331648,Z=D.foregroundColorRGB.rgba>>8&16777215,Ue=D.foregroundColorRGB),Ve=D.options.layer==="top")}),!Ve&&ce&&(Fe=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,ye=Fe.rgba>>8&16777215,Me=50331648,Ve=!0,x.selectionForeground&&(Se=50331648,Z=x.selectionForeground.rgba>>8&16777215,Ue=x.selectionForeground)),Ve&&te.push("xterm-decoration-top");let Ye;switch(Me){case 16777216:case 33554432:Ye=x.ansi[ye],te.push(`xterm-bg-${ye}`);break;case 50331648:Ye=Fn.toColor(ye>>16,ye>>8&255,ye&255),this._addStyle(N,`background-color:#${k1((ye>>>0).toString(16),"0",6)}`);break;default:He?(Ye=x.foreground,te.push("xterm-bg-257")):Ye=x.background}switch(Fe||z.isDim()&&(Fe=on.multiplyOpacity(Ye,.5)),Se){case 16777216:case 33554432:z.isBold()&&Z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Z+=8),this._applyMinimumContrast(N,Ye,x.ansi[Z],z,Fe,void 0)||te.push(`xterm-fg-${Z}`);break;case 50331648:let D=Fn.toColor(Z>>16&255,Z>>8&255,Z&255);this._applyMinimumContrast(N,Ye,D,z,Fe,Ue)||this._addStyle(N,`color:#${k1(Z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(N,Ye,x.foreground,z,Fe,Ue)||He&&te.push("xterm-fg-257")}te.length&&(N.className=te.join(" "),te.length=0),!ve&&!ae&&!V&&O?L++:N.textContent=M,fe!==this.defaultSpacing&&(N.style.letterSpacing=`${fe}px`),b.push(N),Q=R}return N&&L&&(N.textContent=M),b}_applyMinimumContrast(e,t,i,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||h3(r.getCode()))return!1;let u=this._getContrastCache(r),f;if(!o&&!c&&(f=u.getColor(t.rgba,i.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=on.ensureContrastRatio(o||t,c||i,g),u.setColor((o||t).rgba,(c||i).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 i=this._selectionStart,r=this._selectionEnd;return!i||!r?!1:this._columnSelectMode?i[0]<=r[0]?e>=i[0]&&t>=i[1]&&e<r[0]&&t<=r[1]:e<i[0]&&t>=i[1]&&e>=r[0]&&t<=r[1]:t>i[1]&&t<r[1]||i[1]===r[1]&&t===i[1]&&e>=i[0]&&e<r[0]||i[1]<r[1]&&t===r[1]&&e<r[0]||i[1]<r[1]&&t===i[1]&&e>=i[0]}};u_=Cn([$e(1,jk),$e(2,Ni),$e(3,na),$e(4,rl),$e(5,yd),$e(6,Sc)],u_);function k1(e,t,i){for(;e.length<i;)e=t+e;return e}var p3=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 i=e.createElement("span");i.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=[i,r,o,c],this._container.appendChild(i),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,i,r){e===this._font&&t===this._fontSize&&i===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,i){let r=0;if(!t&&!i&&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"),i&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),i&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},m3=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,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,u=i[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=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function g3(){return new m3}var Pg="xterm-dom-renderer-owner-",Ds="xterm-rows",Hh="xterm-fg-",T1="xterm-bg-",bu="xterm-focus",Uh="xterm-selection",v3=1,d_=class extends St{constructor(e,t,i,r,o,c,u,f,g,p,_,b,w,x){super(),this._terminal=e,this._document=t,this._element=i,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=w,this._themeService=x,this._terminalClass=v3++,this._rowElements=[],this._selectionRenderModel=g3(),this.onRequestRedraw=this._register(new Be).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ds),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(Uh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=f3(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(C=>this._injectCss(C))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(u_,document),this._element.classList.add(Pg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(C=>this._handleLinkHover(C))),this._register(this._linkifier2.onHideLinkUnderline(C=>this._handleLinkLeave(C))),this._register(dn(()=>{this._element.classList.remove(Pg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new p3(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ds} 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} .${Ds} { 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} .${Ds} .xterm-dim { color: ${on.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 i=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 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} .${Ds}.${bu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ds}.${bu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ds}.${bu} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ds} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Uh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Uh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Uh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Hh}${c} { color: ${u.css}; }${this._terminalSelector} .${Hh}${c}.xterm-dim { color: ${on.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${T1}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Hh}257 { color: ${on.opaque(e.background).css}; }${this._terminalSelector} .${Hh}257.xterm-dim { color: ${on.multiplyOpacity(on.opaque(e.background),.5).css}; }${this._terminalSelector} .${T1}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 i=this._rowElements.length;i<=t;i++){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(bu),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(bu),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!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(i){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,i,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(i-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 i=this._bufferService.buffer,r=i.ybase+i.y,o=Math.min(i.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+i.ydisp,_=this._rowElements[g],b=i.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`.${Pg}${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,i,r,o,c){i<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;i=Math.max(Math.min(i,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,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=i;x<=r;++x){let C=x+f.ydisp,N=this._rowElements[x],L=f.lines.get(C);if(!N||!L)break;N.replaceChildren(...this._rowFactory.createRow(L,C,C===g,b,w,p,_,this.dimensions.css.cell.width,this._widthCache,c?x===i?e:0:-1,c?(x===r?t:o)-1:-1))}}};d_=Cn([$e(7,zb),$e(8,dp),$e(9,Ni),$e(10,Ri),$e(11,rl),$e(12,na),$e(13,Sc)],d_);var h_=class extends St{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Be),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new b3(this._optionsService))}catch{this._measureStrategy=this._register(new _3(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())}};h_=Cn([$e(2,Ni)],h_);var tT=class extends St{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)}},_3=class extends tT{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},b3=class extends tT{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}},y3=class extends St{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new S3(this._window)),this._onDprChange=this._register(new Be),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Be),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(pi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(lt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(lt(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}},S3=class extends St{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new fc),this._onDprChange=this._register(new Be),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(dn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=lt(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)}},w3=class extends St{constructor(){super(),this.linkProviders=[],this._register(dn(()=>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 Vb(e,t,i){let r=i.getBoundingClientRect(),o=e.getComputedStyle(i),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function x3(e,t,i,r,o,c,u,f,g){if(!c)return;let p=Vb(e,t,i);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 f_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,r,o){return x3(window,e,t,i,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=Vb(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};f_=Cn([$e(0,ia),$e(1,dp)],f_);var C3=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,i){this._rowCount=i,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=[]}},nT={};OA(nT,{getSafariVersion:()=>T3,isChromeOS:()=>aT,isFirefox:()=>iT,isIpad:()=>E3,isIphone:()=>D3,isLegacyEdge:()=>k3,isLinux:()=>Yb,isMac:()=>Lf,isNode:()=>hp,isSafari:()=>sT,isWindows:()=>rT});var hp=typeof process<"u"&&"title"in process,Sd=hp?"node":navigator.userAgent,wd=hp?"node":navigator.platform,iT=Sd.includes("Firefox"),k3=Sd.includes("Edge"),sT=/^((?!chrome|android).)*safari/i.test(Sd);function T3(){if(!sT)return 0;let e=Sd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Lf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(wd),E3=wd==="iPad",D3=wd==="iPhone",rT=["Windows","Win16","Win32","WinCE"].includes(wd),Yb=wd.indexOf("Linux")>=0,aT=/\bCrOS\b/.test(Sd),oT=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,i=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),i=Math.max(t,i),o=e.timeRemaining(),i*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()}},R3=class extends oT{_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())}}},N3=class extends oT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Of=!hp&&"requestIdleCallback"in window?N3:R3,M3=class{constructor(){this._queue=new Of}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},p_=class extends St{constructor(e,t,i,r,o,c,u,f,g){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new fc),this._pausedResizeTask=new M3,this._observerDisposable=this._register(new fc),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Be),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Be),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Be),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Be),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new C3((p,_)=>this._renderRows(p,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new A3(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(dn(()=>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 i=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=dn(()=>i.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,i=!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)),i||(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,i){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,this._renderer.value?.handleSelectionChanged(e,t,i)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};p_=Cn([$e(2,Ni),$e(3,dp),$e(4,rl),$e(5,yd),$e(6,Ri),$e(7,na),$e(8,Sc)],p_);var A3=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 L3(e,t,i,r){let o=i.buffer.x,c=i.buffer.y;if(!i.buffer.hasScrollback)return j3(o,c,e,t,i,r)+fp(c,t,i,r)+I3(o,c,e,t,i,r);let u;if(c===t)return u=o>e?"D":"C",nd(Math.abs(o-e),td(u,r));u=c>t?"D":"C";let f=Math.abs(c-t),g=B3(c>t?e:o,i)+(f-1)*i.cols+1+O3(c>t?o:e);return nd(g,td(u,r))}function O3(e,t){return e-1}function B3(e,t){return t.cols-e}function j3(e,t,i,r,o,c){return fp(t,r,o,c).length===0?"":nd(cT(e,t,e,t-il(t,o),!1,o).length,td("D",c))}function fp(e,t,i,r){let o=e-il(e,i),c=t-il(t,i),u=Math.abs(o-c)-P3(e,t,i);return nd(u,td(lT(e,t),r))}function I3(e,t,i,r,o,c){let u;fp(t,r,o,c).length>0?u=r-il(r,o):u=t;let f=r,g=z3(e,t,i,r,o,c);return nd(cT(e,u,i,f,g==="C",o).length,td(g,c))}function P3(e,t,i){let r=0,o=e-il(e,i),c=t-il(t,i);for(let u=0;u<Math.abs(o-c);u++){let f=lT(e,t)==="A"?-1:1;i.buffer.lines.get(o+f*u)?.isWrapped&&r++}return r}function il(e,t){let i=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return i}function z3(e,t,i,r,o,c){let u;return fp(i,r,o,c).length>0?u=r-il(r,o):u=t,e<i&&u<=r||e>=i&&u<r?"C":"D"}function lT(e,t){return e>t?"A":"B"}function cT(e,t,i,r,o,c){let u=e,f=t,g="";for(;(u!==i||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 td(e,t){let i=t?"O":"[";return ke.ESC+i+e}function nd(e,t){e=Math.floor(e);let i="";for(let r=0;r<e;r++)i+=t;return i}var H3=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 E1(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 zg=50,U3=15,$3=50,F3=500,K3=" ",W3=new RegExp(K3,"g"),m_=class extends St{constructor(e,t,i,r,o,c,u,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=i,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 Os,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Be),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Be),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Be),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Be),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=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 H3(this._bufferService),this._activeSelectionMode=0,this._register(dn(()=>{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 i=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=i.translateBufferLineToString(u,!0,o,c);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let u=i.lines.get(c),f=i.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let c=i.lines.get(t[1]),u=i.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(W3," ")).join(rT?`\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())),Yb&&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),i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r||!t?!1:this._areCoordsInSelection(t,i,r)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!i||!r?!1:this._areCoordsInSelection([e,t],i,r)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=E1(i,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=Vb(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-zg),zg),t/=zg,t/Math.abs(t)+Math.round(t*(U3-1)))}shouldForceSelection(e){return Lf?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(),$3)}_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&&!(Lf&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let r=i.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<F3&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let r=L3(i[0]-1,i[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,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==r&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!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,w=0,x=0;if(u.charAt(f)===" "){for(;f>0&&u.charAt(f-1)===" ";)f--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let L=e[0],M=e[0];c.getWidth(L)===0&&(_++,L--),c.getWidth(M)===2&&(b++,M++);let U=c.getString(M).length;for(U>1&&(x+=U-1,g+=U-1);L>0&&f>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,L--):P>1&&(w+=P-1,f-=P-1),f--,L--}for(;M<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(M+1,this._workCell));){c.loadCell(M+1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,M++):P>1&&(x+=P-1,g+=P-1),g++,M++}}g++;let C=f+p-_+w,N=Math.min(this._bufferService.cols,g-f+_+b-w-x);if(!(!t&&u.slice(f,g).trim()==="")){if(i&&C===0&&c.getCodePoint(0)!==32){let L=o.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let M=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(M){let U=this._bufferService.cols-M.start;C-=U,N+=U}}}if(r&&C+N===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=o.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let M=this._getWordAt([0,e[1]+1],!1,!1,!0);M&&(N+=M.length)}}return{start:C,length:N}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=E1(i,this._bufferService.cols)}};m_=Cn([$e(3,Ri),$e(4,rl),$e(5,Hb),$e(6,Ni),$e(7,ia),$e(8,na)],m_);var D1=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},R1=class{constructor(){this._color=new D1,this._css=new D1}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Wn=Object.freeze((()=>{let e=[gn.toColor("#2e3436"),gn.toColor("#cc0000"),gn.toColor("#4e9a06"),gn.toColor("#c4a000"),gn.toColor("#3465a4"),gn.toColor("#75507b"),gn.toColor("#06989a"),gn.toColor("#d3d7cf"),gn.toColor("#555753"),gn.toColor("#ef2929"),gn.toColor("#8ae234"),gn.toColor("#fce94f"),gn.toColor("#729fcf"),gn.toColor("#ad7fa8"),gn.toColor("#34e2e2"),gn.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let r=t[i/36%6|0],o=t[i/6%6|0],c=t[i%6];e.push({css:Fn.toCss(r,o,c),rgba:Fn.toRgba(r,o,c)})}for(let i=0;i<24;i++){let r=8+i*10;e.push({css:Fn.toCss(r,r,r),rgba:Fn.toRgba(r,r,r)})}return e})()),qo=gn.toColor("#ffffff"),Mu=gn.toColor("#000000"),N1=gn.toColor("#ffffff"),M1=Mu,yu={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},q3=qo,g_=class extends St{constructor(e){super(),this._optionsService=e,this._contrastCache=new R1,this._halfContrastCache=new R1,this._onChangeColors=this._register(new Be),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:qo,background:Mu,cursor:N1,cursorAccent:M1,selectionForeground:void 0,selectionBackgroundTransparent:yu,selectionBackgroundOpaque:on.blend(Mu,yu),selectionInactiveBackgroundTransparent:yu,selectionInactiveBackgroundOpaque:on.blend(Mu,yu),scrollbarSliderBackground:on.opacity(qo,.2),scrollbarSliderHoverBackground:on.opacity(qo,.4),scrollbarSliderActiveBackground:on.opacity(qo,.5),overviewRulerBorder:qo,ansi:Wn.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=Qt(e.foreground,qo),t.background=Qt(e.background,Mu),t.cursor=on.blend(t.background,Qt(e.cursor,N1)),t.cursorAccent=on.blend(t.background,Qt(e.cursorAccent,M1)),t.selectionBackgroundTransparent=Qt(e.selectionBackground,yu),t.selectionBackgroundOpaque=on.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Qt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=on.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Qt(e.selectionForeground,C1):void 0,t.selectionForeground===C1&&(t.selectionForeground=void 0),on.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=on.opacity(t.selectionBackgroundTransparent,.3)),on.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=on.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Qt(e.scrollbarSliderBackground,on.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Qt(e.scrollbarSliderHoverBackground,on.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Qt(e.scrollbarSliderActiveBackground,on.opacity(t.foreground,.5)),t.overviewRulerBorder=Qt(e.overviewRulerBorder,q3),t.ansi=Wn.slice(),t.ansi[0]=Qt(e.black,Wn[0]),t.ansi[1]=Qt(e.red,Wn[1]),t.ansi[2]=Qt(e.green,Wn[2]),t.ansi[3]=Qt(e.yellow,Wn[3]),t.ansi[4]=Qt(e.blue,Wn[4]),t.ansi[5]=Qt(e.magenta,Wn[5]),t.ansi[6]=Qt(e.cyan,Wn[6]),t.ansi[7]=Qt(e.white,Wn[7]),t.ansi[8]=Qt(e.brightBlack,Wn[8]),t.ansi[9]=Qt(e.brightRed,Wn[9]),t.ansi[10]=Qt(e.brightGreen,Wn[10]),t.ansi[11]=Qt(e.brightYellow,Wn[11]),t.ansi[12]=Qt(e.brightBlue,Wn[12]),t.ansi[13]=Qt(e.brightMagenta,Wn[13]),t.ansi[14]=Qt(e.brightCyan,Wn[14]),t.ansi[15]=Qt(e.brightWhite,Wn[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<i;r++)t.ansi[r+16]=Qt(e.extendedAnsi[r],Wn[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()}}};g_=Cn([$e(0,Ni)],g_);function Qt(e,t){if(e!==void 0)try{return gn.toColor(e)}catch{}return t}var V3=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Y3=class{constructor(){this._services=new V3,this._services.set(zb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=UA(e).sort((c,u)=>c.index-u.index),r=[];for(let c of i){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=i.length>0?i[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)}},X3={trace:0,debug:1,info:2,warn:3,error:4,off:5},G3="xterm.js: ",v_=class extends St{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=X3[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":G3)+t,...i)}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)}};v_=Cn([$e(0,Ni)],v_);var A1=class extends St{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Be),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Be),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Be),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){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+i.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<i.length;r++)this._array[this._getCyclicIndex(e+r)]=i[r];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let r=this._length+i.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let r=e+t+i-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+i,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},yt=3,$n=Object.freeze(new bd),$h=0,Hg=2,Au=class uT{constructor(t,i,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*yt);let o=i||Os.fromCharData([0,Rk,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let i=this._data[t*yt+0],r=i&2097151;return[this._data[t*yt+1],i&2097152?this._combined[t]:r?qa(r):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,i){this._data[t*yt+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*yt+0]=t|2097152|i[2]<<22):this._data[t*yt+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*yt+0]>>22}hasWidth(t){return this._data[t*yt+0]&12582912}getFg(t){return this._data[t*yt+1]}getBg(t){return this._data[t*yt+2]}hasContent(t){return this._data[t*yt+0]&4194303}getCodePoint(t){let i=this._data[t*yt+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*yt+0]&2097152}getString(t){let i=this._data[t*yt+0];return i&2097152?this._combined[t]:i&2097151?qa(i&2097151):""}isProtected(t){return this._data[t*yt+2]&536870912}loadCell(t,i){return $h=t*yt,i.content=this._data[$h+0],i.fg=this._data[$h+1],i.bg=this._data[$h+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*yt+0]=i.content,this._data[t*yt+1]=i.fg,this._data[t*yt+2]=i.bg}setCellFromCodepoint(t,i,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*yt+0]=i|r<<22,this._data[t*yt+1]=o.fg,this._data[t*yt+2]=o.bg}addCodepointToCell(t,i,r){let o=this._data[t*yt+0];o&2097152?this._combined[t]+=qa(i):o&2097151?(this._combined[t]=qa(o&2097151)+qa(i),o&=-2097152,o|=2097152):o=i|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*yt+0]=o}insertCells(t,i,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length-t){let o=new Os;for(let c=this.length-t-i-1;c>=0;--c)this.setCell(t+i+c,this.loadCell(t+c,o));for(let c=0;c<i;++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,i,r){if(t%=this.length,i<this.length-t){let o=new Os;for(let c=0;c<this.length-t-i;++c)this.setCell(t+c,this.loadCell(t+i+c,o));for(let c=this.length-i;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,i,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,r);t<i&&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),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,r);t<i&&t<this.length;)this.setCell(t++,r)}resize(t,i){if(t===this.length)return this._data.length*4*Hg<this._data.buffer.byteLength;let r=t*yt;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,i)}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*Hg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Hg<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new uT(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*yt+0]&4194303)return t+(this._data[t*yt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*yt+0]&4194303||this._data[t*yt+2]&50331648)return t+(this._data[t*yt+0]>>22);return 0}copyCellsFrom(t,i,r,o,c){let u=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<yt;p++)this._data[(r+g)*yt+p]=u[(i+g)*yt+p];u[(i+g)*yt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[i+g])}else for(let g=0;g<o;g++){for(let p=0;p<yt;p++)this._data[(r+g)*yt+p]=u[(i+g)*yt+p];u[(i+g)*yt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[i+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let p=parseInt(f[g],10);p>=i&&(this._combined[p-i+r]=t._combined[p])}}translateToString(t,i,r,o){i=i??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;i<r;){let u=this._data[i*yt+0],f=u&2097151,g=u&2097152?this._combined[i]:f?qa(f):Ya;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(i);i+=u>>22||1}return o&&o.push(i),c}};function Z3(e,t,i,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,w=id(_,b,t),x=1,C=0;for(;x<_.length;){let L=id(_,x,t),M=L-C,U=i-w,P=Math.min(M,U);_[b].copyCellsFrom(_[x],C,w,P,!1),w+=P,w===i&&(b++,w=0),C+=P,C===L&&(x++,C=0),w===0&&b!==0&&_[b-1].getWidth(i-1)===2&&(_[b].copyCellsFrom(_[b-1],i-1,w++,1,!1),_[b-1].setCell(i-1,o))}_[b].replaceCells(w,i,o);let N=0;for(let L=_.length-1;L>0&&(L>b||_[L].getTrimmedLength()===0);L--)N++;N>0&&(u.push(f+_.length-N),u.push(N)),f+=_.length-1}return u}function Q3(e,t){let i=[],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 i.push(u);return{layout:i,countRemoved:c}}function J3(e,t){let i=[];for(let r=0;r<t.length;r++)i.push(e.get(t[r]));for(let r=0;r<i.length;r++)e.set(r,i[r]);e.length=t.length}function eO(e,t,i){let r=[],o=e.map((g,p)=>id(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,f=0;for(;f<o;){if(o-f<i){r.push(o-f);break}c+=i;let g=id(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let _=p?i-1:i;r.push(_),f+=_}return r}function id(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?i-1:i}var dT=class hT{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=hT._nextId++,this._onDispose=this.register(new Be),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),nl(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};dT._nextId=1;var tO=dT,Xn={},Vo=Xn.B;Xn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Xn.A={"#":"£"};Xn.B=void 0;Xn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Xn.C=Xn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Xn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Xn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Xn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Xn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Xn.E=Xn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Xn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Xn.H=Xn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Xn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var L1=4294967295,O1=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=$n.clone(),this.savedCharset=Vo,this.markers=[],this._nullCell=Os.fromCharData([0,Rk,1,0]),this._whitespaceCell=Os.fromCharData([0,Ya,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Of,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new A1(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 Nf),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 Nf),this._whitespaceCell}getBlankLine(e,t){return new Au(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>L1?L1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=$n);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 A1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell($n),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,i);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 Au(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Au(e,i)));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,i);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 i=this._optionsService.rawOptions.reflowCursorLine,r=Z3(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell($n),i);if(r.length>0){let o=Q3(this.lines,r);J3(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let r=this.getNullCell($n),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Au(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell($n),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(!i){let P=this.ybase+this.y;if(P>=u&&P<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),_=eO(g,this._cols,e),b=_.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let x=[];for(let P=0;P<b;P++){let H=this.getBlankLine($n,!0);x.push(H)}x.length>0&&(o.push({start:u+g.length+c,newLines:x}),c+=x.length),g.push(...x);let C=_.length-1,N=_[C];N===0&&(C--,N=_[C]);let L=g.length-b-1,M=p;for(;L>=0;){let P=Math.min(M,N);if(g[C]===void 0)break;if(g[C].copyCellsFrom(g[L],M-P,N-P,P,!0),N-=P,N===0&&(C--,N=_[C]),M-=P,M===0){L--;let H=Math.max(L,0);M=id(g,H,this._cols)}}for(let P=0;P<g.length;P++)_[P]<e&&g[P].setCell(_[P],r);let U=b-w;for(;U-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],f=[];for(let N=0;N<this.lines.length;N++)f.push(this.lines.get(N));let g=this.lines.length,p=g-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let N=Math.min(this.lines.maxLength-1,g+c-1);N>=0;N--)if(b&&b.start>p+w){for(let L=b.newLines.length-1;L>=0;L--)this.lines.set(N--,b.newLines[L]);N++,u.push({index:p+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++_]}else this.lines.set(N,f[p--]);let x=0;for(let N=u.length-1;N>=0;N--)u[N].index+=x,this.lines.onInsertEmitter.fire(u[N]),x+=u[N].amount;let C=Math.max(0,g+c-this.lines.maxLength);C>0&&this.lines.onTrimEmitter.fire(C)}}translateBufferLineToString(e,t,i=0,r){let o=this.lines.get(e);return o?o.translateToString(t,i,r):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 tO(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},nO=class extends St{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Be),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new O1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new O1(!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)}},fT=2,pT=1,__=class extends St{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Be),this.onResize=this._onResize.event,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,fT),this.rows=Math.max(e.rawOptions.rows||0,pT),this.buffers=this._register(new nO(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=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:i,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=i.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=i.ybase+i.scrollTop,c=i.ybase+i.scrollBottom;if(i.scrollTop===0){let u=i.lines.isFull;c===i.lines.length-1?u?i.lines.recycle().copyFrom(r):i.lines.push(r.clone()):i.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let u=c-o+1;i.lines.shiftElements(o+1,u-1,-1),i.lines.set(c,r.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let r=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),r!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};__=Cn([$e(0,Ni)],__);var Yl={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:Lf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},iO=["normal","bold","100","200","300","400","500","600","700","800","900"],sO=class extends St{constructor(e){super(),this._onOptionChange=this._register(new Be),this.onOptionChange=this._onOptionChange.event;let t={...Yl};for(let i in e)if(i in t)try{let r=e[i];t[i]=this._sanitizeAndValidateOption(i,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(dn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Yl))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,r)=>{if(!(i in Yl))throw new Error(`No option with key "${i}"`);r=this._sanitizeAndValidateOption(i,r),this.rawOptions[i]!==r&&(this.rawOptions[i]=r,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let r={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Yl[e]),!rO(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Yl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=iO.includes(t)?t:Yl[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 rO(e){return e==="block"||e==="underline"||e==="bar"}function Lu(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let r in e)i[r]=t<=1?e[r]:e[r]&&Lu(e[r],t-1);return i}var B1=Object.freeze({insertMode:!1}),j1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),b_=class extends St{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Be),this.onData=this._onData.event,this._onUserInput=this._register(new Be),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Be),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Be),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Lu(B1),this.decPrivateModes=Lu(j1)}reset(){this.modes=Lu(B1),this.decPrivateModes=Lu(j1)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.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))}};b_=Cn([$e(0,Ri),$e(1,Ok),$e(2,Ni)],b_);var I1={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 Ug(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var $g=String.fromCharCode,P1={DEFAULT:e=>{let t=[Ug(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${$g(t[0])}${$g(t[1])}${$g(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ug(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ug(e,!0)};${e.x};${e.y}${t}`}},y_=class extends St{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Be),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(I1))this.addProtocol(r,I1[r]);for(let r of Object.keys(P1))this.addEncoding(r,P1[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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let r=t/i,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,i){if(i){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)}};y_=Cn([$e(0,Ri),$e(1,rl),$e(2,Ni)],y_);var Fg=[[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]],aO=[[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]],qn;function oO(e,t){let i=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=i;)if(o=i+r>>1,e>t[o][1])i=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var lO=class{constructor(){if(this.version="6",!qn){qn=new Uint8Array(65536),qn.fill(1),qn[0]=0,qn.fill(0,1,32),qn.fill(0,127,160),qn.fill(2,4352,4448),qn[9001]=2,qn[9002]=2,qn.fill(2,11904,42192),qn[12351]=1,qn.fill(2,44032,55204),qn.fill(2,63744,64256),qn.fill(2,65040,65050),qn.fill(2,65072,65136),qn.fill(2,65280,65377),qn.fill(2,65504,65511);for(let e=0;e<Fg.length;++e)qn.fill(0,Fg[e][0],Fg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?qn[e]:oO(e,aO)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),r=i===0&&t!==0;if(r){let o=Yo.extractWidth(t);o===0?r=!1:o>i&&(i=o)}return Yo.createPropertyValue(0,i,r)}},Yo=class of{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Be,this.onChange=this._onChange.event;let t=new lO;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,i,r=!1){return(t&16777215)<<3|(i&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 i=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 i+this.wcwidth(u);let p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let f=this.charProperties(u,r),g=of.extractWidth(f);of.extractShouldJoin(f)&&(g-=of.extractWidth(r)),i+=g,r=f}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},cO=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 z1(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Su=2147483647,uO=256,mT=class S_{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>uO)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new S_;if(!t.length)return i;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)i.addSubParam(o[c]);else i.addParam(o)}return i}clone(){let t=new S_(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 i=0;i<this.length;++i){t.push(this.params[i]);let r=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&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>Su?Su: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>Su?Su:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-i>0?this._subParams.subarray(i,r):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let r=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-r>0&&(t[i]=this._subParams.slice(r,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[i-1];r[i-1]=~o?Math.min(o*10+t,Su):t}},wu=[],dO=class{constructor(){this._state=0,this._active=wu,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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=wu}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=wu,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||wu,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",up(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){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&&i-t>0&&this._put(e,t,i)}}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 i=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;r>=0&&(i=this._active[r].end(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=wu,this._id=-1,this._state=0}}},is=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=up(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},xu=[],hO=class{constructor(){this._handlers=Object.create(null),this._active=xu,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=xu}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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=xu,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||xu,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",up(e,t,i));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;r>=0&&(i=this._active[r].unhook(e),i!==!0);r--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,i;r--}for(;r>=0;r--)if(i=this._active[r].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,i}this._active=xu,this._ident=0}},Ou=new mT;Ou.addParam(0);var H1=class{constructor(e){this._handler=e,this._data="",this._params=Ou,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ou,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=up(e,t,i),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(i=>(this._params=Ou,this._data="",this._hitLimit=!1,i));return this._params=Ou,this._data="",this._hitLimit=!1,t}},fO=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,r){this.table[t<<8|e]=i<<4|r}addMany(e,t,i,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|r}},As=160,pO=(function(){let e=new fO(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),i=(f,g)=>t.slice(f,g),r=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let c=i(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(i(128,144),u,3,0),e.addMany(i(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(i(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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(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(As,0,2,0),e.add(As,8,5,8),e.add(As,6,0,6),e.add(As,11,0,11),e.add(As,13,13,13),e})(),mO=class extends St{constructor(e=pO){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 mT,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(dn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new dO),this._dcsParser=this._register(new hO),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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");i<<=8,i|=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 i<<=8,i|=r,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let r=this._escHandlers[i];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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let r=this._csiHandlers[i];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,i,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,i){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(i===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(i===!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(i===!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,i),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,i),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:As)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<As){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<As){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<As){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<As){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],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 w=f+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<As){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,f),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=f+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<As){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,f),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},gO=/^([\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})$/,vO=/^[\da-f]+$/;function U1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=gO.exec(t);if(i){let r=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/r*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/r*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),vO.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(i*o,i*o+i),16);r[o]=i===1?c<<4:i===2?c:i===3?c>>4:c>>8}return r}}function Kg(e,t){let i=e.toString(16),r=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function _O(e,t=16){let[i,r,o]=e;return`rgb:${Kg(i,t)}/${Kg(r,t)}/${Kg(o,t)}`}var bO={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ha=131072,$1=10;function F1(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var K1=5e3,W1=0,yO=class extends St{constructor(e,t,i,r,o,c,u,f,g=new mO){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,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 zA,this._utf8Decoder=new HA,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=$n.clone(),this._eraseAttrDataInternal=$n.clone(),this._onRequestBell=this._register(new Be),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Be),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Be),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Be),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Be),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Be),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Be),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Be),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Be),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Be),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Be),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Be),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Be),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new w_(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(ke.BEL,()=>this.bell()),this._parser.setExecuteHandler(ke.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ke.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ke.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ke.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ke.BS,()=>this.backspace()),this._parser.setExecuteHandler(ke.HT,()=>this.tab()),this._parser.setExecuteHandler(ke.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ke.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(rf.IND,()=>this.index()),this._parser.setExecuteHandler(rf.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(rf.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new is(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new is(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new is(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new is(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new is(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new is(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new is(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new is(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new is(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new is(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new is(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new is(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 Xn)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 H1((p,_)=>this.requestStatusString(p,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),K1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${K1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ha&&(c=this._parseStack.position+Ha)}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<Ha&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ha))),u||this._dirtyRowTracker.clearRange(),e.length>Ha)for(let p=c;p<e.length;p+=Ha){let _=p+Ha<e.length?p+Ha:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(i),i}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(i),i}(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,i){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&&i-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let w=this._parser.precedingJoinState;for(let x=t;x<i;++x){if(r=e[x],r<127&&c){let M=c[String.fromCharCode(r)];M&&(r=M.charCodeAt(0))}let C=this._unicodeService.charProperties(r,w);o=Yo.extractWidth(C);let N=Yo.extractShouldJoin(C),L=N?Yo.extractWidth(w):0;if(w=C,u&&this._onA11yChar.fire(qa(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-L>f){if(g){let M=b,U=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&b instanceof Au&&b.copyCellsFrom(M,U,0,L,!1);U<f;)M.setCellFromCodepoint(U++,0,1,_)}else if(this._activeBuffer.x=f-1,o===2)continue}if(N&&this._activeBuffer.x){let M=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-M,r,o);for(let U=o-L;--U>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-L,this._activeBuffer.getNullCell(_)),b.getWidth(f-1)===2&&b.setCellFromCodepoint(f-1,0,1,_)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,_),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&i-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,i=>F1(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new H1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new is(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,i,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,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 i=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(i,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 i=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(i,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($n));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);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 i=e.params[0]||1,r=Yo.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*i),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<i;++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(ke.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ke.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ke.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ke.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ke.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,Vo),this._charsetService.setgCharset(1,Vo),this._charsetService.setgCharset(2,Vo),this._charsetService.setgCharset(3,Vo);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 i;(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});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,w=(N,L)=>(u.triggerDataEvent(`${ke.ESC}[${t?"":"?"}${N};${L}$y`),!0),x=N=>N?1:2,C=e.params[0];return t?C===2?w(C,4):C===4?w(C,x(u.modes.insertMode)):C===12?w(C,3):C===20?w(C,x(b.convertEol)):w(C,0):C===1?w(C,x(r.applicationCursorKeys)):C===3?w(C,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):C===6?w(C,x(r.origin)):C===7?w(C,x(r.wraparound)):C===8?w(C,3):C===9?w(C,x(o==="X10")):C===12?w(C,x(b.cursorBlink)):C===25?w(C,x(!u.isCursorHidden)):C===45?w(C,x(r.reverseWraparound)):C===66?w(C,x(r.applicationKeypad)):C===67?w(C,4):C===1e3?w(C,x(o==="VT200")):C===1002?w(C,x(o==="DRAG")):C===1003?w(C,x(o==="ANY")):C===1004?w(C,x(r.sendFocus)):C===1005?w(C,4):C===1006?w(C,x(c==="SGR")):C===1015?w(C,4):C===1016?w(C,x(c==="SGR_PIXELS")):C===1048?w(C,1):C===47||C===1047||C===1049?w(C,x(p===_)):C===2004?w(C,x(r.bracketedPasteMode)):C===2026?w(C,x(r.synchronizedOutput)):w(C,0)}_updateAttrColor(e,t,i,r,o){return t===2?(e|=50331648,e&=-16777216,e|=bd.fromColorRGB([i,r,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){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:i.fg=this._updateAttrColor(i.fg,r[1],r[3],r[4],r[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,r[1],r[3],r[4],r[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.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=$n.fg,e.bg=$n.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,i,r=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(r.fg&=-50331904,r.fg|=16777216|i-30):i>=40&&i<=47?(r.bg&=-50331904,r.bg|=16777216|i-40):i>=90&&i<=97?(r.fg&=-50331904,r.fg|=16777216|i-90|8):i>=100&&i<=107?(r.bg&=-50331904,r.bg|=16777216|i-100|8):i===0?this._processSGR0(r):i===1?r.fg|=134217728:i===3?r.bg|=67108864:i===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):i===5?r.fg|=536870912:i===7?r.fg|=67108864:i===8?r.fg|=1073741824:i===9?r.fg|=2147483648:i===2?r.bg|=134217728:i===21?this._processUnderline(2,r):i===22?(r.fg&=-134217729,r.bg&=-134217729):i===23?r.bg&=-67108865:i===24?(r.fg&=-268435457,this._processUnderline(0,r)):i===25?r.fg&=-536870913:i===27?r.fg&=-67108865:i===28?r.fg&=-1073741825:i===29?r.fg&=2147483647:i===39?(r.fg&=-67108864,r.fg|=$n.fg&16777215):i===49?(r.bg&=-67108864,r.bg|=$n.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,r):i===53?r.bg|=1073741824:i===55?r.bg&=-1073741825:i===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):i===100?(r.fg&=-67108864,r.fg|=$n.fg&16777215,r.bg&=-67108864,r.bg|=$n.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ke.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ke.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ke.ESC}[?${t};${i}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=$n.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!F1(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ke.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>$1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>$1&&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=[],i=e.split(";");for(;i.length>1;){let r=i.shift(),o=i.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(q1(c))if(o==="?")t.push({type:0,index:c});else{let u=U1(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 i=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(i,r):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),r,o=i.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=i[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 i=e.split(";");for(let r=0;r<i.length&&!(t>=this._specialColors.length);++r,++t)if(i[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=U1(i[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=[],i=e.split(";");for(let r=0;r<i.length;++r)if(/^\d+$/.exec(i[r])){let o=parseInt(i[r]);q1(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,Vo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(bO[e[0]],Xn[e[1]]||Vo),!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=$n.clone(),this._eraseAttrDataInternal=$n.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 Os;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(i);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=u=>(this._coreService.triggerDataEvent(`${ke.ESC}${u}${ke.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(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)}},w_=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&&(W1=e,e=t,t=W1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};w_=Cn([$e(0,Ri)],w_);function q1(e){return 0<=e&&e<256}var SO=5e7,V1=12,wO=50,xO=class extends St{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Be),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);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>SO)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 i=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()-i>=V1?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(i,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()-i>=V1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>wO&&(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()}},x_=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 i=e,r=this._getEntryIdKey(i),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(i),data:i,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 i=this._dataByLinkId.get(e);if(i&&i.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);i.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(i,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};x_=Cn([$e(0,Ri)],x_);var Y1=!1,CO=class extends St{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new fc),this._onBinary=this._register(new Be),this.onBinary=this._onBinary.event,this._onData=this._register(new Be),this.onData=this._onData.event,this._onLineFeed=this._register(new Be),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Be),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Be),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Be),this._instantiationService=new Y3,this.optionsService=this._register(new sO(e)),this._instantiationService.setService(Ni,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(__)),this._instantiationService.setService(Ri,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(v_)),this._instantiationService.setService(Ok,this._logService),this.coreService=this._register(this._instantiationService.createInstance(b_)),this._instantiationService.setService(rl,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(y_)),this._instantiationService.setService(Lk,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Yo)),this._instantiationService.setService(KA,this.unicodeService),this._charsetService=this._instantiationService.createInstance(cO),this._instantiationService.setService(FA,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(x_),this._instantiationService.setService(Bk,this._oscLinkService),this._inputHandler=this._register(new yO(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(pi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(pi.forward(this._bufferService.onResize,this._onResize)),this._register(pi.forward(this.coreService.onData,this._onData)),this._register(pi.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 xO((t,i)=>this._inputHandler.parse(t,i))),this._register(pi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Be),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Y1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Y1=!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,fT),t=Math.max(t,pT),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(z1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(z1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=dn(()=>{for(let t of e)t.dispose()})}}},kO={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 TO(e,t,i,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=ke.ESC+"OA":o.key=ke.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ke.ESC+"OD":o.key=ke.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ke.ESC+"OC":o.key=ke.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ke.ESC+"OB":o.key=ke.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ke.DEL,e.altKey&&(o.key=ke.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ke.ESC+"[Z";break}o.key=ke.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ke.ESC+ke.CR:ke.CR,o.cancel=!0;break;case 27:o.key=ke.ESC,e.altKey&&(o.key=ke.ESC+ke.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=ke.ESC+"[1;"+(c+1)+"D":t?o.key=ke.ESC+"OD":o.key=ke.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=ke.ESC+"[1;"+(c+1)+"C":t?o.key=ke.ESC+"OC":o.key=ke.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=ke.ESC+"[1;"+(c+1)+"A":t?o.key=ke.ESC+"OA":o.key=ke.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=ke.ESC+"[1;"+(c+1)+"B":t?o.key=ke.ESC+"OB":o.key=ke.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ke.ESC+"[2~");break;case 46:c?o.key=ke.ESC+"[3;"+(c+1)+"~":o.key=ke.ESC+"[3~";break;case 36:c?o.key=ke.ESC+"[1;"+(c+1)+"H":t?o.key=ke.ESC+"OH":o.key=ke.ESC+"[H";break;case 35:c?o.key=ke.ESC+"[1;"+(c+1)+"F":t?o.key=ke.ESC+"OF":o.key=ke.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ke.ESC+"[5;"+(c+1)+"~":o.key=ke.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ke.ESC+"[6;"+(c+1)+"~":o.key=ke.ESC+"[6~";break;case 112:c?o.key=ke.ESC+"[1;"+(c+1)+"P":o.key=ke.ESC+"OP";break;case 113:c?o.key=ke.ESC+"[1;"+(c+1)+"Q":o.key=ke.ESC+"OQ";break;case 114:c?o.key=ke.ESC+"[1;"+(c+1)+"R":o.key=ke.ESC+"OR";break;case 115:c?o.key=ke.ESC+"[1;"+(c+1)+"S":o.key=ke.ESC+"OS";break;case 116:c?o.key=ke.ESC+"[15;"+(c+1)+"~":o.key=ke.ESC+"[15~";break;case 117:c?o.key=ke.ESC+"[17;"+(c+1)+"~":o.key=ke.ESC+"[17~";break;case 118:c?o.key=ke.ESC+"[18;"+(c+1)+"~":o.key=ke.ESC+"[18~";break;case 119:c?o.key=ke.ESC+"[19;"+(c+1)+"~":o.key=ke.ESC+"[19~";break;case 120:c?o.key=ke.ESC+"[20;"+(c+1)+"~":o.key=ke.ESC+"[20~";break;case 121:c?o.key=ke.ESC+"[21;"+(c+1)+"~":o.key=ke.ESC+"[21~";break;case 122:c?o.key=ke.ESC+"[23;"+(c+1)+"~":o.key=ke.ESC+"[23~";break;case 123:c?o.key=ke.ESC+"[24;"+(c+1)+"~":o.key=ke.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=ke.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ke.DEL:e.keyCode===219?o.key=ke.ESC:e.keyCode===220?o.key=ke.FS:e.keyCode===221&&(o.key=ke.GS);else if((!i||r)&&e.altKey&&!e.metaKey){let u=kO[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=ke.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=ke.ESC+g}else if(e.keyCode===32)o.key=ke.ESC+(e.ctrlKey?ke.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=ke.ESC+f,o.cancel=!0}}else i&&!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=ke.US),e.key==="@"&&(o.key=ke.NUL));break}return o}var Ln=0,EO=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Of,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Of,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,i=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(r[o]=e[t],t++):r[o]=this._array[i++];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||(Ln=this._search(t),Ln===-1)||this._getKey(this._array[Ln])!==t)return!1;do if(this._array[Ln]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ln),!0;while(++Ln<this._array.length&&this._getKey(this._array[Ln])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,i=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[r++]=this._array[o];this._array=i,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&&(Ln=this._search(e),!(Ln<0||Ln>=this._array.length)&&this._getKey(this._array[Ln])===e))do yield this._array[Ln];while(++Ln<this._array.length&&this._getKey(this._array[Ln])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ln=this._search(e),!(Ln<0||Ln>=this._array.length)&&this._getKey(this._array[Ln])===e))do t(this._array[Ln]);while(++Ln<this._array.length&&this._getKey(this._array[Ln])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let r=t+i>>1,o=this._getKey(this._array[r]);if(o>e)i=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}},Wg=0,X1=0,DO=class extends St{constructor(){super(),this._decorations=new EO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Be),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Be),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(dn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new RO(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){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&&(!i||(c.options.layer??"bottom")===i)&&(yield c)}forEachDecorationAtCell(e,t,i,r){this._decorations.forEachByKey(t,o=>{Wg=o.options.x??0,X1=Wg+(o.options.width??1),e>=Wg&&e<X1&&(!i||(o.options.layer??"bottom")===i)&&r(o)})}},RO=class extends Za{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Be),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Be),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=gn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=gn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},NO=1e3,MO=class{constructor(e,t=NO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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)}},G1=20,Bf=class extends St{constructor(e,t,i,r){super(),this._terminal=e,this._coreBrowserService=i,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 MO(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(lt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(dn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<G1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===G1+1&&(this._liveRegion.textContent+=Fv.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 i=this._terminal.buffer,r=i.lines.length.toString();for(let o=e;o<=t;o++){let c=i.lines.get(i.ydisp+o),u=[],f=c?.translateToString(!0,void 0,void 0,u)||"",g=(i.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 i=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=i.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=i,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(u=this._rowElements.shift(),f=i,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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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(i.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(i.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 w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++_,w=0),{row:_,column:w}},c=o(t),u=o(i);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,i=this._rowColumns.get(e)?.slice(-1)?.[0];if(!i)return;let r=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Bf=Cn([$e(1,zb),$e(2,na),$e(3,ia)],Bf);var C_=class extends St{constructor(e,t,i,r,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Be),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Be),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(dn(()=>{nl(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(lt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(lt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(lt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(lt(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 i=e.composedPath();for(let r=0;r<i.length;r++){let o=i[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 i=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(i=this._checkLinkProviderResult(r,e,i)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(f=>({link:f}));this._activeProviderReplies?.set(r,u),i=this._checkLinkProviderResult(r,e,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=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(i.has(p)){o.splice(c--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){if(!this._activeProviderReplies)return i;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&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let u=this._activeProviderReplies.get(c)?.find(f=>this._linkAtPosition(f.link,t));if(u){i=!0,this._handleNewLink(u);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&AO(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,nl(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:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let r=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.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,i){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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-r-1,i.end.x,i.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){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(i,t.text)}_linkAtPosition(e,t){let i=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 i<=o&&o<=r}_positionFromMouseEvent(e,t,i){let r=i.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,i,r,o){return{x1:e,y1:t,x2:i,y2:r,cols:this._bufferService.cols,fg:o}}};C_=Cn([$e(1,Hb),$e(2,ia),$e(3,Ri),$e(4,Ik)],C_);function AO(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 LO=class extends CO{constructor(e={}){super(e),this._linkifier=this._register(new fc),this.browser=nT,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new fc),this._onCursorMove=this._register(new Be),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Be),this.onKey=this._onKey.event,this._onRender=this._register(new Be),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Be),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Be),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Be),this.onBell=this._onBell.event,this._onFocus=this._register(new Be),this._onBlur=this._register(new Be),this._onA11yCharEmitter=this._register(new Be),this._onA11yTabEmitter=this._register(new Be),this._onWillOpen=this._register(new Be),this._setup(),this._decorationService=this._instantiationService.createInstance(DO),this._instantiationService.setService(yd,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(w3),this._instantiationService.setService(Ik,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Wv)),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(pi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(pi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(pi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(pi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(dn(()=>{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 i,r="";switch(t.index){case 256:i="foreground",r="10";break;case 257:i="background",r="11";break;case 258:i="cursor",r="12";break;default:i="ansi",r="4;"+t.index}switch(t.type){case 0:let o=on.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${ke.ESC}]${r};${_O(o)}${eT.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Fn.toColor(...t.color));else{let c=i;this._themeService.modifyColors(u=>u[c]=Fn.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(Bf,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ke.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(ke.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 i=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),c=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,f=i*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(lt(this.element,"copy",t=>{this.hasSelection()&&IA(t,this._selectionService)}));let e=t=>PA(t,this.textarea,this.coreService,this.optionsService);this._register(lt(this.textarea,"paste",e)),this._register(lt(this.element,"paste",e)),iT?this._register(lt(this.element,"mousedown",t=>{t.button===2&&a1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(lt(this.element,"contextmenu",t=>{a1(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Yb&&this._register(lt(this.element,"auxclick",t=>{t.button===1&&Dk(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(lt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(lt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(lt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(lt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(lt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(lt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(lt(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(lt(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",$v.get()),aT||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(y3,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(na,this._coreBrowserService),this._register(lt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(lt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h_,this._document,this._helperContainer),this._instantiationService.setService(dp,this._charSizeService),this._themeService=this._instantiationService.createInstance(g_),this._instantiationService.setService(Sc,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Af),this._instantiationService.setService(jk,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(p_,this.rows,this.screenElement)),this._instantiationService.setService(ia,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(c_,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(f_),this._instantiationService.setService(Hb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(C_,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(o_,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(m_,this.element,this.screenElement,r)),this._instantiationService.setService(qA,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(pi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(l_,this.screenElement)),this._register(lt(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(Bf,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mf,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Mf,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d_,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(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=>(i(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(i(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&i(c)},mousemove:c=>{c.buttons||i(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(lt(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return i(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(lt(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=ke.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){Ek(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,i){this._selectionService.setSelection(e,t,i)}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 i=TO(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===ke.ETX||i.key===ke.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(OO(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($n));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(ke.ESC+"[I"):this.coreService.triggerDataEvent(ke.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ke.ESC}[4;${i};${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(`${ke.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function OO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var BO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},jO=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 Os)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Z1=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 jO(t)}getNullCell(){return new Os}},IO=class extends St{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Be),this.onBufferChange=this._onBufferChange.event,this._normal=new Z1(this._core.buffers.normal,"normal"),this._alternate=new Z1(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)}},PO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,r)=>t(i,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)}},zO=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}},HO=["cols","rows"],hr=0,UO=class extends St{constructor(e){super(),this._core=this._register(new LO(e)),this._addonManager=this._register(new BO),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],i=(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:i.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(HO.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 PO(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new zO(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 IO(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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 $v.get()},set promptLabel(e){$v.set(e)},get tooMuchOutput(){return Fv.get()},set tooMuchOutput(e){Fv.set(e)}}}_verifyIntegers(...e){for(hr of e)if(hr===1/0||isNaN(hr)||hr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(hr of e)if(hr&&(hr===1/0||isNaN(hr)||hr%1!==0||hr<0))throw new Error("This API only accepts positive integers")}};function pp(e){return e.normalize("NFC").trim().toLowerCase()}function $O(e){const t=pp(e);if(t.length>256)return"Use at most 256 characters.";const i=[...t.replace(/\s/gu,"")].length,r=/[\u1100-\u11ff\u3130-\u318f\ua960-\ua97f\uac00-\ud7ff]/u.test(t)?2:3;return i<r?`Enter at least ${r} non-space characters.`:null}const FO=Nt.lazy(()=>Pb(()=>import("./TranscriptMarkdownBody-H8ZsISc6.js"),__vite__mapDeps([2,1])));function gT({entries:e,searchQuery:t,activeEntryIndex:i,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map),f=v.useMemo(()=>{const p=new Map,_=new Array(e.length);for(let b=e.length-1;b>=0;b--){const w=e[b],x=`${w.kind}\0${w.header??""}\0${w.body}`;let C=2166136261,N=5381;for(let U=0;U<x.length;U++)C=Math.imul(C^x.charCodeAt(U),16777619),N=Math.imul(N,33)^x.charCodeAt(U);const L=`${x.length}:${C>>>0}:${N>>>0}`,M=p.get(L)??0;p.set(L,M+1),_[b]=`${L}:${M}`}return _},[e]);v.useEffect(()=>{if(i===null)return;const p=u.current.get(i);if(!p||typeof p.scrollIntoView!="function")return;if(r==="prompt"){p.scrollIntoView({block:"start",inline:"nearest"});return}const _=p.querySelectorAll(".transcript-search-hit");((o?.entryIndex===i?_[o.matchIndexInEntry]:null)??p).scrollIntoView({block:"center",inline:"nearest"})},[i,r,o,t]);let g=-1;return d.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((p,_)=>{const b=p.kind==="user"?++g:null,w=i===_?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return d.jsxs("section",{ref:x=>{x?u.current.set(_,x):u.current.delete(_)},className:`transcript-entry transcript-entry-${p.kind}${w}`,"data-transcript-kind":p.kind,"data-transcript-entry-index":_,...b!==null?{"data-transcript-prompt-position":b}:{},children:[p.header?d.jsx("div",{className:"transcript-entry-header",children:vT(p.header,t)}):null,p.body?d.jsx("div",{className:"transcript-entry-body",children:p.kind==="tool"?d.jsx(Q1,{text:p.body,searchQuery:t}):d.jsx(Nt.Suspense,{fallback:d.jsx(Q1,{text:p.body,searchQuery:t}),children:d.jsx(FO,{text:p.body,searchQuery:t})})}):null]},f[_])})})}function Q1({text:e,searchQuery:t}){const i=e.endsWith(`
|
|
31
|
+
`)?e.slice(0,-1).split(`
|
|
32
|
+
`):e.split(`
|
|
33
|
+
`);return d.jsx("pre",{className:"transcript-entry-pre",children:i.map((r,o)=>d.jsx("span",{className:`transcript-line transcript-line-${YO(r,o===0||i[o-1]?.trim()==="")}`,children:vT(r,t)},o))})}function vT(e,t){const i=t.trim();if(!i)return e||" ";const r=e.toLowerCase(),o=i.toLowerCase(),c=[];let u=0,f=r.indexOf(o);for(;f!==-1;){f>u&&c.push(e.slice(u,f));const g=f+i.length;c.push(d.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),u=g,f=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function KO(e,t){const i=t.trim().toLowerCase();if(!i)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(i);for(;c!==-1;)o+=1,c=r.indexOf(i,c+i.length);return o}function k_(e){const t=e.endsWith(`
|
|
34
|
+
`)?e.slice(0,-1):e;if(!t)return[];const i=[];let r=null,o="plain",c=[];function u(){const f=WO(c).join(`
|
|
35
|
+
`);(r||f)&&i.push({header:r,body:f,kind:o}),r=null,o="plain",c=[]}for(const f of t.split(`
|
|
36
|
+
`)){const g=qO(f);g?(u(),r=f,o=g):c.push(f)}return u(),i}function WO(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function qO(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const i=t[1]??"";return i==="User"?"user":i==="Codex"||i==="Claude"?"assistant":i==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(i)?"tool":null}function VO(e,t){const i=[];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=KO(c,t);for(let f=0;f<u;f+=1)i.push({entryIndex:r,matchIndexInEntry:f})}return i}function YO(e,t){const i=e.trim();if(!i)return"blank";const r=i.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(i);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)||bT(i))?"tool":/^(?:\$|>|❯|➜)\s+/.test(i)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(i)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(i)?"error":/^\[[^\]]+\]/.test(i)||/^(?:info|debug|warn)\b/i.test(i)?"dim":"plain"}function Qa(e){return e==="codex"?"Codex":"Claude"}function lf(e,t,i={}){const r=`[nterminal] ${Qa(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=Xb(o),u=i.includeTools?c:_T(c);return u?`${u}
|
|
42
|
+
`:""}function Xb(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,i)=>{const r=XO(i);return r?`[${r}]`:t})}function XO(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const i=t.getFullYear(),r=Cu(t.getMonth()+1),o=Cu(t.getDate()),c=Cu(t.getHours()),u=Cu(t.getMinutes()),f=Cu(t.getSeconds());return`${i}-${r}-${o} ${c}:${u}:${f}`}function Cu(e){return e.toString().padStart(2,"0")}function jf(e,t){return e.map(i=>t?i:_T(i)).filter(Boolean).map(i=>i.endsWith(`
|
|
43
|
+
`)?i:`${i}
|
|
44
|
+
`).join("")}function _T(e){if(!e)return"";const t=e.split(`
|
|
45
|
+
`),i=[];let r=!1,o=!1,c=!0;for(const u of t){const f=u.trim()==="",g=c?GO(u):null;if(g&&(r=g==="tool",o=!1),bT(u)){o=!0,c=!1;continue}if(o){f?(o=!1,r||i.push(u),c=!0):c=!1;continue}r||i.push(u),c=f}return i.join(`
|
|
46
|
+
`).replace(/\n{3,}/g,`
|
|
47
|
+
|
|
48
|
+
`).trimEnd()}function GO(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function bT(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Xa(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function J1(e,t){return e===null?t===null:t!==null&&Xa(e,t)}const ZO=5e3,QO=200,JO=1200,eB=4,tB=Nt.memo(function({terminalId:t,serverApi:i,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),[w,x]=v.useState(null),[C,N]=v.useState(null),[L,M]=v.useState(null),[U,P]=v.useState(()=>new Set),[H,K]=v.useState(!1),[ee,j]=v.useState(!1),[J,fe]=v.useState([]),[ie,te]=v.useState(null),[Y,Q]=v.useState(!1),[q,ae]=v.useState(!1),[O,R]=v.useState(!1),[z,ce]=v.useState(null),ve=w?.find(D=>D.id===L)??null;v.useEffect(()=>{function D($){$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),c())}return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[c]);const A=v.useCallback(async()=>{try{const D=await i.getTerminalSubagents(t);if(N(null),x($=>$&&aB($,D.subagents)?$:D.subagents),!b.current){const $=D.subagents.find(pe=>pe.hasTranscript);$&&(b.current=!0,M(pe=>pe??$.id))}}catch(D){N(D instanceof Error?D.message:"Failed to load subagents."),x($=>$??[])}},[i,t]);v.useEffect(()=>{A();const D=window.setInterval(()=>{document.hidden||A()},ZO);function $(){document.hidden||A()}return document.addEventListener("visibilitychange",$),()=>{window.clearInterval(D),document.removeEventListener("visibilitychange",$)}},[A]),v.useEffect(()=>{f.current+=1;const D=f.current;return g.current=!1,p.current=!0,_.current=null,fe([]),te(null),Q(!1),ce(null),L&&V(null,"initial",D),()=>{f.current===D&&(f.current+=1)}},[i,t,L,ee]),v.useLayoutEffect(()=>{const D=u.current;if(!D)return;if(p.current){if(q||J.length===0)return;p.current=!1;const pe=()=>{D.scrollTop=D.scrollHeight};pe(),window.requestAnimationFrame?.(pe);return}const $=_.current;$!==null&&(_.current=null,D.scrollTop+=D.scrollHeight-$)},[J,q,ee]);async function V(D,$,pe=f.current){const Ne=L;if(!(!Ne||g.current)){g.current=!0,$==="initial"?ae(!0):(R(!0),_.current=u.current?.scrollHeight??null),ce(null);try{let ne=D,ge=0,Ee=0,Re=[];for(;f.current===pe;){const Te=await i.getTerminalSubagentTranscriptHistory(t,Ne,{...ne?{cursor:ne}:{},limit:QO,maxLines:JO,includeTools:ee});if(f.current!==pe)return;if(!Te.source){if(Ee<1){Ee+=1,await new Promise(Ze=>setTimeout(Ze,600));continue}ce("Subagent transcript is unavailable.");return}const je=lf(Te.output,Te.source.provider,{includeTools:ee});if(te(Te.cursor),Q(!!(Te.hasMore&&Te.cursor)),je&&(Re=[je,...Re],jf(Re,ee))){fe(Ze=>$==="older"?[...Re,...Ze]:Re);return}if(!Te.hasMore||!Te.cursor||ge>=eB){Re.length>0&&fe(Ze=>$==="older"?[...Re,...Ze]:Re);return}ne=Te.cursor,ge+=1}}catch(ne){if(f.current!==pe)return;ce(ne instanceof Error?ne.message:"Failed to load subagent transcript.")}finally{f.current===pe&&(g.current=!1,ae(!1),R(!1))}}}function de(){const D=u.current;D&&(D.scrollTop>72||!Y||!ie||g.current||V(ie,"older"))}function Z(D){P($=>{const pe=new Set($);return pe.delete(D)||pe.add(D),pe})}function Se(D){b.current=!0,K(!0),D.id!==L&&M(D.id),ye(D.id)}function ye(D){const $=sB(w??[],D);$.length!==0&&P(pe=>{if($.every(ne=>pe.has(ne)))return pe;const Ne=new Set(pe);for(const ne of $)Ne.add(ne);return Ne})}function Me(){f.current+=1;const D=f.current;g.current=!1,p.current=!0,_.current=null,fe([]),te(null),Q(!1),ce(null),V(null,"initial",D)}const He=v.useMemo(()=>jf(J,ee),[J,ee]),Fe=v.useMemo(()=>k_(He),[He]),Ue=w===null;v.useEffect(()=>{if(q||O||!Y||!ie||g.current)return;const D=u.current;!D||J.length===0||D.scrollHeight<=D.clientHeight+4&&V(ie,"older")},[J,Y,ie,q,O]);const Ve=w?.filter(D=>D.state==="working").length??0,Ye=v.useMemo(()=>wT(nB(w??[]),U),[w,U]);return d.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:d.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":H?"transcript":"list",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>D.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?d.jsx("span",{className:"subagents-count",children:Ve>0?`${Ve} working · ${w.length} total`:`${w.length} total`}):null]}),d.jsxs("span",{title:r.sessionId,children:[Qa(r.provider)," session ",r.sessionId]})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),d.jsxs("div",{className:"subagents-body",children:[d.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[Ue?d.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Ue&&C?d.jsx("div",{className:"subagents-list-status subagents-list-error",children:C}):null,!Ue&&!C&&w!==null&&w.length===0?d.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,Ye.map(D=>{const $=D.subagent,pe=U.has($.id);return d.jsxs("div",{className:"subagent-row-wrap",style:D.level>0?{paddingLeft:`${Math.min(D.level,4)*14}px`}:void 0,children:[D.nestedCount>0?d.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":pe,"aria-label":`${pe?"Collapse":"Expand"} ${D.nestedCount} nested subagents of ${$.name}`,title:D.nestedWorkingCount>0?`${D.nestedCount} nested · ${D.nestedWorkingCount} working`:`${D.nestedCount} nested`,onClick:()=>Z($.id),children:[d.jsx("span",{"aria-hidden":"true",children:pe?"▾":"▸"}),d.jsx("span",{className:"subagent-expander-count","data-working":D.nestedWorkingCount>0?"true":"false",children:D.nestedCount})]}):d.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),d.jsxs("button",{type:"button",className:"subagent-row","data-selected":$.id===L?"true":"false","data-state":$.state,disabled:!$.hasTranscript,title:$.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Se($),children:[d.jsx("span",{className:"subagent-row-dot","data-state":$.state,"aria-hidden":"true"}),d.jsxs("span",{className:"subagent-row-main",children:[d.jsxs("span",{className:"subagent-row-title",children:[d.jsx("strong",{children:$.name}),d.jsx("span",{className:"subagent-row-badge","data-kind":$.kind,children:$.kind==="cross"?Qa($.provider):$.provider})]}),$.description?d.jsx("span",{className:"subagent-row-description",children:$.description}):null,d.jsxs("span",{className:"subagent-row-meta",children:[oB($.state),$.model?` · ${$.model}`:"",$.updatedAt?` · ${lB($.updatedAt)}`:"",D.nestedCount>0&&!pe?` · ${D.nestedCount} nested${D.nestedWorkingCount>0?` (${D.nestedWorkingCount} working)`:""}`:""]})]})]})]},$.id)})]}),d.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[d.jsxs("div",{className:"subagents-transcript-controls",children:[d.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>K(!1),children:"‹ List"}),d.jsx("span",{className:"subagents-transcript-name",children:ve?ve.name:"Select a subagent"}),d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:ee,onChange:D=>j(D.currentTarget.checked)}),"Show tool output"]}),d.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!ve,onClick:Me,children:"↻"})]}),ve?d.jsx("div",{className:"subagents-transcript-hint",children:rB(ve)}):null,d.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:de,children:[O?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!q&&Y?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,He?d.jsx(gT,{entries:Fe,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,q?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!q&&ve&&!He&&!z?Y&&ie?d.jsxs("div",{className:"transcript-dialog-status",children:[ee?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{V(ie,"older")},disabled:O,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!ve&&!Ue&&!He?d.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,z?d.jsx("div",{className:"transcript-dialog-error",children:z}):null]})]})]})]})})});function nB(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const i=[];for(const r of t.values()){const o=iB(r,t);o?o.children.push(r):i.push(r)}for(const r of i)yT(r);return ST(i),i}function iB(e,t){const i=e.subagent.parentId;if(!i)return null;const r=t.get(i);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 yT(e){let t=0,i=0;for(const r of e.children)yT(r),t+=1+r.nestedCount,i+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=i,ST(e.children)}function ST(e){e.sort((t,i)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=i.subagent.state==="working"||i.nestedWorkingCount>0?0:1;return r!==o?r-o:(i.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function wT(e,t,i=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:i,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...wT(o.children,t,i+1));return r}function sB(e,t){const i=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=i.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=i.get(c)?.parentId??null;return r}function rB(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 aB(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i+=1){const r=e[i],o=t[i];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 oB(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function lB(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const i=Date.now()-t;if(i<45e3)return"just now";const r=Math.round(i/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`}function cB({options:e,value:t,onSelect:i}){const[r,o]=v.useState(!1),c=v.useRef(null),u=v.useRef(null),f=e.find(g=>g.id===t);return v.useEffect(()=>{if(!r)return;const g=()=>Array.from(c.current?.querySelectorAll('[role="menuitemradio"]')??[]),p=g();(p.find(w=>w.getAttribute("aria-checked")==="true")??p[0])?.focus();function _(w){c.current?.contains(w.target)||o(!1)}function b(w){if(w.key==="Escape")w.preventDefault(),w.stopPropagation(),o(!1),u.current?.focus();else if(["ArrowDown","ArrowUp","Home","End"].includes(w.key)){w.preventDefault(),w.stopPropagation();const x=g(),C=x.findIndex(L=>L===document.activeElement),N=w.key==="Home"?0:w.key==="End"?x.length-1:(C+(w.key==="ArrowDown"?1:-1)+x.length)%x.length;x[N]?.focus()}else w.key==="Tab"&&o(!1)}return document.addEventListener("pointerdown",_,!0),window.addEventListener("keydown",b,!0),()=>{document.removeEventListener("pointerdown",_,!0),window.removeEventListener("keydown",b,!0)}},[r]),d.jsxs("div",{className:"transcript-session-menu",ref:c,children:[d.jsxs("button",{ref:u,type:"button",className:"transcript-session-trigger","aria-label":"Transcript session","aria-haspopup":"menu","aria-expanded":r,onClick:()=>o(!r),children:[d.jsx("span",{children:f?.title??"Choose a session"}),d.jsx(cM,{size:16,"aria-hidden":"true"})]}),r?d.jsx("div",{className:"transcript-session-options",role:"menu","aria-label":"Transcript sessions",children:e.map(g=>d.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":t===g.id,tabIndex:-1,onClick:()=>{o(!1),u.current?.focus(),i(g.id)},children:[d.jsx("span",{className:"transcript-session-check",children:t===g.id?d.jsx(VC,{size:16}):null}),d.jsxs("span",{className:"transcript-session-copy",children:[d.jsx("strong",{children:g.title}),d.jsx("small",{children:g.detail})]})]},g.id))}):null]})}function uB(e,t,i){if(!e.length)return null;const r=t.timestamp?Xb(`[${t.timestamp}] ${t.role}`):null;let o=e.length-1;if(r){for(let u=e.length-1;u>=0;u-=1)if(e[u]?.header===r){o=u;break}}const c=VO(e,pp(i)).filter(u=>u.entryIndex===o);return(r&&e[o]?.header===r?c[0]:c.at(-1))??{entryIndex:o,matchIndexInEntry:0}}function dB(e,t,i,r,o,c){const[u,f]=v.useState(null),[g,p]=v.useState(!1),[_,b]=v.useState(null),w=v.useRef(null),x=v.useRef(0);function C(){x.current+=1,w.current?.abort(),w.current=null}function N(){C(),p(!1)}v.useEffect(()=>(C(),f(null),p(!1),b(null),C),[e,t,i.provider,i.sessionId,r,o,c]);async function L(M=!1){const U=$O(c);if(U){b(U);return}C();const P=x.current,H=new AbortController;w.current=H,p(!0),b(null);let K=M?u:null;M||f(null);try{for(let ee=0;ee<4;ee+=1){const j=await e.searchTerminalTranscript(t,{query:pp(c),...K?.cursor?{cursor:K.cursor}:{},...r?{candidateId:r}:{},expectedSessionId:i.sessionId,includeTools:o},H.signal);if(H.signal.aborted||P!==x.current)return;if(!j.source||j.source.provider!==i.provider||j.source.sessionId!==i.sessionId)throw new Error("Transcript source changed or is unavailable. Choose a session again.");const J=new Set(K?.hits.map(te=>te.id)),fe=[...K?.hits??[],...j.hits.filter(te=>!J.has(te.id))],ie=K?.cursor;if(K={...j,hits:fe.slice(-200)},f(K),j.complete||!j.cursor||j.cursor===ie||j.hits.length)break}}catch(ee){!H.signal.aborted&&P===x.current&&b(ee instanceof Error?ee.message:"Search failed.")}finally{P===x.current&&p(!1)}}return{result:u,busy:g,error:_,search:L,cancel:N}}class hB{pending=null;accept(t){let i="";for(const r of t)i+=this.acceptChar(r);return i}acceptChar(t){return t===""?this.acceptBackspace():TT.has(t)?this.acceptConsonant(t):ET.has(t)?this.acceptVowel(t):gB(t)&&this.canReplacePendingWith(t)?(this.pending=tx(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(DT.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const i=mB.get(`${this.pending.final}${t}`);if(i)return this.pending.final=i,"";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=pB.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const i=ex.get(this.pending.final);if(i){this.pending.final=i[0];const c=this.flushPending();return this.pending={initial:i[1],vowel:t},c}const r=this.pending.final,o=nx({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=ex.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 i=tx(t);return i.initial===this.pending.initial&&(!this.pending.vowel||i.vowel===this.pending.vowel)&&(!this.pending.final||i.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=nx(this.pending);return this.pending=null,t}}const If=44032,Pf=21,nc=28,fB=19*Pf*nc,xT=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],CT=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],kT=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],TT=Gb(xT),ET=Gb(CT),DT=Gb(kT),pB=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),RT=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],mB=new Map(RT),ex=new Map(RT.map(([e,t])=>[t,[e[0],e[1]]]));function Gb(e){return new Map(e.map((t,i)=>[t,i]))}function gB(e){const t=e.codePointAt(0);return t!==void 0&&t>=If&&t<If+fB}function tx(e){const t=e.codePointAt(0)-If,i=Math.floor(t/(Pf*nc)),r=Math.floor(t%(Pf*nc)/nc),o=t%nc,c={initial:xT[i],vowel:CT[r]};return o===0?c:{...c,final:kT[o]}}function nx(e){if(!e.vowel)return e.initial;const t=TT.get(e.initial),i=ET.get(e.vowel),r=e.final?DT.get(e.final):0;return t===void 0||i===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(If+(t*Pf+i)*nc+r)}const vB=[{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 _B({ctrlActive:e,onCtrl:t,onStandaloneKey:i,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return d.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[d.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),vB.map(u=>d.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>i(u.key),children:u.label},u.key)),d.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const bB={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function yB(e){return bB[e]}function SB(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const NT="--nterminal-viewport-height",MT="--nterminal-keyboard-inset-bottom",AT="data-nterminal-keyboard-visible",mp="data-nterminal-compose-open",zf="nterminal:viewport-refresh",wB=120;function xB(e=window){const t=e.document.documentElement,i=e.visualViewport,r=RB(e);function o(){Zb(e)}return o(),i?.addEventListener("resize",o),i?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(zf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{i?.removeEventListener("resize",o),i?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(zf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(NT),t.style.removeProperty(MT),t.removeAttribute(AT)}}function Zb(e=window){const t=e.document.documentElement,{keyboardInsetBottom:i,keyboardVisible:r}=T_(e),o=CB(e,r);return o!==null&&ix(t,NT,`${o}px`),ix(t,MT,`${i}px`),kB(t,AT,String(r)),{viewportHeight:o,keyboardInsetBottom:i,keyboardVisible:r}}function T_(e=window){const t=TB(e);return{keyboardInsetBottom:t,keyboardVisible:t>wB}}function CB(e,t){if((e.document.documentElement.hasAttribute(mp)||t)&&Qo(e.innerHeight))return e.innerHeight;const i=e.visualViewport?.height;return Qo(i)?i:Qo(e.innerHeight)?e.innerHeight:null}function Qo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ix(e,t,i){e.style.getPropertyValue(t)!==i&&e.style.setProperty(t,i)}function kB(e,t,i){e.getAttribute(t)!==i&&e.setAttribute(t,i)}function TB(e){return Math.max(EB(e),DB(e))}function EB(e){const t=e.visualViewport?.height;if(!Qo(t)||!Qo(e.innerHeight))return 0;const i=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-i))}function DB(e){if(!Qo(e.innerHeight))return 0;const i=LT(e)?.boundingRect?.height;return!Qo(i)||i>=e.innerHeight*.8?0:Math.round(i)}function LT(e){return e.navigator.virtualKeyboard}function RB(e){const t=LT(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const xd=new Map,sd=new Map,NB=Object.freeze({open:!1,text:""});function MB(e){let t=sd.get(e);return t||(t=new Set,sd.set(e,t)),t}function OT(e){const t=sd.get(e);if(t)for(const i of Array.from(t))i()}function oc(e){return xd.get(e)??NB}function AB(e,t){const i=MB(e);return i.add(t),()=>{i.delete(t)}}function LB(e,t){const i=oc(e);i.open!==t&&(xd.set(e,{...i,open:t}),OT(e))}function OB(e,t){const i=oc(e);i.text!==t&&(xd.set(e,{...i,text:t}),OT(e))}function ku(e){xd.delete(e),sd.delete(e)}function sx(){xd.clear(),sd.clear()}const ro=new Map,rd=new Map,Hf=new Map,BB=Object.freeze([]);function ad(e){return ro.get(e)??BB}function jB(e,t){let i=rd.get(e);return i||(i=new Set,rd.set(e,i)),i.add(t),()=>i?.delete(t)}function qg(e,t){t.length!==0&&(ro.set(e,[...ad(e),...t]),gp(e))}function Vg(e){const t=Hf.get(e)??1;return Hf.set(e,t+1),`attach${t}`}function E_(e){Hf.delete(e)}function Tu(e,t,i){const r=ad(e);r.length!==0&&(ro.set(e,r.map(o=>t.has(o.id)?i(o):o)),gp(e))}function Fh(e,t){const i=ad(e);i.find(c=>c.id===t)?.cancel?.();const o=i.filter(c=>c.id!==t);o.length!==i.length&&(o.length===0?ro.delete(e):ro.set(e,o),gp(e))}function BT(e){const t=ro.get(e);if(t){for(const i of t)i.cancel?.();ro.delete(e),gp(e)}}function Zl(e){BT(e),E_(e),rd.delete(e)}function rx(){for(const e of Array.from(ro.keys()))Zl(e);rd.clear(),Hf.clear()}function gp(e){for(const t of Array.from(rd.get(e)??[]))t()}class IB extends Error{constructor(t){super(t),this.name="UploadDropError"}}function ic(e){return e?Array.from(e.types??[]).includes("Files")||Jb(e.items).some(i=>i.kind==="file")?!0:HT(e.files).length>0:!1}async function jT(e){const t=Jb(e.items).filter(i=>i.kind==="file");return t.length>0?zB(t):IT(e.files)}function PB(e){const t=Jb(e.items).filter(o=>o.kind==="file").flatMap(o=>{const c=o.getAsFile();return c?[{relativePath:Qb(c),file:c}]:[]}),i=IT(e.files);if(t.length===0)return i;if(i.length===0)return t;const r=[...t];for(const o of i)r.some(c=>FB(c.file,o.file))||r.push(o);return r}async function zB(e){const t=[];for(const i of e){const r=KB(i);if(r){await PT(r,"",t);continue}const o=i.getAsFile();if(o){t.push({relativePath:Qb(o),file:o});continue}throw new IB("Folder upload is not supported by this browser.")}return t}function IT(e){return HT(e).map(t=>({relativePath:Qb(t),file:t}))}async function PT(e,t,i){const r=qB(t,e.name);if(e.isFile){const u=await HB(e);i.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await UB(o);for(const u of c)await PT(u,r,i)}function HB(e){return new Promise((t,i)=>{e.file(t,r=>i(r))})}async function UB(e){const t=[];for(;;){const i=await $B(e);if(i.length===0)return t;t.push(...i)}}function $B(e){return new Promise((t,i)=>{e.readEntries(t,r=>i(r))})}function Qb(e){const t=e.webkitRelativePath;return zT(typeof t=="string"&&t?t:e.name)}function FB(e,t){return e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified}function KB(e){const t=e.webkitGetAsEntry?.();return WB(t)?t:null}function WB(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 qB(e,t){return zT(e?`${e}/${t}`:t)}function zT(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Jb(e){return e?Array.from(e):[]}function HT(e){return e?Array.from(e):[]}const VB=120,YB="\x1B[200~",XB="\x1B[201~";function Yg(e,t){const i=t.stripTrailingLineBreaks===!1?e:ey(e),r=ZB(i);return r?t.bracketedPasteMode?`${YB}${r}${XB}`:r:""}function GB(e){return e==="queue"?" ":"\r"}function ey(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function ZB(e){return e.replace(/\r\n/g,`
|
|
49
|
+
`).replace(/\r/g,`
|
|
50
|
+
`).replace(/\n/g,"\r")}const QB=420,JB=3e3,ax=650,e5=80,t5=3,n5=10,i5=50*1024*1024,s5=100*1024*1024,r5=2,a5={maxFiles:n5,maxFileBytes:i5,maxBatchBytes:s5},cf=new Set;let lc=null;function o5({terminalId:e,onSubmit:t,queueAvailable:i=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const f=v.useMemo(()=>D=>AB(e,D),[e]),g=v.useMemo(()=>()=>oc(e),[e]),p=v.useSyncExternalStore(f,g,g),{open:_,text:b}=p,w=v.useMemo(()=>D=>jB(e,D),[e]),x=v.useMemo(()=>()=>ad(e),[e]),C=v.useSyncExternalStore(w,x,x),[N,L]=v.useState(a5),[M,U]=v.useState(!1),P=v.useRef(null),H=v.useRef(null),K=v.useRef(null),ee=v.useRef(null),j=v.useRef(new Map),J=v.useRef(c),fe=v.useRef(u),ie=v.useRef(null),te=v.useRef({start:0,end:0});J.current=c,fe.current=u,v.useEffect(()=>()=>{ie.current?.(),ie.current=null},[]),v.useEffect(()=>{if(!_||!J.current)return;let D=!0;return J.current().then($=>{D&&L($)}).catch(()=>{}),()=>{D=!1}},[_,e]),v.useLayoutEffect(()=>{if(!(!_||!uf()))return m5(e),()=>g5(e)},[_,e]),v.useLayoutEffect(()=>{const D=P.current?.closest(".terminal-pane");if(!D)return;function $(){D?.removeAttribute("data-compose-open"),D?.style.removeProperty("--compose-drawer-panel-height")}if(!_){$();return}const pe=H.current;D.setAttribute("data-compose-open","true");function Ne(){const Re=pe?.getBoundingClientRect().height??0;Re>0&&D?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Re)}px`)}Ne();const ne=[window.setTimeout(Ne,0),window.setTimeout(Ne,180),window.setTimeout(Ne,260)],ge=window.requestAnimationFrame?.(Ne)??null,Ee=typeof ResizeObserver=="function"&&pe?new ResizeObserver(Ne):null;return Ee&&pe&&Ee.observe(pe),()=>{for(const Re of ne)window.clearTimeout(Re);ge!==null&&window.cancelAnimationFrame?.(ge),Ee?.disconnect(),$()}},[_]),v.useEffect(()=>{if(!_){ie.current?.(),ie.current=null;return}Qg(K.current),Ue()},[_]);function Y(D){LB(e,D)}function Q(D){OB(e,D)}function q(){p5(P.current),Y(!1),cx()}function ae(D="send"){const $=C.filter(Ne=>Ne.status==="uploaded"&&Ne.path);if(r||C.some(Ne=>Ne.status==="uploading"||Ne.status==="failed")||!b&&$.length===0)return;const pe=u5(b,C);if(pe.parts.some(Ne=>Ne.kind==="image"||Ne.value.trim())&&t(pe,D)){if(Q(""),BT(e),E_(e),uf()){K.current?.blur(),cx();return}window.setTimeout(()=>K.current?.focus(),VB+20)}}async function O(D){if(r||D.length===0)return;const $=ad(e).filter(je=>je.status!=="failed"),pe=$.reduce((je,Ze)=>je+Ze.file.size,0);let Ne=0,ne=$.length;const ge=[],Ee=D.filter((je,Ze)=>{const Ae=pe+Ne+je.file.size,_t=je.file.size>N.maxFileBytes?`File exceeds the ${lx(N.maxFileBytes)} attachment limit.`:ne>=N.maxFiles?`A compose message can include up to ${N.maxFiles} attachments.`:Ae>N.maxBatchBytes?`Compose attachments cannot exceed ${lx(N.maxBatchBytes)} in total.`:null;return _t?(ge.push({id:Gg(Ze),reference:Vg(e),file:je.file,relativePath:ox(je.relativePath,je.file.name),status:"failed",error:_t}),!1):(ne+=1,Ne+=je.file.size,!0)});if(ge.length>0&&qg(e,ge),Ee.length===0)return;const Re=new Map,Te=Ee.map((je,Ze)=>{const Ae=Gg(Ze),_t=new AbortController;return Re.set(Ae,_t),{id:Ae,reference:Vg(e),file:je.file,relativePath:ox(je.relativePath,je.file.name),status:"uploading",loaded:0,total:je.file.size,cancel:()=>_t.abort()}});qg(e,Te),Ve(Te.map(je=>je.reference));for(const je of Te)j.current.set(je.id,Re.get(je.id));await f5(Te,r5,async je=>{const Ze=Re.get(je.id),Ae=new Set([je.id]);try{const bt=(await o([{relativePath:je.relativePath,file:je.file}],{signal:Ze.signal,onProgress:at=>{Tu(e,Ae,ot=>({...ot,loaded:at.loaded,total:at.total}))}})).results[0];if(Ze.signal.aborted){const at=fe.current;bt?.status==="uploaded"&&bt.attachmentId&&at&&at([bt.attachmentId]).catch(()=>{});return}Tu(e,Ae,at=>{const{error:ot,cancel:Bt,...ln}=at;return bt?.status==="uploaded"&&bt.path?{...ln,status:"uploaded",...bt.attachmentId?{attachmentId:bt.attachmentId}:{},path:bt.path,loaded:bt.size??at.file.size,total:bt.size??at.file.size}:{...ln,status:"failed",error:bt?.error??"upload_failed"}})}catch(_t){const bt=Ze.signal.aborted?"Upload canceled.":Zg(_t);Tu(e,Ae,at=>{const{cancel:ot,...Bt}=at;return{...Bt,status:"failed",error:bt}})}finally{j.current.get(je.id)===Ze&&j.current.delete(je.id)}})}function R(D){if(D.status!=="removing"){if(Ye(D.reference),D.status!=="uploaded"&&D.status!=="failed"||!D.attachmentId||!fe.current){j.current.delete(D.id),Fh(e,D.id);return}ce([D])}}function z(){Q(""),E_(e);const D=C.filter($=>!!($.path&&$.attachmentId));for(const $ of C)D.includes($)||(j.current.delete($.id),Fh(e,$.id));D.length>0&&ce(D)}function ce(D){const $=D.flatMap(Ne=>Ne.attachmentId?[Ne.attachmentId]:[]);if($.length===0||!fe.current){for(const Ne of D)Fh(e,Ne.id);return}const pe=new Set(D.map(Ne=>Ne.id));Tu(e,pe,Ne=>{const{error:ne,...ge}=Ne;return{...ge,status:"removing"}}),fe.current($).then(()=>{for(const Ne of D)Fh(e,Ne.id)}).catch(Ne=>{Tu(e,pe,ne=>({...ne,status:"failed",error:`Could not remove attachment: ${Zg(Ne)}`}))})}function ve(D){const $=Array.from(D.currentTarget.files??[]).map(pe=>({relativePath:pe.name,file:pe}));D.currentTarget.value="",O($)}function A(D){const $=PB(D.clipboardData);$.length!==0&&(D.preventDefault(),O($))}function V(D){r||!ic(D.dataTransfer)||(D.preventDefault(),D.stopPropagation(),D.dataTransfer.dropEffect="copy",U(!0))}function de(D){r||!ic(D.dataTransfer)||(D.preventDefault(),D.stopPropagation(),U(!0))}function Z(D){if(!ic(D.dataTransfer))return;const $=D.relatedTarget;$ instanceof Node&&D.currentTarget.contains($)||U(!1)}function Se(D){ic(D.dataTransfer)&&(D.preventDefault(),D.stopPropagation(),U(!1),jT(D.dataTransfer).then(O).catch($=>{const pe={id:Gg(0),reference:Vg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:Zg($)};qg(e,[pe])}))}const ye=C.some(D=>D.status==="uploading"),Me=C.some(D=>D.status==="failed"),He=C.filter(D=>D.status==="uploaded"&&D.path).length,Fe=!r&&!ye&&!Me&&(!!b||He>0);function Ue(){uf()&&(ie.current?.(),ie.current=v5())}function Ve(D){if(D.length===0)return;const $=D.map(_t=>`@${_t}`).join(" "),pe=oc(e).text,Ne=Math.min(te.current.start,pe.length),ne=Math.min(Math.max(Ne,te.current.end),pe.length),ge=pe.slice(0,Ne),Ee=pe.slice(ne),Re=ge&&!/\s$/.test(ge)?" ":"",Te=Ee&&!/^\s/.test(Ee)?" ":"",je=`${Re}${$}${Te}`,Ze=`${ge}${je}${Ee}`,Ae=ge.length+je.length;te.current={start:Ae,end:Ae},Q(Ze),window.requestAnimationFrame(()=>{const _t=K.current;_t&&(Qg(_t),_t.setSelectionRange(Ae,Ae))})}function Ye(D){const $=oc(e).text,pe=$.replace(new RegExp(`@${h5(D)}(?![A-Za-z0-9_])`,"g"),"");pe!==$&&Q(pe.replace(/[ \t]{2,}/g," "))}return d.jsxs("div",{ref:P,className:"compose-drawer","data-open":_?"true":"false",children:[d.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":_?"true":void 0,tabIndex:_?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>Y(!0),children:[d.jsx("span",{"aria-hidden":"true",children:"▴"}),d.jsx("span",{children:"compose"}),b||C.length>0?d.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),d.jsxs("div",{ref:H,className:"compose-drawer-panel","aria-hidden":_?void 0:"true","data-file-drag-active":M?"true":void 0,onDragEnter:de,onDragOver:V,onDragLeave:Z,onDrop:Se,children:[M?d.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,d.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:_?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:q,children:[d.jsx("span",{"aria-hidden":"true",children:"▾"}),d.jsx("span",{className:"compose-drawer-title",children:"compose"}),d.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:i?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),d.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),d.jsx("textarea",{ref:K,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:_?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:D=>{te.current={start:D.target.selectionStart,end:D.target.selectionEnd},Q(D.target.value)},onSelect:D=>{te.current={start:D.currentTarget.selectionStart,end:D.currentTarget.selectionEnd}},onPaste:A,onFocus:Ue,onKeyDown:D=>{if(D.key==="Enter"&&(D.metaKey||D.ctrlKey)){if(D.preventDefault(),D.shiftKey){i&&ae("queue");return}ae("send");return}D.key==="Escape"&&(D.preventDefault(),q())},placeholder:i?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),d.jsx("input",{ref:ee,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:ve}),C.length>0?d.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:C.map(D=>d.jsx(l5,{attachment:D,onRemove:()=>R(D)},D.id))}):null,d.jsxs("div",{className:"compose-drawer-actions",children:[d.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:_?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>ee.current?.click(),disabled:r,children:"+"}),d.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:_?0:-1,onClick:()=>{z(),Qg(K.current),Ue()},disabled:!b&&C.length===0,children:"Clear"}),i?d.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:_?0:-1,title:Me?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>ae("queue"),disabled:!Fe,children:"Queue"}):null,d.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:_?0:-1,title:Me?"Remove failed attachments before sending.":void 0,onClick:()=>ae("send"),disabled:!Fe,children:"Send"})]})]})]})}function l5({attachment:e,onRemove:t}){const i=c5(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return d.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&i?d.jsx("img",{src:i,alt:""}):d.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),d.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),d.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),d.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),d.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function c5(e,t){const i=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),i}function u5(e,t){const i=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=i.get(u[1]);f&&(Xg(r,e.slice(c,u.index)),f.status==="uploaded"&&f.path&&(d5(f)?r.push({kind:"image",path:f.path}):Xg(r,f.path)),c=o.lastIndex)}return Xg(r,e.slice(c)),{parts:r}}function Xg(e,t){if(!t)return;const i=e.at(-1);if(i?.kind==="text"){i.value+=t;return}e.push({kind:"text",value:t})}function d5(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function h5(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ox(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Gg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function Zg(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function lx(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 f5(e,t,i){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 i(e[c])}});await Promise.all(o)}function p5(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Qg(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function uf(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function cx(){if(!uf())return;const e=sc;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function m5(e){lc!==null&&(window.clearTimeout(lc),lc=null),cf.add(e),document.documentElement.setAttribute(mp,"true"),sc()}function g5(e){if(cf.delete(e),cf.size>0||lc!==null){sc();return}lc=window.setTimeout(()=>{if(lc=null,cf.size>0){sc();return}document.documentElement.removeAttribute(mp),sc()},QB),sc()}function v5(){let e=!1,t=null,i=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,f=_5();function g(){t!==null&&(window.clearTimeout(t),t=null),i!==null&&(window.cancelAnimationFrame?.(i),i=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),f?.removeEventListener("geometrychange",b))}function _(w){if(!e){if(w<ax&&typeof window.requestAnimationFrame=="function"){i=window.requestAnimationFrame(b);return}t=window.setTimeout(b,e5)}}function b(){if(e)return;g();const w=Zb(),x=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),x>=JB||x>=ax&&o>=t5){p();return}_(x)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),f?.addEventListener("geometrychange",b),b(),p}function sc(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Zb()}function _5(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function b5(e,t={}){const i=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(w5(u))return u.preventDefault(),u.stopPropagation(),y5(e),!1;if(S5(u)&&i.onInterrupt&&i.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),i.onInterrupt(),!1;if(x5(u)){const f=D_(e);return f?(u.preventDefault(),u.stopPropagation(),R_(f),!1):!0}return C5(u)?(u.preventDefault(),u.stopPropagation(),k5(e,i.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const f=D_(e);if(f){if(u.clipboardData){u.clipboardData.setData("text/plain",f),u.preventDefault();return}u.preventDefault(),R_(f)}},c=u=>{const f=u.clipboardData?.getData("text/plain");if(!f)return;const g=ey(f);u.preventDefault(),u.stopImmediatePropagation(),UT(e,g,i.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 y5(e){const t=D_(e);t&&await R_(t)}function S5(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function w5(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 x5(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function C5(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 k5(e,t){if(navigator.clipboard?.readText)try{const i=await navigator.clipboard.readText();if(!i)return;UT(e,ey(i),t)}catch{}}function UT(e,t,i){if(t){if(i){i(t);return}e.paste(t)}}function D_(e){return e.hasSelection()?e.getSelection():T5(e.element??null)}function T5(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const i=t.toString();if(!i)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return i}return""}async function R_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}E5(e)}function E5(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,i=document.createElement("textarea");i.value=e,i.setAttribute("readonly","true"),i.style.position="fixed",i.style.left="-9999px",i.style.top="0",i.style.opacity="0",document.body.appendChild(i),i.focus({preventScroll:!0}),i.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{i.remove(),t?.focus({preventScroll:!0})}}const D5=[4,10,11,12];function R5(e,t){const i=[e.parser.registerCsiHandler({final:"c"},r=>ux(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>ux(r)),e.parser.registerCsiHandler({final:"n"},r=>N5(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>M5(r)),e.parser.registerCsiHandler({final:"t"},r=>A5(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...D5.map(r=>e.parser.registerOscHandler(r,o=>L5(o)))];return{dispose(){for(const r of i)r.dispose()}}}function ux(e){return vp(e)===0}function N5(e){const t=vp(e);return t===5||t===6}function M5(e){return vp(e)===6}function A5(e){const t=vp(e);return t===14||t===16||t===18}function L5(e){return e.split(";").some(t=>t==="?")}function vp(e){const t=e[0];return typeof t=="number"?t:0}const Vs=new Map,Jg=2*1024*1024,O5=1500,dx=25e3,B5=2500,j5=2500,I5=1e3,P5=2e3,z5=3e4,H5=16*1024*1024,N_=256,$T=rN-3e4,U5=3e3,FT=1e4,$5=3e3,M_=16*1024*1024,_p=4*1024*1024,Uf=25,F5=1e3,K5=3e3,ev=8,W5=100,KT=1e3,hx=[2e3,5e3,15e3,6e4];let q5=0,V5=0,tv=0,nv=null,df=!1,A_=0,hf=0,Ja=!1,fx=!1,qu=null,px=!1,L_=0,od=document.visibilityState!=="hidden";const $f=new Set;let cc=null,Vu=0;const Y5=new TextEncoder,X5=vj();function G5(e,t){Q5(),rj(),ap()&&Qr(0);let i=Vs.get(e);i||(i=tj(e),Vs.set(e,i),xc(i)),i.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>ny(i));const o=(f,g)=>oj(i,f,g),c=f=>{f?(i.foregroundAttachments.add(r),Ff(),VT(i)):(i.foregroundAttachments.delete(r),O_())},u=()=>{i.listeners.delete(t),i.foregroundAttachments.delete(r),O_()};return{status:i.status,snapshot:i.snapshot,output:i.output.slice(),history:i.history,send:o,setForeground:c,detach:u}}function Ql(e){const t=Vs.get(e);t&&(gj(t),Vs.delete(e),O_())}function Z5(e){const t=Vs.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),lo(t),Ks(t),yr(t),co(t),_r(t,"reconnecting"),ho(t);const i=t.socket;return t.socket=null,Va(t,"reconnecting"),i&&(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(),xc(t),!0}function Q5(){if(px)return;px=!0;const e=()=>{if(document.visibilityState==="hidden"){od=!1,L_+=1,YT(),qT(),J5();return}ty(),Vu=Date.now(),Ff()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),Ff()}function Ff(){cc!==null||document.visibilityState==="hidden"||!WT()||typeof window.requestAnimationFrame!="function"||(cc=window.requestAnimationFrame(()=>{if(cc=null,document.visibilityState==="hidden")return;const e=Date.now(),t=Vu>0?e-Vu:0;if(Vu=e,t>=P5){for(const i of Vs.values())i.foregroundAttachments.size>0&&!i.exited&&i.reconnectEnabled&&ao("terminal.connection.foreground_gap",i,{gapMs:t});ty(void 0,{foregroundOnly:!0})}Ff()}))}function WT(){for(const e of Vs.values())if(e.foregroundAttachments.size>0)return!0;return!1}function O_(){WT()||(qT(),Vu=0)}function qT(){cc!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(cc),cc=null}function VT(e){if(document.visibilityState!=="hidden"){if(!od||e?.heartbeatSuspended){ty(e);return}e&&B_(e)}}function ty(e,t={}){if(document.visibilityState==="hidden")return;od=!0;const i=++L_;YT();const r=Array.from(Vs.values()).filter(f=>!f.exited&&f.reconnectEnabled&&f.status!=="unauthorized"),o=r.filter(f=>f===e||f.foregroundAttachments.size>0||cj(f)),c=new Set(o),u=r.filter(f=>!c.has(f));for(const f of o)B_(f);if(!t.foregroundOnly)for(let f=0;f<u.length;f+=ev){const g=u.slice(f,f+ev),p=Math.floor(f/ev)*W5,_=window.setTimeout(()=>{if($f.delete(_),!(i!==L_||!od||document.visibilityState==="hidden"))for(const b of g)B_(b)},p);$f.add(_)}}function YT(){for(const e of $f)window.clearTimeout(e);$f.clear()}function B_(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,xc(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 i=Date.now();if(e.lastResumeProbeSocket===t&&i-e.lastResumeProbeAt<I5)return Promise.resolve("alive");_r(e,"reconnecting"),ho(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=i;const r=`resume-${i.toString(36)}-${(++q5).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||(ao("terminal.connection.resume_timeout",e,{pendingInputs:eo(e)}),_r(e,"reconnecting"),to(e))},B5);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{_r(e,"reconnecting"),to(e)}return c}function J5(){od=!1;for(const e of Vs.values())e.heartbeatSuspended=!0,lo(e),Ks(e),yr(e),co(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,_r(e,"skipped"),ho(e)}function ej(){Ja=!1,ap()&&Qr(0);for(const e of Vs.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),lo(e),Ks(e),yr(e),co(e),_r(e,"reconnecting"),ho(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Va(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),xc(e)}}function iv(){for(const e of Array.from(Vs.keys()))Ql(e)}function tj(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:Uf,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 xc(e){if(!e.reconnectEnabled)return;Va(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Ks(e),yr(e),co(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let i=!1;t.addEventListener("open",()=>{e.socket===t&&(i=!0,e.lastUpgradeAuthProbeAt=0,lo(e),Ks(e),Va(e,"connected"),oo(e,t),XT(e,t),e.isAlive=!0,mx(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(kj(c)){Tj(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),Ja&&(Ja=!1,ap()&&Qr(0));return}if(e.inputProtocolMode==="unknown"&&QT(e,t),c.type==="pong"){e.isAlive=!0;const f=e.resumeProbe;f?.socket===t&&f.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),eo(e)>0&&ao("terminal.connection.resume_alive",e,{pendingInputs:eo(e)}),_r(e,"alive"),oo(e,t),mx(e),sl(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(cd(e),ao("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:eo(e)}),to(e));return}if(c.type==="input_ack"){Sj(e,t,c);return}if(c.type==="input_received"){wj(e,t,c);return}if(c.type==="error"&&xj(e,c),c.type==="input_ack_confirmed"){Dj(e,c);return}const u=ij(e,c);if(ld(e,{type:"message",message:u}),c.type==="snapshot"){for(const f of e.pendingNotices)f.ready=!0;ny(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",lo(e),Ks(e),yr(e),co(e),_r(e,"reconnecting"),ho(e),r.code===1008){e.reconnectEnabled=!1,Va(e,nj(r.reason)?"unauthorized":"closed");return}if(!i&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=z5)&&(e.lastUpgradeAuthProbeAt=o,ld(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Va(e,"closed");return}Va(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,xc(e)},O5)}}),t.addEventListener("error",()=>{})}function mx(e){if(ho(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 i=Date.now(),r=i-e.heartbeatTickAt>dx*1.5;if(e.heartbeatTickAt=i,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:i.toString(36)}))},dx)}function ho(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function nj(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function ij(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((i,r)=>i+ta(r),0),gx(e),e.exited&&ff(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=ta(t.data),gx(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,ff(e)),t):(t.type==="exit"&&(e.exited=!0,ff(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function gx(e){for(;e.outputBytes>Jg&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=ta(t)}e.outputBytes>Jg&&e.output.length===1&&(e.output[0]=Nj(e.output[0],Jg),e.outputBytes=ta(e.output[0]))}function Va(e,t){e.status!==t&&(e.status=t,ld(e,{type:"status",status:t}))}function ld(e,t){for(const i of Array.from(e.listeners))i(t)}function eo(e){return e.unackedInputs.size+e.pendingOut.reduce((t,i)=>t+(i.message.type==="input"&&!i.message.messageId?1:0),0)}function sj(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 ao(e,t,i={}){xi(e,{...i,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:eo(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:i.terminalId??sj(t)}),A_+=1,hf=0,Qr(KT)}function rj(){if(fx)return;fx=!0;const e=()=>{document.visibilityState==="hidden"||Ja||ap()&&Qr(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Qr(e){if(df){qu=qu===null?e:Math.min(qu,e);return}nv!==null||Ja||document.visibilityState==="hidden"||navigator.onLine===!1||(nv=window.setTimeout(()=>{nv=null,aj()},e))}async function aj(){if(df||Ja||document.visibilityState==="hidden"||navigator.onLine===!1)return;df=!0;const e=A_;try{const t=await dN();if(t.outcome==="auth_blocked"){Ja=!0;return}if(t.outcome==="retryable"){const i=hx[Math.min(hf,hx.length-1)];hf+=1,Qr(i);return}if(hf=0,t.outcome==="sent"&&t.hasMore){Qr(0);return}}finally{df=!1;const t=qu;qu=null,t!==null&&Qr(t),A_!==e&&!Ja&&Qr(KT)}}function oj(e,t,i={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=bj(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=ta(o);if(c>H5)return"rejected";const u=i.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(!yj(e,f))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(ao("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:eo(e)}),VT(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)>_p))return!u&&r.type==="input"?"rejected":lj(e,r)?(p&&g&&oo(e,g),"queued"):e.pendingOut.length>=N_||e.pendingOutBytes+c>M_?"rejected":(e.pendingOut.push(f),e.pendingOutBytes+=c,_x(e,f),p&&g&&oo(e,g),"queued");if(p){_x(e,f);try{return g.send(o),ZT(e,f),"sent"}catch{if(b&&u&&e.pendingOut.length<N_&&e.pendingOutBytes+c<=M_)return e.pendingOut.push(f),e.pendingOutBytes+=c,g.close(),"queued";al(e,f),g.close()}}return"rejected"}function oo(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Ks(e);return}let i=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>_p){Rj(e,t),dj(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){XT(e,t);return}try{t.send(r.encoded),ZT(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=Uf,i=!0}e.outboundFlushDelayMs=Uf,Ks(e),i&&queueMicrotask(()=>{e.pendingOut.length===0&&ld(e,{type:"outbound_flushed"})})}function lj(e,t){const i=e.pendingOut.at(-1);if(!i||!("terminalId"in t)||!("terminalId"in i.message)||i.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&i.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&i.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&i.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&i.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,i.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-i.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=ta(o);return e.pendingOutBytes+=c-i.bytes,i.message=r,i.encoded=o,i.bytes=c,!0}function lo(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=Uf}function Ks(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function Kf(e){return e.pendingOut.some(t=>t.message.type==="input")}function cj(e){return Kf(e)||e.unackedInputs.size>0}function uj(e){if(!Kf(e))return;const t=e.pendingOut.filter(i=>i.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((i,r)=>i+r.bytes,0))}function dj(e,t){e.outboundStallWatchdog!==null||!Kf(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!Kf(e))return;const i=e.inputProtocolMode==="unknown",r=t.bufferedAmount>_p;if(!i&&!r){oo(e,t);return}uj(e),to(e)},K5))}function yr(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function XT(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)&&to(e)},$5))}function GT(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function cd(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function co(e){GT(e),cd(e)}function sl(e){GT(e),j_(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 i=vx(e),r=hj(e),o=pj(e);if(i===null&&r===null&&o===null){cd(e);return}if(e.inputAckProbe)return;const c=i===null?Number.POSITIVE_INFINITY:i+U5,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(j_(e,{notifyImmediately:!0})){sl(e);return}if(fj(e),vx(e)===null){sl(e);return}mj(e,t)},u)}function hj(e){let t=null;for(const i of e.unackedInputs.values()){if(i.receivedAt===null||i.writeSlowReported)continue;const r=i.receivedAt+FT;t=t===null?r:Math.min(t,r)}return t}function fj(e){const t=Date.now();for(const i of e.unackedInputs.values())i.receivedAt===null||i.writeSlowReported||t-i.receivedAt<FT||(i.writeSlowReported=!0,ao("terminal.input.pty_write_slow",e,{terminalId:i.message.type==="input"?i.message.terminalId:null,waitMs:t-i.receivedAt}))}function vx(e){let t=null;for(const i of e.unackedInputs.values())i.sentInstanceId!==e.serverInstanceId||i.receivedInstanceId===e.serverInstanceId||i.lastSentAt===null||(t=t===null?i.lastSentAt:Math.min(t,i.lastSentAt));return t}function pj(e){let t=null;for(const i of e.unackedInputs.values()){if(i.firstSentAt===null)continue;const r=i.firstSentAt+$T;t=t===null?r:Math.min(t,r)}return t}function mj(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>_p){to(e);return}const i=`input-ack-${Date.now().toString(36)}-${(++V5).toString(36)}`;ao("terminal.input.delivery_probe_started",e,{pendingInputs:eo(e)});const r={socket:t,nonce:i,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(ao("terminal.input.delivery_probe_timeout",e,{pendingInputs:eo(e)}),cd(e),to(e))},j5);try{t.send(JSON.stringify({type:"ping",nonce:i}))}catch{cd(e),to(e)}}function _r(e,t){const i=e.resumeProbe;i&&(e.resumeProbe=null,window.clearTimeout(i.timeout),i.resolve(t))}function to(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),lo(e),Ks(e),yr(e),co(e),_r(e,"reconnecting"),ho(e);const t=e.socket;e.socket=null,Va(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),xc(e)}function gj(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),lo(e),Ks(e),yr(e),co(e),_r(e,"skipped"),ho(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ff(e),e.listeners.clear()}function vj(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function _j(){return tv=(tv+1)%Number.MAX_SAFE_INTEGER,`${X5}-${tv.toString(36)}`.slice(0,EC)}function bj(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const i=_j();return i.length===0||i.length>EC?null:{...t,messageId:i}}function yj(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const i=t.message.messageId;return!!(i&&!e.unackedInputs.has(i)&&e.unackedInputs.size+e.pendingAckReceipts.size<N_&&e.unackedInputBytes+t.bytes<=M_)}function _x(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function al(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function Sj(e,t,i){const r=e.unackedInputs.get(i.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==i.terminalId){const c=e.pendingAckReceipts.get(i.messageId);c?.terminalId===i.terminalId&&I_(e,t,c);return}if(al(e,r),sl(e),!iy(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:i.terminalId,messageId:i.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:i.terminalId,messageId:i.messageId})};e.pendingAckReceipts.set(i.messageId,o),I_(e,t,o)}function wj(e,t,i){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(i.messageId);r?.message.type!=="input"||r.message.terminalId!==i.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",sl(e))}function xj(e,t){if(!t.terminalId||!t.messageId)return;const i=e.unackedInputs.get(t.messageId);i?.message.type==="input"&&i.message.terminalId===t.terminalId&&(al(e,i),sl(e))}function ZT(e,t){if(t.message.type!=="input"||!t.message.messageId||!iy(e.inputProtocolMode)||!e.serverInstanceId)return;const i=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=i,t.lastSentAt=i,t.inputState="sent",sl(e)}function Cj(e){if(j_(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),i=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){al(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",i.push(r))}i.length!==0&&(e.pendingOut.unshift(...i),e.pendingOutBytes+=i.reduce((r,o)=>r+o.bytes,0))}function j_(e,t={}){const i=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&i-u.firstSentAt>=$T&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&al(e,u)}return o>0&&(eE(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&&ny(e)),!0}function kj(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function Tj(e,t,i,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){QT(e,t);return}yr(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=i,c===i?(Cj(e),Ej(e,t)):c!==null&&(JT(e),tE(e)),oo(e,t)}function QT(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",yr(e),e.serverInstanceId=null,JT(e),tE(e);for(const i of e.pendingOut){if(i.message.type!=="input"||!i.message.messageId)continue;al(e,i);const{messageId:r,...o}=i.message;i.message=o,i.encoded=JSON.stringify(o);const c=ta(i.encoded);e.pendingOutBytes+=c-i.bytes,i.bytes=c}oo(e,t)}}function JT(e){const t=new Set;let i=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(i+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&al(e,o)}i>0&&eE(e,{message:`The terminal server restarted before ${i} ${i===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${i===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function eE(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function ny(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(i=>i.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(i=>!i.ready);for(const i of t)ld(e,{type:"message",message:{type:"error",message:i.message}})}}function ff(e){lo(e),Ks(e),yr(e),co(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function I_(e,t,i){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!iy(e.inputProtocolMode)||e.serverInstanceId!==i.instanceId))try{t.send(i.encoded)}catch{t.close()}}function iy(e){return e==="ack"||e==="receipt-ack"}function Ej(e,t){for(const i of e.pendingAckReceipts.values())if(I_(e,t,i),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function Dj(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function tE(e){e.pendingAckReceipts.clear()}function Rj(e,t){if(e.outboundFlushTimer!==null)return;const i=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(F5,i*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,oo(e,t)},i)}function ta(e){return Y5.encode(e).byteLength}function Nj(e,t){if(ta(e)<=t)return e;let i=0,r=e.length;for(;i<r;){const o=Math.floor((i+r)/2);ta(e.slice(o))<=t?r=o:i=o+1}return i>0&&i<e.length&&e.charCodeAt(i)>=56320&&e.charCodeAt(i)<=57343&&(i+=1),e.slice(i)}const Mj=[0,50,150,350],Aj=[100,300,750],Lj=2,Oj=[300,1200,2500],Bj=1e3,jj=1e5,Ij="",P_="\x1B[?1049l\x1B[?1047l\x1B[?47l",Pj=new Set(["47","1047","1049"]),zj=400,bx=9,Hj=9,Uj=32,$j=1.42,Fj=2,Kj=24,Wj=720,qj=60,Vj=1260,Yj=6,Xj=2,yx=[500,1500,3e3,5e3,8e3],Sx=15e3,Gj=2,Zj=1e3,wx="Do not take action. Wait for my next input.",Wf=6e4,Qj=Wf+5*6e4,xx=Wf+6e4,Jj=40,Kh=240,e4=5e3,Yu=new Map,Jl=new Map;function Cx({terminal:e,serverApi:t,active:i,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:f,onSelect:g,onClose:p,onExit:_,onSnapshot:b,onAuthClose:w}){const x=v.useSyncExternalStore(dk,Lv,()=>Go),C=v.useSyncExternalStore(hk,Ov,()=>dc),N=v.useSyncExternalStore(fk,jv,()=>!0),L=v.useSyncExternalStore(Jh,Iv,()=>!0),M=v.useSyncExternalStore(Jh,Pv,()=>!0),U=v.useSyncExternalStore(cb,no,()=>uc),P=v.useSyncExternalStore($u,()=>Fu("history.toggle"),()=>"Alt+H"),H=v.useSyncExternalStore($u,()=>Fu("scrollback.toggle"),()=>"Alt+S"),K=v.useSyncExternalStore($u,()=>Fu("subagents.toggle"),()=>"Alt+A"),ee=v.useRef(null),j=v.useRef(null),J=v.useRef(null),fe=v.useRef(null),ie=v.useRef(null),te=v.useRef(e.id),Y=v.useRef({onExit:_,onSnapshot:b}),Q=v.useRef(t.createWebSocketUrl),q=v.useRef(w),ae=v.useRef(null),O=v.useRef(null),R=v.useRef(null),z=v.useRef(!1),ce=v.useRef(new Map),ve=v.useRef(new Map),A=v.useRef(new Set),V=v.useRef([]),de=v.useRef(!1),Z=v.useRef(null),Se=v.useRef(0),ye=v.useRef(!1),Me=v.useRef(!1),He=v.useRef(!1),Fe=v.useRef({terminalId:e.id,enabled:!1}),Ue=v.useRef([]),Ve=v.useRef([]),Ye=v.useRef(0),D=v.useRef(!1),$=v.useRef(null),pe=v.useRef(0),Ne=v.useRef(0),ne=v.useRef(null),ge=v.useRef(null),Ee=v.useRef(!1),Re=v.useRef(!1),Te=v.useRef(!1),je=v.useRef(null),Ze=v.useRef(!1),Ae=v.useRef(null),_t=v.useRef(null),bt=v.useRef(!1),at=v.useRef(!1),ot=v.useRef(!1),Bt=v.useRef(!1),ln=v.useRef(!1),Ht=v.useRef(!1),On=v.useRef(!1),Ut=v.useRef(i),kt=v.useRef(r),$t=v.useRef(c),At=v.useRef(x),kn=v.useRef(C),mi=v.useRef(!1),le=v.useRef(!1),Ge=v.useRef(null),it=v.useRef(null),ct=v.useRef(0),Dt=v.useRef(0),jt=v.useRef(e.id),hn=v.useRef(()=>{}),Tn=v.useRef(null),_e=v.useRef(null),ze=v.useRef(!1),Ie=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),We=v.useRef(0),Je=v.useRef(null),It=v.useRef(0),Ft=v.useRef(null),Gn=v.useRef(0),en=v.useRef(!1),Bn=v.useRef(!1),vn=v.useRef(null),_n=v.useRef(null),[,sn]=v.useState("connecting"),[Zn,Ki]=v.useState(!1),[gi,os]=v.useState(null),[sa,ls]=v.useState(!1),[oi,cs]=v.useState(null),[us,ds]=v.useState(!1),[Mi,Bs]=v.useState(!1),[fn,Ai]=v.useState(!1),[fo,Li]=v.useState(!1),[tn,wr]=v.useState(null),[ra,Xs]=v.useState([]),po=v.useRef([]),Qn=e.agentCache&&tn&&e.agentCache.source.provider===tn.provider&&e.agentCache.source.sessionId===tn.sessionId?e.agentCache:null,[js,Wi]=v.useState(()=>Date.now()),[En,aa]=v.useState(!1),[cl,xr]=v.useState(null),[Gs,Is]=v.useState(!1),[mo,Dn]=v.useState(!1),[li,Cr]=v.useState(null),[go,hs]=v.useState(!1),[vo,Zs]=v.useState(!1),[fs,Ps]=v.useState(null),[Qs,ps]=v.useState(null),vi=f?.serverKey.trim()||(t.isAgent?"agent":"local"),[kc,oa]=v.useState(()=>Dg(e.id)),Oi=tn?.provider??e.agentStatus?.provider??null,_i=Oi!==null||ec(e.currentCommand),la=Oi==="claude"||aE(e.currentCommand),_o=Oi!==null||ec(e.currentCommand),qi=e.capabilities?.tmuxScrollback===!0,ci=qi&&(kc??(_o?M:L)),[bo,yo]=v.useState(!1);v.useLayoutEffect(()=>{Ut.current=i},[i]),v.useLayoutEffect(()=>{kt.current=r},[r]),v.useLayoutEffect(()=>{$t.current=c},[c]),v.useLayoutEffect(()=>{At.current=x},[x]),v.useLayoutEffect(()=>{kn.current=C},[C]),v.useLayoutEffect(()=>{mi.current=Gs},[Gs]),v.useLayoutEffect(()=>{le.current=mo},[mo]),v.useLayoutEffect(()=>{it.current=tn},[tn]);const Ci=v.useCallback((T,F={})=>{!T&&F.preserveOnNull||(J1(it.current,T)||(Dt.current+=1),it.current=T,wr(Le=>Le&&T&&Le.provider===T.provider&&Le.sessionId===T.sessionId?Le:T))},[]),Bi=v.useCallback(async()=>{const T=await t.getTerminalTranscriptSource(e.id);return jt.current===e.id&&(po.current=T.candidates??[],Xs(T.candidates??[])),T.source},[t,e.id]),kr=v.useCallback(()=>{Dn(!1),Is(!0)},[]),ms=v.useCallback(()=>{it.current&&(Is(!1),Dn(!0))},[]),bi=v.useCallback(async(T={})=>{const F=await Tx(vi,t,T);return Cr(F),F},[vi,t]),Rn=v.useCallback((T,F="info")=>{Ft.current!==null&&window.clearTimeout(Ft.current),ps({id:It.current++,message:T,tone:F}),Ft.current=window.setTimeout(()=>{ps(null),Ft.current=null},3200)},[]),er=v.useCallback(()=>{const T=f?.serverKey.trim()||"local",F=f?.serverName.trim()||"Local",Le=f?.tabName.trim()||e.title||"Terminal",Xe=li?.instances.find(gt=>gt.cwd===e.cwd);if(Xe&&Ex(Wh(T,Xe.id))){Rn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Xe&&sv(Wh(T,Xe.id),Xe.url)){Rn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Qe=null;const rt=()=>((!Qe||iE(Qe))&&(Qe=window.open("about:blank","_blank"),t4(Qe)),Qe);li?.installed!==!0&&rt(),Zs(!0),Ps(null),(async()=>{let gt=li;if(gt?.installed||(gt=await bi({force:!0})),!gt?.installed||gt.supported===!1){rv(Qe),hs(!0);return}const vt=gt.instances.find(Yt=>Yt.cwd===e.cwd);if(vt){const Yt=Wh(T,vt.id);if(Dx(Qe,Yt,vt.url)||sv(Yt,vt.url)!==null){Rn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const nt=rt();return{response:await t.openCodeServer({terminalId:e.id,serverName:F,tabName:Le}),targetPopup:nt}})().then(gt=>{if(!gt)return;const{response:vt,targetPopup:nt}=gt;z_(vi,vt.status),Cr(vt.status);const nn=Wh(T,vt.instance.id);if(Ex(nn)){rv(nt),Rn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}Dx(nt,nn,vt.url)||sv(nn,vt.url)?Rn("Opening VS Code..."):Rn("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(gt=>{rv(Qe),hs(!0),Ps(qh(gt))}).finally(()=>Zs(!1))},[f?.serverName,f?.tabName,vi,li,bi,t,Rn,e.cwd,e.id,e.title]);v.useEffect(()=>{let T=!1;return Tx(vi,t).then(F=>{T||Cr(F)}).catch(()=>{}),()=>{T=!0}},[vi,t]),v.useEffect(()=>{if(li?.job?.status!=="running")return;const T=window.setInterval(()=>{bi({force:!0}).catch(F=>Ps(qh(F)))},1e3);return()=>window.clearInterval(T)},[li?.job?.status,bi]),v.useEffect(()=>()=>{Ft.current!==null&&window.clearTimeout(Ft.current)},[]),v.useLayoutEffect(()=>{hn.current=kr},[kr]),v.useLayoutEffect(()=>{_e.current=Qn},[Qn]),v.useLayoutEffect(()=>{ze.current=En},[En]),v.useLayoutEffect(()=>{en.current=_i},[_i]),v.useLayoutEffect(()=>{Bn.current=la},[la]),v.useLayoutEffect(()=>{const T=Fe.current;Me.current=ci,He.current=qi,Fe.current={terminalId:e.id,enabled:ci},Mx(ee.current,ci),T.terminalId===e.id&&T.enabled&&!ci&&Td(),ci||Ai(!1)},[e.id,ci,qi]),v.useEffect(()=>{oa(Dg(e.id)),Se.current=0,ye.current=!1,Ai(!1),vl()},[e.id]),v.useEffect(()=>Jh(()=>{oa(Dg(e.id))}),[e.id]),v.useEffect(()=>()=>{Oc()},[]),v.useEffect(()=>{ie.current?.(r&&e.status==="running"),r&&e.status==="running"&&nr()},[r,e.id,e.status]),v.useEffect(()=>{r&&i&&e.status==="running"&&_s("auto")},[i,r,e.status]),v.useEffect(()=>{Y.current={onExit:_,onSnapshot:b}},[_,b]),v.useLayoutEffect(()=>{Q.current=t.createWebSocketUrl,q.current=w},[t,w]),v.useLayoutEffect(()=>{te.current=e.id,On.current=!1,Li(!1)},[e.id]),v.useEffect(()=>{let T=!1,F=null,Le=0;const Xe=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Qe=Xe||C4(e.currentCommand),rt=Xe||ec(e.currentCommand);function gt(){F!==null&&(window.clearTimeout(F),F=null)}function vt(nn){if(T)return;let Yt;if(nn)Yt=Sx;else if(Le<yx.length){if(!Qe)return;Yt=yx[Le++]}else{if(!rt)return;Yt=Sx}F=window.setTimeout(()=>{F=null,nt()},Yt)}async function nt(){try{const nn=it.current!==null,Yt=await Bi();if(T)return;if(Yt){ct.current=0,Ci(Yt),vt(!0);return}ct.current+=1;const Kt=!!(nn&&Qe&&ct.current<Gj);Ci(null,{preserveOnNull:Kt}),vt(Kt)}catch(nn){if(T)return;av(nn)&&Ci(null),vt(!1)}}return jt.current!==e.id&&(po.current=[],Xs([]),jt.current=e.id,Dt.current+=1,it.current=null,ct.current=0,wr(null)),e.status!=="running"?(Dt.current+=1,it.current=null,ct.current=0,wr(null),()=>{T=!0,gt()}):(nt(),()=>{T=!0,gt()})},[Ci,Bi,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const T=s4(e.id,tn),F=Tn.current;F!==null&&T!==null&&F!==T&&(ge.current=null,Ee.current=!1,Re.current=!1,Dn(!1)),Tn.current=T},[e.id,tn?.provider,tn?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!tn){aa(!1);return}const T=window.setInterval(()=>{Wi(Date.now())},Zj);return()=>{window.clearInterval(T)}},[e.status,tn?.provider,tn?.sessionId]),v.useEffect(()=>{const T=i4(Qn);Ie.current.key!==T&&(Ie.current={key:T,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[Qn?.expiresAt,Qn?.source?.provider,Qn?.source?.sessionId]),v.useEffect(()=>{if(!En||!Qn||Qn.status!=="ready")return;const T=sE(Qn,js);if(T===null||T<=0)return;const F=Ie.current;!F.warnedFiveMinutes&&T<=Qj&&T>xx&&(F.warnedFiveMinutes=!0,ar({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."})),!F.warnedOneMinute&&T<=xx&&T>Wf&&(F.warnedOneMinute=!0,ar({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!F.sent&&!F.skipped&&T<=Wf&&Dd()},[En,js,Qn,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function T(F){if(!Ut.current||!kt.current||F.isComposing||F.key==="Process"||o4(F.target))return;const Le=vk(F);if(Le?.id==="history.toggle"&&(it.current||po.current.length)){F.preventDefault(),F.stopPropagation(),mi.current?Is(!1):hn.current();return}if(Le?.id==="subagents.toggle"&&it.current){F.preventDefault(),F.stopPropagation(),le.current?Dn(!1):ms();return}if(Le?.id==="scrollback.toggle"&&He.current){F.preventDefault(),F.stopPropagation(),Lc();return}}return window.addEventListener("keydown",T,!0),()=>window.removeEventListener("keydown",T,!0)},[]),v.useEffect(()=>{const T=j.current;T&&(T.options.disableStdin=e.status==="exited"),e.status==="exited"&&sn("closed")},[e.status]),v.useEffect(()=>{const T=j.current;T&&(T.options.fontSize=x,Eg(x,kn.current).then(()=>{At.current===x&&In()}))},[x]),v.useEffect(()=>{const T=j.current;T&&(T.options.fontFamily=Av(C),Eg(At.current,C).then(()=>{kn.current===C&&In()}))},[C]),v.useEffect(()=>{const T=j.current;T&&(T.options.theme=kx(U))},[U]),v.useEffect(()=>{const T=ee.current;if(!T)return;let F=!1,Le=null,Xe=null,Qe=null,rt=null,gt=null,vt=null,nt=null;ae.current=null,ln.current=!1,Ht.current=!1,Ze.current=!1,fa(),hl(),gs(),de.current=!1;const nn=At.current,Yt=kn.current,Kt=new UO({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Av(Yt),fontSize:nn,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:jj,theme:{...kx(no())}}),Hs=new AA;return Kt.loadAddon(Hs),rt=R5(Kt),j.current=Kt,J.current=Hs,Eg(nn,Yt).then(()=>{if(F)return;Kt.open(T),Mx(T,Me.current),ln.current=!0,Le=b5(Kt,{onPasteText:Nd,onInterrupt:Rd,shouldInterruptPlainCtrlC:()=>Bn.current}),kt.current&&Ut.current&&e.status==="running"&&_s("auto"),In(),gt=N4(T,Kt,()=>At.current*1.2,Jn,bs=>{Yi(bs)},Oe,Pe,()=>Me.current,Ac),vt=E4(T,Kt,Jn,bs=>{Yi(bs)},Oe,Pe,()=>Me.current,Ac);const Eo=new hB;Xe=Kt.onData(bs=>{if(On.current){const Do=SB(bs);if(Do){ko(!1),Xi(Do);return}}const Ii=Eo.accept(bs);Ii&&Xi(Ii)}),Qe=Kt.onScroll(bs=>{if(at.current||Bt.current||ot.current){Nn();return}ml(),ss(Kt)&&k({scrollToBottom:!0}),Jn(),!Me.current&&bs<=3&&Yi()}),nt=new ResizeObserver(()=>{Er()}),nt.observe(T),Ht.current&&(vs(),Ht.current=!1,In()),ha()}),()=>{_l(fe.current,{updateUi:!1}),F=!0,ln.current=!1,Ht.current=!1,fa(),hl(),O.current=null,R.current=null,z.current=!1,fl(),de.current=!1,pl(),ot.current=!1,D.current=!1,pe.current+=1,Ne.current+=1,$.current=null,vn.current=null,_n.current=null,Te.current=!1,je.current=null,Ki(!1),gt?.(),vt?.(),nt?.disconnect(),Le?.dispose(),Xe?.dispose(),Qe?.dispose(),rt?.dispose(),Kt.dispose(),j.current=null,J.current=null}},[e.id]),v.useEffect(()=>{const T=Q.current(e.id),F=G5(T,ut);return fe.current=F.send,ie.current=F.setForeground,F.setForeground(kt.current&&e.status==="running"),sn(F.status),F.status==="connected"&&In(),F.snapshot&&(Y.current.onSnapshot(F.snapshot,{notifyCompletion:!1}),j.current&&(In(),Vi(F.output,F.history),In())),()=>{_l(F.send,{updateUi:!1}),F.setForeground(!1),F.detach(),fe.current=null,ie.current=null}},[e.id,e.status]);function ut(T){if(T.type==="status"){sn(T.status),T.status==="unauthorized"&&q.current?.({source:"terminal-ws-1008",terminalId:e.id}),T.status==="connected"&&(In(),xo());return}if(T.type==="upgrade_rejected"){q.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(T.type==="outbound_flushed"){de.current&&(de.current=!1,Bc());return}ua(T.message)}function gs(T=[],F=null){Ue.current=[],Ve.current=Vh(T),Ye.current=0,D.current=!1,$.current=null,ot.current=!1,pe.current+=1,ne.current=F,ge.current=null,Ee.current=!1,Re.current=!1,Te.current=!1,je.current=null,Ht.current=!1,vn.current=null,_n.current=null,Ae.current=null,bt.current=!1,Ki(!1),os(null),ls(!1),cs(null),ds(!1),Bs(!1)}function Vi(T=[],F=null){if(ot.current||D.current){_n.current={output:T,history:F,appendFromLiveOutputIndex:Ve.current.length};return}gs(T,F),jn()}function Tr(){if(ot.current||D.current)return!1;const T=_n.current;if(!T)return!1;const F=Ve.current.slice(T.appendFromLiveOutputIndex);return _n.current=null,gs([...T.output,...F],T.history),jn(),!0}function jn(){if(!j.current||!ln.current){Ht.current=!0;return}Ht.current=!1,vs()}async function vs(){const T=j.current;if(!T)return;const F=Yh(T,bt.current),Le=F?Ve.current.length:Ye.current,Xe=await tr(T,{liveOutputLimit:Le,scrollToBottom:F});j.current===T&&(Nn(),Xe&&xo())}function tr(T,F={}){return new Promise(Le=>{ot.current=!0,D.current=!1;const Xe=pe.current+1;pe.current=Xe;const Qe=Math.max(0,Math.min(F.liveOutputLimit??Ve.current.length,Ve.current.length)),rt=F.historyPages??Ue.current,gt=()=>j.current===T&&pe.current===Xe,vt=()=>gt()&&(F.isCurrent?.()??!0),nt=()=>{gt()&&(ot.current=!1),Le(!1)},nn=()=>{if(!vt()){nt();return}try{Ye.current=Qe,F.scrollToBottom&&ht(T)}finally{if(ot.current=!1,Tr()){Le(!1);return}const Kt=S();Kt?k(Kt):F.applyDeferredSnapshot!==!1&&xe(),Le(!0)}},Yt=()=>{if(!vt()){nt();return}T.clear();const Kt=Vh([...rt,...Ve.current.slice(0,Qe)]);if(Kt.length===0){nn();return}for(let Hs=0;Hs<Kt.length;Hs+=1){const Eo=Kt[Hs];Hs===Kt.length-1?T.write(Eo,nn):T.write(Eo)}};if(T.buffer.active.type==="alternate"){T.write(P_,Yt);return}Yt()})}async function Yi(T=0){const F=j.current;if(Te.current||!F)return;if(B(F)){Nn();return}const Le=ne.current,Xe=Ne.current,Qe=Symbol("history-load"),rt=()=>j.current===F&&Ne.current===Xe;je.current=Qe,Te.current=!0,Ki(!0);const gt=F.buffer.active.viewportY;try{let vt=!!(Le&&!Le.hasMore);if(!vt)try{const nt=await t.getTerminalHistory(e.id,{beforeLine:Le?.startLine??0,...Le?.snapshotHistorySize!==void 0?{snapshotHistorySize:Le.snapshotHistorySize}:{},...Le?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Le.snapshotHistoryLimit}:{},...Le?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Le.snapshotHistoryToken}:{},...Le?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Le.snapshotPaneWidth}:{},limit:Bj});if(!rt()||ne.current!==Le)return;const nn=()=>rt()&&ne.current===Le;if(nt.invalidated){ir();return}const Yt=nt.hasMore&&nt.snapshotHistorySize!==void 0&&nt.snapshotPaneWidth!==void 0,Kt={startLine:nt.startLine,endLine:nt.endLine,hasMore:Yt,...nt.snapshotHistorySize!==void 0?{snapshotHistorySize:nt.snapshotHistorySize}:{},...nt.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:nt.snapshotHistoryLimit}:{},...nt.snapshotHistoryToken!==void 0?{snapshotHistoryToken:nt.snapshotHistoryToken}:{},...nt.snapshotPaneWidth!==void 0?{snapshotPaneWidth:nt.snapshotPaneWidth}:{}};if(nt.output.length>0){await ca(F,nt.output,gt,T)&&nn()&&(ne.current=Kt);return}if(!nn())return;ne.current=Kt,vt=!Yt}catch(nt){vt=rt()&&av(nt)}if(vt){if(!rt()||B(F)){Nn();return}await Tc(F,gt,T,rt)}}catch{}finally{je.current===Qe&&(je.current=null,Te.current=!1,Ki(!1))}}async function Tc(T,F,Le,Xe){if(!Xe()||Ee.current||Re.current)return;const Qe=it.current,rt=Dt.current,gt=ge.current,vt=()=>Xe()&&Dt.current===rt&&J1(Qe,it.current)&&ge.current===gt;try{const nt=await t.getTerminalTranscriptHistory(e.id,{...gt?{cursor:gt}:{},limit:zj}),nn=nt.output.map(Xb);if(!nt.source||nt.terminalId!==e.id||!vt())return;if(Qe&&!Xa(Qe,nt.source)){ge.current=null,Ee.current=!1,Re.current=!1,Ci(nt.source);return}if(nn.length===0){Ci(nt.source),ge.current=nt.cursor,Re.current=!nt.hasMore||!nt.cursor;return}await ca(T,nn,F,Le,vt)&&vt()&&(Ci(nt.source),ge.current=nt.cursor,Re.current=!nt.hasMore||!nt.cursor)}catch(nt){vt()&&av(nt)&&(Ee.current=!0)}}async function ca(T,F,Le,Xe,Qe){if(B(T)||Qe&&!Qe())return Nn(),!1;const rt=Ue.current,gt=[...F,...rt],vt=k4(F),nt=pe.current+1,nn=await tr(T,{liveOutputLimit:Ye.current,scrollToBottom:!1,historyPages:gt,applyDeferredSnapshot:!1,...Qe?{isCurrent:Qe}:{}}),Yt=Qe!==void 0&&!Qe();return!nn||Yt||j.current!==T?(Yt&&j.current===T&&pe.current===nt&&await tr(T,{liveOutputLimit:Ye.current,scrollToBottom:!1,historyPages:rt,applyDeferredSnapshot:!1})&&j.current===T&&(Mt(T,Le),bt.current=!ss(T),Jn()),!1):(Ue.current=gt,Mt(T,Math.max(0,Le+vt+Math.min(0,Xe))),bt.current=!ss(T),Jn(),!0)}v.useEffect(()=>{const T=window.visualViewport;function F(){document.visibilityState!=="hidden"&&nr()}function Le(){nr()}function Xe(){nr()}function Qe(){Er()}function rt(){ji()}return document.addEventListener("visibilitychange",F),window.addEventListener("pageshow",Le),window.addEventListener("online",Xe),window.addEventListener("resize",Qe),window.addEventListener(zf,rt),T?.addEventListener("resize",Qe),T?.addEventListener("scroll",Qe),()=>{document.removeEventListener("visibilitychange",F),window.removeEventListener("pageshow",Le),window.removeEventListener("online",Xe),window.removeEventListener("resize",Qe),window.removeEventListener(zf,rt),T?.removeEventListener("resize",Qe),T?.removeEventListener("scroll",Qe)}},[e.id]);function nr(){document.visibilityState==="hidden"||!kt.current||(xo(),In())}function ir(){const T=Q.current(e.id);Ne.current+=1,Ze.current=!0,vn.current=null,sn("reconnecting"),In(),Z5(T)}function ua(T){if(T.type==="snapshot"&&T.terminal.id===e.id){Ne.current+=1,Y.current.onSnapshot(T.terminal,{notifyCompletion:!1});const Le=Ze.current;Ze.current=!1;const Xe=j.current;if(!Xe)return;if(In(),Le){ul(T.output,T.history??null);return}if(X(Xe,T.terminal)){he(T.output,T.history??null),Nn(),In();return}Vi(T.output,T.history??null),In();return}if(T.type==="terminal_updated"&&T.terminal.id===e.id){Y.current.onSnapshot(T.terminal,{notifyCompletion:!0});return}if(T.type==="output"&&T.terminalId===e.id){const Le=oE(T.data);if(!Le)return;Ve.current.push(Le),j.current&&ln.current?k({scrollToBottom:!0}):Ht.current=!0;return}const F=j.current;if(F){if(T.type==="exit"&&T.terminalId===e.id){Y.current.onExit(T.exitCode),sn("closed");return}T.type==="error"&&F.writeln(`\r
|
|
51
|
+
[nterminal] ${T.message}`)}}function ul(T,F){Vi(T,F),In()}function Ec(T=25){if(document.visibilityState==="hidden"||!kt.current||ce.current.has(T))return;const F=window.setTimeout(()=>{ce.current.delete(T),!So()&&kd()},T);ce.current.set(T,F)}function Er(){So()||ha()}function So(){const T=wo();return T&&da(T)?(z.current=!0,R.current=T,!0):T&&dl(T)?(z.current=!1,R.current=null,!0):((!T||!T.composeOpen&&!T.keyboardVisible)&&(z.current=!1,R.current=null),!1)}function ji(){if(!z.current)return;const T=wo();T&&(T.composeOpen||T.keyboardVisible)||(z.current=!1,R.current=null)}function da(T){if(!T.mobileLike||!T.composeOpen&&!T.keyboardVisible)return!1;const F=O.current;return F?sr(T.windowWidth,F.windowWidth)&&sr(T.visualViewportWidth,F.visualViewportWidth)&&sr(T.containerWidth,F.containerWidth):!1}function dl(T){if(!T.mobileLike||T.composeOpen||T.keyboardVisible)return!1;const F=R.current;return!F||!F.composeOpen&&!F.keyboardVisible?!1:sr(T.windowWidth,F.windowWidth)&&sr(T.visualViewportWidth,F.visualViewportWidth)&&sr(T.containerWidth,F.containerWidth)}function wo(){const T=ee.current;if(!T||T.isConnected===!1)return null;const F=T.getBoundingClientRect(),Le=Dr(window.innerWidth)??0,Xe=Dr(window.visualViewport?.width)??Le,Qe=Dr(F.width)??Dr(T.clientWidth)??Le;if(Le<=0||Xe<=0||Qe<=0)return null;const{keyboardVisible:rt}=T_(),gt=document.documentElement.hasAttribute(mp),vt=Dc()||rt;return{windowWidth:Le,visualViewportWidth:Xe,containerWidth:Qe,composeOpen:gt,keyboardVisible:rt,mobileLike:vt}}function Dc(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Rc(){return T_().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Dr(T){return typeof T=="number"&&Number.isFinite(T)&&T>0?T:null}function sr(T,F){return Math.abs(T-F)<=Lj}function ha(){for(const T of Mj)Ec(T)}function In(){ae.current=null,ha()}function xo(){if(rr(),A.current.size===0&&typeof window.requestAnimationFrame=="function"){const T=window.requestAnimationFrame(()=>{A.current.delete(T),rr();const F=window.requestAnimationFrame(()=>{A.current.delete(F),rr()});A.current.add(F)});A.current.add(T)}for(const T of Aj){if(ve.current.has(T))continue;const F=window.setTimeout(()=>{ve.current.delete(T),rr()},T);ve.current.set(T,F)}}function rr(){const T=j.current;if(!(!T||!ln.current||document.visibilityState==="hidden"||!kt.current||ee.current?.isConnected===!1))try{T.refresh(0,Math.max(0,T.rows-1))}catch{}}function fa(){for(const T of ce.current.values())window.clearTimeout(T);ce.current.clear()}function hl(){for(const T of ve.current.values())window.clearTimeout(T);ve.current.clear();for(const T of A.current)window.cancelAnimationFrame(T);A.current.clear()}function fl(){for(const T of V.current)window.clearTimeout(T);V.current=[]}function Jn(){if(Nn(),!Ae.current){ls(!1);return}ls(!0),pl(),_t.current=window.setTimeout(()=>{_t.current=null,ls(!1)},1200)}function Nn(){const T=j.current,F=T?T4(T):null;if(Ae.current=F,os(F),Bs(!!(T&&F)),ds(!!(T&&F&&!ss(T))),F||!T||!Nc()){cs(null);return}cs({alternate:T.buffer.active.type==="alternate"})}function Nc(){const T=ne.current;return Ue.current.length>0||!!T?.hasMore}function pl(){_t.current!==null&&(window.clearTimeout(_t.current),_t.current=null)}function ml(){const T=j.current;T&&(bt.current=!ss(T),Nn())}function gl(T){$.current=ov($.current,T)}function Mc(T){const F=$.current;return $.current=null,ov(F,T)}function S(){const T=$.current;return $.current=null,T}function k(T={}){const F=j.current;if(!F||!ln.current){Ht.current=!0;return}if(vn.current&&!ot.current&&!D.current&&ss(F)){xe();return}if(ot.current){gl(T);return}if(D.current){gl(T);return}const Le=Mc(T);if(!Le.force&&!Yh(F,bt.current)){Nn();return}D.current=!0;const Xe=pe.current,Qe=()=>{if(j.current!==F||pe.current!==Xe)return;if(!Le.force&&!Yh(F,bt.current)){if(D.current=!1,Tr())return;Nn();return}const rt=Ye.current,gt=Ve.current[rt];if(gt===void 0){if(D.current=!1,Tr())return;Le.scrollToBottom&&ht(F),Nn();const vt=S();vt?k(ov(Le,vt)):xe();return}F.write(gt,()=>{j.current!==F||pe.current!==Xe||(Ye.current=rt+1,Qe())})};Qe()}function B(T){return vn.current!==null||!ss(T)&&(oe()||D.current||ot.current)}function X(T,F){return(F?.agentStatus?.provider==="codex"||F?.agentStatus?.provider==="claude"||en.current||ec(F?.currentCommand))&&!ss(T)}function oe(){return Ye.current<Ve.current.length}function he(T,F){vn.current={output:T,history:F,appendFromLiveOutputIndex:Ve.current.length}}function xe(){const T=j.current,F=vn.current;if(!T||!F||!ss(T)||D.current||ot.current)return;const Le=Vh(F.output),Xe=Vh(Ve.current.slice(F.appendFromLiveOutputIndex));vn.current=null,Vi([...Le,...Xe],F.history),In()}function Oe(){Bt.current=!0}function Pe(){ml(),Bt.current=!1;const T=j.current;T&&ss(T)&&k({scrollToBottom:!0})}function ht(T){yi(()=>Ax(T))&&(bt.current=!1)}function Mt(T,F){yi(()=>(T.scrollToLine(F),!0))}function yi(T){at.current=!0;try{return T()}finally{at.current=!1}}function pn(){const T=j.current;if(!T)return;const F=()=>{Me.current&&(bl(fe.current),Ai(!1)),Ax(T),bt.current=!1,Nn(),k({force:!0,scrollToBottom:!0}),_s("scroll-action")};if(T.buffer.active.type==="alternate"){T.write(P_,F);return}F()}function zs(T){const F=j.current,Le=ee.current;if(!F||!Le)return;const Xe=Le.getBoundingClientRect();if(Xe.height<=0)return;const Qe=Math.max(0,Math.min(1,(T-Xe.top)/Xe.height)),rt=Math.round(F.buffer.active.baseY*Qe);Oe();try{F.scrollToLine(rt)}finally{Pe()}bt.current=!ss(F),Nn(),Jn(),rt<=3&&Yi()}function xp(T){T.preventDefault(),T.stopPropagation(),T.currentTarget.setPointerCapture?.(T.pointerId),zs(T.clientY)}function Cd(T){(T.buttons&1)!==0&&(T.preventDefault(),T.stopPropagation(),zs(T.clientY))}function kd(){const T=j.current,F=J.current;if(!(!T||!F)&&!(document.visibilityState==="hidden"||!kt.current||ee.current?.isConnected===!1))try{const Le=Yh(T,bt.current),Xe=wo();F.fit(),Xe&&(O.current=Xe),Le&&ht(T),T.refresh(0,Math.max(0,T.rows-1)),Nn();const Qe={cols:T.cols,rows:T.rows},rt=ae.current;if(rt&&rt.cols===Qe.cols&&rt.rows===Qe.rows)return;Rr({type:"resize",terminalId:e.id,cols:Qe.cols,rows:Qe.rows})&&(ae.current=Qe)}catch{}}function pa(T,F){const Le=fe.current;return Le?Le(T,F):"rejected"}function Rr(T){return pa(T)!=="rejected"}function vl(){Z.current!==null&&(window.clearTimeout(Z.current),Z.current=null)}function Co(){vl();const T=Math.max(-Kh,Math.min(Kh,Se.current));if(Se.current=0,T===0)return!1;const F=Rr({type:"scrollback_scroll",terminalId:e.id,lines:T});return F&&(ye.current=!0,T<0&&Ai(!0)),F}function Ac(T){if(!Me.current||T===0)return;const F=Se.current+T;Se.current=Math.max(-Kh,Math.min(Kh,F)),Z.current===null&&(Z.current=window.setTimeout(()=>{Z.current=null,Co()},Jj))}function Td(){bl(fe.current)}function _l(T=fe.current,F={}){const Le=ye.current;vl(),Se.current=0,ye.current=!1,F.updateUi!==!1&&Ai(!1),Le&&T?.({type:"cancel_scrollback",terminalId:e.id})}function bl(T){vl(),Se.current=0,ye.current=!1,Ai(!1),T?.({type:"cancel_scrollback",terminalId:e.id})}function Lc(){if(!He.current)return;const T=!Me.current;oa(FM(te.current,T)),ki()}function Ed(){const T=!ze.current;ze.current=T,aa(T),ar({tone:T?"info":"skipped",message:T?"Cache keep-alive enabled":"Cache keep-alive off",...T?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Oc(){Je.current!==null&&(window.clearTimeout(Je.current),Je.current=null)}function ar(T,F={}){Oc();const Le=We.current+1;We.current=Le,xr({...T,id:Le}),!F.sticky&&(Je.current=window.setTimeout(()=>{Je.current=null,xr(Xe=>Xe?.id===Le?null:Xe)},12e3))}function Cp(){Ie.current.skipped=!0,ar({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function kp(){ze.current=!1,aa(!1),ar({tone:"skipped",message:"Cache keep-alive off"})}async function Dd(){const T=Ie.current;if(T.sent||T.skipped)return;const F=Tp();if(T.sent=!0,F){ar({tone:"skipped",message:"Skipped cache keep-alive",detail:F});return}if(Xi(`${wx}\r`,{userInitiated:!1})==="rejected"){ar({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}ar({tone:"success",message:"Cache keep-alive sent",detail:wx})}function Tp(){const T=_e.current,F=it.current;return ze.current?e.status!=="running"?"Pane is not running.":!T||T.status!=="ready"||!T.source||!F?"Transcript cache status is unavailable.":T.source.provider!==F.provider||T.source.sessionId!==F.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Qa(F.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":oc(e.id).text.trim()?"Compose has an unsent draft.":l4(ee.current)?"Pane input is focused.":Date.now()-Gn.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function ki(){const T=j.current;T&&(ht(T),Nn())}function Xi(T,F={}){Co();const Le=ye.current;k({force:!0,scrollToBottom:!0});const Xe=pa({type:"input",terminalId:e.id,data:T,...Le?{cancelScrollbackMode:!0}:{}},{durability:F.userInitiated===!1?"live-only":"durable"});return Xe==="rejected"?(F.userInitiated!==!1&&Rn("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Xe):(F.userInitiated!==!1&&(Gn.current=Date.now()),Le&&(ye.current=!1,Ai(!1)),x4(T)&&(Xe==="sent"?Bc():Xe==="queued"&&(de.current=!0)),Xe)}function Rd(){On.current&&ko(!1),Xi(Ij)}function Nd(T){const F=Yg(T,{bracketedPasteMode:j.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});F&&Xi(F)}function Md(T,F){const Le=j.current?.modes.bracketedPasteMode===!0,Xe=Oi==="codex"||Oi==="claude"||ec(e.currentCommand),Qe=T.parts.map(rt=>rt.kind==="image"&&Xe?Yg(rt.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Yg(rt.kind==="image"?rt.path:rt.value,{bracketedPasteMode:Le,stripTrailingLineBreaks:!1})).join("");return Qe?Xi(`${Qe}${GB(F)}`)!=="rejected":!1}function Bc(){!$t.current||!Ut.current||(fl(),V.current=Oj.map(T=>{const F=window.setTimeout(()=>{V.current=V.current.filter(Le=>Le!==F),$t.current&&Ut.current&&Rr({type:"refresh_cwd",terminalId:e.id})},T);return F}))}function _s(T="terminal-interaction"){mi.current||Rc()&&(T==="auto"||T==="scroll-action")||j.current?.focus()}const Ep=v.useCallback(()=>{Is(!1)},[]);function ma(){Li(T=>{const F=!T;return On.current=F,F}),_s("input-action")}function ko(T){On.current=T,Li(T)}function To(T){On.current&&ko(!1),Xi(yB(T)),_s("input-action")}async function yl(T="install"){Zs(!0),Ps(null);try{const F=T==="update"?await t.updateCodeServer():await t.installCodeServer();z_(vi,F.status),Cr(F.status)}catch(F){Ps(qh(F))}finally{Zs(!1)}}return d.jsxs("section",{className:"terminal-pane","data-active":i,"data-tmux-scrollback":ci?"true":"false",onMouseDown:()=>{i||g()},children:[d.jsx(c4,{terminal:e,canClose:o,tabId:u,transcriptSource:tn,hasTranscriptCandidates:ra.length>0,transcriptShortcutLabel:P,subagentsShortcutLabel:K,transcriptCacheStatus:Qn,transcriptCacheNow:js,cacheKeepAliveEnabled:En,codeServerAvailable:!0,codeServerInstallState:li===null?"unknown":li.installed?"installed":"missing",codeServerBusy:vo||li?.job?.status==="running",codeServerSupported:li?.supported!==!1,scrollbackShortcutLabel:H,tmuxScrollbackSupported:qi,tmuxScrollbackEnabled:ci,onToggleCacheKeepAlive:Ed,onOpenCodeServer:er,onToggleTmuxScrollback:Lc,onOpenTranscript:kr,onOpenSubagents:ms,onReload:ir,onClose:p}),d.jsx("div",{className:"xterm-container",ref:ee}),Zn?d.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:d.jsx("span",{"aria-hidden":"true"})}):null,N&&!ci&&gi?d.jsxs("div",{className:"terminal-scroll-progress","data-active":sa,"aria-hidden":"true",children:[gi.current,"/",gi.total]}):N&&!ci&&oi?d.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":oi.alternate?"alternate":"normal","aria-hidden":"true",children:[oi.alternate?"alt ":"","0/?"]}):null,us||ci&&fn?d.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),pn()},children:"↓"}):null,Mi&&!ci?d.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:xp,onPointerMove:Cd,children:d.jsx("span",{"aria-hidden":"true"})}):null,i&&e.status==="running"?bo?d.jsx(_B,{ctrlActive:fo,onCtrl:ma,onStandaloneKey:To,onPreserveFocus:()=>_s("input-action"),onHide:()=>yo(!1)}):d.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:T=>{T.stopPropagation(),_s("input-action")},onPointerDown:T=>{T.stopPropagation(),_s("input-action")},onClick:()=>yo(!0),children:"⌨"}):null,d.jsx(o5,{terminalId:e.id,onSubmit:Md,onUploadAttachments:(T,F)=>t.uploadComposeAttachments({terminalId:e.id,files:T,signal:F.signal,onProgress:F.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:T=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:T})}:{},queueAvailable:Oi==="codex"||rE(e.currentCommand),disabled:e.status!=="running"}),d.jsx(f4,{toast:cl,onSendNow:()=>{Dd()},onSkipOnce:Cp,onTurnOff:kp,onDismiss:()=>xr(null)}),Gs?d.jsx(p4,{terminalId:e.id,serverApi:t,source:tn,candidates:ra,rememberedSelection:Ge,fontSize:x,onClose:Ep},e.id):null,mo&&tn?d.jsx(tB,{terminalId:e.id,serverApi:t,source:tn,fontSize:x,onClose:()=>Dn(!1)}):null,Qs?d.jsx(d4,{notice:Qs}):null,go?d.jsx(u4,{status:li,busy:vo,error:fs,onInstall:()=>{yl("install")},onUpdate:()=>{yl("update")},onOpen:er,onRefresh:()=>{bi({checkLatest:!0}).catch(T=>Ps(qh(T)))},onClose:()=>hs(!1)}):null]})}function kx(e){return fD(e)}async function Tx(e,t,i={}){const r=i.checkLatest===!0,o=i.force===!0||r,c=Date.now(),u=Jl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=e4)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=>(z_(e,g),g)).catch(g=>{const p=Jl.get(e);throw p?.inflight===f&&(p.status?Jl.set(e,{status:p.status,fetchedAt:p.fetchedAt}):Jl.delete(e)),g}),Jl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:f,inflightCheckLatest:r}),f}function z_(e,t){Jl.set(e,{status:t,fetchedAt:Date.now()})}function Wh(e,t){return`${e}:${t}`}function nE(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function Ex(e){const t=Yu.get(e);if(!t)return!1;try{return t.closed?(Yu.delete(e),!1):(t.focus(),!0)}catch{return Yu.delete(e),!1}}function sv(e,t){const i=window.open(t,nE(e));if(!i)return null;Yu.set(e,i);try{i.focus()}catch{}return i}function Dx(e,t,i){if(!e||iE(e))return!1;try{return e.name=nE(t),e.location.href=i,Yu.set(t,e),e.focus(),!0}catch{return!1}}function t4(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 iE(e){if(!e)return!0;try{return e.closed}catch{return!0}}function rv(e){if(e)try{e.closed||e.close()}catch{}}function Rx(e,t,i){const r=n4(e,t),o=Nx(r*Math.max(1,i),qj,Vj);return{limit:Nx(Math.ceil(o/Fj),Kj,Wj),maxLines:o}}function n4(e,t){const i=e?.clientHeight??0;if(i<=0)return Uj;const r=Math.max(10,t*$j);return Math.max(1,Math.floor(i/r))}function Nx(e,t,i){return Math.max(t,Math.min(i,Math.floor(e)))}function i4(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function s4(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function sE(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const i=Date.parse(e.expiresAt);return Number.isFinite(i)?i-t:null}function r4(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function a4(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const i=Math.ceil(t/60);if(i<60)return`${i}m`;const r=Math.floor(i/60),o=i%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 o4(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function qh(e){return e instanceof Vn||e instanceof Error?e.message:"Something went wrong."}function l4(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function c4({terminal:e,canClose:t,tabId:i,transcriptSource:r,hasTranscriptCandidates:o,transcriptShortcutLabel:c,subagentsShortcutLabel:u,transcriptCacheStatus:f,transcriptCacheNow:g,cacheKeepAliveEnabled:p,codeServerAvailable:_,codeServerInstallState:b,codeServerBusy:w,codeServerSupported:x,scrollbackShortcutLabel:C,tmuxScrollbackSupported:N,tmuxScrollbackEnabled:L,onToggleCacheKeepAlive:M,onOpenCodeServer:U,onToggleTmuxScrollback:P,onOpenTranscript:H,onOpenSubagents:K,onReload:ee,onClose:j}){const J=_b({id:`pane-${e.id}`,disabled:!i,...i?{data:{kind:"pane",sourceTabId:i,terminalId:e.id}}:{}}),fe={cursor:i?"grab":"default",opacity:J.isDragging?.5:void 0};return d.jsxs("header",{ref:J.setNodeRef,className:"terminal-pane-header",style:fe,"data-dragging":J.isDragging,...J.attributes,...J.listeners,children:[d.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),d.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),d.jsx("span",{className:"terminal-pane-spacer"}),_?d.jsx("button",{type:"button",className:"terminal-pane-code","data-state":b,"data-busy":w?"true":"false",disabled:!x||w,title:b==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":b==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),U()},children:d.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r||o?d.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r?.provider,title:"View transcript history","aria-label":"View transcript history",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),H()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View history"}),d.jsx("span",{className:"pane-button-label-short",children:"History"}),d.jsx("kbd",{children:c})]}):null,r?d.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),K()},children:[d.jsx("span",{className:"pane-button-label-full",children:"View agents"}),d.jsx("span",{className:"pane-button-label-short",children:"Agents"}),d.jsx("kbd",{children:u})]}):null,r?d.jsx(h4,{status:f,now:g,keepAliveEnabled:p,onToggle:M}):null,e.status==="exited"?d.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,N&&e.status==="running"?d.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":L?"true":"false","aria-pressed":L,"aria-label":`Toggle tmux scrollback (${C})`,title:L?`Scroll input uses tmux scrollback (${C}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${C}).`,onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),P()},children:[L?d.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),d.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):d.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),d.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),d.jsx("kbd",{children:C})]}):null,e.status==="running"?d.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),ee()},children:"↻"}):null,t?d.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),j()},children:"x"}):null]})}function u4({status:e,busy:t,error:i,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,w=e===null&&t,x=e?.updateAvailable===!0,C=_?"VS Code add-on":"Install VS Code add-on";return d.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":C,onClick:f,children:d.jsxs("section",{className:"security-panel code-server-dialog",onClick:N=>N.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{children:[d.jsx("h2",{children:C}),d.jsx("p",{children:w?"Checking code-server status...":_?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:f,children:"x"})]}),d.jsxs("div",{className:"code-server-dialog-scroll",children:[d.jsxs("div",{className:"code-server-dialog-body",children:[d.jsxs("p",{children:["NTerminal installs code-server under ",d.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?d.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:d.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),i?d.jsx("p",{className:"code-server-dialog-error",children:i}):null,g?d.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[d.jsxs("div",{className:"code-server-progress-heading",children:[d.jsx("span",{children:g.action}),d.jsx("strong",{children:g.status})]}),d.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
52
|
+
`):"Preparing..."})]}):null]}),d.jsxs("div",{className:"code-server-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!b,children:"Check"}),_?d.jsxs(d.Fragment,{children:[x?d.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:"Update"}):null,d.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):d.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function d4({notice:e}){return d.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function h4({status:e,now:t,keepAliveEnabled:i,onToggle:r}){const o=sE(e,t),c=r4(e,o),u=o===null?"?":a4(o),f=["Estimated cache remaining time based on session history.",i?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return d.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":i?"true":"false","aria-pressed":i,"aria-label":i?"Disable cache keep-alive":"Enable cache keep-alive",title:f,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[d.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[d.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),d.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),d.jsx("span",{children:u})]})}function f4({toast:e,onSendNow:t,onSkipOnce:i,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return d.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[d.jsxs("header",{children:[d.jsx("strong",{children:e.message}),d.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?d.jsx("p",{children:e.detail}):null,c?d.jsxs("div",{className:"cache-keepalive-toast-actions",children:[d.jsx("button",{type:"button",onClick:t,children:"Send now"}),d.jsx("button",{type:"button",onClick:i,children:"Skip once"}),d.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}function p4(e){const[t,i]=v.useState(e.source),[r,o]=v.useState(),[c,u]=v.useState(e.candidates),[f,g]=v.useState(e.source),[p,_]=v.useState(null),[b,w]=v.useState(!1),x=v.useRef(0);async function C(M=!1){const U=++x.current;w(!0);try{const P=await e.serverApi.getTerminalTranscriptSource(e.terminalId);if(U!==x.current)return;u(P.candidates??[]),g(P.source);const H=e.rememberedSelection?.current;let K=!1;if((M||!t)&&H?.terminalId===e.terminalId){const ee=P.candidates?.find(j=>j.id===H.candidateId);ee?(i({provider:ee.provider,sessionId:ee.sessionId}),o(ee.id),K=!0):e.rememberedSelection&&(e.rememberedSelection.current=null)}if((M||!t)&&P.source)i(P.source),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);else if((M||!t)&&!K&&P.candidates?.length===1){const ee=P.candidates[0];i({provider:ee.provider,sessionId:ee.sessionId}),o(ee.id)}_(null)}catch(P){U===x.current&&_(P instanceof Error?P.message:"Could not load sessions.")}finally{U===x.current&&w(!1)}}v.useEffect(()=>(C(),()=>{x.current+=1}),[]),v.useEffect(()=>{if(t)return;function M(U){U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),e.onClose())}return document.addEventListener("keydown",M,!0),()=>document.removeEventListener("keydown",M,!0)},[t,e.onClose]);const N=[];t&&N.push({id:r??"__pinned",title:c.find(M=>M.id===r)?.title||`${Qa(t.provider)} · ${t.sessionId}`,detail:c.find(M=>M.id===r)?.cwd||t.sessionId}),f&&(!t||!Xa(f,t))&&N.push({id:"__current",title:`Current session · ${Qa(f.provider)}`,detail:f.sessionId});for(const M of c)t&&Xa(t,M)||f&&Xa(f,M)||N.push({id:M.id,title:M.title||M.sessionId,detail:`${Qa(M.provider)} · ${M.cwd}${M.updatedAt?` · ${new Date(M.updatedAt).toLocaleString()}`:""}`});const L=t&&N.length<=1?null:d.jsxs("div",{className:"transcript-session-picker",children:[N.length>1?d.jsx(cB,{options:N,value:r??(t?"__pinned":void 0),onSelect:M=>{if(x.current+=1,w(!1),M==="__current"&&f){i(f),o(void 0),e.rememberedSelection&&(e.rememberedSelection.current=null);return}const U=c.find(P=>P.id===M);U&&(i({provider:U.provider,sessionId:U.sessionId}),o(U.id),e.rememberedSelection&&(e.rememberedSelection.current={terminalId:e.terminalId,candidateId:U.id}))}}):null,d.jsx("button",{type:"button","aria-label":"Refresh sessions",title:"Refresh sessions",disabled:b,onClick:()=>{C()},children:d.jsx(Ef,{size:16})}),p?d.jsx("span",{role:"alert",children:p}):null,!t&&!f&&!b&&!c.length?d.jsx("span",{children:"No sessions available."}):null]});return t?v.createElement(m4,{...e,key:`${t.provider}:${t.sessionId}:${r??""}`,source:t,...r?{candidateId:r}:{},sessionPicker:L,liveSourceChanged:!!(e.source&&!Xa(e.source,t)),onReloadLatest:async()=>{e.rememberedSelection&&(e.rememberedSelection.current=null),i(null),o(void 0),await C(!0)}}):d.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-picker-title",onPointerDown:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),onClick:M=>{M.stopPropagation(),e.onClose()},children:d.jsxs("div",{className:"security-panel transcript-dialog",onClick:M=>M.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"transcript-picker-title",children:"History"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e.onClose,children:"×"})]}),L,b?d.jsx("div",{className:"transcript-dialog-status",children:"Loading sessions..."}):null]})})}const m4=Nt.memo(function({terminalId:t,serverApi:i,source:r,fontSize:o,onClose:c,onReloadLatest:u,candidateId:f,sessionPicker:g,liveSourceChanged:p}){const _=v.useRef(null),b=v.useRef(!1),w=v.useRef(null),x=v.useRef(!1),C=v.useRef(()=>{});C.current=Ge;const N=v.useRef(0),L=v.useRef(!1),M=v.useRef(!1),U=v.useRef(null),P=v.useRef(null),H=v.useRef(null),[K,ee]=v.useState([]),[j,J]=v.useState(!1),[fe,ie]=v.useState(""),[te,Y]=v.useState(null),[Q,q]=v.useState(null),[ae,O]=v.useState(!1),[R,z]=v.useState(!1),[ce,ve]=v.useState(-1),[A,V]=v.useState(null),[de,Z]=v.useState(null),[Se,ye]=v.useState(!1),[Me,He]=v.useState(!0),[Fe,Ue]=v.useState(!1),[Ve,Ye]=v.useState(null),[D,$]=v.useState(!1),pe=dB(i,t,r,f,j,fe),Ne=v.useRef(0),ne=v.useRef(null),ge=v.useRef(null);function Ee(){if(b.current)return!0;const _e=_.current,ze=window.getSelection();if(!_e||!ze||ze.isCollapsed)return!1;for(let Ie=0;Ie<ze.rangeCount;Ie++)if(ze.getRangeAt(Ie).intersectsNode(_e))return!0;return!1}v.useEffect(()=>{const _e=()=>{Ee()||(w.current?w.current.resume():x.current&&(x.current=!1,C.current()))},ze=()=>{b.current=!1,_e()};return document.addEventListener("selectionchange",_e),document.addEventListener("pointerup",ze,!0),document.addEventListener("pointercancel",ze,!0),window.addEventListener("blur",ze),()=>{document.removeEventListener("selectionchange",_e),document.removeEventListener("pointerup",ze,!0),document.removeEventListener("pointercancel",ze,!0),window.removeEventListener("blur",ze),w.current?.cancel()}},[]);function Re(_e){return _e?.aborted?Promise.reject(new DOMException("Aborted","AbortError")):Ee()?new Promise((ze,Ie)=>{const We=()=>{_e?.removeEventListener("abort",Je),w.current?.cancel===Je&&(w.current=null)},Je=()=>{We(),Ie(new DOMException("Aborted","AbortError"))};w.current={resume:()=>{We(),ze()},cancel:Je},_e?.addEventListener("abort",Je,{once:!0})}):Promise.resolve()}v.useEffect(()=>{ct(),Y(null),q(null)},[fe,j]),v.useEffect(()=>()=>{Ne.current+=1,ge.current?.abort()},[]),v.useEffect(()=>{function _e(ze){ze.key==="Escape"&&(ze.preventDefault(),ze.stopPropagation(),c())}return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[c]),v.useEffect(()=>{N.current+=1;const _e=N.current;return L.current=!1,M.current=!0,U.current=null,P.current=null,H.current=null,ee([]),Z(null),ye(!1),Ye(null),$(!1),Y(null),q(null),ve(-1),V(null),kn(null,"initial",_e),()=>{N.current+=1,ne.current?.abort(),L.current=!1}},[i,j,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const _e=_.current;if(!_e)return;if(M.current){if(Me||K.length===0)return;M.current=!1;const Ie=()=>{_e.scrollTop=_e.scrollHeight};Ie(),window.requestAnimationFrame?.(Ie);return}const ze=U.current;ze!==null&&(U.current=null,_e.scrollTop+=_e.scrollHeight-ze)},[K,Me,j]);const Te=Qa(r.provider),je=Nt.useMemo(()=>jf(K,j),[K,j]),Ze=Nt.useMemo(()=>k_(je),[je]),Ae=Nt.useMemo(()=>g4(Ze),[Ze]),_t=Ae.map(_e=>_e.key).join(""),bt=A?Ae.find(_e=>_e.key===A)?.entryIndex??null:null,at=fe.trim().length>0,ot=pe.result?.hits.length??0,Bt=pe.result?.hits.findIndex(_e=>_e.id===te?.id)??-1,ln=Q?.entryIndex??null,Ht=at?ln:bt,On=at?ln===null?null:"search":bt===null?null:"prompt",Ut=je?je.split(`
|
|
53
|
+
`).length-1:0,kt=Ae.length>0&&ce>=0&&ce<Ae.length?ce:Ae.length-1,$t=A??(kt>=0?Ae[kt]?.key??null:null),At=at?ot>0?`${Bt+1}/${ot} ${ot===1?"match":"matches"} · ${Ut} ${Ut===1?"line":"lines"}`:`0 matches · ${Ut} ${Ut===1?"line":"lines"}`:Ae.length>0?`${kt+1}/${Ae.length} prompts · ${Ut} ${Ut===1?"line":"lines"}`:`0 prompts · ${Ut} ${Ut===1?"line":"lines"}`;v.useEffect(()=>{if(at){V(null);return}A&&!Ae.some(_e=>_e.key===A)&&V(null),ve(_e=>{if(Ae.length===0)return H.current=null,-1;const ze=H.current?Ae.findIndex(We=>We.key===H.current):-1,Ie=ze>=0?ze:_e>=0&&_e<Ae.length?_e:Ae.length-1;return H.current=Ae[Ie]?.key??null,Ie})},[A,at,_t]),v.useEffect(()=>{const _e=P.current;if(!_e||Ae.length===0)return;P.current=null;const ze=_e.anchorKey?Ae.findIndex(We=>We.key===_e.anchorKey):-1,Ie=ze>0?ze-1:0;jt(Ie)},[_t]);async function kn(_e,ze,Ie=N.current){if(!L.current){L.current=!0,ne.current?.abort(),ne.current=new AbortController,ze==="initial"?He(!0):(Ue(!0),U.current=_.current?.scrollHeight??null),Ye(null);try{await mi(_e,ze,Ie)}catch(We){if(N.current!==Ie)return;Ye(We instanceof Error?We.message:"Failed to load transcript history."),We instanceof Vn&&We.status===409&&$(!0)}finally{N.current===Ie&&(L.current=!1,He(!1),Ue(!1))}}}async function mi(_e,ze,Ie){const We=ne.current?.signal;let Je=_e,It=0,Ft=[];const Gn=ze==="initial"&&r.provider!=="claude"?Xj:Yj;for(;N.current===Ie;){const en=await i.getTerminalTranscriptHistory(t,{...Je?{cursor:Je}:{},...Rx(_.current,o,ze==="initial"?bx:Hj),includeTools:j,expectedSessionId:r.sessionId,...f?{candidateId:f}:{}},We);if(N.current!==Ie||(ze==="older"&&await Re(We),N.current!==Ie))return;if(!en.source){Ye("Transcript source is temporarily unavailable.");return}if(!Xa(r,en.source)){$(!0),ye(!1);return}const Bn=lf(en.output,r.provider,{includeTools:j}),vn=le(en,ze,Ft,Bn);if(Bn&&(Ft=[Bn,...Ft],vn))return;if(!en.hasMore||!en.cursor||It>=Gn){Ft.length>0&&ee(_n=>ze==="older"?[...Ft,..._n]:Ft);return}Je=en.cursor,It+=1}}function le(_e,ze,Ie,We=lf(_e.output,r.provider,{includeTools:j})){if(Z(_e.cursor),ye(!!(_e.hasMore&&_e.cursor)),!We)return!1;const Je=[We,...Ie];return jf(Je,j)?(ee(It=>ze==="older"?[...Je,...It]:Je),!0):!1}function Ge(){const _e=_.current;if(_e){if(Ee()){x.current=!0;return}x.current=!1,Tn(),!(at||_e.scrollTop>72||!Se||!de||L.current)&&kn(de,"older")}}function it(_e){if(ot===0)return;const ze=Bt>=0?Bt:_e>0?-1:0;Dt((ze+_e+ot)%ot)}function ct(){Ne.current+=1,ge.current?.abort(),ge.current=null,O(!1)}async function Dt(_e){const ze=pe.result?.hits[_e];if(!ze)return;const Ie=++Ne.current;ge.current?.abort(),ne.current?.abort();const We=new AbortController;ge.current=We,N.current+=1,L.current=!1,M.current=!1,U.current=null,He(!1),O(!0),Ue(!1),Ye(null),Y(ze),q(null);try{const Je=await i.getTerminalTranscriptHistory(t,{around:ze.cursor,expectedSessionId:r.sessionId,...f?{candidateId:f}:{},includeTools:j,...Rx(_.current,o,bx)},We.signal);if(Ie!==Ne.current)return;if(!Je.source||!Xa(r,Je.source)){$(!0);return}const It=lf(Je.output,r.provider,{includeTools:j});ee([It]),q(uB(k_(It),ze,fe)),Z(Je.cursor),ye(!!(Je.hasMore&&Je.cursor)),_.current&&(_.current.scrollTop=0)}catch(Je){Ie===Ne.current&&(Ye(Je instanceof Error?Je.message:"Could not load search result."),Je instanceof Vn&&Je.status===409&&$(!0))}finally{Ie===Ne.current&&O(!1)}}function jt(_e){const ze=Ae[_e];ze&&(H.current=ze.key,ve(_e),V(ze.key))}async function hn(_e){if(Ae.length===0){_e<0&&Se&&de&&!L.current&&(P.current={anchorKey:null},await kn(de,"older"));return}const Ie=(ce>=0&&ce<Ae.length?ce:_e<0?Ae.length-1:-1)+_e;if(Ie>=0&&Ie<Ae.length){jt(Ie);return}_e<0&&Ie<0&&Se&&de&&!L.current&&(P.current={anchorKey:Ae[0]?.key??null},await kn(de,"older"))}function Tn(){if(at)return;const _e=_.current;if(!_e)return;const Ie=_e.getBoundingClientRect().top+Math.min(140,Math.max(48,_e.clientHeight*.28));let We=null;for(const Je of S4(_e)){const It=w4(Je);if(It!==null)if(Je.getBoundingClientRect().top<=Ie)We=It;else break}if(We!==null){const Je=Ae[We]?.key??null;H.current=Je,ve(We),A&&A!==Je&&V(null)}}return d.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),c()},children:d.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>_e.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsxs("div",{className:"transcript-dialog-title",children:[d.jsxs("h2",{id:"transcript-dialog-title",children:[Te," JSONL"]}),d.jsx("span",{title:r.sessionId,children:r.sessionId})]}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),g,p?d.jsx("div",{className:"transcript-dialog-status",children:"The live pane uses another session. History remains pinned to this session."}):null,d.jsxs("div",{className:"transcript-dialog-controls",children:[d.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[d.jsx("input",{type:"checkbox",checked:j,onChange:_e=>J(_e.currentTarget.checked)}),"Show tool output"]}),d.jsx("label",{className:"transcript-search",children:d.jsx("input",{type:"search",value:fe,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:_e=>{pe.cancel(),ct(),ie(_e.currentTarget.value)},onKeyDown:_e=>{_e.nativeEvent.isComposing||_e.key==="Enter"&&(_e.preventDefault(),at?pe.result?.query===pp(fe)?ot>0?it(_e.shiftKey?-1:1):!pe.result.complete&&pe.result.cursor&&!pe.busy&&pe.search(!0):pe.busy||(ct(),Y(null),q(null),pe.search()):hn(_e.shiftKey?-1:1))}})}),d.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":R,"aria-label":"Toggle prompt list",title:"Toggle prompt list",onClick:()=>z(_e=>!_e),disabled:Ae.length===0,children:d.jsx(hM,{size:16})}),d.jsxs("div",{className:"transcript-search-actions","aria-label":at?"Search result navigation":"Prompt navigation",children:[d.jsx("button",{type:"button",onClick:()=>at?it(-1):void hn(-1),disabled:at?ot===0:Ae.length===0&&!Se,"aria-label":at?"Previous search match":"Previous user prompt",title:at?"Previous search match":"Previous user prompt",children:d.jsx(lM,{size:16})}),d.jsx("button",{type:"button",onClick:()=>at?it(1):void hn(1),disabled:at?ot===0:Ae.length===0,"aria-label":at?"Next search match":"Next user prompt",title:at?"Next search match":"Next user prompt",children:d.jsx(aM,{size:16})})]}),d.jsx("span",{className:"transcript-result-count",children:At}),d.jsx("button",{type:"button",title:"Load newest entries","aria-label":"Load newest entries",onClick:()=>{pe.cancel(),ct(),ne.current?.abort(),N.current+=1,L.current=!1,M.current=!0,Y(null),q(null),kn(null,"initial")},children:d.jsx(Ef,{size:16})})]}),at?d.jsxs("div",{className:"transcript-search-results","aria-label":"Search results","aria-busy":pe.busy,children:[d.jsxs("div",{className:"transcript-search-summary",role:"status",children:[pe.busy?"Searching...":pe.result?`${ot} ${ot>=200?"retained results":"results"}${pe.result.complete?" · Complete":" · More to scan"} · ${pe.result.scannedBytes.toLocaleString()} bytes scanned`:"Search history",pe.result&&!pe.result.complete&&pe.result.cursor?d.jsx("button",{type:"button",disabled:pe.busy,onClick:()=>{pe.search(!0)},children:"Search more"}):null]}),te&&Bt<0&&pe.result?d.jsx("div",{className:"transcript-dialog-status",children:"Selected result is outside the retained result window."}):null,pe.error?d.jsx("div",{className:"transcript-dialog-error",role:"alert",children:pe.error}):null,pe.result?.hits.map((_e,ze)=>d.jsxs("button",{type:"button",className:`transcript-prompt-index-item${te?.id===_e.id?" transcript-prompt-index-item-active":""}`,"aria-current":te?.id===_e.id?"true":void 0,onClick:()=>{Dt(ze)},children:[d.jsxs("span",{children:[_e.timestamp?new Date(_e.timestamp).toLocaleString():""," · ",_e.role]}),d.jsx("strong",{children:_e.preview.slice(0,500)})]},_e.id))]}):null,R?d.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ae.length>0?Ae.map((_e,ze)=>d.jsxs("button",{type:"button",className:$t===_e.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>jt(ze),children:[d.jsx("span",{children:_e.timestampLabel}),d.jsx("strong",{children:_e.snippet})]},`${_e.key}:${ze}`)):d.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,D?d.jsxs("div",{className:"transcript-dialog-status",role:"status",children:["The pinned transcript session changed."," ",d.jsx("button",{type:"button",onClick:()=>{u()},children:"Choose session"})]}):null,Ve?d.jsx("div",{className:"transcript-dialog-error",role:"alert",children:Ve}):null,ae?d.jsx("div",{className:"transcript-dialog-status",role:"status",children:"Loading search result..."}):null,d.jsxs("div",{ref:_,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Ge,onPointerDownCapture:()=>{b.current=!0},children:[Fe?d.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!Me&&Se?d.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,je?d.jsx(gT,{entries:Ze,searchQuery:fe,activeEntryIndex:Ht,activeEntryMode:On,activeSearchMatch:Q,fontSize:o}):null,Me?d.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!D&&!Me&&!je&&!Ve?Se&&de?d.jsxs("div",{className:"transcript-dialog-status",children:[j?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",d.jsx("button",{type:"button",onClick:()=>{kn(de,"older")},disabled:Fe,children:"Search earlier entries"})]}):d.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null]})]})})});function g4(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:v4(c),entry:c,entryIndex:o})}const i=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=i.get(c.contentKey)??0;i.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:b4(o.entry.body),timestampLabel:y4(o.entry.header)}))}function v4(e){return JSON.stringify([e.header??"",e.body.length,_4(e.body)])}function _4(e){let t=2166136261;for(let i=0;i<e.length;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function b4(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function y4(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function S4(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function w4(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const i=Number(t);return Number.isInteger(i)&&i>=0?i:null}function x4(e){return e.includes("\r")||e.includes(`
|
|
54
|
+
`)}function av(e){return e instanceof Vn&&e.status===404}function ec(e){return rE(e)||aE(e)}function rE(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function aE(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function C4(e){if(ec(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function k4(e){let t=0;for(const i of e){if(!i)continue;const r=i.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Vh(e){const t=[];for(const i of e){const r=oE(i);r&&t.push(r)}return t}function oE(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,i,r)=>{const o=i.split(";").filter(Boolean).filter(c=>!Pj.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function ov(e,t={}){const i={};return(e?.force||t.force)&&(i.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(i.scrollToBottom=!0),i}function T4(e){const t=e.buffer.active,i=t.baseY+e.rows;return i<=e.rows?null:{current:Math.max(1,Math.min(i,t.viewportY+1)),total:i}}function Mx(e,t){const i=e?.querySelector(".xterm .xterm-viewport");if(i){if(t){i.dataset.nterminalTmuxScrollHidden="true",i.style.setProperty("overflow-y","hidden","important"),i.style.setProperty("scrollbar-color","transparent transparent","important"),i.style.setProperty("scrollbar-width","none","important"),i.style.setProperty("-ms-overflow-style","none");return}i.dataset.nterminalTmuxScrollHidden==="true"&&(delete i.dataset.nterminalTmuxScrollHidden,i.style.removeProperty("overflow-y"),i.style.removeProperty("scrollbar-color"),i.style.removeProperty("scrollbar-width"),i.style.removeProperty("-ms-overflow-style"))}}function ss(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Yh(e,t){return!t||ss(e)}function Ax(e){return ss(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function E4(e,t,i,r,o,c,u,f){const g=p=>{const _=R4(p);if(_!==0){if(u()){if(A4(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),f(_);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),D4(t,_,i,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function D4(e,t,i,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}i(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(P_,u);return}u()}function R4(e){const i=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(i===0)return 0;const r=i<0?Math.floor(i):Math.ceil(i);return Math.max(-30,Math.min(30,r))}function N4(e,t,i,r,o,c,u,f,g){let p=null,_=0;const b={passive:!1};function w(N){p=lv(N),_=0}function x(N){const L=lv(N);if(L===null){p=null,_=0;return}if(p===null){p=L;return}const M=L.clientY-p.clientY;if(p=L,N.cancelable&&N.preventDefault(),M===0)return;if(M4(t)&&L4(t,L,-M)){_=0;return}_-=M/i();const U=_<0?Math.ceil(_):Math.floor(_);if(U!==0){if(_-=U,f()){g(U);return}c();try{t.scrollLines(U)}finally{u()}r(),U<0&&t.buffer.active.viewportY<=3&&o(U)}}function C(N){if(N.touches.length>0){p=lv(N);return}p=null,_=0}return e.addEventListener("touchstart",w,b),e.addEventListener("touchmove",x,b),e.addEventListener("touchend",C),e.addEventListener("touchcancel",C),()=>{e.removeEventListener("touchstart",w,b),e.removeEventListener("touchmove",x,b),e.removeEventListener("touchend",C),e.removeEventListener("touchcancel",C)}}function lv(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function M4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function A4(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function L4(e,t,i){const r=e.element;return r?(r.dispatchEvent(O4(t,i)),!0):!1}function O4(e,t){const i=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:i};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 H_({node:e,terminals:t,editors:i,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:f,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:_=null,mobileFocusLeafKey:b=null,path:w=[],totalPanes:x,onSelect:C,onClose:N,onResize:L,onExit:M,onSnapshot:U,onCloseEditor:P,onAuthClose:H}){const K=x??U_(e);if(w.length===0&&b){const fe=$_(e),ie=fe.some(te=>te.key===b)?b:fe[0]?.key;if(fe.length>1&&ie)return d.jsx("div",{className:"mobile-focused-split",children:fe.map(te=>{const Y=te.key===ie;if(te.type==="editor"){const q=i[te.editorId];return d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:q?d.jsx(i1,{api:r,editor:q,canClose:K>1,onClose:()=>P(te.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},te.key)}const Q=t[te.terminalId];return Q?d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:d.jsx(Cx,{terminal:Q,serverApi:r,active:Y,visible:c&&Y,canClose:K>1,refreshCwdOnEnter:u&&Y,tabId:f,codeServerContext:g,onSelect:()=>C(te.terminalId),onClose:()=>N(te.terminalId),onExit:q=>M(te.terminalId,q),onSnapshot:U,...H?{onAuthClose:H}:{}})},te.key):d.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},te.key)})})}if(e.type==="pane"){const fe=t[e.terminalId];if(!fe)return d.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ie=d.jsx(Cx,{terminal:fe,serverApi:r,active:e.terminalId===o,visible:c,canClose:K>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:f,codeServerContext:g,onSelect:()=>C(e.terminalId),onClose:()=>N(e.terminalId),onExit:Y=>M(e.terminalId,Y),onSnapshot:U,...H?{onAuthClose:H}:{}});return p&&_!==e.terminalId?d.jsxs("div",{className:"pane-drop-host",children:[ie,d.jsx(Xh,{terminalId:e.terminalId,side:"top"}),d.jsx(Xh,{terminalId:e.terminalId,side:"right"}),d.jsx(Xh,{terminalId:e.terminalId,side:"bottom"}),d.jsx(Xh,{terminalId:e.terminalId,side:"left"})]}):ie}if(e.type==="editor"){const fe=i[e.editorId];return fe?d.jsx(i1,{api:r,editor:fe,canClose:K>1,onClose:()=>P(e.editorId)}):d.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const ee=Math.max(.1,Math.min(.9,e.ratio)),j=1-ee,J=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${ee}fr) 1px minmax(0, ${j}fr)`}:{gridTemplateRows:`minmax(0, ${ee}fr) 1px minmax(0, ${j}fr)`};return d.jsxs("div",{className:"split-pane","data-direction":e.direction,style:J,children:[d.jsx("div",{className:"split-cell",children:d.jsx(H_,{node:e.first,terminals:t,editors:i,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...w,0],totalPanes:K,onSelect:C,onClose:N,onResize:L,onExit:M,onSnapshot:U,onCloseEditor:P,...H?{onAuthClose:H}:{}})}),d.jsx(B4,{direction:e.direction,path:w,onResize:L}),d.jsx("div",{className:"split-cell",children:d.jsx(H_,{node:e.second,terminals:t,editors:i,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:f,codeServerContext:g,dropZoneActive:p,draggingTerminalId:_,mobileFocusLeafKey:b,path:[...w,1],totalPanes:K,onSelect:C,onClose:N,onResize:L,onExit:M,onSnapshot:U,onCloseEditor:P,...H?{onAuthClose:H}:{}})})]})}function Xh({terminalId:e,side:t}){const{setNodeRef:i,isOver:r}=ip({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return d.jsx("div",{ref:i,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function B4({direction:e,path:t,onResize:i}){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;i(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 d.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:d.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function U_(e){return e.type==="pane"||e.type==="editor"?1:U_(e.first)+U_(e.second)}function $_(e){return e.type==="pane"?[{key:j4(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:I4(e.editorId),type:"editor",editorId:e.editorId}]:[...$_(e.first),...$_(e.second)]}function j4(e){return`terminal:${e}`}function I4(e){return`editor:${e}`}const bp="workspace-default",P4="NTerminal";function z4(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function H4(e,t){switch(t.type){case"workspace.hydrated":return pf(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return U4(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return W4(e,t.workspaceId);case"workspace.selected":return lE(e,t.workspaceId);case"workspace.renamed":return $4(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return F4(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return K4(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return cE(e,t.terminal);case"terminal.split":return q4(e,t.terminal,t.direction);case"terminal.updated":return iI(e,t.terminal);case"terminal.exited":return sI(e,t.terminalId,t.exitCode);case"terminal.closed":return hE(e,t.terminalId);case"terminal.detached":return rI(e,t.terminalId,t.workspaceId);case"editor.split":return V4(e,t.editorId,t.title,t.direction);case"editor.closed":return aI(e,t.editorId);case"pane.selected":return tI(e,t.terminalId);case"pane.resized":return nI(e,t.path,t.ratio);case"tab.selected":return X4(e,t.tabId);case"tab.renamed":return eI(e,t.tabId,t.title);case"tab.reordered":return sy(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return G4(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return uE(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return dE(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return Z4(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return Y4(e);default:return e}}function U4(e,t){if(e.workspaces.some(r=>r.id===t.id))return lE(e,t.id);const i={id:t.id,title:t.title,defaultCwd:Ys(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,i],activeWorkspaceId:i.id}}function lE(e,t){return e.workspaces.some(i=>i.id===t)?{...e,activeWorkspaceId:t}:e}function $4(e,t,i){const r=i.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 F4(e,t,i){const r=Ys(i);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 K4(e,t,i,r){if(t===i)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===i);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===i);if(g<0)return e;const p=r==="before"?g:g+1,_=u.slice();return _.splice(p,0,f),J4(e.workspaces,_)?e:{...e,workspaces:_}}function W4(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const i=e.workspaces.find(f=>f.id===t),r=new Set(i?Vf(i):[]),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 cE(e,t){const i=pE(e),r=ol(i)??Sp(),o=bE(t);return{...i,activeWorkspaceId:r.id,terminals:{...i.terminals,[t.id]:t},workspaces:i.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Ys(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:_E(c,t.id))}}function q4(e,t,i){const r=ol(e),o=r?yp(r):void 0;if(!r||!o)return cE(e,t);const c=o.activeTerminalId,u=ud(o.root,c,{type:"split",direction:i,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??Ys(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:_E(f,t.id))}}function V4(e,t,i,r){const o=ol(e),c=o?yp(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,f=ud(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:i}});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 Y4(e){const t=ol(e),i=t?yp(t):void 0;return i?hE(e,i.activeTerminalId):e}function X4(e,t){const i=ol(e);return!i||!i.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===i.id?{...r,activeTabId:t}:r)}}function sy(e,t,i){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,i)),p=u.slice();return p.splice(g,0,f),Q4(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function G4(e,t,i,r,o){if(i===r||!e.terminals[i]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(C=>C.id===t);if(p<0)return g;const _=g.tabs[p];if(!_)return g;const b=pc(_.root,i);if(!b){const C=g.tabs.filter((N,L)=>L!==p);return{...g,tabs:C}}const w={..._,root:b,activeTerminalId:xn(b)[0]??_.activeTerminalId},x=g.tabs.slice();return x[p]=w,{...g,tabs:x}});const u=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(N=>xn(N.root).includes(r));if(p<0)return g;const _=g.tabs[p];if(!_)return g;const b={type:"pane",terminalId:i},w={type:"split",direction:u,ratio:.5,first:f?b:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:b},x=ud(_.root,r,w),C=g.tabs.slice();return C[p]={..._,root:x,activeTerminalId:i},{...g,tabs:C,activeTabId:_.id}}),pE({...e,workspaces:c})}function uE(e,t,i,r){let o=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const M=e.workspaces[L].tabs.findIndex(U=>U.id===t);if(M>=0){o=L,c=M;break}}if(o<0)return e;const u=e.workspaces[o],f=u.tabs[c],g=xn(f.root);if(!g.includes(i))return e;if(g.length===1)return sy(e,t,r);const p=pc(f.root,i);if(!p)return e;const _={...f,root:p,activeTerminalId:xn(p)[0]??f.activeTerminalId},b=e.terminals[i],w={id:`tab-${Date.now().toString(36)}-${i.slice(0,8)}`,title:b?.title??"",activeTerminalId:i,root:{type:"pane",terminalId:i}},x=u.tabs.slice();x[c]=_;const C=Math.max(0,Math.min(x.length,r));x.splice(C,0,w);const N=e.workspaces.slice();return N[o]={...u,tabs:x,activeTabId:w.id},{...e,workspaces:N}}function dE(e,t,i,r=Number.MAX_SAFE_INTEGER){const o=mE(e.workspaces,t),c=e.workspaces.find(p=>p.id===i);if(!o||!c)return e;if(o.workspace.id===i)return r===Number.MAX_SAFE_INTEGER?e:sy(e,t,r);const u=xn(o.tab.root),f=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return ll({...p,tabs:p.tabs.filter(_=>_.id!==t)});if(p.id===i){const _=p.tabs.slice(),b=Math.max(0,Math.min(_.length,r));return _.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??Ys(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!u.includes(w)),tabs:_,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:i}}function Z4(e,t,i,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(x=>x.id===r),u=mE(e.workspaces,t);if(!c||!u||!e.terminals[i]||!xn(u.tab.root).includes(i))return e;if(u.workspace.id===r)return uE(e,t,i,o);if(xn(u.tab.root).length===1)return dE(e,t,r,o);const g=pc(u.tab.root,i);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:xn(g)[0]??u.tab.activeTerminalId},_=e.terminals[i],b={id:`tab-${Date.now().toString(36)}-${i.slice(0,8)}`,title:_.title??i,activeTerminalId:i,root:{type:"pane",terminalId:i}},w=e.workspaces.map(x=>{if(x.id===u.workspace.id)return ll({...x,tabs:x.tabs.map(C=>C.id===t?p:C)});if(x.id===r){const C=x.tabs.slice(),N=Math.max(0,Math.min(C.length,o));return C.splice(N,0,b),{...x,defaultCwd:x.defaultCwd??Ys(_.cwd),detachedTerminalIds:x.detachedTerminalIds.filter(L=>L!==i),tabs:C,activeTabId:b.id}}return x});return{...e,workspaces:w,activeWorkspaceId:r}}function Q4(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i+=1)if(e[i]?.id!==t[i]?.id)return!1;return!0}function J4(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i+=1)if(e[i]?.id!==t[i]?.id)return!1;return!0}function eI(e,t,i){const r=i.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 tI(e,t){const i=e.workspaces.find(o=>o.tabs.some(c=>mc(c.root,t))),r=i?.tabs.find(o=>mc(o.root,t));return!i||!r?e:{...e,activeWorkspaceId:i.id,workspaces:e.workspaces.map(o=>o.id===i.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function nI(e,t,i){const r=ol(e),o=r?yp(r):void 0;if(!r||!o)return e;const c=V_(o.root,t,wE(i));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 pf(e,t,i,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,f=!!(i&&i.some(b=>yE(b))||t&&t.some(b=>SE(b)));let g=oI(t,i,c,u);g.length===0&&(g=[Sp()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,_=p??g[0]?.id??bp;for(const b of e)if(!u.has(b.id)){if(f)g=uI(g,_,b.id,b);else{const w=bE(b);g=hI(g,_,w,b)}u.add(b.id)}return{workspaces:g.map(b=>ll(dI(b,o))),activeWorkspaceId:p,terminals:o}}function Xo(e){return xn(e.root)}function qf(e){return Y_(e.root)}function Vf(e){return ry([...e.tabs.flatMap(t=>xn(t.root)),...e.detachedTerminalIds])}function cv(e){const t=e.workspaces.map(i=>{const r=i.tabs.flatMap(o=>{const c=W_(o.root);return c?[{...o,root:c}]:[]});return ll({...i,tabs:r})});return{activeWorkspaceId:t.some(i=>i.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function iI(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(i=>({...i,tabs:i.tabs.map(r=>mc(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function sI(e,t,i){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:i}}}:e}function hE(e,t){const i={...e.terminals};return delete i[t],fE(e,t,i)}function rI(e,t,i){if(!e.terminals[t])return e;const r=(i&&e.workspaces.some(c=>c.id===i)?i:null)??lI(e,t)?.id??cI(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??bp,o=e.workspaces.find(c=>c.id===r);return!o||!vE(o,t)?e:fE(e,t,{...e.terminals},{detachToWorkspaceId:r})}function fE(e,t,i,r={}){let o=e.workspaces.map(u=>{const f=[];for(const g of u.tabs){const p=pc(g.root,t);if(!p)continue;const _=xn(p),b=_.includes(g.activeTerminalId)?g.activeTerminalId:_[0];b&&f.push({...g,root:p,activeTerminalId:b})}return ll({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&i[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?gE(u,t,i[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:i}}function aI(e,t){const i=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const f=F_(u.root,t);if(!f)continue;const g=xn(f),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:f,activeTerminalId:p})}return ll({...o,tabs:c})}),r=i.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:i,activeWorkspaceId:r?e.activeWorkspaceId:i[0]?.id??null}}function oI(e,t,i,r){if(t&&t.length>0){const o=[];for(const c of t)yE(c)&&o.push(Lx(c,i,r));if(o.length>0)return o}return[Lx({...Sp(),tabs:e??[]},i,r)]}function Lx(e,t,i){const r=[];for(const c of e.tabs){if(!SE(c))continue;const u=K_(c.root,t);if(!u)continue;const f=xn(u);for(const p of f)i.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)||i.has(c)||(i.add(c),o.push(c));return ll({...e,defaultCwd:Ys(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function pE(e){return ol(e)?e:{...e,workspaces:[Sp()],activeWorkspaceId:bp}}function ol(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function yp(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function mE(e,t){for(const i of e){const r=i.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:i,tab:i.tabs[r],tabIndex:r}}return null}function lI(e,t){return e.workspaces.find(i=>i.tabs.some(r=>mc(r.root,t)))}function cI(e,t){return e.workspaces.find(i=>i.detachedTerminalIds.includes(t))}function uI(e,t,i,r){return e.map(o=>o.id===t?gE(o,i,r):o)}function gE(e,t,i){return vE(e,t)?{...e,defaultCwd:e.defaultCwd??Ys(i?.cwd),detachedTerminalIds:ry([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function vE(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<bc}function _E(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(i=>i!==t)}:e}function dI(e,t){if(e.defaultCwd)return e;const i=Vf(e).find(o=>!!t[o]),r=i?Ys(t[i]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Sp(){return{id:bp,title:P4,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ll(e){const t=e.tabs.some(i=>i.id===e.activeTabId);return{...e,defaultCwd:Ys(e.defaultCwd),detachedTerminalIds:ry(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function hI(e,t,i,r){const o=xn(i.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Ys(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,i],activeTabId:c.activeTabId??i.id}:c)}function bE(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function ud(e,t,i){return e.type==="pane"?e.terminalId===t?i:e:e.type==="editor"?e:{...e,first:ud(e.first,t,i),second:ud(e.second,t,i)}}function pc(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const i=pc(e.first,t),r=pc(e.second,t);return i&&r?{...e,first:i,second:r}:i??r}function F_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const i=F_(e.first,t),r=F_(e.second,t);return i&&r?{...e,first:i,second:r}:i??r}function K_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const i=K_(e.first,t),r=K_(e.second,t);return i&&r?{...e,ratio:wE(e.ratio),first:i,second:r}:i??r}function W_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=W_(e.first),i=W_(e.second);return t&&i?{...e,first:t,second:i}:t??i}function yE(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 SE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&q_(t.root)}function q_(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")&&q_(t.first)&&q_(t.second):!1}function V_(e,t,i){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===i?e:{...e,ratio:i};const[r,...o]=t;if(r===0){const c=V_(e.first,o,i);return c===e.first?e:{...e,first:c}}if(r===1){const c=V_(e.second,o,i);return c===e.second?e:{...e,second:c}}return e}function wE(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Ys(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ry(e){const t=new Set,i=[];for(const r of e)!r||t.has(r)||(t.add(r),i.push(r));return i}function mc(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:mc(e.first,t)||mc(e.second,t)}function xn(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...xn(e.first),...xn(e.second)]}function Y_(e){return e.type==="pane"||e.type==="editor"?1:Y_(e.first)+Y_(e.second)}const Sr=new Map,dd=new Map,hd=new Map,fd=new Map,pd=new Map,X_=new Set;let xE=0;function uo(e){return e??"__local__"}function fI(e){return{agentId:e,state:z4(),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 wt(e){const t=uo(e);let i=Sr.get(t);return i||(i=fI(e),Sr.set(t,i)),i}function pI(e){return Sr.get(uo(e))??null}function CE(e,t){const i=uo(e);let r=dd.get(i);return r||(r=new Set,dd.set(i,r)),r.add(t),()=>{r.delete(t)}}function mI(e){const t=uo(e),i=dd.get(t);if(i)for(const r of Array.from(i))r()}function Cc(e,t,i=!0){const r=Sr.get(uo(e)),o=i&&Ox(r)!==Ox(t);Sr.set(uo(e),t),mI(e),o&&oy()}function G_(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function ay(e,t){const i=e.state.workspaces.find(u=>u.id===t);if(!i)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const u of i.tabs)for(const f of xn(u.root))r.add(f);let o=0,c=0;for(const u of r)G_(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(c+=1);return{workingTerminalCount:o,unreadCompletionCount:c}}function Ox(e){return e?e.state.workspaces.map(t=>{const i=ay(e,t.id);return`${t.id}:${i.workingTerminalCount}:${i.unreadCompletionCount}`}).join("|"):""}function kE(e){return!!(e&&e.state.workspaces.some(t=>{const i=ay(e,t.id);return i.workingTerminalCount>0||i.unreadCompletionCount>0}))}function oy(){xE+=1;for(const e of Array.from(X_))e()}function gI(e){return X_.add(e),()=>{X_.delete(e)}}function Bx(){return xE}function vI(e,t){return ay(wt(e),t)}const Z_=new Set;function _I(e){return Z_.add(e),()=>{Z_.delete(e)}}function Ua(e,t){const i=wt(e),r=uo(e),o=yI(i.state,t);t.type==="workspace.hydrated"&&(hd.delete(r),fd.delete(r),pd.delete(r));const c=H4(i.state,t);let u=i.unreadCompletions,f=null;if(t.type==="terminal.updated"){const _=i.state.terminals[t.terminal.id],b=EI(r),w=DI(r),x=SI(r);if(t.terminal.agentStatus){const C=t.terminal.agentStatus.state,N=t.terminal.agentStatus.sessionId,L=x.get(t.terminal.id),M=!!(_&&(_.currentCommand!==t.terminal.currentCommand||_.agentStatus?.provider!==t.terminal.agentStatus.provider||bI(L,N)));M&&(w.delete(t.terminal.id),b.delete(t.terminal.id),x.delete(t.terminal.id)),N&&x.set(t.terminal.id,N),t.notifyCompletion===!0&&(C==="working"?(w.add(t.terminal.id),b.delete(t.terminal.id)):C==="unknown"&&t.terminal.activity==="busy"&&b.add(t.terminal.id)),!M&&(C==="done"||C==="stopped")&&(w.has(t.terminal.id)||b.has(t.terminal.id))&&(f=Px(c,t.terminal.id,_?.currentCommand??null,C==="stopped"?"stopped":"finished"),w.delete(t.terminal.id),b.delete(t.terminal.id)),C==="idle"&&(w.delete(t.terminal.id),b.delete(t.terminal.id))}else{_?.agentStatus&&(w.delete(t.terminal.id),x.delete(t.terminal.id));const C=_?.activity==="busy",N=t.terminal.activity==="busy",L=t.terminal.activity==="idle";t.notifyCompletion===!0&&N&&b.add(t.terminal.id),t.notifyCompletion===!0&&C&&L&&b.has(t.terminal.id)&&(f=Px(c,t.terminal.id,_?.currentCommand??null,"finished")),(L||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(f){const C=TE(c,t.terminal.id);C&&(C.workspace.activeTabId!==C.tab.id||C.workspace.id!==c.activeWorkspaceId)&&(u.has(t.terminal.id)||(u=new Set(u),u.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),w.delete(t.terminal.id),x.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let _=null;if(t.type==="tab.selected")_=wI(c,t.tabId)?.tab??null;else{const w=c.workspaces.find(x=>x.id===t.workspaceId);_=w?.tabs.find(x=>x.id===w.activeTabId)??null}const b=_?xn(_.root):[];if(b.some(w=>u.has(w))){const w=new Set(u);for(const x of b)w.delete(x);u=w}}const g=c!==i.state,p=u!==i.unreadCompletions;if((g||p)&&Cc(e,{...i,state:c,unreadCompletions:u},o||p),p&&wp(),f)for(const _ of Array.from(Z_))_({agentId:e,...f})}function bI(e,t){return e!==void 0&&t!==void 0&&e!==t}function yI(e,t){switch(t.type){case"terminal.updated":return G_(e.terminals[t.terminal.id])!==G_(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 SI(e){let t=pd.get(e);return t||(t=new Map,pd.set(e,t)),t}function TE(e,t){for(const i of e.workspaces)for(const r of i.tabs)if(xn(r.root).includes(t))return{workspace:i,tab:r};return null}function wI(e,t){for(const i of e.workspaces){const r=i.tabs.find(o=>o.id===t);if(r)return{workspace:i,tab:r}}return null}const Q_=new Set;function xI(e){return Q_.add(e),()=>{Q_.delete(e)}}function CI(){let e=0;for(const t of Sr.values())e+=t.unreadCompletions.size;return e}function wp(){for(const e of Array.from(Q_))e()}function jx(e,t){const i=wt(e);if(!i.unreadCompletions.has(t))return;const r=new Set(i.unreadCompletions);r.delete(t),Cc(e,{...i,unreadCompletions:r}),wp()}function Ix(e,t){const i=wt(e);t!==i.state&&Cc(e,{...i,state:t})}function uv(e,t){const i=wt(e),r=t(i.editors);r!==i.editors&&Cc(e,{...i,editors:r},!1)}function $a(e,t,i){const r=wt(e);r.loaded===t&&r.error===i||Cc(e,{...r,loaded:t,error:i},!1)}function Eu(e,t,i){const r=wt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===i||Cc(e,{...r,layoutRevision:t,lastPersistedLayoutJson:i},!1)}function kI(e){const t=wt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function TI(e){const t=uo(e),i=Sr.get(t);i&&i.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(i.mutable.saveCoord.saveTimer);const r=i?i.unreadCompletions.size>0:!1,o=kE(i);Sr.delete(t),dd.delete(t),hd.delete(t),fd.delete(t),pd.delete(t),r&&wp(),o&&oy()}function dv(){let e=!1,t=!1;for(const i of Sr.values()){const r=i.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),i.unreadCompletions.size>0&&(e=!0),kE(i)&&(t=!0)}Sr.clear(),dd.clear(),hd.clear(),fd.clear(),pd.clear(),e&&wp(),t&&oy()}function EI(e){let t=hd.get(e);return t||(t=new Set,hd.set(e,t)),t}function DI(e){let t=fd.get(e);return t||(t=new Set,fd.set(e,t)),t}function Px(e,t,i,r){const o=TE(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:i,outcome:r}:null}function J_(e,t){let i=!1,r=!1,o=null,c=!1;for(const u of Xo(e)){const f=t[u];if(f){if(f.status==="exited"){c=!0,i=!0;continue}f.activity==="busy"?(r=!0,i=!0,!o&&f.currentCommand&&(o=f.currentCommand)):f.activity==="idle"&&(i=!0)}}return i?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function ly(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function eb(e,t){const i=t[e.activeTerminalId];return e.title||i?.title||e.activeTerminalId}function RI(e,t,i,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${i} pane${i===1?"":"s"}`}function NI({tabs:e,activeTabId:t,terminals:i,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,onSelectTab:u,onCreateTab:f,onToggleWorkspaces:g,onCloseTerminals:p,onReattachTerminal:_,onDeleteTerminal:b,onSplitVertical:w,onSplitHorizontal:x,onRenameTab:C,onToggleFavorite:N,onOpenFavorites:L,activePaneAvailable:M}){const[U,P]=v.useState(null),[H,K]=v.useState(!1),[ee,j]=v.useState(null),J=v.useRef(null),fe=e.findIndex(R=>R.id===t),ie=fe>=0?e[fe]:e[0]??null,te=ie?J_(ie,i):null,Y=ie?qf(ie):0,Q=ie?eb(ie,i):"No tab";v.useEffect(()=>{J.current?.focus(),J.current?.select()},[U?.tabId]),v.useEffect(()=>{if(!H)return;const R=z=>{z.key==="Escape"&&K(!1)};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[H]),v.useEffect(()=>{H&&e.length===0&&K(!1)},[H,e.length]);function q(R,z){P({tabId:R,title:z})}function ae(){if(!U)return;const R=U.title.trim();R&&C(U.tabId,R),P(null)}function O(){return d.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${XM()}`,onClick:w,disabled:!M,children:d.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),d.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${GM()}`,onClick:x,disabled:!M,children:d.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return d.jsxs(d.Fragment,{children:[d.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[d.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:g,children:d.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[d.jsx("span",{}),d.jsx("span",{}),d.jsx("span",{})]})}),d.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Q,onClick:()=>K(!0),disabled:e.length===0,children:[te?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":te.state,"aria-hidden":"true",title:ly(te)}):null,d.jsx("span",{children:Q}),d.jsxs("small",{children:[fe>=0?fe+1:0,"/",e.length||0,Y>1?` / ${Y}`:""]})]}),d.jsxs("div",{className:"terminal-tab-list",children:[e.map((R,z)=>{const ce=Xo(R),ve=qf(R),A=eb(R,i),V=R.id===t,de=U?.tabId===R.id,Z=J_(R,i),Se=r?.has(R.id)??!1;return d.jsxs(Nt.Fragment,{children:[d.jsx(zx,{index:z}),d.jsx(MI,{tab:R,active:V,editing:de,title:A,paneCount:ve,terminalIds:ce,canClose:e.length>1,editValue:de?U.title:null,editInputRef:de?J:null,activity:Z,unread:Se,favorite:o?.has(R.id)??!1,onSelect:()=>u(R.id),onBeginRename:()=>q(R.id,A),onCloseAll:()=>p(ce),onCommitRename:ae,onCancelRename:()=>P(null),onRenameChange:ye=>P({tabId:R.id,title:ye}),onToggleFavorite:()=>N?.(R)})]},R.id)}),d.jsx(zx,{index:e.length}),d.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),d.jsx("button",{type:"button",className:"tab-favorites-button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>L?.(),children:"★"}),(c?.length??0)>0?d.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(c??[]).map(R=>d.jsx(LI,{terminal:R,onReattach:()=>_?.(R.id),onDelete:()=>j(R)},R.id))}):null]}),d.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:f,children:"+"}),M?O():null]}),H?d.jsx(AI,{tabs:e,activeTabId:t,terminals:i,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:U,editInputRef:J,onClose:()=>K(!1),onSelectTab:R=>{u(R),K(!1)},onCreateTab:()=>{f(),K(!1)},onBeginRename:q,onCloseTerminals:R=>{p(R),K(!1)},onCommitRename:ae,onCancelRename:()=>P(null),onRenameChange:(R,z)=>P({tabId:R,title:z}),onToggleFavorite:N,onOpenFavorites:L,onReattachTerminal:R=>{_?.(R),K(!1)},onDeleteTerminal:R=>{j(R),K(!1)}}):null,ee?d.jsx(OI,{terminal:ee,onCancel:()=>j(null),onConfirm:()=>{b?.(ee.id),j(null)}}):null]})}function MI({tab:e,active:t,editing:i,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:f,activity:g,unread:p,favorite:_,onSelect:b,onBeginRename:w,onCloseAll:x,onCommitRename:C,onCancelRename:N,onRenameChange:L,onToggleFavorite:M}){const{attributes:U,listeners:P,setNodeRef:H,transform:K,isDragging:ee}=_b({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:i}),j={transform:ea.Translate.toString(K),opacity:ee?.4:void 0,zIndex:ee?2:void 0};return d.jsxs("div",{ref:H,className:"terminal-tab","data-active":t,"data-dragging":ee,"data-unread":p?"true":void 0,style:j,...U,...P,children:[g?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:ly(g)}):null,i&&f&&u!==null?d.jsxs("form",{className:"terminal-tab-editor",onSubmit:J=>{J.preventDefault(),C()},children:[d.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:u,onBlur:C,onChange:J=>L(J.target.value),onKeyDown:J=>{if(J.key==="Enter"){J.preventDefault(),C();return}J.key==="Escape"&&(J.preventDefault(),N())}}),d.jsx("small",{children:o})]}):d.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:b,onDoubleClick:J=>{J.preventDefault(),w()},children:[d.jsx("span",{children:r}),d.jsx("small",{title:`${o} pane${o===1?"":"s"}`,children:o})]}),i?null:d.jsx("button",{type:"button",className:"terminal-tab-favorite","aria-label":_?`Remove ${r} from favorites`:`Add ${r} to favorites`,title:_?"Remove from favorites":"Add to favorites",onPointerDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),M()},children:_?"★":"☆"}),c&&!i?d.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),x()},children:"x"}):null]})}function AI({tabs:e,activeTabId:t,terminals:i,unreadCompletionTabIds:r,favoriteTabIds:o,detachedTerminals:c,editingTab:u,editInputRef:f,onClose:g,onSelectTab:p,onCreateTab:_,onBeginRename:b,onCloseTerminals:w,onCommitRename:x,onCancelRename:C,onRenameChange:N,onToggleFavorite:L,onOpenFavorites:M,onReattachTerminal:U,onDeleteTerminal:P}){const H=v.useRef(null);return v.useEffect(()=>{H.current?.scrollIntoView?.({block:"nearest"})},[t]),d.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:g,children:d.jsxs("section",{className:"mobile-tab-sheet",onClick:K=>K.stopPropagation(),children:[d.jsxs("header",{children:[d.jsxs("div",{children:[d.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),d.jsxs("small",{children:[e.length," open"]})]}),d.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[d.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:_,children:"+"}),d.jsx("button",{type:"button","aria-label":"Open favorite tabs",title:"Favorite tabs",onClick:()=>{g(),M?.()},children:"★"}),d.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:g,children:"×"})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((K,ee)=>{const j=Xo(K),J=qf(K),fe=eb(K,i),ie=K.id===t,te=u?.tabId===K.id,Y=J_(K,i),Q=r?.has(K.id)??!1,q=o?.has(K.id)??!1;return d.jsxs("div",{ref:ie?H:null,className:"mobile-tab-sheet-row","data-active":ie,"data-unread":Q?"true":void 0,children:[te&&u?d.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ae=>{ae.preventDefault(),x()},children:d.jsx("input",{ref:f,"aria-label":`Rename ${fe}`,value:u.title,onBlur:x,onChange:ae=>N(K.id,ae.target.value),onKeyDown:ae=>{if(ae.key==="Enter"){ae.preventDefault(),x();return}ae.key==="Escape"&&(ae.preventDefault(),C())}})}):d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${fe}`,onClick:()=>p(K.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:ee+1}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:fe}),d.jsx("small",{children:RI(K,i,J,Y)})]}),d.jsxs("span",{className:"mobile-tab-sheet-meta",children:[Y?d.jsx("span",{className:"terminal-tab-status-dot","data-activity":Y.state,"aria-hidden":"true",title:ly(Y)}):null,d.jsx("span",{children:J})]})]}),d.jsxs("div",{className:"mobile-tab-sheet-actions",children:[te?d.jsx("button",{type:"button","aria-label":`Done renaming ${fe}`,onClick:x,children:"Done"}):d.jsx("button",{type:"button","aria-label":`Rename ${fe}`,onClick:()=>b(K.id,fe),children:"Rename"}),te?null:d.jsx("button",{type:"button","aria-label":q?`Remove ${fe} from favorites`:`Add ${fe} to favorites`,title:q?"Remove from favorites":"Add to favorites",onClick:()=>L?.(K),children:q?"★":"☆"}),e.length>1?d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${fe}`,onClick:()=>w(j),children:"×"}):null]})]},K.id)}),(c?.length??0)>0?d.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[d.jsx("span",{children:"Detached"}),(c??[]).map(K=>{const ee=K.title||K.cwd||K.id.slice(0,8);return d.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[d.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${ee}`,onClick:()=>U(K.id),children:[d.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),d.jsxs("span",{className:"mobile-tab-sheet-copy",children:[d.jsx("strong",{children:ee}),d.jsx("small",{children:K.cwd})]}),d.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),d.jsx("div",{className:"mobile-tab-sheet-actions",children:d.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${ee}`,onClick:()=>P(K),children:"×"})})]},K.id)})]}):null]})]})})}function zx({index:e}){const{setNodeRef:t,isOver:i}=ip({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return d.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":i,"aria-hidden":"true"})}function LI({terminal:e,onReattach:t,onDelete:i}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
55
|
+
${e.cwd}
|
|
56
|
+
(detached — click to re-open, × to delete)`;return d.jsxs("span",{className:"terminal-detached-pill",title:o,children:[d.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),d.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),i()},children:"×"})]})}function OI({terminal:e,onCancel:t,onConfirm:i}){const r=e.title||e.cwd||e.id.slice(0,8);return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:"Delete this terminal?"}),d.jsx("span",{children:r}),d.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:i,children:"Delete"})]})]})})}function EE(e,t,i){const r=e.slice();return r.splice(i<0?r.length+i:i,0,r.splice(t,1)[0]),r}function BI(e,t){return e.reduce((i,r,o)=>{const c=t.get(r);return c&&(i[o]=c),i},Array(e.length))}function Gh(e){return e!==null&&e>=0}function jI(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function II(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const cy=e=>{let{rects:t,activeIndex:i,overIndex:r,index:o}=e;const c=EE(t,r,i),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}},Zh={scaleX:1,scaleY:1},PI=e=>{var t;let{activeIndex:i,activeNodeRect:r,index:o,rects:c,overIndex:u}=e;const f=(t=c[i])!=null?t:r;if(!f)return null;if(o===i){const p=c[u];return p?{x:0,y:i<u?p.top+p.height-(f.top+f.height):p.top-f.top,...Zh}:null}const g=zI(c,o,i);return o>i&&o<=u?{x:0,y:-f.height-g,...Zh}:o<i&&o>=u?{x:0,y:f.height+g,...Zh}:{x:0,y:0,...Zh}};function zI(e,t,i){const r=e[t],o=e[t-1],c=e[t+1];return r?i<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 DE="Sortable",RE=Nt.createContext({activeIndex:-1,containerId:DE,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:cy,disabled:{draggable:!1,droppable:!1}});function HI(e){let{children:t,id:i,items:r,strategy:o=cy,disabled:c=!1}=e;const{active:u,dragOverlay:f,droppableRects:g,over:p,measureDroppableContainers:_}=xC(),b=vd(DE,i),w=f.rect!==null,x=v.useMemo(()=>r.map(ee=>typeof ee=="object"&&"id"in ee?ee.id:ee),[r]),C=u!=null,N=u?x.indexOf(u.id):-1,L=p?x.indexOf(p.id):-1,M=v.useRef(x),U=!jI(x,M.current),P=L!==-1&&N===-1||U,H=II(c);Ws(()=>{U&&C&&_(x)},[U,x,C,_]),v.useEffect(()=>{M.current=x},[x]);const K=v.useMemo(()=>({activeIndex:N,containerId:b,disabled:H,disableTransforms:P,items:x,overIndex:L,useDragOverlay:w,sortedRects:BI(x,g),strategy:o}),[N,b,H.draggable,H.droppable,P,x,L,g,w,o]);return Nt.createElement(RE.Provider,{value:K},t)}const UI=e=>{let{id:t,items:i,activeIndex:r,overIndex:o}=e;return EE(i,r,o).indexOf(t)},$I=e=>{let{containerId:t,isSorting:i,wasDragging:r,index:o,items:c,newIndex:u,previousItems:f,previousContainerId:g,transition:p}=e;return!p||!r||f!==c&&o===u?!1:i?!0:u!==o&&t===g},FI={duration:200,easing:"ease"},NE="transform",KI=ea.Transition.toString({property:NE,duration:0,easing:"linear"}),WI={roleDescription:"sortable"};function qI(e){let{disabled:t,index:i,node:r,rect:o}=e;const[c,u]=v.useState(null),f=v.useRef(i);return Ws(()=>{if(!t&&i!==f.current&&r.current){const g=o.current;if(g){const p=_c(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(_)}}i!==f.current&&(f.current=i)},[t,i,r,o]),v.useEffect(()=>{c&&u(null)},[c]),c}function VI(e){let{animateLayoutChanges:t=$I,attributes:i,disabled:r,data:o,getNewIndex:c=UI,id:u,strategy:f,resizeObserverConfig:g,transition:p=FI}=e;const{items:_,containerId:b,activeIndex:w,disabled:x,disableTransforms:C,sortedRects:N,overIndex:L,useDragOverlay:M,strategy:U}=v.useContext(RE),P=YI(r,x),H=_.indexOf(u),K=v.useMemo(()=>({sortable:{containerId:b,index:H,items:_},...o}),[b,o,H,_]),ee=v.useMemo(()=>_.slice(_.indexOf(u)),[_,u]),{rect:j,node:J,isOver:fe,setNodeRef:ie}=ip({id:u,data:K,disabled:P.droppable,resizeObserverConfig:{updateMeasurementsFor:ee,...g}}),{active:te,activatorEvent:Y,activeNodeRect:Q,attributes:q,setNodeRef:ae,listeners:O,isDragging:R,over:z,setActivatorNodeRef:ce,transform:ve}=_b({id:u,data:K,attributes:{...WI,...i},disabled:P.draggable}),A=vD(ie,ae),V=!!te,de=V&&!C&&Gh(w)&&Gh(L),Z=!M&&R,Se=Z&&de?ve:null,Me=de?Se??(f??U)({rects:N,activeNodeRect:Q,activeIndex:w,overIndex:L,index:H}):null,He=Gh(w)&&Gh(L)?c({id:u,items:_,activeIndex:w,overIndex:L}):H,Fe=te?.id,Ue=v.useRef({activeId:Fe,items:_,newIndex:He,containerId:b}),Ve=_!==Ue.current.items,Ye=t({active:te,containerId:b,isDragging:R,isSorting:V,id:u,index:H,items:_,newIndex:Ue.current.newIndex,previousItems:Ue.current.items,previousContainerId:Ue.current.containerId,transition:p,wasDragging:Ue.current.activeId!=null}),D=qI({disabled:!Ye,index:H,node:J,rect:j});return v.useEffect(()=>{V&&Ue.current.newIndex!==He&&(Ue.current.newIndex=He),b!==Ue.current.containerId&&(Ue.current.containerId=b),_!==Ue.current.items&&(Ue.current.items=_)},[V,He,b,_]),v.useEffect(()=>{if(Fe===Ue.current.activeId)return;if(Fe!=null&&Ue.current.activeId==null){Ue.current.activeId=Fe;return}const pe=setTimeout(()=>{Ue.current.activeId=Fe},50);return()=>clearTimeout(pe)},[Fe]),{active:te,activeIndex:w,attributes:q,data:K,rect:j,index:H,newIndex:He,items:_,isOver:fe,isSorting:V,isDragging:R,listeners:O,node:J,overIndex:L,over:z,setNodeRef:A,setActivatorNodeRef:ce,setDroppableNodeRef:ie,setDraggableNodeRef:ae,transform:D??Me,transition:$()};function $(){if(D||Ve&&Ue.current.newIndex===H)return KI;if(!(Z&&!ep(Y)||!p)&&(V||Ye))return ea.Transition.toString({...p,property:NE})}}function YI(e,t){var i,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(i=e?.draggable)!=null?i:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}zt.Down,zt.Right,zt.Up,zt.Left;function XI({favorites:e,unavailableFavoriteIds:t,busy:i=!1,error:r=null,getRuntimeStatus:o,onClose:c,onOpen:u,onRemove:f,onReorder:g}){const p=v.useRef(null),[_,b]=v.useState(()=>Date.now()),[w,x]=v.useState("grid"),[C,N]=v.useState(null),L=sC(kf(mb,{activationConstraint:{distance:6}}),kf(gb,{activationConstraint:{delay:180,tolerance:8}})),M=v.useMemo(()=>e.map(Fs),[e]),U=v.useMemo(()=>new Map(e.map(j=>[Fs(j),o?.(j)??null])),[e,o,_]);v.useEffect(()=>{const j=window.setInterval(()=>b(Date.now()),3e4);return()=>window.clearInterval(j)},[]),v.useEffect(()=>{const j=J=>{if(J.key==="Escape"){J.preventDefault(),J.stopImmediatePropagation(),c();return}const fe=J.target;if((fe instanceof HTMLInputElement||fe instanceof HTMLTextAreaElement)&&p.current?.contains(fe)||J.ctrlKey||J.altKey||J.metaKey)return;const ie=Number.parseInt(J.key,10)-1;ie>=0&&ie<Math.min(9,e.length)&&(J.preventDefault(),J.stopImmediatePropagation(),u(e[ie]))};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[e,c,u]);const P=j=>{N(null);const J=String(j.active.id),fe=j.over?String(j.over.id):null;if(!fe||J===fe)return;const ie=e.find(Y=>Fs(Y)===J),te=e.find(Y=>Fs(Y)===fe);ie&&te&&g(ie,te)},H=j=>N({activeId:String(j.active.id),overId:null}),K=j=>{const J=String(j.active.id),fe=j.over?String(j.over.id):null;N(ie=>ie?.activeId===J&&ie.overId===fe?ie:{activeId:J,overId:fe})},ee=C?e.find(j=>Fs(j)===C.activeId)??null:null;return d.jsx("div",{className:"favorite-tabs-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"favorite-tabs-title",onClick:c,children:d.jsxs("section",{ref:p,className:"favorite-tabs-dialog",onClick:j=>j.stopPropagation(),children:[d.jsxs("header",{className:"favorite-tabs-header",children:[d.jsxs("div",{children:[d.jsxs("h2",{id:"favorite-tabs-title",children:["Favorite Tabs ",d.jsx("span",{children:e.length})]}),d.jsx("p",{children:"Press 1–9 to open a favorite"})]}),d.jsxs("div",{className:"favorite-tabs-actions",role:"group","aria-label":"Favorite tab view",children:[d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"Grid view",title:"Grid view","aria-pressed":w==="grid",onClick:()=>x("grid"),children:"▦"}),d.jsx("button",{type:"button",className:"favorite-tabs-view","aria-label":"List view",title:"List view","aria-pressed":w==="list",onClick:()=>x("list"),children:"☷"}),d.jsx("button",{type:"button","aria-label":"Close favorite tabs",title:"Close",onClick:c,children:"×"})]})]}),d.jsxs(wC,{sensors:L,collisionDetection:jD,onDragStart:H,onDragOver:K,onDragEnd:P,onDragCancel:()=>N(null),children:[d.jsxs("div",{className:"favorite-tabs-list","data-view":w,children:[r?d.jsx("p",{className:"favorite-tabs-error",role:"alert",children:r}):null,e.length===0?d.jsx("p",{className:"favorite-tabs-empty",children:"Star a tab to keep it close."}):d.jsx(HI,{items:M,strategy:w==="grid"?cy:PI,children:e.map((j,J)=>d.jsx(GI,{favorite:j,index:J,busy:i,unavailable:t?.has(Fs(j))??!1,runtimeStatus:U.get(Fs(j))??null,now:_,isDropTarget:C?.overId===Fs(j)&&C.activeId!==Fs(j),onOpen:u,onRemove:f},Fs(j)))})]}),d.jsx(KR,{dropAnimation:{duration:120,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:ee?d.jsx(ZI,{favorite:ee}):null})]})]})})}const GI=v.memo(function({favorite:t,index:i,busy:r,unavailable:o,runtimeStatus:c,now:u,isDropTarget:f,onOpen:g,onRemove:p}){const _=Fs(t),{attributes:b,listeners:w,setActivatorNodeRef:x,setNodeRef:C,transform:N,transition:L,isDragging:M}=VI({id:_,disabled:r,transition:{duration:100,easing:"cubic-bezier(0.2, 0, 0, 1)"}}),U={transform:ea.Transform.toString(N),transition:L,zIndex:M?1:void 0,opacity:M?.16:void 0};return d.jsxs("div",{ref:C,className:"favorite-tab-row","data-dragging":M||void 0,"data-drop-target":f||void 0,style:U,children:[d.jsx("button",{ref:x,type:"button",className:"favorite-tab-drag","aria-label":`Reorder favorite ${i+1}`,title:"Drag to reorder",onClick:P=>P.stopPropagation(),...b,...w,children:"⋮⋮"}),d.jsxs("button",{type:"button",className:"favorite-tab-open",onClick:()=>g(t),disabled:r||o,title:o?"Server is no longer registered":void 0,children:[d.jsx("span",{className:"favorite-tab-index",children:i<9?i+1:"·"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsx("small",{children:o?"Unavailable server":`${t.serverName} › ${t.workspaceName}${t.cwd?` · ${t.cwd}`:""}`}),c&&!o?d.jsxs("small",{className:`favorite-tab-runtime favorite-tab-runtime--${c.state}`,title:"Last observed terminal status",children:[d.jsx("i",{"aria-hidden":"true"}),QI(c.state),c.lastActivityAt?` · ${JI(c.lastActivityAt,u)}`:""]}):null]}),d.jsxs("span",{className:"favorite-tab-providers","aria-label":t.providers.length?`Contains ${t.providers.join(" and ")}`:void 0,children:[t.providers.map(P=>d.jsx("img",{src:`/brand/${P}.webp`,alt:"","aria-hidden":"true"},P)),d.jsx("em",{children:t.paneCount})]})]}),d.jsx("button",{type:"button",className:"favorite-tab-remove","aria-label":`Remove ${t.tabName} from favorites`,title:"Remove from favorites",disabled:r,onClick:()=>p(t),children:"×"})]})}),ZI=v.memo(function({favorite:t}){return d.jsxs("div",{className:"favorite-tab-drag-preview","aria-hidden":"true",children:[d.jsx("span",{className:"favorite-tab-index",children:"★"}),d.jsxs("span",{className:"favorite-tab-copy",children:[d.jsx("strong",{children:t.tabName}),d.jsxs("small",{children:[t.serverName," › ",t.workspaceName]})]}),d.jsxs("span",{className:"favorite-tab-providers",children:[t.providers.map(i=>d.jsx("img",{src:`/brand/${i}.webp`,alt:""},i)),d.jsx("em",{children:t.paneCount})]})]})});function Fs(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function QI(e){return e==="working"?"Working":e==="done"?"Done":e==="stopped"?"Stopped":e==="exited"?"Exited":"Idle"}function JI(e,t){const i=Date.parse(e);if(!Number.isFinite(i))return"recently";const r=Math.max(0,Math.floor((t-i)/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 e6({uploads:e,onDismiss:t,onDismissAll:i,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return d.jsxs("aside",{className:`upload-toast upload-toast-${r6(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[d.jsxs("header",{className:"upload-toast-header",children:[d.jsx("strong",{children:e.length===1?mf(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),d.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:i,children:"x"})]}),d.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>d.jsx(t6,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function t6({upload:e,compact:t,onDismiss:i,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return d.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":mf(e),children:[d.jsxs("div",{className:"upload-queue-item-header",children:[d.jsx("strong",{children:mf(e)}),d.jsxs("div",{className:"upload-queue-actions",children:[f?d.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?d.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,d.jsx("button",{type:"button","aria-label":`Dismiss ${mf(e)}`,onClick:i,children:"x"})]})]}),e.status==="queued"?d.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?d.jsx(n6,{toast:e}):null,c&&"message"in e&&e.message?d.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?d.jsx(i6,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?d.jsx("p",{children:e.message}):null]})}function n6({toast:e}){const t=e.percent===null?a6(e.loaded):`${e.percent}%`;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"upload-progress-row",children:[d.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),d.jsx("span",{children:t})]}),d.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:d.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function i6({response:e,compact:t}){const i=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...i,...r].slice(0,o);return d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?d.jsx("ul",{className:"upload-result-list",children:c.map((u,f)=>d.jsx(s6,{result:u},`${u.relativePath}-${f}`))}):null,e.results.length>c.length?d.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function s6({result:e}){const t=e.savedRelativePath??e.relativePath,i=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return d.jsxs("li",{"data-status":e.status,children:[d.jsx("span",{className:"upload-result-path",children:t}),i?d.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?d.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function mf(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,i=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${i} files`}return"Upload failed"}function r6(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 a6(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function o6({toast:e,onActivate:t,onDismiss:i}){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(),i()}function f(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return d.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:f,children:[d.jsxs("header",{className:"completion-toast-header",children:[d.jsxs("div",{className:"completion-toast-copy",children:[d.jsx("strong",{children:r.tabTitle}),d.jsx("span",{children:c})]}),d.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),d.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const l6=ju(0,0,1,1),Yr=1e-6;function c6(e){return ME(e).map(t=>t.terminalId)}function ME(e){return Bu(e,l6).sort(f6).map((t,i)=>({...t,index:i+1}))}function u6(e,t,i){const r=ME(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>h6(o,u,i)).filter(u=>u!==null).sort(p6)[0]?.entry.terminalId??null:null}function d6(e,t){return!Number.isInteger(t)||t<1?null:c6(e)[t-1]??null}function Bu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const i=m6(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*i;return[...Bu(e.first,ju(t.left,t.top,o,t.bottom)),...Bu(e.second,ju(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*i;return[...Bu(e.first,ju(t.left,t.top,t.right,r)),...Bu(e.second,ju(t.left,r,t.right,t.bottom))]}function h6(e,t,i){const r=e.bounds,o=t.bounds,c=Hx(r.left,r.right,o.left,o.right),u=Hx(r.top,r.bottom,o.top,o.bottom);switch(i){case"left":return o.centerX>=r.centerX-Yr||u<=Yr?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+Yr||u<=Yr?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-Yr||c<=Yr?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+Yr||c<=Yr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function f6(e,t){return rc(e.bounds.top,t.bounds.top)||rc(e.bounds.left,t.bounds.left)}function p6(e,t){return rc(e.primaryDistance,t.primaryDistance)||rc(e.perpendicularDistance,t.perpendicularDistance)||rc(t.overlap,e.overlap)||rc(e.entry.index,t.entry.index)}function rc(e,t){const i=e-t;return Math.abs(i)<=Yr?0:i}function Hx(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))}function ju(e,t,i,r){return{left:e,top:t,right:i,bottom:r,centerX:e+(i-e)/2,centerY:t+(r-t)/2}}function m6(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const Ux="nterminal.terminalWorkspaces.v2",AE="nterminal.sidebarCollapsed.v1",g6=75,$x=TC.map(e=>e.url),v6=TC[0].url,_6=6;function b6({api:e,serverApi:t,activeAgentId:i=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:f}){const g=v.useMemo(()=>e??Gf(),[e]),p=v.useMemo(()=>t??pr(null),[t]),_=v.useMemo(()=>$6(i),[i]),b=v.useMemo(()=>S=>CE(i,S),[i]),w=v.useMemo(()=>()=>wt(i),[i]),x=v.useSyncExternalStore(b,w,w),C=x.state,N=x.editors,L=!x.loaded,M=x.error,[U,P]=v.useState(!1),[H,K]=v.useState(()=>X6()),[ee,j]=v.useState("servers"),[J,fe]=v.useState(!1),[ie,te]=v.useState(!1),[Y,Q]=v.useState([]),[q,ae]=v.useState(!1),[O,R]=v.useState(null),[z,ce]=v.useState(null),[ve,A]=v.useState(null),V=v.useMemo(()=>pr(ve?.agentId??null),[ve?.agentId]),de=v.useMemo(()=>pr(z?.agentId??null),[z?.agentId]),Z=v.useSyncExternalStore(aA,Qw,Qw);v.useSyncExternalStore($u,Zw,Zw);const[Se,ye]=v.useState(0),[Me,He]=v.useState(null),[Fe,Ue]=v.useState(()=>[null]),[Ve,Ye]=v.useState(()=>({[Vt]:"Local"})),[D,$]=v.useState(0),[pe,Ne]=v.useState(()=>[i]),[ne,ge]=v.useState(()=>new Set),[Ee,Re]=v.useState({}),[Te,je]=v.useState(null),Ze=v.useRef(0),Ae=v.useRef(0),[_t,bt]=v.useState(null),[at,ot]=v.useState(null),Bt=v.useRef(null),ln=v.useRef(0),Ht=v.useRef(null),On=v.useRef(null),Ut=v.useRef(null),kt=v.useRef(null),$t=v.useRef([]),At=v.useRef(0),kn=v.useRef(!1),mi=v.useRef(0),le=v.useRef(0),Ge=v.useRef([]),it=v.useRef(null),ct=v.useRef(()=>{}),[Dt,jt]=v.useState(null),hn=sC(kf(mb,{activationConstraint:{distance:8}}),kf(gb,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>oA(g),[g]);function Tn(S){const k=S.active.data.current;if(k){if(k.kind==="tab"&&typeof k.tabId=="string"&&typeof k.terminalId=="string"){jt({tabId:k.tabId,terminalId:k.terminalId});return}k.kind==="pane"&&typeof k.sourceTabId=="string"&&typeof k.terminalId=="string"&&jt({tabId:k.sourceTabId,terminalId:k.terminalId})}}function _e(S){jt(null);const k=S.active.data.current,B=S.over?.data.current;if(!(!k||!B||typeof k.terminalId!="string")){if(k.kind==="tab"&&typeof k.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){ut({type:"tab.reordered",sourceTabId:k.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){ut({type:"tab.moved_to_workspace",sourceTabId:k.tabId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&ut({type:"tab.dropped_into_pane",sourceTabId:k.tabId,sourceTerminalId:k.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(k.kind==="pane"&&typeof k.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){ut({type:"terminal.extracted_to_tab",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){ut({type:"terminal.extracted_to_workspace",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&ut({type:"tab.dropped_into_pane",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function ze(){jt(null)}const Ie=C.workspaces.find(S=>S.id===C.activeWorkspaceId)??C.workspaces[0],We=Ie?.tabs.find(S=>S.id===Ie.activeTabId)??Ie?.tabs[0],Je=We?.activeTerminalId??null,It=Je?C.terminals[Je]:void 0,Ft=j6("(max-width: 760px)"),Gn=v.useMemo(()=>We?Yf(We.root):[],[We]),en=Ie&&We?Iu(i,Ie.id,We.id):null,Bn=We?LE(Gn,We.activeTerminalId,en?Ee[en]:void 0):null,vn=Ft&&Gn.length>1,_n=v.useMemo(()=>(Ie?.detachedTerminalIds??[]).flatMap(S=>{const k=C.terminals[S];return k?[k]:[]}),[Ie?.detachedTerminalIds,C.terminals]),sn=v.useMemo(()=>{const S=new Set;for(const k of Ie?.tabs??[])Xo(k).some(B=>x.unreadCompletions.has(B))&&S.add(k.id);return S},[Ie?.tabs,x.unreadCompletions]);v.useSyncExternalStore(gI,Bx,Bx);const[Zn,Ki]=v.useState([]),gi=v.useRef([]),os=v.useRef(null),[sa,ls]=v.useState(null),[oi,cs]=v.useState(null),[us,ds]=v.useState([]),[Mi,Bs]=v.useState(()=>el()),fn=v.useRef(0),Ai=v.useRef(i),fo=v.useRef($x),Li=v.useRef(Mi),tn=v.useRef(()=>{});tn.current=tr,ct.current=ha;const wr=v.useCallback(async()=>{try{const S=await g.listNotificationAssets();ds(S.assets.filter(k=>k.enabled).map(k=>k.url))}catch{ds([])}},[g]),ra=v.useCallback(S=>{Ye(k=>{const B={...k};for(const X of S)B[_f(X.agentId)]=X.label;return hv(k,B)?k:B})},[]);v.useEffect(()=>{const S=le.current+1;le.current=S;const k=mi.current;g.getFavorites().then(B=>{S!==le.current||k!==mi.current||(Qs(B.favorites,B.revision),vi(B.favorites,i,C))}).catch(()=>{})},[g]),v.useEffect(()=>{vi($t.current,i,C)},[i,Ve]),v.useEffect(()=>{Ne(S=>S.some(k=>Sn(k,i))?S:[...S,i])},[i]);const Xs=v.useCallback(S=>{const k=wt(S),B=pr(S);for(const X of Object.keys(k.state.terminals))Ql(B.createWebSocketUrl(X)),ku(X),Zl(X);TI(S),Ne(X=>X.filter(oe=>!Sn(oe,S))),ge(X=>{const oe=`${vf(S)}:`;let he=!1;const xe=new Set;for(const Oe of X){if(Oe.startsWith(oe)){he=!0;continue}xe.add(Oe)}return he?xe:X}),Re(X=>{const oe=`${vf(S)}:`;let he=!1;const xe={};for(const[Oe,Pe]of Object.entries(X)){if(Oe.startsWith(oe)){he=!0;continue}xe[Oe]=Pe}return he?xe:X})},[]);v.useEffect(()=>{let S=!1;return g.getMainInfo().then(k=>{if(S)return;const B=k.name?.trim()||"Local";Ye(X=>{const oe={...X,[Vt]:B};return hv(X,oe)?X:oe})}).catch(()=>{}),g.listAgents().then(k=>{if(!S){const B=k.agents.map(he=>he.id),X=pM(k.serverOrder,k.agents);Ye(he=>{const xe={[Vt]:he[Vt]??"Local"};for(const Oe of k.agents)xe[Oe.id]=Oe.name;return hv(he,xe)?he:xe}),i!==null&&!B.includes(i)&&(Xs(i),r?.(null));const oe=kt.current;oe&&oe.serverId!==Vt&&!B.includes(oe.serverId)&&(kt.current=null,R(`${oe.serverName} is no longer registered.`),te(!0)),Ue(X)}}).catch(()=>{}),()=>{S=!0}},[i,g,Xs,r,D]);const po=v.useCallback(S=>{Xs(S),$(k=>k+1),Sn(S,Ai.current)&&r?.(null)},[Xs,r]);v.useEffect(()=>{Ue(S=>S.some(k=>Sn(k,i))?S:[...S,i])},[i]),v.useEffect(()=>{Ai.current=i},[i]),v.useEffect(()=>{He(null)},[i]),v.useEffect(()=>{const S=Ht.current;if(!S)return;if(!Sn(S.agentId,i)){Ht.current=null;return}if(!x.loaded||C.workspaces.length===0)return;Ht.current=null;const k=S.edge==="first"?C.workspaces[0]:C.workspaces[C.workspaces.length-1];k&&k.id!==C.activeWorkspaceId&&ut({type:"workspace.selected",workspaceId:k.id})},[i,x.loaded,C.activeWorkspaceId,C.workspaces]),v.useEffect(()=>{const S=On.current;if(S){if(!Sn(S.agentId,i)){On.current=null;return}x.loaded&&(On.current=null,C.workspaces.some(k=>k.id===S.workspaceId)&&ut({type:"workspace.selected",workspaceId:S.workspaceId}))}},[i,x.loaded,C.workspaces]),v.useEffect(()=>{const S=Ut.current;if(S){if(!Sn(S.agentId,i)){Ut.current=null;return}x.loaded&&(Ut.current=null,x.error||En())}},[i,x.error,x.loaded]),v.useEffect(()=>{const S=kt.current;if(!(!S||!Sn(S.serverId===Vt?null:S.serverId,i)||!x.loaded)){if(kt.current=null,x.error){R(`Could not reach ${S.serverName}.`),te(!0);return}Oi(S)}},[i,x.loaded]),v.useEffect(()=>{In()},[i,x.loaded,C]),v.useEffect(()=>{const S=()=>{const X=P6();X&&ct.current(X)},k=X=>{const oe=z6(X.data);oe&&ct.current(oe)},B=X=>{const oe=sp(X.detail);oe&&ct.current(oe)};return S(),window.addEventListener("hashchange",S),window.addEventListener(yv,B),navigator.serviceWorker?.addEventListener?.("message",k),()=>{window.removeEventListener("hashchange",S),window.removeEventListener(yv,B),navigator.serviceWorker?.removeEventListener?.("message",k)}},[]),v.useEffect(()=>{wr()},[wr]),v.useEffect(()=>jC(()=>Bs(el())),[]),v.useEffect(()=>{const S=k=>{tn.current(k)};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{fo.current=us.length>0?us:$x},[us]),v.useEffect(()=>{Li.current=Mi},[Mi]),v.useEffect(()=>{if(!x.loaded||!Ie||!We)return;const S=Iu(i,Ie.id,We.id);ge(k=>{if(k.has(S))return k;const B=new Set(k);return B.add(S),B})},[i,x.loaded,Ie?.id,We?.id]),v.useEffect(()=>()=>{rr()},[]),v.useEffect(()=>{const S=UN(g),k=KN(g);return()=>{S(),k()}},[g]),v.useEffect(()=>_I(S=>{const k=wt(S.agentId).state,B=k.workspaces.flatMap(xe=>xe.tabs).find(xe=>xe.id===S.tabId),X=k.terminals[S.terminalId],oe=B?.title?.trim()||X?.title||S.commandName||"terminal",he=document.visibilityState==="visible"&&Sn(S.agentId,Ai.current)&&S.tabId===U6(k);if(he||BN({agentId:S.agentId,tabTitle:oe,commandName:S.commandName,terminalId:S.terminalId,outcome:S.outcome}),!he&&document.visibilityState==="visible"&&Li.current.enabled){const xe=fn.current+1;fn.current=xe;const Oe=fo.current;ls({id:xe,agentId:S.agentId,terminalId:S.terminalId,tabId:S.tabId,tabTitle:oe,commandName:S.commandName,outcome:S.outcome,assetSrc:Oe[Math.floor(Math.random()*Oe.length)]??v6})}}),[]),v.useEffect(()=>{if(!sa||Mi.persistUntilDismissed)return;const S=window.setTimeout(()=>{ls(k=>k?.id===sa.id?null:k)},Mi.durationSeconds*1e3);return()=>window.clearTimeout(S)},[sa,Mi]),v.useEffect(()=>{G6(H),H&&js()},[H]),v.useEffect(()=>{let S=!1;async function k(){if(!wt(i).loaded){$a(i,!1,null);try{let X=null,oe=null;try{X=F6(_)}catch(Pe){if(!(Pe instanceof Xf))throw Pe;oe=Pe}const[he,xe]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Oe=he.terminals.length>0?he.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!S){const Pe=xe.layout?nb(xe.layout):null;if(!Pe&&oe)throw oe;const ht=Pe??X??{},Mt=pf(Oe,void 0,ht.savedWorkspaces,ht.savedActiveWorkspaceId),yi=cv(Mt);Ix(i,Mt),Eu(i,xe.revision,JSON.stringify(yi)),$a(i,!0,null),!Pe&&X&&fa(yi,{baseRevision:xe.revision})}}catch(X){!S&&!er(X)&&$a(i,!0,Fa(X))}}}return k(),()=>{S=!0}},[i,p,Se]);function Qn(){$a(i,!1,null),ye(S=>S+1)}function js(){Ze.current+=1,Ae.current+=1,je(null)}function Wi(S){Ze.current+=1,Ae.current+=1,je(k=>k&&{...k,cwd:S,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function En(){Ze.current+=1,Ae.current+=1;const S=C.workspaces.length+1,k=xr();je({mode:"create",workspaceId:null,title:`Workspace ${S}`,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),k&&Gs(k)}function aa(S){if(Sn(S,i)){En();return}Ut.current={agentId:S},r?.(S)}function cl(S){if(H&&!U)return;const k=C.workspaces.find(X=>X.id===S);if(!k)return;Ze.current+=1,Ae.current+=1;const B=k.defaultCwd??It?.cwd??"";je({mode:"edit",workspaceId:S,title:k.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&Gs(B)}function xr(){return Ie?.defaultCwd??It?.cwd??""}async function Gs(S){const k=Ze.current+1;Ze.current=k;const B=S.trim();if(je(X=>X&&{...X,cwd:S,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const X=await p.createFileRoot({path:B}),oe=await p.listFiles({rootToken:X.rootToken,path:""});if(Ze.current!==k)return;je(he=>he&&{...he,cwd:X.rootPath,browseRoot:{rootToken:X.rootToken,rootPath:X.rootPath},browseEntries:oe.entries.filter(xe=>xe.kind==="directory"),browseStatus:"idle",error:null})}catch(X){if(Ze.current!==k)return;je(oe=>oe&&{...oe,browseStatus:"idle",error:Fa(X)})}}async function Is(){const S=Te;if(!S)return;const k=S.title.trim(),B=S.cwd.trim();if(!k||!B){je({...S,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const X=Ae.current+1;Ae.current=X,je({...S,submitStatus:"submitting",error:null});try{const oe=await p.createFileRoot({path:B});if(Ae.current!==X)return;if(S.mode==="create"){const he=C.workspaces.length+1;ut({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${he}`,title:k,defaultCwd:oe.rootPath})}else S.workspaceId&&(ut({type:"workspace.renamed",workspaceId:S.workspaceId,title:k}),ut({type:"workspace.defaultCwdChanged",workspaceId:S.workspaceId,defaultCwd:oe.rootPath}));je(null)}catch(oe){if(Ae.current!==X)return;je(he=>he&&{...he,submitStatus:"idle",error:Fa(oe)})}}function mo(S){Ae.current+=1,je(S)}function Dn(S,k,B){if(S===k)return;const X=C.workspaces.some(he=>he.id===S),oe=C.workspaces.some(he=>he.id===k);!X||!oe||ut({type:"workspace.reordered",sourceWorkspaceId:S,targetWorkspaceId:k,placement:B})}function li(S,k){const B=C.workspaces.findIndex(oe=>oe.id===S),X=C.workspaces[B+k];B<0||!X||Dn(S,X.id,k<0?"before":"after")}function Cr(S,k){k.pointerType==="mouse"&&k.button!==0||(k.preventDefault(),k.stopPropagation(),Bt.current={sourceId:S,pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,active:!1,targetId:null,placement:"after"},k.currentTarget.setPointerCapture?.(k.pointerId))}function go(S){const k=Bt.current;if(!k||k.pointerId!==S.pointerId)return;const B=Math.hypot(S.clientX-k.startX,S.clientY-k.startY);if(!k.active){if(B<_6)return;k.active=!0,bt(k.sourceId)}const oe=document.elementFromPoint(S.clientX,S.clientY)?.closest("[data-workspace-id]"),he=oe?.dataset.workspaceId??null;if(!oe||!he||he===k.sourceId||!C.workspaces.some(Pe=>Pe.id===he)){k.targetId=null,ot(null);return}const xe=oe.getBoundingClientRect(),Oe=S.clientY<xe.top+xe.height/2?"before":"after";k.targetId=he,k.placement=Oe,ot({workspaceId:he,placement:Oe})}function hs(S){const k=Bt.current;!k||k.pointerId!==S.pointerId||(S.preventDefault(),S.stopPropagation(),S.currentTarget.releasePointerCapture?.(S.pointerId),Bt.current=null,bt(null),ot(null),k.active&&k.targetId&&Dn(k.sourceId,k.targetId,k.placement))}function vo(S){const k=Bt.current;k&&k.pointerId===S.pointerId&&S.currentTarget.releasePointerCapture?.(S.pointerId),Bt.current=null,bt(null),ot(null)}async function Zs(){await Rn(async()=>{const S=Ie?.defaultCwd?{cols:80,rows:24,cwd:Ie.defaultCwd}:{cols:80,rows:24},k=await p.createTerminal(S);ut({type:"terminal.created",terminal:k.terminal})})}function fs(S,k=Ie,B=C,X=i){const oe=B.terminals[S.activeTerminalId],he=Array.from(new Set(Xo(S).flatMap(xe=>{const Oe=B.terminals[xe]?.agentStatus?.provider;return Oe==="codex"||Oe==="claude"?[Oe]:[]})));return{serverId:X??Vt,workspaceId:k.id,tabId:S.id,serverName:Ve[_f(X)]??"Local",workspaceName:k.title,tabName:S.title||oe?.title||"Terminal",cwd:oe?.cwd||k.defaultCwd,paneCount:qf(S),providers:he}}function Ps(S){const k=S.serverId===Vt?null:S.serverId,B=pI(k);if(!B?.loaded||B.error)return null;const X=B.state,he=X.workspaces.find(Pe=>Pe.tabs.some(ht=>ht.id===S.tabId))?.tabs.find(Pe=>Pe.id===S.tabId);if(!he)return null;const xe=Xo(he).flatMap(Pe=>{const ht=X.terminals[Pe];return ht?[ht]:[]});if(xe.length===0)return null;const Oe=xe.reduce((Pe,ht)=>{const Mt=ht.agentCache?.lastCallAt;return Mt&&(!Pe||Date.parse(Mt)>Date.parse(Pe))?Mt:Pe},null);return xe.some(Pe=>Pe.status==="running"&&(Pe.agentStatus?.state==="working"||!Pe.agentStatus&&Pe.activity==="busy"))?{state:"working",lastActivityAt:Oe}:xe.some(Pe=>Pe.agentStatus?.state==="stopped")?{state:"stopped",lastActivityAt:Oe}:xe.some(Pe=>Pe.agentStatus?.state==="done")?{state:"done",lastActivityAt:Oe}:xe.every(Pe=>Pe.status==="exited")?{state:"exited",lastActivityAt:Oe}:{state:"idle",lastActivityAt:Oe}}function Qs(S,k){$t.current=S,At.current=k,Q(S)}function ps(S){mi.current+=1,Ge.current.push(S),!kn.current&&(kn.current=!0,ae(!0),R(null),(async()=>{try{for(;Ge.current.length>0;){const k=Ge.current.shift();let B=0;for(;B<2;){const X=k($t.current);if(Kx(X,$t.current))break;Qs(X,At.current);try{const oe=await g.saveFavorites({favorites:X,baseRevision:At.current});Qs(oe.favorites,oe.revision);break}catch(oe){const he=await g.getFavorites().catch(()=>null);if(he&&Qs(he.favorites,he.revision),oe instanceof Vn&&oe.status===409&&he){B+=1;continue}Ge.current=[],R("Could not save favorites. Please try again.");return}}if(B>=2){Ge.current=[],R("Favorites changed on another device. Please try again.");return}}}finally{kn.current=!1,ae(!1)}})())}function vi(S,k,B){const X=k??Vt,oe=S.map(he=>{if(he.serverId!==X)return he;const xe=B.workspaces.find(Pe=>Pe.tabs.some(ht=>ht.id===he.tabId)),Oe=xe?.tabs.find(Pe=>Pe.id===he.tabId);return xe&&Oe?fs(Oe,xe,B,k):he});Kx(S,oe)||ps(()=>oe)}function kc(S){const k=i??Vt,B=$t.current.find(oe=>oe.serverId===k&&oe.tabId===S.id);if(B){const oe=Ns(B);ps(he=>he.filter(xe=>Ns(xe)!==oe));return}if(!Ie||$t.current.length>=100)return;const X=fs(S);ps(oe=>oe.length>=100?oe:[...oe,X])}function oa(S){const k=S.serverId===Vt?null:S.serverId;if(k!==null&&!Fe.some(B=>Sn(B,k))){R(`${S.serverName} is no longer registered.`);return}if(R(null),te(!1),!Sn(k,i)){kt.current=S,r?.(k);return}Oi(S)}async function Oi(S){const k=wt(i).state,B=k.workspaces.find(oe=>oe.tabs.some(he=>he.id===S.tabId));if(B){ut({type:"workspace.selected",workspaceId:B.id}),ut({type:"tab.selected",tabId:S.tabId});return}let X=k.workspaces.find(oe=>oe.id===S.workspaceId);if(!X){const oe=`workspace-favorite-${Date.now().toString(36)}`;ut({type:"workspace.created",workspaceId:oe,title:S.workspaceName,defaultCwd:S.cwd}),X=wt(i).state.workspaces.find(he=>he.id===oe)}X&&ut({type:"workspace.selected",workspaceId:X.id}),await Rn(async()=>{const oe=await p.createTerminal(S.cwd?{cols:80,rows:24,cwd:S.cwd}:{cols:80,rows:24});ut({type:"terminal.created",terminal:oe.terminal});const xe=wt(i).state.workspaces.find(pn=>pn.tabs.some(zs=>zs.activeTerminalId===oe.terminal.id)),Oe=xe?.tabs.find(pn=>pn.activeTerminalId===oe.terminal.id);if(!Oe||!xe)return;Oe.title!==S.tabName&&ut({type:"tab.renamed",tabId:Oe.id,title:S.tabName});const Pe=wt(i).state,ht=Pe.workspaces.find(pn=>pn.id===xe.id)??xe,Mt=ht.tabs.find(pn=>pn.id===Oe.id)??Oe,yi=fs(Mt,ht,Pe);ps(pn=>pn.map(zs=>zs.serverId===S.serverId&&zs.workspaceId===S.workspaceId&&zs.tabId===S.tabId?yi:zs))})}async function _i(S){await Rn(async()=>{const k=Je?{parentTerminalId:Je,cols:80,rows:24}:Ie?.defaultCwd?{cols:80,rows:24,cwd:Ie.defaultCwd}:{cols:80,rows:24},B=await p.createTerminal(k);ut({type:"terminal.split",terminal:B.terminal,direction:S})})}async function la(S){let k=Je,B=en;const X=Ie?.defaultCwd?.trim();if(!k&&!X)throw new Error("No active pane is available.");const oe=await p.readFile(S);if(!k&&X){const Oe=await p.createTerminal({cols:80,rows:24,cwd:X});k=Oe.terminal.id,ut({type:"terminal.created",terminal:Oe.terminal})}if(k){ut({type:"pane.selected",terminalId:k});const Oe=wt(i).state,Pe=Oe.workspaces.find(Mt=>Mt.id===Oe.activeWorkspaceId)??Oe.workspaces[0],ht=Pe?.tabs.find(Mt=>Mt.id===Pe.activeTabId)??Pe?.tabs[0];B=Pe&&ht?Iu(i,Pe.id,ht.id):null}const he=`editor-${Date.now().toString(36)}-${kI(i)}`,xe=Y6(oe.path);uv(i,Oe=>({...Oe,[he]:{id:he,title:xe,rootToken:S.rootToken,path:oe.path,read:oe}})),B&&Re(Oe=>({...Oe,[B]:OE(he)})),ut({type:"editor.split",editorId:he,title:xe,direction:"vertical"})}function _o(S){uv(i,k=>{const B={...k};return delete B[S],B}),ut({type:"editor.closed",editorId:S})}function qi(S){Js([S])}function Js(S){const k=[...new Set(S)].filter(X=>C.terminals[X]);if(k.length===0)return;const B=k.length===1?C.terminals[k[0]]?.title||C.terminals[k[0]]?.cwd||k[0]:`${k.length} panes`;He(null),cs({terminalIds:k,label:B,workspaceId:Ie?.id??C.activeWorkspaceId??null})}function ci(S,k){const B=nr(S,k);if(!B)return!1;const X=S.filter(oe=>!B.detachedTerminalIds.includes(oe));if(B.detachedTerminalIds.length+X.length>bc)return He(W6(B.detachedTerminalIds.length)),!1;He(null);for(const oe of S)ut(B.id?{type:"terminal.detached",terminalId:oe,workspaceId:B.id}:{type:"terminal.detached",terminalId:oe});return!0}async function bo(S){await Rn(async()=>{for(const k of S)await ms(k),Ql(p.createWebSocketUrl(k)),ku(k),Zl(k),ut({type:"terminal.closed",terminalId:k})})}async function yo(S){const k=C.workspaces.find(B=>B.id===S);!k||C.workspaces.length<=1||window.confirm(`Delete workspace "${k.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Rn(async()=>{const B=Vf(k),X=[];let oe=null;for(const xe of B)try{await ms(xe)}catch(Oe){X.push(Fa(Oe)),Oe instanceof Vn&&Oe.status===401&&!p.isAgent&&(oe=Oe)}finally{Ql(p.createWebSocketUrl(xe)),ku(xe),Zl(xe)}const he=k.tabs.flatMap(xe=>tb(xe.root));if(he.length>0){const xe=new Set(he);uv(i,Oe=>{const Pe={...Oe};for(const ht of xe)delete Pe[ht];return Pe})}if(ut({type:"workspace.closed",workspaceId:S}),oe)throw oe;if(X.length>0)throw new Error(`Workspace was removed, but ${X.length} terminal session${X.length===1?"":"s"} may still be running. ${X[0]}`)})}async function Ci(S){await Rn(async()=>{await ms(S),Ql(p.createWebSocketUrl(S)),ku(S),Zl(S),ut({type:"terminal.closed",terminalId:S})})}async function Bi(S,k){const B=k.trim();if(!B)return;let X=null;for(const oe of C.workspaces){const he=oe.tabs.find(xe=>xe.id===S);if(he){X=he.activeTerminalId;break}}if(ut({type:"tab.renamed",tabId:S,title:B}),!!X)try{const oe=await p.renameTerminal(X,B);gs({type:"terminal.updated",terminal:oe.terminal})}catch(oe){$a(i,!0,Fa(oe))}}function kr(S){const k=C.terminals[S];k&&ut({type:"terminal.created",terminal:k})}async function ms(S){try{await p.closeTerminal(S)}catch(k){if(k instanceof Vn&&k.status===404)return;throw k}}async function bi(){await Rn(async()=>{await u()})}async function Rn(S){$a(i,!0,null);try{await S()}catch(k){if(er(k))return;$a(i,!0,Fa(k))}}function er(S){return S instanceof Vn&&S.status===401&&!p.isAgent&&f?(f({source:"workspace-api-401",status:401,activeAgentId:i}),!0):!1}function ut(S){Ua(i,S);const k=wt(i),B=k.state;if(vi($t.current,i,B),!k.loaded||B.workspaces.length===0)return;const X=cv(B);JSON.stringify(X)!==k.lastPersistedLayoutJson&&xo(X)}function gs(S){Ua(i,S),vi($t.current,i,wt(i).state)}function Vi(S,k,B,X){const oe=Iu(S,k,B);Re(he=>({...he,[oe]:X}))}function Tr(S){en&&Re(k=>({...k,[en]:S}))}function jn(S,k){const B=Xu(S);k?Vi(i,k.workspaceId,k.tabId,B):Tr(B),ut({type:"pane.selected",terminalId:S})}function vs(S){Tr(S.key),S.type==="terminal"&&ut({type:"pane.selected",terminalId:S.terminalId})}function tr(S){if(J||ve||oi||S.isComposing||S.key==="Process"||k6(S.target))return;const k=S6(S);if(!k)return;if(S.preventDefault(),S.stopPropagation(),k.type==="server.previous"||k.type==="server.next"){Tc(k.type==="server.next"?1:-1);return}if(k.type==="favorites.toggle"){te(!0);return}const B=wt(i).state,X=B.workspaces.find(xe=>xe.id===B.activeWorkspaceId)??B.workspaces[0],oe=X?.tabs.find(xe=>xe.id===X.activeTabId)??X?.tabs[0];if(k.type==="split"){if(!oe)return;_i(k.direction);return}if(!X||!oe)return;if(k.type==="tab.previous"||k.type==="tab.next"){const xe=C6(X.tabs,oe.id,k.type==="tab.next"?1:-1);xe&&ut({type:"tab.selected",tabId:xe.id});return}if(k.type==="tab.index"){const xe=X.tabs[k.index-1];xe&&ut({type:"tab.selected",tabId:xe.id});return}const he=w6(oe.root,oe.activeTerminalId,k);he&&jn(he,{workspaceId:X.id,tabId:oe.id})}function Yi(S,k){if(!r||Fe.length===0)return;const B=Fe.findIndex(xe=>Sn(xe,i)),oe=((B===-1?0:B)+S+Fe.length)%Fe.length,he=Fe[oe]??null;Sn(he,i)||(k&&(Ht.current={agentId:he,edge:k}),r(he))}function Tc(S){const k=wt(i).state,B=k.workspaces;if(B.length===0){Yi(S,S===1?"first":"last");return}const X=B.findIndex(xe=>xe.id===k.activeWorkspaceId),he=(X===-1?0:X)+S;if(he>=0&&he<B.length){ut({type:"workspace.selected",workspaceId:B[he].id});return}Yi(S,S===1?"first":"last")}function ca(S,k){if(Sn(S,i)){ut({type:"workspace.selected",workspaceId:k});return}On.current={agentId:S,workspaceId:k},r?.(S)}function nr(S,k){if(k)return C.workspaces.find(B=>B.id===k)??null;for(const B of S){const X=C.workspaces.find(he=>he.tabs.some(xe=>Xo(xe).includes(B)));if(X)return X;const oe=C.workspaces.find(he=>he.detachedTerminalIds.includes(B));if(oe)return oe}return C.workspaces.find(B=>B.id===C.activeWorkspaceId)??C.workspaces[0]??null}function ir(S){ic(S.dataTransfer)&&(S.preventDefault(),S.dataTransfer.dropEffect="copy")}function ua(S){if(!ic(S.dataTransfer))return;S.preventDefault();const k=q6(wt(i).state),B=ln.current+1;if(ln.current=B,!k){So({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}So({id:B,status:"queued",fileCount:0,terminalId:k.id,message:"Preparing upload..."}),ul(B,k.id,S.dataTransfer)}async function ul(S,k,B){try{const X=await jT(B);if(X.length===0)throw new Error("No files were found in the drop.");ji(S,{id:S,status:"queued",fileCount:X.length,message:"Queued"},{terminalId:k,files:X})}catch(X){ji(S,{id:S,status:"failed",fileCount:0,message:Fa(X)},{terminalId:k})}finally{Er()}}async function Ec(S){const k=gi.current.find(he=>he.id===S);if(!k?.terminalId||!k.files||k.files.length===0)return;const B=k.terminalId,X=k.files,oe=new AbortController;os.current=S,ji(S,{id:S,status:"uploading",fileCount:X.length,loaded:0,total:null,percent:null},{terminalId:B,files:X,abortController:oe});try{const he=await Xx({terminalId:B,files:X,signal:oe.signal,onProgress:ht=>{ji(S,{id:S,status:"uploading",fileCount:X.length,loaded:ht.loaded,total:ht.total,percent:ht.percent},{terminalId:B,files:X,abortController:oe})}}),xe=he.failed>0?he.uploaded>0?"partial":"failed":"success",Oe=he.failed>0?V6(he):void 0,Pe={id:S,status:xe,fileCount:X.length,response:he};Oe&&(Pe.message=Oe),ji(S,Pe,{terminalId:B,files:X})}catch(he){ji(S,{id:S,status:"failed",fileCount:X.length,message:oe.signal.aborted?"Upload canceled.":Fa(he)},{terminalId:B,files:X})}finally{os.current===S&&(os.current=null),Er()}}function Er(){if(os.current!==null)return;const S=gi.current.find(k=>k.status==="queued");S?.terminalId&&S.files&&S.files.length>0&&Ec(S.id)}function So(S){da(k=>[...k,S])}function ji(S,k,B={}){da(X=>X.map(oe=>{if(oe.id!==S)return oe;const he={...k},xe=B.terminalId??oe.terminalId,Oe=B.files??oe.files;return xe!==void 0&&(he.terminalId=xe),Oe!==void 0&&(he.files=Oe),B.abortController!==void 0&&(he.abortController=B.abortController),he}))}function da(S){const k=S(gi.current);gi.current=k,Ki(k)}function dl(S){gi.current.find(B=>B.id===S)?.abortController?.abort(),os.current===S&&(os.current=null),da(B=>B.filter(X=>X.id!==S)),Er()}function wo(){for(const S of gi.current)S.abortController?.abort();os.current=null,da(()=>[])}function Dc(S){const k=gi.current.find(B=>B.id===S);if(k){if(k.status==="queued"){dl(S);return}k.abortController?.abort()}}function Rc(S){const k=gi.current.find(X=>X.id===S);if(!k?.terminalId||!k.files||k.files.length===0)return;const B=Dr(k);if(B.length===0){ji(S,{id:S,status:"failed",fileCount:k.fileCount,message:"No failed files are available to retry."},{terminalId:k.terminalId,files:k.files});return}ji(S,{id:S,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:k.terminalId,files:B}),Er()}function Dr(S){const k=S.files??[],B="response"in S?S.response:void 0;if(!B)return k;const X=B.results.filter(xe=>xe.status==="failed").map(xe=>xe.relativePath);if(X.length===0)return[];const oe=new Map;for(const xe of k){const Oe=oe.get(xe.relativePath)??[];Oe.push(xe),oe.set(xe.relativePath,Oe)}const he=[];for(const xe of X){const Pe=oe.get(xe)?.shift();Pe&&he.push(Pe)}return he}function sr(S){const B=wt(S.agentId).state.workspaces.find(X=>X.tabs.some(oe=>oe.id===S.tabId));B&&Vi(S.agentId,B.id,S.tabId,Xu(S.terminalId)),Ua(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),jx(S.agentId,S.terminalId),Sn(S.agentId,i)||r?.(S.agentId),ls(null)}function ha(S){if(it.current=S,!Sn(S.agentId,i)){r?r(S.agentId):it.current=null;return}In()}function In(){const S=it.current;if(!S||!Sn(S.agentId,i)||!x.loaded)return;const k=wt(S.agentId),B=H6(k.state,S.terminalId);it.current=null,B&&(Vi(S.agentId,B.workspaceId,B.tabId,Xu(S.terminalId)),Ua(S.agentId,{type:"pane.selected",terminalId:S.terminalId}),jx(S.agentId,S.terminalId))}function xo(S){const k=wt(i).mutable.saveCoord;k.pendingLayoutSave=S,Du(S,_),k.saveTimer!==null&&window.clearTimeout(k.saveTimer),k.saveTimer=window.setTimeout(()=>{k.saveTimer=null;const B=k.pendingLayoutSave;k.pendingLayoutSave=null,B&&fa(B)},g6)}function rr(){const S=wt(i).mutable.saveCoord;S.saveTimer!==null&&(window.clearTimeout(S.saveTimer),S.saveTimer=null);const k=S.pendingLayoutSave;S.pendingLayoutSave=null,k&&(Du(k,_),fa(k))}function fa(S,k={}){const B=wt(i).mutable.saveCoord;B.nextPersistLayout=S,k.baseRevision!==void 0&&(B.queuedBaseRevision=k.baseRevision),!B.nextPersistQueued&&(B.nextPersistQueued=!0,B.persistChain=B.persistChain.then(async()=>{B.nextPersistQueued=!1;const X=B.nextPersistLayout,oe=B.queuedBaseRevision;B.nextPersistLayout=null,B.queuedBaseRevision=void 0,X&&await hl(X,oe!==void 0?{baseRevision:oe}:{})}))}async function hl(S,k={}){const B=wt(i),X=k.baseRevision??B.layoutRevision,oe={layout:S,...typeof X=="number"?{baseRevision:X}:{}};try{const he=await p.saveTerminalLayout(oe),xe=he.layout??S;Eu(i,he.revision,JSON.stringify(xe)),Du(xe,_);return}catch(he){if(he instanceof Vn&&he.status===400&&he.message===VR){K6(i,_),$a(i,!0,BE());return}if(he instanceof Vn&&he.status===409)try{const xe=await p.getTerminalLayout(),Oe=wt(i).mutable.saveCoord;if(Oe.nextPersistLayout||Oe.pendingLayoutSave){const Pe=xe.layout?JSON.stringify(xe.layout):wt(i).lastPersistedLayoutJson;Eu(i,xe.revision,Pe);return}if(xe.layout){const Pe=wt(i).state,ht=pf(Object.values(Pe.terminals),void 0,xe.layout.workspaces,xe.layout.activeWorkspaceId),Mt=cv(ht);Ix(i,ht),Eu(i,xe.revision,JSON.stringify(Mt)),Du(Mt,_)}else Eu(i,xe.revision,B.lastPersistedLayoutJson);return}catch{}Du(S,_)}}const fl=Z6(o),Jn=!H||U,Nn=Jn?ee:"servers";function Nc(S){const k=S.active?x:wt(S.agentId),B=S.active?C:k.state,X=S.active?x.loaded:k.loaded,oe=S.active?M:k.error;return d.jsxs("div",{className:`workspace-list-panel${S.active?" workspace-list-panel--active-server":""}`,"aria-label":`${S.label} workspaces`,children:[d.jsxs("div",{className:"workspace-list-header",children:[d.jsx("span",{children:"Workspaces"}),d.jsx("button",{type:"button","aria-label":`New workspace on ${S.label}`,title:"New workspace",onClick:()=>aa(S.agentId),children:"+"})]}),X?oe?d.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(S.agentId),children:oe}):d.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(he=>{const xe=S.active&&he.id===Ie?.id,Oe=Vf(he).length,Pe=vI(S.agentId,he.id),ht=N6(Pe),Mt=S.active&&B.workspaces.length>1,yi=at?.workspaceId===he.id&&_t!==he.id?at.placement:null;return d.jsxs(A6,{workspaceId:he.id,active:xe,disabled:!S.active,reorderable:Mt,dragging:_t===he.id,dropPlacement:yi,working:Pe.workingTerminalCount>0,unread:Pe.unreadCompletionCount>0,children:[Mt?d.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":he.id,title:"Drag to reorder","aria-label":`Reorder ${he.title}`,"aria-grabbed":_t===he.id,onPointerDown:pn=>Cr(he.id,pn),onPointerMove:go,onPointerUp:hs,onPointerCancel:vo,onKeyDown:pn=>{(pn.key==="ArrowUp"||pn.key==="ArrowDown")&&(pn.preventDefault(),pn.stopPropagation(),li(he.id,pn.key==="ArrowUp"?-1:1))},onClick:pn=>pn.stopPropagation(),children:"::"}):null,d.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":xe?"page":void 0,title:he.defaultCwd??void 0,onClick:()=>ca(S.agentId,he.id),onDoubleClick:()=>{S.active&&cl(he.id)},children:[d.jsxs("span",{className:"workspace-list-title-row",children:[d.jsx("span",{className:"workspace-list-name",children:he.title}),Pe.workingTerminalCount>0||Pe.unreadCompletionCount>0?d.jsxs("span",{className:"workspace-list-attention",title:ht,"aria-label":ht,children:[Pe.workingTerminalCount>0?d.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,Pe.unreadCompletionCount>0?d.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:R6(Pe.unreadCompletionCount)}):null]}):null]}),d.jsxs("small",{children:[he.defaultCwd??"No folder"," · ",Oe," ",Oe===1?"session":"sessions"]})]}),S.active?d.jsxs("div",{className:"workspace-list-actions",children:[d.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${he.title}`,title:"Edit workspace",onClick:()=>cl(he.id),children:"..."}),d.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${he.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{yo(he.id)},children:"x"})]}):null]},he.id)})}):d.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(S.agentId),children:"Open server to load workspaces"})]})}function pl(S,k){ce({...S,provider:k})}async function ml(S){if(A(S),!wt(S.agentId).loaded)try{const k=pr(S.agentId),[B,X]=await Promise.all([k.listTerminals(),k.getTerminalLayout()]),oe=X.layout?nb(X.layout):null,he=pf(B.terminals,void 0,oe?.savedWorkspaces,oe?.savedActiveWorkspaceId),xe=he.workspaces.flatMap(Oe=>Oe.tabs.flatMap(Pe=>xn(Pe.root).flatMap(ht=>{const Mt=he.terminals[ht];return Mt?[{terminalId:ht,cwd:Mt.cwd,label:`${Oe.title} / ${Pe.title} / ${Mt.title}`}]:[]})));A(Oe=>Oe===S?{...Oe,targets:xe}:Oe)}catch{A(k=>k===S?{...k,targetError:"Could not retrieve open tabs."}:k)}}function gl(S,k){if(Sn(S,i)){ut({type:"terminal.created",terminal:k});return}Ua(S,{type:"terminal.created",terminal:k}),r?.(S)}async function Mc(S,k){const B=pr(S);try{await B.closeTerminal(k)}catch(X){if(!(X instanceof Vn)||X.status!==404)throw X}if(Ql(B.createWebSocketUrl(k)),ku(k),Zl(k),Sn(S,i)){ut({type:"terminal.closed",terminalId:k});return}Ua(S,{type:"terminal.closed",terminalId:k})}return d.jsx(wC,{sensors:hn,onDragStart:Tn,onDragEnd:_e,onDragCancel:ze,children:d.jsxs("main",{className:"terminal-shell","data-collapsed":H,"data-sidebar-open":U,onDragOver:ir,onDrop:ua,children:[d.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>P(!1)}),d.jsxs("aside",{className:"workspace-sidebar",children:[d.jsxs("header",{className:"workspace-brand",children:[d.jsxs("div",{className:"workspace-brand-lockup",children:[Jn?d.jsx(eC,{height:20}):d.jsx(Jx,{size:24}),c&&Jn?d.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),d.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":H?"Expand sidebar":"Collapse sidebar",title:H?"Expand sidebar":"Collapse sidebar",onClick:()=>K(S=>!S),children:H?">":"<"}),d.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>P(!1),children:"x"})]}),d.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Nn==="files"?"files":"servers"}`,children:[Jn?d.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":ee==="servers",onClick:()=>{j("servers")},children:"Workspaces"}),d.jsx("button",{type:"button",role:"tab","aria-selected":ee==="files",onClick:()=>{j("files")},children:"Files"})]}):null,Nn==="servers"&&Jn?d.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:d.jsx(Gw,{api:g,activeAgentId:i,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:D,onServerLabelsChange:ra,onManageAccounts:pl,onServerInfo:S=>{ml(S)},renderServerChildren:Nc})}):null,Jn?null:d.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:d.jsx(Gw,{api:g,activeAgentId:i,onSelectServer:r??(()=>{}),onSessionInvalid:f,refreshToken:D,onServerLabelsChange:ra,compact:!0})}),Nn==="files"?d.jsx(xA,{api:p,activeTerminalId:Je,activeTerminalCwd:It?.cwd??null,workspaceRootPath:Je?null:Ie?.defaultCwd??null,onOpenFile:la},`${i??"local"}:${Ie?.id??"no-workspace"}`):null]}),d.jsxs("div",{className:"workspace-sidebar-footer",children:[Jn?d.jsx("span",{children:fl}):null,d.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[d.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>fe(!0),children:[d.jsx(Wx,{name:"settings"}),Z.hasUpdates?d.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Jn?d.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{bi()},children:d.jsx(Wx,{name:"logout"})}):null]})]})]}),J?d.jsx(vA,{api:g,onClose:()=>fe(!1),updateAvailable:Z.hasUpdates,onNotificationAssetsChanged:()=>{wr()},onAgentRemoved:po}):null,z?d.jsx(EM,{provider:z.provider,serverLabel:z.label,api:de,onClose:()=>ce(null),onLoginStarted:S=>gl(z.agentId,S),onLoginFinished:S=>Mc(z.agentId,S)}):null,ve&&d.jsx(OM,{api:V,label:ve.label,main:ve.agentId===null,getRuntimeStatus:Ps,favorites:Y.filter(S=>S.serverId===(ve.agentId??Vt)),targetStatus:ve.targetError??(!wt(ve.agentId).loaded&&!ve.targets?"Loading open tabs...":null),targets:ve.targets??wt(ve.agentId).state.workspaces.flatMap(S=>S.tabs.flatMap(k=>xn(k.root).flatMap(B=>{const X=wt(ve.agentId).state.terminals[B];return X?[{terminalId:B,cwd:X.cwd,label:`${S.title} / ${k.title} / ${X.title}`}]:[]}))),onClose:()=>A(null),onFavorite:S=>{A(null),oa(S)},onTarget:S=>{ha({kind:"terminal",agentId:ve.agentId,terminalId:S.terminalId}),A(null)}},ve.agentId??Vt),Te?d.jsx(T6,{dialog:Te,activePaneCwd:It?.cwd??null,activeWorkspaceCwd:Ie?.defaultCwd??null,onChange:mo,onManualCwdChange:Wi,onBrowse:Gs,onCancel:js,onSubmit:()=>{Is()}}):null,d.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":vn?"true":void 0,children:[d.jsx(NI,{tabs:Ie?.tabs??[],activeTabId:Ie?.activeTabId??null,terminals:C.terminals,unreadCompletionTabIds:sn,favoriteTabIds:new Set(Y.filter(S=>S.serverId===(i??Vt)).map(S=>S.tabId)),detachedTerminals:_n,onSelectTab:S=>ut({type:"tab.selected",tabId:S}),onCreateTab:()=>{Zs()},onToggleWorkspaces:()=>P(S=>!S),onCloseTerminals:S=>Js(S),onReattachTerminal:S=>kr(S),onDeleteTerminal:S=>{Ci(S)},onSplitVertical:()=>{_i("vertical")},onSplitHorizontal:()=>{_i("horizontal")},onRenameTab:(S,k)=>{Bi(S,k)},onToggleFavorite:kc,onOpenFavorites:()=>te(!0),activePaneAvailable:!!Je}),ie?d.jsx(XI,{favorites:Y,unavailableFavoriteIds:new Set(Y.filter(S=>S.serverId!==Vt&&!Fe.some(k=>Sn(k,S.serverId))).map(Ns)),busy:q,error:O,getRuntimeStatus:Ps,onClose:()=>{te(!1),R(null)},onOpen:oa,onRemove:S=>{ps(k=>k.filter(B=>Ns(B)!==Ns(S)))},onReorder:(S,k)=>{const B=Ns(S),X=Ns(k);ps(oe=>{const he=oe.findIndex(Mt=>Ns(Mt)===B),xe=oe.findIndex(Mt=>Ns(Mt)===X);if(he<0||xe<0||he===xe)return oe;const Oe=oe.slice(),[Pe]=Oe.splice(he,1),ht=Oe.findIndex(Mt=>Ns(Mt)===X);return Pe&&ht>=0&&Oe.splice(ht,0,Pe),Oe})}}):null,vn?d.jsx(O6,{targets:Gn,activeLeafKey:Bn,terminals:C.terminals,editors:N,onSelect:vs}):null,M?d.jsxs("div",{className:"workspace-error",role:"alert",children:[d.jsx("span",{children:M}),d.jsxs("div",{className:"workspace-error-actions",children:[d.jsx("button",{type:"button",onClick:Qn,children:"Retry"}),i!==null&&r?d.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,d.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?d.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!We?d.jsx(M6,{onCreate:()=>{Zs()}}):null,pe.map(S=>{const k=Sn(S,i);return d.jsx(y6,{agentId:S,serverName:Ve[_f(S)]??(S===null?"Local":"Server"),active:k,activeServerApi:k?p:void 0,visitedTabKeys:ne,refreshCwdOnEnter:k,draggingTab:k?Dt:null,mobileSplitFocus:Ft,mobileFocusedLeafByTabKey:Ee,onSelect:B=>{k&&jn(B)},onClose:B=>{k&&qi(B)},onCloseEditor:B=>{k&&_o(B)},onResize:(B,X)=>{k&&ut({type:"pane.resized",path:B,ratio:X})},onExit:(B,X)=>{k?gs({type:"terminal.exited",terminalId:B,exitCode:X}):Ua(S,{type:"terminal.exited",terminalId:B,exitCode:X})},onSnapshot:(B,X)=>{const oe={type:"terminal.updated",terminal:B,notifyCompletion:X?.notifyCompletion===!0};k?gs(oe):Ua(S,oe)},...f?{onAuthClose:B=>f({...B,source:B?.source??"terminal-ws-1008",activeAgentId:S})}:{}},vf(S))})]}),oi?d.jsx(L6,{label:oi.label,count:oi.terminalIds.length,warning:Me,onCancel:()=>{He(null),cs(null)},onHide:()=>{ci(oi.terminalIds,oi.workspaceId)&&cs(null)},onDelete:()=>{const S=oi.terminalIds;He(null),cs(null),bo(S)}}):null,d.jsx(o6,{toast:sa,onActivate:sr,onDismiss:()=>ls(null)}),d.jsx(e6,{uploads:Zn,onDismiss:dl,onDismissAll:wo,onRetry:Rc,onCancel:Dc})]})]})})}function y6({agentId:e,serverName:t,active:i,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:f,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:_,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,onAuthClose:N}){const L=v.useMemo(()=>ie=>CE(e,ie),[e]),M=v.useMemo(()=>()=>wt(e),[e]),U=v.useSyncExternalStore(L,M,M),P=v.useMemo(()=>pr(e),[e]),H=r??P,K=U.state,ee=K.workspaces.find(ie=>ie.id===K.activeWorkspaceId)??K.workspaces[0],j=ee?.id??null,fe=(ee?.tabs.find(ie=>ie.id===ee.activeTabId)??ee?.tabs[0])?.id??null;return!U.loaded||K.workspaces.length===0?null:d.jsx("div",{className:"workspace-server-surface","data-active":i,"aria-hidden":!i,children:K.workspaces.flatMap(ie=>ie.tabs.map(te=>{const Y=i&&ie.id===j&&te.id===fe,Q=Iu(e,ie.id,te.id),q=Yf(te.root),ae=f&&q.length>1?LE(q,te.activeTerminalId,g[Q]):null;return!Y&&!o.has(Q)?null:d.jsx("div",{className:"workspace-tab-surface","data-active":Y,"aria-hidden":!Y,children:d.jsx(H_,{node:te.root,terminals:K.terminals,editors:U.editors,api:H,activeTerminalId:te.activeTerminalId,visible:Y,refreshCwdOnEnter:Y&&c,tabId:te.id,codeServerContext:{serverKey:_f(e),serverName:t,tabName:te.title||K.terminals[te.activeTerminalId]?.title||"Terminal"},dropZoneActive:Y&&u!==null,draggingTerminalId:Y?u?.terminalId??null:null,mobileFocusLeafKey:ae,onSelect:p,onClose:_,onCloseEditor:b,onResize:w,onExit:x,onSnapshot:C,...N?{onAuthClose:N}:{}})},te.id)}))})}function S6(e){const t=vk(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 i=x6(e.key);return i?{type:"pane.direction",direction:i}:null}return null}function w6(e,t,i){switch(i.type){case"pane.direction":return u6(e,t,i.direction);case"pane.index":return d6(e,i.index);default:return null}}function x6(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function C6(e,t,i){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+i+e.length)%e.length]??null}function Yf(e){return e.type==="pane"?[{key:Xu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:OE(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Yf(e.first),...Yf(e.second)]}function tb(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...tb(e.first),...tb(e.second)]}function LE(e,t,i){if(i&&e.some(o=>o.key===i))return i;const r=t?Xu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function Xu(e){return`terminal:${e}`}function OE(e){return`editor:${e}`}function k6(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 T6({dialog:e,activePaneCwd:t,activeWorkspaceCwd:i,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(x=>x.kind==="directory"),_=e.submitStatus==="submitting";function b(x){r(C=>C&&{...C,...x})}function w(x){x&&(b({cwd:x,error:null}),c(x))}return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:d.jsxs("form",{className:"security-panel workspace-dialog",onClick:x=>x.stopPropagation(),onSubmit:x=>{x.preventDefault(),_||f()},children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),d.jsxs("section",{className:"workspace-dialog-body",children:[d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{value:e.title,autoFocus:!0,disabled:_,onChange:x=>b({title:x.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),d.jsxs("label",{className:"workspace-dialog-field",children:[d.jsx("span",{children:"Default cwd"}),d.jsxs("div",{className:"workspace-dialog-path-row",children:[d.jsx("input",{value:e.cwd,disabled:_,onChange:x=>o(x.currentTarget.value),placeholder:"/home/user/project"}),d.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:_||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),d.jsxs("div",{className:"workspace-dialog-quick-actions",children:[d.jsx("button",{type:"button",onClick:()=>w(t),disabled:_||!t,children:"Use active pane"}),d.jsx("button",{type:"button",onClick:()=>w(i),disabled:_||!i,children:"Use current workspace"})]}),d.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[d.jsxs("div",{className:"workspace-dialog-browser-header",children:[d.jsx("span",{title:g,children:g||"No folder selected"}),d.jsx("button",{type:"button",onClick:()=>{c(D6(g))},disabled:_||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?d.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?d.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?d.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(x=>d.jsxs("button",{type:"button","aria-label":`Choose folder ${x.name}`,disabled:_,onClick:()=>{c(E6(g,x.path))},children:[d.jsx("span",{children:x.name}),d.jsx("small",{children:x.path})]},x.path))}):null]}),e.error?d.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),d.jsxs("div",{className:"workspace-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),d.jsx("button",{type:"submit",className:"primary-button",disabled:_||e.browseStatus==="loading",children:_?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function E6(e,t){return t?t.startsWith("/")?gf(t):gf(`${e||"/"}/${t}`):gf(e)}function D6(e){const t=gf(e);if(!t||t==="/")return"/";const i=t.lastIndexOf("/");return i<=0?"/":t.slice(0,i)}function gf(e){const t=e.trim();if(!t)return"";const i=t.replace(/\/+/g,"/");return i==="/"?"/":i.endsWith("/")?i.slice(0,-1):i}function R6(e){return e>99?"99+":String(e)}function N6(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 M6({onCreate:e}){return d.jsxs("div",{className:"empty-workspace",children:[d.jsx("span",{children:"No terminal is open."}),d.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function A6({workspaceId:e,active:t,disabled:i=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,working:u=!1,unread:f=!1,children:g}){const{setNodeRef:p,isOver:_}=ip({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:i}),b=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",u?"workspace-list-item--working":"",f?"workspace-list-item--unread":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return d.jsx("div",{ref:p,className:b,"data-workspace-id":e,"data-drop-over":_?"true":void 0,children:g})}function L6({label:e,count:t,warning:i,onCancel:r,onHide:o,onDelete:c}){return d.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:d.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[d.jsxs("header",{className:"security-panel-header",children:[d.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),d.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),d.jsxs("section",{className:"terminal-delete-dialog-body",children:[d.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),d.jsx("span",{children:e}),d.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),i?d.jsx("div",{className:"terminal-delete-warning",role:"alert",children:i}):null]}),d.jsxs("div",{className:"terminal-delete-dialog-actions",children:[d.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),d.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function O6({targets:e,activeLeafKey:t,terminals:i,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],_=Fx(p,i,r);function b(w){const x=(g+w+e.length)%e.length,C=e[x];C&&o(C)}return d.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[d.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),d.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:_,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",_]}),d.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?d.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:d.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[d.jsxs("header",{children:[d.jsx("strong",{children:"Panes"}),d.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),d.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,x)=>{const C=Fx(w,i,r),N=B6(w,i,r),L=w.key===p.key;return d.jsxs("button",{type:"button","data-active":L,onClick:()=>{o(w),u(!1)},children:[d.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),d.jsxs("span",{className:"mobile-pane-sheet-copy",children:[d.jsx("strong",{children:C}),d.jsx("small",{children:N})]}),d.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function Fx(e,t,i){if(e.type==="editor")return i[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function B6(e,t,i){if(e.type==="editor"){const c=i[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 j6(e){const[t,i]=v.useState(()=>I6(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){i(!1);return}const r=window.matchMedia(e),o=()=>i(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 I6(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function P6(){if(typeof window>"u")return null;const e=sN(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 z6(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:sp(t.focus)}function H6(e,t){for(const i of e.workspaces)for(const r of i.tabs)if(xn(r.root).includes(t))return{workspaceId:i.id,tabId:r.id};return null}function Sn(e,t){return e===t}function Ns(e){return JSON.stringify([e.serverId,e.workspaceId,e.tabId])}function Kx(e,t){return e.length!==t.length?!1:e.every((i,r)=>{const o=t[r];return o!==void 0&&Ns(i)===Ns(o)&&i.serverName===o.serverName&&i.workspaceName===o.workspaceName&&i.tabName===o.tabName&&i.cwd===o.cwd&&i.paneCount===o.paneCount&&i.providers.length===o.providers.length&&i.providers.every((c,u)=>c===o.providers[u])})}function U6(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 vf(e){return e??"__local__"}function Iu(e,t,i){return`${vf(e)}:${t}:${i}`}class Xf extends Error{constructor(){super(BE())}}function $6(e){return e?{workspaceKey:`${Ux}:${e}`}:{workspaceKey:Ux}}function F6(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const i=JSON.parse(t);if(kC(i))throw new Xf;const r=CC(i);return r?nb(r):null}catch(i){if(i instanceof Xf)throw i;return null}}function nb(e){if(kC(e))throw new Xf;const t=CC(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Du(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function K6(e,t){const i=wt(e).lastPersistedLayoutJson;if(i){localStorage.setItem(t.workspaceKey,i);return}localStorage.removeItem(t.workspaceKey)}function W6(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${bc}. Re-open or delete hidden sessions before hiding more.`}function BE(){return`A saved terminal layout has more than ${bc} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function q6(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],i=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=i?e.terminals[i.activeTerminalId]:void 0;return r?.status==="running"?r:null}function V6(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function Y6(e){return e.split("/").filter(Boolean).pop()??e}function X6(){try{return localStorage.getItem(AE)==="true"}catch{return!1}}function G6(e){try{localStorage.setItem(AE,e?"true":"false")}catch{}}function _f(e){return e??Vt}function hv(e,t){const i=Object.keys(e),r=Object.keys(t);return i.length===r.length&&i.every(o=>e[o]===t[o])}function Z6(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const i=t-Date.now();if(i<=0)return"session · expired";const r=Math.max(1,Math.floor(i/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function Wx({name:e}){return d.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M4 7h9"}),d.jsx("path",{d:"M17 7h3"}),d.jsx("circle",{cx:"15",cy:"7",r:"2"}),d.jsx("path",{d:"M4 12h3"}),d.jsx("path",{d:"M11 12h9"}),d.jsx("circle",{cx:"9",cy:"12",r:"2"}),d.jsx("path",{d:"M4 17h9"}),d.jsx("path",{d:"M17 17h3"}),d.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?d.jsxs(d.Fragment,{children:[d.jsx("path",{d:"M10 6H6v12h4"}),d.jsx("path",{d:"M13 8l4 4-4 4"}),d.jsx("path",{d:"M8 12h9"})]}):null]})}function Fa(e){return e instanceof Error?e.message:"Request failed"}function Q6({api:e,onDone:t}){const[i,r]=v.useState(null),[o,c]=v.useState(null),[u,f]=v.useState(""),[g,p]=v.useState(!1),[_,b]=v.useState(null),[w,x]=v.useState(null);v.useEffect(()=>{let N=!1;return e.setupTotp().then(L=>{N||(r(L.qrDataUrl),c(L.secret))}).catch(L=>{N||x(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{N=!0}},[e]);async function C(N){if(N.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(L){b(L instanceof Error?L.message:"Verification failed")}finally{p(!1)}}}return w?d.jsx("p",{className:"form-error",children:w}):!i||!o?d.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):d.jsxs("div",{className:"totp-setup",children:[d.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),d.jsx("div",{className:"totp-qr-container",children:d.jsx("img",{src:i,alt:"TOTP QR code",width:192,height:192})}),d.jsxs("details",{className:"totp-secret-details",children:[d.jsx("summary",{children:"Can't scan? Enter manually"}),d.jsx("p",{className:"totp-secret-text",children:o})]}),d.jsxs("form",{className:"auth-form",onSubmit:C,children:[d.jsxs("label",{children:["Verification code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:N=>f(N.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),_?d.jsx("p",{className:"form-error",children:_}):null,d.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function J6(e){return{source:fv(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:fv(e.terminalId)}:{},...e?.detail?{detail:fv(e.detail)}:{}}}function eP(e){return{invalidationSource:e.source}}function tP(e){xi("auth.session_invalid.request",jE(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),yb("session-invalid-request").catch(()=>{}))}function nP(e,t){xi("auth.session_invalid.result",{...jE(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),yb("session-invalid-result").catch(()=>{}))}function jE(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 fv(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function iP({api:e,serverApi:t,activeAgentId:i=null,onSelectServer:r}){const o=v.useMemo(()=>e??Gf(),[e]),c=v.useMemo(()=>t??pr(null),[t]),[u,f]=v.useState(null),[g,p]=v.useState(null),_=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let M=!1;return o.getSession().then(U=>{M||(f(U),p(null))}).catch(U=>{M||(p(Jo(U)),f(null))}),()=>{M=!0}},[o]);const w=oP(u);v.useEffect(()=>{const M=b.current;xi("auth.view",{view:w,previousView:M,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),M==="workspace"&&w!=="workspace"&&yb(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[u,w]);async function x(){const M=await o.getSession();f(M),p(null)}async function C(){iv(),dv(),sx(),rx(),p(null),f(null);try{await x()}catch(M){p(Jo(M))}}function N(M){const U=J6(M);if(tP(U),_.current)return _.current;const P=(async()=>{p(null);try{const H=await o.getSession(eP(U));if(nP(U,H.authenticated),f(H),H.authenticated){ej();return}iv(),dv(),sx(),rx()}catch(H){p(Jo(H))}finally{_.current=null}})();return _.current=P,P}if(w==="workspace")return d.jsx(b6,{api:o,serverApi:c,activeAgentId:i,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:M=>{N(M)},onLogout:async()=>{iv(),dv();const M=await o.logout();f(M)}});const L={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return d.jsxs("main",{className:"auth-screen",children:[d.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[d.jsx("div",{className:"auth-grid"}),d.jsx("div",{className:"auth-glow"})]}),d.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[d.jsxs("header",{className:"auth-header",children:[d.jsxs("div",{className:"auth-brand",children:[d.jsx(Jx,{size:26}),d.jsxs("div",{children:[d.jsx(eC,{height:17}),d.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),d.jsx("h1",{children:L[w]})]}),g?d.jsx("p",{className:"form-error",children:g}):null,w==="loading"?d.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{C()},children:"Retry"}):null,w==="setup_password"?d.jsx(sP,{api:o,onSession:M=>{f(M)}}):null,w==="setup_totp"?d.jsx(Q6,{api:o,onDone:()=>{x()}}):null,w==="login"?d.jsx(rP,{api:o,session:u,onSession:f,onRefresh:x}):null,w==="reauth"?d.jsx(aP,{api:o,session:u,onSession:f,onFullLogin:()=>f(M=>M&&{...M,deviceTrusted:!1})}):null]})]})}function sP({api:e,onSession:t}){const[i,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(i!==o){p("Passwords do not match");return}t(await e.setupPassword({password:i}))}catch(w){p(Jo(w))}finally{f(!1)}}return d.jsxs("form",{className:"auth-form",onSubmit:_,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,value:i,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),d.jsxs("label",{children:["Confirm password",d.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?d.jsx("p",{className:"form-error",children:g}):null,d.jsx("button",{type:"submit",disabled:u||i.length<8||o.length<8,children:"Set password"})]})}function rP({api:e,session:t,onSession:i,onRefresh:r}){const[o,c]=v.useState(""),[u,f]=v.useState(""),[g,p]=v.useState(!1),[_,b]=v.useState(!1),[w,x]=v.useState(null),C=t?.totpEnabled??!1,N=t?.currentIpWhitelisted??!1;async function L(M){M.preventDefault(),b(!0),x(null);try{i(await e.login({password:o,...C?{otp:u}:{},rememberNetwork:g}))}catch(U){x(Jo(U))}finally{b(!1)}}return d.jsxs("form",{className:"auth-form",onSubmit:L,children:[d.jsxs("label",{children:["Password",d.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:M=>c(M.currentTarget.value),required:!0})]}),C?d.jsxs("label",{children:["Authenticator code",d.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:M=>f(M.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,N?null:d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:g,onChange:M=>p(M.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?d.jsx("p",{className:"form-error",children:w}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:_||o.length===0||C&&u.length!==6,children:"Unlock"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:_,children:"Refresh"})]})]})}function aP({api:e,session:t,onSession:i,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[f,g]=v.useState(!1),[p,_]=v.useState(!1),[b,w]=v.useState(!1),[x,C]=v.useState(!1),[N,L]=v.useState(null),M=Nt.useCallback(async(P,H)=>{_(!0),L(null);try{i(await e.reauth({...P?{otp:P}:{},rememberNetwork:H}))}catch(K){L(Jo(K))}finally{_(!1)}},[e,i]);v.useEffect(()=>{if(o){let P=!1;w(!0),C(!1),L(null);const H=window.setTimeout(()=>{P||C(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(K=>{P||i(K)}).catch(K=>{P||(L(Jo(K)),C(!0))}).finally(()=>{window.clearTimeout(H),P||w(!1)}),()=>{P=!0,window.clearTimeout(H)}}},[e,o,i]);async function U(P){P.preventDefault(),await M(c,f)}return o&&b&&!x&&!N?d.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):d.jsxs("form",{className:"auth-form",onSubmit:U,children:[o&&x&&!N?d.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,d.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),d.jsxs("label",{children:["Authenticator code",d.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:P=>u(P.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),d.jsxs("label",{className:"auth-checkbox",children:[d.jsx("input",{type:"checkbox",checked:f,onChange:P=>g(P.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),N?d.jsx("p",{className:"form-error",children:N}):null,d.jsxs("div",{className:"button-row",children:[d.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),d.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function oP(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Jo(e){return e instanceof Error?e.message:"Request failed"}const qx="NTerminal",ib="nterminal.activeAgentId";function lP(){const[e,t]=v.useState(()=>cP()),i=v.useMemo(()=>Gf(),[]),r=v.useMemo(()=>pr(e),[e]);v.useEffect(()=>{const c=()=>{const u=CI();document.title=u>0?`(${u}) ${qx}`:qx};return c(),xI(c)},[]);function o(c){uP(c),t(c)}return d.jsx(iP,{api:i,activeAgentId:e,serverApi:r,onSelectServer:o})}function cP(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(ib);return e&&e.trim()?e:null}catch{return null}}function uP(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(ib,e);return}window.localStorage.removeItem(ib)}catch{}}const Vx=["gesturestart","gesturechange","gestureend"],dP=[".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 hP(e=window){if(!pP(e))return()=>{};const t={passive:!1},i=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||!fP(c.target))&&r(c)}for(const c of Vx)i.addEventListener(c,r,t);return i.addEventListener("touchmove",o,t),i.addEventListener("dblclick",r,t),()=>{for(const c of Vx)i.removeEventListener(c,r,t);i.removeEventListener("touchmove",o,t),i.removeEventListener("dblclick",r,t)}}function fP(e){return e instanceof Element&&e.closest(dP)!==null}function pP(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}uN();xB();hP();lb();cD.createRoot(document.getElementById("root")).render(d.jsx(Nt.StrictMode,{children:d.jsx(lP,{})}));export{Nt as R,eD as g,d as j};
|