nterminal 1.2.81 → 1.2.83
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-D43VLS-2.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-DDFnUWuE.js → TranscriptMarkdownBody-BeM4ohbd.js} +1 -1
- package/dist/client/assets/{index-D7w92nCI.js → index-CiCZJzIi.js} +1 -1
- package/dist/client/assets/index-DMjdQxDt.js +57 -0
- package/dist/client/assets/{index-hoeidjW4.css → index-yKhwlegq.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/terminal/TerminalManager.js +7 -3
- package/dist/server/terminal/TerminalManager.js.map +1 -1
- package/dist/server/terminal/subagentSources.d.ts +6 -1
- package/dist/server/terminal/subagentSources.js +298 -27
- package/dist/server/terminal/subagentSources.js.map +1 -1
- package/dist/server/terminal/transcriptHistory.d.ts +1 -0
- package/dist/server/terminal/transcriptHistory.js +40 -24
- package/dist/server/terminal/transcriptHistory.js.map +1 -1
- package/dist/shared/protocol.d.ts +1 -0
- package/dist/shared/protocol.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-Dq1fT9EP.js +0 -1
- package/dist/client/assets/index-Di6LPXrS.js +0 -57
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-D43VLS-2.js","assets/index-CiCZJzIi.js","assets/TranscriptMarkdownBody-BeM4ohbd.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 d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function jE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fm={exports:{}},Cc={};var US;function zE(){if(US)return Cc;US=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var m in o)m!=="key"&&(c[m]=o[m])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:d,ref:o!==void 0?o:null,props:c}}return Cc.Fragment=t,Cc.jsx=n,Cc.jsxs=n,Cc}var KS;function IE(){return KS||(KS=1,fm.exports=zE()),fm.exports}var f=IE(),pm={exports:{}},rt={};var FS;function PE(){if(FS)return rt;FS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function C(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,O={};function N(M,K,ce){this.props=M,this.context=K,this.refs=O,this.updater=ce||x}N.prototype.isReactComponent={},N.prototype.setState=function(M,K){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,K,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function B(){}B.prototype=N.prototype;function V(M,K,ce){this.props=M,this.context=K,this.refs=O,this.updater=ce||x}var W=V.prototype=new B;W.constructor=V,D(W,N.prototype),W.isPureReactComponent=!0;var ie=Array.isArray;function Q(){}var $={H:null,A:null,T:null,S:null},Se=Object.prototype.hasOwnProperty;function ne(M,K,ce){var we=ce.ref;return{$$typeof:e,type:M,key:K,ref:we!==void 0?we:null,props:ce}}function Te(M,K){return ne(M.type,K,M.props)}function te(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function Y(M){var K={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ce){return K[ce]})}var G=/\/+/g;function F(M,K){return typeof M=="object"&&M!==null&&M.key!=null?Y(""+M.key):K.toString(36)}function le(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(Q,Q):(M.status="pending",M.then(function(K){M.status==="pending"&&(M.status="fulfilled",M.value=K)},function(K){M.status==="pending"&&(M.status="rejected",M.reason=K)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,K,ce,we,Le){var xe=typeof M;(xe==="undefined"||xe==="boolean")&&(M=null);var Be=!1;if(M===null)Be=!0;else switch(xe){case"bigint":case"string":case"number":Be=!0;break;case"object":switch(M.$$typeof){case e:case t:Be=!0;break;case y:return Be=M._init,L(Be(M._payload),K,ce,we,Le)}}if(Be)return Le=Le(M),Be=we===""?"."+F(M,0):we,ie(Le)?(ce="",Be!=null&&(ce=Be.replace(G,"$&/")+"/"),L(Le,K,ce,"",function(ze){return ze})):Le!=null&&(te(Le)&&(Le=Te(Le,ce+(Le.key==null||M&&M.key===Le.key?"":(""+Le.key).replace(G,"$&/")+"/")+Be)),K.push(Le)),1;Be=0;var De=we===""?".":we+":";if(ie(M))for(var He=0;He<M.length;He++)we=M[He],xe=De+F(we,He),Be+=L(we,K,ce,xe,Le);else if(He=C(M),typeof He=="function")for(M=He.call(M),He=0;!(we=M.next()).done;)we=we.value,xe=De+F(we,He++),Be+=L(we,K,ce,xe,Le);else if(xe==="object"){if(typeof M.then=="function")return L(le(M),K,ce,we,Le);throw K=String(M),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return Be}function R(M,K,ce){if(M==null)return M;var we=[],Le=0;return L(M,we,"","",function(xe){return K.call(ce,xe,Le++)}),we}function j(M){if(M._status===-1){var K=M._result;K=K(),K.then(function(ce){(M._status===0||M._status===-1)&&(M._status=1,M._result=ce)},function(ce){(M._status===0||M._status===-1)&&(M._status=2,M._result=ce)}),M._status===-1&&(M._status=0,M._result=K)}if(M._status===1)return M._result.default;throw M._result}var ae=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},be={map:R,forEach:function(M,K,ce){R(M,function(){K.apply(this,arguments)},ce)},count:function(M){var K=0;return R(M,function(){K++}),K},toArray:function(M){return R(M,function(K){return K})||[]},only:function(M){if(!te(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return rt.Activity=b,rt.Children=be,rt.Component=N,rt.Fragment=n,rt.Profiler=o,rt.PureComponent=V,rt.StrictMode=r,rt.Suspense=g,rt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,rt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return $.H.useMemoCache(M)}},rt.cache=function(M){return function(){return M.apply(null,arguments)}},rt.cacheSignal=function(){return null},rt.cloneElement=function(M,K,ce){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var we=D({},M.props),Le=M.key;if(K!=null)for(xe in K.key!==void 0&&(Le=""+K.key),K)!Se.call(K,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&K.ref===void 0||(we[xe]=K[xe]);var xe=arguments.length-2;if(xe===1)we.children=ce;else if(1<xe){for(var Be=Array(xe),De=0;De<xe;De++)Be[De]=arguments[De+2];we.children=Be}return ne(M.type,Le,we)},rt.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},rt.createElement=function(M,K,ce){var we,Le={},xe=null;if(K!=null)for(we in K.key!==void 0&&(xe=""+K.key),K)Se.call(K,we)&&we!=="key"&&we!=="__self"&&we!=="__source"&&(Le[we]=K[we]);var Be=arguments.length-2;if(Be===1)Le.children=ce;else if(1<Be){for(var De=Array(Be),He=0;He<Be;He++)De[He]=arguments[He+2];Le.children=De}if(M&&M.defaultProps)for(we in Be=M.defaultProps,Be)Le[we]===void 0&&(Le[we]=Be[we]);return ne(M,xe,Le)},rt.createRef=function(){return{current:null}},rt.forwardRef=function(M){return{$$typeof:m,render:M}},rt.isValidElement=te,rt.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:j}},rt.memo=function(M,K){return{$$typeof:p,type:M,compare:K===void 0?null:K}},rt.startTransition=function(M){var K=$.T,ce={};$.T=ce;try{var we=M(),Le=$.S;Le!==null&&Le(ce,we),typeof we=="object"&&we!==null&&typeof we.then=="function"&&we.then(Q,ae)}catch(xe){ae(xe)}finally{K!==null&&ce.types!==null&&(K.types=ce.types),$.T=K}},rt.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},rt.use=function(M){return $.H.use(M)},rt.useActionState=function(M,K,ce){return $.H.useActionState(M,K,ce)},rt.useCallback=function(M,K){return $.H.useCallback(M,K)},rt.useContext=function(M){return $.H.useContext(M)},rt.useDebugValue=function(){},rt.useDeferredValue=function(M,K){return $.H.useDeferredValue(M,K)},rt.useEffect=function(M,K){return $.H.useEffect(M,K)},rt.useEffectEvent=function(M){return $.H.useEffectEvent(M)},rt.useId=function(){return $.H.useId()},rt.useImperativeHandle=function(M,K,ce){return $.H.useImperativeHandle(M,K,ce)},rt.useInsertionEffect=function(M,K){return $.H.useInsertionEffect(M,K)},rt.useLayoutEffect=function(M,K){return $.H.useLayoutEffect(M,K)},rt.useMemo=function(M,K){return $.H.useMemo(M,K)},rt.useOptimistic=function(M,K){return $.H.useOptimistic(M,K)},rt.useReducer=function(M,K,ce){return $.H.useReducer(M,K,ce)},rt.useRef=function(M){return $.H.useRef(M)},rt.useState=function(M){return $.H.useState(M)},rt.useSyncExternalStore=function(M,K,ce){return $.H.useSyncExternalStore(M,K,ce)},rt.useTransition=function(){return $.H.useTransition()},rt.version="19.2.6",rt}var WS;function Kv(){return WS||(WS=1,pm.exports=PE()),pm.exports}var v=Kv();const Ai=jE(v);var mm={exports:{}},xc={},gm={exports:{}},vm={};var $S;function HE(){return $S||($S=1,(function(e){function t(L,R){var j=L.length;L.push(R);e:for(;0<j;){var ae=j-1>>>1,be=L[ae];if(0<o(be,R))L[ae]=R,L[j]=be,j=ae;else break e}}function n(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var R=L[0],j=L.pop();if(j!==R){L[0]=j;e:for(var ae=0,be=L.length,M=be>>>1;ae<M;){var K=2*(ae+1)-1,ce=L[K],we=K+1,Le=L[we];if(0>o(ce,j))we<be&&0>o(Le,ce)?(L[ae]=Le,L[we]=j,ae=we):(L[ae]=ce,L[K]=j,ae=K);else if(we<be&&0>o(Le,j))L[ae]=Le,L[we]=j,ae=we;else break e}}return R}function o(L,R){var j=L.sortIndex-R.sortIndex;return j!==0?j:L.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 d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var g=[],p=[],y=1,b=null,w=3,C=!1,x=!1,D=!1,O=!1,N=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,V=typeof setImmediate<"u"?setImmediate:null;function W(L){for(var R=n(p);R!==null;){if(R.callback===null)r(p);else if(R.startTime<=L)r(p),R.sortIndex=R.expirationTime,t(g,R);else break;R=n(p)}}function ie(L){if(D=!1,W(L),!x)if(n(g)!==null)x=!0,Q||(Q=!0,Y());else{var R=n(p);R!==null&&le(ie,R.startTime-L)}}var Q=!1,$=-1,Se=5,ne=-1;function Te(){return O?!0:!(e.unstable_now()-ne<Se)}function te(){if(O=!1,Q){var L=e.unstable_now();ne=L;var R=!0;try{e:{x=!1,D&&(D=!1,B($),$=-1),C=!0;var j=w;try{t:{for(W(L),b=n(g);b!==null&&!(b.expirationTime>L&&Te());){var ae=b.callback;if(typeof ae=="function"){b.callback=null,w=b.priorityLevel;var be=ae(b.expirationTime<=L);if(L=e.unstable_now(),typeof be=="function"){b.callback=be,W(L),R=!0;break t}b===n(g)&&r(g),W(L)}else r(g);b=n(g)}if(b!==null)R=!0;else{var M=n(p);M!==null&&le(ie,M.startTime-L),R=!1}}break e}finally{b=null,w=j,C=!1}R=void 0}}finally{R?Y():Q=!1}}}var Y;if(typeof V=="function")Y=function(){V(te)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,F=G.port2;G.port1.onmessage=te,Y=function(){F.postMessage(null)}}else Y=function(){N(te,0)};function le(L,R){$=N(function(){L(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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Se=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(L){switch(w){case 1:case 2:case 3:var R=3;break;default:R=w}var j=w;w=R;try{return L()}finally{w=j}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function(L,R){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var j=w;w=L;try{return R()}finally{w=j}},e.unstable_scheduleCallback=function(L,R,j){var ae=e.unstable_now();switch(typeof j=="object"&&j!==null?(j=j.delay,j=typeof j=="number"&&0<j?ae+j:ae):j=ae,L){case 1:var be=-1;break;case 2:be=250;break;case 5:be=1073741823;break;case 4:be=1e4;break;default:be=5e3}return be=j+be,L={id:y++,callback:R,priorityLevel:L,startTime:j,expirationTime:be,sortIndex:-1},j>ae?(L.sortIndex=j,t(p,L),n(g)===null&&L===n(p)&&(D?(B($),$=-1):D=!0,le(ie,j-ae))):(L.sortIndex=be,t(g,L),x||C||(x=!0,Q||(Q=!0,Y()))),L},e.unstable_shouldYield=Te,e.unstable_wrapCallback=function(L){var R=w;return function(){var j=w;w=R;try{return L.apply(this,arguments)}finally{w=j}}}})(vm)),vm}var qS;function UE(){return qS||(qS=1,gm.exports=HE()),gm.exports}var _m={exports:{}},fn={};var VS;function KE(){if(VS)return fn;VS=1;var e=Kv();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,p,y){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:y}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return fn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,fn.createPortal=function(g,p){var y=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,y)},fn.flushSync=function(g){var p=d.T,y=r.p;try{if(d.T=null,r.p=2,g)return g()}finally{d.T=p,r.p=y,r.d.f()}},fn.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))},fn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},fn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,C=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:C}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:C,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},fn.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=m(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,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)},fn.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin);r.d.L(g,y,{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})}},fn.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=m(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},fn.requestFormReset=function(g){r.d.r(g)},fn.unstable_batchedUpdates=function(g,p){return g(p)},fn.useFormState=function(g,p,y){return d.H.useFormState(g,p,y)},fn.useFormStatus=function(){return d.H.useHostTransitionStatus()},fn.version="19.2.6",fn}var YS;function u1(){if(YS)return _m.exports;YS=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(),_m.exports=KE(),_m.exports}var XS;function FE(){if(XS)return xc;XS=1;var e=UE(),t=Kv(),n=u1();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function d(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,l=s;;){var u=a.return;if(u===null)break;var h=u.alternate;if(h===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===a)return g(u),i;if(h===l)return g(u),s;h=h.sibling}throw Error(r(188))}if(a.return!==l.return)a=u,l=h;else{for(var _=!1,E=u.child;E;){if(E===a){_=!0,a=u,l=h;break}if(E===l){_=!0,l=u,a=h;break}E=E.sibling}if(!_){for(E=h.child;E;){if(E===a){_=!0,a=h,l=u;break}if(E===l){_=!0,l=h,a=u;break}E=E.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),V=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),ie=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),Se=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),Te=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function Y(i){return i===null||typeof i!="object"?null:(i=te&&i[te]||i["@@iterator"],typeof i=="function"?i:null)}var G=Symbol.for("react.client.reference");function F(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===G?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case N:return"Profiler";case O:return"StrictMode";case ie:return"Suspense";case Q:return"SuspenseList";case ne:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case V:return i.displayName||"Context";case B:return(i._context.displayName||"Context")+".Consumer";case W:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return s=i.displayName||null,s!==null?s:F(i.type)||"Memo";case Se:s=i._payload,i=i._init;try{return F(i(s))}catch{}}return null}var le=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j={pending:!1,data:null,method:null,action:null},ae=[],be=-1;function M(i){return{current:i}}function K(i){0>be||(i.current=ae[be],ae[be]=null,be--)}function ce(i,s){be++,ae[be]=i.current,i.current=s}var we=M(null),Le=M(null),xe=M(null),Be=M(null);function De(i,s){switch(ce(xe,s),ce(Le,i),ce(we,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?uS(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=uS(s),i=dS(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}K(we),ce(we,i)}function He(){K(we),K(Le),K(xe)}function ze(i){i.memoizedState!==null&&ce(Be,i);var s=we.current,a=dS(s,i.type);s!==a&&(ce(Le,i),ce(we,a))}function re(i){Le.current===i&&(K(we),K(Le)),Be.current===i&&(K(Be),bc._currentValue=j)}var he,H;function ue(i){if(he===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);he=s&&s[1]||"",H=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+he+i+H}var Re=!1;function Ne(i,s){if(!i||Re)return"";Re=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var ge=function(){throw Error()};if(Object.defineProperty(ge.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ge,[])}catch(oe){var J=oe}Reflect.construct(i,[],ge)}else{try{ge.call()}catch(oe){J=oe}i.call(ge.prototype)}}else{try{throw Error()}catch(oe){J=oe}(ge=i())&&typeof ge.catch=="function"&&ge.catch(function(){})}}catch(oe){if(oe&&J&&typeof oe.stack=="string")return[oe.stack,J.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),_=h[0],E=h[1];if(_&&E){var A=_.split(`
|
|
5
|
+
`),Z=E.split(`
|
|
6
|
+
`);for(u=l=0;l<A.length&&!A[l].includes("DetermineComponentFrameRoot");)l++;for(;u<Z.length&&!Z[u].includes("DetermineComponentFrameRoot");)u++;if(l===A.length||u===Z.length)for(l=A.length-1,u=Z.length-1;1<=l&&0<=u&&A[l]!==Z[u];)u--;for(;1<=l&&0<=u;l--,u--)if(A[l]!==Z[u]){if(l!==1||u!==1)do if(l--,u--,0>u||A[l]!==Z[u]){var de=`
|
|
7
|
+
`+A[l].replace(" at new "," at ");return i.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",i.displayName)),de}while(1<=l&&0<=u);break}}}finally{Re=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?ue(a):""}function ee(i,s){switch(i.tag){case 26:case 27:case 5:return ue(i.type);case 16:return ue("Lazy");case 13:return i.child!==s&&s!==null?ue("Suspense Fallback"):ue("Suspense");case 19:return ue("SuspenseList");case 0:case 15:return Ne(i.type,!1);case 11:return Ne(i.type.render,!1);case 1:return Ne(i.type,!0);case 31:return ue("Activity");default:return""}}function Ee(i){try{var s="",a=null;do s+=ee(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var me=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,st=e.unstable_shouldYield,ot=e.unstable_requestPaint,Nt=e.unstable_now,pi=e.unstable_getCurrentPriorityLevel,Cn=e.unstable_ImmediatePriority,Rt=e.unstable_UserBlockingPriority,Qe=e.unstable_NormalPriority,gt=e.unstable_LowPriority,Bt=e.unstable_IdlePriority,ye=e.log,We=e.unstable_setDisableYieldValue,Je=null,et=null;function wt(i){if(typeof ye=="function"&&We(i),et&&typeof et.setStrictMode=="function")try{et.setStrictMode(Je,i)}catch{}}var ft=Math.clz32?Math.clz32:q,xn=Math.log,Oi=Math.LN2;function q(i){return i>>>=0,i===0?32:31-(xn(i)/Oi|0)|0}var Ke=256,Ge=262144,at=4194304;function xt(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function jt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var E=l&134217727;return E!==0?(l=E&~h,l!==0?u=xt(l):(_&=E,_!==0?u=xt(_):a||(a=E&~i,a!==0&&(u=xt(a))))):(E=l&~h,E!==0?u=xt(E):_!==0?u=xt(_):a||(a=l&~i,a!==0&&(u=xt(a)))),u===0?0:s!==0&&s!==u&&(s&h)===0&&(h=u&-u,a=s&-s,h>=a||h===32&&(a&4194048)!==0)?s:u}function qt(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function Vt(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $t(){var i=at;return at<<=1,(at&62914560)===0&&(at=4194304),i}function Ci(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function Yt(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function ii(i,s,a,l,u,h){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var E=i.entanglements,A=i.expirationTimes,Z=i.hiddenUpdates;for(a=_&~a;0<a;){var de=31-ft(a),ge=1<<de;E[de]=0,A[de]=-1;var J=Z[de];if(J!==null)for(Z[de]=null,de=0;de<J.length;de++){var oe=J[de];oe!==null&&(oe.lane&=-536870913)}a&=~ge}l!==0&&mi(i,l,0),h!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~s))}function mi(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-ft(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function xi(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-ft(a),u=1<<l;u&s|i[l]&s&&(i[l]|=s),a&=~u}}function Fi(i,s){var a=s&-s;return a=(a&42)!==0?1:gn(a),(a&(i.suspendedLanes|s))!==0?0:a}function gn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function gi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function vi(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:OS(i.type))}function en(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var Bi=Math.random().toString(36).slice(2),Qt="__reactFiber$"+Bi,ki="__reactProps$"+Bi,Xn="__reactContainer$"+Bi,Oa="__reactEvents$"+Bi,qs="__reactListeners$"+Bi,Ba="__reactHandles$"+Bi,Vs="__reactResources$"+Bi,Ys="__reactMarker$"+Bi;function xs(i){delete i[Qt],delete i[ki],delete i[Oa],delete i[qs],delete i[Ba]}function ks(i){var s=i[Qt];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Xn]||a[Qt]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=_S(i);i!==null;){if(a=i[Qt])return a;i=_S(i)}return s}i=a,a=i.parentNode}return null}function ps(i){if(i=i[Qt]||i[Xn]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function Es(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function cn(i){var s=i[Vs];return s||(s=i[Vs]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function ai(i){i[Ys]=!0}var Or=new Set,oi={};function zn(i,s){_i(i,s),_i(i+"Capture",s)}function _i(i,s){for(oi[i]=s,i=0;i<s.length;i++)Or.add(s[i])}var Xs=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]*$"),Co={},Ts={};function ja(i){return me.call(Ts,i)?!0:me.call(Co,i)?!1:Xs.test(i)?Ts[i]=!0:(Co[i]=!0,!1)}function Gs(i,s,a){if(ja(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function Ds(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function vn(i,s,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+l)}}function Ei(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Br(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Zs(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,h=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,h.call(this,_)}}),Object.defineProperty(i,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function tn(i){if(!i._valueTracker){var s=Br(i)?"checked":"value";i._valueTracker=Zs(i,s,""+i[s])}}function ms(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Br(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function jr(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var Gn=/[\n"\\]/g;function Wi(i){return i.replace(Gn,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function ct(i,s,a,l,u,h,_,E){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),s!=null?_==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Ei(s)):i.value!==""+Ei(s)&&(i.value=""+Ei(s)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),s!=null?kn(i,_,Ei(s)):a!=null?kn(i,_,Ei(a)):l!=null&&i.removeAttribute("value"),u==null&&h!=null&&(i.defaultChecked=!!h),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?i.name=""+Ei(E):i.removeAttribute("name")}function zr(i,s,a,l,u,h,_,E){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),s!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||s!=null)){tn(i);return}a=a!=null?""+Ei(a):"",s=s!=null?""+Ei(s):a,E||s===i.value||(i.value=s),i.defaultValue=s}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=E?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),tn(i)}function kn(i,s,a){s==="number"&&jr(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Zn(i,s,a,l){if(i=i.options,s){s={};for(var u=0;u<a.length;u++)s["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=s.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Ei(a),s=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}s!==null||i[u].disabled||(s=i[u])}s!==null&&(s.selected=!0)}}function Ir(i,s,a){if(s!=null&&(s=""+Ei(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Ei(a):""}function Qn(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(le(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Ei(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),tn(i)}function Rs(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var Pr=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(i,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":l?i.setProperty(s,a):typeof a!="number"||a===0||Pr.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function za(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in s)l=s[u],s.hasOwnProperty(u)&&a[u]!==l&&Qs(i,u,l)}else for(var h in s)s.hasOwnProperty(h)&&Qs(i,h,s[h])}function Hr(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rl=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"]]),Ur=/^[\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 Ia(i){return Ur.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Jt(){}var Ms=null;function Js(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Kt=null,un=null;function er(i){var s=ps(i);if(s&&(i=s.stateNode)){var a=i[ki]||null;e:switch(i=s.stateNode,s.type){case"input":if(ct(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Wi(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var u=l[ki]||null;if(!u)throw Error(r(90));ct(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&ms(l)}break e;case"textarea":Ir(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&Zn(i,!!a.multiple,s,!1)}}}var Kr=!1;function Ns(i,s,a){if(Kr)return i(s,a);Kr=!0;try{var l=i(s);return l}finally{if(Kr=!1,(Kt!==null||un!==null)&&(Td(),Kt&&(s=Kt,i=un,un=Kt=null,er(s),i)))for(s=0;s<i.length;s++)er(i[s])}}function nn(i,s){var a=i.stateNode;if(a===null)return null;var l=a[ki]||null;if(l===null)return null;a=l[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var En=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pa=!1;if(En)try{var gs={};Object.defineProperty(gs,"passive",{get:function(){Pa=!0}}),window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch{Pa=!1}var dn=null,tr=null,ir=null;function nr(){if(ir)return ir;var i,s=tr,a=s.length,l,u="value"in dn?dn.value:dn.textContent,h=u.length;for(i=0;i<a&&s[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&s[a-l]===u[h-l];l++);return ir=u.slice(i,1<l?1-l:void 0)}function As(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function vs(){return!0}function In(){return!1}function bi(i){function s(a,l,u,h,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var E in i)i.hasOwnProperty(E)&&(a=i[E],this[E]=a?a(h):h[E]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?vs:In,this.isPropagationStopped=In,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=vs)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=vs)},persist:function(){},isPersistent:vs}),s}var Tn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},k=bi(Tn),T=b({},Tn,{view:0,detail:0}),I=bi(T),se,ve,fe,ke=b({},T,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ji,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==fe&&(fe&&i.type==="mousemove"?(se=i.screenX-fe.screenX,ve=i.screenY-fe.screenY):ve=se=0,fe=i),se)},movementY:function(i){return"movementY"in i?i.movementY:ve}}),Ve=bi(ke),vt=b({},ke,{dataTransfer:0}),li=bi(vt),ni=b({},T,{relatedTarget:0}),Fr=bi(ni),xo=b({},Tn,{animationName:0,elapsedTime:0,pseudoElement:0}),Wr=bi(xo),Ml=b({},Tn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),$i=bi(Ml),ko=b({},Tn,{data:0}),Ha=bi(ko),Tu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Du={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"},Ru={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $r(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Ru[i])?!!s[i]:!1}function ji(){return $r}var vf=b({},T,{key:function(i){if(i.key){var s=Tu[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=As(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Du[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ji,charCode:function(i){return i.type==="keypress"?As(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?As(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Mu=bi(vf),Nu=b({},ke,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Nl=bi(Nu),_f=b({},T,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ji}),Au=bi(_f),sr=b({},Tn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Al=bi(sr),bf=b({},ke,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),yf=bi(bf),Sf=b({},Tn,{newState:0,oldState:0}),Ll=bi(Sf),Ol=[9,13,27,32],Ua=En&&"CompositionEvent"in window,Ls=null;En&&"documentMode"in document&&(Ls=document.documentMode);var Lu=En&&"TextEvent"in window&&!Ls,Bl=En&&(!Ua||Ls&&8<Ls&&11>=Ls),Ou=" ",jl=!1;function Bu(i,s){switch(i){case"keyup":return Ol.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ju(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var qr=!1;function zu(i,s){switch(i){case"compositionend":return ju(s);case"keypress":return s.which!==32?null:(jl=!0,Ou);case"textInput":return i=s.data,i===Ou&&jl?null:i;default:return null}}function zl(i,s){if(qr)return i==="compositionend"||!Ua&&Bu(i,s)?(i=nr(),ir=tr=dn=null,qr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Bl&&s.locale!=="ko"?null:s.data;default:return null}}var Eo={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 Il(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!Eo[i.type]:s==="textarea"}function Pl(i,s,a,l){Kt?un?un.push(l):un=[l]:Kt=l,s=Od(s,"onChange"),0<s.length&&(a=new k("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var Ka=null,Vr=null;function Iu(i){sS(i,0)}function Fa(i){var s=Es(i);if(ms(s))return i}function Pu(i,s){if(i==="change")return s}var Hl=!1;if(En){var Jn;if(En){var Ul="oninput"in document;if(!Ul){var Hu=document.createElement("div");Hu.setAttribute("oninput","return;"),Ul=typeof Hu.oninput=="function"}Jn=Ul}else Jn=!1;Hl=Jn&&(!document.documentMode||9<document.documentMode)}function Kl(){Ka&&(Ka.detachEvent("onpropertychange",Uu),Vr=Ka=null)}function Uu(i){if(i.propertyName==="value"&&Fa(Vr)){var s=[];Pl(s,Vr,i,Js(i)),Ns(Iu,s)}}function wf(i,s,a){i==="focusin"?(Kl(),Ka=s,Vr=a,Ka.attachEvent("onpropertychange",Uu)):i==="focusout"&&Kl()}function rr(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Fa(Vr)}function Cf(i,s){if(i==="click")return Fa(s)}function xf(i,s){if(i==="input"||i==="change")return Fa(s)}function kf(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var hn=typeof Object.is=="function"?Object.is:kf;function Dn(i,s){if(hn(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!me.call(s,u)||!hn(i[u],s[u]))return!1}return!0}function Ku(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Fu(i,s){var a=Ku(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ku(a)}}function Wu(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?Wu(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function To(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=jr(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=jr(i.document)}return s}function Fl(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var $u=En&&"documentMode"in document&&11>=document.documentMode,S=null,z=null,Ce=null,Fe=!1;function Ye(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Fe||S==null||S!==jr(l)||(l=S,"selectionStart"in l&&Fl(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}),Ce&&Dn(Ce,l)||(Ce=l,l=Od(z,"onSelect"),0<l.length&&(s=new k("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=S)))}function Ze(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var tt={animationend:Ze("Animation","AnimationEnd"),animationiteration:Ze("Animation","AnimationIteration"),animationstart:Ze("Animation","AnimationStart"),transitionrun:Ze("Transition","TransitionRun"),transitionstart:Ze("Transition","TransitionStart"),transitioncancel:Ze("Transition","TransitionCancel"),transitionend:Ze("Transition","TransitionEnd")},ut={},qe={};En&&(qe=document.createElement("div").style,"AnimationEvent"in window||(delete tt.animationend.animation,delete tt.animationiteration.animation,delete tt.animationstart.animation),"TransitionEvent"in window||delete tt.transitionend.transition);function kt(i){if(ut[i])return ut[i];if(!tt[i])return i;var s=tt[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in qe)return ut[i]=s[a];return i}var At=kt("animationend"),Mt=kt("animationiteration"),_s=kt("animationstart"),Do=kt("transitionrun"),Os=kt("transitionstart"),qu=kt("transitioncancel"),Wl=kt("transitionend"),I_=new Map,Ef="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(" ");Ef.push("scrollEnd");function bs(i,s){I_.set(i,s),zn(s,[i])}var Vu=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},es=[],Ro=0,Tf=0;function Yu(){for(var i=Ro,s=Tf=Ro=0;s<i;){var a=es[s];es[s++]=null;var l=es[s];es[s++]=null;var u=es[s];es[s++]=null;var h=es[s];if(es[s++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}h!==0&&P_(a,u,h)}}function Xu(i,s,a,l){es[Ro++]=i,es[Ro++]=s,es[Ro++]=a,es[Ro++]=l,Tf|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Df(i,s,a,l){return Xu(i,s,a,l),Gu(i)}function Wa(i,s){return Xu(i,null,null,s),Gu(i)}function P_(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,h=i.return;h!==null;)h.childLanes|=a,l=h.alternate,l!==null&&(l.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(u=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,u&&s!==null&&(u=31-ft(a),i=h.hiddenUpdates,l=i[u],l===null?i[u]=[s]:l.push(s),s.lane=a|536870912),h):null}function Gu(i){if(50<hc)throw hc=0,zp=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var Mo={};function bk(i,s,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(i,s,a,l){return new bk(i,s,a,l)}function Rf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function ar(i,s){var a=i.alternate;return a===null?(a=Pn(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function H_(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function Zu(i,s,a,l,u,h){var _=0;if(l=i,typeof i=="function")Rf(i)&&(_=1);else if(typeof i=="string")_=xE(i,a,we.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ne:return i=Pn(31,a,s,u),i.elementType=ne,i.lanes=h,i;case D:return $a(a.children,u,h,s);case O:_=8,u|=24;break;case N:return i=Pn(12,a,s,u|2),i.elementType=N,i.lanes=h,i;case ie:return i=Pn(13,a,s,u),i.elementType=ie,i.lanes=h,i;case Q:return i=Pn(19,a,s,u),i.elementType=Q,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case V:_=10;break e;case B:_=9;break e;case W:_=11;break e;case $:_=14;break e;case Se:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return s=Pn(_,a,s,u),s.elementType=i,s.type=l,s.lanes=h,s}function $a(i,s,a,l){return i=Pn(7,i,l,s),i.lanes=a,i}function Mf(i,s,a){return i=Pn(6,i,null,s),i.lanes=a,i}function U_(i){var s=Pn(18,null,null,0);return s.stateNode=i,s}function Nf(i,s,a){return s=Pn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var K_=new WeakMap;function ts(i,s){if(typeof i=="object"&&i!==null){var a=K_.get(i);return a!==void 0?a:(s={value:i,source:s,stack:Ee(s)},K_.set(i,s),s)}return{value:i,source:s,stack:Ee(s)}}var No=[],Ao=0,Qu=null,$l=0,is=[],ns=0,Yr=null,Bs=1,js="";function or(i,s){No[Ao++]=$l,No[Ao++]=Qu,Qu=i,$l=s}function F_(i,s,a){is[ns++]=Bs,is[ns++]=js,is[ns++]=Yr,Yr=i;var l=Bs;i=js;var u=32-ft(l)-1;l&=~(1<<u),a+=1;var h=32-ft(s)+u;if(30<h){var _=u-u%5;h=(l&(1<<_)-1).toString(32),l>>=_,u-=_,Bs=1<<32-ft(s)+u|a<<u|l,js=h+i}else Bs=1<<h|a<<u|l,js=i}function Af(i){i.return!==null&&(or(i,1),F_(i,1,0))}function Lf(i){for(;i===Qu;)Qu=No[--Ao],No[Ao]=null,$l=No[--Ao],No[Ao]=null;for(;i===Yr;)Yr=is[--ns],is[ns]=null,js=is[--ns],is[ns]=null,Bs=is[--ns],is[ns]=null}function W_(i,s){is[ns++]=Bs,is[ns++]=js,is[ns++]=Yr,Bs=s.id,js=s.overflow,Yr=i}var sn=null,Xt=null,Ct=!1,Xr=null,ss=!1,Of=Error(r(519));function Gr(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ql(ts(s,i)),Of}function $_(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[Qt]=i,s[ki]=l,a){case"dialog":bt("cancel",s),bt("close",s);break;case"iframe":case"object":case"embed":bt("load",s);break;case"video":case"audio":for(a=0;a<pc.length;a++)bt(pc[a],s);break;case"source":bt("error",s);break;case"img":case"image":case"link":bt("error",s),bt("load",s);break;case"details":bt("toggle",s);break;case"input":bt("invalid",s),zr(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":bt("invalid",s);break;case"textarea":bt("invalid",s),Qn(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||lS(s.textContent,a)?(l.popover!=null&&(bt("beforetoggle",s),bt("toggle",s)),l.onScroll!=null&&bt("scroll",s),l.onScrollEnd!=null&&bt("scrollend",s),l.onClick!=null&&(s.onclick=Jt),s=!0):s=!1,s||Gr(i,!0)}function q_(i){for(sn=i.return;sn;)switch(sn.tag){case 5:case 31:case 13:ss=!1;return;case 27:case 3:ss=!0;return;default:sn=sn.return}}function Lo(i){if(i!==sn)return!1;if(!Ct)return q_(i),Ct=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Qp(i.type,i.memoizedProps)),a=!a),a&&Xt&&Gr(i),q_(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Xt=vS(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Xt=vS(i)}else s===27?(s=Xt,ua(i.type)?(i=nm,nm=null,Xt=i):Xt=s):Xt=sn?as(i.stateNode.nextSibling):null;return!0}function qa(){Xt=sn=null,Ct=!1}function Bf(){var i=Xr;return i!==null&&(An===null?An=i:An.push.apply(An,i),Xr=null),i}function ql(i){Xr===null?Xr=[i]:Xr.push(i)}var jf=M(null),Va=null,lr=null;function Zr(i,s,a){ce(jf,s._currentValue),s._currentValue=a}function cr(i){i._currentValue=jf.current,K(jf)}function zf(i,s,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),i===a)break;i=i.return}}function If(i,s,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var h=u.dependencies;if(h!==null){var _=u.child;h=h.firstContext;e:for(;h!==null;){var E=h;h=u;for(var A=0;A<s.length;A++)if(E.context===s[A]){h.lanes|=a,E=h.alternate,E!==null&&(E.lanes|=a),zf(h.return,a,i),l||(_=null);break e}h=E.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(r(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),zf(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function Oo(i,s,a,l){i=null;for(var u=s,h=!1;u!==null;){if(!h){if((u.flags&524288)!==0)h=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var E=u.type;hn(u.pendingProps.value,_.value)||(i!==null?i.push(E):i=[E])}}else if(u===Be.current){if(_=u.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(bc):i=[bc])}u=u.return}i!==null&&If(s,i,a,l),s.flags|=262144}function Ju(i){for(i=i.firstContext;i!==null;){if(!hn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Ya(i){Va=i,lr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function rn(i){return V_(Va,i)}function ed(i,s){return Va===null&&Ya(i),V_(i,s)}function V_(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},lr===null){if(i===null)throw Error(r(308));lr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else lr=lr.next=s;return a}var yk=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},Sk=e.unstable_scheduleCallback,wk=e.unstable_NormalPriority,Ti={$$typeof:V,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Pf(){return{controller:new yk,data:new Map,refCount:0}}function Vl(i){i.refCount--,i.refCount===0&&Sk(wk,function(){i.controller.abort()})}var Yl=null,Hf=0,Bo=0,jo=null;function Ck(i,s){if(Yl===null){var a=Yl=[];Hf=0,Bo=Fp(),jo={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Hf++,s.then(Y_,Y_),s}function Y_(){if(--Hf===0&&Yl!==null){jo!==null&&(jo.status="fulfilled");var i=Yl;Yl=null,Bo=0,jo=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function xk(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var u=0;u<a.length;u++)(0,a[u])(s)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var X_=L.S;L.S=function(i,s){Ay=Nt(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&Ck(i,s),X_!==null&&X_(i,s)};var Xa=M(null);function Uf(){var i=Xa.current;return i!==null?i:Ft.pooledCache}function td(i,s){s===null?ce(Xa,Xa.current):ce(Xa,s.pool)}function G_(){var i=Uf();return i===null?null:{parent:Ti._currentValue,pool:i}}var zo=Error(r(460)),Kf=Error(r(474)),id=Error(r(542)),nd={then:function(){}};function Z_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Q_(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Jt,Jt),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,eb(i),i;default:if(typeof s.status=="string")s.then(Jt,Jt);else{if(i=Ft,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var u=s;u.status="fulfilled",u.value=l}},function(l){if(s.status==="pending"){var u=s;u.status="rejected",u.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,eb(i),i}throw Za=s,zo}}function Ga(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Za=a,zo):a}}var Za=null;function J_(){if(Za===null)throw Error(r(459));var i=Za;return Za=null,i}function eb(i){if(i===zo||i===id)throw Error(r(483))}var Io=null,Xl=0;function sd(i){var s=Xl;return Xl+=1,Io===null&&(Io=[]),Q_(Io,i,s)}function Gl(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function rd(i,s){throw s.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function tb(i){function s(U,P){if(i){var X=U.deletions;X===null?(U.deletions=[P],U.flags|=16):X.push(P)}}function a(U,P){if(!i)return null;for(;P!==null;)s(U,P),P=P.sibling;return null}function l(U){for(var P=new Map;U!==null;)U.key!==null?P.set(U.key,U):P.set(U.index,U),U=U.sibling;return P}function u(U,P){return U=ar(U,P),U.index=0,U.sibling=null,U}function h(U,P,X){return U.index=X,i?(X=U.alternate,X!==null?(X=X.index,X<P?(U.flags|=67108866,P):X):(U.flags|=67108866,P)):(U.flags|=1048576,P)}function _(U){return i&&U.alternate===null&&(U.flags|=67108866),U}function E(U,P,X,pe){return P===null||P.tag!==6?(P=Mf(X,U.mode,pe),P.return=U,P):(P=u(P,X),P.return=U,P)}function A(U,P,X,pe){var $e=X.type;return $e===D?de(U,P,X.props.children,pe,X.key):P!==null&&(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===Se&&Ga($e)===P.type)?(P=u(P,X.props),Gl(P,X),P.return=U,P):(P=Zu(X.type,X.key,X.props,null,U.mode,pe),Gl(P,X),P.return=U,P)}function Z(U,P,X,pe){return P===null||P.tag!==4||P.stateNode.containerInfo!==X.containerInfo||P.stateNode.implementation!==X.implementation?(P=Nf(X,U.mode,pe),P.return=U,P):(P=u(P,X.children||[]),P.return=U,P)}function de(U,P,X,pe,$e){return P===null||P.tag!==7?(P=$a(X,U.mode,pe,$e),P.return=U,P):(P=u(P,X),P.return=U,P)}function ge(U,P,X){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=Mf(""+P,U.mode,X),P.return=U,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case C:return X=Zu(P.type,P.key,P.props,null,U.mode,X),Gl(X,P),X.return=U,X;case x:return P=Nf(P,U.mode,X),P.return=U,P;case Se:return P=Ga(P),ge(U,P,X)}if(le(P)||Y(P))return P=$a(P,U.mode,X,null),P.return=U,P;if(typeof P.then=="function")return ge(U,sd(P),X);if(P.$$typeof===V)return ge(U,ed(U,P),X);rd(U,P)}return null}function J(U,P,X,pe){var $e=P!==null?P.key:null;if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return $e!==null?null:E(U,P,""+X,pe);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case C:return X.key===$e?A(U,P,X,pe):null;case x:return X.key===$e?Z(U,P,X,pe):null;case Se:return X=Ga(X),J(U,P,X,pe)}if(le(X)||Y(X))return $e!==null?null:de(U,P,X,pe,null);if(typeof X.then=="function")return J(U,P,sd(X),pe);if(X.$$typeof===V)return J(U,P,ed(U,X),pe);rd(U,X)}return null}function oe(U,P,X,pe,$e){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return U=U.get(X)||null,E(P,U,""+pe,$e);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case C:return U=U.get(pe.key===null?X:pe.key)||null,A(P,U,pe,$e);case x:return U=U.get(pe.key===null?X:pe.key)||null,Z(P,U,pe,$e);case Se:return pe=Ga(pe),oe(U,P,X,pe,$e)}if(le(pe)||Y(pe))return U=U.get(X)||null,de(P,U,pe,$e,null);if(typeof pe.then=="function")return oe(U,P,X,sd(pe),$e);if(pe.$$typeof===V)return oe(U,P,X,ed(P,pe),$e);rd(P,pe)}return null}function Pe(U,P,X,pe){for(var $e=null,Et=null,Ue=P,dt=P=0,St=null;Ue!==null&&dt<X.length;dt++){Ue.index>dt?(St=Ue,Ue=null):St=Ue.sibling;var Tt=J(U,Ue,X[dt],pe);if(Tt===null){Ue===null&&(Ue=St);break}i&&Ue&&Tt.alternate===null&&s(U,Ue),P=h(Tt,P,dt),Et===null?$e=Tt:Et.sibling=Tt,Et=Tt,Ue=St}if(dt===X.length)return a(U,Ue),Ct&&or(U,dt),$e;if(Ue===null){for(;dt<X.length;dt++)Ue=ge(U,X[dt],pe),Ue!==null&&(P=h(Ue,P,dt),Et===null?$e=Ue:Et.sibling=Ue,Et=Ue);return Ct&&or(U,dt),$e}for(Ue=l(Ue);dt<X.length;dt++)St=oe(Ue,U,dt,X[dt],pe),St!==null&&(i&&St.alternate!==null&&Ue.delete(St.key===null?dt:St.key),P=h(St,P,dt),Et===null?$e=St:Et.sibling=St,Et=St);return i&&Ue.forEach(function(ma){return s(U,ma)}),Ct&&or(U,dt),$e}function Xe(U,P,X,pe){if(X==null)throw Error(r(151));for(var $e=null,Et=null,Ue=P,dt=P=0,St=null,Tt=X.next();Ue!==null&&!Tt.done;dt++,Tt=X.next()){Ue.index>dt?(St=Ue,Ue=null):St=Ue.sibling;var ma=J(U,Ue,Tt.value,pe);if(ma===null){Ue===null&&(Ue=St);break}i&&Ue&&ma.alternate===null&&s(U,Ue),P=h(ma,P,dt),Et===null?$e=ma:Et.sibling=ma,Et=ma,Ue=St}if(Tt.done)return a(U,Ue),Ct&&or(U,dt),$e;if(Ue===null){for(;!Tt.done;dt++,Tt=X.next())Tt=ge(U,Tt.value,pe),Tt!==null&&(P=h(Tt,P,dt),Et===null?$e=Tt:Et.sibling=Tt,Et=Tt);return Ct&&or(U,dt),$e}for(Ue=l(Ue);!Tt.done;dt++,Tt=X.next())Tt=oe(Ue,U,dt,Tt.value,pe),Tt!==null&&(i&&Tt.alternate!==null&&Ue.delete(Tt.key===null?dt:Tt.key),P=h(Tt,P,dt),Et===null?$e=Tt:Et.sibling=Tt,Et=Tt);return i&&Ue.forEach(function(BE){return s(U,BE)}),Ct&&or(U,dt),$e}function Pt(U,P,X,pe){if(typeof X=="object"&&X!==null&&X.type===D&&X.key===null&&(X=X.props.children),typeof X=="object"&&X!==null){switch(X.$$typeof){case C:e:{for(var $e=X.key;P!==null;){if(P.key===$e){if($e=X.type,$e===D){if(P.tag===7){a(U,P.sibling),pe=u(P,X.props.children),pe.return=U,U=pe;break e}}else if(P.elementType===$e||typeof $e=="object"&&$e!==null&&$e.$$typeof===Se&&Ga($e)===P.type){a(U,P.sibling),pe=u(P,X.props),Gl(pe,X),pe.return=U,U=pe;break e}a(U,P);break}else s(U,P);P=P.sibling}X.type===D?(pe=$a(X.props.children,U.mode,pe,X.key),pe.return=U,U=pe):(pe=Zu(X.type,X.key,X.props,null,U.mode,pe),Gl(pe,X),pe.return=U,U=pe)}return _(U);case x:e:{for($e=X.key;P!==null;){if(P.key===$e)if(P.tag===4&&P.stateNode.containerInfo===X.containerInfo&&P.stateNode.implementation===X.implementation){a(U,P.sibling),pe=u(P,X.children||[]),pe.return=U,U=pe;break e}else{a(U,P);break}else s(U,P);P=P.sibling}pe=Nf(X,U.mode,pe),pe.return=U,U=pe}return _(U);case Se:return X=Ga(X),Pt(U,P,X,pe)}if(le(X))return Pe(U,P,X,pe);if(Y(X)){if($e=Y(X),typeof $e!="function")throw Error(r(150));return X=$e.call(X),Xe(U,P,X,pe)}if(typeof X.then=="function")return Pt(U,P,sd(X),pe);if(X.$$typeof===V)return Pt(U,P,ed(U,X),pe);rd(U,X)}return typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint"?(X=""+X,P!==null&&P.tag===6?(a(U,P.sibling),pe=u(P,X),pe.return=U,U=pe):(a(U,P),pe=Mf(X,U.mode,pe),pe.return=U,U=pe),_(U)):a(U,P)}return function(U,P,X,pe){try{Xl=0;var $e=Pt(U,P,X,pe);return Io=null,$e}catch(Ue){if(Ue===zo||Ue===id)throw Ue;var Et=Pn(29,Ue,null,U.mode);return Et.lanes=pe,Et.return=U,Et}}}var Qa=tb(!0),ib=tb(!1),Qr=!1;function Ff(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wf(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Jr(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ea(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Dt&2)!==0){var u=l.pending;return u===null?s.next=s:(s.next=u.next,u.next=s),l.pending=s,s=Gu(i),P_(i,null,a),s}return Xu(i,l,s,a),Gu(i)}function Zl(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,xi(i,a)}}function $f(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?u=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?u=h=s:h=h.next=s}else u=h=s;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var qf=!1;function Ql(){if(qf){var i=jo;if(i!==null)throw i}}function Jl(i,s,a,l){qf=!1;var u=i.updateQueue;Qr=!1;var h=u.firstBaseUpdate,_=u.lastBaseUpdate,E=u.shared.pending;if(E!==null){u.shared.pending=null;var A=E,Z=A.next;A.next=null,_===null?h=Z:_.next=Z,_=A;var de=i.alternate;de!==null&&(de=de.updateQueue,E=de.lastBaseUpdate,E!==_&&(E===null?de.firstBaseUpdate=Z:E.next=Z,de.lastBaseUpdate=A))}if(h!==null){var ge=u.baseState;_=0,de=Z=A=null,E=h;do{var J=E.lane&-536870913,oe=J!==E.lane;if(oe?(yt&J)===J:(l&J)===J){J!==0&&J===Bo&&(qf=!0),de!==null&&(de=de.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Pe=i,Xe=E;J=s;var Pt=a;switch(Xe.tag){case 1:if(Pe=Xe.payload,typeof Pe=="function"){ge=Pe.call(Pt,ge,J);break e}ge=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Xe.payload,J=typeof Pe=="function"?Pe.call(Pt,ge,J):Pe,J==null)break e;ge=b({},ge,J);break e;case 2:Qr=!0}}J=E.callback,J!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=u.callbacks,oe===null?u.callbacks=[J]:oe.push(J))}else oe={lane:J,tag:E.tag,payload:E.payload,callback:E.callback,next:null},de===null?(Z=de=oe,A=ge):de=de.next=oe,_|=J;if(E=E.next,E===null){if(E=u.shared.pending,E===null)break;oe=E,E=oe.next,oe.next=null,u.lastBaseUpdate=oe,u.shared.pending=null}}while(!0);de===null&&(A=ge),u.baseState=A,u.firstBaseUpdate=Z,u.lastBaseUpdate=de,h===null&&(u.shared.lanes=0),ra|=_,i.lanes=_,i.memoizedState=ge}}function nb(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function sb(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)nb(a[i],s)}var Po=M(null),ad=M(0);function rb(i,s){i=_r,ce(ad,i),ce(Po,s),_r=i|s.baseLanes}function Vf(){ce(ad,_r),ce(Po,Po.current)}function Yf(){_r=ad.current,K(Po),K(ad)}var Hn=M(null),rs=null;function ta(i){var s=i.alternate;ce(yi,yi.current&1),ce(Hn,i),rs===null&&(s===null||Po.current!==null||s.memoizedState!==null)&&(rs=i)}function Xf(i){ce(yi,yi.current),ce(Hn,i),rs===null&&(rs=i)}function ab(i){i.tag===22?(ce(yi,yi.current),ce(Hn,i),rs===null&&(rs=i)):ia()}function ia(){ce(yi,yi.current),ce(Hn,Hn.current)}function Un(i){K(Hn),rs===i&&(rs=null),K(yi)}var yi=M(0);function od(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||tm(a)||im(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var ur=0,lt=null,zt=null,Di=null,ld=!1,Ho=!1,Ja=!1,cd=0,ec=0,Uo=null,kk=0;function ci(){throw Error(r(321))}function Gf(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!hn(i[a],s[a]))return!1;return!0}function Zf(i,s,a,l,u,h){return ur=h,lt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,L.H=i===null||i.memoizedState===null?Fb:hp,Ja=!1,h=a(l,u),Ja=!1,Ho&&(h=lb(s,a,l,u)),ob(i),h}function ob(i){L.H=nc;var s=zt!==null&&zt.next!==null;if(ur=0,Di=zt=lt=null,ld=!1,ec=0,Uo=null,s)throw Error(r(300));i===null||Ri||(i=i.dependencies,i!==null&&Ju(i)&&(Ri=!0))}function lb(i,s,a,l){lt=i;var u=0;do{if(Ho&&(Uo=null),ec=0,Ho=!1,25<=u)throw Error(r(301));if(u+=1,Di=zt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}L.H=Wb,h=s(a,l)}while(Ho);return h}function Ek(){var i=L.H,s=i.useState()[0];return s=typeof s.then=="function"?tc(s):s,i=i.useState()[0],(zt!==null?zt.memoizedState:null)!==i&&(lt.flags|=1024),s}function Qf(){var i=cd!==0;return cd=0,i}function Jf(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function ep(i){if(ld){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}ld=!1}ur=0,Di=zt=lt=null,Ho=!1,ec=cd=0,Uo=null}function _n(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Di===null?lt.memoizedState=Di=i:Di=Di.next=i,Di}function Si(){if(zt===null){var i=lt.alternate;i=i!==null?i.memoizedState:null}else i=zt.next;var s=Di===null?lt.memoizedState:Di.next;if(s!==null)Di=s,zt=i;else{if(i===null)throw lt.alternate===null?Error(r(467)):Error(r(310));zt=i,i={memoizedState:zt.memoizedState,baseState:zt.baseState,baseQueue:zt.baseQueue,queue:zt.queue,next:null},Di===null?lt.memoizedState=Di=i:Di=Di.next=i}return Di}function ud(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function tc(i){var s=ec;return ec+=1,Uo===null&&(Uo=[]),i=Q_(Uo,i,s),s=lt,(Di===null?s.memoizedState:Di.next)===null&&(s=s.alternate,L.H=s===null||s.memoizedState===null?Fb:hp),i}function dd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return tc(i);if(i.$$typeof===V)return rn(i)}throw Error(r(438,String(i)))}function tp(i){var s=null,a=lt.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=lt.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(u){return u.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=ud(),lt.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),l=0;l<i;l++)a[l]=Te;return s.index++,a}function dr(i,s){return typeof s=="function"?s(i):s}function hd(i){var s=Si();return ip(s,zt,i)}function ip(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var u=i.baseQueue,h=l.pending;if(h!==null){if(u!==null){var _=u.next;u.next=h.next,h.next=_}s.baseQueue=u=h,l.pending=null}if(h=i.baseState,u===null)i.memoizedState=h;else{s=u.next;var E=_=null,A=null,Z=s,de=!1;do{var ge=Z.lane&-536870913;if(ge!==Z.lane?(yt&ge)===ge:(ur&ge)===ge){var J=Z.revertLane;if(J===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ge===Bo&&(de=!0);else if((ur&J)===J){Z=Z.next,J===Bo&&(de=!0);continue}else ge={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},A===null?(E=A=ge,_=h):A=A.next=ge,lt.lanes|=J,ra|=J;ge=Z.action,Ja&&a(h,ge),h=Z.hasEagerState?Z.eagerState:a(h,ge)}else J={lane:ge,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},A===null?(E=A=J,_=h):A=A.next=J,lt.lanes|=ge,ra|=ge;Z=Z.next}while(Z!==null&&Z!==s);if(A===null?_=h:A.next=E,!hn(h,i.memoizedState)&&(Ri=!0,de&&(a=jo,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=A,l.lastRenderedState=h}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function np(i){var s=Si(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,h=s.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do h=i(h,_.action),_=_.next;while(_!==u);hn(h,s.memoizedState)||(Ri=!0),s.memoizedState=h,s.baseQueue===null&&(s.baseState=h),a.lastRenderedState=h}return[h,l]}function cb(i,s,a){var l=lt,u=Si(),h=Ct;if(h){if(a===void 0)throw Error(r(407));a=a()}else a=s();var _=!hn((zt||u).memoizedState,a);if(_&&(u.memoizedState=a,Ri=!0),u=u.queue,ap(hb.bind(null,l,u,i),[i]),u.getSnapshot!==s||_||Di!==null&&Di.memoizedState.tag&1){if(l.flags|=2048,Ko(9,{destroy:void 0},db.bind(null,l,u,a,s),null),Ft===null)throw Error(r(349));h||(ur&127)!==0||ub(l,s,a)}return a}function ub(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=lt.updateQueue,s===null?(s=ud(),lt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function db(i,s,a,l){s.value=a,s.getSnapshot=l,fb(s)&&pb(i)}function hb(i,s,a){return a(function(){fb(s)&&pb(i)})}function fb(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!hn(i,a)}catch{return!0}}function pb(i){var s=Wa(i,2);s!==null&&Ln(s,i,2)}function sp(i){var s=_n();if(typeof i=="function"){var a=i;if(i=a(),Ja){wt(!0);try{a()}finally{wt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:dr,lastRenderedState:i},s}function mb(i,s,a,l){return i.baseState=a,ip(i,zt,typeof l=="function"?l:dr)}function Tk(i,s,a,l,u){if(md(i))throw Error(r(485));if(i=s.action,i!==null){var h={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){h.listeners.push(_)}};L.T!==null?a(!0):h.isTransition=!1,l(h),a=s.pending,a===null?(h.next=s.pending=h,gb(s,h)):(h.next=a.next,s.pending=a.next=h)}}function gb(i,s){var a=s.action,l=s.payload,u=i.state;if(s.isTransition){var h=L.T,_={};L.T=_;try{var E=a(u,l),A=L.S;A!==null&&A(_,E),vb(i,s,E)}catch(Z){rp(i,s,Z)}finally{h!==null&&_.types!==null&&(h.types=_.types),L.T=h}}else try{h=a(u,l),vb(i,s,h)}catch(Z){rp(i,s,Z)}}function vb(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){_b(i,s,l)},function(l){return rp(i,s,l)}):_b(i,s,a)}function _b(i,s,a){s.status="fulfilled",s.value=a,bb(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,gb(i,a)))}function rp(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,bb(s),s=s.next;while(s!==l)}i.action=null}function bb(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function yb(i,s){return s}function Sb(i,s){if(Ct){var a=Ft.formState;if(a!==null){e:{var l=lt;if(Ct){if(Xt){t:{for(var u=Xt,h=ss;u.nodeType!==8;){if(!h){u=null;break t}if(u=as(u.nextSibling),u===null){u=null;break t}}h=u.data,u=h==="F!"||h==="F"?u:null}if(u){Xt=as(u.nextSibling),l=u.data==="F!";break e}}Gr(l)}l=!1}l&&(s=a[0])}}return a=_n(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yb,lastRenderedState:s},a.queue=l,a=Hb.bind(null,lt,l),l.dispatch=a,l=sp(!1),h=dp.bind(null,lt,!1,l.queue),l=_n(),u={state:s,dispatch:null,action:i,pending:null},l.queue=u,a=Tk.bind(null,lt,u,h,a),u.dispatch=a,l.memoizedState=i,[s,a,!1]}function wb(i){var s=Si();return Cb(s,zt,i)}function Cb(i,s,a){if(s=ip(i,s,yb)[0],i=hd(dr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=tc(s)}catch(_){throw _===zo?id:_}else l=s;s=Si();var u=s.queue,h=u.dispatch;return a!==s.memoizedState&&(lt.flags|=2048,Ko(9,{destroy:void 0},Dk.bind(null,u,a),null)),[l,h,i]}function Dk(i,s){i.action=s}function xb(i){var s=Si(),a=zt;if(a!==null)return Cb(s,a,i);Si(),s=s.memoizedState,a=Si();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function Ko(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=lt.updateQueue,s===null&&(s=ud(),lt.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,s.lastEffect=i),i}function kb(){return Si().memoizedState}function fd(i,s,a,l){var u=_n();lt.flags|=i,u.memoizedState=Ko(1|s,{destroy:void 0},a,l===void 0?null:l)}function pd(i,s,a,l){var u=Si();l=l===void 0?null:l;var h=u.memoizedState.inst;zt!==null&&l!==null&&Gf(l,zt.memoizedState.deps)?u.memoizedState=Ko(s,h,a,l):(lt.flags|=i,u.memoizedState=Ko(1|s,h,a,l))}function Eb(i,s){fd(8390656,8,i,s)}function ap(i,s){pd(2048,8,i,s)}function Rk(i){lt.flags|=4;var s=lt.updateQueue;if(s===null)s=ud(),lt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function Tb(i){var s=Si().memoizedState;return Rk({ref:s,nextImpl:i}),function(){if((Dt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function Db(i,s){return pd(4,2,i,s)}function Rb(i,s){return pd(4,4,i,s)}function Mb(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function Nb(i,s,a){a=a!=null?a.concat([i]):null,pd(4,4,Mb.bind(null,s,i),a)}function op(){}function Ab(i,s){var a=Si();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Gf(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function Lb(i,s){var a=Si();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Gf(s,l[1]))return l[0];if(l=i(),Ja){wt(!0);try{i()}finally{wt(!1)}}return a.memoizedState=[l,s],l}function lp(i,s,a){return a===void 0||(ur&1073741824)!==0&&(yt&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=Oy(),lt.lanes|=i,ra|=i,a)}function Ob(i,s,a,l){return hn(a,s)?a:Po.current!==null?(i=lp(i,a,l),hn(i,s)||(Ri=!0),i):(ur&42)===0||(ur&1073741824)!==0&&(yt&261930)===0?(Ri=!0,i.memoizedState=a):(i=Oy(),lt.lanes|=i,ra|=i,s)}function Bb(i,s,a,l,u){var h=R.p;R.p=h!==0&&8>h?h:8;var _=L.T,E={};L.T=E,dp(i,!1,s,a);try{var A=u(),Z=L.S;if(Z!==null&&Z(E,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var de=xk(A,l);ic(i,s,de,Wn(i))}else ic(i,s,l,Wn(i))}catch(ge){ic(i,s,{then:function(){},status:"rejected",reason:ge},Wn())}finally{R.p=h,_!==null&&E.types!==null&&(_.types=E.types),L.T=_}}function Mk(){}function cp(i,s,a,l){if(i.tag!==5)throw Error(r(476));var u=jb(i).queue;Bb(i,u,s,j,a===null?Mk:function(){return zb(i),a(l)})}function jb(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:dr,lastRenderedState:j},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:dr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function zb(i){var s=jb(i);s.next===null&&(s=i.alternate.memoizedState),ic(i,s.next.queue,{},Wn())}function up(){return rn(bc)}function Ib(){return Si().memoizedState}function Pb(){return Si().memoizedState}function Nk(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Wn();i=Jr(a);var l=ea(s,i,a);l!==null&&(Ln(l,s,a),Zl(l,s,a)),s={cache:Pf()},i.payload=s;return}s=s.return}}function Ak(i,s,a){var l=Wn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},md(i)?Ub(s,a):(a=Df(i,s,a,l),a!==null&&(Ln(a,i,l),Kb(a,s,l)))}function Hb(i,s,a){var l=Wn();ic(i,s,a,l)}function ic(i,s,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(md(i))Ub(s,u);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var _=s.lastRenderedState,E=h(_,a);if(u.hasEagerState=!0,u.eagerState=E,hn(E,_))return Xu(i,s,u,0),Ft===null&&Yu(),!1}catch{}if(a=Df(i,s,u,l),a!==null)return Ln(a,i,l),Kb(a,s,l),!0}return!1}function dp(i,s,a,l){if(l={lane:2,revertLane:Fp(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},md(i)){if(s)throw Error(r(479))}else s=Df(i,a,l,2),s!==null&&Ln(s,i,2)}function md(i){var s=i.alternate;return i===lt||s!==null&&s===lt}function Ub(i,s){Ho=ld=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function Kb(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,xi(i,a)}}var nc={readContext:rn,use:dd,useCallback:ci,useContext:ci,useEffect:ci,useImperativeHandle:ci,useLayoutEffect:ci,useInsertionEffect:ci,useMemo:ci,useReducer:ci,useRef:ci,useState:ci,useDebugValue:ci,useDeferredValue:ci,useTransition:ci,useSyncExternalStore:ci,useId:ci,useHostTransitionStatus:ci,useFormState:ci,useActionState:ci,useOptimistic:ci,useMemoCache:ci,useCacheRefresh:ci};nc.useEffectEvent=ci;var Fb={readContext:rn,use:dd,useCallback:function(i,s){return _n().memoizedState=[i,s===void 0?null:s],i},useContext:rn,useEffect:Eb,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,fd(4194308,4,Mb.bind(null,s,i),a)},useLayoutEffect:function(i,s){return fd(4194308,4,i,s)},useInsertionEffect:function(i,s){fd(4,2,i,s)},useMemo:function(i,s){var a=_n();s=s===void 0?null:s;var l=i();if(Ja){wt(!0);try{i()}finally{wt(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=_n();if(a!==void 0){var u=a(s);if(Ja){wt(!0);try{a(s)}finally{wt(!1)}}}else u=s;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=Ak.bind(null,lt,i),[l.memoizedState,i]},useRef:function(i){var s=_n();return i={current:i},s.memoizedState=i},useState:function(i){i=sp(i);var s=i.queue,a=Hb.bind(null,lt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:op,useDeferredValue:function(i,s){var a=_n();return lp(a,i,s)},useTransition:function(){var i=sp(!1);return i=Bb.bind(null,lt,i.queue,!0,!1),_n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=lt,u=_n();if(Ct){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Ft===null)throw Error(r(349));(yt&127)!==0||ub(l,s,a)}u.memoizedState=a;var h={value:a,getSnapshot:s};return u.queue=h,Eb(hb.bind(null,l,h,i),[i]),l.flags|=2048,Ko(9,{destroy:void 0},db.bind(null,l,h,a,s),null),a},useId:function(){var i=_n(),s=Ft.identifierPrefix;if(Ct){var a=js,l=Bs;a=(l&~(1<<32-ft(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=cd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=kk++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:up,useFormState:Sb,useActionState:Sb,useOptimistic:function(i){var s=_n();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=dp.bind(null,lt,!0,a),a.dispatch=s,[i,s]},useMemoCache:tp,useCacheRefresh:function(){return _n().memoizedState=Nk.bind(null,lt)},useEffectEvent:function(i){var s=_n(),a={impl:i};return s.memoizedState=a,function(){if((Dt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},hp={readContext:rn,use:dd,useCallback:Ab,useContext:rn,useEffect:ap,useImperativeHandle:Nb,useInsertionEffect:Db,useLayoutEffect:Rb,useMemo:Lb,useReducer:hd,useRef:kb,useState:function(){return hd(dr)},useDebugValue:op,useDeferredValue:function(i,s){var a=Si();return Ob(a,zt.memoizedState,i,s)},useTransition:function(){var i=hd(dr)[0],s=Si().memoizedState;return[typeof i=="boolean"?i:tc(i),s]},useSyncExternalStore:cb,useId:Ib,useHostTransitionStatus:up,useFormState:wb,useActionState:wb,useOptimistic:function(i,s){var a=Si();return mb(a,zt,i,s)},useMemoCache:tp,useCacheRefresh:Pb};hp.useEffectEvent=Tb;var Wb={readContext:rn,use:dd,useCallback:Ab,useContext:rn,useEffect:ap,useImperativeHandle:Nb,useInsertionEffect:Db,useLayoutEffect:Rb,useMemo:Lb,useReducer:np,useRef:kb,useState:function(){return np(dr)},useDebugValue:op,useDeferredValue:function(i,s){var a=Si();return zt===null?lp(a,i,s):Ob(a,zt.memoizedState,i,s)},useTransition:function(){var i=np(dr)[0],s=Si().memoizedState;return[typeof i=="boolean"?i:tc(i),s]},useSyncExternalStore:cb,useId:Ib,useHostTransitionStatus:up,useFormState:xb,useActionState:xb,useOptimistic:function(i,s){var a=Si();return zt!==null?mb(a,zt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:tp,useCacheRefresh:Pb};Wb.useEffectEvent=Tb;function fp(i,s,a,l){s=i.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var pp={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Wn(),u=Jr(l);u.payload=s,a!=null&&(u.callback=a),s=ea(i,u,l),s!==null&&(Ln(s,i,l),Zl(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Wn(),u=Jr(l);u.tag=1,u.payload=s,a!=null&&(u.callback=a),s=ea(i,u,l),s!==null&&(Ln(s,i,l),Zl(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Wn(),l=Jr(a);l.tag=2,s!=null&&(l.callback=s),s=ea(i,l,a),s!==null&&(Ln(s,i,a),Zl(s,i,a))}};function $b(i,s,a,l,u,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):s.prototype&&s.prototype.isPureReactComponent?!Dn(a,l)||!Dn(u,h):!0}function qb(i,s,a,l){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==i&&pp.enqueueReplaceState(s,s.state,null)}function eo(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Vb(i){Vu(i)}function Yb(i){console.error(i)}function Xb(i){Vu(i)}function gd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Gb(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function mp(i,s,a){return a=Jr(a),a.tag=3,a.payload={element:null},a.callback=function(){gd(i,s)},a}function Zb(i){return i=Jr(i),i.tag=3,i}function Qb(i,s,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var h=l.value;i.payload=function(){return u(h)},i.callback=function(){Gb(s,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Gb(s,a,l),typeof u!="function"&&(aa===null?aa=new Set([this]):aa.add(this));var E=l.stack;this.componentDidCatch(l.value,{componentStack:E!==null?E:""})})}function Lk(i,s,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Oo(s,a,u,!0),a=Hn.current,a!==null){switch(a.tag){case 31:case 13:return rs===null?Dd():a.alternate===null&&ui===0&&(ui=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===nd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),Hp(i,l,u)),!1;case 22:return a.flags|=65536,l===nd?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)),Hp(i,l,u)),!1}throw Error(r(435,a.tag))}return Hp(i,l,u),Dd(),!1}if(Ct)return s=Hn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=u,l!==Of&&(i=Error(r(422),{cause:l}),ql(ts(i,a)))):(l!==Of&&(s=Error(r(423),{cause:l}),ql(ts(s,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=ts(l,a),u=mp(i.stateNode,l,u),$f(i,u),ui!==4&&(ui=2)),!1;var h=Error(r(520),{cause:l});if(h=ts(h,a),dc===null?dc=[h]:dc.push(h),ui!==4&&(ui=2),s===null)return!0;l=ts(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=mp(a.stateNode,l,i),$f(a,i),!1;case 1:if(s=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(aa===null||!aa.has(h))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Zb(u),Qb(u,i,a,l),$f(a,u),!1}a=a.return}while(a!==null);return!1}var gp=Error(r(461)),Ri=!1;function an(i,s,a,l){s.child=i===null?ib(s,null,a,l):Qa(s,i.child,a,l)}function Jb(i,s,a,l,u){a=a.render;var h=s.ref;if("ref"in l){var _={};for(var E in l)E!=="ref"&&(_[E]=l[E])}else _=l;return Ya(s),l=Zf(i,s,a,_,h,u),E=Qf(),i!==null&&!Ri?(Jf(i,s,u),hr(i,s,u)):(Ct&&E&&Af(s),s.flags|=1,an(i,s,l,u),s.child)}function ey(i,s,a,l,u){if(i===null){var h=a.type;return typeof h=="function"&&!Rf(h)&&h.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=h,ty(i,s,h,l,u)):(i=Zu(a.type,null,l,s,s.mode,u),i.ref=s.ref,i.return=s,s.child=i)}if(h=i.child,!xp(i,u)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Dn,a(_,l)&&i.ref===s.ref)return hr(i,s,u)}return s.flags|=1,i=ar(h,l),i.ref=s.ref,i.return=s,s.child=i}function ty(i,s,a,l,u){if(i!==null){var h=i.memoizedProps;if(Dn(h,l)&&i.ref===s.ref)if(Ri=!1,s.pendingProps=l=h,xp(i,u))(i.flags&131072)!==0&&(Ri=!0);else return s.lanes=i.lanes,hr(i,s,u)}return vp(i,s,a,l,u)}function iy(i,s,a,l){var u=l.children,h=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(l=s.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~h}else l=0,s.child=null;return ny(i,s,h,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&td(s,h!==null?h.cachePool:null),h!==null?rb(s,h):Vf(),ab(s);else return l=s.lanes=536870912,ny(i,s,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(td(s,h.cachePool),rb(s,h),ia(),s.memoizedState=null):(i!==null&&td(s,null),Vf(),ia());return an(i,s,u,a),s.child}function sc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function ny(i,s,a,l,u){var h=Uf();return h=h===null?null:{parent:Ti._currentValue,pool:h},s.memoizedState={baseLanes:a,cachePool:h},i!==null&&td(s,null),Vf(),ab(s),i!==null&&Oo(i,s,l,!0),s.childLanes=u,null}function vd(i,s){return s=bd({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function sy(i,s,a){return Qa(s,i.child,null,a),i=vd(s,s.pendingProps),i.flags|=2,Un(s),s.memoizedState=null,i}function Ok(i,s,a){var l=s.pendingProps,u=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(Ct){if(l.mode==="hidden")return i=vd(s,l),s.lanes=536870912,sc(null,i);if(Xf(s),(i=Xt)?(i=gS(i,ss),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Yr!==null?{id:Bs,overflow:js}:null,retryLane:536870912,hydrationErrors:null},a=U_(i),a.return=s,s.child=a,sn=s,Xt=null)):i=null,i===null)throw Gr(s);return s.lanes=536870912,null}return vd(s,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(Xf(s),u)if(s.flags&256)s.flags&=-257,s=sy(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Ri||Oo(i,s,a,!1),u=(a&i.childLanes)!==0,Ri||u){if(l=Ft,l!==null&&(_=Fi(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,Wa(i,_),Ln(l,i,_),gp;Dd(),s=sy(i,s,a)}else i=h.treeContext,Xt=as(_.nextSibling),sn=s,Ct=!0,Xr=null,ss=!1,i!==null&&W_(s,i),s=vd(s,l),s.flags|=4096;return s}return i=ar(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function _d(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function vp(i,s,a,l,u){return Ya(s),a=Zf(i,s,a,l,void 0,u),l=Qf(),i!==null&&!Ri?(Jf(i,s,u),hr(i,s,u)):(Ct&&l&&Af(s),s.flags|=1,an(i,s,a,u),s.child)}function ry(i,s,a,l,u,h){return Ya(s),s.updateQueue=null,a=lb(s,l,a,u),ob(i),l=Qf(),i!==null&&!Ri?(Jf(i,s,h),hr(i,s,h)):(Ct&&l&&Af(s),s.flags|=1,an(i,s,a,h),s.child)}function ay(i,s,a,l,u){if(Ya(s),s.stateNode===null){var h=Mo,_=a.contextType;typeof _=="object"&&_!==null&&(h=rn(_)),h=new a(l,h),s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=pp,s.stateNode=h,h._reactInternals=s,h=s.stateNode,h.props=l,h.state=s.memoizedState,h.refs={},Ff(s),_=a.contextType,h.context=typeof _=="object"&&_!==null?rn(_):Mo,h.state=s.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(fp(s,a,_,l),h.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(_=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),_!==h.state&&pp.enqueueReplaceState(h,h.state,null),Jl(s,l,h,u),Ql(),h.state=s.memoizedState),typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){h=s.stateNode;var E=s.memoizedProps,A=eo(a,E);h.props=A;var Z=h.context,de=a.contextType;_=Mo,typeof de=="object"&&de!==null&&(_=rn(de));var ge=a.getDerivedStateFromProps;de=typeof ge=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=s.pendingProps!==E,de||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||Z!==_)&&qb(s,h,l,_),Qr=!1;var J=s.memoizedState;h.state=J,Jl(s,l,h,u),Ql(),Z=s.memoizedState,E||J!==Z||Qr?(typeof ge=="function"&&(fp(s,a,ge,l),Z=s.memoizedState),(A=Qr||$b(s,a,A,l,J,Z,_))?(de||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(s.flags|=4194308)):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=Z),h.props=l,h.state=Z,h.context=_,l=A):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{h=s.stateNode,Wf(i,s),_=s.memoizedProps,de=eo(a,_),h.props=de,ge=s.pendingProps,J=h.context,Z=a.contextType,A=Mo,typeof Z=="object"&&Z!==null&&(A=rn(Z)),E=a.getDerivedStateFromProps,(Z=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==ge||J!==A)&&qb(s,h,l,A),Qr=!1,J=s.memoizedState,h.state=J,Jl(s,l,h,u),Ql();var oe=s.memoizedState;_!==ge||J!==oe||Qr||i!==null&&i.dependencies!==null&&Ju(i.dependencies)?(typeof E=="function"&&(fp(s,a,E,l),oe=s.memoizedState),(de=Qr||$b(s,a,de,l,J,oe,A)||i!==null&&i.dependencies!==null&&Ju(i.dependencies))?(Z||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(l,oe,A),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(l,oe,A)),typeof h.componentDidUpdate=="function"&&(s.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=oe),h.props=l,h.state=oe,h.context=A,l=de):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&J===i.memoizedState||(s.flags|=1024),l=!1)}return h=l,_d(i,s),l=(s.flags&128)!==0,h||l?(h=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:h.render(),s.flags|=1,i!==null&&l?(s.child=Qa(s,i.child,null,u),s.child=Qa(s,null,a,u)):an(i,s,a,u),s.memoizedState=h.state,i=s.child):i=hr(i,s,u),i}function oy(i,s,a,l){return qa(),s.flags|=256,an(i,s,a,l),s.child}var _p={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bp(i){return{baseLanes:i,cachePool:G_()}}function yp(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Fn),i}function ly(i,s,a){var l=s.pendingProps,u=!1,h=(s.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(yi.current&2)!==0),_&&(u=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,i===null){if(Ct){if(u?ta(s):ia(),(i=Xt)?(i=gS(i,ss),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Yr!==null?{id:Bs,overflow:js}:null,retryLane:536870912,hydrationErrors:null},a=U_(i),a.return=s,s.child=a,sn=s,Xt=null)):i=null,i===null)throw Gr(s);return im(i)?s.lanes=32:s.lanes=536870912,null}var E=l.children;return l=l.fallback,u?(ia(),u=s.mode,E=bd({mode:"hidden",children:E},u),l=$a(l,u,a,null),E.return=s,l.return=s,E.sibling=l,s.child=E,l=s.child,l.memoizedState=bp(a),l.childLanes=yp(i,_,a),s.memoizedState=_p,sc(null,l)):(ta(s),Sp(s,E))}var A=i.memoizedState;if(A!==null&&(E=A.dehydrated,E!==null)){if(h)s.flags&256?(ta(s),s.flags&=-257,s=wp(i,s,a)):s.memoizedState!==null?(ia(),s.child=i.child,s.flags|=128,s=null):(ia(),E=l.fallback,u=s.mode,l=bd({mode:"visible",children:l.children},u),E=$a(E,u,a,null),E.flags|=2,l.return=s,E.return=s,l.sibling=E,s.child=l,Qa(s,i.child,null,a),l=s.child,l.memoizedState=bp(a),l.childLanes=yp(i,_,a),s.memoizedState=_p,s=sc(null,l));else if(ta(s),im(E)){if(_=E.nextSibling&&E.nextSibling.dataset,_)var Z=_.dgst;_=Z,l=Error(r(419)),l.stack="",l.digest=_,ql({value:l,source:null,stack:null}),s=wp(i,s,a)}else if(Ri||Oo(i,s,a,!1),_=(a&i.childLanes)!==0,Ri||_){if(_=Ft,_!==null&&(l=Fi(_,a),l!==0&&l!==A.retryLane))throw A.retryLane=l,Wa(i,l),Ln(_,i,l),gp;tm(E)||Dd(),s=wp(i,s,a)}else tm(E)?(s.flags|=192,s.child=i.child,s=null):(i=A.treeContext,Xt=as(E.nextSibling),sn=s,Ct=!0,Xr=null,ss=!1,i!==null&&W_(s,i),s=Sp(s,l.children),s.flags|=4096);return s}return u?(ia(),E=l.fallback,u=s.mode,A=i.child,Z=A.sibling,l=ar(A,{mode:"hidden",children:l.children}),l.subtreeFlags=A.subtreeFlags&65011712,Z!==null?E=ar(Z,E):(E=$a(E,u,a,null),E.flags|=2),E.return=s,l.return=s,l.sibling=E,s.child=l,sc(null,l),l=s.child,E=i.child.memoizedState,E===null?E=bp(a):(u=E.cachePool,u!==null?(A=Ti._currentValue,u=u.parent!==A?{parent:A,pool:A}:u):u=G_(),E={baseLanes:E.baseLanes|a,cachePool:u}),l.memoizedState=E,l.childLanes=yp(i,_,a),s.memoizedState=_p,sc(i.child,l)):(ta(s),a=i.child,i=a.sibling,a=ar(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,i!==null&&(_=s.deletions,_===null?(s.deletions=[i],s.flags|=16):_.push(i)),s.child=a,s.memoizedState=null,a)}function Sp(i,s){return s=bd({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function bd(i,s){return i=Pn(22,i,null,s),i.lanes=0,i}function wp(i,s,a){return Qa(s,i.child,null,a),i=Sp(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function cy(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),zf(i.return,s,a)}function Cp(i,s,a,l,u,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:h}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=h)}function uy(i,s,a){var l=s.pendingProps,u=l.revealOrder,h=l.tail;l=l.children;var _=yi.current,E=(_&2)!==0;if(E?(_=_&1|2,s.flags|=128):_&=1,ce(yi,_),an(i,s,l,a),l=Ct?$l:0,!E&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&cy(i,a,s);else if(i.tag===19)cy(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=s.child,u=null;a!==null;)i=a.alternate,i!==null&&od(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=s.child,s.child=null):(u=a.sibling,a.sibling=null),Cp(s,!1,u,a,h,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=s.child,s.child=null;u!==null;){if(i=u.alternate,i!==null&&od(i)===null){s.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Cp(s,!0,a,null,h,l);break;case"together":Cp(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function hr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),ra|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Oo(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=ar(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=ar(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function xp(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Ju(i)))}function Bk(i,s,a){switch(s.tag){case 3:De(s,s.stateNode.containerInfo),Zr(s,Ti,i.memoizedState.cache),qa();break;case 27:case 5:ze(s);break;case 4:De(s,s.stateNode.containerInfo);break;case 10:Zr(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Xf(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(ta(s),s.flags|=128,null):(a&s.child.childLanes)!==0?ly(i,s,a):(ta(s),i=hr(i,s,a),i!==null?i.sibling:null);ta(s);break;case 19:var u=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Oo(i,s,a,!1),l=(a&s.childLanes)!==0),u){if(l)return uy(i,s,a);s.flags|=128}if(u=s.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ce(yi,yi.current),l)break;return null;case 22:return s.lanes=0,iy(i,s,a,s.pendingProps);case 24:Zr(s,Ti,i.memoizedState.cache)}return hr(i,s,a)}function dy(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Ri=!0;else{if(!xp(i,a)&&(s.flags&128)===0)return Ri=!1,Bk(i,s,a);Ri=(i.flags&131072)!==0}else Ri=!1,Ct&&(s.flags&1048576)!==0&&F_(s,$l,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=Ga(s.elementType),s.type=i,typeof i=="function")Rf(i)?(l=eo(i,l),s.tag=1,s=ay(null,s,i,l,a)):(s.tag=0,s=vp(null,s,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===W){s.tag=11,s=Jb(null,s,i,l,a);break e}else if(u===$){s.tag=14,s=ey(null,s,i,l,a);break e}}throw s=F(i)||i,Error(r(306,s,""))}}return s;case 0:return vp(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,u=eo(l,s.pendingProps),ay(i,s,l,u,a);case 3:e:{if(De(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var h=s.memoizedState;u=h.element,Wf(i,s),Jl(s,l,null,a);var _=s.memoizedState;if(l=_.cache,Zr(s,Ti,l),l!==h.cache&&If(s,[Ti],a,!0),Ql(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){s=oy(i,s,l,a);break e}else if(l!==u){u=ts(Error(r(424)),s),ql(u),s=oy(i,s,l,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Xt=as(i.firstChild),sn=s,Ct=!0,Xr=null,ss=!0,a=ib(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(qa(),l===u){s=hr(i,s,a);break e}an(i,s,l,a)}s=s.child}return s;case 26:return _d(i,s),i===null?(a=wS(s.type,null,s.pendingProps,null))?s.memoizedState=a:Ct||(a=s.type,i=s.pendingProps,l=Bd(xe.current).createElement(a),l[Qt]=s,l[ki]=i,on(l,a,i),ai(l),s.stateNode=l):s.memoizedState=wS(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return ze(s),i===null&&Ct&&(l=s.stateNode=bS(s.type,s.pendingProps,xe.current),sn=s,ss=!0,u=Xt,ua(s.type)?(nm=u,Xt=as(l.firstChild)):Xt=u),an(i,s,s.pendingProps.children,a),_d(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&Ct&&((u=l=Xt)&&(l=dE(l,s.type,s.pendingProps,ss),l!==null?(s.stateNode=l,sn=s,Xt=as(l.firstChild),ss=!1,u=!0):u=!1),u||Gr(s)),ze(s),u=s.type,h=s.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,Qp(u,h)?l=null:_!==null&&Qp(u,_)&&(s.flags|=32),s.memoizedState!==null&&(u=Zf(i,s,Ek,null,null,a),bc._currentValue=u),_d(i,s),an(i,s,l,a),s.child;case 6:return i===null&&Ct&&((i=a=Xt)&&(a=hE(a,s.pendingProps,ss),a!==null?(s.stateNode=a,sn=s,Xt=null,i=!0):i=!1),i||Gr(s)),null;case 13:return ly(i,s,a);case 4:return De(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=Qa(s,null,l,a):an(i,s,l,a),s.child;case 11:return Jb(i,s,s.type,s.pendingProps,a);case 7:return an(i,s,s.pendingProps,a),s.child;case 8:return an(i,s,s.pendingProps.children,a),s.child;case 12:return an(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,Zr(s,s.type,l.value),an(i,s,l.children,a),s.child;case 9:return u=s.type._context,l=s.pendingProps.children,Ya(s),u=rn(u),l=l(u),s.flags|=1,an(i,s,l,a),s.child;case 14:return ey(i,s,s.type,s.pendingProps,a);case 15:return ty(i,s,s.type,s.pendingProps,a);case 19:return uy(i,s,a);case 31:return Ok(i,s,a);case 22:return iy(i,s,a,s.pendingProps);case 24:return Ya(s),l=rn(Ti),i===null?(u=Uf(),u===null&&(u=Ft,h=Pf(),u.pooledCache=h,h.refCount++,h!==null&&(u.pooledCacheLanes|=a),u=h),s.memoizedState={parent:l,cache:u},Ff(s),Zr(s,Ti,u)):((i.lanes&a)!==0&&(Wf(i,s),Jl(s,null,null,a),Ql()),u=i.memoizedState,h=s.memoizedState,u.parent!==l?(u={parent:l,cache:l},s.memoizedState=u,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=u),Zr(s,Ti,l)):(l=h.cache,Zr(s,Ti,l),l!==u.cache&&If(s,[Ti],a,!0))),an(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function fr(i){i.flags|=4}function kp(i,s,a,l,u){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(Iy())i.flags|=8192;else throw Za=nd,Kf}else i.flags&=-16777217}function hy(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!TS(s))if(Iy())i.flags|=8192;else throw Za=nd,Kf}function yd(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?$t():536870912,i.lanes|=s,qo|=s)}function rc(i,s){if(!Ct)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function Gt(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function jk(i,s,a){var l=s.pendingProps;switch(Lf(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(s),null;case 1:return Gt(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),cr(Ti),He(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Lo(s)?fr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,Bf())),Gt(s),null;case 26:var u=s.type,h=s.memoizedState;return i===null?(fr(s),h!==null?(Gt(s),hy(s,h)):(Gt(s),kp(s,u,null,l,a))):h?h!==i.memoizedState?(fr(s),Gt(s),hy(s,h)):(Gt(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&fr(s),Gt(s),kp(s,u,i,l,a)),null;case 27:if(re(s),a=xe.current,u=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&fr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Gt(s),null}i=we.current,Lo(s)?$_(s):(i=bS(u,l,a),s.stateNode=i,fr(s))}return Gt(s),null;case 5:if(re(s),u=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&fr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Gt(s),null}if(h=we.current,Lo(s))$_(s);else{var _=Bd(xe.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":h=_.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?h.multiple=!0:l.size&&(h.size=l.size);break;default:h=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}h[Qt]=s,h[ki]=l;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)h.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=h;e:switch(on(h,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&fr(s)}}return Gt(s),kp(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&fr(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=xe.current,Lo(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,u=sn,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[Qt]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||lS(i.nodeValue,a)),i||Gr(s,!0)}else i=Bd(i).createTextNode(l),i[Qt]=s,s.stateNode=i}return Gt(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=Lo(s),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Qt]=s}else qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Gt(s),i=!1}else a=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Un(s),s):(Un(s),null);if((s.flags&128)!==0)throw Error(r(558))}return Gt(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Lo(s),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(r(318));if(u=s.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[Qt]=s}else qa(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Gt(s),u=!1}else u=Bf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return s.flags&256?(Un(s),s):(Un(s),null)}return Un(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),h=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(h=l.memoizedState.cachePool.pool),h!==u&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),yd(s,s.updateQueue),Gt(s),null);case 4:return He(),i===null&&Vp(s.stateNode.containerInfo),Gt(s),null;case 10:return cr(s.type),Gt(s),null;case 19:if(K(yi),l=s.memoizedState,l===null)return Gt(s),null;if(u=(s.flags&128)!==0,h=l.rendering,h===null)if(u)rc(l,!1);else{if(ui!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(h=od(i),h!==null){for(s.flags|=128,rc(l,!1),i=h.updateQueue,s.updateQueue=i,yd(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)H_(a,i),a=a.sibling;return ce(yi,yi.current&1|2),Ct&&or(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&Nt()>kd&&(s.flags|=128,u=!0,rc(l,!1),s.lanes=4194304)}else{if(!u)if(i=od(h),i!==null){if(s.flags|=128,u=!0,i=i.updateQueue,s.updateQueue=i,yd(s,i),rc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!Ct)return Gt(s),null}else 2*Nt()-l.renderingStartTime>kd&&a!==536870912&&(s.flags|=128,u=!0,rc(l,!1),s.lanes=4194304);l.isBackwards?(h.sibling=s.child,s.child=h):(i=l.last,i!==null?i.sibling=h:s.child=h,l.last=h)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=Nt(),i.sibling=null,a=yi.current,ce(yi,u?a&1|2:a&1),Ct&&or(s,l.treeForkCount),i):(Gt(s),null);case 22:case 23:return Un(s),Yf(),l=s.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(Gt(s),s.subtreeFlags&6&&(s.flags|=8192)):Gt(s),a=s.updateQueue,a!==null&&yd(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),i!==null&&K(Xa),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),cr(Ti),Gt(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function zk(i,s){switch(Lf(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return cr(Ti),He(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return re(s),null;case 31:if(s.memoizedState!==null){if(Un(s),s.alternate===null)throw Error(r(340));qa()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Un(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));qa()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return K(yi),null;case 4:return He(),null;case 10:return cr(s.type),null;case 22:case 23:return Un(s),Yf(),i!==null&&K(Xa),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return cr(Ti),null;case 25:return null;default:return null}}function fy(i,s){switch(Lf(s),s.tag){case 3:cr(Ti),He();break;case 26:case 27:case 5:re(s);break;case 4:He();break;case 31:s.memoizedState!==null&&Un(s);break;case 13:Un(s);break;case 19:K(yi);break;case 10:cr(s.type);break;case 22:case 23:Un(s),Yf(),i!==null&&K(Xa);break;case 24:cr(Ti)}}function ac(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var h=a.create,_=a.inst;l=h(),_.destroy=l}a=a.next}while(a!==u)}}catch(E){Ot(s,s.return,E)}}function na(i,s,a){try{var l=s.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var h=u.next;l=h;do{if((l.tag&i)===i){var _=l.inst,E=_.destroy;if(E!==void 0){_.destroy=void 0,u=s;var A=a,Z=E;try{Z()}catch(de){Ot(u,A,de)}}}l=l.next}while(l!==h)}}catch(de){Ot(s,s.return,de)}}function py(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{sb(s,a)}catch(l){Ot(i,i.return,l)}}}function my(i,s,a){a.props=eo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){Ot(i,s,l)}}function oc(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){Ot(i,s,u)}}function zs(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){Ot(i,s,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){Ot(i,s,u)}else a.current=null}function gy(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){Ot(i,i.return,u)}}function Ep(i,s,a){try{var l=i.stateNode;rE(l,i.type,a,s),l[ki]=s}catch(u){Ot(i,i.return,u)}}function vy(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ua(i.type)||i.tag===4}function Tp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||vy(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ua(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Dp(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Jt));else if(l!==4&&(l===27&&ua(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Dp(i,s,a),i=i.sibling;i!==null;)Dp(i,s,a),i=i.sibling}function Sd(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(l!==4&&(l===27&&ua(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Sd(i,s,a),i=i.sibling;i!==null;)Sd(i,s,a),i=i.sibling}function _y(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=s.attributes;u.length;)s.removeAttributeNode(u[0]);on(s,l,a),s[Qt]=i,s[ki]=a}catch(h){Ot(i,i.return,h)}}var pr=!1,Mi=!1,Rp=!1,by=typeof WeakSet=="function"?WeakSet:Set,qi=null;function Ik(i,s){if(i=i.containerInfo,Gp=Kd,i=To(i),Fl(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,E=-1,A=-1,Z=0,de=0,ge=i,J=null;t:for(;;){for(var oe;ge!==a||u!==0&&ge.nodeType!==3||(E=_+u),ge!==h||l!==0&&ge.nodeType!==3||(A=_+l),ge.nodeType===3&&(_+=ge.nodeValue.length),(oe=ge.firstChild)!==null;)J=ge,ge=oe;for(;;){if(ge===i)break t;if(J===a&&++Z===u&&(E=_),J===h&&++de===l&&(A=_),(oe=ge.nextSibling)!==null)break;ge=J,J=ge.parentNode}ge=oe}a=E===-1||A===-1?null:{start:E,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(Zp={focusedElem:i,selectionRange:a},Kd=!1,qi=s;qi!==null;)if(s=qi,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,qi=i;else for(;qi!==null;){switch(s=qi,h=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=s,u=h.memoizedProps,h=h.memoizedState,l=a.stateNode;try{var Pe=eo(a.type,u);i=l.getSnapshotBeforeUpdate(Pe,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Xe){Ot(a,a.return,Xe)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)em(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":em(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,qi=i;break}qi=s.return}}function yy(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:gr(i,a),l&4&&ac(5,a);break;case 1:if(gr(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(_){Ot(a,a.return,_)}else{var u=eo(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(u,s,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Ot(a,a.return,_)}}l&64&&py(a),l&512&&oc(a,a.return);break;case 3:if(gr(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{sb(i,s)}catch(_){Ot(a,a.return,_)}}break;case 27:s===null&&l&4&&_y(a);case 26:case 5:gr(i,a),s===null&&l&4&&gy(a),l&512&&oc(a,a.return);break;case 12:gr(i,a);break;case 31:gr(i,a),l&4&&Cy(i,a);break;case 13:gr(i,a),l&4&&xy(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Vk.bind(null,a),fE(i,a))));break;case 22:if(l=a.memoizedState!==null||pr,!l){s=s!==null&&s.memoizedState!==null||Mi,u=pr;var h=Mi;pr=l,(Mi=s)&&!h?vr(i,a,(a.subtreeFlags&8772)!==0):gr(i,a),pr=u,Mi=h}break;case 30:break;default:gr(i,a)}}function Sy(i){var s=i.alternate;s!==null&&(i.alternate=null,Sy(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&xs(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var ei=null,Rn=!1;function mr(i,s,a){for(a=a.child;a!==null;)wy(i,s,a),a=a.sibling}function wy(i,s,a){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(Je,a)}catch{}switch(a.tag){case 26:Mi||zs(a,s),mr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Mi||zs(a,s);var l=ei,u=Rn;ua(a.type)&&(ei=a.stateNode,Rn=!1),mr(i,s,a),gc(a.stateNode),ei=l,Rn=u;break;case 5:Mi||zs(a,s);case 6:if(l=ei,u=Rn,ei=null,mr(i,s,a),ei=l,Rn=u,ei!==null)if(Rn)try{(ei.nodeType===9?ei.body:ei.nodeName==="HTML"?ei.ownerDocument.body:ei).removeChild(a.stateNode)}catch(h){Ot(a,s,h)}else try{ei.removeChild(a.stateNode)}catch(h){Ot(a,s,h)}break;case 18:ei!==null&&(Rn?(i=ei,pS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),el(i)):pS(ei,a.stateNode));break;case 4:l=ei,u=Rn,ei=a.stateNode.containerInfo,Rn=!0,mr(i,s,a),ei=l,Rn=u;break;case 0:case 11:case 14:case 15:na(2,a,s),Mi||na(4,a,s),mr(i,s,a);break;case 1:Mi||(zs(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&my(a,s,l)),mr(i,s,a);break;case 21:mr(i,s,a);break;case 22:Mi=(l=Mi)||a.memoizedState!==null,mr(i,s,a),Mi=l;break;default:mr(i,s,a)}}function Cy(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{el(i)}catch(a){Ot(s,s.return,a)}}}function xy(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{el(i)}catch(a){Ot(s,s.return,a)}}function Pk(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new by),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new by),s;default:throw Error(r(435,i.tag))}}function wd(i,s){var a=Pk(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var u=Yk.bind(null,i,l);l.then(u,u)}})}function Mn(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],h=i,_=s,E=_;e:for(;E!==null;){switch(E.tag){case 27:if(ua(E.type)){ei=E.stateNode,Rn=!1;break e}break;case 5:ei=E.stateNode,Rn=!1;break e;case 3:case 4:ei=E.stateNode.containerInfo,Rn=!0;break e}E=E.return}if(ei===null)throw Error(r(160));wy(h,_,u),ei=null,Rn=!1,h=u.alternate,h!==null&&(h.return=null),u.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)ky(s,i),s=s.sibling}var ys=null;function ky(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Mn(s,i),Nn(i),l&4&&(na(3,i,i.return),ac(3,i),na(5,i,i.return));break;case 1:Mn(s,i),Nn(i),l&512&&(Mi||a===null||zs(a,a.return)),l&64&&pr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=ys;if(Mn(s,i),Nn(i),l&512&&(Mi||a===null||zs(a,a.return)),l&4){var h=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":h=u.getElementsByTagName("title")[0],(!h||h[Ys]||h[Qt]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=u.createElement(l),u.head.insertBefore(h,u.querySelector("head > title"))),on(h,l,a),h[Qt]=i,ai(h),l=h;break e;case"link":var _=kS("link","href",u).get(l+(a.href||""));if(_){for(var E=0;E<_.length;E++)if(h=_[E],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(E,1);break t}}h=u.createElement(l),on(h,l,a),u.head.appendChild(h);break;case"meta":if(_=kS("meta","content",u).get(l+(a.content||""))){for(E=0;E<_.length;E++)if(h=_[E],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(E,1);break t}}h=u.createElement(l),on(h,l,a),u.head.appendChild(h);break;default:throw Error(r(468,l))}h[Qt]=i,ai(h),l=h}i.stateNode=l}else ES(u,i.type,i.stateNode);else i.stateNode=xS(u,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?ES(u,i.type,i.stateNode):xS(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Ep(i,i.memoizedProps,a.memoizedProps)}break;case 27:Mn(s,i),Nn(i),l&512&&(Mi||a===null||zs(a,a.return)),a!==null&&l&4&&Ep(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Mn(s,i),Nn(i),l&512&&(Mi||a===null||zs(a,a.return)),i.flags&32){u=i.stateNode;try{Rs(u,"")}catch(Pe){Ot(i,i.return,Pe)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Ep(i,u,a!==null?a.memoizedProps:u)),l&1024&&(Rp=!0);break;case 6:if(Mn(s,i),Nn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Pe){Ot(i,i.return,Pe)}}break;case 3:if(Id=null,u=ys,ys=jd(s.containerInfo),Mn(s,i),ys=u,Nn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{el(s.containerInfo)}catch(Pe){Ot(i,i.return,Pe)}Rp&&(Rp=!1,Ey(i));break;case 4:l=ys,ys=jd(i.stateNode.containerInfo),Mn(s,i),Nn(i),ys=l;break;case 12:Mn(s,i),Nn(i);break;case 31:Mn(s,i),Nn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,wd(i,l)));break;case 13:Mn(s,i),Nn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(xd=Nt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,wd(i,l)));break;case 22:u=i.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,Z=pr,de=Mi;if(pr=Z||u,Mi=de||A,Mn(s,i),Mi=de,pr=Z,Nn(i),l&8192)e:for(s=i.stateNode,s._visibility=u?s._visibility&-2:s._visibility|1,u&&(a===null||A||pr||Mi||to(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){A=a=s;try{if(h=A.stateNode,u)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{E=A.stateNode;var ge=A.memoizedProps.style,J=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;E.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(Pe){Ot(A,A.return,Pe)}}}else if(s.tag===6){if(a===null){A=s;try{A.stateNode.nodeValue=u?"":A.memoizedProps}catch(Pe){Ot(A,A.return,Pe)}}}else if(s.tag===18){if(a===null){A=s;try{var oe=A.stateNode;u?mS(oe,!0):mS(A.stateNode,!1)}catch(Pe){Ot(A,A.return,Pe)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,wd(i,a))));break;case 19:Mn(s,i),Nn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,wd(i,l)));break;case 30:break;case 21:break;default:Mn(s,i),Nn(i)}}function Nn(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(vy(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var u=a.stateNode,h=Tp(i);Sd(i,h,u);break;case 5:var _=a.stateNode;a.flags&32&&(Rs(_,""),a.flags&=-33);var E=Tp(i);Sd(i,E,_);break;case 3:case 4:var A=a.stateNode.containerInfo,Z=Tp(i);Dp(i,Z,A);break;default:throw Error(r(161))}}catch(de){Ot(i,i.return,de)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function Ey(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;Ey(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function gr(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)yy(i,s.alternate,s),s=s.sibling}function to(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:na(4,s,s.return),to(s);break;case 1:zs(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&my(s,s.return,a),to(s);break;case 27:gc(s.stateNode);case 26:case 5:zs(s,s.return),to(s);break;case 22:s.memoizedState===null&&to(s);break;case 30:to(s);break;default:to(s)}i=i.sibling}}function vr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,u=i,h=s,_=h.flags;switch(h.tag){case 0:case 11:case 15:vr(u,h,a),ac(4,h);break;case 1:if(vr(u,h,a),l=h,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(Z){Ot(l,l.return,Z)}if(l=h,u=l.updateQueue,u!==null){var E=l.stateNode;try{var A=u.shared.hiddenCallbacks;if(A!==null)for(u.shared.hiddenCallbacks=null,u=0;u<A.length;u++)nb(A[u],E)}catch(Z){Ot(l,l.return,Z)}}a&&_&64&&py(h),oc(h,h.return);break;case 27:_y(h);case 26:case 5:vr(u,h,a),a&&l===null&&_&4&&gy(h),oc(h,h.return);break;case 12:vr(u,h,a);break;case 31:vr(u,h,a),a&&_&4&&Cy(u,h);break;case 13:vr(u,h,a),a&&_&4&&xy(u,h);break;case 22:h.memoizedState===null&&vr(u,h,a),oc(h,h.return);break;case 30:break;default:vr(u,h,a)}s=s.sibling}}function Mp(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Vl(a))}function Np(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Vl(i))}function Ss(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Ty(i,s,a,l),s=s.sibling}function Ty(i,s,a,l){var u=s.flags;switch(s.tag){case 0:case 11:case 15:Ss(i,s,a,l),u&2048&&ac(9,s);break;case 1:Ss(i,s,a,l);break;case 3:Ss(i,s,a,l),u&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&Vl(i)));break;case 12:if(u&2048){Ss(i,s,a,l),i=s.stateNode;try{var h=s.memoizedProps,_=h.id,E=h.onPostCommit;typeof E=="function"&&E(_,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(A){Ot(s,s.return,A)}}else Ss(i,s,a,l);break;case 31:Ss(i,s,a,l);break;case 13:Ss(i,s,a,l);break;case 23:break;case 22:h=s.stateNode,_=s.alternate,s.memoizedState!==null?h._visibility&2?Ss(i,s,a,l):lc(i,s):h._visibility&2?Ss(i,s,a,l):(h._visibility|=2,Fo(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),u&2048&&Mp(_,s);break;case 24:Ss(i,s,a,l),u&2048&&Np(s.alternate,s);break;default:Ss(i,s,a,l)}}function Fo(i,s,a,l,u){for(u=u&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var h=i,_=s,E=a,A=l,Z=_.flags;switch(_.tag){case 0:case 11:case 15:Fo(h,_,E,A,u),ac(8,_);break;case 23:break;case 22:var de=_.stateNode;_.memoizedState!==null?de._visibility&2?Fo(h,_,E,A,u):lc(h,_):(de._visibility|=2,Fo(h,_,E,A,u)),u&&Z&2048&&Mp(_.alternate,_);break;case 24:Fo(h,_,E,A,u),u&&Z&2048&&Np(_.alternate,_);break;default:Fo(h,_,E,A,u)}s=s.sibling}}function lc(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,u=l.flags;switch(l.tag){case 22:lc(a,l),u&2048&&Mp(l.alternate,l);break;case 24:lc(a,l),u&2048&&Np(l.alternate,l);break;default:lc(a,l)}s=s.sibling}}var cc=8192;function Wo(i,s,a){if(i.subtreeFlags&cc)for(i=i.child;i!==null;)Dy(i,s,a),i=i.sibling}function Dy(i,s,a){switch(i.tag){case 26:Wo(i,s,a),i.flags&cc&&i.memoizedState!==null&&kE(a,ys,i.memoizedState,i.memoizedProps);break;case 5:Wo(i,s,a);break;case 3:case 4:var l=ys;ys=jd(i.stateNode.containerInfo),Wo(i,s,a),ys=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=cc,cc=16777216,Wo(i,s,a),cc=l):Wo(i,s,a));break;default:Wo(i,s,a)}}function Ry(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function uc(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];qi=l,Ny(l,i)}Ry(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)My(i),i=i.sibling}function My(i){switch(i.tag){case 0:case 11:case 15:uc(i),i.flags&2048&&na(9,i,i.return);break;case 3:uc(i);break;case 12:uc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,Cd(i)):uc(i);break;default:uc(i)}}function Cd(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];qi=l,Ny(l,i)}Ry(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:na(8,s,s.return),Cd(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,Cd(s));break;default:Cd(s)}i=i.sibling}}function Ny(i,s){for(;qi!==null;){var a=qi;switch(a.tag){case 0:case 11:case 15:na(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:Vl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,qi=l;else e:for(a=i;qi!==null;){l=qi;var u=l.sibling,h=l.return;if(Sy(l),l===a){qi=null;break e}if(u!==null){u.return=h,qi=u;break e}qi=h}}}var Hk={getCacheForType:function(i){var s=rn(Ti),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return rn(Ti).controller.signal}},Uk=typeof WeakMap=="function"?WeakMap:Map,Dt=0,Ft=null,_t=null,yt=0,Lt=0,Kn=null,sa=!1,$o=!1,Ap=!1,_r=0,ui=0,ra=0,io=0,Lp=0,Fn=0,qo=0,dc=null,An=null,Op=!1,xd=0,Ay=0,kd=1/0,Ed=null,aa=null,zi=0,oa=null,Vo=null,br=0,Bp=0,jp=null,Ly=null,hc=0,zp=null;function Wn(){return(Dt&2)!==0&&yt!==0?yt&-yt:L.T!==null?Fp():vi()}function Oy(){if(Fn===0)if((yt&536870912)===0||Ct){var i=Ge;Ge<<=1,(Ge&3932160)===0&&(Ge=262144),Fn=i}else Fn=536870912;return i=Hn.current,i!==null&&(i.flags|=32),Fn}function Ln(i,s,a){(i===Ft&&(Lt===2||Lt===9)||i.cancelPendingCommit!==null)&&(Yo(i,0),la(i,yt,Fn,!1)),Yt(i,a),((Dt&2)===0||i!==Ft)&&(i===Ft&&((Dt&2)===0&&(io|=a),ui===4&&la(i,yt,Fn,!1)),Is(i))}function By(i,s,a){if((Dt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||qt(i,s),u=l?Wk(i,s):Pp(i,s,!0),h=l;do{if(u===0){$o&&!l&&la(i,s,0,!1);break}else{if(a=i.current.alternate,h&&!Kk(a)){u=Pp(i,s,!1),h=!1;continue}if(u===2){if(h=s,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var E=i;u=dc;var A=E.current.memoizedState.isDehydrated;if(A&&(Yo(E,_).flags|=256),_=Pp(E,_,!1),_!==2){if(Ap&&!A){E.errorRecoveryDisabledLanes|=h,io|=h,u=4;break e}h=An,An=u,h!==null&&(An===null?An=h:An.push.apply(An,h))}u=_}if(h=!1,u!==2)continue}}if(u===1){Yo(i,0),la(i,s,0,!0);break}e:{switch(l=i,h=u,h){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:la(l,s,Fn,!sa);break e;case 2:An=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(u=xd+300-Nt(),10<u)){if(la(l,s,Fn,!sa),jt(l,0,!0)!==0)break e;br=s,l.timeoutHandle=hS(jy.bind(null,l,a,An,Ed,Op,s,Fn,io,qo,sa,h,"Throttled",-0,0),u);break e}jy(l,a,An,Ed,Op,s,Fn,io,qo,sa,h,null,-0,0)}}break}while(!0);Is(i)}function jy(i,s,a,l,u,h,_,E,A,Z,de,ge,J,oe){if(i.timeoutHandle=-1,ge=s.subtreeFlags,ge&8192||(ge&16785408)===16785408){ge={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Jt},Dy(s,h,ge);var Pe=(h&62914560)===h?xd-Nt():(h&4194048)===h?Ay-Nt():0;if(Pe=EE(ge,Pe),Pe!==null){br=h,i.cancelPendingCommit=Pe(Wy.bind(null,i,s,h,a,l,u,_,E,A,de,ge,null,J,oe)),la(i,h,_,!Z);return}}Wy(i,s,h,a,l,u,_,E,A)}function Kk(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],h=u.getSnapshot;u=u.value;try{if(!hn(h(),u))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function la(i,s,a,l){s&=~Lp,s&=~io,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var u=s;0<u;){var h=31-ft(u),_=1<<h;l[h]=-1,u&=~_}a!==0&&mi(i,a,s)}function Td(){return(Dt&6)===0?(fc(0),!1):!0}function Ip(){if(_t!==null){if(Lt===0)var i=_t.return;else i=_t,lr=Va=null,ep(i),Io=null,Xl=0,i=_t;for(;i!==null;)fy(i.alternate,i),i=i.return;_t=null}}function Yo(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,lE(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),br=0,Ip(),Ft=i,_t=a=ar(i.current,null),yt=s,Lt=0,Kn=null,sa=!1,$o=qt(i,s),Ap=!1,qo=Fn=Lp=io=ra=ui=0,An=dc=null,Op=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var u=31-ft(l),h=1<<u;s|=i[u],l&=~h}return _r=s,Yu(),a}function zy(i,s){lt=null,L.H=nc,s===zo||s===id?(s=J_(),Lt=3):s===Kf?(s=J_(),Lt=4):Lt=s===gp?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Kn=s,_t===null&&(ui=1,gd(i,ts(s,i.current)))}function Iy(){var i=Hn.current;return i===null?!0:(yt&4194048)===yt?rs===null:(yt&62914560)===yt||(yt&536870912)!==0?i===rs:!1}function Py(){var i=L.H;return L.H=nc,i===null?nc:i}function Hy(){var i=L.A;return L.A=Hk,i}function Dd(){ui=4,sa||(yt&4194048)!==yt&&Hn.current!==null||($o=!0),(ra&134217727)===0&&(io&134217727)===0||Ft===null||la(Ft,yt,Fn,!1)}function Pp(i,s,a){var l=Dt;Dt|=2;var u=Py(),h=Hy();(Ft!==i||yt!==s)&&(Ed=null,Yo(i,s)),s=!1;var _=ui;e:do try{if(Lt!==0&&_t!==null){var E=_t,A=Kn;switch(Lt){case 8:Ip(),_=6;break e;case 3:case 2:case 9:case 6:Hn.current===null&&(s=!0);var Z=Lt;if(Lt=0,Kn=null,Xo(i,E,A,Z),a&&$o){_=0;break e}break;default:Z=Lt,Lt=0,Kn=null,Xo(i,E,A,Z)}}Fk(),_=ui;break}catch(de){zy(i,de)}while(!0);return s&&i.shellSuspendCounter++,lr=Va=null,Dt=l,L.H=u,L.A=h,_t===null&&(Ft=null,yt=0,Yu()),_}function Fk(){for(;_t!==null;)Uy(_t)}function Wk(i,s){var a=Dt;Dt|=2;var l=Py(),u=Hy();Ft!==i||yt!==s?(Ed=null,kd=Nt()+500,Yo(i,s)):$o=qt(i,s);e:do try{if(Lt!==0&&_t!==null){s=_t;var h=Kn;t:switch(Lt){case 1:Lt=0,Kn=null,Xo(i,s,h,1);break;case 2:case 9:if(Z_(h)){Lt=0,Kn=null,Ky(s);break}s=function(){Lt!==2&&Lt!==9||Ft!==i||(Lt=7),Is(i)},h.then(s,s);break e;case 3:Lt=7;break e;case 4:Lt=5;break e;case 7:Z_(h)?(Lt=0,Kn=null,Ky(s)):(Lt=0,Kn=null,Xo(i,s,h,7));break;case 5:var _=null;switch(_t.tag){case 26:_=_t.memoizedState;case 5:case 27:var E=_t;if(_?TS(_):E.stateNode.complete){Lt=0,Kn=null;var A=E.sibling;if(A!==null)_t=A;else{var Z=E.return;Z!==null?(_t=Z,Rd(Z)):_t=null}break t}}Lt=0,Kn=null,Xo(i,s,h,5);break;case 6:Lt=0,Kn=null,Xo(i,s,h,6);break;case 8:Ip(),ui=6;break e;default:throw Error(r(462))}}$k();break}catch(de){zy(i,de)}while(!0);return lr=Va=null,L.H=l,L.A=u,Dt=a,_t!==null?0:(Ft=null,yt=0,Yu(),ui)}function $k(){for(;_t!==null&&!st();)Uy(_t)}function Uy(i){var s=dy(i.alternate,i,_r);i.memoizedProps=i.pendingProps,s===null?Rd(i):_t=s}function Ky(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=ry(a,s,s.pendingProps,s.type,void 0,yt);break;case 11:s=ry(a,s,s.pendingProps,s.type.render,s.ref,yt);break;case 5:ep(s);default:fy(a,s),s=_t=H_(s,_r),s=dy(a,s,_r)}i.memoizedProps=i.pendingProps,s===null?Rd(i):_t=s}function Xo(i,s,a,l){lr=Va=null,ep(s),Io=null,Xl=0;var u=s.return;try{if(Lk(i,u,s,a,yt)){ui=1,gd(i,ts(a,i.current)),_t=null;return}}catch(h){if(u!==null)throw _t=u,h;ui=1,gd(i,ts(a,i.current)),_t=null;return}s.flags&32768?(Ct||l===1?i=!0:$o||(yt&536870912)!==0?i=!1:(sa=i=!0,(l===2||l===9||l===3||l===6)&&(l=Hn.current,l!==null&&l.tag===13&&(l.flags|=16384))),Fy(s,i)):Rd(s)}function Rd(i){var s=i;do{if((s.flags&32768)!==0){Fy(s,sa);return}i=s.return;var a=jk(s.alternate,s,_r);if(a!==null){_t=a;return}if(s=s.sibling,s!==null){_t=s;return}_t=s=i}while(s!==null);ui===0&&(ui=5)}function Fy(i,s){do{var a=zk(i.alternate,i);if(a!==null){a.flags&=32767,_t=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){_t=i;return}_t=i=a}while(i!==null);ui=6,_t=null}function Wy(i,s,a,l,u,h,_,E,A){i.cancelPendingCommit=null;do Md();while(zi!==0);if((Dt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(h=s.lanes|s.childLanes,h|=Tf,ii(i,a,h,_,E,A),i===Ft&&(_t=Ft=null,yt=0),Vo=s,oa=i,br=a,Bp=h,jp=u,Ly=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Xk(Qe,function(){return Xy(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=L.T,L.T=null,u=R.p,R.p=2,_=Dt,Dt|=4;try{Ik(i,s,a)}finally{Dt=_,R.p=u,L.T=l}}zi=1,$y(),qy(),Vy()}}function $y(){if(zi===1){zi=0;var i=oa,s=Vo,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=L.T,L.T=null;var l=R.p;R.p=2;var u=Dt;Dt|=4;try{ky(s,i);var h=Zp,_=To(i.containerInfo),E=h.focusedElem,A=h.selectionRange;if(_!==E&&E&&E.ownerDocument&&Wu(E.ownerDocument.documentElement,E)){if(A!==null&&Fl(E)){var Z=A.start,de=A.end;if(de===void 0&&(de=Z),"selectionStart"in E)E.selectionStart=Z,E.selectionEnd=Math.min(de,E.value.length);else{var ge=E.ownerDocument||document,J=ge&&ge.defaultView||window;if(J.getSelection){var oe=J.getSelection(),Pe=E.textContent.length,Xe=Math.min(A.start,Pe),Pt=A.end===void 0?Xe:Math.min(A.end,Pe);!oe.extend&&Xe>Pt&&(_=Pt,Pt=Xe,Xe=_);var U=Fu(E,Xe),P=Fu(E,Pt);if(U&&P&&(oe.rangeCount!==1||oe.anchorNode!==U.node||oe.anchorOffset!==U.offset||oe.focusNode!==P.node||oe.focusOffset!==P.offset)){var X=ge.createRange();X.setStart(U.node,U.offset),oe.removeAllRanges(),Xe>Pt?(oe.addRange(X),oe.extend(P.node,P.offset)):(X.setEnd(P.node,P.offset),oe.addRange(X))}}}}for(ge=[],oe=E;oe=oe.parentNode;)oe.nodeType===1&&ge.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<ge.length;E++){var pe=ge[E];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}Kd=!!Gp,Zp=Gp=null}finally{Dt=u,R.p=l,L.T=a}}i.current=s,zi=2}}function qy(){if(zi===2){zi=0;var i=oa,s=Vo,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=L.T,L.T=null;var l=R.p;R.p=2;var u=Dt;Dt|=4;try{yy(i,s.alternate,s)}finally{Dt=u,R.p=l,L.T=a}}zi=3}}function Vy(){if(zi===4||zi===3){zi=0,ot();var i=oa,s=Vo,a=br,l=Ly;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?zi=5:(zi=0,Vo=oa=null,Yy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(aa=null),gi(a),s=s.stateNode,et&&typeof et.onCommitFiberRoot=="function")try{et.onCommitFiberRoot(Je,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=L.T,u=R.p,R.p=2,L.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var E=l[_];h(E.value,{componentStack:E.stack})}}finally{L.T=s,R.p=u}}(br&3)!==0&&Md(),Is(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===zp?hc++:(hc=0,zp=i):hc=0,fc(0)}}function Yy(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,Vl(s)))}function Md(){return $y(),qy(),Vy(),Xy()}function Xy(){if(zi!==5)return!1;var i=oa,s=Bp;Bp=0;var a=gi(br),l=L.T,u=R.p;try{R.p=32>a?32:a,L.T=null,a=jp,jp=null;var h=oa,_=br;if(zi=0,Vo=oa=null,br=0,(Dt&6)!==0)throw Error(r(331));var E=Dt;if(Dt|=4,My(h.current),Ty(h,h.current,_,a),Dt=E,fc(0,!1),et&&typeof et.onPostCommitFiberRoot=="function")try{et.onPostCommitFiberRoot(Je,h)}catch{}return!0}finally{R.p=u,L.T=l,Yy(i,s)}}function Gy(i,s,a){s=ts(a,s),s=mp(i.stateNode,s,2),i=ea(i,s,2),i!==null&&(Yt(i,2),Is(i))}function Ot(i,s,a){if(i.tag===3)Gy(i,i,a);else for(;s!==null;){if(s.tag===3){Gy(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(aa===null||!aa.has(l))){i=ts(a,i),a=Zb(2),l=ea(s,a,2),l!==null&&(Qb(a,l,s,i),Yt(l,2),Is(l));break}}s=s.return}}function Hp(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new Uk;var u=new Set;l.set(s,u)}else u=l.get(s),u===void 0&&(u=new Set,l.set(s,u));u.has(a)||(Ap=!0,u.add(a),i=qk.bind(null,i,s,a),s.then(i,i))}function qk(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Ft===i&&(yt&a)===a&&(ui===4||ui===3&&(yt&62914560)===yt&&300>Nt()-xd?(Dt&2)===0&&Yo(i,0):Lp|=a,qo===yt&&(qo=0)),Is(i)}function Zy(i,s){s===0&&(s=$t()),i=Wa(i,s),i!==null&&(Yt(i,s),Is(i))}function Vk(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),Zy(i,a)}function Yk(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),Zy(i,a)}function Xk(i,s){return Oe(i,s)}var Nd=null,Go=null,Up=!1,Ad=!1,Kp=!1,ca=0;function Is(i){i!==Go&&i.next===null&&(Go===null?Nd=Go=i:Go=Go.next=i),Ad=!0,Up||(Up=!0,Zk())}function fc(i,s){if(!Kp&&Ad){Kp=!0;do for(var a=!1,l=Nd;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var h=0;else{var _=l.suspendedLanes,E=l.pingedLanes;h=(1<<31-ft(42|i)+1)-1,h&=u&~(_&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,tS(l,h))}else h=yt,h=jt(l,l===Ft?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||qt(l,h)||(a=!0,tS(l,h));l=l.next}while(a);Kp=!1}}function Gk(){Qy()}function Qy(){Ad=Up=!1;var i=0;ca!==0&&oE()&&(i=ca);for(var s=Nt(),a=null,l=Nd;l!==null;){var u=l.next,h=Jy(l,s);h===0?(l.next=null,a===null?Nd=u:a.next=u,u===null&&(Go=a)):(a=l,(i!==0||(h&3)!==0)&&(Ad=!0)),l=u}zi!==0&&zi!==5||fc(i),ca!==0&&(ca=0)}function Jy(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-ft(h),E=1<<_,A=u[_];A===-1?((E&a)===0||(E&l)!==0)&&(u[_]=Vt(E,s)):A<=s&&(i.expiredLanes|=E),h&=~E}if(s=Ft,a=yt,a=jt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Lt===2||Lt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ie(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||qt(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&Ie(l),gi(a)){case 2:case 8:a=Rt;break;case 32:a=Qe;break;case 268435456:a=Bt;break;default:a=Qe}return l=eS.bind(null,i),a=Oe(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&Ie(l),i.callbackPriority=2,i.callbackNode=null,2}function eS(i,s){if(zi!==0&&zi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Md()&&i.callbackNode!==a)return null;var l=yt;return l=jt(i,i===Ft?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(By(i,l,s),Jy(i,Nt()),i.callbackNode!=null&&i.callbackNode===a?eS.bind(null,i):null)}function tS(i,s){if(Md())return null;By(i,s,!0)}function Zk(){cE(function(){(Dt&6)!==0?Oe(Cn,Gk):Qy()})}function Fp(){if(ca===0){var i=Bo;i===0&&(i=Ke,Ke<<=1,(Ke&261888)===0&&(Ke=256)),ca=i}return ca}function iS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Ia(""+i)}function nS(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function Qk(i,s,a,l,u){if(s==="submit"&&a&&a.stateNode===u){var h=iS((u[ki]||null).action),_=l.submitter;_&&(s=(s=_[ki]||null)?iS(s.formAction):_.getAttribute("formAction"),s!==null&&(h=s,_=null));var E=new k("action","action",null,l,u);i.push({event:E,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ca!==0){var A=_?nS(u,_):new FormData(u);cp(a,{pending:!0,data:A,method:u.method,action:h},null,A)}}else typeof h=="function"&&(E.preventDefault(),A=_?nS(u,_):new FormData(u),cp(a,{pending:!0,data:A,method:u.method,action:h},h,A))},currentTarget:u}]})}}for(var Wp=0;Wp<Ef.length;Wp++){var $p=Ef[Wp],Jk=$p.toLowerCase(),eE=$p[0].toUpperCase()+$p.slice(1);bs(Jk,"on"+eE)}bs(At,"onAnimationEnd"),bs(Mt,"onAnimationIteration"),bs(_s,"onAnimationStart"),bs("dblclick","onDoubleClick"),bs("focusin","onFocus"),bs("focusout","onBlur"),bs(Do,"onTransitionRun"),bs(Os,"onTransitionStart"),bs(qu,"onTransitionCancel"),bs(Wl,"onTransitionEnd"),_i("onMouseEnter",["mouseout","mouseover"]),_i("onMouseLeave",["mouseout","mouseover"]),_i("onPointerEnter",["pointerout","pointerover"]),_i("onPointerLeave",["pointerout","pointerover"]),zn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),zn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),zn("onBeforeInput",["compositionend","keypress","textInput","paste"]),zn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var pc="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(" "),tE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(pc));function sS(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var h=void 0;if(s)for(var _=l.length-1;0<=_;_--){var E=l[_],A=E.instance,Z=E.currentTarget;if(E=E.listener,A!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Z;try{h(u)}catch(de){Vu(de)}u.currentTarget=null,h=A}else for(_=0;_<l.length;_++){if(E=l[_],A=E.instance,Z=E.currentTarget,E=E.listener,A!==h&&u.isPropagationStopped())break e;h=E,u.currentTarget=Z;try{h(u)}catch(de){Vu(de)}u.currentTarget=null,h=A}}}}function bt(i,s){var a=s[Oa];a===void 0&&(a=s[Oa]=new Set);var l=i+"__bubble";a.has(l)||(rS(s,i,2,!1),a.add(l))}function qp(i,s,a){var l=0;s&&(l|=4),rS(a,i,l,s)}var Ld="_reactListening"+Math.random().toString(36).slice(2);function Vp(i){if(!i[Ld]){i[Ld]=!0,Or.forEach(function(a){a!=="selectionchange"&&(tE.has(a)||qp(a,!1,i),qp(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[Ld]||(s[Ld]=!0,qp("selectionchange",!1,s))}}function rS(i,s,a,l){switch(OS(s)){case 2:var u=RE;break;case 8:u=ME;break;default:u=lm}a=u.bind(null,s,a,i),u=void 0,!Pa||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(s,a,{capture:!0,passive:u}):i.addEventListener(s,a,!0):u!==void 0?i.addEventListener(s,a,{passive:u}):i.addEventListener(s,a,!1)}function Yp(i,s,a,l,u){var h=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var E=l.stateNode.containerInfo;if(E===u)break;if(_===4)for(_=l.return;_!==null;){var A=_.tag;if((A===3||A===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;E!==null;){if(_=ks(E),_===null)return;if(A=_.tag,A===5||A===6||A===26||A===27){l=h=_;continue e}E=E.parentNode}}l=l.return}Ns(function(){var Z=h,de=Js(a),ge=[];e:{var J=I_.get(i);if(J!==void 0){var oe=k,Pe=i;switch(i){case"keypress":if(As(a)===0)break e;case"keydown":case"keyup":oe=Mu;break;case"focusin":Pe="focus",oe=Fr;break;case"focusout":Pe="blur",oe=Fr;break;case"beforeblur":case"afterblur":oe=Fr;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":oe=Ve;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=li;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=Au;break;case At:case Mt:case _s:oe=Wr;break;case Wl:oe=Al;break;case"scroll":case"scrollend":oe=I;break;case"wheel":oe=yf;break;case"copy":case"cut":case"paste":oe=$i;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=Nl;break;case"toggle":case"beforetoggle":oe=Ll}var Xe=(s&4)!==0,Pt=!Xe&&(i==="scroll"||i==="scrollend"),U=Xe?J!==null?J+"Capture":null:J;Xe=[];for(var P=Z,X;P!==null;){var pe=P;if(X=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||X===null||U===null||(pe=nn(P,U),pe!=null&&Xe.push(mc(P,pe,X))),Pt)break;P=P.return}0<Xe.length&&(J=new oe(J,Pe,null,a,de),ge.push({event:J,listeners:Xe}))}}if((s&7)===0){e:{if(J=i==="mouseover"||i==="pointerover",oe=i==="mouseout"||i==="pointerout",J&&a!==Ms&&(Pe=a.relatedTarget||a.fromElement)&&(ks(Pe)||Pe[Xn]))break e;if((oe||J)&&(J=de.window===de?de:(J=de.ownerDocument)?J.defaultView||J.parentWindow:window,oe?(Pe=a.relatedTarget||a.toElement,oe=Z,Pe=Pe?ks(Pe):null,Pe!==null&&(Pt=c(Pe),Xe=Pe.tag,Pe!==Pt||Xe!==5&&Xe!==27&&Xe!==6)&&(Pe=null)):(oe=null,Pe=Z),oe!==Pe)){if(Xe=Ve,pe="onMouseLeave",U="onMouseEnter",P="mouse",(i==="pointerout"||i==="pointerover")&&(Xe=Nl,pe="onPointerLeave",U="onPointerEnter",P="pointer"),Pt=oe==null?J:Es(oe),X=Pe==null?J:Es(Pe),J=new Xe(pe,P+"leave",oe,a,de),J.target=Pt,J.relatedTarget=X,pe=null,ks(de)===Z&&(Xe=new Xe(U,P+"enter",Pe,a,de),Xe.target=X,Xe.relatedTarget=Pt,pe=Xe),Pt=pe,oe&&Pe)t:{for(Xe=iE,U=oe,P=Pe,X=0,pe=U;pe;pe=Xe(pe))X++;pe=0;for(var $e=P;$e;$e=Xe($e))pe++;for(;0<X-pe;)U=Xe(U),X--;for(;0<pe-X;)P=Xe(P),pe--;for(;X--;){if(U===P||P!==null&&U===P.alternate){Xe=U;break t}U=Xe(U),P=Xe(P)}Xe=null}else Xe=null;oe!==null&&aS(ge,J,oe,Xe,!1),Pe!==null&&Pt!==null&&aS(ge,Pt,Pe,Xe,!0)}}e:{if(J=Z?Es(Z):window,oe=J.nodeName&&J.nodeName.toLowerCase(),oe==="select"||oe==="input"&&J.type==="file")var Et=Pu;else if(Il(J))if(Hl)Et=xf;else{Et=rr;var Ue=wf}else oe=J.nodeName,!oe||oe.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?Z&&Hr(Z.elementType)&&(Et=Pu):Et=Cf;if(Et&&(Et=Et(i,Z))){Pl(ge,Et,a,de);break e}Ue&&Ue(i,J,Z),i==="focusout"&&Z&&J.type==="number"&&Z.memoizedProps.value!=null&&kn(J,"number",J.value)}switch(Ue=Z?Es(Z):window,i){case"focusin":(Il(Ue)||Ue.contentEditable==="true")&&(S=Ue,z=Z,Ce=null);break;case"focusout":Ce=z=S=null;break;case"mousedown":Fe=!0;break;case"contextmenu":case"mouseup":case"dragend":Fe=!1,Ye(ge,a,de);break;case"selectionchange":if($u)break;case"keydown":case"keyup":Ye(ge,a,de)}var dt;if(Ua)e:{switch(i){case"compositionstart":var St="onCompositionStart";break e;case"compositionend":St="onCompositionEnd";break e;case"compositionupdate":St="onCompositionUpdate";break e}St=void 0}else qr?Bu(i,a)&&(St="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(St="onCompositionStart");St&&(Bl&&a.locale!=="ko"&&(qr||St!=="onCompositionStart"?St==="onCompositionEnd"&&qr&&(dt=nr()):(dn=de,tr="value"in dn?dn.value:dn.textContent,qr=!0)),Ue=Od(Z,St),0<Ue.length&&(St=new Ha(St,i,null,a,de),ge.push({event:St,listeners:Ue}),dt?St.data=dt:(dt=ju(a),dt!==null&&(St.data=dt)))),(dt=Lu?zu(i,a):zl(i,a))&&(St=Od(Z,"onBeforeInput"),0<St.length&&(Ue=new Ha("onBeforeInput","beforeinput",null,a,de),ge.push({event:Ue,listeners:St}),Ue.data=dt)),Qk(ge,i,Z,a,de)}sS(ge,s)})}function mc(i,s,a){return{instance:i,listener:s,currentTarget:a}}function Od(i,s){for(var a=s+"Capture",l=[];i!==null;){var u=i,h=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||h===null||(u=nn(i,a),u!=null&&l.unshift(mc(i,u,h)),u=nn(i,s),u!=null&&l.push(mc(i,u,h))),i.tag===3)return l;i=i.return}return[]}function iE(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function aS(i,s,a,l,u){for(var h=s._reactName,_=[];a!==null&&a!==l;){var E=a,A=E.alternate,Z=E.stateNode;if(E=E.tag,A!==null&&A===l)break;E!==5&&E!==26&&E!==27||Z===null||(A=Z,u?(Z=nn(a,h),Z!=null&&_.unshift(mc(a,Z,A))):u||(Z=nn(a,h),Z!=null&&_.push(mc(a,Z,A)))),a=a.return}_.length!==0&&i.push({event:s,listeners:_})}var nE=/\r\n?/g,sE=/\u0000|\uFFFD/g;function oS(i){return(typeof i=="string"?i:""+i).replace(nE,`
|
|
10
|
+
`).replace(sE,"")}function lS(i,s){return s=oS(s),oS(i)===s}function It(i,s,a,l,u,h){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||Rs(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&Rs(i,""+l);break;case"className":Ds(i,"class",l);break;case"tabIndex":Ds(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Ds(i,a,l);break;case"style":za(i,l,h);break;case"data":if(s!=="object"){Ds(i,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Ia(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(s!=="input"&&It(i,s,"name",u.name,u,null),It(i,s,"formEncType",u.formEncType,u,null),It(i,s,"formMethod",u.formMethod,u,null),It(i,s,"formTarget",u.formTarget,u,null)):(It(i,s,"encType",u.encType,u,null),It(i,s,"method",u.method,u,null),It(i,s,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Ia(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Jt);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=Ia(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":bt("beforetoggle",i),bt("toggle",i),Gs(i,"popover",l);break;case"xlinkActuate":vn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":vn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":vn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":vn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":vn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":vn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":vn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":vn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":vn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Gs(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Rl.get(a)||a,Gs(i,a,l))}}function Xp(i,s,a,l,u,h){switch(a){case"style":za(i,l,h);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Rs(i,l):(typeof l=="number"||typeof l=="bigint")&&Rs(i,""+l);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Jt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!oi.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),s=a.slice(2,u?a.length-7:void 0),h=i[ki]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(s,h,u),typeof l=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Gs(i,a,l)}}}function on(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",i),bt("load",i);var l=!1,u=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:It(i,s,h,_,a,null)}}u&&It(i,s,"srcSet",a.srcSet,a,null),l&&It(i,s,"src",a.src,a,null);return;case"input":bt("invalid",i);var E=h=_=u=null,A=null,Z=null;for(l in a)if(a.hasOwnProperty(l)){var de=a[l];if(de!=null)switch(l){case"name":u=de;break;case"type":_=de;break;case"checked":A=de;break;case"defaultChecked":Z=de;break;case"value":h=de;break;case"defaultValue":E=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(137,s));break;default:It(i,s,l,de,a,null)}}zr(i,h,E,A,Z,_,u,!1);return;case"select":bt("invalid",i),l=_=h=null;for(u in a)if(a.hasOwnProperty(u)&&(E=a[u],E!=null))switch(u){case"value":h=E;break;case"defaultValue":_=E;break;case"multiple":l=E;default:It(i,s,u,E,a,null)}s=h,a=_,i.multiple=!!l,s!=null?Zn(i,!!l,s,!1):a!=null&&Zn(i,!!l,a,!0);return;case"textarea":bt("invalid",i),h=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(E=a[_],E!=null))switch(_){case"value":l=E;break;case"defaultValue":u=E;break;case"children":h=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(r(91));break;default:It(i,s,_,E,a,null)}Qn(i,l,u,h);return;case"option":for(A in a)a.hasOwnProperty(A)&&(l=a[A],l!=null)&&(A==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":It(i,s,A,l,a,null));return;case"dialog":bt("beforetoggle",i),bt("toggle",i),bt("cancel",i),bt("close",i);break;case"iframe":case"object":bt("load",i);break;case"video":case"audio":for(l=0;l<pc.length;l++)bt(pc[l],i);break;case"image":bt("error",i),bt("load",i);break;case"details":bt("toggle",i);break;case"embed":case"source":case"link":bt("error",i),bt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in a)if(a.hasOwnProperty(Z)&&(l=a[Z],l!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:It(i,s,Z,l,a,null)}return;default:if(Hr(s)){for(de in a)a.hasOwnProperty(de)&&(l=a[de],l!==void 0&&Xp(i,s,de,l,a,void 0));return}}for(E in a)a.hasOwnProperty(E)&&(l=a[E],l!=null&&It(i,s,E,l,a,null))}function rE(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,h=null,_=null,E=null,A=null,Z=null,de=null;for(oe in a){var ge=a[oe];if(a.hasOwnProperty(oe)&&ge!=null)switch(oe){case"checked":break;case"value":break;case"defaultValue":A=ge;default:l.hasOwnProperty(oe)||It(i,s,oe,null,l,ge)}}for(var J in l){var oe=l[J];if(ge=a[J],l.hasOwnProperty(J)&&(oe!=null||ge!=null))switch(J){case"type":h=oe;break;case"name":u=oe;break;case"checked":Z=oe;break;case"defaultChecked":de=oe;break;case"value":_=oe;break;case"defaultValue":E=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,s));break;default:oe!==ge&&It(i,s,J,oe,l,ge)}}ct(i,_,E,A,Z,de,h,u);return;case"select":oe=_=E=J=null;for(h in a)if(A=a[h],a.hasOwnProperty(h)&&A!=null)switch(h){case"value":break;case"multiple":oe=A;default:l.hasOwnProperty(h)||It(i,s,h,null,l,A)}for(u in l)if(h=l[u],A=a[u],l.hasOwnProperty(u)&&(h!=null||A!=null))switch(u){case"value":J=h;break;case"defaultValue":E=h;break;case"multiple":_=h;default:h!==A&&It(i,s,u,h,l,A)}s=E,a=_,l=oe,J!=null?Zn(i,!!a,J,!1):!!l!=!!a&&(s!=null?Zn(i,!!a,s,!0):Zn(i,!!a,a?[]:"",!1));return;case"textarea":oe=J=null;for(E in a)if(u=a[E],a.hasOwnProperty(E)&&u!=null&&!l.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:It(i,s,E,null,l,u)}for(_ in l)if(u=l[_],h=a[_],l.hasOwnProperty(_)&&(u!=null||h!=null))switch(_){case"value":J=u;break;case"defaultValue":oe=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==h&&It(i,s,_,u,l,h)}Ir(i,J,oe);return;case"option":for(var Pe in a)J=a[Pe],a.hasOwnProperty(Pe)&&J!=null&&!l.hasOwnProperty(Pe)&&(Pe==="selected"?i.selected=!1:It(i,s,Pe,null,l,J));for(A in l)J=l[A],oe=a[A],l.hasOwnProperty(A)&&J!==oe&&(J!=null||oe!=null)&&(A==="selected"?i.selected=J&&typeof J!="function"&&typeof J!="symbol":It(i,s,A,J,l,oe));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 Xe in a)J=a[Xe],a.hasOwnProperty(Xe)&&J!=null&&!l.hasOwnProperty(Xe)&&It(i,s,Xe,null,l,J);for(Z in l)if(J=l[Z],oe=a[Z],l.hasOwnProperty(Z)&&J!==oe&&(J!=null||oe!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(r(137,s));break;default:It(i,s,Z,J,l,oe)}return;default:if(Hr(s)){for(var Pt in a)J=a[Pt],a.hasOwnProperty(Pt)&&J!==void 0&&!l.hasOwnProperty(Pt)&&Xp(i,s,Pt,void 0,l,J);for(de in l)J=l[de],oe=a[de],!l.hasOwnProperty(de)||J===oe||J===void 0&&oe===void 0||Xp(i,s,de,J,l,oe);return}}for(var U in a)J=a[U],a.hasOwnProperty(U)&&J!=null&&!l.hasOwnProperty(U)&&It(i,s,U,null,l,J);for(ge in l)J=l[ge],oe=a[ge],!l.hasOwnProperty(ge)||J===oe||J==null&&oe==null||It(i,s,ge,J,l,oe)}function cS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function aE(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],h=u.transferSize,_=u.initiatorType,E=u.duration;if(h&&E&&cS(_)){for(_=0,E=u.responseEnd,l+=1;l<a.length;l++){var A=a[l],Z=A.startTime;if(Z>E)break;var de=A.transferSize,ge=A.initiatorType;de&&cS(ge)&&(A=A.responseEnd,_+=de*(A<E?1:(E-Z)/(A-Z)))}if(--l,s+=8*(h+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Gp=null,Zp=null;function Bd(i){return i.nodeType===9?i:i.ownerDocument}function uS(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function dS(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function Qp(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Jp=null;function oE(){var i=window.event;return i&&i.type==="popstate"?i===Jp?!1:(Jp=i,!0):(Jp=null,!1)}var hS=typeof setTimeout=="function"?setTimeout:void 0,lE=typeof clearTimeout=="function"?clearTimeout:void 0,fS=typeof Promise=="function"?Promise:void 0,cE=typeof queueMicrotask=="function"?queueMicrotask:typeof fS<"u"?function(i){return fS.resolve(null).then(i).catch(uE)}:hS;function uE(i){setTimeout(function(){throw i})}function ua(i){return i==="head"}function pS(i,s){var a=s,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),el(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")gc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,gc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,E=h.nodeName;h[Ys]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&gc(i.ownerDocument.body);a=u}while(a);el(s)}function mS(i,s){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function em(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":em(a),xs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function dE(i,s,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Ys])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var h=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=as(i.nextSibling),i===null)break}return null}function hE(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=as(i.nextSibling),i===null))return null;return i}function gS(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=as(i.nextSibling),i===null))return null;return i}function tm(i){return i.data==="$?"||i.data==="$~"}function im(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function fE(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function as(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var nm=null;function vS(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return as(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function _S(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function bS(i,s,a){switch(s=Bd(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function gc(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);xs(i)}var os=new Map,yS=new Set;function jd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var yr=R.d;R.d={f:pE,r:mE,D:gE,C:vE,L:_E,m:bE,X:SE,S:yE,M:wE};function pE(){var i=yr.f(),s=Td();return i||s}function mE(i){var s=ps(i);s!==null&&s.tag===5&&s.type==="form"?zb(s):yr.r(i)}var Zo=typeof document>"u"?null:document;function SS(i,s,a){var l=Zo;if(l&&typeof s=="string"&&s){var u=Wi(s);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),yS.has(u)||(yS.add(u),i={rel:i,crossOrigin:a,href:s},l.querySelector(u)===null&&(s=l.createElement("link"),on(s,"link",i),ai(s),l.head.appendChild(s)))}}function gE(i){yr.D(i),SS("dns-prefetch",i,null)}function vE(i,s){yr.C(i,s),SS("preconnect",i,s)}function _E(i,s,a){yr.L(i,s,a);var l=Zo;if(l&&i&&s){var u='link[rel="preload"][as="'+Wi(s)+'"]';s==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Wi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Wi(a.imageSizes)+'"]')):u+='[href="'+Wi(i)+'"]';var h=u;switch(s){case"style":h=Qo(i);break;case"script":h=Jo(i)}os.has(h)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),os.set(h,i),l.querySelector(u)!==null||s==="style"&&l.querySelector(vc(h))||s==="script"&&l.querySelector(_c(h))||(s=l.createElement("link"),on(s,"link",i),ai(s),l.head.appendChild(s)))}}function bE(i,s){yr.m(i,s);var a=Zo;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",u='link[rel="modulepreload"][as="'+Wi(l)+'"][href="'+Wi(i)+'"]',h=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Jo(i)}if(!os.has(h)&&(i=b({rel:"modulepreload",href:i},s),os.set(h,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(_c(h)))return}l=a.createElement("link"),on(l,"link",i),ai(l),a.head.appendChild(l)}}}function yE(i,s,a){yr.S(i,s,a);var l=Zo;if(l&&i){var u=cn(l).hoistableStyles,h=Qo(i);s=s||"default";var _=u.get(h);if(!_){var E={loading:0,preload:null};if(_=l.querySelector(vc(h)))E.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=os.get(h))&&sm(i,a);var A=_=l.createElement("link");ai(A),on(A,"link",i),A._p=new Promise(function(Z,de){A.onload=Z,A.onerror=de}),A.addEventListener("load",function(){E.loading|=1}),A.addEventListener("error",function(){E.loading|=2}),E.loading|=4,zd(_,s,l)}_={type:"stylesheet",instance:_,count:1,state:E},u.set(h,_)}}}function SE(i,s){yr.X(i,s);var a=Zo;if(a&&i){var l=cn(a).hoistableScripts,u=Jo(i),h=l.get(u);h||(h=a.querySelector(_c(u)),h||(i=b({src:i,async:!0},s),(s=os.get(u))&&rm(i,s),h=a.createElement("script"),ai(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function wE(i,s){yr.M(i,s);var a=Zo;if(a&&i){var l=cn(a).hoistableScripts,u=Jo(i),h=l.get(u);h||(h=a.querySelector(_c(u)),h||(i=b({src:i,async:!0,type:"module"},s),(s=os.get(u))&&rm(i,s),h=a.createElement("script"),ai(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(u,h))}}function wS(i,s,a,l){var u=(u=xe.current)?jd(u):null;if(!u)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=Qo(a.href),a=cn(u).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Qo(a.href);var h=cn(u).hoistableStyles,_=h.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=u.querySelector(vc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),os.has(i)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},os.set(i,a),h||CE(u,i,a,_.state))),s&&l===null)throw Error(r(528,""));return _}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=Jo(a),a=cn(u).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Qo(i){return'href="'+Wi(i)+'"'}function vc(i){return'link[rel="stylesheet"]['+i+"]"}function CS(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function CE(i,s,a,l){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=i.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),on(s,"link",a),ai(s),i.head.appendChild(s))}function Jo(i){return'[src="'+Wi(i)+'"]'}function _c(i){return"script[async]"+i}function xS(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+Wi(a.href)+'"]');if(l)return s.instance=l,ai(l),l;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),ai(l),on(l,"style",u),zd(l,a.precedence,i),s.instance=l;case"stylesheet":u=Qo(a.href);var h=i.querySelector(vc(u));if(h)return s.state.loading|=4,s.instance=h,ai(h),h;l=CS(a),(u=os.get(u))&&sm(l,u),h=(i.ownerDocument||i).createElement("link"),ai(h);var _=h;return _._p=new Promise(function(E,A){_.onload=E,_.onerror=A}),on(h,"link",l),s.state.loading|=4,zd(h,a.precedence,i),s.instance=h;case"script":return h=Jo(a.src),(u=i.querySelector(_c(h)))?(s.instance=u,ai(u),u):(l=a,(u=os.get(h))&&(l=b({},a),rm(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),ai(u),on(u,"link",l),i.head.appendChild(u),s.instance=u);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,zd(l,a.precedence,i));return s.instance}function zd(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,h=u,_=0;_<l.length;_++){var E=l[_];if(E.dataset.precedence===s)h=E;else if(h!==u)break}h?h.parentNode.insertBefore(i,h.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function sm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function rm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var Id=null;function kS(i,s,a){if(Id===null){var l=new Map,u=Id=new Map;u.set(a,l)}else u=Id,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var h=a[u];if(!(h[Ys]||h[Qt]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(s)||"";_=i+_;var E=l.get(_);E?E.push(h):l.set(_,[h])}}return l}function ES(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function xE(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function TS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function kE(i,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=Qo(l.href),h=s.querySelector(vc(u));if(h){s=h._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=Pd.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=h,ai(h);return}h=s.ownerDocument||s,l=CS(l),(u=os.get(u))&&sm(l,u),h=h.createElement("link"),ai(h);var _=h;_._p=new Promise(function(E,A){_.onload=E,_.onerror=A}),on(h,"link",l),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Pd.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var am=0;function EE(i,s){return i.stylesheets&&i.count===0&&Ud(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&Ud(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+s);0<i.imgBytes&&am===0&&(am=62500*aE());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Ud(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>am?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function Pd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ud(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Hd=null;function Ud(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Hd=new Map,s.forEach(TE,i),Hd=null,Pd.call(i))}function TE(i,s){if(!(s.state.loading&4)){var a=Hd.get(i);if(a)var l=a.get(null);else{a=new Map,Hd.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<u.length;h++){var _=u[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=s.instance,_=u.getAttribute("data-precedence"),h=a.get(_)||l,h===l&&a.set(null,u),a.set(_,u),this.count++,l=Pd.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),h?h.parentNode.insertBefore(u,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),s.state.loading|=4}}var bc={$$typeof:V,Provider:null,Consumer:null,_currentValue:j,_currentValue2:j,_threadCount:0};function DE(i,s,a,l,u,h,_,E,A){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ci(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ci(0),this.hiddenUpdates=Ci(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function DS(i,s,a,l,u,h,_,E,A,Z,de,ge){return i=new DE(i,s,a,_,A,Z,de,ge,E),s=1,h===!0&&(s|=24),h=Pn(3,null,null,s),i.current=h,h.stateNode=i,s=Pf(),s.refCount++,i.pooledCache=s,s.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:s},Ff(h),i}function RS(i){return i?(i=Mo,i):Mo}function MS(i,s,a,l,u,h){u=RS(u),l.context===null?l.context=u:l.pendingContext=u,l=Jr(s),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=ea(i,l,s),a!==null&&(Ln(a,i,s),Zl(a,i,s))}function NS(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function om(i,s){NS(i,s),(i=i.alternate)&&NS(i,s)}function AS(i){if(i.tag===13||i.tag===31){var s=Wa(i,67108864);s!==null&&Ln(s,i,67108864),om(i,67108864)}}function LS(i){if(i.tag===13||i.tag===31){var s=Wn();s=gn(s);var a=Wa(i,s);a!==null&&Ln(a,i,s),om(i,s)}}var Kd=!0;function RE(i,s,a,l){var u=L.T;L.T=null;var h=R.p;try{R.p=2,lm(i,s,a,l)}finally{R.p=h,L.T=u}}function ME(i,s,a,l){var u=L.T;L.T=null;var h=R.p;try{R.p=8,lm(i,s,a,l)}finally{R.p=h,L.T=u}}function lm(i,s,a,l){if(Kd){var u=cm(l);if(u===null)Yp(i,s,l,Fd,a),BS(i,l);else if(AE(u,i,s,a,l))l.stopPropagation();else if(BS(i,l),s&4&&-1<NE.indexOf(i)){for(;u!==null;){var h=ps(u);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=xt(h.pendingLanes);if(_!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;_;){var A=1<<31-ft(_);E.entanglements[1]|=A,_&=~A}Is(h),(Dt&6)===0&&(kd=Nt()+500,fc(0))}}break;case 31:case 13:E=Wa(h,2),E!==null&&Ln(E,h,2),Td(),om(h,2)}if(h=cm(l),h===null&&Yp(i,s,l,Fd,a),h===u)break;u=h}u!==null&&l.stopPropagation()}else Yp(i,s,l,null,a)}}function cm(i){return i=Js(i),um(i)}var Fd=null;function um(i){if(Fd=null,i=ks(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=d(s),i!==null)return i;i=null}else if(a===31){if(i=m(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return Fd=i,null}function OS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(pi()){case Cn:return 2;case Rt:return 8;case Qe:case gt:return 32;case Bt:return 268435456;default:return 32}default:return 32}}var dm=!1,da=null,ha=null,fa=null,yc=new Map,Sc=new Map,pa=[],NE="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 BS(i,s){switch(i){case"focusin":case"focusout":da=null;break;case"dragenter":case"dragleave":ha=null;break;case"mouseover":case"mouseout":fa=null;break;case"pointerover":case"pointerout":yc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Sc.delete(s.pointerId)}}function wc(i,s,a,l,u,h){return i===null||i.nativeEvent!==h?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[u]},s!==null&&(s=ps(s),s!==null&&AS(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,u!==null&&s.indexOf(u)===-1&&s.push(u),i)}function AE(i,s,a,l,u){switch(s){case"focusin":return da=wc(da,i,s,a,l,u),!0;case"dragenter":return ha=wc(ha,i,s,a,l,u),!0;case"mouseover":return fa=wc(fa,i,s,a,l,u),!0;case"pointerover":var h=u.pointerId;return yc.set(h,wc(yc.get(h)||null,i,s,a,l,u)),!0;case"gotpointercapture":return h=u.pointerId,Sc.set(h,wc(Sc.get(h)||null,i,s,a,l,u)),!0}return!1}function jS(i){var s=ks(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=d(a),s!==null){i.blockedOn=s,en(i.priority,function(){LS(a)});return}}else if(s===31){if(s=m(a),s!==null){i.blockedOn=s,en(i.priority,function(){LS(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Wd(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=cm(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Ms=l,a.target.dispatchEvent(l),Ms=null}else return s=ps(a),s!==null&&AS(s),i.blockedOn=a,!1;s.shift()}return!0}function zS(i,s,a){Wd(i)&&a.delete(s)}function LE(){dm=!1,da!==null&&Wd(da)&&(da=null),ha!==null&&Wd(ha)&&(ha=null),fa!==null&&Wd(fa)&&(fa=null),yc.forEach(zS),Sc.forEach(zS)}function $d(i,s){i.blockedOn===s&&(i.blockedOn=null,dm||(dm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,LE)))}var qd=null;function IS(i){qd!==i&&(qd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){qd===i&&(qd=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],u=i[s+2];if(typeof l!="function"){if(um(l||a)===null)continue;break}var h=ps(a);h!==null&&(i.splice(s,3),s-=3,cp(h,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function el(i){function s(A){return $d(A,i)}da!==null&&$d(da,i),ha!==null&&$d(ha,i),fa!==null&&$d(fa,i),yc.forEach(s),Sc.forEach(s);for(var a=0;a<pa.length;a++){var l=pa[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<pa.length&&(a=pa[0],a.blockedOn===null);)jS(a),a.blockedOn===null&&pa.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],h=a[l+1],_=u[ki]||null;if(typeof h=="function")_||IS(a);else if(_){var E=null;if(h&&h.hasAttribute("formAction")){if(u=h,_=h[ki]||null)E=_.formAction;else if(um(u)!==null)continue}else E=_.action;typeof E=="function"?a[l+1]=E:(a.splice(l,3),l-=3),IS(a)}}}function PS(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function s(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),u!==null&&(u(),u=null)}}}function hm(i){this._internalRoot=i}Vd.prototype.render=hm.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Wn();MS(a,l,i,s,null,null)},Vd.prototype.unmount=hm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;MS(i.current,2,null,i,null,null),Td(),s[Xn]=null}};function Vd(i){this._internalRoot=i}Vd.prototype.unstable_scheduleHydration=function(i){if(i){var s=vi();i={blockedOn:null,target:i,priority:s};for(var a=0;a<pa.length&&s!==0&&s<pa[a].priority;a++);pa.splice(a,0,i),a===0&&jS(i)}};var HS=t.version;if(HS!=="19.2.6")throw Error(r(527,HS,"19.2.6"));R.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var OE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yd.isDisabled&&Yd.supportsFiber)try{Je=Yd.inject(OE),et=Yd}catch{}}return xc.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",u=Vb,h=Yb,_=Xb;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(u=s.onUncaughtError),s.onCaughtError!==void 0&&(h=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=DS(i,1,!1,null,null,a,l,null,u,h,_,PS),i[Xn]=s.current,Vp(i),new hm(s)},xc.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,u="",h=Vb,_=Yb,E=Xb,A=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(E=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),s=DS(i,1,!0,s,a??null,l,u,A,h,_,E,PS),s.context=RS(null),a=s.current,l=Wn(),l=gn(l),u=Jr(l),u.callback=null,ea(a,u,l),a=l,s.current.lanes=a,Yt(s,a),Is(s),i[Xn]=s.current,Vp(i),new Vd(s)},xc.version="19.2.6",xc}var GS;function WE(){if(GS)return mm.exports;GS=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(),mm.exports=FE(),mm.exports}var $E=WE();class Bn extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Xh(e=fetch){return{getSession:(t={})=>Me(e,`/api/auth/session${Ks(t)}`),setupPassword:t=>Me(e,"/api/auth/password",it("POST",t)),login:t=>Me(e,"/api/auth/login",it("POST",t)),reauth:t=>Me(e,"/api/auth/reauth",it("POST",t)),logout:()=>Me(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Me(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Me(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Me(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Me(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Me(e,"/api/auth/devices"),revokeDevice:async t=>{await sl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Me(e,"/api/auth/networks"),addNetwork:t=>Me(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await sl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Me(e,"/api/agents"),addAgent:t=>Me(e,"/api/agents",it("POST",t)),reorderAgents:t=>Me(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>Me(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>Me(e,"/api/main"),renameMain:t=>Me(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await sl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Me(e,"/api/stats"),getAgentStats:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Me(e,"/api/version"),checkUpdate:()=>Me(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Me(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Me(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Me(e,`/api/code-server/status${Ks(t)}`),installCodeServer:()=>Me(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Me(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Me(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>Me(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>Me(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>Me(e,"/api/terminals"),getTerminalLayout:()=>Me(e,"/api/terminal-layout"),saveTerminalLayout:t=>Me(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>Me(e,"/api/files/root",it("POST",t)),listFiles:t=>Me(e,"/api/files/list",it("POST",t)),readFile:t=>Me(e,"/api/files/read",it("POST",t)),writeFile:t=>Me(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Me(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Me(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Me(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Me(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Me(e,"/api/files/open",it("POST",t)),previewFile:t=>d1(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Me(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await sl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Me(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Me(e,`/api/terminals/${encodeURIComponent(t)}/history${Ks(n)}`),getTerminalTranscriptHistory:(t,n={})=>Me(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Ks(n)}`),getTerminalTranscriptSource:t=>Me(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Me(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>Me(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${Ks(r)}`),listNotificationAssets:()=>Me(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Me(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Me(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await sl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Me(e,`/api/push-notifications/status${t||n?Ks({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Me(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>Me(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>Me(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>Me(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>Me(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>Me(e,"/api/push-notifications/test",it("POST",t))}}function fl(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Me(t,n("terminals")),createTerminal:(r={})=>Me(t,n("terminals"),it("POST",r)),closeTerminal:async r=>{await sl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Me(t,n(`terminals/${encodeURIComponent(r)}`),it("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Me(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${Ks(o)}`),getTerminalTranscriptHistory:(r,o={})=>Me(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Ks(o)}`),getTerminalTranscriptSource:r=>Me(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>Me(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>Me(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${Ks(c)}`),getTerminalLayout:()=>Me(t,n("terminal-layout")),saveTerminalLayout:r=>Me(t,n("terminal-layout"),it("PUT",r)),createFileRoot:r=>Me(t,n("files/root"),it("POST",r)),listFiles:r=>Me(t,n("files/list"),it("POST",r)),readFile:r=>Me(t,n("files/read"),it("POST",r)),writeFile:r=>Me(t,n("files/write"),it("POST",r)),createFileEntry:r=>Me(t,n("files/create"),it("POST",r)),moveFileEntry:r=>Me(t,n("files/move"),it("POST",r)),previewDeleteFileEntry:r=>Me(t,n("files/delete-preview"),it("POST",r)),deleteFileEntry:r=>Me(t,n("files/delete"),it("POST",r)),openFileInTerminal:r=>Me(t,n("files/open"),it("POST",r)),previewFile:r=>d1(t,n("files/preview"),it("POST",r)),getCodeServerStatus:(r={})=>Me(t,`${n("code-server/status")}${Ks(r)}`),installCodeServer:()=>Me(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Me(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>Me(t,n("code-server/open"),it("POST",r)),stopCodeServer:(r={})=>Me(t,n("code-server/stop"),it("POST",r)),uninstallCodeServer:()=>Me(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>qE(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function qE(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function it(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Ks(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function Me(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await Fv(r);try{return await r.json()}catch{throw new Bn(r.status,"invalid_json_response")}}async function sl(e,t,n){const r=await e(t,n);await Fv(r)}async function d1(e,t,n){const r=await e(t,n);return await Fv(r),r.blob()}async function Fv(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Bn(e.status,t)}const Wv="nterminal.theme.id",h1="nterminal.theme.accent",ng="nterminal:theme",Th=[{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",...ZS({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",...ZS({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],pl="midnight";function Gh(e){return Th.some(t=>t.id===e)?e:pl}function $v(e){return Th.find(t=>t.id===e)??Th[0]}function Da(){if(typeof window>"u")return pl;try{const e=window.localStorage.getItem(Wv);return e?Gh(e):ZE(window.localStorage.getItem(h1))}catch{return pl}}function VE(e){const t=Gh(e);if(typeof window<"u"){try{window.localStorage.setItem(Wv,t)}catch{}qv(t),window.dispatchEvent(new CustomEvent(ng,{detail:t}))}return t}function qv(e=Da()){if(typeof document>"u")return;const t=$v(Gh(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),ht(n,"--nt-bg",t.tokens.bg),ht(n,"--nt-bg-2",t.tokens.bg2),ht(n,"--nt-bg-sidebar",t.tokens.bgSidebar),ht(n,"--nt-line",t.tokens.line),ht(n,"--nt-line-2",t.tokens.line2),ht(n,"--nt-fg",t.tokens.fg),ht(n,"--nt-fg-2",t.tokens.fg2),ht(n,"--nt-fg-3",t.tokens.fg3),ht(n,"--nt-fg-4",t.tokens.fg4),ht(n,"--nt-accent",t.tokens.accent),ht(n,"--nt-accent-soft",t.tokens.accentSoft),ht(n,"--nt-accent-glow",t.tokens.accentGlow),ht(n,"--nt-on-accent",t.tokens.onAccent),ht(n,"--nt-ok",t.tokens.ok),ht(n,"--nt-danger",t.tokens.danger),ht(n,"--nt-on-danger",t.tokens.onDanger),ht(n,"--nt-danger-soft",t.tokens.dangerSoft),ht(n,"--nt-danger-line",t.tokens.dangerLine),ht(n,"--nt-warning",t.tokens.warning),ht(n,"--nt-warn",t.tokens.warning),ht(n,"--nt-warning-soft",t.tokens.warningSoft),ht(n,"--nt-warning-glow",t.tokens.warningGlow),ht(n,"--nt-scrim",t.tokens.scrim),ht(n,"--nt-scrim-soft",t.tokens.scrimSoft),ht(n,"--nt-shadow",t.tokens.shadow),ht(n,"--nt-shadow-strong",t.tokens.shadowStrong),ht(n,"--nt-floating-bg",t.tokens.floatingBg),ht(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),ht(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),ht(n,"--nt-subtle-fill",t.tokens.subtleFill),ht(n,"--nt-hover-fill",t.tokens.hoverFill),ht(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),ht(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),ht(n,"--nt-transcript-user",t.tokens.transcriptUser),ht(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),ht(n,"--nt-transcript-tool",t.tokens.transcriptTool),ht(n,"--nt-transcript-command",t.tokens.transcriptCommand),ht(n,"--nt-transcript-code",t.tokens.transcriptCode),ht(n,"--nt-transcript-search",t.tokens.transcriptSearch),ht(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),ht(n,"--nt-qr-bg",t.tokens.qrBg)}function YE(e=Da()){return $v(Gh(e)).xterm}function Vv(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Wv||n.key===h1)&&(qv(Da()),e())};return window.addEventListener(ng,e),window.addEventListener("storage",t),()=>{window.removeEventListener(ng,e),window.removeEventListener("storage",t)}}function ht(e,t,n){e.style.setProperty(t,n)}function ZS(e){const t=XE(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 XE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(GE(n));return t}function GE(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return QS(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return QS(t,t,t)}return"#000000"}function QS(e,t,n){return`#${bm(e)}${bm(t)}${bm(n)}`}function bm(e){return e.toString(16).padStart(2,"0")}function ZE(e){return e==="signal-red"?"signal-red":pl}function f1(){const e=v.useSyncExternalStore(Vv,Da,()=>pl);return $v(e).mode==="light"?"-light":""}function p1({size:e=22}){const t=f1();return f.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function m1({height:e=18}){const t=f1(),n=Math.round(243/34*e);return f.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var Bc=u1();const Zh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function yl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Yv(e){return"nodeType"in e}function jn(e){var t,n;return e?yl(e)?e:Yv(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Xv(e){const{Document:t}=jn(e);return e instanceof t}function vu(e){return yl(e)?!1:e instanceof jn(e).HTMLElement}function g1(e){return e instanceof jn(e).SVGElement}function Sl(e){return e?yl(e)?e.document:Yv(e)?Xv(e)?e:vu(e)||g1(e)?e.ownerDocument:document:document:document}const Ra=Zh?v.useLayoutEffect:v.useEffect;function Gv(e){const t=v.useRef(e);return Ra(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function QE(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function iu(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Ra(()=>{n.current!==e&&(n.current=e)},t),n}function _u(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Dh(e){const t=Gv(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function sg(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let ym={};function Qh(e,t){return v.useMemo(()=>{if(t)return t;const n=ym[e]==null?0:ym[e]+1;return ym[e]=n,e+"-"+n},[e,t])}function v1(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,d)=>{const m=Object.entries(d);for(const[g,p]of m){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const dl=v1(1),Rh=v1(-1);function JE(e){return"clientX"in e&&"clientY"in e}function _1(e){if(!e)return!1;const{KeyboardEvent:t}=jn(e.target);return t&&e instanceof t}function eT(e){if(!e)return!1;const{TouchEvent:t}=jn(e.target);return t&&e instanceof t}function rg(e){if(eT(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return JE(e)?{x:e.clientX,y:e.clientY}:null}const ag=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ag.Translate.toString(e),ag.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),JS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function tT(e){return e.matches(JS)?e:e.querySelector(JS)}const iT={display:"none"};function nT(e){let{id:t,value:n}=e;return Ai.createElement("div",{id:t,style:iT},n)}function sT(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ai.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function rT(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const b1=v.createContext(null);function aT(e){const t=v.useContext(b1);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function oT(){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(d=>{var m;return(m=d[o])==null?void 0:m.call(d,c)})},[e]),t]}const lT={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
|
+
`},cT={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function uT(e){let{announcements:t=cT,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=lT}=e;const{announce:c,announcement:d}=rT(),m=Qh("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),aT(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:C}=b;t.onDragMove&&c(t.onDragMove({active:w,over:C}))},onDragOver(b){let{active:w,over:C}=b;c(t.onDragOver({active:w,over:C}))},onDragEnd(b){let{active:w,over:C}=b;c(t.onDragEnd({active:w,over:C}))},onDragCancel(b){let{active:w,over:C}=b;c(t.onDragCancel({active:w,over:C}))}}),[c,t])),!g)return null;const y=Ai.createElement(Ai.Fragment,null,Ai.createElement(nT,{id:r,value:o.draggable}),Ai.createElement(sT,{id:m,announcement:d}));return n?Bc.createPortal(y,n):y}var Hi;(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"})(Hi||(Hi={}));function Mh(){}function e0(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function dT(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ws=Object.freeze({x:0,y:0});function hT(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function fT(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function pT(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-r,m=c-n;if(r<o&&n<c){const g=t.width*t.height,p=e.width*e.height,y=d*m,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const mT=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:d}=c,m=n.get(d);if(m){const g=pT(m,t);g>0&&o.push({id:d,data:{droppableContainer:c,value:g}})}}return o.sort(hT)};function gT(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function y1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ws}function vT(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((d,m)=>({...d,top:d.top+e*m.y,bottom:d.bottom+e*m.y,left:d.left+e*m.x,right:d.right+e*m.x}),{...n})}}const _T=vT(1);function bT(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 yT(e,t,n){const r=bT(t);if(!r)return e;const{scaleX:o,scaleY:c,x:d,y:m}=r,g=e.left-d-(1-o)*parseFloat(n),p=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:p,right:g+y,bottom:p+b,left:g}}const ST={ignoreTransform:!1};function bu(e,t){t===void 0&&(t=ST);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=jn(e).getComputedStyle(e);p&&(n=yT(n,p,y))}const{top:r,left:o,width:c,height:d,bottom:m,right:g}=n;return{top:r,left:o,width:c,height:d,bottom:m,right:g}}function t0(e){return bu(e,{ignoreTransform:!0})}function wT(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function CT(e,t){return t===void 0&&(t=jn(e).getComputedStyle(e)),t.position==="fixed"}function xT(e,t){t===void 0&&(t=jn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function Zv(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Xv(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!vu(o)||g1(o)||n.includes(o))return n;const c=jn(e).getComputedStyle(o);return o!==e&&xT(o,c)&&n.push(o),CT(o,c)?n:r(o.parentNode)}return e?r(e):n}function S1(e){const[t]=Zv(e,1);return t??null}function Sm(e){return!Zh||!e?null:yl(e)?e:Yv(e)?Xv(e)||e===Sl(e).scrollingElement?window:vu(e)?e:null:null}function w1(e){return yl(e)?e.scrollX:e.scrollLeft}function C1(e){return yl(e)?e.scrollY:e.scrollTop}function og(e){return{x:w1(e),y:C1(e)}}var Yi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Yi||(Yi={}));function x1(e){return!Zh||!e?!1:e===document.scrollingElement}function k1(e){const t={x:0,y:0},n=x1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=r.y,m=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:d,isRight:m,maxScroll:r,minScroll:t}}const kT={x:.2,y:.2};function ET(e,t,n,r,o){let{top:c,left:d,right:m,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=kT);const{isTop:p,isBottom:y,isLeft:b,isRight:w}=k1(e),C={x:0,y:0},x={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+D.height?(C.y=Yi.Backward,x.y=r*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(C.y=Yi.Forward,x.y=r*Math.abs((t.bottom-D.height-g)/D.height)),!w&&m>=t.right-D.width?(C.x=Yi.Forward,x.x=r*Math.abs((t.right-D.width-m)/D.width)):!b&&d<=t.left+D.width&&(C.x=Yi.Backward,x.x=r*Math.abs((t.left+D.width-d)/D.width)),{direction:C,speed:x}}function TT(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function E1(e){return e.reduce((t,n)=>dl(t,og(n)),ws)}function DT(e){return e.reduce((t,n)=>t+w1(n),0)}function RT(e){return e.reduce((t,n)=>t+C1(n),0)}function MT(e,t){if(t===void 0&&(t=bu),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);S1(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const NT=[["x",["left","right"],DT],["y",["top","bottom"],RT]];class Qv{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Zv(n),o=E1(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,m]of NT)for(const g of d)Object.defineProperty(this,g,{get:()=>{const p=m(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class qc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function AT(e){const{EventTarget:t}=jn(e);return e instanceof t?e:Sl(e)}function wm(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var us;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(us||(us={}));function i0(e){e.preventDefault()}function LT(e){e.stopPropagation()}var Wt;(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"})(Wt||(Wt={}));const T1={start:[Wt.Space,Wt.Enter],cancel:[Wt.Esc],end:[Wt.Space,Wt.Enter,Wt.Tab]},OT=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Wt.Right:return{...n,x:n.x+25};case Wt.Left:return{...n,x:n.x-25};case Wt.Down:return{...n,y:n.y+25};case Wt.Up:return{...n,y:n.y-25}}};class D1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new qc(Sl(n)),this.windowListeners=new qc(jn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(us.Resize,this.handleCancel),this.windowListeners.add(us.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(us.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&MT(r),n(ws)}handleKeyDown(t){if(_1(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=T1,coordinateGetter:d=OT,scrollBehavior:m="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,y=p?{x:p.left,y:p.top}:ws;this.referenceCoordinates||(this.referenceCoordinates=y);const b=d(t,{active:n,context:r.current,currentCoordinates:y});if(b){const w=Rh(b,y),C={x:0,y:0},{scrollableAncestors:x}=r.current;for(const D of x){const O=t.code,{isTop:N,isRight:B,isLeft:V,isBottom:W,maxScroll:ie,minScroll:Q}=k1(D),$=TT(D),Se={x:Math.min(O===Wt.Right?$.right-$.width/2:$.right,Math.max(O===Wt.Right?$.left:$.left+$.width/2,b.x)),y:Math.min(O===Wt.Down?$.bottom-$.height/2:$.bottom,Math.max(O===Wt.Down?$.top:$.top+$.height/2,b.y))},ne=O===Wt.Right&&!B||O===Wt.Left&&!V,Te=O===Wt.Down&&!W||O===Wt.Up&&!N;if(ne&&Se.x!==b.x){const te=D.scrollLeft+w.x,Y=O===Wt.Right&&te<=ie.x||O===Wt.Left&&te>=Q.x;if(Y&&!w.y){D.scrollTo({left:te,behavior:m});return}Y?C.x=D.scrollLeft-te:C.x=O===Wt.Right?D.scrollLeft-ie.x:D.scrollLeft-Q.x,C.x&&D.scrollBy({left:-C.x,behavior:m});break}else if(Te&&Se.y!==b.y){const te=D.scrollTop+w.y,Y=O===Wt.Down&&te<=ie.y||O===Wt.Up&&te>=Q.y;if(Y&&!w.x){D.scrollTo({top:te,behavior:m});return}Y?C.y=D.scrollTop-te:C.y=O===Wt.Down?D.scrollTop-ie.y:D.scrollTop-Q.y,C.y&&D.scrollBy({top:-C.y,behavior:m});break}}this.handleMove(t,dl(Rh(b,this.referenceCoordinates),C))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}D1.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=T1,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(r.start.includes(d)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function n0(e){return!!(e&&"distance"in e)}function s0(e){return!!(e&&"delay"in e)}class Jv{constructor(t,n,r){var o;r===void 0&&(r=AT(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=Sl(d),this.documentListeners=new qc(this.document),this.listeners=new qc(r),this.windowListeners=new qc(jn(d)),this.initialCoordinates=(o=rg(c))!=null?o:ws,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(us.Resize,this.handleCancel),this.windowListeners.add(us.DragStart,i0),this.windowListeners.add(us.VisibilityChange,this.handleCancel),this.windowListeners.add(us.ContextMenu,i0),this.documentListeners.add(us.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(s0(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(n0(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(us.Click,LT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(us.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=rg(t))!=null?n:ws,p=Rh(o,g);if(!r&&m){if(n0(m)){if(m.tolerance!=null&&wm(p,m.tolerance))return this.handleCancel();if(wm(p,m.distance))return this.handleStart()}if(s0(m)&&wm(p,m.tolerance))return this.handleCancel();this.handlePending(m,p);return}t.cancelable&&t.preventDefault(),d(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Wt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const BT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class R1 extends Jv{constructor(t){const{event:n}=t,r=Sl(n.target);super(t,BT,r)}}R1.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const jT={move:{name:"mousemove"},end:{name:"mouseup"}};var lg;(function(e){e[e.RightClick=2]="RightClick"})(lg||(lg={}));class M1 extends Jv{constructor(t){super(t,jT,Sl(t.event.target))}}M1.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===lg.RightClick?!1:(r?.({event:n}),!0)}}];const Cm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class N1 extends Jv{constructor(t){super(t,Cm)}static setup(){return window.addEventListener(Cm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Cm.move.name,t)};function t(){}}}N1.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Vc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Vc||(Vc={}));var Nh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Nh||(Nh={}));function zT(e){let{acceleration:t,activator:n=Vc.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:d=5,order:m=Nh.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:w}=e;const C=PT({delta:b,disabled:!c}),[x,D]=QE(),O=v.useRef({x:0,y:0}),N=v.useRef({x:0,y:0}),B=v.useMemo(()=>{switch(n){case Vc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Vc.DraggableRect:return o}},[n,o,g]),V=v.useRef(null),W=v.useCallback(()=>{const Q=V.current;if(!Q)return;const $=O.current.x*N.current.x,Se=O.current.y*N.current.y;Q.scrollBy($,Se)},[]),ie=v.useMemo(()=>m===Nh.TreeOrder?[...p].reverse():p,[m,p]);v.useEffect(()=>{if(!c||!p.length||!B){D();return}for(const Q of ie){if(r?.(Q)===!1)continue;const $=p.indexOf(Q),Se=y[$];if(!Se)continue;const{direction:ne,speed:Te}=ET(Q,Se,B,t,w);for(const te of["x","y"])C[te][ne[te]]||(Te[te]=0,ne[te]=0);if(Te.x>0||Te.y>0){D(),V.current=Q,x(W,d),O.current=Te,N.current=ne;return}}O.current={x:0,y:0},N.current={x:0,y:0},D()},[t,W,r,D,c,d,JSON.stringify(B),JSON.stringify(C),x,p,ie,y,JSON.stringify(w)])}const IT={x:{[Yi.Backward]:!1,[Yi.Forward]:!1},y:{[Yi.Backward]:!1,[Yi.Forward]:!1}};function PT(e){let{delta:t,disabled:n}=e;const r=sg(t);return _u(o=>{if(n||!r||!o)return IT;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Yi.Backward]:o.x[Yi.Backward]||c.x===-1,[Yi.Forward]:o.x[Yi.Forward]||c.x===1},y:{[Yi.Backward]:o.y[Yi.Backward]||c.y===-1,[Yi.Forward]:o.y[Yi.Forward]||c.y===1}}},[n,t,r])}function HT(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return _u(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function UT(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,r)}));return[...n,...c]},[]),[e,t])}var nu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(nu||(nu={}));var cg;(function(e){e.Optimized="optimized"})(cg||(cg={}));const r0=new Map;function KT(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,d]=v.useState(null),{frequency:m,measure:g,strategy:p}=o,y=v.useRef(e),b=O(),w=iu(b),C=v.useCallback(function(N){N===void 0&&(N=[]),!w.current&&d(B=>B===null?N:B.concat(N.filter(V=>!B.includes(V))))},[w]),x=v.useRef(null),D=_u(N=>{if(b&&!n)return r0;if(!N||N===r0||y.current!==e||c!=null){const B=new Map;for(let V of e){if(!V)continue;if(c&&c.length>0&&!c.includes(V.id)&&V.rect.current){B.set(V.id,V.rect.current);continue}const W=V.node.current,ie=W?new Qv(g(W),W):null;V.rect.current=ie,ie&&B.set(V.id,ie)}return B}return N},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||C()},[n,b]),v.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||x.current!==null||(x.current=setTimeout(()=>{C(),x.current=null},m))},[m,b,C,...r]),{droppableRects:D,measureDroppableContainers:C,measuringScheduled:c!=null};function O(){switch(p){case nu.Always:return!1;case nu.BeforeDragging:return n;default:return!n}}}function A1(e,t){return _u(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function FT(e,t){return A1(e,t)}function WT(e){let{callback:t,disabled:n}=e;const r=Gv(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Jh(e){let{callback:t,disabled:n}=e;const r=Gv(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function $T(e){return new Qv(bu(e),e)}function a0(e,t,n){t===void 0&&(t=$T);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const d=WT({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Jh({callback:c});return Ra(()=>{c(),e?(m?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),d?.disconnect())},[e]),r}function qT(e){const t=A1(e);return y1(e,t)}const o0=[];function VT(e){const t=v.useRef(e),n=_u(r=>e?r&&r!==o0&&e&&t.current&&e.parentNode===t.current.parentNode?r:Zv(e):o0,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function YT(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const d=Sm(c.target);d&&n(m=>m?(m.set(d,og(d)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){d(c);const m=e.map(g=>{const p=Sm(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,og(p)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),r.current=e}return()=>{d(e),d(c)};function d(m){m.forEach(g=>{const p=Sm(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>dl(c,d),ws):E1(e):ws,[e,t])}function l0(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==ws;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Rh(e,n.current):ws}function XT(e){v.useEffect(()=>{if(!Zh)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function GT(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function L1(e){return v.useMemo(()=>e?wT(e):null,[e])}const c0=[];function ZT(e,t){t===void 0&&(t=bu);const[n]=e,r=L1(n?jn(n):null),[o,c]=v.useState(c0);function d(){c(()=>e.length?e.map(g=>x1(g)?r:new Qv(t(g),g)):c0)}const m=Jh({callback:d});return Ra(()=>{m?.disconnect(),d(),e.forEach(g=>m?.observe(g))},[e]),o}function QT(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return vu(t)?t:e}function JT(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if(vu(y)){r(b=>{const w=t(y);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=Jh({callback:o}),d=v.useCallback(p=>{const y=QT(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[m,g]=Dh(d);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const e2=[{sensor:R1,options:{}},{sensor:D1,options:{}}],t2={current:{}},hh={draggable:{measure:t0},droppable:{measure:t0,strategy:nu.WhileDragging,frequency:cg.Optimized},dragOverlay:{measure:bu}};class Yc extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const i2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Yc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Mh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:hh,measureDroppableContainers:Mh,windowRect:null,measuringScheduled:!1},n2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Mh,draggableNodes:new Map,over:null,measureDroppableContainers:Mh},ef=v.createContext(n2),s2=v.createContext(i2);function r2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Yc}}}function a2(e,t){switch(t.type){case Hi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Hi.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 Hi.DragEnd:case Hi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Hi.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Yc(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Hi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const d=new Yc(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case Hi.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new Yc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function o2(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(ef),c=sg(r),d=sg(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&d!=null){if(!_1(c)||document.activeElement===c.target)return;const m=o.get(d);if(!m)return;const{activatorNode:g,node:p}=m;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=tT(y);if(b){b.focus();break}}})}},[r,t,o,d,c]),null}function l2(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function c2(e){return v.useMemo(()=>({draggable:{...hh.draggable,...e?.draggable},droppable:{...hh.droppable,...e?.droppable},dragOverlay:{...hh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function u2(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:d,y:m}=typeof o=="boolean"?{x:o,y:o}:o;Ra(()=>{if(!d&&!m||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=n(p),b=y1(y,r);if(d||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=S1(p);w&&w.scrollBy({top:b.y,left:b.x})}},[t,d,m,r,n])}const O1=v.createContext({...ws,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 d2=v.memo(function(t){var n,r,o,c;let{id:d,accessibility:m,autoScroll:g=!0,children:p,sensors:y=e2,collisionDetection:b=mT,measuring:w,modifiers:C,...x}=t;const D=v.useReducer(a2,void 0,r2),[O,N]=D,[B,V]=oT(),[W,ie]=v.useState(wa.Uninitialized),Q=W===wa.Initialized,{draggable:{active:$,nodes:Se,translate:ne},droppable:{containers:Te}}=O,te=$!=null?Se.get($):null,Y=v.useRef({initial:null,translated:null}),G=v.useMemo(()=>{var at;return $!=null?{id:$,data:(at=te?.data)!=null?at:t2,rect:Y}:null},[$,te]),F=v.useRef(null),[le,L]=v.useState(null),[R,j]=v.useState(null),ae=iu(x,Object.values(x)),be=Qh("DndDescribedBy",d),M=v.useMemo(()=>Te.getEnabled(),[Te]),K=c2(w),{droppableRects:ce,measureDroppableContainers:we,measuringScheduled:Le}=KT(M,{dragging:Q,dependencies:[ne.x,ne.y],config:K.droppable}),xe=HT(Se,$),Be=v.useMemo(()=>R?rg(R):null,[R]),De=Ge(),He=FT(xe,K.draggable.measure);u2({activeNode:$!=null?Se.get($):null,config:De.layoutShiftCompensation,initialRect:He,measure:K.draggable.measure});const ze=a0(xe,K.draggable.measure,He),re=a0(xe?xe.parentElement:null),he=v.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ce,draggableNodes:Se,draggingNode:null,draggingNodeRect:null,droppableContainers:Te,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),H=Te.getNodeFor((n=he.current.over)==null?void 0:n.id),ue=JT({measure:K.dragOverlay.measure}),Re=(r=ue.nodeRef.current)!=null?r:xe,Ne=Q?(o=ue.rect)!=null?o:ze:null,ee=!!(ue.nodeRef.current&&ue.rect),Ee=qT(ee?null:ze),me=L1(Re?jn(Re):null),Oe=VT(Q?H??xe:null),Ie=ZT(Oe),st=l2(C,{transform:{x:ne.x-Ee.x,y:ne.y-Ee.y,scaleX:1,scaleY:1},activatorEvent:R,active:G,activeNodeRect:ze,containerNodeRect:re,draggingNodeRect:Ne,over:he.current.over,overlayNodeRect:ue.rect,scrollableAncestors:Oe,scrollableAncestorRects:Ie,windowRect:me}),ot=Be?dl(Be,ne):null,Nt=YT(Oe),pi=l0(Nt),Cn=l0(Nt,[ze]),Rt=dl(st,pi),Qe=Ne?_T(Ne,st):null,gt=G&&Qe?b({active:G,collisionRect:Qe,droppableRects:ce,droppableContainers:M,pointerCoordinates:ot}):null,Bt=fT(gt,"id"),[ye,We]=v.useState(null),Je=ee?st:dl(st,Cn),et=gT(Je,(c=ye?.rect)!=null?c:null,ze),wt=v.useRef(null),ft=v.useCallback((at,xt)=>{let{sensor:jt,options:qt}=xt;if(F.current==null)return;const Vt=Se.get(F.current);if(!Vt)return;const $t=at.nativeEvent,Ci=new jt({active:F.current,activeNode:Vt,event:$t,options:qt,context:he,onAbort(ii){if(!Se.get(ii))return;const{onDragAbort:xi}=ae.current,Fi={id:ii};xi?.(Fi),B({type:"onDragAbort",event:Fi})},onPending(ii,mi,xi,Fi){if(!Se.get(ii))return;const{onDragPending:gi}=ae.current,vi={id:ii,constraint:mi,initialCoordinates:xi,offset:Fi};gi?.(vi),B({type:"onDragPending",event:vi})},onStart(ii){const mi=F.current;if(mi==null)return;const xi=Se.get(mi);if(!xi)return;const{onDragStart:Fi}=ae.current,gn={activatorEvent:$t,active:{id:mi,data:xi.data,rect:Y}};Bc.unstable_batchedUpdates(()=>{Fi?.(gn),ie(wa.Initializing),N({type:Hi.DragStart,initialCoordinates:ii,active:mi}),B({type:"onDragStart",event:gn}),L(wt.current),j($t)})},onMove(ii){N({type:Hi.DragMove,coordinates:ii})},onEnd:Yt(Hi.DragEnd),onCancel:Yt(Hi.DragCancel)});wt.current=Ci;function Yt(ii){return async function(){const{active:xi,collisions:Fi,over:gn,scrollAdjustedTranslate:gi}=he.current;let vi=null;if(xi&&gi){const{cancelDrop:en}=ae.current;vi={activatorEvent:$t,active:xi,collisions:Fi,delta:gi,over:gn},ii===Hi.DragEnd&&typeof en=="function"&&await Promise.resolve(en(vi))&&(ii=Hi.DragCancel)}F.current=null,Bc.unstable_batchedUpdates(()=>{N({type:ii}),ie(wa.Uninitialized),We(null),L(null),j(null),wt.current=null;const en=ii===Hi.DragEnd?"onDragEnd":"onDragCancel";if(vi){const Bi=ae.current[en];Bi?.(vi),B({type:en,event:vi})}})}}},[Se]),xn=v.useCallback((at,xt)=>(jt,qt)=>{const Vt=jt.nativeEvent,$t=Se.get(qt);if(F.current!==null||!$t||Vt.dndKit||Vt.defaultPrevented)return;const Ci={active:$t};at(jt,xt.options,Ci)===!0&&(Vt.dndKit={capturedBy:xt.sensor},F.current=qt,ft(jt,xt))},[Se,ft]),Oi=UT(y,xn);XT(y),Ra(()=>{ze&&W===wa.Initializing&&ie(wa.Initialized)},[ze,W]),v.useEffect(()=>{const{onDragMove:at}=ae.current,{active:xt,activatorEvent:jt,collisions:qt,over:Vt}=he.current;if(!xt||!jt)return;const $t={active:xt,activatorEvent:jt,collisions:qt,delta:{x:Rt.x,y:Rt.y},over:Vt};Bc.unstable_batchedUpdates(()=>{at?.($t),B({type:"onDragMove",event:$t})})},[Rt.x,Rt.y]),v.useEffect(()=>{const{active:at,activatorEvent:xt,collisions:jt,droppableContainers:qt,scrollAdjustedTranslate:Vt}=he.current;if(!at||F.current==null||!xt||!Vt)return;const{onDragOver:$t}=ae.current,Ci=qt.get(Bt),Yt=Ci&&Ci.rect.current?{id:Ci.id,rect:Ci.rect.current,data:Ci.data,disabled:Ci.disabled}:null,ii={active:at,activatorEvent:xt,collisions:jt,delta:{x:Vt.x,y:Vt.y},over:Yt};Bc.unstable_batchedUpdates(()=>{We(Yt),$t?.(ii),B({type:"onDragOver",event:ii})})},[Bt]),Ra(()=>{he.current={activatorEvent:R,active:G,activeNode:xe,collisionRect:Qe,collisions:gt,droppableRects:ce,draggableNodes:Se,draggingNode:Re,draggingNodeRect:Ne,droppableContainers:Te,over:ye,scrollableAncestors:Oe,scrollAdjustedTranslate:Rt},Y.current={initial:Ne,translated:Qe}},[G,xe,gt,Qe,Se,Re,Ne,ce,Te,ye,Oe,Rt]),zT({...De,delta:ne,draggingRect:Qe,pointerCoordinates:ot,scrollableAncestors:Oe,scrollableAncestorRects:Ie});const q=v.useMemo(()=>({active:G,activeNode:xe,activeNodeRect:ze,activatorEvent:R,collisions:gt,containerNodeRect:re,dragOverlay:ue,draggableNodes:Se,droppableContainers:Te,droppableRects:ce,over:ye,measureDroppableContainers:we,scrollableAncestors:Oe,scrollableAncestorRects:Ie,measuringConfiguration:K,measuringScheduled:Le,windowRect:me}),[G,xe,ze,R,gt,re,ue,Se,Te,ce,ye,we,Oe,Ie,K,Le,me]),Ke=v.useMemo(()=>({activatorEvent:R,activators:Oi,active:G,activeNodeRect:ze,ariaDescribedById:{draggable:be},dispatch:N,draggableNodes:Se,over:ye,measureDroppableContainers:we}),[R,Oi,G,ze,N,be,Se,ye,we]);return Ai.createElement(b1.Provider,{value:V},Ai.createElement(ef.Provider,{value:Ke},Ai.createElement(s2.Provider,{value:q},Ai.createElement(O1.Provider,{value:et},p)),Ai.createElement(o2,{disabled:m?.restoreFocus===!1})),Ai.createElement(uT,{...m,hiddenTextDescribedById:be}));function Ge(){const at=le?.autoScrollEnabled===!1,xt=typeof g=="object"?g.enabled===!1:g===!1,jt=Q&&!at&&!xt;return typeof g=="object"?{...g,enabled:jt}:{enabled:jt}}}),h2=v.createContext(null),u0="button",f2="Draggable";function B1(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=Qh(f2),{activators:d,activatorEvent:m,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:w}=v.useContext(ef),{role:C=u0,roleDescription:x="draggable",tabIndex:D=0}=o??{},O=g?.id===t,N=v.useContext(O?O1:h2),[B,V]=Dh(),[W,ie]=Dh(),Q=GT(d,t),$=iu(n);Ra(()=>(b.set(t,{id:t,key:c,node:B,activatorNode:W,data:$}),()=>{const ne=b.get(t);ne&&ne.key===c&&b.delete(t)}),[b,t]);const Se=v.useMemo(()=>({role:C,tabIndex:D,"aria-disabled":r,"aria-pressed":O&&C===u0?!0:void 0,"aria-roledescription":x,"aria-describedby":y.draggable}),[r,C,D,O,x,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:p,attributes:Se,isDragging:O,listeners:r?void 0:Q,node:B,over:w,setNodeRef:V,setActivatorNodeRef:ie,transform:N}}const p2="Droppable",m2={timeout:25};function e_(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=Qh(p2),{active:d,dispatch:m,over:g,measureDroppableContainers:p}=v.useContext(ef),y=v.useRef({disabled:n}),b=v.useRef(!1),w=v.useRef(null),C=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:O}={...m2,...o},N=iu(D??r),B=v.useCallback(()=>{if(!b.current){b.current=!0;return}C.current!=null&&clearTimeout(C.current),C.current=setTimeout(()=>{p(Array.isArray(N.current)?N.current:[N.current]),C.current=null},O)},[O]),V=Jh({callback:B,disabled:x||!d}),W=v.useCallback((Se,ne)=>{V&&(ne&&(V.unobserve(ne),b.current=!1),Se&&V.observe(Se))},[V]),[ie,Q]=Dh(W),$=iu(t);return v.useEffect(()=>{!V||!ie.current||(V.disconnect(),b.current=!1,V.observe(ie.current))},[ie,V]),v.useEffect(()=>(m({type:Hi.RegisterDroppable,element:{id:r,key:c,disabled:n,node:ie,rect:w,data:$}}),()=>m({type:Hi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:Hi.SetDroppableDisabled,id:r,key:c,disabled:n}),y.current.disabled=n)},[r,c,n,m]),{active:d,rect:w,isOver:g?.id===r,node:ie,over:g,setNodeRef:Q}}const g2=128,v2=512,wl=100,_2="too_many_detached_terminals",b2=64,y2=4096;function j1(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>g2)return null;const n=t.workspaces.map(S2);return n.some(r=>r===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function z1(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>wl}):!1}function S2(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>v2)return null;const n=t.tabs.map(w2);if(n.some(o=>o===null))return null;const r=E2(t.detachedTerminalIds,wl);return r===null?null:{id:t.id,title:t.title,defaultCwd:k2(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function w2(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=C2(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function C2(e){if(!e||typeof e!="object")return null;let t=0;return ug(e,1,()=>(t+=1,t<=y2))}function ug(e,t,n){if(!e||typeof e!="object"||t>b2||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=ug(r.first,t+1,n),c=ug(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:x2(r.ratio),first:o,second:c}}function x2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function k2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function E2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const I1=[{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"}],T2="nterminal-focus",D2=/^[A-Za-z0-9_.:-]{1,128}$/;function R2(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(T2)!=="terminal"?null:tf({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function tf(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!d0(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!d0(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function d0(e){return typeof e=="string"&&D2.test(e)}const Xi="__main__",P1=128,M2=600*1e3,H1="nterminal.clientDiagnostics.v1",U1=150,N2=24,A2=160;let h0=!1,kc=null;function L2(){h0||typeof window>"u"||(h0=!0,yn("page.load",{navigation:F2(),visibility:document.visibilityState,online:navigator.onLine,viewport:W1(),standalone:K2()}),document.addEventListener("visibilitychange",()=>{yn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{yn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{yn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>yn("network.online")),window.addEventListener("offline",()=>yn("network.offline")),window.addEventListener("focus",()=>yn("window.focus")),window.addEventListener("blur",()=>yn("window.blur")),window.addEventListener("error",e=>{yn("runtime.error",{message:e.message,source:W2(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{yn("runtime.unhandledrejection",{reason:$2(e.reason)})}))}function yn(e,t={}){const n={at:new Date().toISOString(),event:nf(e,80),data:F1({...t,visibility:t.visibility??H2(),online:t.online??U2(),viewport:t.viewport??W1()})},r=K1();return r.push(n),O2(r.slice(-U1)),n}function K1(){try{const e=window.localStorage.getItem(H1);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(B2).filter(n=>n!==null).slice(-U1):[]}catch{return[]}}async function t_(e,t=fetch){if(kc)return kc;const n=K1(),r={reason:nf(e,80),events:n},o=JSON.stringify(r);kc=(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 kc}finally{kc=null}}function O2(e){try{window.localStorage.setItem(H1,JSON.stringify(e))}catch{}}function B2(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:nf(t.event,80),...t.data&&typeof t.data=="object"?{data:F1(t.data)}:{}}}function F1(e){const t={};for(const[n,r]of Object.entries(e).slice(0,N2)){const o=nf(n,64);if(!o||j2(o))continue;const c=z2(r);c!==void 0&&(t[o]=c)}return t}function j2(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function z2(e){if(typeof e=="string")return I2(e,A2);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function nf(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function I2(e,t){return P2(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function P2(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 H2(){return typeof document>"u"?void 0:document.visibilityState}function U2(){return typeof navigator>"u"?void 0:navigator.onLine}function W1(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function K2(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function F2(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function W2(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 $2(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const $1="nterminal.notifications.completionEnabled",i_="nterminal.notifications.completionToastEnabled",n_="nterminal.notifications.completionToastDurationSeconds",s_="nterminal.notifications.completionToastPersistent",dg="nterminal:completion-toast-display",hg="nterminal:notification-focus",Xc=6.5,fg=2,pg=60;function sf(){return typeof window<"u"&&"Notification"in window}function r_(){try{return window.localStorage.getItem($1)==="true"}catch{return!1}}function f0(e){try{window.localStorage.setItem($1,e?"true":"false")}catch{}}function po(){return{enabled:X2(),durationSeconds:Y2(),persistUntilDismissed:G2()}}function q2(e){if(typeof window<"u"){try{window.localStorage.setItem(i_,e?"true":"false")}catch{}a_()}return po()}function p0(e){const t=V1(e);if(typeof window<"u"){try{window.localStorage.setItem(n_,String(t))}catch{}a_()}return po()}function V2(e){if(typeof window<"u"){try{window.localStorage.setItem(s_,e?"true":"false")}catch{}a_()}return po()}function q1(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===i_||n.key===n_||n.key===s_)&&e()};return window.addEventListener(dg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(dg,e),window.removeEventListener("storage",t)}}function Cl(){return sf()?window.Notification.permission:"unsupported"}function Y2(){if(typeof window>"u")return Xc;try{const e=window.localStorage.getItem(n_);return e===null?Xc:V1(Number(e))}catch{return Xc}}function X2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(i_)!=="false"}catch{return!0}}function G2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(s_)==="true"}catch{return!1}}function V1(e){if(!Number.isFinite(e))return Xc;const t=Math.round(e*2)/2;return Math.max(fg,Math.min(pg,t))}function a_(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(dg))}async function Y1(){if(!sf())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Cl()}}function Z2(e){if(!sf()||Cl()!=="granted"||!r_()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=tf({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),Q2(r)})}catch{}}function Q2(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(hg,{detail:e}))}const m0="nterminal.push.clientId",J2=2e4,g0=[5e3,3e4,12e4];function Er(){try{const e=window.localStorage.getItem(m0);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${gg()}`;return window.localStorage.setItem(m0,t),t}catch{return`client-${gg()}`}}function eD(){return`page-${gg()}`}function rf(){const e=typeof window<"u"&&window.isSecureContext===!0,t=oD(),n=lD(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function tD(e,t){const n=rf();if(!n.supported)throw new Error(n.reason);if((Cl()==="granted"?"granted":await Y1())!=="granted")throw new Error("permission_denied");const o=Er(),c=await navigator.serviceWorker.register("/sw.js"),d=await e.preparePushNotifications(o),g=await uD(c,d.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Z1(d.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:G1(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:X1(n.deviceKind),alwaysNotify:t})}async function iD(e){const t=rf();if(!t.supported||Cl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Er(),c=await dD(r.endpoint),d=await e.getPushNotificationStatus(o,c);if(d.currentDevice&&d.endpointRegistered===!0&&d.vapidPublicKey&&mg(r,d.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=d.endpointRegistered===!0&&mg(r,m.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Z1(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:G1(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:X1(t.deviceKind),alwaysNotify:!1}),!0}function nD(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},d=y=>{t||n||(n=!0,iD(e).then(b=>{r=0,b&&yn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(yn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&r<g0.length){const w=g0[r++];o=window.setTimeout(()=>{o=null,d("retry")},w)}}).finally(()=>{n=!1}))},m=y=>{c(),r=0,d(y)},g=()=>m("online"),p=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),d("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function sD(e){const t=Er();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function rD(e,t){await e.updatePushNotificationDevice({clientId:Er(),alwaysNotify:t})}function aD(e){if(typeof window>"u")return()=>{};const t=Er(),n=eD();let r=null,o=!1;const c=(p=!0)=>{const y=rf();e.updatePushPresence({clientId:t,pageId:n,visibilityState:cD(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:r_()&&Cl()==="granted",active:p}).catch(()=>{})},d=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),J2))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),d(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function oD(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function lD(){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 X1(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function cD(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function G1(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function uD(e,t){const n=await e.pushManager.getSubscription();return n?mg(n,t)?n:(await n.unsubscribe(),null):null}function mg(e,t){const n=e.options.applicationServerKey;return n?Q1(n)===t:!0}async function dD(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Q1(t)}function Z1(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let d=0;d<r.length;d+=1)c[d]=r.charCodeAt(d);return o}function Q1(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function gg(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function kr(e,t){const n=[Xi,...t.map(d=>d.id)],r=new Set(n),o=new Set,c=[];for(const d of e??[])!r.has(d)||o.has(d)||(o.add(d),c.push(d));for(const d of n)o.has(d)||c.push(d);return c}function hD(e,t){return kr(e,t).map(n=>n===Xi?null:n)}function fD(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function pD(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const v0="Local",mD=3e4,gD=2,vD=6,J1="nterminal.serverList.viewMode.v1";function _D(){try{return window.localStorage.getItem(J1)==="list"?"list":"stats"}catch{return"stats"}}function bD(e){try{window.localStorage.setItem(J1,e)}catch{}}function yD(e,t){const n=new Map(e.map(r=>[r.id,r]));return kr(t,e).flatMap(r=>{if(r===Xi)return[{kind:"main",id:Xi}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function _0(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function eC(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${hs(e.value.cpuPercent)} ${o_(e.value)}`,`MEM ${hs(e.value.memoryPercent)} ${Dr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${hs(e.value.diskPercent)} ${Dr(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${hs(e.value.swapPercent)} ${Dr(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function b0(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${hs(e.value.cpuPercent)} (${o_(e.value)})`,`RAM ${hs(e.value.memoryPercent)} (${Dr(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${hs(e.value.diskPercent)} (${Dr(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${hs(e.value.swapPercent)} (${Dr(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function SD(e,t){const n=eC(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function hs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function o_(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`:`${vg(e.cpuPercent/100*t)}/${t} cores`}function Dr(e,t){return!y0(e)||!y0(t)?"–/–":wD(e,t)}function wD(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${vg(e/r)}/${vg(t/r)} ${n}`}function vg(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function y0(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Xd(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function CD(e){return[{label:"CPU",percent:hs(e.cpuPercent),detail:o_(e),tone:Xd(e.cpuPercent)},{label:"MEM",percent:hs(e.memoryPercent),detail:Dr(e.memoryUsedBytes,e.memoryTotalBytes),tone:Xd(e.memoryPercent)},{label:"DISK",percent:hs(e.diskPercent),detail:Dr(e.diskUsedBytes,e.diskTotalBytes),tone:Xd(e.diskPercent)},{label:"SWAP",percent:hs(e.swapPercent),detail:Dr(e.swapUsedBytes,e.swapTotalBytes),tone:Xd(e.swapPercent)}]}function xD({entry:e}){return e?.status==="offline"?f.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?f.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=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t}),f.jsx("span",{className:"server-list-stat-value",children:"–"})]}),f.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):f.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:b0(e),"aria-label":b0(e),children:CD(e.value).map(t=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t.label}),f.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),f.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function S0({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,renderServerChildren:d,compact:m=!1}){const[g,p]=v.useState([]),[y,b]=v.useState([Xi]),[w,C]=v.useState(null),[x,D]=v.useState(null),[O,N]=v.useState(""),B=v.useRef(null),[V,W]=v.useState(()=>_D()),[ie,Q]=v.useState(null),[$,Se]=v.useState(null),[ne,Te]=v.useState({}),te=v.useRef({}),Y=v.useRef(0),G=v.useRef([]),F=v.useRef([Xi]),le=v.useRef(null);v.useEffect(()=>{G.current=g},[g]),v.useEffect(()=>{const re=kr(y,g);F.current=re,_0(re,y)||b(re)},[g,y]),v.useEffect(()=>{let re=!1;return e.listAgents().then(he=>{re||(p(he.agents),b(kr(he.serverOrder,he.agents)))}).catch(()=>{}),e.getMainInfo().then(he=>{re||C(he.name)}).catch(()=>{}),()=>{re=!0}},[e,o]),v.useEffect(()=>{x&&(B.current?.focus(),B.current?.select())},[x]),v.useEffect(()=>{let re=!1;function he(){const ue=[{key:Xi,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...g.map(Ne=>({key:Ne.id,load:()=>e.getAgentStats(Ne.id),probe:async()=>(await e.pingAgent(Ne.id)).ok}))],Re=new Set(ue.map(Ne=>Ne.key));for(const Ne of Object.keys(te.current))Re.has(Ne)||delete te.current[Ne];Te(Ne=>{const ee={};for(const Ee of Re)Ee in Ne&&(ee[Ee]=Ne[Ee]);return ee});for(const Ne of ue)Ne.load().then(ee=>{re||(te.current[Ne.key]=0,Te(Ee=>Re.has(Ne.key)?{...Ee,[Ne.key]:{status:"online",value:ee,stale:!1}}:Ee))}).catch(async ee=>{if(re)return;if(ee instanceof Bn&&ee.status===401&&Ne.key===Xi){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(Ne.key===Xi&&ee instanceof Bn){te.current[Ne.key]=0,Te(me=>{if(!Re.has(Ne.key))return me;const Oe=me[Ne.key];return{...me,[Ne.key]:{status:"online",value:Oe?.value??null,stale:!0}}});return}if(Ne.probe)try{if(await Ne.probe()){if(re)return;te.current[Ne.key]=0,Te(me=>{if(!Re.has(Ne.key))return me;const Oe=me[Ne.key];return{...me,[Ne.key]:{status:"online",value:Oe?.value??null,stale:!0}}});return}}catch(me){if(re)return;if(me instanceof Bn&&me.status===401){r?.({source:Ne.key===Xi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const Ee=(te.current[Ne.key]??0)+1;te.current[Ne.key]=Ee,Ee>=gD&&Te(me=>Re.has(Ne.key)?{...me,[Ne.key]:{status:"offline",value:me[Ne.key]?.value??null,stale:!0}}:me)})}he();const H=window.setInterval(he,mD);return()=>{re=!0,window.clearInterval(H)}},[e,g,r]);function L(re){re==="main"?(N(w??""),D({kind:"main"})):(N(re.name),D({kind:"agent",id:re.id}))}async function R(){if(!x)return;const re=O.trim(),he=x;if(D(null),he.kind==="main"){const H=re||"";try{const ue=await e.renameMain(H);C(ue.name)}catch{}}else{if(!re)return;const H=g.find(ue=>ue.id===he.id)?.name;p(ue=>ue.map(Re=>Re.id===he.id?{...Re,name:re}:Re));try{await e.renameAgent(he.id,re)}catch{H!==void 0&&p(ue=>ue.map(Re=>Re.id===he.id?{...Re,name:H}:Re))}}}function j(){D(null)}function ae(re){W(re),bD(re)}function be(re,he,H){if(re===he)return;const ue=kr(F.current,G.current),Re=ue.findIndex(st=>st===re),Ne=ue.findIndex(st=>st===he);if(Re<0||Ne<0)return;const ee=[...ue],[Ee]=ee.splice(Re,1);if(!Ee)return;const me=ee.findIndex(st=>st===he);if(me<0)return;const Oe=H==="before"?me:me+1;if(ee.splice(Oe,0,Ee),_0(ee,ue))return;const Ie=Y.current+1;Y.current=Ie,F.current=ee,b(ee),e.reorderAgents(ee).then(st=>{if(Y.current===Ie){G.current=st.agents;const ot=kr(st.serverOrder,st.agents);F.current=ot,p(st.agents),b(ot)}}).catch(async()=>{if(Y.current===Ie)try{const st=await e.listAgents();if(Y.current===Ie){G.current=st.agents;const ot=kr(st.serverOrder,st.agents);F.current=ot,p(st.agents),b(ot)}}catch{Y.current===Ie&&(F.current=ue,b(ue))}})}function M(re,he){const H=kr(F.current,G.current),ue=H.findIndex(Ne=>Ne===re),Re=H[ue+he];ue<0||!Re||be(re,Re,he<0?"before":"after")}function K(re,he){he.pointerType==="mouse"&&he.button!==0||(he.stopPropagation(),le.current={sourceId:re,pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,active:!1,targetId:null,placement:"after"},he.currentTarget.setPointerCapture?.(he.pointerId))}function ce(re){const he=le.current;if(!he||he.pointerId!==re.pointerId)return;const H=Math.hypot(re.clientX-he.startX,re.clientY-he.startY);if(!he.active){if(H<vD)return;he.active=!0,Q(he.sourceId)}const Re=document.elementFromPoint(re.clientX,re.clientY)?.closest("[data-server-id]"),Ne=Re?.dataset.serverId??null;if(!Re||!Ne||Ne===he.sourceId){he.targetId=null,Se(null);return}const ee=Re.getBoundingClientRect(),Ee=re.clientY<ee.top+ee.height/2?"before":"after";he.targetId=Ne,he.placement=Ee,Se({serverId:Ne,placement:Ee})}function we(re){const he=le.current;!he||he.pointerId!==re.pointerId||(re.stopPropagation(),re.currentTarget.releasePointerCapture?.(re.pointerId),le.current=null,Q(null),Se(null),he.active&&he.targetId&&be(he.sourceId,he.targetId,he.placement))}function Le(re){const he=le.current;he&&he.pointerId===re.pointerId&&re.currentTarget.releasePointerCapture?.(re.pointerId),le.current=null,Q(null),Se(null)}const xe=w?.trim()||v0,Be=x?.kind==="main",De=V==="stats",He=yD(g,y),ze=He.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:xe},...g.map(re=>({agentId:re.id,label:re.name}))])},[g,xe,c]),m?f.jsx("div",{className:"server-list server-list--compact",children:He.map(re=>{const he=re.kind==="main",H=he?xe:re.agent.name,ue=he?Xi:re.id,Re=ne[ue],Ne=eC(Re);return f.jsxs("button",{type:"button",className:`server-list-chip${(he?t===null:t===re.id)?" server-list-chip--active":""}`,onClick:()=>n(he?null:re.id),"aria-label":`${H}${Ne?` — ${Ne}`:""}`,title:`${H}${Ne?` — ${Ne}`:""}`,children:[f.jsx("span",{className:"server-list-chip-initial",children:pD(H)}),f.jsx("span",{className:"server-list-chip-pip","data-status":fD(Re)})]},re.id)})}):f.jsxs("div",{className:`server-list server-list--${V}`,children:[f.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":V==="list",onClick:()=>ae("list"),title:"Show server names only",children:"List"}),f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":V==="stats",onClick:()=>ae("stats"),title:"Show resource usage",children:"Stats"})]}),He.map(re=>{const he=re.kind==="main",H=he?xe:re.agent.name,ue=he?Xi:re.id,Re=he?t===null:t===re.id,Ne=he?Be:x?.kind==="agent"&&x.id===re.id,ee=d?.({agentId:he?null:re.id,serverId:re.id,label:H,active:Re}),Ee=$?.serverId===re.id&&ie!==re.id?` server-list-section--drop-target server-list-section--drop-${$.placement}`:"";return f.jsxs("section",{className:`server-list-section${Ee}`,"aria-label":`${H} server`,children:[f.jsx("div",{className:["server-list-row",ie===re.id?"server-list-row--dragging":"",$?.serverId===re.id&&ie!==re.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":re.id,children:Ne?f.jsxs(f.Fragment,{children:[ze?f.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,f.jsx("form",{className:"server-list-editor",onSubmit:me=>{me.preventDefault(),R()},children:f.jsx("input",{ref:B,"aria-label":he?"Rename main server":`Rename ${H}`,value:O,onChange:me=>N(me.target.value),onBlur:()=>{R()},onKeyDown:me=>{me.key==="Escape"&&(me.preventDefault(),j())},placeholder:he?v0:void 0})})]}):f.jsxs(f.Fragment,{children:[ze?f.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":re.id,title:"Drag to reorder","aria-label":`Reorder ${H}`,"aria-grabbed":ie===re.id,onPointerDown:me=>K(re.id,me),onPointerMove:ce,onPointerUp:we,onPointerCancel:Le,onKeyDown:me=>{(me.key==="ArrowUp"||me.key==="ArrowDown")&&(me.preventDefault(),me.stopPropagation(),M(re.id,me.key==="ArrowUp"?-1:1))},onClick:me=>me.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:`server-list-item${Re?" server-list-item--active":""}`,onClick:()=>n(he?null:re.id),onDoubleClick:me=>{me.preventDefault(),L(he?"main":{id:re.id,name:H})},title:SD(H,ne[ue]),children:[f.jsxs("span",{className:"server-list-item-header",children:[f.jsx("span",{className:"server-list-dot"}),f.jsx("span",{className:"server-list-name",title:he?void 0:re.agent.url??"Outbound connection to main",children:H})]}),De?f.jsx(xD,{entry:ne[ue]}):null]})]})}),ee?f.jsx("div",{className:"server-list-children",children:ee}):null]},re.id)})]})}function kD({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,d]=v.useState(!1),[m,g]=v.useState(null),[p,y]=v.useState(""),[b,w]=v.useState("");async function C(){try{const[N,B,V]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(N.devices),o(B.networks),d(V.totpEnabled),g(null)}catch(N){g(N instanceof Error?N.message:"Failed to load")}}v.useEffect(()=>{C()},[]);async function x(N){await e.revokeDevice(N),await C()}async function D(N){await e.removeNetwork(N),await C()}async function O(N){N.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),w(""),await C()}catch(B){g(B instanceof Error?B.message:"Failed to add network")}}return f.jsxs(f.Fragment,{children:[m?f.jsx("p",{className:"form-error",children:m}):null,f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted devices"}),f.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?f.jsx("p",{className:"muted",children:"No trusted devices."}):f.jsx("ul",{className:"security-list",children:t.map(N=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[N.label,N.current?f.jsx("span",{className:"security-badge",children:"this device"}):null]}),f.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(N.lastSeenAt).toLocaleString()]})]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(N.id)},children:"revoke"})]},N.id))})]}),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted networks"}),f.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?f.jsx("p",{className:"muted",children:"No trusted networks."}):f.jsx("ul",{className:"security-list",children:r.map(N=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:N.value}),N.label!==N.value?f.jsx("span",{className:"security-item-meta",children:N.label}):null]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(N.id)},children:"remove"})]},N.id))}),f.jsxs("form",{className:"security-add-form",onSubmit:O,children:[f.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:N=>y(N.currentTarget.value),required:!0}),f.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:N=>w(N.currentTarget.value)}),f.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Two-factor authentication"}),f.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."}),f.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await C()},children:"Disable 2FA"})]}):null]})}const ED=1500,l_="nterminal.terminal.fontSize",c_="nterminal.terminal.fontFamily",_g="nterminal:terminal-font-size",bg="nterminal:terminal-font-family",yg=11,Sg=20,co=14,Ah=[{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:[]}],ml="meslo";wg(ml);async function xm(e=co,t=ml){if(typeof document>"u"||!document.fonts)return;const n=nC(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,ED)})])}function tC(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return co;const n=Math.round(t);return Math.max(yg,Math.min(Sg,n))}function iC(e){return Ah.some(t=>t.id===e)?e:ml}function wg(e){return nC(e).cssFamily}function nC(e){return Ah.find(t=>t.id===e)??Ah[0]}function Cg(){if(typeof window>"u")return co;try{const e=window.localStorage.getItem(l_);return e?tC(e):co}catch{return co}}function xg(){if(typeof window>"u")return ml;try{return iC(window.localStorage.getItem(c_))}catch{return ml}}function Gd(e){const t=tC(e);if(typeof window>"u")return t;try{window.localStorage.setItem(l_,String(t))}catch{}return window.dispatchEvent(new CustomEvent(_g,{detail:t})),t}function TD(e){const t=iC(e);if(typeof window>"u")return t;try{window.localStorage.setItem(c_,t)}catch{}return window.dispatchEvent(new CustomEvent(bg,{detail:t})),t}function sC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===l_&&e()};return window.addEventListener(_g,e),window.addEventListener("storage",t),()=>{window.removeEventListener(_g,e),window.removeEventListener("storage",t)}}function rC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===c_&&e()};return window.addEventListener(bg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(bg,e),window.removeEventListener("storage",t)}}const u_="nterminal.terminal.showScrollProgress",kg="nterminal:terminal-scroll-progress",d_="nterminal.terminal.tmuxScrollback.shell",h_="nterminal.terminal.tmuxScrollback.agent",f_="nterminal.terminal.tmuxScrollback.overrides",su="nterminal:terminal-tmux-scrollback",DD=200;function Eg(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(u_)!=="false"}catch{return!0}}function RD(e){if(typeof window<"u"){try{window.localStorage.setItem(u_,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(kg,{detail:e}))}return e}function aC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===u_&&e()};return window.addEventListener(kg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(kg,e),window.removeEventListener("storage",t)}}function Tg(){return oC(d_,!0)}function MD(e){return lC(d_,e,su)}function Dg(){return oC(h_,!0)}function ND(e){return lC(h_,e,su)}function fh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===d_||n.key===h_||n.key===f_)&&e()};return window.addEventListener(su,e),window.addEventListener("storage",t),()=>{window.removeEventListener(su,e),window.removeEventListener("storage",t)}}function km(e){const n=cC()[e];return typeof n=="boolean"?n:null}function AD(e,t){if(typeof window<"u"){try{const n=cC(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-DD);window.localStorage.setItem(f_,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(su,{detail:{terminalId:e,enabled:t}}))}return t}function oC(e,t){if(typeof window>"u")return t;try{const n=window.localStorage.getItem(e);if(n==="true")return!0;if(n==="false")return!1}catch{}return t}function lC(e,t,n){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(n,{detail:t}))}return t}function cC(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(f_);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const p_="nterminal.shortcuts.workspace.v1",Rg="nterminal:workspace-shortcuts",ru=[{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}],af={"server.previous":di("ArrowUp",{ctrlKey:!0}),"server.next":di("ArrowDown",{ctrlKey:!0}),"tab.previous":di("ArrowLeft",{ctrlKey:!0}),"tab.next":di("ArrowRight",{ctrlKey:!0}),"tab.index":di("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":di("KeyH",{altKey:!0}),"subagents.toggle":di("KeyA",{altKey:!0}),"scrollback.toggle":di("KeyS",{altKey:!0})},LD={"server.previous":di("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":di("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":di("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":di("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":di("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":di("Digit",{ctrlKey:!0,altKey:!0}),"split.right":di("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":di("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":di("KeyH",{altKey:!0}),"subagents.toggle":di("KeyA",{altKey:!0}),"scrollback.toggle":di("KeyS",{altKey:!0})};function mo(){const e=hC(af);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(p_);if(!t)return e;const n=JSON.parse(t);for(const r of ru){const o=n[r.id];if(UD(o)){const c=fC(o,r);HD(c,LD[r.id])||(e[r.id]=c)}}}catch{return e}return e}function w0(){return JSON.stringify(mo())}function OD(e,t){const n=mo(),r=ru.find(o=>o.id===e);return r&&(n[e]=fC(t,r),m_(n)),n}function BD(e){const t=mo();return t[e]={...af[e]},m_(t),t}function jD(){const e=hC(af);return m_(e),e}function Gc(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===p_&&e()};return window.addEventListener(Rg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Rg,e),window.removeEventListener("storage",t)}}function zD(e,t){const n=gC(e);return!n||FD(n)||t.indexed&&mC(e)===null||t.requiresPrimaryModifier&&!pC(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function uC(e){const t=mo();for(const n of ru){const r=t[n.id];if(!(!r||!KD(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=mC(e);if(o!==null)return{id:n.id,index:o};continue}if(gC(e)===r.code)return{id:n.id,index:null}}}return null}function Zc(e){return dC(mo()[e])}function dC(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(WD(e.code)),t.join("+")}const ID=()=>Zc("split.right"),PD=()=>Zc("split.down");function di(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function hC(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function HD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function m_(e){if(!(typeof window>"u")){try{window.localStorage.setItem(p_,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Rg))}}function fC(e,t){return t.requiresPrimaryModifier&&!pC(e)?{...af[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function pC(e){return e.ctrlKey||e.altKey||e.metaKey}function UD(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 KD(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function mC(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 gC(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 FD(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function WD(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const $D="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 qD(e="nterminal",t=new Date){return{reason:"permission",message:$D,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function VD(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 vC=3600*1e3,YD="local",Mg=new Set,Ea=new Map;let Ma={checking:!1,hasUpdates:!1,lastCheckedAt:null},g_=null,Qc=null,Lh=0,Sa=null;function XD(e){return Mg.add(e),()=>{Mg.delete(e)}}function C0(){return Ma}function GD(e){const t=tR();g_=e,v_(),Ng(e,t);const n=()=>{if(document.visibilityState!=="visible"||!Na(e,t))return;const r=Ma.lastCheckedAt;(r===null||Date.now()-r>=vC)&&Ng(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),Na(e,t)&&eR()}}function ZD(e,t){Ea.set(e,_C(t)),gl({...Ma,hasUpdates:__(),lastCheckedAt:Date.now()})}function Em(e){e===void 0?Ea.clear():Ea.set(e,!1),gl({...Ma,hasUpdates:__()})}async function Ng(e,t){if(!Na(e,t))return;if(Sa&&Sa.api===e&&Sa.runId===t)return Sa.promise;gl({...Ma,checking:!0});const n=QD(e,t).finally(()=>{Sa?.promise===n&&(Sa=null),Na(e,t)&&(gl({...Ma,checking:!1,lastCheckedAt:Date.now()}),JD(e,t))});return Sa={api:e,runId:t,promise:n},n}async function QD(e,t){try{const n=await e.listAgents();if(!Na(e,t))return;const r=[{key:YD,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const d=await c.check();o.set(c.key,_C(d))}catch{o.set(c.key,Ea.get(c.key)??!1)}})),!Na(e,t))return;Ea.clear();for(const[c,d]of o)Ea.set(c,d);gl({...Ma,hasUpdates:__()})}catch{}}function JD(e,t){Na(e,t)&&(v_(),Qc=window.setTimeout(()=>{Qc=null,Na(e,t)&&Ng(e,t)},vC))}function eR(){Lh+=1,v_(),g_=null,Sa=null,Ea.clear(),gl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function v_(){Qc!==null&&(window.clearTimeout(Qc),Qc=null)}function tR(){return Lh+=1,Lh}function Na(e,t){return g_===e&&Lh===t}function _C(e){return e.updateAvailable===!0}function __(){return Array.from(Ea.values()).some(Boolean)}function gl(e){Ma=e;for(const t of Array.from(Mg))t()}const iR=e=>new Promise(t=>setTimeout(t,e));function nR({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[d,m]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[w,C]=v.useState({});function x(R,j){c(ae=>({...ae,[R]:{...ae[R],...j}}))}function D(R,j){C(ae=>({...ae,[R]:{status:ae[R]?.status??null,busy:ae[R]?.busy??!1,error:ae[R]?.error??null,...j}}))}const O=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),N=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),B=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),V=R=>R.id===null?e:fl(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async j=>{if(R)return;let ae="Local";try{ae=(await e.getMainInfo()).name?.trim()||ae}catch{}if(R)return;const be=new Map(j.agents.map(K=>[K.id,K])),M=kr(j.serverOrder,j.agents).flatMap(K=>{if(K===Xi)return[{key:"local",id:null,name:ae}];const ce=be.get(K);return ce?[{key:ce.id,id:ce.id,name:ce.name}]:[]});r(M);for(const K of M)O(K).then(ce=>x(K.key,{version:ce,manualUpdate:ce.manualUpdate??null})).catch(ce=>x(K.key,{error:ce instanceof Error?ce.message:"unreachable"})),F(K)}).catch(()=>{}),()=>{R=!0}},[]);async function W(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const j=await N(R);ZD(R.key,j),x(R.key,{latestVersion:j.latestVersion,updateAvailable:j.updateAvailable,status:te(j),...j.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(j){x(R.key,{busy:!1,error:j instanceof Error?j.message:"check failed"})}}async function ie(){m(!0),await Promise.all(n.map(R=>W(R))),m(!1)}async function Q(R,j){const ae=Date.now()+18e4;for(;Date.now()<ae;){await iR(3e3);try{const be=await O(R);if(j&&be.runningVersion!==j.runningVersion)return be}catch{}}return null}async function $(R){let j=o[R.key]?.version;if(!j)try{j=await O(R),x(R.key,{version:j,manualUpdate:j.manualUpdate??null})}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}x(R.key,{busy:!0,status:"updating…",error:void 0});let ae;try{ae=await B(R)}catch(M){return x(R.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!ae.ok){const M=ae.manualUpdate??(VD(ae.message)?qD():null);return M?(x(R.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(x(R.key,{busy:!1,status:void 0,error:ae.message}),"failed")}if(!ae.changed)return x(R.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Em(R.key),"unchanged";x(R.key,{status:"restarting…"});const be=await Q(R,j);return be?(x(R.key,{busy:!1,version:be,updateAvailable:!1,status:"updated",manualUpdate:be.manualUpdate??null}),Em(R.key),R.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(x(R.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function Se(R){if(!(R.id===null||!window.confirm([`Delete secondary server "${R.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){x(R.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const ae=await e.uninstallAgent(R.id);r(be=>be.filter(M=>M.key!==R.key)),c(be=>{const M={...be};return delete M[R.key],M}),Em(R.key),t?.(R.id),p(ae.message)}catch(ae){x(R.key,{busy:!1,status:void 0,error:ae instanceof Error?ae.message:"delete failed"})}}}async function ne(){m(!0),p(null);const R=n.filter(ce=>ce.id!==null),j=n.find(ce=>ce.id===null),ae=await Promise.all(R.map(ce=>$(ce))),be=ae.filter(ce=>ce==="failed").length;let M=ae.filter(ce=>ce==="manual").length,K=null;if(j&&(K=await $(j),K==="manual"&&(M+=1),K==="updated")){be>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),m(!1);return}be>0&&M>0?p("Some servers failed and some need manual update. Check each marked row."):be>0?p("Some secondary servers failed to update. Check their rows and retry."):M>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function Te(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 j=R?.version;return j?`npm package v${j.runningVersion}`:""}async function G(R,j){try{await rR(j),x(R,{copiedCommand:!0}),window.setTimeout(()=>x(R,{copiedCommand:!1}),1800)}catch(ae){x(R,{error:ae instanceof Error?ae.message:"copy failed"})}}async function F(R,j=!1){try{const ae=await V(R).getCodeServerStatus(j?{checkLatest:!0}:void 0);D(R.key,{status:ae,error:null})}catch(ae){D(R.key,{error:ae instanceof Error?ae.message:"code-server status failed"})}}async function le(R,j){if(j==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const ae=V(R);D(R.key,{busy:!0,error:null});try{if(j==="install"){const be=await ae.installCodeServer();D(R.key,{status:be.status})}else if(j==="update"){const be=await ae.updateCodeServer();D(R.key,{status:be.status})}else if(j==="stop")D(R.key,{status:await ae.stopCodeServer()});else{const be=await ae.uninstallCodeServer();D(R.key,{status:be.status})}}catch(be){D(R.key,{error:be instanceof Error?be.message:"code-server action failed"})}finally{D(R.key,{busy:!1})}}const L=n.filter(R=>w[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(ae=>w[ae.key]?.status?.job?.status==="running");if(R.length===0)return;const j=window.setInterval(()=>{for(const ae of R)F(ae)},1e3);return()=>window.clearInterval(j)},[L]),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Servers"}),f.jsxs("div",{className:"update-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ie()},disabled:d,children:"Check for updates"}),f.jsx("button",{type:"button",onClick:()=>{ne()},disabled:d,children:"Update all"})]}),g?f.jsx("p",{className:"settings-status",children:g}):null,y?f.jsxs("div",{className:"server-reload-required",role:"status",children:[f.jsx("span",{children:"Main server update is ready."}),f.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,f.jsx("ul",{className:"security-list",children:n.map(R=>{const j=o[R.key],ae=Y(j),be=j?.manualUpdate??null,M=w[R.key]??{status:null,busy:!1,error:null},K=j?.version!==void 0&&j?.updateAvailable!==!1&&!j?.busy&&!d,ce=R.id!==null&&!j?.busy&&!d;return f.jsxs("li",{children:[f.jsxs("div",{className:"server-row-main",children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[R.name,R.id===null?f.jsx("span",{className:"security-badge",children:"Main"}):null]}),f.jsxs("span",{className:"security-item-meta",children:[ae?`${ae} — `:"",Te(j)]})]}),be?f.jsxs("div",{className:"server-manual-update",children:[f.jsx("span",{children:be.message}),f.jsxs("div",{className:"server-manual-command",children:[f.jsx("code",{children:be.command}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{G(R.key,be.command)},children:j?.copiedCommand?"Copied":"Copy"})]})]}):null,f.jsx(sR,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{F(R,!0)},onInstall:()=>{le(R,"install")},onUpdate:()=>{le(R,"update")},onStop:()=>{le(R,"stop")},onUninstall:()=>{le(R,"uninstall")}})]}),f.jsxs("div",{className:"server-row-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{$(R)},disabled:!K,children:j?.busy?"…":"Update"}),R.id!==null?f.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{Se(R)},disabled:!ce,children:"Delete"}):null]})]},R.key)})})]})}function sR({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onStop:d,onUninstall:m}){const g=e?.job??null,p=g?.status==="running",y=e!==null,b=e?.installed===!0,w=(e?.instances.length??0)>0,C=e?.supported!==!1,x=e===null&&!n;return f.jsxs("div",{className:"server-code-addon",children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),f.jsxs("span",{className:"security-item-meta",children:[C?x?"checking...":b?`code-server v${e?.version??"unknown"}${w?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?f.jsx("p",{className:"settings-error",children:n}):null,g?f.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
|
|
16
|
+
`):`${g.action} ${g.status}`}):null,f.jsxs("div",{className:"server-code-addon-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:t||p||!C,children:"Check"}),b?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||p||!C,children:e?.updateAvailable?"Update code-server":"Reinstall"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||p||!w,children:"Stop"}),f.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||p,children:"Uninstall"})]}):f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:!y||x||t||p||!C,children:"Install code-server"})]})]})}async function rR(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 Zd=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function aR({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??Xh(),[t]),[d,m]=v.useState(()=>Cg()),[g,p]=v.useState(()=>xg()),[y,b]=v.useState(()=>Eg()),[w,C]=v.useState(()=>Tg()),[x,D]=v.useState(()=>Dg()),[O,N]=v.useState(()=>Da()),[B,V]=v.useState(()=>mo()),[W,ie]=v.useState(null),[Q,$]=v.useState(null),[Se,ne]=v.useState("appearance"),[Te,te]=v.useState(()=>r_()),[Y,G]=v.useState(()=>po()),[F,le]=v.useState(()=>Cl()),[L,R]=v.useState([]),[j,ae]=v.useState([]),[be,M]=v.useState([]),[K,ce]=v.useState(5*1024*1024),[we,Le]=v.useState(!1),[xe,Be]=v.useState(null),[De,He]=v.useState(null),[ze,re]=v.useState(!1),[he,H]=v.useState(null),[ue,Re]=v.useState(null),Ne=v.useRef(null),ee=v.useRef(null),Ee=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),me=v.useMemo(()=>new Set(j),[j]),Oe=!lR(j,be),Ie=v.useMemo(()=>rf(),[]),st=De?.displayMode==="standalone"&&(De.deviceKind==="mobile"||De.deviceKind==="tablet");v.useEffect(()=>sC(()=>m(Cg())),[]),v.useEffect(()=>rC(()=>p(xg())),[]),v.useEffect(()=>aC(()=>b(Eg())),[]),v.useEffect(()=>fh(()=>{C(Tg()),D(Dg())}),[]),v.useEffect(()=>Vv(()=>N(Da())),[]),v.useEffect(()=>Gc(()=>V(mo())),[]),v.useEffect(()=>q1(()=>G(po())),[]),v.useEffect(()=>{if(!W)return;const q=ru.find(Ge=>Ge.id===W);if(!q)return;const Ke=Ge=>{if(Ge.preventDefault(),Ge.stopPropagation(),Ge.key==="Escape"){ie(null),$(null);return}const at=zD(Ge,q);if(!at){$(oR(q));return}V(OD(W,at)),ie(null),$(null)};return window.addEventListener("keydown",Ke,!0),()=>window.removeEventListener("keydown",Ke,!0)},[W]),v.useEffect(()=>{let q=!1;return c.listNotificationAssets().then(Ke=>{q||gt(Ke)}).catch(Ke=>{q||Be(rl(Ke))}),()=>{q=!0}},[c]),v.useEffect(()=>{let q=!1;return c.getPushNotificationStatus(Er()).then(Ke=>{q||(He(Ke.currentDevice),H(null))}).catch(Ke=>{q||H(rl(Ke))}),()=>{q=!0}},[c]);function ot(q){m(Gd(Number(q)))}function Nt(q){G(p0(Number(q)))}function pi(q){ne(q);const Ke=ee.current,Ge=Ee.current[q];if(!Ke||!Ge)return;const at=Math.max(0,x0(Ge,Ke)-12);typeof Ke.scrollTo=="function"?Ke.scrollTo({top:at,behavior:"smooth"}):Ke.scrollTop=at}function Cn(){const q=ee.current;if(!q)return;if(q.scrollTop+q.clientHeight>=q.scrollHeight-2){ne(Zd[Zd.length-1].id);return}let Ke="appearance";const Ge=q.scrollTop+Math.min(180,Math.max(48,q.clientHeight*.28));for(const at of Zd){const xt=Ee.current[at.id];xt&&x0(xt,q)<=Ge&&(Ke=at.id)}ne(Ke)}function Rt(q){V(BD(q)),ie(null),$(null)}function Qe(){V(jD()),ie(null),$(null)}function gt(q){const Ke=q.assets.filter(Ge=>Ge.enabled).map(Ge=>Ge.id);R(q.assets),ae(Ke),M(Ke),ce(q.maxFileBytes),Be(null)}async function Bt(){if(Te){f0(!1),te(!1);return}let q=F;q==="default"&&(q=await Y1(),le(q)),q==="granted"&&(f0(!0),te(!0))}async function ye(){re(!0),H(null),Re(null);try{if(De)await sD(c),He(null);else{await tD(c,!1);const q=await c.getPushNotificationStatus(Er());He(q.currentDevice)}}catch(q){H(Dm(q))}finally{re(!1)}}async function We(q){re(!0),H(null),Re(null);try{await rD(c,q);const Ke=await c.getPushNotificationStatus(Er());He(Ke.currentDevice)}catch(Ke){H(Dm(Ke))}finally{re(!1)}}async function Je(){re(!0),H(null),Re(null);try{await c.testPushNotification({clientId:Er()}),Re("Test notification accepted by the push service.")}catch(q){H(Dm(q))}finally{re(!1)}}async function et(q){const Ke=q?.[0];if(Ke){if(Ke.size>K){Be(`File must be ${Tm(K)} or smaller.`),ft();return}if(Ke.type!=="video/mp4"&&Ke.type!=="video/webm"){Be("Upload an MP4 or WebM video."),ft();return}Le(!0),Be(null);try{await c.uploadNotificationAsset(Ke),gt(await c.listNotificationAssets()),r?.()}catch(Ge){Be(rl(Ge))}finally{Le(!1),ft()}}}async function wt(q){Le(!0),Be(null);try{await c.deleteNotificationAsset(q),gt(await c.listNotificationAssets()),r?.()}catch(Ke){Be(rl(Ke))}finally{Le(!1)}}function ft(){Ne.current&&(Ne.current.value="")}function xn(q,Ke){const Ge=new Set(j);if(Ke?Ge.add(q):Ge.delete(q),Ge.size===0){Be("Keep at least one toast video selected.");return}Be(null),ae(Array.from(Ge))}async function Oi(){if(j.length===0){Be("Keep at least one toast video selected.");return}Le(!0),Be(null);try{const q=await c.updateNotificationAssetSelection({enabledAssetIds:j});gt(q),r?.()}catch(q){Be(rl(q))}finally{Le(!1)}}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:f.jsxs("div",{className:"security-panel settings-panel",onClick:q=>q.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{children:"Settings"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),f.jsxs("div",{className:"settings-layout",children:[f.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Zd.map(q=>f.jsxs("button",{type:"button","data-active":Se===q.id?"true":"false","aria-current":Se===q.id?"true":void 0,onClick:()=>pi(q.id),children:[q.label,q.id==="servers"&&n?f.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},q.id))}),f.jsxs("div",{ref:ee,className:"settings-content",onScroll:Cn,children:[f.jsxs("section",{id:"settings-appearance",ref:q=>{Ee.current.appearance=q},className:"security-section settings-section",children:[f.jsx("h3",{children:"Appearance"}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Theme"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),f.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Th.map(q=>f.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":O===q.id,"data-active":O===q.id?"true":"false",onClick:()=>N(VE(q.id)),style:{"--settings-theme-bg":q.tokens.bg,"--settings-theme-bg-2":q.tokens.bg2,"--settings-theme-sidebar":q.tokens.bgSidebar,"--settings-theme-line":q.tokens.line,"--settings-theme-fg":q.tokens.fg,"--settings-theme-fg-2":q.tokens.fg2,"--settings-theme-accent":q.tokens.accent,"--settings-theme-xterm-bg":q.xterm.background,"--settings-theme-xterm-fg":q.xterm.foreground,"--settings-theme-xterm-selection":q.xterm.selectionBackground},children:[f.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[f.jsxs("span",{className:"settings-theme-preview-sidebar",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-main",children:[f.jsxs("span",{className:"settings-theme-preview-tabs",children:[f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-terminal",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})]})]}),f.jsxs("span",{className:"settings-theme-card-copy",children:[f.jsx("strong",{children:q.label}),f.jsx("small",{children:q.description})]})]},q.id))}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font size"}),f.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),f.jsx("input",{type:"range",min:yg,max:Sg,step:1,value:d,"aria-label":"Terminal font size",onChange:q=>ot(q.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row",children:[f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Gd(d-1)),children:"-"}),f.jsx("input",{type:"number",min:yg,max:Sg,step:1,value:d,"aria-label":"Terminal font size value",onChange:q=>ot(q.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(Gd(d+1)),children:"+"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(Gd(co)),children:"Reset"})]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font family"}),f.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:q=>p(TD(q.currentTarget.value)),children:Ah.map(q=>f.jsx("option",{value:q.id,children:q.label},q.id))})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:y,onChange:q=>b(RD(q.currentTarget.checked))}),"Show scroll progress"]}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:w,onChange:q=>C(MD(q.currentTarget.checked))}),"Shell panes"]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:x,onChange:q=>D(ND(q.currentTarget.checked))}),"Codex/Claude panes"]})]}),f.jsxs("section",{id:"settings-shortcuts",ref:q=>{Ee.current.shortcuts=q},className:"security-section settings-section",children:[f.jsxs("div",{className:"settings-section-heading",children:[f.jsx("h3",{children:"Shortcuts"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:Qe,children:"Reset all"})]}),f.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),Q?f.jsx("p",{className:"settings-error",children:Q}):null,f.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ru.map(q=>{const Ke=W===q.id;return f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"settings-shortcut-label",children:q.label}),f.jsx("span",{className:"settings-shortcut-group",children:q.group})]}),f.jsxs("div",{className:"settings-shortcut-actions",children:[f.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ke?"true":"false",onClick:()=>{ie(q.id),$(null)},children:Ke?"Press keys…":dC(B[q.id])}),f.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Rt(q.id),children:"Reset"})]})]},q.id)})})]}),f.jsxs("section",{id:"settings-notifications",ref:q=>{Ee.current.notifications=q},className:"security-section settings-section",children:[f.jsx("h3",{children:"Notifications"}),sf()?f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Te&&F==="granted",onChange:()=>{Bt()},disabled:F==="denied"}),"System notification when page is hidden"]}),F==="denied"?f.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."}):f.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):f.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),f.jsxs("div",{className:"settings-subsection",children:[f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:!!De,onChange:()=>{ye()},disabled:ze||!Ie.supported}),"Installed app push notifications"]}),f.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ie.supported?null:f.jsx("p",{className:"muted",children:ph(Ie.reason)}),De?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"muted",children:["Registered as ",De.label,". Last active ",new Date(De.lastActiveAt).toLocaleString(),"."]}),f.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{Je()},disabled:ze,children:"Send test notification"})]}):null,st?f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:De?.alwaysNotify===!0,onChange:q=>{We(q.currentTarget.checked)},disabled:ze||!De}),"Always notify this mobile device"]}):null,he?f.jsx("p",{className:"form-error",children:he}):null,ue?f.jsx("p",{className:"muted",role:"status",children:ue}):null]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Y.enabled,onChange:q=>G(q2(q.currentTarget.checked))}),"Show animated completion toast"]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Toast duration"}),f.jsx("span",{className:"settings-control-value",children:Y.persistUntilDismissed?"Until closed":`${Y.durationSeconds}s`}),f.jsx("input",{type:"range",min:fg,max:pg,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:q=>Nt(q.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[f.jsx("input",{type:"number",min:fg,max:pg,step:.5,value:Y.durationSeconds,disabled:!Y.enabled||Y.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:q=>Nt(q.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!Y.enabled||Y.persistUntilDismissed,onClick:()=>G(p0(Xc)),children:"Reset"})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Y.persistUntilDismissed,disabled:!Y.enabled,onChange:q=>G(V2(q.currentTarget.checked))}),"Keep toast until dismissed"]}),f.jsxs("div",{className:"settings-assets-header",children:[f.jsx("span",{children:"Toast videos"}),f.jsxs("span",{children:[Tm(K)," max"]})]}),f.jsx("input",{ref:Ne,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:q=>{et(q.currentTarget.files)}}),f.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:we,onClick:()=>Ne.current?.click(),children:"Upload video"}),xe?f.jsx("p",{className:"settings-error",children:xe}):null,L.length>0?f.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:L.map(q=>f.jsxs("li",{"data-enabled":me.has(q.id)?"true":"false",children:[f.jsxs("label",{className:"settings-asset-choice",children:[f.jsx("input",{type:"checkbox",checked:me.has(q.id),disabled:we,"aria-label":`Use ${q.filename}`,onChange:Ke=>xn(q.id,Ke.currentTarget.checked)}),f.jsx("video",{src:q.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),f.jsxs("span",{className:"settings-asset-copy",children:[f.jsx("span",{children:q.filename}),f.jsx("small",{children:q.source==="built-in"?"Built-in":Tm(q.size)})]})]}),q.source==="uploaded"?f.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:we,"aria-label":`Delete ${q.filename}`,onClick:()=>{wt(q.id)},children:"x"}):null]},q.id))}):f.jsx("p",{className:"muted",children:"Built-in videos will be used."}),f.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:we||L.length===0||!Oe,onClick:()=>{Oi()},children:"Save selected videos"})]}),f.jsx("div",{id:"settings-security",ref:q=>{Ee.current.security=q},className:"settings-section-group",children:f.jsx(kD,{api:c})}),f.jsx("div",{id:"settings-servers",ref:q=>{Ee.current.servers=q},className:"settings-section-group",children:f.jsx(nR,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function x0(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Tm(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 rl(e){return e instanceof Error?e.message:"Request failed."}function ph(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 Dm(e){const t=rl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?ph("not_standalone"):t==="insecure"?ph("insecure"):t==="not_mobile"?ph("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 oR(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 lR(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}class no extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function cR(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{d||(d=!0,m(),o(b))},p=b=>{d||(d=!0,m(),c(b))},y=()=>{t.abort(),p(new no(0,"Upload aborted."))};if(e.signal?.aborted){p(new no(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/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 no(t.status,"Invalid upload response."))}return}p(new no(t.status,uR(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new no(0,"Upload failed.")),t.onabort=()=>p(new no(0,"Upload aborted.")),t.ontimeout=()=>p(new no(0,"Upload timed out.")),t.send(n)})}function uR(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}const dR="modulepreload",hR=function(e){return"/"+e},k0={},b_=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");o=g(n.map(p=>{if(p=hR(p),p in k0)return;k0[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":dR,y||(w.as="script"),w.crossOrigin="",w.href=p,m&&w.setAttribute("nonce",m),document.head.appendChild(w),y)return new Promise((C,x)=>{w.addEventListener("load",C),w.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(d){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=d,window.dispatchEvent(m),!m.defaultPrevented)throw d}return o.then(d=>{for(const m of d||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},fR=v.lazy(()=>b_(()=>import("./MarkdownPreview-D43VLS-2.js"),__vite__mapDeps([0,1])));function pR({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,d]=v.useState(null),[m,g]=v.useState(""),[p,y]=v.useState({}),[b,w]=v.useState(()=>new Set),[C,x]=v.useState(null),[D,O]=v.useState({type:"empty"}),[N,B]=v.useState("idle"),[V,W]=v.useState(null),ie=v.useRef(null),Q=v.useRef(null),$=v.useRef(!1),Se=v.useRef(0),ne=v.useRef(null);ne.current===null&&t&&(ne.current=t);const Te=ne.current,te=r?gR(r):t?E0(t,n):null,Y=c?[c.rootPath,m].filter(Boolean).join("/"):"",G=C?.path??null;v.useEffect(()=>($.current=!0,()=>{$.current=!1,Se.current+=1,re()}),[]),v.useEffect(()=>{ne.current=t,Q.current=null,F(te)},[e]),v.useEffect(()=>{r&&te!==Q.current&&le(r,te)},[r,te]),v.useEffect(()=>{if(r||!Te||t!==Te)return;const ee=E0(Te,n);ee!==Q.current&&L(Te,ee)},[Te,t,n,r]);async function F(ee=te){if(r){await le(r,ee);return}await L(t,ee)}async function le(ee,Ee=te){const me=he();if(Q.current=Ee,re(),d(null),g(""),y({}),w(new Set),x(null),O({type:"empty"}),W(null),!ee){B("idle");return}B("loading");try{const Oe=await e.createFileRoot({path:ee});if(!H(me))return;d({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const Ie=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!H(me))return;ae(Ie),B("idle")}catch(Oe){H(me)&&(W(Sr(Oe)),B("idle"))}}async function L(ee,Ee=te){const me=he();if(Q.current=Ee,re(),d(null),g(""),y({}),w(new Set),x(null),O({type:"empty"}),W(null),!ee){B("idle");return}B("loading");try{const Oe=await e.createFileRoot({terminalId:ee});if(!H(me))return;d({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const Ie=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!H(me))return;ae(Ie),B("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(W(Sr(Oe)),B("idle"))}}async function R(ee=m,Ee=c){if(!Ee)return;const me=he();B("loading"),W(null);try{const Oe=await e.listFiles({rootToken:Ee.rootToken,path:ee});if(!H(me))return;ae(Oe),B("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(W(Sr(Oe)),B("idle"))}}async function j(){if(r){await le(r,te);return}ne.current=t,await L(t,te)}function ae(ee){y(Ee=>({...Ee,[ee.path]:vR(ee.entries)}))}async function be(ee){if(!(!Rm(ee)||!c)){if(x(ee),W(null),ee.kind==="directory"){g(ee.path),ze(),await K(ee);return}if(g(so(ee.path)),ee.editable){await we(ee);return}ee.previewKind!=="none"&&await xe(ee,ee.previewKind)}}async function M(ee){if(!(!Rm(ee)||!c)){if(x(ee),W(null),ee.kind==="directory"){g(ee.path),ze(),await K(ee);return}if(g(so(ee.path)),ee.editable){await Le(ee);return}ee.previewKind!=="none"&&await xe(ee,ee.previewKind)}}async function K(ee){if(b.has(ee.path)){w(Ee=>{const me=new Set(Ee);return me.delete(ee.path),me});return}w(Ee=>new Set(Ee).add(ee.path)),await R(ee.path)}function ce(ee,Ee){ee.key==="Enter"&&(ee.preventDefault(),M(Ee))}async function we(ee){if(!c)return;const Ee=he();B("loading"),re();try{const me=await e.readFile({rootToken:c.rootToken,path:ee.path});if(!H(Ee))return;O({type:"text-preview",file:ee,read:me}),B("idle")}catch(me){if(await ue(me,Ee))return;H(Ee)&&(W(Sr(me)),B("idle"))}}async function Le(ee){if(!c)return;const Ee=he();B("loading");try{await o({rootToken:c.rootToken,path:ee.path,...t?{terminalId:t}:{}}),H(Ee)&&B("idle")}catch(me){if(await ue(me,Ee))return;H(Ee)&&(W(Sr(me)),B("idle"))}}async function xe(ee,Ee){if(!c)return;const me=he();B("loading"),re();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:ee.path});if(!H(me))return;const Ie=URL.createObjectURL(Oe);if(!H(me)){URL.revokeObjectURL(Ie);return}ie.current=Ie,O({type:"preview",file:ee,previewKind:Ee,url:Ie}),B("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(W(Sr(Oe)),B("idle"))}}async function Be(ee){if(!c)return;const Ee=ee==="file"?"New file":"New folder",me=window.prompt(Ee,""),Oe=C?C.kind==="directory"?C.path:so(C.path):m,Ie=T0(me,Oe);if(Ie){W(null);try{const st=await e.createFileEntry({rootToken:c.rootToken,path:Ie,kind:ee});x(st.entry),await R(Oe)}catch(st){if(await ue(st))return;W(Sr(st))}}}async function De(){if(!c||!C)return;const ee=window.prompt("Move selected entry",C.path),Ee=T0(ee,"");if(!Ee||Ee===C.path)return;const me=so(C.path),Oe=so(Ee);W(null);try{const Ie=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:C.path,destinationPath:Ee});x(Ie.entry),g(Ie.entry.kind==="directory"?Ie.entry.path:so(Ie.entry.path)),ze(),await R(me),Oe!==me&&await R(Oe)}catch(Ie){if(await ue(Ie))return;W(Sr(Ie))}}async function He(){if(!c||!C)return;const ee=C.path,Ee=so(ee);W(null);try{const me=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:C.path}),Oe=me.descendantCount>0?` and ${me.descendantCount} nested item${me.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${me.path}${Oe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:C.path,previewToken:me.previewToken}),x(null),g(Ee),w(Ie=>{const st=new Set(Ie);for(const ot of Ie)(ot===ee||ot.startsWith(`${ee}/`))&&st.delete(ot);return st}),ze(),await R(Ee)}catch(me){if(await ue(me))return;W(Sr(me))}}function ze(){Se.current+=1,re(),O({type:"empty"})}function re(){ie.current&&(URL.revokeObjectURL(ie.current),ie.current=null)}function he(){return Se.current+=1,Se.current}function H(ee){return $.current&&ee===Se.current}async function ue(ee,Ee){return _R(ee)?(Ee!==void 0&&!H(Ee)||await F(te),!0):!1}function Re(ee,Ee){const me=Rm(ee),Oe=ee.kind==="directory"&&b.has(ee.path),Ie=p[ee.path]??[],st={"--file-tree-depth":Ee};return f.jsxs(Ai.Fragment,{children:[f.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ee.kind,"data-expanded":Oe,"data-active":G===ee.path,disabled:!me,style:st,"aria-expanded":ee.kind==="directory"?Oe:void 0,"aria-label":`${ee.kind==="directory"?"Open folder":"Open file"} ${ee.name}`,title:ee.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{be(ee)},onDoubleClick:()=>{M(ee)},onKeyDown:ot=>ce(ot,ee),children:[f.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ee.kind==="directory"?Oe?"▾":"▸":""}),f.jsx("span",{className:"file-entry-name",children:ee.name}),f.jsx("small",{children:mR(ee)})]}),Oe?f.jsx("div",{className:"file-tree-children",role:"group",children:Ie.map(ot=>Re(ot,Ee+1))}):null]},ee.path)}const Ne=p[""]??[];return f.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":N==="loading",children:[f.jsxs("header",{className:"file-explorer-header",children:[f.jsx("div",{className:"file-explorer-path",title:Y,children:Y||"No active pane"}),f.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[f.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{j()},children:"↻"}),f.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Be("file")},children:"+"}),f.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Be("directory")},children:"▣"})]})]}),V?f.jsx("div",{className:"file-explorer-alert",role:"alert",children:V}):null,f.jsxs("div",{className:"file-explorer-layout",children:[f.jsx("div",{className:"file-tree","aria-label":Y?`Files in ${Y}`:"Files",children:Ne.map(ee=>Re(ee,0))}),f.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[f.jsxs("div",{className:"file-detail-header",children:[f.jsx("strong",{children:C?.name??"detail"}),f.jsxs("div",{className:"file-detail-actions",children:[f.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!C,onClick:()=>{De()},children:"Move"}),f.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!C,onClick:()=>{He()},children:"Delete"})]})]}),N==="loading"?f.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&N!=="loading"?f.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?f.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?f.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?f.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?f.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:f.jsx(fR,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?f.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function Rm(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function mR(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function E0(e,t){return`${e}\0${t??""}`}function gR(e){return`workspace\0${e}`}function vR(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function so(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function T0(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Sr(e){return e instanceof Error?e.message:"Request failed"}function _R(e){return e instanceof Bn&&e.status===409&&e.message==="terminal_cwd_changed"}const bR=v.lazy(()=>b_(()=>import("./MarkdownPreview-D43VLS-2.js"),__vite__mapDeps([0,1])));function D0({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[d,m]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[w,C]=v.useState(!1),[x,D]=v.useState("edit"),O=v.useRef(t),N=v.useRef(t.read),B=v.useRef(t.read.content),V=v.useRef(!1),W=v.useRef(!1),ie=v.useRef(0),Q=d!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(W.current=!0,()=>{W.current=!1,ie.current+=1}),[]),v.useEffect(()=>{ie.current+=1,V.current=!1,O.current=t,N.current=t.read,B.current=t.read.content,c(t.read),m(t.read.content),p("idle"),b(null),C(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{O.current=t},[t]),v.useEffect(()=>{N.current=o},[o]),v.useEffect(()=>{B.current=d},[d]),v.useEffect(()=>{if(d===o.content||w)return;const te=window.setInterval(()=>{!V.current&&B.current!==N.current.content&&$()},1e3);return()=>window.clearInterval(te)},[d===o.content,w,t.id]);async function $(){if(V.current)return;const te=B.current,Y=N.current;if(te===Y.content)return;const G=O.current,F=ie.current;V.current=!0,p("saving"),b(null),C(!1);try{const le=await e.writeFile({rootToken:G.rootToken,path:G.path,content:te,expectedVersion:Y.version});if(!W.current||F!==ie.current)return;const L={...Y,content:te,version:le.version};N.current=L,c(L),p(B.current===te?"saved":"idle")}catch(le){if(!W.current||F!==ie.current)return;if(le instanceof Bn&&le.status===409){C(!0),p("idle");return}b(yR(le)),p("idle")}finally{F===ie.current&&(V.current=!1)}}const Se=g==="saving"?"saving":g==="saved"?"saved":o.language,ne=o.language==="markdown",Te=ne&&x==="preview";return f.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[f.jsxs("header",{className:"editor-pane-header",children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("strong",{children:t.title}),f.jsx("span",{className:"terminal-pane-spacer"}),f.jsx("span",{className:"terminal-pane-state",children:Se}),f.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!Q,onClick:()=>{$()},children:"Save"}),ne?f.jsx("button",{type:"button","aria-label":`${Te?"Edit":"Preview"} ${t.title}`,onClick:()=>D(te=>te==="preview"?"edit":"preview"),children:Te?"Edit":"Preview"}):null,n?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,w?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Te?f.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:f.jsx(bR,{content:d})})}):f.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:te=>{const Y=te.target.value;B.current=Y,m(Y),p("idle"),b(null),C(!1)}})]})}function yR(e){return e instanceof Error?e.message:"Request failed"}var SR=2,wR=1,CR=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=d.top+d.bottom,g=d.right+d.left,p=r-m,y=o-g-t;return{cols:Math.max(SR,Math.floor(y/e.css.cell.width)),rows:Math.max(wR,Math.floor(p/e.css.cell.height))}}};var bC=Object.defineProperty,xR=Object.getOwnPropertyDescriptor,kR=(e,t)=>{for(var n in t)bC(e,n,{get:t[n],enumerable:!0})},fi=(e,t,n,r)=>{for(var o=r>1?void 0:r?xR(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(r?d(t,n,o):d(o))||o);return r&&o&&bC(t,n,o),o},je=(e,t)=>(n,r)=>t(n,r,e),R0="Terminal input",Ag={get:()=>R0,set:e=>R0=e},M0="Too much output to announce, navigate to rows manually to read",Lg={get:()=>M0,set:e=>M0=e};function ER(e){return e.replace(/\r?\n/g,"\r")}function TR(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function DR(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function RR(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");yC(o,t,n,r)}}function yC(e,t,n,r){e=ER(e),e=TR(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function SC(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function N0(e,t,n,r,o){SC(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ca(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function of(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var MR=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,r;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[r++]=(d-55296)*1024+m-56320+65536:(t[r++]=d,t[r++]=m);continue}d!==65279&&(t[r++]=d)}return r}},NR=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,d,m,g=0,p=0;if(this.interim[0]){let w=!1,C=this.interim[0];C&=(C&224)===192?31:(C&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)C<<=6,C|=D;let O=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=O-x;for(;p<N;){if(p>=n)return 0;if(D=e[p++],(D&192)!==128){p--,w=!0;break}else this.interim[x++]=D,C<<=6,C|=D&63}w||(O===2?C<128?p--:t[r++]=C:O===3?C<2048||C>=55296&&C<=57343||C===65279||(t[r++]=C):C<65536||C>1114111||(t[r++]=C)),this.interim.fill(0)}let y=n-4,b=p;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((d=e[b+2])&128)&&!((m=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=d,t[r++]=m,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(d=e[b++],(d&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|d&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(d=e[b++],(d&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,r;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(d&63)<<6|m&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},wC="",ka=" ",yu=class CC{constructor(){this.fg=0,this.bg=0,this.extended=new Oh}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 CC;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}},Oh=class xC{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new xC(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},fs=class kC extends yu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Oh,this.combinedData=""}static fromCharData(t){let n=new kC;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ca(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},A0="di$target",Og="di$dependencies",Mm=new Map;function AR(e){return e[Og]||[]}function Ji(e){if(Mm.has(e))return Mm.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");LR(t,n,o)};return t._id=e,Mm.set(e,t),t}function LR(e,t,n){t[A0]===t?t[Og].push({id:e,index:n}):(t[Og]=[{id:e,index:n}],t[A0]=t)}var Sn=Ji("BufferService"),EC=Ji("CoreMouseService"),yo=Ji("CoreService"),OR=Ji("CharsetService"),y_=Ji("InstantiationService"),TC=Ji("LogService"),wn=Ji("OptionsService"),DC=Ji("OscLinkService"),BR=Ji("UnicodeService"),Su=Ji("DecorationService"),Bg=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new fs,d=n.getTrimmedLength(),m=-1,g=-1,p=!1;for(let y=0;y<d;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else p=c.extended.urlId!==m;else g!==-1&&(p=!0);if(p||g!==-1&&y===d-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:y+(!p&&y===d-1?1:0),y:e}},C=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(C=!0)}catch{C=!0}C||r.push({text:b,range:w,activate:(x,D)=>o?o.activate(x,D,w):jR(x,D),hover:(x,D)=>o?.hover?.(x,D,w),leave:(x,D)=>o?.leave?.(x,D,w)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(r)}};Bg=fi([je(0,Sn),je(1,wn),je(2,DC)],Bg);function jR(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
17
|
+
|
|
18
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var lf=Ji("CharSizeService"),Ar=Ji("CoreBrowserService"),S_=Ji("MouseService"),Lr=Ji("RenderService"),zR=Ji("SelectionService"),RC=Ji("CharacterJoinerService"),xl=Ji("ThemeService"),MC=Ji("LinkProviderService"),IR=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?L0.isErrorNoTelemetry(e)?new L0(e.message+`
|
|
19
|
+
|
|
20
|
+
`+e.stack):new Error(e.message+`
|
|
21
|
+
|
|
22
|
+
`+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)}},PR=new IR;function mh(e){HR(e)||PR.onUnexpectedError(e)}var jg="Canceled";function HR(e){return e instanceof UR?!0:e instanceof Error&&e.name===jg&&e.message===jg}var UR=class extends Error{constructor(){super(jg),this.name=this.message}};function KR(e){return new Error(`Illegal argument: ${e}`)}var L0=class zg extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof zg)return t;let n=new zg;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ig=class NC extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,NC.prototype)}};function $n(e,t=0){return e[e.length-(1+t)]}var FR;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(FR||={});function WR(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var AC;(e=>{function t(W){return W&&typeof W=="object"&&typeof W[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(W){yield W}e.single=o;function c(W){return t(W)?W:o(W)}e.wrap=c;function d(W){return W||n}e.from=d;function*m(W){for(let ie=W.length-1;ie>=0;ie--)yield W[ie]}e.reverse=m;function g(W){return!W||W[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(W){return W[Symbol.iterator]().next().value}e.first=p;function y(W,ie){let Q=0;for(let $ of W)if(ie($,Q++))return!0;return!1}e.some=y;function b(W,ie){for(let Q of W)if(ie(Q))return Q}e.find=b;function*w(W,ie){for(let Q of W)ie(Q)&&(yield Q)}e.filter=w;function*C(W,ie){let Q=0;for(let $ of W)yield ie($,Q++)}e.map=C;function*x(W,ie){let Q=0;for(let $ of W)yield*ie($,Q++)}e.flatMap=x;function*D(...W){for(let ie of W)yield*ie}e.concat=D;function O(W,ie,Q){let $=Q;for(let Se of W)$=ie($,Se);return $}e.reduce=O;function*N(W,ie,Q=W.length){for(ie<0&&(ie+=W.length),Q<0?Q+=W.length:Q>W.length&&(Q=W.length);ie<Q;ie++)yield W[ie]}e.slice=N;function B(W,ie=Number.POSITIVE_INFINITY){let Q=[];if(ie===0)return[Q,W];let $=W[Symbol.iterator]();for(let Se=0;Se<ie;Se++){let ne=$.next();if(ne.done)return[Q,e.empty()];Q.push(ne.value)}return[Q,{[Symbol.iterator](){return $}}]}e.consume=B;async function V(W){let ie=[];for await(let Q of W)ie.push(Q);return Promise.resolve(ie)}e.asyncToArray=V})(AC||={});function go(e){if(AC.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function $R(...e){return ti(()=>go(e))}function ti(e){return{dispose:WR(()=>{e()})}}var LC=class OC{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{go(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?OC.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)}};LC.DISABLE_DISPOSED_WARNING=!1;var Ta=LC,mt=class{constructor(){this._store=new Ta,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)}};mt.None=Object.freeze({dispose(){}});var vl=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}},Tr=typeof window=="object"?window:globalThis,Pg=class Hg{constructor(t){this.element=t,this.next=Hg.Undefined,this.prev=Hg.Undefined}};Pg.Undefined=new Pg(void 0);var si=Pg,O0=class{constructor(){this._first=si.Undefined,this._last=si.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===si.Undefined}clear(){let e=this._first;for(;e!==si.Undefined;){let t=e.next;e.prev=si.Undefined,e.next=si.Undefined,e=t}this._first=si.Undefined,this._last=si.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new si(e);if(this._first===si.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==si.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==si.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==si.Undefined&&e.next!==si.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===si.Undefined&&e.next===si.Undefined?(this._first=si.Undefined,this._last=si.Undefined):e.next===si.Undefined?(this._last=this._last.prev,this._last.next=si.Undefined):e.prev===si.Undefined&&(this._first=this._first.next,this._first.prev=si.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==si.Undefined;)yield e.element,e=e.next}},qR=globalThis.performance&&typeof globalThis.performance.now=="function",VR=class BC{static create(t){return new BC(t)}constructor(t){this._now=qR&&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}},ln;(e=>{e.None=()=>mt.None;function t(Y,G){return b(Y,()=>{},0,void 0,!0,void 0,G)}e.defer=t;function n(Y){return(G,F=null,le)=>{let L=!1,R;return R=Y(j=>{if(!L)return R?R.dispose():L=!0,G.call(F,j)},null,le),L&&R.dispose(),R}}e.once=n;function r(Y,G,F){return p((le,L=null,R)=>Y(j=>le.call(L,G(j)),null,R),F)}e.map=r;function o(Y,G,F){return p((le,L=null,R)=>Y(j=>{G(j),le.call(L,j)},null,R),F)}e.forEach=o;function c(Y,G,F){return p((le,L=null,R)=>Y(j=>G(j)&&le.call(L,j),null,R),F)}e.filter=c;function d(Y){return Y}e.signal=d;function m(...Y){return(G,F=null,le)=>{let L=$R(...Y.map(R=>R(j=>G.call(F,j))));return y(L,le)}}e.any=m;function g(Y,G,F,le){let L=F;return r(Y,R=>(L=G(L,R),L),le)}e.reduce=g;function p(Y,G){let F,le={onWillAddFirstListener(){F=Y(L.fire,L)},onDidRemoveLastListener(){F?.dispose()}},L=new Ae(le);return G?.add(L),L.event}function y(Y,G){return G instanceof Array?G.push(Y):G&&G.add(Y),Y}function b(Y,G,F=100,le=!1,L=!1,R,j){let ae,be,M,K=0,ce,we={leakWarningThreshold:R,onWillAddFirstListener(){ae=Y(xe=>{K++,be=G(be,xe),le&&!M&&(Le.fire(be),be=void 0),ce=()=>{let Be=be;be=void 0,M=void 0,(!le||K>1)&&Le.fire(Be),K=0},typeof F=="number"?(clearTimeout(M),M=setTimeout(ce,F)):M===void 0&&(M=0,queueMicrotask(ce))})},onWillRemoveListener(){L&&K>0&&ce?.()},onDidRemoveLastListener(){ce=void 0,ae.dispose()}},Le=new Ae(we);return j?.add(Le),Le.event}e.debounce=b;function w(Y,G=0,F){return e.debounce(Y,(le,L)=>le?(le.push(L),le):[L],G,void 0,!0,void 0,F)}e.accumulate=w;function C(Y,G=(le,L)=>le===L,F){let le=!0,L;return c(Y,R=>{let j=le||!G(R,L);return le=!1,L=R,j},F)}e.latch=C;function x(Y,G,F){return[e.filter(Y,G,F),e.filter(Y,le=>!G(le),F)]}e.split=x;function D(Y,G=!1,F=[],le){let L=F.slice(),R=Y(be=>{L?L.push(be):ae.fire(be)});le&&le.add(R);let j=()=>{L?.forEach(be=>ae.fire(be)),L=null},ae=new Ae({onWillAddFirstListener(){R||(R=Y(be=>ae.fire(be)),le&&le.add(R))},onDidAddFirstListener(){L&&(G?setTimeout(j):j())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return le&&le.add(ae),ae.event}e.buffer=D;function O(Y,G){return(F,le,L)=>{let R=G(new B);return Y(function(j){let ae=R.evaluate(j);ae!==N&&F.call(le,ae)},void 0,L)}}e.chain=O;let N=Symbol("HaltChainable");class B{constructor(){this.steps=[]}map(G){return this.steps.push(G),this}forEach(G){return this.steps.push(F=>(G(F),F)),this}filter(G){return this.steps.push(F=>G(F)?F:N),this}reduce(G,F){let le=F;return this.steps.push(L=>(le=G(le,L),le)),this}latch(G=(F,le)=>F===le){let F=!0,le;return this.steps.push(L=>{let R=F||!G(L,le);return F=!1,le=L,R?L:N}),this}evaluate(G){for(let F of this.steps)if(G=F(G),G===N)break;return G}}function V(Y,G,F=le=>le){let le=(...ae)=>j.fire(F(...ae)),L=()=>Y.on(G,le),R=()=>Y.removeListener(G,le),j=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:R});return j.event}e.fromNodeEventEmitter=V;function W(Y,G,F=le=>le){let le=(...ae)=>j.fire(F(...ae)),L=()=>Y.addEventListener(G,le),R=()=>Y.removeEventListener(G,le),j=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:R});return j.event}e.fromDOMEventEmitter=W;function ie(Y){return new Promise(G=>n(Y)(G))}e.toPromise=ie;function Q(Y){let G=new Ae;return Y.then(F=>{G.fire(F)},()=>{G.fire(void 0)}).finally(()=>{G.dispose()}),G.event}e.fromPromise=Q;function $(Y,G){return Y(F=>G.fire(F))}e.forward=$;function Se(Y,G,F){return G(F),Y(le=>G(le))}e.runAndSubscribe=Se;class ne{constructor(G,F){this._observable=G,this._counter=0,this._hasChanged=!1;let le={onWillAddFirstListener:()=>{G.addObserver(this)},onDidRemoveLastListener:()=>{G.removeObserver(this)}};this.emitter=new Ae(le),F&&F.add(this.emitter)}beginUpdate(G){this._counter++}handlePossibleChange(G){}handleChange(G,F){this._hasChanged=!0}endUpdate(G){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Te(Y,G){return new ne(Y,G).emitter.event}e.fromObservable=Te;function te(Y){return(G,F,le)=>{let L=0,R=!1,j={beginUpdate(){L++},endUpdate(){L--,L===0&&(Y.reportChanges(),R&&(R=!1,G.call(F)))},handlePossibleChange(){},handleChange(){R=!0}};Y.addObserver(j),Y.reportChanges();let ae={dispose(){Y.removeObserver(j)}};return le instanceof Ta?le.add(ae):Array.isArray(le)&&le.push(ae),ae}}e.fromObservableLight=te})(ln||={});var Ug=class Kg{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Kg._idPool++}`,Kg.all.add(this)}start(t){this._stopWatch=new VR,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}}};Ug.all=new Set,Ug._idPool=0;var YR=Ug,XR=-1,jC=class zC{constructor(t,n,r=(zC._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,d]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${d}):`;console.warn(m),console.warn(c);let g=new QR(m,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};jC._idPool=1;var GR=jC,ZR=class IC{constructor(t){this.value=t}static create(){let t=new Error;return new IC(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
+
`).slice(2).join(`
|
|
24
|
+
`))}},QR=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},JR=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},eM=0,Nm=class{constructor(e){this.value=e,this.id=eM++}},tM=2,iM,Ae=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new GR(e?.onListenerError??mh,this._options?.leakWarningThreshold??XR):void 0,this._perfMon=this._options?._profName?new YR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new JR(`${d}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||mh)(g),mt.None}if(this._disposed)return mt.None;t&&(e=e.bind(t));let r=new Nm(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=ZR.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Nm?(this._deliveryQueue??=new nM,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=ti(()=>{o?.(),this._removeListener(r)});return n instanceof Ta?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*tM<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||mh;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Nm)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}},nM=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Fg=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ae,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ae,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Fg.INSTANCE=new Fg;var w_=Fg;function sM(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}w_.INSTANCE.onDidChangeZoomLevel;function rM(e){return w_.INSTANCE.getZoomFactor(e)}w_.INSTANCE.onDidChangeFullscreen;var kl=typeof navigator=="object"?navigator.userAgent:"",Wg=kl.indexOf("Firefox")>=0,aM=kl.indexOf("AppleWebKit")>=0,C_=kl.indexOf("Chrome")>=0,oM=!C_&&kl.indexOf("Safari")>=0;kl.indexOf("Electron/")>=0;kl.indexOf("Android")>=0;var Am=!1;if(typeof Tr.matchMedia=="function"){let e=Tr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Tr.matchMedia("(display-mode: fullscreen)");Am=e.matches,sM(Tr,e,({matches:n})=>{Am&&t.matches||(Am=n)})}var ol="en",$g=!1,qg=!1,gh=!1,PC=!1,Qd,vh=ol,B0=ol,lM,Cr,uo=globalThis,Yn;typeof uo.vscode<"u"&&typeof uo.vscode.process<"u"?Yn=uo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Yn=process);var cM=typeof Yn?.versions?.electron=="string",uM=cM&&Yn?.type==="renderer";if(typeof Yn=="object"){$g=Yn.platform==="win32",qg=Yn.platform==="darwin",gh=Yn.platform==="linux",gh&&Yn.env.SNAP&&Yn.env.SNAP_REVISION,Yn.env.CI||Yn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Qd=ol,vh=ol;let e=Yn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Qd=t.userLocale,B0=t.osLocale,vh=t.resolvedLanguage||ol,lM=t.languagePack?.translationsConfigFile}catch{}PC=!0}else typeof navigator=="object"&&!uM?(Cr=navigator.userAgent,$g=Cr.indexOf("Windows")>=0,qg=Cr.indexOf("Macintosh")>=0,(Cr.indexOf("Macintosh")>=0||Cr.indexOf("iPad")>=0||Cr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,gh=Cr.indexOf("Linux")>=0,Cr?.indexOf("Mobi")>=0,vh=globalThis._VSCODE_NLS_LANGUAGE||ol,Qd=navigator.language.toLowerCase(),B0=Qd):console.error("Unable to resolve platform.");var HC=$g,Ws=qg,dM=gh,j0=PC,$s=Cr,ga=vh,hM;(e=>{function t(){return ga}e.value=t;function n(){return ga.length===2?ga==="en":ga.length>=3?ga[0]==="e"&&ga[1]==="n"&&ga[2]==="-":!1}e.isDefaultVariant=n;function r(){return ga==="en"}e.isDefault=r})(hM||={});var fM=typeof uo.postMessage=="function"&&!uo.importScripts;(()=>{if(fM){let e=[];uo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),uo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var pM=!!($s&&$s.indexOf("Chrome")>=0);$s&&$s.indexOf("Firefox")>=0;!pM&&$s&&$s.indexOf("Safari")>=0;$s&&$s.indexOf("Edg/")>=0;$s&&$s.indexOf("Android")>=0;var tl=typeof navigator=="object"?navigator:{};j0||document.queryCommandSupported&&document.queryCommandSupported("copy")||tl&&tl.clipboard&&tl.clipboard.writeText,j0||tl&&tl.clipboard&&tl.clipboard.readText;var x_=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}},Lm=new x_,z0=new x_,I0=new x_,mM=new Array(230),UC;(e=>{function t(m){return Lm.keyCodeToStr(m)}e.toString=t;function n(m){return Lm.strToKeyCode(m)}e.fromString=n;function r(m){return z0.keyCodeToStr(m)}e.toUserSettingsUS=r;function o(m){return I0.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return z0.strToKeyCode(m)||I0.strToKeyCode(m)}e.fromUserSettings=c;function d(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Lm.keyCodeToStr(m)}e.toElectronAccelerator=d})(UC||={});var gM=class KC{constructor(t,n,r,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof KC&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new vM([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},vM=class{constructor(e){if(e.length===0)throw KR("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function _M(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return UC.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Wg)switch(t){case 59:return 85;case 60:if(dM)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ws)return 57;break}else if(aM&&(Ws&&t===93||!Ws&&t===92))return 57;return mM[t]||0}var bM=Ws?256:2048,yM=512,SM=1024,wM=Ws?2048:256,P0=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=_M(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|=bM),this.altKey&&(t|=yM),this.shiftKey&&(t|=SM),this.metaKey&&(t|=wM),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new gM(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},H0=new WeakMap;function CM(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var xM=class{static getSameOriginWindowChain(e){let t=H0.get(e);if(!t){t=[],H0.set(e,t);let n=e,r;do r=CM(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let d=c.window.deref();if(n+=d?.scrollY??0,r+=d?.scrollX??0,d===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,r+=m.left}return{top:n,left:r}}},Jd=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=xM.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},U0=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(C_){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,d=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*d):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 m=e;m.deltaMode===m.DOM_DELTA_LINE?Wg&&!Ws?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")oM&&HC?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*d):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 m=e;m.deltaMode===m.DOM_DELTA_LINE?Wg&&!Ws?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*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},FC=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),kM;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof EM?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ln.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:FC})})(kM||={});var EM=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?FC:(this._emitter||(this._emitter=new Ae),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},k_=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 Ig("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ig("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},TM=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Ig("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=ti(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},DM;(e=>{async function t(r){let o,c=await Promise.all(r.map(d=>d.then(m=>m,m=>{o||(o=m)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(d){c(d)}})}e.withAsyncBody=n})(DM||={});var K0=class cs{static fromArray(t){return new cs(n=>{n.emitMany(t)})}static fromPromise(t){return new cs(async n=>{n.emitMany(await t)})}static fromPromises(t){return new cs(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new cs(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Ae,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 ln.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new cs(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return cs.map(this,t)}static filter(t,n){return new cs(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return cs.filter(this,t)}static coalesce(t){return cs.filter(t,n=>!!n)}coalesce(){return cs.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return cs.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())}};K0.EMPTY=K0.fromArray([]);var{getWindow:Fs,getWindowId:RM,onDidRegisterWindow:MM}=(function(){let e=new Map,t={window:Tr,disposables:new Ta};e.set(Tr.vscodeWindowId,t);let n=new Ae,r=new Ae,o=new Ae;function c(d,m){return(typeof d=="number"?e.get(d):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(d){if(e.has(d.vscodeWindowId))return mt.None;let m=new Ta,g={window:d,disposables:m.add(new Ta)};return e.set(d.vscodeWindowId,g),m.add(ti(()=>{e.delete(d.vscodeWindowId),r.fire(d)})),m.add(nt(d,Vi.BEFORE_UNLOAD,()=>{o.fire(d)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(d){return d.vscodeWindowId},hasWindow(d){return e.has(d)},getWindowById:c,getWindow(d){let m=d;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=d;return g?.view?g.view.window:Tr},getDocument(d){return Fs(d).document}}})(),NM=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function nt(e,t,n,r){return new NM(e,t,n,r)}var F0=function(e,t,n,r){return nt(e,t,n,r)},E_,AM=class extends TM{constructor(e){super(),this.defaultTarget=e&&Fs(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},W0=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){mh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let d=e.get(c)??[];for(t.set(c,d),e.set(c,[]),r.set(c,!0);d.length>0;)d.sort(W0.sort),d.shift().execute();r.set(c,!1)};E_=(c,d,m=0)=>{let g=RM(c),p=new W0(d,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function LM(e){let t=e.getBoundingClientRect(),n=Fs(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Vi={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"},OM=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=On(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=On(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=On(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=On(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=On(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=On(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=On(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=On(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=On(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=On(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=On(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=On(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=On(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=On(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 On(e){return typeof e=="number"?`${e}px`:e}function Jc(e){return new OM(e)}var WC=class{constructor(){this._hooks=new Ta,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(ti(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Fs(e)}this._hooks.add(nt(c,Vi.POINTER_MOVE,d=>{if(d.buttons!==n){this.stopMonitoring(!0);return}d.preventDefault(),this._pointerMoveCallback(d)})),this._hooks.add(nt(c,Vi.POINTER_UP,d=>this.stopMonitoring(!0)))}};function BM(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...d){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,d)}),this[c]}}var Us;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Us||={});var jc=class mn extends mt{constructor(){super(),this.dispatched=!1,this.targets=new O0,this.ignoreTargets=new O0,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ln.runAndSubscribe(MM,({window:t,disposables:n})=>{n.add(nt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(nt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(nt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Tr,disposables:this._store}))}static addTarget(t){if(!mn.isTouchDevice())return mt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.targets.push(t);return ti(n)}static ignoreTarget(t){if(!mn.isTouchDevice())return mt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.ignoreTargets.push(t);return ti(n)}static isTouchDevice(){return"ontouchstart"in Tr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let d=this.newGestureEvent(Us.Start,c.target);d.pageX=c.pageX,d.pageY=c.pageY,this.dispatchEvent(d)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,d=n.changedTouches.length;c<d;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],p=Date.now()-g.initialTimeStamp;if(p<mn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Us.Tap,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(p>=mn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Us.Contextmenu,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=$n(g.rollingPageX),b=$n(g.rollingPageY),w=$n(g.rollingTimestamps)-g.rollingTimestamps[0],C=y-g.rollingPageX[0],x=b-g.rollingPageY[0],D=[...this.targets].filter(O=>g.initialTarget instanceof Node&&O.contains(g.initialTarget));this.inertia(t,D,r,Math.abs(C)/w,C>0?1:-1,y,Math.abs(x)/w,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Us.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Us.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>mn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Us.Change||t.type===Us.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,d,m,g,p){this.handle=E_(t,()=>{let y=Date.now(),b=y-r,w=0,C=0,x=!0;o+=mn.SCROLL_FRICTION*b,m+=mn.SCROLL_FRICTION*b,o>0&&(x=!1,w=c*o*b),m>0&&(x=!1,C=g*m*b);let D=this.newGestureEvent(Us.Change);D.translationX=w,D.translationY=C,n.forEach(O=>O.dispatchEvent(D)),x||this.inertia(t,n,y,o,c,d+w,m,g,p+C)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],m=this.newGestureEvent(Us.Change,d.initialTarget);m.translationX=c.pageX-$n(d.rollingPageX),m.translationY=c.pageY-$n(d.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),d.rollingPageX.length>3&&(d.rollingPageX.shift(),d.rollingPageY.shift(),d.rollingTimestamps.shift()),d.rollingPageX.push(c.pageX),d.rollingPageY.push(c.pageY),d.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};jc.SCROLL_FRICTION=-.005,jc.HOLD_DELAY=700,jc.CLEAR_TAP_COUNT_TIME=400,fi([BM],jc,"isTouchDevice",1);var jM=jc,T_=class extends mt{onclick(e,t){this._register(nt(e,Vi.CLICK,n=>t(new Jd(Fs(e),n))))}onmousedown(e,t){this._register(nt(e,Vi.MOUSE_DOWN,n=>t(new Jd(Fs(e),n))))}onmouseover(e,t){this._register(nt(e,Vi.MOUSE_OVER,n=>t(new Jd(Fs(e),n))))}onmouseleave(e,t){this._register(nt(e,Vi.MOUSE_LEAVE,n=>t(new Jd(Fs(e),n))))}onkeydown(e,t){this._register(nt(e,Vi.KEY_DOWN,n=>t(new P0(n))))}onkeyup(e,t){this._register(nt(e,Vi.KEY_UP,n=>t(new P0(n))))}oninput(e,t){this._register(nt(e,Vi.INPUT,t))}onblur(e,t){this._register(nt(e,Vi.BLUR,t))}onfocus(e,t){this._register(nt(e,Vi.FOCUS,t))}onchange(e,t){this._register(nt(e,Vi.CHANGE,t))}ignoreGesture(e){return jM.ignoreTarget(e)}},$0=11,zM=class extends T_{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=$0+"px",this.domNode.style.height=$0+"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 WC),this._register(F0(this.bgDomNode,Vi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(F0(this.domNode,Vi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new AM),this._pointerdownScheduleRepeatTimer=this._register(new k_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Fs(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},IM=class Vg{constructor(t,n,r,o,c,d,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,d=d|0,m=m|0),this.rawScrollLeft=o,this.rawScrollTop=m,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),c<0&&(c=0),m+c>d&&(m=d-c),m<0&&(m=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=d,this.scrollTop=m}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Vg(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Vg(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,d=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:d,scrollHeightChanged:m,scrollTopChanged:g}}},PM=class extends mt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new IM(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new V0(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=V0.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},q0=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Om(e,t){let n=t-e;return function(r){return e+n*KM(r)}}function HM(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var V0=class Yg{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let o,c;return t<n?(o=t+.75*r,c=n-.75*r):(o=t-.75*r,c=n+.75*r),HM(Om(t,o),Om(c,n),.33)}return Om(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new q0(r,o,!1)}return new q0(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return Yg.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new Yg(t,n,o,r)}};function UM(e){return Math.pow(e,3)}function KM(e){return 1-UM(1-e)}var FM=class extends mt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new k_)}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":"")))}},WM=140,$C=class extends T_{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 FM(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new WC),this._shouldRender=!0,this.domNode=Jc(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(nt(this.domNode.domNode,Vi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zM(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Jc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(nt(this.slider.domNode,Vi.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=LM(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),d=Math.abs(c-n);if(HC&&d>WM){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let m=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(m))},()=>{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()}},qC=class Xg{constructor(t,n,r,o,c,d){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=d,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Xg(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,c){let d=Math.max(0,r-t),m=Math.max(0,d-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*m/o))),y=(m-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(d),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Xg._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},$M=class extends $C{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new qC(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}},qM=class extends $C{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new qC(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}},VM=500,Y0=50,YM=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Gg=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(C_){let n=Fs(t.browserEvent),r=rM(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,c=new YM(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),d=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,d),1),p=Math.max(Math.min(c,m),1),y=Math.max(o,d),b=Math.max(c,m);y%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}};Gg.INSTANCE=new Gg;var XM=Gg,GM=class extends T_{constructor(e,t,n){super(),this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ae),this.onWillScroll=this._onWillScroll.event,this._options=QM(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new qM(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $M(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=Jc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Jc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Jc(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 k_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=go(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,Ws&&(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 U0(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=go(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new U0(n))};this._mouseWheelToDispose.push(nt(this._listenOnDomNode,Vi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=XM.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let d=!Ws&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=Y0*o,y=m.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=Y0*c,y=m.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),VM)}},ZM=class extends GM{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function QM(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,Ws&&(t.className+=" mac"),t}var Zg=class extends mt{constructor(e,t,n,r,o,c,d,m){super(),this._bufferService=n,this._optionsService=d,this._renderService=m,this._onRequestScrollLines=this._register(new Ae),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new PM({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>E_(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ZM(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(ln.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ti(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ti(()=>this._styleElement.remove())),this._register(ln.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(`
|
|
25
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Zg=fi([je(2,Sn),je(3,Ar),je(4,EC),je(5,xl),je(6,wn),je(7,Lr)],Zg);var Qg=class extends mt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(ti(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Qg=fi([je(1,Sn),je(2,Ar),je(3,Su),je(4,Lr)],Qg);var JM=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ps={full:0,left:0,center:0,right:0},va={full:0,left:0,center:0,right:0},Ec={full:0,left:0,center:0,right:0},Bh=class extends mt{constructor(e,t,n,r,o,c,d,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=d,this._coreBrowserService=m,this._colorZoneStore=new JM,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(ti(()=>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);va.full=this._canvas.width,va.left=e,va.center=t,va.right=e,this._refreshDrawHeightConstants(),Ec.full=1,Ec.left=1,Ec.center=1+va.left,Ec.right=1+va.left+va.center}_refreshDrawHeightConstants(){Ps.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);Ps.left=t,Ps.center=t,Ps.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ps.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ps.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ps.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ps.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(Ec[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ps[e.position||"full"]/2),va[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ps[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}))}};Bh=fi([je(2,Sn),je(3,Su),je(4,Lr),je(5,wn),je(6,xl),je(7,Ar)],Bh);var _e;(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=`
|
|
26
|
+
`,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=""))(_e||={});var _h;(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=""))(_h||={});var VC;(e=>e.ST=`${_e.ESC}\\`)(VC||={});var Jg=class{constructor(e,t,n,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${_e.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Jg=fi([je(2,Sn),je(3,wn),je(4,yo),je(5,Lr)],Jg);var Gi=0,Zi=0,Qi=0,hi=0,X0={css:"#00000000",rgba:0},Li;(e=>{function t(o,c,d,m){return m!==void 0?`#${ro(o)}${ro(c)}${ro(d)}${ro(m)}`:`#${ro(o)}${ro(c)}${ro(d)}`}e.toCss=t;function n(o,c,d,m=255){return(o<<24|c<<16|d<<8|m)>>>0}e.toRgba=n;function r(o,c,d,m){return{css:e.toCss(o,c,d,m),rgba:e.toRgba(o,c,d,m)}}e.toColor=r})(Li||={});var Zt;(e=>{function t(g,p){if(hi=(p.rgba&255)/255,hi===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,w=p.rgba>>8&255,C=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Gi=C+Math.round((y-C)*hi),Zi=x+Math.round((b-x)*hi),Qi=D+Math.round((w-D)*hi);let O=Li.toCss(Gi,Zi,Qi),N=Li.toRgba(Gi,Zi,Qi);return{css:O,rgba:N}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,y){let b=bh.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return Li.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Gi,Zi,Qi]=bh.toChannels(p),{css:Li.toCss(Gi,Zi,Qi),rgba:p}}e.opaque=o;function c(g,p){return hi=Math.round(p*255),[Gi,Zi,Qi]=bh.toChannels(g.rgba),{css:Li.toCss(Gi,Zi,Qi,hi),rgba:Li.toRgba(Gi,Zi,Qi,hi)}}e.opacity=c;function d(g,p){return hi=g.rgba&255,c(g,hi*p/255)}e.multiplyOpacity=d;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(Zt||={});var ri;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Gi=parseInt(o.slice(1,2).repeat(2),16),Zi=parseInt(o.slice(2,3).repeat(2),16),Qi=parseInt(o.slice(3,4).repeat(2),16),Li.toColor(Gi,Zi,Qi);case 5:return Gi=parseInt(o.slice(1,2).repeat(2),16),Zi=parseInt(o.slice(2,3).repeat(2),16),Qi=parseInt(o.slice(3,4).repeat(2),16),hi=parseInt(o.slice(4,5).repeat(2),16),Li.toColor(Gi,Zi,Qi,hi);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 Gi=parseInt(c[1]),Zi=parseInt(c[2]),Qi=parseInt(c[3]),hi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Li.toColor(Gi,Zi,Qi,hi);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Gi,Zi,Qi,hi]=t.getImageData(0,0,1,1).data,hi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Li.toRgba(Gi,Zi,Qi,hi),css:o}}e.toColor=r})(ri||={});var bn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let d=r/255,m=o/255,g=c/255,p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(bn||={});var bh;(e=>{function t(d,m){if(hi=(m&255)/255,hi===1)return m;let g=m>>24&255,p=m>>16&255,y=m>>8&255,b=d>>24&255,w=d>>16&255,C=d>>8&255;return Gi=b+Math.round((g-b)*hi),Zi=w+Math.round((p-w)*hi),Qi=C+Math.round((y-C)*hi),Li.toRgba(Gi,Zi,Qi)}e.blend=t;function n(d,m,g){let p=bn.relativeLuminance(d>>8),y=bn.relativeLuminance(m>>8);if(wr(p,y)<g){if(y<p){let C=r(d,m,g),x=wr(p,bn.relativeLuminance(C>>8));if(x<g){let D=o(d,m,g),O=wr(p,bn.relativeLuminance(D>>8));return x>O?C:D}return C}let b=o(d,m,g),w=wr(p,bn.relativeLuminance(b>>8));if(w<g){let C=r(d,m,g),x=wr(p,bn.relativeLuminance(C>>8));return w>x?b:C}return b}}e.ensureContrastRatio=n;function r(d,m,g){let p=d>>24&255,y=d>>16&255,b=d>>8&255,w=m>>24&255,C=m>>16&255,x=m>>8&255,D=wr(bn.relativeLuminance2(w,C,x),bn.relativeLuminance2(p,y,b));for(;D<g&&(w>0||C>0||x>0);)w-=Math.max(0,Math.ceil(w*.1)),C-=Math.max(0,Math.ceil(C*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=wr(bn.relativeLuminance2(w,C,x),bn.relativeLuminance2(p,y,b));return(w<<24|C<<16|x<<8|255)>>>0}e.reduceLuminance=r;function o(d,m,g){let p=d>>24&255,y=d>>16&255,b=d>>8&255,w=m>>24&255,C=m>>16&255,x=m>>8&255,D=wr(bn.relativeLuminance2(w,C,x),bn.relativeLuminance2(p,y,b));for(;D<g&&(w<255||C<255||x<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),C=Math.min(255,C+Math.ceil((255-C)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=wr(bn.relativeLuminance2(w,C,x),bn.relativeLuminance2(p,y,b));return(w<<24|C<<16|x<<8|255)>>>0}e.increaseLuminance=o;function c(d){return[d>>24&255,d>>16&255,d>>8&255,d&255]}e.toChannels=c})(bh||={});function ro(e){let t=e.toString(16);return t.length<2?"0"+t:t}function wr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var eN=class extends yu{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},jh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new fs}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,c=0,d=0,m=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!==m||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,d,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=p,d=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||ka.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,d,c,t,o);for(let y=0;y<p.length;y++)n.push(p[y])}return n}_getJoinedRanges(e,t,n,r,o){let c=e.substring(t,n),d=[];try{d=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let p=0;p<g.length;p++)jh._mergeRanges(d,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(d,r,o),d}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,d=e[r];if(d){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),p=t.getString(m).length||ka.length;if(g!==0){if(!o&&d[0]<=c&&(d[0]=m,o=!0),d[1]<=c){if(d[1]=m,d=e[++r],!d)break;d[0]<=c?(d[0]=m,o=!0):o=!1}c+=p}}d&&(d[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};jh=fi([je(0,Sn)],jh);function tN(e){return 57508<=e&&e<=57558}function iN(e){return 9472<=e&&e<=9631}function nN(e){return tN(e)||iN(e)}function sN(){return{css:{canvas:eh(),cell:eh()},device:{canvas:eh(),cell:eh(),char:{width:0,height:0,left:0,top:0}}}}function eh(){return{width:0,height:0}}var ev=class{constructor(e,t,n,r,o,c,d){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=d,this._workCell=new fs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,d,m,g,p,y){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),C=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<c+1&&(x=c+1);let D,O=0,N="",B=0,V=0,W=0,ie=0,Q=!1,$=0,Se=!1,ne=0,Te=0,te=[],Y=p!==-1&&y!==-1;for(let G=0;G<x;G++){e.loadCell(G,this._workCell);let F=this._workCell.getWidth();if(F===0)continue;let le=!1,L=G>=Te,R=G,j=this._workCell;if(w.length>0&&G===w[0][0]&&L){let H=w.shift(),ue=this._isCellInSelection(H[0],t);for(B=H[0]+1;B<H[1];B++)L&&=ue===this._isCellInSelection(B,t);L&&=!n||c<H[0]||c>=H[1],L?(le=!0,j=new eN(this._workCell,e.translateToString(!0,H[0],H[1]),H[1]-H[0]),R=H[1]-1,F=j.getWidth()):Te=H[1]}let ae=this._isCellInSelection(G,t),be=n&&G===c,M=Y&&G>=p&&G<=y,K=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,H=>{K=!0});let ce=j.getChars()||ka;if(ce===" "&&(j.isUnderline()||j.isOverline())&&(ce=" "),ne=F*m-g.get(ce,j.isBold(),j.isItalic()),!D)D=this._document.createElement("span");else if(O&&(ae&&Se||!ae&&!Se&&j.bg===V)&&(ae&&Se&&C.selectionForeground||j.fg===W)&&j.extended.ext===ie&&M===Q&&ne===$&&!be&&!le&&!K&&L){j.isInvisible()?N+=ka:N+=ce,O++;continue}else O&&(D.textContent=N),D=this._document.createElement("span"),O=0,N="";if(V=j.bg,W=j.fg,ie=j.extended.ext,Q=M,$=ne,Se=ae,le&&c>=G&&c<=R&&(c=G),!this._coreService.isCursorHidden&&be&&this._coreService.isCursorInitialized){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)d&&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(j.isBold()&&te.push("xterm-bold"),j.isItalic()&&te.push("xterm-italic"),j.isDim()&&te.push("xterm-dim"),j.isInvisible()?N=ka:N=j.getChars()||ka,j.isUnderline()&&(te.push(`xterm-underline-${j.extended.underlineStyle}`),N===" "&&(N=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${yu.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let H=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&H<8&&(H+=8),D.style.textDecorationColor=C.ansi[H].css}j.isOverline()&&(te.push("xterm-overline"),N===" "&&(N=" ")),j.isStrikethrough()&&te.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let we=j.getFgColor(),Le=j.getFgColorMode(),xe=j.getBgColor(),Be=j.getBgColorMode(),De=!!j.isInverse();if(De){let H=we;we=xe,xe=H;let ue=Le;Le=Be,Be=ue}let He,ze,re=!1;this._decorationService.forEachDecorationAtCell(G,t,void 0,H=>{H.options.layer!=="top"&&re||(H.backgroundColorRGB&&(Be=50331648,xe=H.backgroundColorRGB.rgba>>8&16777215,He=H.backgroundColorRGB),H.foregroundColorRGB&&(Le=50331648,we=H.foregroundColorRGB.rgba>>8&16777215,ze=H.foregroundColorRGB),re=H.options.layer==="top")}),!re&&ae&&(He=this._coreBrowserService.isFocused?C.selectionBackgroundOpaque:C.selectionInactiveBackgroundOpaque,xe=He.rgba>>8&16777215,Be=50331648,re=!0,C.selectionForeground&&(Le=50331648,we=C.selectionForeground.rgba>>8&16777215,ze=C.selectionForeground)),re&&te.push("xterm-decoration-top");let he;switch(Be){case 16777216:case 33554432:he=C.ansi[xe],te.push(`xterm-bg-${xe}`);break;case 50331648:he=Li.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(D,`background-color:#${G0((xe>>>0).toString(16),"0",6)}`);break;default:De?(he=C.foreground,te.push("xterm-bg-257")):he=C.background}switch(He||j.isDim()&&(He=Zt.multiplyOpacity(he,.5)),Le){case 16777216:case 33554432:j.isBold()&&we<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(we+=8),this._applyMinimumContrast(D,he,C.ansi[we],j,He,void 0)||te.push(`xterm-fg-${we}`);break;case 50331648:let H=Li.toColor(we>>16&255,we>>8&255,we&255);this._applyMinimumContrast(D,he,H,j,He,ze)||this._addStyle(D,`color:#${G0(we.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,he,C.foreground,j,He,ze)||De&&te.push("xterm-fg-257")}te.length&&(D.className=te.join(" "),te.length=0),!be&&!le&&!K&&L?O++:D.textContent=N,ne!==this.defaultSpacing&&(D.style.letterSpacing=`${ne}px`),b.push(D),G=R}return D&&O&&(D.textContent=N),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||nN(r.getCode()))return!1;let d=this._getContrastCache(r),m;if(!o&&!c&&(m=d.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);m=Zt.ensureContrastRatio(o||t,c||n,g),d.setColor((o||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};ev=fi([je(1,RC),je(2,wn),je(3,Ar),je(4,yo),je(5,Su),je(6,xl)],ev);function G0(e,t,n){for(;e.length<n;)e=t+e;return e}var rN=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,r,o,c],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let d=this._measure(e,0);return d>0&&(this._flat[r]=d),d}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let d=0;t&&(d|=1),n&&(d|=2),c=this._measure(e,d),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},aN=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,d=n[1]-o,m=Math.max(c,0),g=Math.min(d,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=d,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function oN(){return new aN}var Bm="xterm-dom-renderer-owner-",ls="xterm-rows",th="xterm-fg-",Z0="xterm-bg-",Tc="xterm-focus",ih="xterm-selection",lN=1,tv=class extends mt{constructor(e,t,n,r,o,c,d,m,g,p,y,b,w,C){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=d,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=w,this._themeService=C,this._terminalClass=lN++,this._rowElements=[],this._selectionRenderModel=oN(),this.onRequestRedraw=this._register(new Ae).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ls),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(ih),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=sN(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(ev,document),this._element.classList.add(Bm+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(ti(()=>{this._element.classList.remove(Bm+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new rN(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ls} 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} .${ls} { 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} .${ls} .xterm-dim { color: ${Zt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ls}.${Tc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${ls}.${Tc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${ls}.${Tc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ls} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ih} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ih} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ih} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,d]of e.ansi.entries())t+=`${this._terminalSelector} .${th}${c} { color: ${d.css}; }${this._terminalSelector} .${th}${c}.xterm-dim { color: ${Zt.multiplyOpacity(d,.5).css}; }${this._terminalSelector} .${Z0}${c} { background-color: ${d.css}; }`;t+=`${this._terminalSelector} .${th}257 { color: ${Zt.opaque(e.background).css}; }${this._terminalSelector} .${th}257.xterm-dim { color: ${Zt.multiplyOpacity(Zt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Z0}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Tc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Tc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,d=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],d-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,p));let y=d-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==d){let b=o===d?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(d,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,d=this.dimensions.css.cell.width*(n-t);return c+d>this.dimensions.css.canvas.width&&(d=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=`${d}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,d=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,d,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Bm}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,c){n<0&&(e=0),r<0&&(t=0);let d=this._bufferService.rows-1;n=Math.max(Math.min(n,d),0),r=Math.max(Math.min(r,d),0),o=Math.min(o,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,p=Math.min(m.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let C=n;C<=r;++C){let x=C+m.ydisp,D=this._rowElements[C],O=m.lines.get(x);if(!D||!O)break;D.replaceChildren(...this._rowFactory.createRow(O,x,x===g,b,w,p,y,this.dimensions.css.cell.width,this._widthCache,c?C===n?e:0:-1,c?(C===r?t:o)-1:-1))}}};tv=fi([je(7,y_),je(8,lf),je(9,wn),je(10,Sn),je(11,yo),je(12,Ar),je(13,xl)],tv);var iv=class extends mt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ae),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new uN(this._optionsService))}catch{this._measureStrategy=this._register(new cN(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())}};iv=fi([je(2,wn)],iv);var YC=class extends mt{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)}},cN=class extends YC{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},uN=class extends YC{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}},dN=class extends mt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hN(this._window)),this._onDprChange=this._register(new Ae),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ae),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(ln.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(nt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(nt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},hN=class extends mt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new vl),this._onDprChange=this._register(new Ae),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ti(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=nt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},fN=class extends mt{constructor(){super(),this.linkProviders=[],this._register(ti(()=>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 D_(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),d=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-d]}function pN(e,t,n,r,o,c,d,m,g){if(!c)return;let p=D_(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?d/2:0))/d),p[1]=Math.ceil(p[1]/m),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 nv=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return pN(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=D_(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};nv=fi([je(0,Lr),je(1,lf)],nv);var mN=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},XC={};kR(XC,{getSafariVersion:()=>vN,isChromeOS:()=>JC,isFirefox:()=>GC,isIpad:()=>_N,isIphone:()=>bN,isLegacyEdge:()=>gN,isLinux:()=>R_,isMac:()=>zh,isNode:()=>cf,isSafari:()=>ZC,isWindows:()=>QC});var cf=typeof process<"u"&&"title"in process,wu=cf?"node":navigator.userAgent,Cu=cf?"node":navigator.platform,GC=wu.includes("Firefox"),gN=wu.includes("Edge"),ZC=/^((?!chrome|android).)*safari/i.test(wu);function vN(){if(!ZC)return 0;let e=wu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var zh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Cu),_N=Cu==="iPad",bN=Cu==="iPhone",QC=["Windows","Win16","Win32","WinCE"].includes(Cu),R_=Cu.indexOf("Linux")>=0,JC=/\bCrOS\b/.test(wu),ex=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},yN=class extends ex{_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())}}},SN=class extends ex{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ih=!cf&&"requestIdleCallback"in window?SN:yN,wN=class{constructor(){this._queue=new Ih}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},sv=class extends mt{constructor(e,t,n,r,o,c,d,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new vl),this._pausedResizeTask=new wN,this._observerDisposable=this._register(new vl),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 Ae),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ae),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ae),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ae),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new mN((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new CN(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ti(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(d.onResize(()=>this._fullRefresh())),this._register(d.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(d.cols,d.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(d.buffer.y,d.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ti(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};sv=fi([je(2,wn),je(3,lf),je(4,yo),je(5,Su),je(6,Sn),je(7,Ar),je(8,xl)],sv);var CN=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function xN(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return TN(o,c,e,t,n,r)+uf(c,t,n,r)+DN(o,c,e,t,n,r);let d;if(c===t)return d=o>e?"D":"C",ou(Math.abs(o-e),au(d,r));d=c>t?"D":"C";let m=Math.abs(c-t),g=EN(c>t?e:o,n)+(m-1)*n.cols+1+kN(c>t?o:e);return ou(g,au(d,r))}function kN(e,t){return e-1}function EN(e,t){return t.cols-e}function TN(e,t,n,r,o,c){return uf(t,r,o,c).length===0?"":ou(ix(e,t,e,t-vo(t,o),!1,o).length,au("D",c))}function uf(e,t,n,r){let o=e-vo(e,n),c=t-vo(t,n),d=Math.abs(o-c)-RN(e,t,n);return ou(d,au(tx(e,t),r))}function DN(e,t,n,r,o,c){let d;uf(t,r,o,c).length>0?d=r-vo(r,o):d=t;let m=r,g=MN(e,t,n,r,o,c);return ou(ix(e,d,n,m,g==="C",o).length,au(g,c))}function RN(e,t,n){let r=0,o=e-vo(e,n),c=t-vo(t,n);for(let d=0;d<Math.abs(o-c);d++){let m=tx(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*d)?.isWrapped&&r++}return r}function vo(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function MN(e,t,n,r,o,c){let d;return uf(n,r,o,c).length>0?d=r-vo(r,o):d=t,e<n&&d<=r||e>=n&&d<r?"C":"D"}function tx(e,t){return e>t?"A":"B"}function ix(e,t,n,r,o,c){let d=e,m=t,g="";for(;(d!==n||m!==r)&&m>=0&&m<c.buffer.lines.length;)d+=o?1:-1,o&&d>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,d),d=0,e=0,m++):!o&&d<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),d=c.cols-1,e=d,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,d)}function au(e,t){let n=t?"O":"[";return _e.ESC+n+e}function ou(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var NN=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 Q0(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 jm=50,AN=15,LN=50,ON=500,BN=" ",jN=new RegExp(BN,"g"),rv=class extends mt{constructor(e,t,n,r,o,c,d,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=d,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new fs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ae),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ae),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ae),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ae),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 NN(this._bufferService),this._activeSelectionMode=0,this._register(ti(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let d=e[1];d<=t[1];d++){let m=n.translateBufferLineToString(d,!0,o,c);r.push(m)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let d=n.lines.get(c),m=n.translateBufferLineToString(c,!0);d?.isWrapped?r[r.length-1]+=m:r.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),d=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=d:r.push(d)}}return r.map(o=>o.replace(jN," ")).join(QC?`\r
|
|
27
|
+
`:`
|
|
28
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),R_&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Q0(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=D_(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-jm),jm),t/=jm,t/Math.abs(t)+Math.round(t*(AN-1)))}shouldForceSelection(e){return zh?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(),LN)}_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&&!(zh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<ON&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=xN(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let d=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,p=e[0]-m,y=0,b=0,w=0,C=0;if(d.charAt(m)===" "){for(;m>0&&d.charAt(m-1)===" ";)m--;for(;g<d.length&&d.charAt(g+1)===" ";)g++}else{let O=e[0],N=e[0];c.getWidth(O)===0&&(y++,O--),c.getWidth(N)===2&&(b++,N++);let B=c.getString(N).length;for(B>1&&(C+=B-1,g+=B-1);O>0&&m>0&&!this._isCharWordSeparator(c.loadCell(O-1,this._workCell));){c.loadCell(O-1,this._workCell);let V=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,O--):V>1&&(w+=V-1,m-=V-1),m--,O--}for(;N<c.length&&g+1<d.length&&!this._isCharWordSeparator(c.loadCell(N+1,this._workCell));){c.loadCell(N+1,this._workCell);let V=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,N++):V>1&&(C+=V-1,g+=V-1),g++,N++}}g++;let x=m+p-y+w,D=Math.min(this._bufferService.cols,g-m+y+b-w-C);if(!(!t&&d.slice(m,g).trim()==="")){if(n&&x===0&&c.getCodePoint(0)!==32){let O=o.lines.get(e[1]-1);if(O&&c.isWrapped&&O.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let B=this._bufferService.cols-N.start;x-=B,D+=B}}}if(r&&x+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let O=o.lines.get(e[1]+1);if(O?.isWrapped&&O.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(D+=N.length)}}return{start:x,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Q0(n,this._bufferService.cols)}};rv=fi([je(3,Sn),je(4,yo),je(5,S_),je(6,wn),je(7,Lr),je(8,Ar)],rv);var J0=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},ew=class{constructor(){this._color=new J0,this._css=new J0}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ii=Object.freeze((()=>{let e=[ri.toColor("#2e3436"),ri.toColor("#cc0000"),ri.toColor("#4e9a06"),ri.toColor("#c4a000"),ri.toColor("#3465a4"),ri.toColor("#75507b"),ri.toColor("#06989a"),ri.toColor("#d3d7cf"),ri.toColor("#555753"),ri.toColor("#ef2929"),ri.toColor("#8ae234"),ri.toColor("#fce94f"),ri.toColor("#729fcf"),ri.toColor("#ad7fa8"),ri.toColor("#34e2e2"),ri.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:Li.toCss(r,o,c),rgba:Li.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Li.toCss(r,r,r),rgba:Li.toRgba(r,r,r)})}return e})()),ao=ri.toColor("#ffffff"),zc=ri.toColor("#000000"),tw=ri.toColor("#ffffff"),iw=zc,Dc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},zN=ao,av=class extends mt{constructor(e){super(),this._optionsService=e,this._contrastCache=new ew,this._halfContrastCache=new ew,this._onChangeColors=this._register(new Ae),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ao,background:zc,cursor:tw,cursorAccent:iw,selectionForeground:void 0,selectionBackgroundTransparent:Dc,selectionBackgroundOpaque:Zt.blend(zc,Dc),selectionInactiveBackgroundTransparent:Dc,selectionInactiveBackgroundOpaque:Zt.blend(zc,Dc),scrollbarSliderBackground:Zt.opacity(ao,.2),scrollbarSliderHoverBackground:Zt.opacity(ao,.4),scrollbarSliderActiveBackground:Zt.opacity(ao,.5),overviewRulerBorder:ao,ansi:Ii.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=Ht(e.foreground,ao),t.background=Ht(e.background,zc),t.cursor=Zt.blend(t.background,Ht(e.cursor,tw)),t.cursorAccent=Zt.blend(t.background,Ht(e.cursorAccent,iw)),t.selectionBackgroundTransparent=Ht(e.selectionBackground,Dc),t.selectionBackgroundOpaque=Zt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ht(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Zt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ht(e.selectionForeground,X0):void 0,t.selectionForeground===X0&&(t.selectionForeground=void 0),Zt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Zt.opacity(t.selectionBackgroundTransparent,.3)),Zt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Zt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ht(e.scrollbarSliderBackground,Zt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ht(e.scrollbarSliderHoverBackground,Zt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ht(e.scrollbarSliderActiveBackground,Zt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ht(e.overviewRulerBorder,zN),t.ansi=Ii.slice(),t.ansi[0]=Ht(e.black,Ii[0]),t.ansi[1]=Ht(e.red,Ii[1]),t.ansi[2]=Ht(e.green,Ii[2]),t.ansi[3]=Ht(e.yellow,Ii[3]),t.ansi[4]=Ht(e.blue,Ii[4]),t.ansi[5]=Ht(e.magenta,Ii[5]),t.ansi[6]=Ht(e.cyan,Ii[6]),t.ansi[7]=Ht(e.white,Ii[7]),t.ansi[8]=Ht(e.brightBlack,Ii[8]),t.ansi[9]=Ht(e.brightRed,Ii[9]),t.ansi[10]=Ht(e.brightGreen,Ii[10]),t.ansi[11]=Ht(e.brightYellow,Ii[11]),t.ansi[12]=Ht(e.brightBlue,Ii[12]),t.ansi[13]=Ht(e.brightMagenta,Ii[13]),t.ansi[14]=Ht(e.brightCyan,Ii[14]),t.ansi[15]=Ht(e.brightWhite,Ii[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Ht(e.extendedAnsi[r],Ii[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()}}};av=fi([je(0,wn)],av);function Ht(e,t){if(e!==void 0)try{return ri.toColor(e)}catch{}return t}var IN=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},PN=class{constructor(){this._services=new IN,this._services.set(y_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=AR(e).sort((c,d)=>c.index-d.index),r=[];for(let c of n){let d=this._services.get(c.id);if(!d)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(d)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},HN={trace:0,debug:1,info:2,warn:3,error:4,off:5},UN="xterm.js: ",ov=class extends mt{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=HN[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":UN)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};ov=fi([je(0,wn)],ov);var nw=class extends mt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ae),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ae),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ae),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},pt=3,Ni=Object.freeze(new yu),nh=0,zm=2,Ic=class nx{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*pt);let o=n||fs.fromCharData([0,wC,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*pt+0],r=n&2097151;return[this._data[t*pt+1],n&2097152?this._combined[t]:r?Ca(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*pt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*pt+0]=t|2097152|n[2]<<22):this._data[t*pt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*pt+0]>>22}hasWidth(t){return this._data[t*pt+0]&12582912}getFg(t){return this._data[t*pt+1]}getBg(t){return this._data[t*pt+2]}hasContent(t){return this._data[t*pt+0]&4194303}getCodePoint(t){let n=this._data[t*pt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*pt+0]&2097152}getString(t){let n=this._data[t*pt+0];return n&2097152?this._combined[t]:n&2097151?Ca(n&2097151):""}isProtected(t){return this._data[t*pt+2]&536870912}loadCell(t,n){return nh=t*pt,n.content=this._data[nh+0],n.fg=this._data[nh+1],n.bg=this._data[nh+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*pt+0]=n.content,this._data[t*pt+1]=n.fg,this._data[t*pt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*pt+0]=n|r<<22,this._data[t*pt+1]=o.fg,this._data[t*pt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*pt+0];o&2097152?this._combined[t]+=Ca(n):o&2097151?(this._combined[t]=Ca(o&2097151)+Ca(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*pt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new fs;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,o));for(let c=0;c<n;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new fs;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,o));for(let c=this.length-n;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*zm<this._data.buffer.byteLength;let r=t*pt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let d=0;d<o.length;d++){let m=parseInt(o[d],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let d=0;d<c.length;d++){let m=parseInt(c[d],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,r*4*zm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*zm<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new nx(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*pt+0]&4194303)return t+(this._data[t*pt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*pt+0]&4194303||this._data[t*pt+2]&50331648)return t+(this._data[t*pt+0]>>22);return 0}copyCellsFrom(t,n,r,o,c){let d=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<pt;p++)this._data[(r+g)*pt+p]=d[(n+g)*pt+p];d[(n+g)*pt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<pt;p++)this._data[(r+g)*pt+p]=d[(n+g)*pt+p];d[(n+g)*pt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let p=parseInt(m[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<r;){let d=this._data[n*pt+0],m=d&2097151,g=d&2097152?this._combined[n]:m?Ca(m):ka;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=d>>22||1}return o&&o.push(n),c}};function KN(e,t,n,r,o,c){let d=[];for(let m=0;m<e.length-1;m++){let g=m,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=m&&r<g){m+=y.length-1;continue}let b=0,w=lu(y,b,t),C=1,x=0;for(;C<y.length;){let O=lu(y,C,t),N=O-x,B=n-w,V=Math.min(N,B);y[b].copyCellsFrom(y[C],x,w,V,!1),w+=V,w===n&&(b++,w=0),x+=V,x===O&&(C++,x=0),w===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,w++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(w,n,o);let D=0;for(let O=y.length-1;O>0&&(O>b||y[O].getTrimmedLength()===0);O--)D++;D>0&&(d.push(m+y.length-D),d.push(D)),m+=y.length-1}return d}function FN(e,t){let n=[],r=0,o=t[r],c=0;for(let d=0;d<e.length;d++)if(o===d){let m=t[++r];e.onDeleteEmitter.fire({index:d-c,amount:m}),d+=m-1,c+=m,o=t[++r]}else n.push(d);return{layout:n,countRemoved:c}}function WN(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function $N(e,t,n){let r=[],o=e.map((g,p)=>lu(e,p,t)).reduce((g,p)=>g+p),c=0,d=0,m=0;for(;m<o;){if(o-m<n){r.push(o-m);break}c+=n;let g=lu(e,d,t);c>g&&(c-=g,d++);let p=e[d].getWidth(c-1)===2;p&&c--;let y=p?n-1:n;r.push(y),m+=y}return r}function lu(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var sx=class rx{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=rx._nextId++,this._onDispose=this.register(new Ae),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),go(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};sx._nextId=1;var qN=sx,Ki={},oo=Ki.B;Ki[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ki.A={"#":"£"};Ki.B=void 0;Ki[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ki.C=Ki[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ki.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ki.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ki.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ki.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ki.E=Ki[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ki.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ki.H=Ki[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ki["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var sw=4294967295,rw=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ni.clone(),this.savedCharset=oo,this.markers=[],this._nullCell=fs.fromCharData([0,wC,1,0]),this._whitespaceCell=fs.fromCharData([0,ka,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ih,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new nw(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 Oh),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 Oh),this._whitespaceCell}getBlankLine(e,t){return new Ic(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>sw?sw:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ni);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 nw(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ni),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 d=0;d<this.lines.length;d++)r+=+this.lines.get(d).resize(e,n);let c=0;if(this._rows<t)for(let d=this._rows;d<t;d++)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 Ic(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ic(e,n)));else for(let d=this._rows;d>t;d--)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 d=this.lines.length-o;d>0&&(this.lines.trimStart(d),this.ybase=Math.max(this.ybase-d,0),this.ydisp=Math.max(this.ydisp-d,0),this.savedY=Math.max(this.savedY-d,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=KN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ni),n);if(r.length>0){let o=FN(this.lines,r);WN(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ni),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ic(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Ni),o=[],c=0;for(let d=this.lines.length-1;d>=0;d--){let m=this.lines.get(d);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&d>0;)m=this.lines.get(--d),g.unshift(m);if(!n){let V=this.ybase+this.y;if(V>=d&&V<d+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=$N(g,this._cols,e),b=y.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 C=[];for(let V=0;V<b;V++){let W=this.getBlankLine(Ni,!0);C.push(W)}C.length>0&&(o.push({start:d+g.length+c,newLines:C}),c+=C.length),g.push(...C);let x=y.length-1,D=y[x];D===0&&(x--,D=y[x]);let O=g.length-b-1,N=p;for(;O>=0;){let V=Math.min(N,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[O],N-V,D-V,V,!0),D-=V,D===0&&(x--,D=y[x]),N-=V,N===0){O--;let W=Math.max(O,0);N=lu(g,W,this._cols)}}for(let V=0;V<g.length;V++)y[V]<e&&g[V].setCell(y[V],r);let B=b-w;for(;B-- >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 d=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>p+w){for(let O=b.newLines.length-1;O>=0;O--)this.lines.set(D--,b.newLines[O]);D++,d.push({index:p+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[p--]);let C=0;for(let D=d.length-1;D>=0;D--)d[D].index+=C,this.lines.onInsertEmitter.fire(d[D]),C+=d[D].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new qN(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},VN=class extends mt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ae),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 rw(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new rw(!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)}},ax=2,ox=1,lv=class extends mt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ae),this.onResize=this._onResize.event,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ax),this.rows=Math.max(e.rawOptions.rows||0,ox),this.buffers=this._register(new VN(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let d=n.lines.isFull;c===n.lines.length-1?d?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),d?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let d=c-o+1;n.lines.shiftElements(o+1,d-1,-1),n.lines.set(c,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};lv=fi([je(0,wn)],lv);var il={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:zh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},YN=["normal","bold","100","200","300","400","500","600","700","800","900"],XN=class extends mt{constructor(e){super(),this._onOptionChange=this._register(new Ae),this.onOptionChange=this._onOptionChange.event;let t={...il};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ti(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in il))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in il))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=il[e]),!GN(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=il[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=YN.includes(t)?t:il[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 GN(e){return e==="block"||e==="underline"||e==="bar"}function Pc(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Pc(e[r],t-1);return n}var aw=Object.freeze({insertMode:!1}),ow=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),cv=class extends mt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ae),this.onData=this._onData.event,this._onUserInput=this._register(new Ae),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ae),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ae),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Pc(aw),this.decPrivateModes=Pc(ow)}reset(){this.modes=Pc(aw),this.decPrivateModes=Pc(ow)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};cv=fi([je(0,Sn),je(1,TC),je(2,wn)],cv);var lw={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 Im(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Pm=String.fromCharCode,cw={DEFAULT:e=>{let t=[Im(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Pm(t[0])}${Pm(t[1])}${Pm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Im(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Im(e,!0)};${e.x};${e.y}${t}`}},uv=class extends mt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ae),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(lw))this.addProtocol(r,lw[r]);for(let r of Object.keys(cw))this.addEncoding(r,cw[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};uv=fi([je(0,Sn),je(1,yo),je(2,wn)],uv);var Hm=[[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]],ZN=[[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]],Pi;function QN(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var JN=class{constructor(){if(this.version="6",!Pi){Pi=new Uint8Array(65536),Pi.fill(1),Pi[0]=0,Pi.fill(0,1,32),Pi.fill(0,127,160),Pi.fill(2,4352,4448),Pi[9001]=2,Pi[9002]=2,Pi.fill(2,11904,42192),Pi[12351]=1,Pi.fill(2,44032,55204),Pi.fill(2,63744,64256),Pi.fill(2,65040,65050),Pi.fill(2,65072,65136),Pi.fill(2,65280,65377),Pi.fill(2,65504,65511);for(let e=0;e<Hm.length;++e)Pi.fill(0,Hm[e][0],Hm[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Pi[e]:QN(e,ZN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=lo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return lo.createPropertyValue(0,n,r)}},lo=class yh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ae,this.onChange=this._onChange.event;let t=new JN;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let c=0;c<o;++c){let d=t.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=o)return n+this.wcwidth(d);let p=t.charCodeAt(c);56320<=p&&p<=57343?d=(d-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let m=this.charProperties(d,r),g=yh.extractWidth(m);yh.extractShouldJoin(m)&&(g-=yh.extractWidth(r)),n+=g,r=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},eA=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 uw(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Rc=2147483647,tA=256,lx=class dv{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>tA)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new dv;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)n.addSubParam(o[c]);else n.addParam(o)}return n}clone(){let t=new dv(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Rc?Rc: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>Rc?Rc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Rc):t}},Mc=[],iA=class{constructor(){this._state=0,this._active=Mc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Mc}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=Mc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Mc,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",of(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Mc,this._id=-1,this._state=0}}},qn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=of(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Nc=[],nA=class{constructor(){this._handlers=Object.create(null),this._active=Nc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Nc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Nc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Nc,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",of(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Nc,this._ident=0}},Hc=new lx;Hc.addParam(0);var dw=class{constructor(e){this._handler=e,this._data="",this._params=Hc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Hc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=of(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Hc,this._data="",this._hitLimit=!1,n));return this._params=Hc,this._data="",this._hitLimit=!1,t}},sA=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},ds=160,rA=(function(){let e=new sA(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),d;e.setDefault(1,0),e.addMany(r,0,2,0);for(d in c)e.addMany([24,26,153,154],d,3,0),e.addMany(n(128,144),d,3,0),e.addMany(n(144,152),d,3,0),e.add(156,d,0,0),e.add(27,d,11,1),e.add(157,d,4,8),e.addMany([152,158,159],d,0,7),e.add(155,d,11,3),e.add(144,d,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ds,0,2,0),e.add(ds,8,5,8),e.add(ds,6,0,6),e.add(ds,11,0,11),e.add(ds,13,13,13),e})(),aA=class extends mt{constructor(e=rA){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 lx,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ti(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new iA),this._dcsParser=this._register(new nA),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,d;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](this._params),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(d=m[g](),d!==!0);g--)if(d instanceof Promise)return this._parseStack.handlerPos=g,d}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],d=this._dcsParser.unhook(r!==24&&r!==26,n),d)return d;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],d=this._oscParser.end(r!==24&&r!==26,n),d)return d;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 m=c;m<t;++m){switch(r=e[m],o=this._transitions.table[this.currentState<<8|(r<160?r:ds)],o>>4){case 2:for(let w=m+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<ds){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ds){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ds){this._printHandler(e,m,w),m=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<ds){this._printHandler(e,m,w),m=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:m,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&&(d=g[p](this._params),d!==!0);p--)if(d instanceof Promise)return this._preserveStack(3,g,p,o,m),d;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(++m<t&&(r=e[m])>47&&r<60);m--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(d=y[b](),d!==!0);b--)if(d instanceof Promise)return this._preserveStack(4,y,b,o,m),d;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=m+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<ds){this._dcsParser.put(e,m,w),m=w-1;break}break;case 14:if(d=this._dcsParser.unhook(r!==24&&r!==26),d)return this._preserveStack(6,[],0,o,m),d;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=m+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<ds){this._oscParser.put(e,m,w),m=w-1;break}break;case 6:if(d=this._oscParser.end(r!==24&&r!==26),d)return this._preserveStack(5,[],0,o,m),d;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},oA=/^([\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})$/,lA=/^[\da-f]+$/;function hw(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=oA.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),lA.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return r}}function Um(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function cA(e,t=16){let[n,r,o]=e;return`rgb:${Um(n,t)}/${Um(r,t)}/${Um(o,t)}`}var uA={"(":0,")":1,"*":2,"+":3,"-":1,".":2},_a=131072,fw=10;function pw(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 mw=5e3,gw=0,dA=class extends mt{constructor(e,t,n,r,o,c,d,m,g=new aA){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=d,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new MR,this._utf8Decoder=new NR,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ni.clone(),this._eraseAttrDataInternal=Ni.clone(),this._onRequestBell=this._register(new Ae),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ae),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ae),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ae),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ae),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ae),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ae),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ae),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ae),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ae),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ae),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ae),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ae),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 hv(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.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,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,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(_e.BEL,()=>this.bell()),this._parser.setExecuteHandler(_e.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(_e.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(_e.BS,()=>this.backspace()),this._parser.setExecuteHandler(_e.HT,()=>this.tab()),this._parser.setExecuteHandler(_e.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(_e.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(_h.IND,()=>this.index()),this._parser.setExecuteHandler(_h.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(_h.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qn(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new qn(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new qn(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new qn(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new qn(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new qn(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new qn(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new qn(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new qn(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new qn(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new qn(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new qn(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 Ki)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 dw((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),mw))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${mw} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,d=this._parseStack.paused;if(d){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>_a&&(c=this._parseStack.position+_a)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,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<_a&&(this._parseBuffer=new Uint32Array(Math.min(e.length,_a))),d||this._dirtyRowTracker.clearRange(),e.length>_a)for(let p=c;p<e.length;p+=_a){let y=p+_a<e.length?p+_a:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(n),n}else if(!d){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let m=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(m,this._bufferService.rows-1)})}print(e,t,n){let r,o,c=this._charsetService.charset,d=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let w=this._parser.precedingJoinState;for(let C=t;C<n;++C){if(r=e[C],r<127&&c){let N=c[String.fromCharCode(r)];N&&(r=N.charCodeAt(0))}let x=this._unicodeService.charProperties(r,w);o=lo.extractWidth(x);let D=lo.extractShouldJoin(x),O=D?lo.extractWidth(w):0;if(w=x,d&&this._onA11yChar.fire(Ca(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-O>m){if(g){let N=b,B=this._activeBuffer.x-O;for(this._activeBuffer.x=O,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),O>0&&b instanceof Ic&&b.copyCellsFrom(N,B,0,O,!1);B<m;)N.setCellFromCodepoint(B++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(D&&this._activeBuffer.x){let N=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-N,r,o);for(let B=o-O;--B>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-O,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=w,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>pw(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new dw(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ni));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=lo.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),d=new Uint32Array(c.length*n),m=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;d[m++]=y,p+=y>65535?2:1}let g=m;for(let p=1;p<n;++p)d.copyWithin(g,0,m),g+=m;return this.print(d,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(_e.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(_e.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(_e.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(_e.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(_e.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,oo),this._charsetService.setgCharset(1,oo),this._charsetService.setgCharset(2,oo),this._charsetService.setgCharset(3,oo);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:p,alt:y}=m,b=this._optionsService.rawOptions,w=(D,O)=>(d.triggerDataEvent(`${_e.ESC}[${t?"":"?"}${D};${O}$y`),!0),C=D=>D?1:2,x=e.params[0];return t?x===2?w(x,4):x===4?w(x,C(d.modes.insertMode)):x===12?w(x,3):x===20?w(x,C(b.convertEol)):w(x,0):x===1?w(x,C(r.applicationCursorKeys)):x===3?w(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?w(x,C(r.origin)):x===7?w(x,C(r.wraparound)):x===8?w(x,3):x===9?w(x,C(o==="X10")):x===12?w(x,C(b.cursorBlink)):x===25?w(x,C(!d.isCursorHidden)):x===45?w(x,C(r.reverseWraparound)):x===66?w(x,C(r.applicationKeypad)):x===67?w(x,4):x===1e3?w(x,C(o==="VT200")):x===1002?w(x,C(o==="DRAG")):x===1003?w(x,C(o==="ANY")):x===1004?w(x,C(r.sendFocus)):x===1005?w(x,4):x===1006?w(x,C(c==="SGR")):x===1015?w(x,4):x===1016?w(x,C(c==="SGR_PIXELS")):x===1048?w(x,1):x===47||x===1047||x===1049?w(x,C(p===y)):x===2004?w(x,C(r.bracketedPasteMode)):x===2026?w(x,C(r.synchronizedOutput)):w(x,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=yu.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let d=e.getSubParams(t+c),m=0;do r[1]===5&&(o=1),r[c+m+1+o]=d[m];while(++m<d.length&&m+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 d=2;d<r.length;++d)r[d]===-1&&(r[d]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ni.fg,e.bg=Ni.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Ni.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ni.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Ni.fg&16777215,r.bg&=-67108864,r.bg|=Ni.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${_e.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${_e.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ni.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!pw(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(`${_e.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>fw&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>fw&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(vw(c))if(o==="?")t.push({type:0,index:c});else{let d=hw(o);d&&t.push({type:1,index:c,color:d})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=hw(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);vw(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,oo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(uA[e[0]],Ki[e[1]]||oo),!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=Ni.clone(),this._eraseAttrDataInternal=Ni.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 fs;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=d=>(this._coreService.triggerDataEvent(`${_e.ESC}${d}${_e.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},hv=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&&(gw=e,e=t,t=gw),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};hv=fi([je(0,Sn)],hv);function vw(e){return 0<=e&&e<256}var hA=5e7,_w=12,fA=50,pA=class extends mt{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 Ae),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>hA)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let d=m=>performance.now()-n>=_w?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(d);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=_w)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>fA&&(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()}},fv=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 m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),d={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._entriesWithId.set(d.key,d),this._dataByLinkId.set(d.id,d),d.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};fv=fi([je(0,Sn)],fv);var bw=!1,mA=class extends mt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new vl),this._onBinary=this._register(new Ae),this.onBinary=this._onBinary.event,this._onData=this._register(new Ae),this.onData=this._onData.event,this._onLineFeed=this._register(new Ae),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ae),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ae),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ae),this._instantiationService=new PN,this.optionsService=this._register(new XN(e)),this._instantiationService.setService(wn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(lv)),this._instantiationService.setService(Sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ov)),this._instantiationService.setService(TC,this._logService),this.coreService=this._register(this._instantiationService.createInstance(cv)),this._instantiationService.setService(yo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(uv)),this._instantiationService.setService(EC,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(lo)),this._instantiationService.setService(BR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eA),this._instantiationService.setService(OR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(fv),this._instantiationService.setService(DC,this._oscLinkService),this._inputHandler=this._register(new dA(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ln.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ln.forward(this._bufferService.onResize,this._onResize)),this._register(ln.forward(this.coreService.onData,this._onData)),this._register(ln.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 pA((t,n)=>this._inputHandler.parse(t,n))),this._register(ln.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ae),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&&!bw&&(this._logService.warn("writeSync is unreliable and will be removed soon."),bw=!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,ax),t=Math.max(t,ox),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(uw.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(uw(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ti(()=>{for(let t of e)t.dispose()})}}},gA={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 vA(e,t,n,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=_e.ESC+"OA":o.key=_e.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=_e.ESC+"OD":o.key=_e.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=_e.ESC+"OC":o.key=_e.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=_e.ESC+"OB":o.key=_e.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":_e.DEL,e.altKey&&(o.key=_e.ESC+o.key);break;case 9:if(e.shiftKey){o.key=_e.ESC+"[Z";break}o.key=_e.HT,o.cancel=!0;break;case 13:o.key=e.altKey?_e.ESC+_e.CR:_e.CR,o.cancel=!0;break;case 27:o.key=_e.ESC,e.altKey&&(o.key=_e.ESC+_e.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=_e.ESC+"[1;"+(c+1)+"D":t?o.key=_e.ESC+"OD":o.key=_e.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=_e.ESC+"[1;"+(c+1)+"C":t?o.key=_e.ESC+"OC":o.key=_e.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=_e.ESC+"[1;"+(c+1)+"A":t?o.key=_e.ESC+"OA":o.key=_e.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=_e.ESC+"[1;"+(c+1)+"B":t?o.key=_e.ESC+"OB":o.key=_e.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=_e.ESC+"[2~");break;case 46:c?o.key=_e.ESC+"[3;"+(c+1)+"~":o.key=_e.ESC+"[3~";break;case 36:c?o.key=_e.ESC+"[1;"+(c+1)+"H":t?o.key=_e.ESC+"OH":o.key=_e.ESC+"[H";break;case 35:c?o.key=_e.ESC+"[1;"+(c+1)+"F":t?o.key=_e.ESC+"OF":o.key=_e.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=_e.ESC+"[5;"+(c+1)+"~":o.key=_e.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=_e.ESC+"[6;"+(c+1)+"~":o.key=_e.ESC+"[6~";break;case 112:c?o.key=_e.ESC+"[1;"+(c+1)+"P":o.key=_e.ESC+"OP";break;case 113:c?o.key=_e.ESC+"[1;"+(c+1)+"Q":o.key=_e.ESC+"OQ";break;case 114:c?o.key=_e.ESC+"[1;"+(c+1)+"R":o.key=_e.ESC+"OR";break;case 115:c?o.key=_e.ESC+"[1;"+(c+1)+"S":o.key=_e.ESC+"OS";break;case 116:c?o.key=_e.ESC+"[15;"+(c+1)+"~":o.key=_e.ESC+"[15~";break;case 117:c?o.key=_e.ESC+"[17;"+(c+1)+"~":o.key=_e.ESC+"[17~";break;case 118:c?o.key=_e.ESC+"[18;"+(c+1)+"~":o.key=_e.ESC+"[18~";break;case 119:c?o.key=_e.ESC+"[19;"+(c+1)+"~":o.key=_e.ESC+"[19~";break;case 120:c?o.key=_e.ESC+"[20;"+(c+1)+"~":o.key=_e.ESC+"[20~";break;case 121:c?o.key=_e.ESC+"[21;"+(c+1)+"~":o.key=_e.ESC+"[21~";break;case 122:c?o.key=_e.ESC+"[23;"+(c+1)+"~":o.key=_e.ESC+"[23~";break;case 123:c?o.key=_e.ESC+"[24;"+(c+1)+"~":o.key=_e.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=_e.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=_e.DEL:e.keyCode===219?o.key=_e.ESC:e.keyCode===220?o.key=_e.FS:e.keyCode===221&&(o.key=_e.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let d=gA[e.keyCode]?.[e.shiftKey?1:0];if(d)o.key=_e.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),o.key=_e.ESC+g}else if(e.keyCode===32)o.key=_e.ESC+(e.ctrlKey?_e.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=_e.ESC+m,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=_e.US),e.key==="@"&&(o.key=_e.NUL));break}return o}var wi=0,_A=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ih,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ih,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(wi=this._search(t),wi===-1)||this._getKey(this._array[wi])!==t)return!1;do if(this._array[wi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(wi),!0;while(++wi<this._array.length&&this._getKey(this._array[wi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(wi=this._search(e),!(wi<0||wi>=this._array.length)&&this._getKey(this._array[wi])===e))do yield this._array[wi];while(++wi<this._array.length&&this._getKey(this._array[wi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(wi=this._search(e),!(wi<0||wi>=this._array.length)&&this._getKey(this._array[wi])===e))do t(this._array[wi]);while(++wi<this._array.length&&this._getKey(this._array[wi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Km=0,yw=0,bA=class extends mt{constructor(){super(),this._decorations=new _A(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ae),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ae),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ti(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new yA(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{Km=o.options.x??0,yw=Km+(o.options.width??1),e>=Km&&e<yw&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},yA=class extends Ta{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ae),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ae),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=ri.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ri.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},SA=1e3,wA=class{constructor(e,t=SA){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Sw=20,Ph=class extends mt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new wA(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(`
|
|
29
|
+
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(nt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ti(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Sw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Sw+1&&(this._liveRegion.textContent+=Lg.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),d=[],m=c?.translateToString(!0,void 0,void 0,d)||"",g=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(m.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=m,this._rowColumns.set(p,d)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let d,m;if(t===0?(d=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(d=this._rowElements.shift(),m=n,this._rowContainer.removeChild(d)),d.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:m,offset:g})=>{let p=m instanceof Text?m.parentNode:m,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))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&&(++y,w=0),{row:y,column:w}},c=o(t),d=o(n);if(!(!c||!d)){if(c.row>d.row||c.row===d.row&&c.column>=d.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(d.row-c.row)*this._terminal.cols-c.column+d.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Ph=fi([je(1,y_),je(2,Ar),je(3,Lr)],Ph);var pv=class extends mt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ae),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ae),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ti(()=>{go(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(nt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(nt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(nt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(nt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let d=c?.map(m=>({link:m}));this._activeProviderReplies?.set(r,d),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let d=o[c],m=d.link.range.start.y<e?0:d.link.range.start.x,g=d.link.range.end.y>e?this._bufferService.cols:d.link.range.end.x;for(let p=m;p<=g;p++){if(n.has(p)){o.splice(c--,1);break}n.add(p)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(d=>this._linkAtPosition(d.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&CA(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,go(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};pv=fi([je(1,S_),je(2,Lr),je(3,Sn),je(4,MC)],pv);function CA(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 xA=class extends mA{constructor(e={}){super(e),this._linkifier=this._register(new vl),this.browser=XC,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new vl),this._onCursorMove=this._register(new Ae),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ae),this.onKey=this._onKey.event,this._onRender=this._register(new Ae),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ae),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ae),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ae),this.onBell=this._onBell.event,this._onFocus=this._register(new Ae),this._onBlur=this._register(new Ae),this._onA11yCharEmitter=this._register(new Ae),this._onA11yTabEmitter=this._register(new Ae),this._onWillOpen=this._register(new Ae),this._setup(),this._decorationService=this._instantiationService.createInstance(bA),this._instantiationService.setService(Su,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(fN),this._instantiationService.setService(MC,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Bg)),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(ln.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ln.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ln.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ln.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ti(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=Zt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${_e.ESC}]${r};${cA(o)}${VC.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Li.toColor(...t.color));else{let c=n;this._themeService.modifyColors(d=>d[c]=Li.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(Ph,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(_e.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(_e.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,d=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=d+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(nt(this.element,"copy",t=>{this.hasSelection()&&DR(t,this._selectionService)}));let e=t=>RR(t,this.textarea,this.coreService,this.optionsService);this._register(nt(this.textarea,"paste",e)),this._register(nt(this.element,"paste",e)),GC?this._register(nt(this.element,"mousedown",t=>{t.button===2&&N0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(nt(this.element,"contextmenu",t=>{N0(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),R_&&this._register(nt(this.element,"auxclick",t=>{t.button===1&&SC(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(nt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(nt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(nt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(nt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(nt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(nt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(nt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(nt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ag.get()),JC||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(dN,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ar,this._coreBrowserService),this._register(nt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(nt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(iv,this._document,this._helperContainer),this._instantiationService.setService(lf,this._charSizeService),this._themeService=this._instantiationService.createInstance(av),this._instantiationService.setService(xl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(jh),this._instantiationService.setService(RC,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sv,this.rows,this.screenElement)),this._instantiationService.setService(Lr,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(Jg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(nv),this._instantiationService.setService(S_,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(pv,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(Zg,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(rv,this.element,this.screenElement,r)),this._instantiationService.setService(zR,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(ln.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Qg,this.screenElement)),this._register(nt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ph,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Bh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(tv,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let d=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!d)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=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,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:d.col,row:d.row,x:d.x,y:d.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(nt(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(nt(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let d=_e.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!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){yC(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=vA(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===_e.ETX||n.key===_e.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(kA(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(Ni));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(_e.ESC+"[I"):this.coreService.triggerDataEvent(_e.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${_e.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function kA(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var EA=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},TA=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 fs)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},ww=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 TA(t)}getNullCell(){return new fs}},DA=class extends mt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ae),this.onBufferChange=this._onBufferChange.event,this._normal=new ww(this._core.buffers.normal,"normal"),this._alternate=new ww(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)}},RA=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},MA=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}},NA=["cols","rows"],Hs=0,AA=class extends mt{constructor(e){super(),this._core=this._register(new xA(e)),this._addonManager=this._register(new EA),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(NA.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 RA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new MA(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 DA(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
31
|
+
`,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 Ag.get()},set promptLabel(e){Ag.set(e)},get tooMuchOutput(){return Lg.get()},set tooMuchOutput(e){Lg.set(e)}}}_verifyIntegers(...e){for(Hs of e)if(Hs===1/0||isNaN(Hs)||Hs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Hs of e)if(Hs&&(Hs===1/0||isNaN(Hs)||Hs%1!==0||Hs<0))throw new Error("This API only accepts positive integers")}};const LA=Ai.lazy(()=>b_(()=>import("./TranscriptMarkdownBody-BeM4ohbd.js"),__vite__mapDeps([2,1])));function cx({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const d=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=d.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let m=-1;return f.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,p)=>{const y=g.kind==="user"?++m:null,b=n===p?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return f.jsxs("section",{ref:w=>{w?d.current.set(p,w):d.current.delete(p)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":p,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?f.jsx("div",{className:"transcript-entry-header",children:ux(g.header,t)}):null,g.body?f.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?f.jsx(Cw,{text:g.body,searchQuery:t}):f.jsx(Ai.Suspense,{fallback:f.jsx(Cw,{text:g.body,searchQuery:t}),children:f.jsx(LA,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function Cw({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
32
|
+
`)?e.slice(0,-1).split(`
|
|
33
|
+
`):e.split(`
|
|
34
|
+
`);return f.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>f.jsx("span",{className:`transcript-line transcript-line-${IA(r,o===0||n[o-1]?.trim()==="")}`,children:ux(r,t)},o))})}function ux(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let d=0,m=r.indexOf(o);for(;m!==-1;){m>d&&c.push(e.slice(d,m));const g=m+n.length;c.push(f.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),d=g,m=r.indexOf(o,d)}return d<e.length&&c.push(e.slice(d)),c.length>0?c:e||" "}function OA(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(n);for(;c!==-1;)o+=1,c=r.indexOf(n,c+n.length);return o}function dx(e){const t=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function d(){const m=BA(c).join(`
|
|
36
|
+
`);(r||m)&&n.push({header:r,body:m,kind:o}),r=null,o="plain",c=[]}for(const m of t.split(`
|
|
37
|
+
`)){const g=jA(m);g?(d(),r=m,o=g):c.push(m)}return d(),n}function BA(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function jA(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const n=t[1]??"";return n==="User"?"user":n==="Codex"||n==="Claude"?"assistant":n==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(n)?"tool":null}function zA(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
38
|
+
${o.body}`:o.body,d=OA(c,t);for(let m=0;m<d;m+=1)n.push({entryIndex:r,matchIndexInEntry:m})}return n}function IA(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||px(n))?"tool":/^(?:\$|>|❯|➜)\s+/.test(n)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(n)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(n)?"error":/^\[[^\]]+\]/.test(n)||/^(?:info|debug|warn)\b/i.test(n)?"dim":"plain"}function _o(e){return e==="codex"?"Codex":"Claude"}function mv(e,t,n={}){const r=`[nterminal] ${_o(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
+
`).replace(/\r/g,`
|
|
40
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
41
|
+
|
|
42
|
+
`).trimEnd(),c=hx(o),d=n.includeTools?c:fx(c);return d?`${d}
|
|
43
|
+
`:""}function hx(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=PA(n);return r?`[${r}]`:t})}function PA(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=Ac(t.getMonth()+1),o=Ac(t.getDate()),c=Ac(t.getHours()),d=Ac(t.getMinutes()),m=Ac(t.getSeconds());return`${n}-${r}-${o} ${c}:${d}:${m}`}function Ac(e){return e.toString().padStart(2,"0")}function Hh(e,t){return e.map(n=>t?n:fx(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
44
|
+
`)?n:`${n}
|
|
45
|
+
`).join("")}function fx(e){if(!e)return"";const t=e.split(`
|
|
46
|
+
`),n=[];let r=!1,o=!1,c=!0;for(const d of t){const m=d.trim()==="",g=c?HA(d):null;if(g&&(r=g==="tool",o=!1),px(d)){o=!0,c=!1;continue}if(o){m?(o=!1,r||n.push(d),c=!0):c=!1;continue}r||n.push(d),c=m}return n.join(`
|
|
47
|
+
`).replace(/\n{3,}/g,`
|
|
48
|
+
|
|
49
|
+
`).trimEnd()}function HA(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function px(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function M_(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function sh(e,t){return e===null?t===null:t!==null&&M_(e,t)}const UA=5e3,KA=200,FA=1200,WA=4,$A=Ai.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const d=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(!1),[w,C]=v.useState(null),[x,D]=v.useState(null),[O,N]=v.useState(null),[B,V]=v.useState(()=>new Set),[W,ie]=v.useState(!1),[Q,$]=v.useState(!1),[Se,ne]=v.useState([]),[Te,te]=v.useState(null),[Y,G]=v.useState(!1),[F,le]=v.useState(!1),[L,R]=v.useState(!1),[j,ae]=v.useState(null),be=w?.find(H=>H.id===O)??null;v.useEffect(()=>{function H(ue){ue.key==="Escape"&&(ue.preventDefault(),ue.stopPropagation(),c())}return document.addEventListener("keydown",H,!0),()=>document.removeEventListener("keydown",H,!0)},[c]);const M=v.useCallback(async()=>{try{const H=await n.getTerminalSubagents(t);if(D(null),C(ue=>ue&&GA(ue,H.subagents)?ue:H.subagents),!b.current){const ue=H.subagents.find(Re=>Re.hasTranscript);ue&&(b.current=!0,N(Re=>Re??ue.id))}}catch(H){D(H instanceof Error?H.message:"Failed to load subagents."),C(ue=>ue??[])}},[n,t]);v.useEffect(()=>{M();const H=window.setInterval(()=>{document.hidden||M()},UA);function ue(){document.hidden||M()}return document.addEventListener("visibilitychange",ue),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",ue)}},[M]),v.useEffect(()=>{m.current+=1;const H=m.current;return g.current=!1,p.current=!0,y.current=null,ne([]),te(null),G(!1),ae(null),O&&K(null,"initial",H),()=>{m.current===H&&(m.current+=1)}},[n,t,O,Q]),v.useLayoutEffect(()=>{const H=d.current;if(!H)return;if(p.current){if(F||Se.length===0)return;p.current=!1;const Re=()=>{H.scrollTop=H.scrollHeight};Re(),window.requestAnimationFrame?.(Re);return}const ue=y.current;ue!==null&&(y.current=null,H.scrollTop+=H.scrollHeight-ue)},[Se,F,Q]);async function K(H,ue,Re=m.current){const Ne=O;if(!(!Ne||g.current)){g.current=!0,ue==="initial"?le(!0):(R(!0),y.current=d.current?.scrollHeight??null),ae(null);try{let ee=H,Ee=0,me=0,Oe=[];for(;m.current===Re;){const Ie=await n.getTerminalSubagentTranscriptHistory(t,Ne,{...ee?{cursor:ee}:{},limit:KA,maxLines:FA,includeTools:Q});if(m.current!==Re)return;if(!Ie.source){if(me<1){me+=1,await new Promise(ot=>setTimeout(ot,600));continue}ae("Subagent transcript is unavailable.");return}const st=mv(Ie.output,Ie.source.provider,{includeTools:Q});if(te(Ie.cursor),G(!!(Ie.hasMore&&Ie.cursor)),st&&(Oe=[st,...Oe],Hh(Oe,Q))){ne(ot=>ue==="older"?[...Oe,...ot]:Oe);return}if(!Ie.hasMore||!Ie.cursor||Ee>=WA){Oe.length>0&&ne(ot=>ue==="older"?[...Oe,...ot]:Oe);return}ee=Ie.cursor,Ee+=1}}catch(ee){if(m.current!==Re)return;ae(ee instanceof Error?ee.message:"Failed to load subagent transcript.")}finally{m.current===Re&&(g.current=!1,le(!1),R(!1))}}}function ce(){const H=d.current;H&&(H.scrollTop>72||!Y||!Te||g.current||K(Te,"older"))}function we(H){V(ue=>{const Re=new Set(ue);return Re.delete(H)||Re.add(H),Re})}function Le(H){b.current=!0,ie(!0),H.id!==O&&N(H.id),xe(H.id)}function xe(H){const ue=YA(w??[],H);ue.length!==0&&V(Re=>{if(ue.every(ee=>Re.has(ee)))return Re;const Ne=new Set(Re);for(const ee of ue)Ne.add(ee);return Ne})}function Be(){m.current+=1;const H=m.current;g.current=!1,p.current=!0,y.current=null,ne([]),te(null),G(!1),ae(null),K(null,"initial",H)}const De=v.useMemo(()=>Hh(Se,Q),[Se,Q]),He=v.useMemo(()=>dx(De),[De]),ze=w===null;v.useEffect(()=>{if(F||L||!Y||!Te||g.current)return;const H=d.current;!H||Se.length===0||H.scrollHeight<=H.clientHeight+4&&K(Te,"older")},[Se,Y,Te,F,L]);const re=w?.filter(H=>H.state==="working").length??0,he=v.useMemo(()=>vx(qA(w??[]),B),[w,B]);return f.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:H=>H.stopPropagation(),onMouseDown:H=>H.stopPropagation(),onClick:H=>{H.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":W?"transcript":"list",onPointerDown:H=>H.stopPropagation(),onMouseDown:H=>H.stopPropagation(),onClick:H=>H.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",w&&w.length>0?f.jsx("span",{className:"subagents-count",children:re>0?`${re} working · ${w.length} total`:`${w.length} total`}):null]}),f.jsxs("span",{title:r.sessionId,children:[_o(r.provider)," session ",r.sessionId]})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),f.jsxs("div",{className:"subagents-body",children:[f.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[ze?f.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!ze&&x?f.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!ze&&!x&&w!==null&&w.length===0?f.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,he.map(H=>{const ue=H.subagent,Re=B.has(ue.id);return f.jsxs("div",{className:"subagent-row-wrap",style:H.level>0?{paddingLeft:`${Math.min(H.level,4)*14}px`}:void 0,children:[H.nestedCount>0?f.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":Re,"aria-label":`${Re?"Collapse":"Expand"} ${H.nestedCount} nested subagents of ${ue.name}`,title:H.nestedWorkingCount>0?`${H.nestedCount} nested · ${H.nestedWorkingCount} working`:`${H.nestedCount} nested`,onClick:()=>we(ue.id),children:[f.jsx("span",{"aria-hidden":"true",children:Re?"▾":"▸"}),f.jsx("span",{className:"subagent-expander-count","data-working":H.nestedWorkingCount>0?"true":"false",children:H.nestedCount})]}):f.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),f.jsxs("button",{type:"button",className:"subagent-row","data-selected":ue.id===O?"true":"false","data-state":ue.state,disabled:!ue.hasTranscript,title:ue.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Le(ue),children:[f.jsx("span",{className:"subagent-row-dot","data-state":ue.state,"aria-hidden":"true"}),f.jsxs("span",{className:"subagent-row-main",children:[f.jsxs("span",{className:"subagent-row-title",children:[f.jsx("strong",{children:ue.name}),f.jsx("span",{className:"subagent-row-badge","data-kind":ue.kind,children:ue.kind==="cross"?_o(ue.provider):ue.provider})]}),ue.description?f.jsx("span",{className:"subagent-row-description",children:ue.description}):null,f.jsxs("span",{className:"subagent-row-meta",children:[ZA(ue.state),ue.model?` · ${ue.model}`:"",ue.updatedAt?` · ${QA(ue.updatedAt)}`:"",H.nestedCount>0&&!Re?` · ${H.nestedCount} nested${H.nestedWorkingCount>0?` (${H.nestedWorkingCount} working)`:""}`:""]})]})]})]},ue.id)})]}),f.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[f.jsxs("div",{className:"subagents-transcript-controls",children:[f.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>ie(!1),children:"‹ List"}),f.jsx("span",{className:"subagents-transcript-name",children:be?be.name:"Select a subagent"}),f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:Q,onChange:H=>$(H.currentTarget.checked)}),"Show tool output"]}),f.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!be,onClick:Be,children:"↻"})]}),be?f.jsx("div",{className:"subagents-transcript-hint",children:XA(be)}):null,f.jsxs("div",{ref:d,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:ce,children:[L?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!F&&Y?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,De?f.jsx(cx,{entries:He,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,F?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!F&&be&&!De&&!j?Y&&Te?f.jsxs("div",{className:"transcript-dialog-status",children:[Q?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{K(Te,"older")},disabled:L,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!be&&!ze&&!De?f.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,j?f.jsx("div",{className:"transcript-dialog-error",children:j}):null]})]})]})]})})});function qA(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=VA(r,t);o?o.children.push(r):n.push(r)}for(const r of n)mx(r);return gx(n),n}function VA(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const d=c.subagent.parentId;c=d?t.get(d):void 0}return r}function mx(e){let t=0,n=0;for(const r of e.children)mx(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,gx(e.children)}function gx(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function vx(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...vx(o.children,t,n+1));return r}function YA(e,t){const n=new Map(e.map(d=>[d.id,d])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function XA(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 GA(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function ZA(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function QA(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}class JA{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():Sx.has(t)?this.acceptConsonant(t):wx.has(t)?this.acceptVowel(t):nL(t)&&this.canReplacePendingWith(t)?(this.pending=kw(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(Cx.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=iL.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=tL.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=xw.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const r=this.pending.final,o=Ew({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=xw.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const n=kw(t);return n.initial===this.pending.initial&&(!this.pending.vowel||n.vowel===this.pending.vowel)&&(!this.pending.final||n.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=Ew(this.pending);return this.pending=null,t}}const Uh=44032,Kh=21,ll=28,eL=19*Kh*ll,_x=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],bx=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],yx=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Sx=N_(_x),wx=N_(bx),Cx=N_(yx),tL=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),xx=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],iL=new Map(xx),xw=new Map(xx.map(([e,t])=>[t,[e[0],e[1]]]));function N_(e){return new Map(e.map((t,n)=>[t,n]))}function nL(e){const t=e.codePointAt(0);return t!==void 0&&t>=Uh&&t<Uh+eL}function kw(e){const t=e.codePointAt(0)-Uh,n=Math.floor(t/(Kh*ll)),r=Math.floor(t%(Kh*ll)/ll),o=t%ll,c={initial:_x[n],vowel:bx[r]};return o===0?c:{...c,final:yx[o]}}function Ew(e){if(!e.vowel)return e.initial;const t=Sx.get(e.initial),n=wx.get(e.vowel),r=e.final?Cx.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Uh+(t*Kh+n)*ll+r)}const sL=[{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 rL({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(d){d.preventDefault(),d.stopPropagation(),r()}return f.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[f.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"}),sL.map(d=>f.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":d.ariaLabel,onClick:()=>n(d.key),children:d.label},d.key)),f.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const aL={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function oL(e){return aL[e]}function lL(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const kx="--nterminal-viewport-height",Ex="--nterminal-keyboard-inset-bottom",Tx="data-nterminal-keyboard-visible",df="data-nterminal-compose-open",Fh="nterminal:viewport-refresh",cL=120;function uL(e=window){const t=e.document.documentElement,n=e.visualViewport,r=gL(e);function o(){A_(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(Fh,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(Fh,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(kx),t.style.removeProperty(Ex),t.removeAttribute(Tx)}}function A_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=gv(e),o=dL(e,r);return o!==null&&Tw(t,kx,`${o}px`),Tw(t,Ex,`${n}px`),hL(t,Tx,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function gv(e=window){const t=fL(e);return{keyboardInsetBottom:t,keyboardVisible:t>cL}}function dL(e,t){if((e.document.documentElement.hasAttribute(df)||t)&&ho(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return ho(n)?n:ho(e.innerHeight)?e.innerHeight:null}function ho(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Tw(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function hL(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function fL(e){return Math.max(pL(e),mL(e))}function pL(e){const t=e.visualViewport?.height;if(!ho(t)||!ho(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}function mL(e){if(!ho(e.innerHeight))return 0;const n=Dx(e)?.boundingRect?.height;return!ho(n)||n>=e.innerHeight*.8?0:Math.round(n)}function Dx(e){return e.navigator.virtualKeyboard}function gL(e){const t=Dx(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const xu=new Map,cu=new Map,vL=Object.freeze({open:!1,text:""});function _L(e){let t=cu.get(e);return t||(t=new Set,cu.set(e,t)),t}function Rx(e){const t=cu.get(e);if(t)for(const n of Array.from(t))n()}function hf(e){return xu.get(e)??vL}function bL(e,t){const n=_L(e);return n.add(t),()=>{n.delete(t)}}function yL(e,t){const n=hf(e);n.open!==t&&(xu.set(e,{...n,open:t}),Rx(e))}function SL(e,t){const n=hf(e);n.text!==t&&(xu.set(e,{...n,text:t}),Rx(e))}function rh(e){xu.delete(e),cu.delete(e)}function Dw(){xu.clear(),cu.clear()}const wL=120,CL="\x1B[200~",xL="\x1B[201~";function Rw(e,t){const n=t.stripTrailingLineBreaks===!1?e:L_(e),r=EL(n);return r?t.bracketedPasteMode?`${CL}${r}${xL}`:r:""}function kL(e){return e==="queue"?" ":"\r"}function L_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function EL(e){return e.replace(/\r\n/g,`
|
|
50
|
+
`).replace(/\r/g,`
|
|
51
|
+
`).replace(/\n/g,"\r")}const TL=420,DL=3e3,Mw=650,RL=80,ML=3,Sh=new Set;let hl=null;function NL({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1}){const o=v.useMemo(()=>B=>bL(e,B),[e]),c=v.useMemo(()=>()=>hf(e),[e]),d=v.useSyncExternalStore(o,c,c),{open:m,text:g}=d,p=v.useRef(null),y=v.useRef(null),b=v.useRef(null),w=v.useRef(null);v.useEffect(()=>()=>{w.current?.(),w.current=null},[]),v.useLayoutEffect(()=>{if(!(!m||!wh()))return LL(e),()=>OL(e)},[m,e]),v.useLayoutEffect(()=>{const B=p.current?.closest(".terminal-pane");if(!B)return;function V(){B?.removeAttribute("data-compose-open"),B?.style.removeProperty("--compose-drawer-panel-height")}if(!m){V();return}const W=y.current;B.setAttribute("data-compose-open","true");function ie(){const ne=W?.getBoundingClientRect().height??0;ne>0&&B?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ne)}px`)}ie();const Q=[window.setTimeout(ie,0),window.setTimeout(ie,180),window.setTimeout(ie,260)],$=window.requestAnimationFrame?.(ie)??null,Se=typeof ResizeObserver=="function"&&W?new ResizeObserver(ie):null;return Se&&W&&Se.observe(W),()=>{for(const ne of Q)window.clearTimeout(ne);$!==null&&window.cancelAnimationFrame?.($),Se?.disconnect(),V()}},[m]),v.useEffect(()=>{if(!m){w.current?.(),w.current=null;return}Nw(b.current),N()},[m]);function C(B){yL(e,B)}function x(B){SL(e,B)}function D(){AL(p.current),C(!1),Aw()}function O(B="send"){if(!(r||!g)&&t(g,B)){if(x(""),wh()){b.current?.blur(),Aw();return}window.setTimeout(()=>b.current?.focus(),wL+20)}}function N(){wh()&&(w.current?.(),w.current=BL())}return f.jsxs("div",{ref:p,className:"compose-drawer","data-open":m?"true":"false",children:[f.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":m?"true":void 0,tabIndex:m?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>C(!0),children:[f.jsx("span",{"aria-hidden":"true",children:"▴"}),f.jsx("span",{children:"compose"}),g?f.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),f.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":m?void 0:"true",children:[f.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:m?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[f.jsx("span",{"aria-hidden":"true",children:"▾"}),f.jsx("span",{className:"compose-drawer-title",children:"compose"}),f.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),f.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),f.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:m?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:B=>x(B.target.value),onFocus:N,onKeyDown:B=>{if(B.key==="Enter"&&(B.metaKey||B.ctrlKey)){if(B.preventDefault(),B.shiftKey){n&&O("queue");return}O("send");return}B.key==="Escape"&&(B.preventDefault(),D())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),f.jsxs("div",{className:"compose-drawer-actions",children:[f.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:m?0:-1,onClick:()=>{x(""),Nw(b.current),N()},disabled:!g,children:"Clear"}),n?f.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:m?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>O("queue"),disabled:r||!g,children:"Queue"}):null,f.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:m?0:-1,onClick:()=>O("send"),disabled:r||!g,children:"Send"})]})]})]})}function AL(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Nw(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function wh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Aw(){if(!wh())return;const e=cl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function LL(e){hl!==null&&(window.clearTimeout(hl),hl=null),Sh.add(e),document.documentElement.setAttribute(df,"true"),cl()}function OL(e){if(Sh.delete(e),Sh.size>0||hl!==null){cl();return}hl=window.setTimeout(()=>{if(hl=null,Sh.size>0){cl();return}document.documentElement.removeAttribute(df),cl()},TL),cl()}function BL(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),d=window.visualViewport,m=jL();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),d?.removeEventListener("resize",b),d?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(w){if(!e){if(w<Mw&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,RL)}}function b(){if(e)return;g();const w=A_(),C=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),C>=DL||C>=Mw&&o>=ML){p();return}y(C)}return d?.addEventListener("resize",b),d?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),p}function cl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,A_()}function jL(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function zL(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(d=>{if(HL(d))return d.preventDefault(),d.stopPropagation(),IL(e),!1;if(PL(d)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return d.preventDefault(),d.stopPropagation(),n.onInterrupt(),!1;if(UL(d)){const m=vv(e);return m?(d.preventDefault(),d.stopPropagation(),_v(m),!1):!0}return KL(d)?(d.preventDefault(),d.stopPropagation(),FL(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=d=>{const m=vv(e);if(m){if(d.clipboardData){d.clipboardData.setData("text/plain",m),d.preventDefault();return}d.preventDefault(),_v(m)}},c=d=>{const m=d.clipboardData?.getData("text/plain");if(!m)return;const g=L_(m);d.preventDefault(),d.stopImmediatePropagation(),Mx(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",c,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function IL(e){const t=vv(e);t&&await _v(t)}function PL(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function HL(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 UL(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function KL(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 FL(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;Mx(e,L_(n),t)}catch{}}function Mx(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function vv(e){return e.hasSelection()?e.getSelection():WL(e.element??null)}function WL(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function _v(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}$L(e)}function $L(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.style.opacity="0",document.body.appendChild(n),n.focus({preventScroll:!0}),n.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{n.remove(),t?.focus({preventScroll:!0})}}const qL=[4,10,11,12];function VL(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>Lw(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>Lw(r)),e.parser.registerCsiHandler({final:"n"},r=>YL(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>XL(r)),e.parser.registerCsiHandler({final:"t"},r=>GL(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...qL.map(r=>e.parser.registerOscHandler(r,o=>ZL(o)))];return{dispose(){for(const r of n)r.dispose()}}}function Lw(e){return ff(e)===0}function YL(e){const t=ff(e);return t===5||t===6}function XL(e){return ff(e)===6}function GL(e){const t=ff(e);return t===14||t===16||t===18}function ZL(e){return e.split(";").some(t=>t==="?")}function ff(e){const t=e[0];return typeof t=="number"?t:0}const Mr=new Map,Fm=2*1024*1024,QL=1500,Ow=25e3,JL=2500,e3=1e3,t3=3e4,i3=16*1024*1024,bv=256,n3=M2-3e4,yv=16*1024*1024,Nx=4*1024*1024,Wh=25,s3=1e3;let r3=0,Wm=0;const a3=new TextEncoder,o3=b3();function l3(e,t){let n=Mr.get(e);n||(n=f3(e),Mr.set(e,n),ku(n)),n.listeners.add(t),queueMicrotask(()=>jx(n));const r=c=>g3(n,c),o=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:r,detach:o}}function Uc(e){const t=Mr.get(e);t&&(_3(t),Mr.delete(e))}function c3(e){const t=Mr.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),El(t),Rr(t,"reconnecting"),La(t);const n=t.socket;return t.socket=null,xa(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),ku(t),!0}function u3(e){const t=Mr.get(e);if(!t||(t.heartbeatSuspended=!1,t.exited||!t.reconnectEnabled||t.status==="unauthorized"))return Promise.resolve("skipped");const n=t.socket;if(!n||n.readyState!==WebSocket.OPEN)return Promise.resolve(t.status==="closed"?"skipped":"reconnecting");if(t.resumeProbe?.socket===n)return t.resumeProbe.promise;const r=Date.now();if(t.lastResumeProbeSocket===n&&r-t.lastResumeProbeAt<e3)return Promise.resolve("alive");Rr(t,"reconnecting"),La(t),t.lastResumeProbeSocket=n,t.lastResumeProbeAt=r;const o=`resume-${r.toString(36)}-${(++r3).toString(36)}`;let c;const d=new Promise(g=>{c=g}),m={socket:n,nonce:o,timeout:0,promise:d,resolve:c};t.resumeProbe=m,m.timeout=window.setTimeout(()=>{t.resumeProbe!==m||t.socket!==n||(Rr(t,"reconnecting"),zw(t))},JL);try{n.send(JSON.stringify({type:"ping",nonce:o}))}catch{Rr(t,"reconnecting"),zw(t)}return d}function d3(){for(const e of Mr.values())e.heartbeatSuspended=!0,El(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,Rr(e,"skipped"),La(e)}function h3(){for(const e of Mr.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),La(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,xa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ku(e)}}function $m(){for(const e of Array.from(Mr.keys()))Uc(e)}function f3(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,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:Wh,listeners: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 ku(e){if(!e.reconnectEnabled)return;xa(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,El(e),xa(e,"connected"),bo(e,t),e.isAlive=!0,Bw(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(E3(c)){T3(e,t,c.instanceId,c.inputAck);return}if(e.inputProtocolMode==="unknown"&&Lx(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),Rr(e,"alive"),bo(e,t),Bw(e));return}if(c.type==="input_ack"){C3(e,t,c);return}if(c.type==="input_ack_confirmed"){R3(e,c);return}const d=m3(e,c);if(uu(e,{type:"message",message:d}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;jx(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Rr(e,"reconnecting"),La(e),r.code===1008){e.reconnectEnabled=!1,xa(e,p3(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=t3)&&(e.lastUpgradeAuthProbeAt=o,uu(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){xa(e,"closed");return}xa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,ku(e)},QL)}}),t.addEventListener("error",()=>{})}function Bw(e){if(La(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>Ow*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},Ow)}function La(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function p3(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function m3(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+Nr(r),0),jw(e),e.exited&&Ch(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Nr(t.data),jw(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Ch(e)),t):(t.type==="exit"&&(e.exited=!0,Ch(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function jw(e){for(;e.outputBytes>Fm&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Nr(t)}e.outputBytes>Fm&&e.output.length===1&&(e.output[0]=N3(e.output[0],Fm),e.outputBytes=Nr(e.output[0]))}function xa(e,t){e.status!==t&&(e.status=t,uu(e,{type:"status",status:t}))}function uu(e,t){for(const n of Array.from(e.listeners))n(t)}function g3(e,t){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const n=S3(e,t);if(!n)return"rejected";const r=JSON.stringify(n),o=Nr(r);if(o>i3)return"rejected";const c={message:n,encoded:r,bytes:o,sentInstanceId:null,firstSentAt:null};if(!w3(e,c))return"rejected";const d=e.socket,m=d?.readyState===WebSocket.OPEN,g=n.type!=="ping"&&n.type!=="resize";if(g&&(!m||n.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(d?.bufferedAmount??0)>Nx))return v3(e,n)?(m&&d&&bo(e,d),"queued"):e.pendingOut.length>=bv||e.pendingOutBytes+o>yv?"rejected":(e.pendingOut.push(c),e.pendingOutBytes+=o,Iw(e,c),m&&d&&bo(e,d),"queued");if(m){Iw(e,c);try{return d.send(r),Ax(e,c),"sent"}catch{if(g&&e.pendingOut.length<bv&&e.pendingOutBytes+o<=yv)return e.pendingOut.push(c),e.pendingOutBytes+=o,d.close(),"queued";Eu(e,c),d.close()}}return"rejected"}function bo(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden")return;let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Nx){M3(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown")return;try{t.send(r.encoded),Ax(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=Wh,n=!0}e.outboundFlushDelayMs=Wh,n&&queueMicrotask(()=>{e.pendingOut.length===0&&uu(e,{type:"outbound_flushed"})})}function v3(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const d=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(d===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:d}}}if(!r)return!1;const o=JSON.stringify(r),c=Nr(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function El(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=Wh}function Rr(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function zw(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),El(e),Rr(e,"reconnecting"),La(e);const t=e.socket;e.socket=null,xa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ku(e)}function _3(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),El(e),Rr(e,"skipped"),La(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Ch(e),e.listeners.clear()}function b3(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function y3(){return Wm=(Wm+1)%Number.MAX_SAFE_INTEGER,`${o3}-${Wm.toString(36)}`.slice(0,P1)}function S3(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=y3();return n.length===0||n.length>P1?null:{...t,messageId:n}}function w3(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<bv&&e.unackedInputBytes+t.bytes<=yv)}function Iw(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function Eu(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 C3(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&Sv(e,t,c);return}if(Eu(e,r),e.inputProtocolMode!=="ack"||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),Sv(e,t,o)}function Ax(e,t){t.message.type!=="input"||!t.message.messageId||e.inputProtocolMode!=="ack"||!e.serverInstanceId||(t.sentInstanceId=e.serverInstanceId,t.firstSentAt??=Date.now())}function x3(e){if(k3(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=Array.from(e.unackedInputs.values()).filter(r=>r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId));n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function k3(e){const t=Date.now(),n=new Set;for(const[c,d]of e.unackedInputs)d.firstSentAt!==null&&t-d.firstSentAt>=n3&&n.add(c);if(n.size===0)return;e.pendingOut=e.pendingOut.filter(c=>{const d=c.message.type==="input"?c.message.messageId:void 0;return!d||!n.has(d)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of n){const d=e.unackedInputs.get(c);d&&Eu(e,d)}const r=n.size===1?"input":"inputs",o=n.size===1?"it":"them";Bx(e,{message:`NTerminal did not replay ${n.size} unacknowledged ${r} after the connection was unavailable for too long, to avoid running ${o} twice.`,ready:!1})}function E3(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function T3(e,t,n,r){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){Lx(e,t);return}const o=e.serverInstanceId;e.inputProtocolMode="ack",e.serverInstanceId=n,o===n?(x3(e),D3(e,t)):o!==null&&(Ox(e),zx(e)),bo(e,t)}function Lx(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",e.serverInstanceId=null,Ox(e),zx(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;Eu(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=Nr(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}bo(e,t)}}function Ox(e){const t=new Set;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&t.add(r);if(t.size===0)return;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&&Eu(e,o)}const n=t.size===1?"input was":"inputs were";Bx(e,{message:`The terminal server restarted before ${t.size} ${n} acknowledged. NTerminal did not resend ${t.size===1?"it":"them"} to avoid running input twice.`,ready:!1})}function Bx(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function jx(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)uu(e,{type:"message",message:{type:"error",message:n.message}})}}function Ch(e){El(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function Sv(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="ack"||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function D3(e,t){for(const n of e.pendingAckReceipts.values())if(Sv(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function R3(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function zx(e){e.pendingAckReceipts.clear()}function M3(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(s3,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,bo(e,t)},n)}function Nr(e){return a3.encode(e).byteLength}function N3(e,t){if(Nr(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);Nr(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const A3=[0,50,150,350],L3=[100,300,750],O3=2,B3=[300,1200,2500],j3=1e3,z3=1e5,I3="",wv="\x1B[?1049l\x1B[?1047l\x1B[?47l",P3=new Set(["47","1047","1049"]),H3=400,U3=9,K3=9,F3=32,W3=1.42,$3=2,q3=24,V3=720,Y3=60,X3=1260,G3=6,Z3=2,Pw=[500,1500,3e3,5e3,8e3],Hw=15e3,Q3=2,J3=1e3,Uw="Do not take action. Wait for my next input.",$h=6e4,e5=$h+5*6e4,Kw=$h+6e4,t5=40,ah=240,i5=5e3,eu=new Map,al=new Map;function Fw({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:d,codeServerContext:m,onSelect:g,onClose:p,onExit:y,onSnapshot:b,onAuthClose:w}){const C=v.useSyncExternalStore(sC,Cg,()=>co),x=v.useSyncExternalStore(rC,xg,()=>ml),D=v.useSyncExternalStore(aC,Eg,()=>!0),O=v.useSyncExternalStore(fh,Tg,()=>!0),N=v.useSyncExternalStore(fh,Dg,()=>!0),B=v.useSyncExternalStore(Vv,Da,()=>pl),V=v.useSyncExternalStore(Gc,()=>Zc("history.toggle"),()=>"Alt+H"),W=v.useSyncExternalStore(Gc,()=>Zc("scrollback.toggle"),()=>"Alt+S"),ie=v.useSyncExternalStore(Gc,()=>Zc("subagents.toggle"),()=>"Alt+A"),Q=v.useRef(null),$=v.useRef(null),Se=v.useRef(null),ne=v.useRef(null),Te=v.useRef(e.id),te=v.useRef({onExit:y,onSnapshot:b}),Y=v.useRef(t.createWebSocketUrl),G=v.useRef(w),F=v.useRef(null),le=v.useRef(null),L=v.useRef(null),R=v.useRef(!1),j=v.useRef(new Map),ae=v.useRef(new Map),be=v.useRef(new Set),M=v.useRef([]),K=v.useRef(!1),ce=v.useRef(null),we=v.useRef(0),Le=v.useRef(!1),xe=v.useRef(!1),Be=v.useRef(!1),De=v.useRef({terminalId:e.id,enabled:!1}),He=v.useRef([]),ze=v.useRef([]),re=v.useRef(0),he=v.useRef(!1),H=v.useRef(null),ue=v.useRef(0),Re=v.useRef(0),Ne=v.useRef(null),ee=v.useRef(null),Ee=v.useRef(!1),me=v.useRef(!1),Oe=v.useRef(!1),Ie=v.useRef(null),st=v.useRef(!1),ot=v.useRef(null),Nt=v.useRef(null),pi=v.useRef(!1),Cn=v.useRef(!1),Rt=v.useRef(!1),Qe=v.useRef(!1),gt=v.useRef(!1),Bt=v.useRef(!1),ye=v.useRef(!1),We=v.useRef(n),Je=v.useRef(r),et=v.useRef(c),wt=v.useRef(C),ft=v.useRef(x),xn=v.useRef(!1),Oi=v.useRef(!1),q=v.useRef(null),Ke=v.useRef(0),Ge=v.useRef(0),at=v.useRef(e.id),xt=v.useRef(()=>{}),jt=v.useRef(null),qt=v.useRef(null),Vt=v.useRef(!1),$t=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),Ci=v.useRef(0),Yt=v.useRef(null),ii=v.useRef(0),mi=v.useRef(null),xi=v.useRef(0),Fi=v.useRef(!1),gn=v.useRef(!1),gi=v.useRef(null),vi=v.useRef(null),[,en]=v.useState("connecting"),[Bi,Qt]=v.useState(!1),[ki,Xn]=v.useState(null),[Oa,qs]=v.useState(!1),[Ba,Vs]=v.useState(null),[Ys,xs]=v.useState(!1),[ks,ps]=v.useState(!1),[Es,cn]=v.useState(!1),[ai,Or]=v.useState(!1),[oi,zn]=v.useState(null),_i=e.agentCache&&oi&&e.agentCache.source.provider===oi.provider&&e.agentCache.source.sessionId===oi.sessionId?e.agentCache:null,[Xs,Co]=v.useState(()=>Date.now()),[Ts,ja]=v.useState(!1),[Gs,Ds]=v.useState(null),[vn,Ei]=v.useState(!1),[Br,Zs]=v.useState(!1),[tn,ms]=v.useState(null),[jr,Gn]=v.useState(!1),[Wi,ct]=v.useState(!1),[zr,kn]=v.useState(null),[Zn,Ir]=v.useState(null),Qn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Rs,Pr]=v.useState(()=>km(e.id)),Qs=oi?.provider??e.agentStatus?.provider??null,za=Qs!==null||Kc(e.currentCommand),Hr=Qs==="claude"||Kx(e.currentCommand),Rl=Qs!==null||Kc(e.currentCommand),Ur=e.capabilities?.tmuxScrollback===!0,Jt=Ur&&(Rs??(Rl?N:O)),[Ms,Js]=v.useState(!1);v.useLayoutEffect(()=>{We.current=n},[n]),v.useLayoutEffect(()=>{Je.current=r},[r]),v.useLayoutEffect(()=>{et.current=c},[c]),v.useLayoutEffect(()=>{wt.current=C},[C]),v.useLayoutEffect(()=>{ft.current=x},[x]),v.useLayoutEffect(()=>{xn.current=vn},[vn]),v.useLayoutEffect(()=>{Oi.current=Br},[Br]),v.useLayoutEffect(()=>{q.current=oi},[oi]);const Kt=v.useCallback((S,z={})=>{!S&&z.preserveOnNull||(sh(q.current,S)||(Ge.current+=1),q.current=S,zn(Ce=>Ce&&S&&Ce.provider===S.provider&&Ce.sessionId===S.sessionId?Ce:S))},[]),un=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),er=v.useCallback(()=>{const S=q.current,z=Ge.current;S&&(async()=>{let Ce=S;try{Ce=await un()??Ce}catch{}Ce&&at.current===e.id&&Ge.current===z&&sh(S,q.current)&&(Kt(Ce,{preserveOnNull:!0}),jt.current=Ym(e.id,Ce),Zs(!1),Ei(!0))})()},[Kt,un,e.id]),Kr=v.useCallback(()=>{q.current&&(Ei(!1),Zs(!0))},[]),Ns=v.useCallback(async(S={})=>{const z=await $w(Qn,t,S);return ms(z),z},[Qn,t]),nn=v.useCallback((S,z="info")=>{mi.current!==null&&window.clearTimeout(mi.current),Ir({id:ii.current++,message:S,tone:z}),mi.current=window.setTimeout(()=>{Ir(null),mi.current=null},3200)},[]),En=v.useCallback(()=>{const S=m?.serverKey.trim()||"local",z=m?.serverName.trim()||"Local",Ce=m?.tabName.trim()||e.title||"Terminal",Fe=tn?.instances.find(tt=>tt.cwd===e.cwd);if(Fe&&qw(oh(S,Fe.id))){nn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(Fe&&qm(oh(S,Fe.id),Fe.url)){nn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ye=null;const Ze=()=>((!Ye||Px(Ye))&&(Ye=window.open("about:blank","_blank"),n5(Ye)),Ye);tn?.installed!==!0&&Ze(),ct(!0),kn(null),(async()=>{let tt=tn;if(tt?.installed||(tt=await Ns({force:!0})),!tt?.installed||tt.supported===!1){Vm(Ye),Gn(!0);return}const ut=tt.instances.find(At=>At.cwd===e.cwd);if(ut){const At=oh(S,ut.id);if(Vw(Ye,At,ut.url)||qm(At,ut.url)!==null){nn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const qe=Ze();return{response:await t.openCodeServer({terminalId:e.id,serverName:z,tabName:Ce}),targetPopup:qe}})().then(tt=>{if(!tt)return;const{response:ut,targetPopup:qe}=tt;Cv(Qn,ut.status),ms(ut.status);const kt=oh(S,ut.instance.id);if(qw(kt)){Vm(qe),nn("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}Vw(qe,kt,ut.url)||qm(kt,ut.url)?nn("Opening VS Code..."):nn("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(tt=>{Vm(Ye),Gn(!0),kn(lh(tt))}).finally(()=>ct(!1))},[m?.serverName,m?.tabName,Qn,tn,Ns,t,nn,e.cwd,e.id,e.title]);v.useEffect(()=>{let S=!1;return $w(Qn,t).then(z=>{S||ms(z)}).catch(()=>{}),()=>{S=!0}},[Qn,t]),v.useEffect(()=>{if(tn?.job?.status!=="running")return;const S=window.setInterval(()=>{Ns({force:!0}).catch(z=>kn(lh(z)))},1e3);return()=>window.clearInterval(S)},[tn?.job?.status,Ns]),v.useEffect(()=>()=>{mi.current!==null&&window.clearTimeout(mi.current)},[]),v.useLayoutEffect(()=>{xt.current=er},[er]),v.useLayoutEffect(()=>{qt.current=_i},[_i]),v.useLayoutEffect(()=>{Vt.current=Ts},[Ts]),v.useLayoutEffect(()=>{Fi.current=za},[za]),v.useLayoutEffect(()=>{gn.current=Hr},[Hr]),v.useLayoutEffect(()=>{const S=De.current;xe.current=Jt,Be.current=Ur,De.current={terminalId:e.id,enabled:Jt},Xw(Q.current,Jt),S.terminalId===e.id&&S.enabled&&!Jt&&Ka(),Jt||cn(!1)},[e.id,Jt,Ur]),v.useEffect(()=>{Pr(km(e.id)),we.current=0,Le.current=!1,cn(!1),Eo()},[e.id]),v.useEffect(()=>fh(()=>{Pr(km(e.id))}),[e.id]),v.useEffect(()=>()=>{Hl()},[]),v.useEffect(()=>{let S=!1;return r&&e.status==="running"&&Tn(()=>S),()=>{S=!0}},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&Dn("auto")},[n,r,e.status]),v.useEffect(()=>{te.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{Y.current=t.createWebSocketUrl,G.current=w},[t,w]),v.useLayoutEffect(()=>{Te.current=e.id,ye.current=!1,Or(!1)},[e.id]),v.useEffect(()=>{let S=!1,z=null,Ce=0;const Fe=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ye=Fe||k5(e.currentCommand),Ze=Fe||Kc(e.currentCommand);function tt(){z!==null&&(window.clearTimeout(z),z=null)}function ut(kt){if(S)return;let At;if(kt)At=Hw;else if(Ce<Pw.length){if(!Ye)return;At=Pw[Ce++]}else{if(!Ze)return;At=Hw}z=window.setTimeout(()=>{z=null,qe()},At)}async function qe(){try{const kt=q.current!==null,At=await un();if(S)return;if(At){Ke.current=0,Kt(At),ut(!0);return}Ke.current+=1;const Mt=!!(kt&&Ye&&Ke.current<Q3);Kt(null,{preserveOnNull:Mt}),ut(Mt)}catch(kt){if(S)return;Xm(kt)&&Kt(null),ut(!1)}}return at.current!==e.id&&(at.current=e.id,Ge.current+=1,q.current=null,Ke.current=0,zn(null)),e.status!=="running"?(Ge.current+=1,q.current=null,Ke.current=0,zn(null),()=>{S=!0,tt()}):(qe(),()=>{S=!0,tt()})},[Kt,un,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const S=Ym(e.id,oi),z=jt.current;z!==null&&S!==null&&z!==S&&(ee.current=null,Ee.current=!1,me.current=!1,xn.current&&Ei(!1),Zs(!1)),jt.current=S},[e.id,oi?.provider,oi?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!oi){ja(!1);return}const S=window.setInterval(()=>{Co(Date.now())},J3);return()=>{window.clearInterval(S)}},[e.status,oi?.provider,oi?.sessionId]),v.useEffect(()=>{const S=a5(_i);$t.current.key!==S&&($t.current={key:S,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[_i?.expiresAt,_i?.source?.provider,_i?.source?.sessionId]),v.useEffect(()=>{if(!Ts||!_i||_i.status!=="ready")return;const S=Hx(_i,Xs);if(S===null||S<=0)return;const z=$t.current;!z.warnedFiveMinutes&&S<=e5&&S>Kw&&(z.warnedFiveMinutes=!0,Jn({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!z.warnedOneMinute&&S<=Kw&&S>$h&&(z.warnedOneMinute=!0,Jn({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!z.sent&&!z.skipped&&S<=$h&&Kl()},[Ts,Xs,_i,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function S(z){if(!We.current||!Je.current||z.isComposing||z.key==="Process"||c5(z.target))return;const Ce=uC(z);if(Ce?.id==="history.toggle"&&q.current){z.preventDefault(),z.stopPropagation(),xn.current?Ei(!1):xt.current();return}if(Ce?.id==="subagents.toggle"&&q.current){z.preventDefault(),z.stopPropagation(),Oi.current?Zs(!1):Kr();return}if(Ce?.id==="scrollback.toggle"&&Be.current){z.preventDefault(),z.stopPropagation(),Fa();return}}return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[]),v.useEffect(()=>{const S=$.current;S&&(S.options.disableStdin=e.status==="exited"),e.status==="exited"&&en("closed")},[e.status]),v.useEffect(()=>{const S=$.current;S&&(S.options.fontSize=C,xm(C,ft.current).then(()=>{wt.current===C&&$i()}))},[C]),v.useEffect(()=>{const S=$.current;S&&(S.options.fontFamily=wg(x),xm(wt.current,x).then(()=>{ft.current===x&&$i()}))},[x]),v.useEffect(()=>{const S=$.current;S&&(S.options.theme=Ww(B))},[B]),v.useEffect(()=>{const S=Q.current;if(!S)return;let z=!1,Ce=null,Fe=null,Ye=null,Ze=null,tt=null,ut=null,qe=null;F.current=null,gt.current=!1,Bt.current=!1,st.current=!1,Tu(),Du(),gs(),K.current=!1;const kt=wt.current,At=ft.current,Mt=new AA({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:wg(At),fontSize:kt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:z3,theme:{...Ww(Da())}}),_s=new CR;return Mt.loadAddon(_s),Ze=VL(Mt),$.current=Mt,Se.current=_s,xm(kt,At).then(()=>{if(z)return;Mt.open(S),Xw(S,xe.current),gt.current=!0,Ce=zL(Mt,{onPasteText:xf,onInterrupt:Cf,shouldInterruptPlainCtrlC:()=>gn.current}),Je.current&&We.current&&e.status==="running"&&Dn("auto"),$i(),tt=N5(S,Mt,()=>wt.current*1.2,$r,Os=>{vs(Os)},Ol,Ua,()=>xe.current,Pl),ut=D5(S,Mt,$r,Os=>{vs(Os)},Ol,Ua,()=>xe.current,Pl);const Do=new JA;Fe=Mt.onData(Os=>{if(ye.current){const Wl=lL(Os);if(Wl){To(!1),rr(Wl);return}}const qu=Do.accept(Os);qu&&rr(qu)}),Ye=Mt.onScroll(Os=>{if(Cn.current||Qe.current||Rt.current){ji();return}Nu(),Vn(Mt)&&sr({scrollToBottom:!0}),$r(),!xe.current&&Os<=3&&vs()}),qe=new ResizeObserver(()=>{ve()}),qe.observe(S),Bt.current&&(nr(),Bt.current=!1,$i()),Ml()}),()=>{Vr(ne.current,{updateUi:!1}),z=!0,gt.current=!1,Bt.current=!1,Tu(),Du(),le.current=null,L.current=null,R.current=!1,Ru(),K.current=!1,Mu(),Rt.current=!1,he.current=!1,ue.current+=1,Re.current+=1,H.current=null,gi.current=null,vi.current=null,Oe.current=!1,Ie.current=null,Qt(!1),tt?.(),ut?.(),qe?.disconnect(),Ce?.dispose(),Fe?.dispose(),Ye?.dispose(),Ze?.dispose(),Mt.dispose(),$.current=null,Se.current=null}},[e.id]),v.useEffect(()=>{const S=Y.current(e.id),z=l3(S,Pa);return ne.current=z.send,en(z.status),z.status==="connected"&&$i(),z.snapshot&&(te.current.onSnapshot(z.snapshot,{notifyCompletion:!1}),$.current&&($i(),dn(z.output,z.history),$i())),()=>{Vr(z.send,{updateUi:!1}),z.detach(),ne.current=null}},[e.id,e.status]);function Pa(S){if(S.type==="status"){en(S.status),S.status==="unauthorized"&&G.current?.({source:"terminal-ws-1008",terminalId:e.id}),S.status==="connected"&&($i(),ko());return}if(S.type==="upgrade_rejected"){G.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(S.type==="outbound_flushed"){K.current&&(K.current=!1,hn());return}T(S.message)}function gs(S=[],z=null){He.current=[],ze.current=ch(S),re.current=0,he.current=!1,H.current=null,Rt.current=!1,ue.current+=1,Ne.current=z,ee.current=null,Ee.current=!1,me.current=!1,Oe.current=!1,Ie.current=null,Bt.current=!1,gi.current=null,vi.current=null,ot.current=null,pi.current=!1,Qt(!1),Xn(null),qs(!1),Vs(null),xs(!1),ps(!1)}function dn(S=[],z=null){if(Rt.current||he.current){vi.current={output:S,history:z,appendFromLiveOutputIndex:ze.current.length};return}gs(S,z),ir()}function tr(){if(Rt.current||he.current)return!1;const S=vi.current;if(!S)return!1;const z=ze.current.slice(S.appendFromLiveOutputIndex);return vi.current=null,gs([...S.output,...z],S.history),ir(),!0}function ir(){if(!$.current||!gt.current){Bt.current=!0;return}Bt.current=!1,nr()}async function nr(){const S=$.current;if(!S)return;const z=uh(S,pi.current),Ce=z?ze.current.length:re.current,Fe=await As(S,{liveOutputLimit:Ce,scrollToBottom:z});$.current===S&&(ji(),Fe&&ko())}function As(S,z={}){return new Promise(Ce=>{Rt.current=!0,he.current=!1;const Fe=ue.current+1;ue.current=Fe;const Ye=Math.max(0,Math.min(z.liveOutputLimit??ze.current.length,ze.current.length)),Ze=z.historyPages??He.current,tt=()=>$.current===S&&ue.current===Fe,ut=()=>tt()&&(z.isCurrent?.()??!0),qe=()=>{tt()&&(Rt.current=!1),Ce(!1)},kt=()=>{if(!ut()){qe();return}try{re.current=Ye,z.scrollToBottom&&Ls(S)}finally{if(Rt.current=!1,tr()){Ce(!1);return}const Mt=Au();Mt?sr(Mt):z.applyDeferredSnapshot!==!1&&Ll(),Ce(!0)}},At=()=>{if(!ut()){qe();return}S.clear();const Mt=ch([...Ze,...ze.current.slice(0,Ye)]);if(Mt.length===0){kt();return}for(let _s=0;_s<Mt.length;_s+=1){const Do=Mt[_s];_s===Mt.length-1?S.write(Do,kt):S.write(Do)}};if(S.buffer.active.type==="alternate"){S.write(wv,At);return}At()})}async function vs(S=0){const z=$.current;if(Oe.current||!z)return;if(Al(z)){ji();return}const Ce=Ne.current,Fe=Re.current,Ye=Symbol("history-load"),Ze=()=>$.current===z&&Re.current===Fe;Ie.current=Ye,Oe.current=!0,Qt(!0);const tt=z.buffer.active.viewportY;try{let ut=!!(Ce&&!Ce.hasMore);if(!ut)try{const qe=await t.getTerminalHistory(e.id,{beforeLine:Ce?.startLine??0,...Ce?.snapshotHistorySize!==void 0?{snapshotHistorySize:Ce.snapshotHistorySize}:{},...Ce?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ce.snapshotHistoryLimit}:{},...Ce?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ce.snapshotHistoryToken}:{},...Ce?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ce.snapshotPaneWidth}:{},limit:j3});if(!Ze()||Ne.current!==Ce)return;const kt=()=>Ze()&&Ne.current===Ce;if(qe.invalidated){k();return}const At=qe.hasMore&&qe.snapshotHistorySize!==void 0&&qe.snapshotPaneWidth!==void 0,Mt={startLine:qe.startLine,endLine:qe.endLine,hasMore:At,...qe.snapshotHistorySize!==void 0?{snapshotHistorySize:qe.snapshotHistorySize}:{},...qe.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:qe.snapshotHistoryLimit}:{},...qe.snapshotHistoryToken!==void 0?{snapshotHistoryToken:qe.snapshotHistoryToken}:{},...qe.snapshotPaneWidth!==void 0?{snapshotPaneWidth:qe.snapshotPaneWidth}:{}};if(qe.output.length>0){await bi(z,qe.output,tt,S)&&kt()&&(Ne.current=Mt);return}if(!kt())return;Ne.current=Mt,ut=!At}catch(qe){ut=Ze()&&Xm(qe)}if(ut){if(!Ze()||Al(z)){ji();return}await In(z,tt,S,Ze)}}catch{}finally{Ie.current===Ye&&(Ie.current=null,Oe.current=!1,Qt(!1))}}async function In(S,z,Ce,Fe){if(!Fe()||Ee.current||me.current)return;const Ye=q.current,Ze=Ge.current,tt=ee.current,ut=()=>Fe()&&Ge.current===Ze&&sh(Ye,q.current)&&ee.current===tt;try{const qe=await t.getTerminalTranscriptHistory(e.id,{...tt?{cursor:tt}:{},limit:H3}),kt=qe.output.map(hx);if(!qe.source||qe.terminalId!==e.id||!ut())return;if(Ye&&!M_(Ye,qe.source)){ee.current=null,Ee.current=!1,me.current=!1,Kt(qe.source);return}if(kt.length===0){Kt(qe.source),ee.current=qe.cursor,me.current=!qe.hasMore||!qe.cursor;return}await bi(S,kt,z,Ce,ut)&&ut()&&(Kt(qe.source),ee.current=qe.cursor,me.current=!qe.hasMore||!qe.cursor)}catch(qe){ut()&&Xm(qe)&&(Ee.current=!0)}}async function bi(S,z,Ce,Fe,Ye){if(Al(S)||Ye&&!Ye())return ji(),!1;const Ze=He.current,tt=[...z,...Ze],ut=E5(z),qe=ue.current+1,kt=await As(S,{liveOutputLimit:re.current,scrollToBottom:!1,historyPages:tt,applyDeferredSnapshot:!1,...Ye?{isCurrent:Ye}:{}}),At=Ye!==void 0&&!Ye();return!kt||At||$.current!==S?(At&&$.current===S&&ue.current===qe&&await As(S,{liveOutputLimit:re.current,scrollToBottom:!1,historyPages:Ze,applyDeferredSnapshot:!1})&&$.current===S&&(Lu(S,Ce),pi.current=!Vn(S),$r()),!1):(He.current=tt,Lu(S,Math.max(0,Ce+ut+Math.min(0,Fe))),pi.current=!Vn(S),$r(),!0)}v.useEffect(()=>{const S=window.visualViewport;let z=!1;function Ce(){if(document.visibilityState==="hidden"){d3();return}Tn(()=>z)}function Fe(){Tn(()=>z)}function Ye(){Tn(()=>z)}function Ze(){ve()}function tt(){ke()}return document.addEventListener("visibilitychange",Ce),window.addEventListener("pageshow",Fe),window.addEventListener("online",Ye),window.addEventListener("resize",Ze),window.addEventListener(Fh,tt),S?.addEventListener("resize",Ze),S?.addEventListener("scroll",Ze),()=>{z=!0,document.removeEventListener("visibilitychange",Ce),window.removeEventListener("pageshow",Fe),window.removeEventListener("online",Ye),window.removeEventListener("resize",Ze),window.removeEventListener(Fh,tt),S?.removeEventListener("resize",Ze),S?.removeEventListener("scroll",Ze)}},[e.id]);function Tn(S){if(document.visibilityState==="hidden"||!Je.current)return;ko(),$i();const z=Y.current(e.id);u3(z).then(()=>{S()||($i(),ko())})}function k(){const S=Y.current(e.id);Re.current+=1,st.current=!0,gi.current=null,en("reconnecting"),$i(),c3(S)}function T(S){if(S.type==="snapshot"&&S.terminal.id===e.id){Re.current+=1,te.current.onSnapshot(S.terminal,{notifyCompletion:!1});const Ce=st.current;st.current=!1;const Fe=$.current;if(!Fe)return;if($i(),Ce){I(S.output,S.history??null);return}if(bf(Fe,S.terminal)){Sf(S.output,S.history??null),ji(),$i();return}dn(S.output,S.history??null),$i();return}if(S.type==="terminal_updated"&&S.terminal.id===e.id){te.current.onSnapshot(S.terminal,{notifyCompletion:!0});return}if(S.type==="output"&&S.terminalId===e.id){const Ce=Fx(S.data);if(!Ce)return;ze.current.push(Ce),$.current&>.current?sr({scrollToBottom:!0}):Bt.current=!0;return}const z=$.current;if(z){if(S.type==="exit"&&S.terminalId===e.id){te.current.onExit(S.exitCode),en("closed");return}S.type==="error"&&z.writeln(`\r
|
|
52
|
+
[nterminal] ${S.message}`)}}function I(S,z){dn(S,z),$i()}function se(S=25){if(document.visibilityState==="hidden"||!Je.current||j.current.has(S))return;const z=window.setTimeout(()=>{j.current.delete(S),!fe()&&qr()},S);j.current.set(S,z)}function ve(){fe()||Ml()}function fe(){const S=li();return S&&Ve(S)?(R.current=!0,L.current=S,!0):S&&vt(S)?(R.current=!1,L.current=null,!0):((!S||!S.composeOpen&&!S.keyboardVisible)&&(R.current=!1,L.current=null),!1)}function ke(){if(!R.current)return;const S=li();S&&(S.composeOpen||S.keyboardVisible)||(R.current=!1,L.current=null)}function Ve(S){if(!S.mobileLike||!S.composeOpen&&!S.keyboardVisible)return!1;const z=le.current;return z?Wr(S.windowWidth,z.windowWidth)&&Wr(S.visualViewportWidth,z.visualViewportWidth)&&Wr(S.containerWidth,z.containerWidth):!1}function vt(S){if(!S.mobileLike||S.composeOpen||S.keyboardVisible)return!1;const z=L.current;return!z||!z.composeOpen&&!z.keyboardVisible?!1:Wr(S.windowWidth,z.windowWidth)&&Wr(S.visualViewportWidth,z.visualViewportWidth)&&Wr(S.containerWidth,z.containerWidth)}function li(){const S=Q.current;if(!S||S.isConnected===!1)return null;const z=S.getBoundingClientRect(),Ce=xo(window.innerWidth)??0,Fe=xo(window.visualViewport?.width)??Ce,Ye=xo(z.width)??xo(S.clientWidth)??Ce;if(Ce<=0||Fe<=0||Ye<=0)return null;const{keyboardVisible:Ze}=gv(),tt=document.documentElement.hasAttribute(df),ut=ni()||Ze;return{windowWidth:Ce,visualViewportWidth:Fe,containerWidth:Ye,composeOpen:tt,keyboardVisible:Ze,mobileLike:ut}}function ni(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Fr(){return gv().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function xo(S){return typeof S=="number"&&Number.isFinite(S)&&S>0?S:null}function Wr(S,z){return Math.abs(S-z)<=O3}function Ml(){for(const S of A3)se(S)}function $i(){F.current=null,Ml()}function ko(){if(Ha(),be.current.size===0&&typeof window.requestAnimationFrame=="function"){const S=window.requestAnimationFrame(()=>{be.current.delete(S),Ha();const z=window.requestAnimationFrame(()=>{be.current.delete(z),Ha()});be.current.add(z)});be.current.add(S)}for(const S of L3){if(ae.current.has(S))continue;const z=window.setTimeout(()=>{ae.current.delete(S),Ha()},S);ae.current.set(S,z)}}function Ha(){const S=$.current;if(!(!S||!gt.current||document.visibilityState==="hidden"||!Je.current||Q.current?.isConnected===!1))try{S.refresh(0,Math.max(0,S.rows-1))}catch{}}function Tu(){for(const S of j.current.values())window.clearTimeout(S);j.current.clear()}function Du(){for(const S of ae.current.values())window.clearTimeout(S);ae.current.clear();for(const S of be.current)window.cancelAnimationFrame(S);be.current.clear()}function Ru(){for(const S of M.current)window.clearTimeout(S);M.current=[]}function $r(){if(ji(),!ot.current){qs(!1);return}qs(!0),Mu(),Nt.current=window.setTimeout(()=>{Nt.current=null,qs(!1)},1200)}function ji(){const S=$.current,z=S?T5(S):null;if(ot.current=z,Xn(z),ps(!!(S&&z)),xs(!!(S&&z&&!Vn(S))),z||!S||!vf()){Vs(null);return}Vs({alternate:S.buffer.active.type==="alternate"})}function vf(){const S=Ne.current;return He.current.length>0||!!S?.hasMore}function Mu(){Nt.current!==null&&(window.clearTimeout(Nt.current),Nt.current=null)}function Nu(){const S=$.current;S&&(pi.current=!Vn(S),ji())}function Nl(S){H.current=Gm(H.current,S)}function _f(S){const z=H.current;return H.current=null,Gm(z,S)}function Au(){const S=H.current;return H.current=null,S}function sr(S={}){const z=$.current;if(!z||!gt.current){Bt.current=!0;return}if(gi.current&&!Rt.current&&!he.current&&Vn(z)){Ll();return}if(Rt.current){Nl(S);return}if(he.current){Nl(S);return}const Ce=_f(S);if(!Ce.force&&!uh(z,pi.current)){ji();return}he.current=!0;const Fe=ue.current,Ye=()=>{if($.current!==z||ue.current!==Fe)return;if(!Ce.force&&!uh(z,pi.current)){if(he.current=!1,tr())return;ji();return}const Ze=re.current,tt=ze.current[Ze];if(tt===void 0){if(he.current=!1,tr())return;Ce.scrollToBottom&&Ls(z),ji();const ut=Au();ut?sr(Gm(Ce,ut)):Ll();return}z.write(tt,()=>{$.current!==z||ue.current!==Fe||(re.current=Ze+1,Ye())})};Ye()}function Al(S){return gi.current!==null||!Vn(S)&&(yf()||he.current||Rt.current)}function bf(S,z){return(z?.agentStatus?.provider==="codex"||z?.agentStatus?.provider==="claude"||Fi.current||Kc(z?.currentCommand))&&!Vn(S)}function yf(){return re.current<ze.current.length}function Sf(S,z){gi.current={output:S,history:z,appendFromLiveOutputIndex:ze.current.length}}function Ll(){const S=$.current,z=gi.current;if(!S||!z||!Vn(S)||he.current||Rt.current)return;const Ce=ch(z.output),Fe=ch(ze.current.slice(z.appendFromLiveOutputIndex));gi.current=null,dn([...Ce,...Fe],z.history),$i()}function Ol(){Qe.current=!0}function Ua(){Nu(),Qe.current=!1;const S=$.current;S&&Vn(S)&&sr({scrollToBottom:!0})}function Ls(S){Bl(()=>Gw(S))&&(pi.current=!1)}function Lu(S,z){Bl(()=>(S.scrollToLine(z),!0))}function Bl(S){Cn.current=!0;try{return S()}finally{Cn.current=!1}}function Ou(){const S=$.current;if(!S)return;const z=()=>{xe.current&&(Iu(ne.current),cn(!1)),Gw(S),pi.current=!1,ji(),sr({force:!0,scrollToBottom:!0}),Dn("scroll-action")};if(S.buffer.active.type==="alternate"){S.write(wv,z);return}z()}function jl(S){const z=$.current,Ce=Q.current;if(!z||!Ce)return;const Fe=Ce.getBoundingClientRect();if(Fe.height<=0)return;const Ye=Math.max(0,Math.min(1,(S-Fe.top)/Fe.height)),Ze=Math.round(z.buffer.active.baseY*Ye);Ol();try{z.scrollToLine(Ze)}finally{Ua()}pi.current=!Vn(z),ji(),$r(),Ze<=3&&vs()}function Bu(S){S.preventDefault(),S.stopPropagation(),S.currentTarget.setPointerCapture?.(S.pointerId),jl(S.clientY)}function ju(S){(S.buttons&1)!==0&&(S.preventDefault(),S.stopPropagation(),jl(S.clientY))}function qr(){const S=$.current,z=Se.current;if(!(!S||!z)&&!(document.visibilityState==="hidden"||!Je.current||Q.current?.isConnected===!1))try{const Ce=uh(S,pi.current),Fe=li();z.fit(),Fe&&(le.current=Fe),Ce&&Ls(S),S.refresh(0,Math.max(0,S.rows-1)),ji();const Ye={cols:S.cols,rows:S.rows},Ze=F.current;if(Ze&&Ze.cols===Ye.cols&&Ze.rows===Ye.rows)return;zl({type:"resize",terminalId:e.id,cols:Ye.cols,rows:Ye.rows})&&(F.current=Ye)}catch{}}function zu(S){const z=ne.current;return z?z(S):"rejected"}function zl(S){return zu(S)!=="rejected"}function Eo(){ce.current!==null&&(window.clearTimeout(ce.current),ce.current=null)}function Il(){Eo();const S=Math.max(-ah,Math.min(ah,we.current));if(we.current=0,S===0)return!1;const z=zl({type:"scrollback_scroll",terminalId:e.id,lines:S});return z&&(Le.current=!0,S<0&&cn(!0)),z}function Pl(S){if(!xe.current||S===0)return;const z=we.current+S;we.current=Math.max(-ah,Math.min(ah,z)),ce.current===null&&(ce.current=window.setTimeout(()=>{ce.current=null,Il()},t5))}function Ka(){Iu(ne.current)}function Vr(S=ne.current,z={}){const Ce=Le.current;Eo(),we.current=0,Le.current=!1,z.updateUi!==!1&&cn(!1),Ce&&S?.({type:"cancel_scrollback",terminalId:e.id})}function Iu(S){Eo(),we.current=0,Le.current=!1,cn(!1),S?.({type:"cancel_scrollback",terminalId:e.id})}function Fa(){if(!Be.current)return;const S=!xe.current;Pr(AD(Te.current,S)),wf()}function Pu(){const S=!Vt.current;Vt.current=S,ja(S),Jn({tone:S?"info":"skipped",message:S?"Cache keep-alive enabled":"Cache keep-alive off",...S?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Hl(){Yt.current!==null&&(window.clearTimeout(Yt.current),Yt.current=null)}function Jn(S,z={}){Hl();const Ce=Ci.current+1;Ci.current=Ce,Ds({...S,id:Ce}),!z.sticky&&(Yt.current=window.setTimeout(()=>{Yt.current=null,Ds(Fe=>Fe?.id===Ce?null:Fe)},12e3))}function Ul(){$t.current.skipped=!0,Jn({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function Hu(){Vt.current=!1,ja(!1),Jn({tone:"skipped",message:"Cache keep-alive off"})}async function Kl(){const S=$t.current;if(S.sent||S.skipped)return;const z=Uu();if(S.sent=!0,z){Jn({tone:"skipped",message:"Skipped cache keep-alive",detail:z});return}if(rr(`${Uw}\r`,{userInitiated:!1})==="rejected"){Jn({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Jn({tone:"success",message:"Cache keep-alive sent",detail:Uw})}function Uu(){const S=qt.current,z=q.current;return Vt.current?e.status!=="running"?"Pane is not running.":!S||S.status!=="ready"||!S.source||!z?"Transcript cache status is unavailable.":S.source.provider!==z.provider||S.source.sessionId!==z.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${_o(z.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":hf(e.id).text.trim()?"Compose has an unsent draft.":u5(Q.current)?"Pane input is focused.":Date.now()-xi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function wf(){const S=$.current;S&&(Ls(S),ji())}function rr(S,z={}){Il();const Ce=Le.current;sr({force:!0,scrollToBottom:!0});const Fe=zu({type:"input",terminalId:e.id,data:S,...Ce?{cancelScrollbackMode:!0}:{}});return Fe==="rejected"?(nn("Input was not sent because the terminal connection buffer is full or unavailable.","error"),Fe):(z.userInitiated!==!1&&(xi.current=Date.now()),Ce&&(Le.current=!1,cn(!1)),x5(S)&&(Fe==="sent"?hn():Fe==="queued"&&(K.current=!0)),Fe)}function Cf(){ye.current&&To(!1),rr(I3)}function xf(S){const z=Rw(S,{bracketedPasteMode:$.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});z&&rr(z)}function kf(S,z){const Ce=Rw(S,{bracketedPasteMode:$.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});return Ce?rr(`${Ce}${kL(z)}`)!=="rejected":!1}function hn(){!et.current||!We.current||(Ru(),M.current=B3.map(S=>{const z=window.setTimeout(()=>{M.current=M.current.filter(Ce=>Ce!==z),et.current&&We.current&&zl({type:"refresh_cwd",terminalId:e.id})},S);return z}))}function Dn(S="terminal-interaction"){xn.current||Fr()&&(S==="auto"||S==="scroll-action")||$.current?.focus()}const Ku=v.useCallback(()=>{Ei(!1)},[]),Fu=v.useCallback(async()=>{const S=q.current,z=Ge.current;try{const Ce=await t.getTerminalTranscriptSource(e.id);if(!Ce.source||at.current!==e.id||Ge.current!==z||!sh(S,q.current))return;ee.current=null,Ee.current=!1,me.current=!1,Kt(Ce.source),jt.current=Ym(e.id,Ce.source)}catch{}},[Kt,t,e.id]);function Wu(){Or(S=>{const z=!S;return ye.current=z,z}),Dn("input-action")}function To(S){ye.current=S,Or(S)}function Fl(S){ye.current&&To(!1),rr(oL(S)),Dn("input-action")}async function $u(S="install"){ct(!0),kn(null);try{const z=S==="update"?await t.updateCodeServer():await t.installCodeServer();Cv(Qn,z.status),ms(z.status)}catch(z){kn(lh(z))}finally{ct(!1)}}return f.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Jt?"true":"false",onMouseDown:()=>{n||g()},children:[f.jsx(d5,{terminal:e,canClose:o,tabId:d,transcriptSource:oi,transcriptShortcutLabel:V,subagentsShortcutLabel:ie,transcriptCacheStatus:_i,transcriptCacheNow:Xs,cacheKeepAliveEnabled:Ts,codeServerAvailable:!0,codeServerInstallState:tn===null?"unknown":tn.installed?"installed":"missing",codeServerBusy:Wi||tn?.job?.status==="running",codeServerSupported:tn?.supported!==!1,scrollbackShortcutLabel:W,tmuxScrollbackSupported:Ur,tmuxScrollbackEnabled:Jt,onToggleCacheKeepAlive:Pu,onOpenCodeServer:En,onToggleTmuxScrollback:Fa,onOpenTranscript:er,onOpenSubagents:Kr,onReload:k,onClose:p}),f.jsx("div",{className:"xterm-container",ref:Q}),Bi?f.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:f.jsx("span",{"aria-hidden":"true"})}):null,D&&!Jt&&ki?f.jsxs("div",{className:"terminal-scroll-progress","data-active":Oa,"aria-hidden":"true",children:[ki.current,"/",ki.total]}):D&&!Jt&&Ba?f.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ba.alternate?"alternate":"normal","aria-hidden":"true",children:[Ba.alternate?"alt ":"","0/?"]}):null,Ys||Jt&&Es?f.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),onClick:S=>{S.stopPropagation(),Ou()},children:"↓"}):null,ks&&!Jt?f.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Bu,onPointerMove:ju,children:f.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Ms?f.jsx(rL,{ctrlActive:ai,onCtrl:Wu,onStandaloneKey:Fl,onPreserveFocus:()=>Dn("input-action"),onHide:()=>Js(!1)}):f.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:S=>{S.stopPropagation(),Dn("input-action")},onPointerDown:S=>{S.stopPropagation(),Dn("input-action")},onClick:()=>Js(!0),children:"⌨"}):null,f.jsx(NL,{terminalId:e.id,onSubmit:kf,queueAvailable:Qs==="codex"||Ux(e.currentCommand),disabled:e.status!=="running"}),f.jsx(m5,{toast:Gs,onSendNow:()=>{Kl()},onSkipOnce:Ul,onTurnOff:Hu,onDismiss:()=>Ds(null)}),vn&&oi?f.jsx(g5,{terminalId:e.id,serverApi:t,source:oi,fontSize:C,onClose:Ku,onReloadLatest:Fu}):null,Br&&oi?f.jsx($A,{terminalId:e.id,serverApi:t,source:oi,fontSize:C,onClose:()=>Zs(!1)}):null,Zn?f.jsx(f5,{notice:Zn}):null,jr?f.jsx(h5,{status:tn,busy:Wi,error:zr,onInstall:()=>{$u("install")},onUpdate:()=>{$u("update")},onOpen:En,onRefresh:()=>{Ns({checkLatest:!0}).catch(S=>kn(lh(S)))},onClose:()=>Gn(!1)}):null]})}function Ww(e){return YE(e)}async function $w(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),d=al.get(e);if(!o&&d?.status&&c-d.fetchedAt<=i5)return d.status;if(d?.inflight&&(!r||d.inflightCheckLatest))return d.inflight;let m;return m=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(Cv(e,g),g)).catch(g=>{const p=al.get(e);throw p?.inflight===m&&(p.status?al.set(e,{status:p.status,fetchedAt:p.fetchedAt}):al.delete(e)),g}),al.set(e,{...d?.status?{status:d.status,fetchedAt:d.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:r}),m}function Cv(e,t){al.set(e,{status:t,fetchedAt:Date.now()})}function oh(e,t){return`${e}:${t}`}function Ix(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function qw(e){const t=eu.get(e);if(!t)return!1;try{return t.closed?(eu.delete(e),!1):(t.focus(),!0)}catch{return eu.delete(e),!1}}function qm(e,t){const n=window.open(t,Ix(e));if(!n)return null;eu.set(e,n);try{n.focus()}catch{}return n}function Vw(e,t,n){if(!e||Px(e))return!1;try{return e.name=Ix(t),e.location.href=n,eu.set(t,e),e.focus(),!0}catch{return!1}}function n5(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 Px(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Vm(e){if(e)try{e.closed||e.close()}catch{}}function s5(e,t,n){const r=r5(e,t),o=Yw(r*Math.max(1,n),Y3,X3);return{limit:Yw(Math.ceil(o/$3),q3,V3),maxLines:o}}function r5(e,t){const n=e?.clientHeight??0;if(n<=0)return F3;const r=Math.max(10,t*W3);return Math.max(1,Math.floor(n/r))}function Yw(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function a5(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function Ym(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function Hx(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function o5(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function l5(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),d=r%24;return d>0?`${c}d ${d}h`:`${c}d`}function c5(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function lh(e){return e instanceof Bn||e instanceof Error?e.message:"Something went wrong."}function u5(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function d5({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:d,transcriptCacheNow:m,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:y,codeServerBusy:b,codeServerSupported:w,scrollbackShortcutLabel:C,tmuxScrollbackSupported:x,tmuxScrollbackEnabled:D,onToggleCacheKeepAlive:O,onOpenCodeServer:N,onToggleTmuxScrollback:B,onOpenTranscript:V,onOpenSubagents:W,onReload:ie,onClose:Q}){const $=B1({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),Se={cursor:n?"grab":"default",opacity:$.isDragging?.5:void 0};return f.jsxs("header",{ref:$.setNodeRef,className:"terminal-pane-header",style:Se,"data-dragging":$.isDragging,...$.attributes,...$.listeners,children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),f.jsx("span",{className:"terminal-pane-spacer"}),p?f.jsx("button",{type:"button",className:"terminal-pane-code","data-state":y,"data-busy":b?"true":"false",disabled:!w||b,title:y==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":y==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),N()},children:f.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?f.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${_o(r.provider)} transcript history`,"aria-label":`View ${_o(r.provider)} transcript history`,onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),V()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View history"}),f.jsx("span",{className:"pane-button-label-short",children:"History"}),f.jsx("kbd",{children:o})]}):null,r?f.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:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),W()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View agents"}),f.jsx("span",{className:"pane-button-label-short",children:"Agents"}),f.jsx("kbd",{children:c})]}):null,r?f.jsx(p5,{status:d,now:m,keepAliveEnabled:g,onToggle:O}):null,e.status==="exited"?f.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,x&&e.status==="running"?f.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":D?"true":"false","aria-pressed":D,"aria-label":`Toggle tmux scrollback (${C})`,title:D?`Scroll input uses tmux scrollback (${C}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${C}).`,onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),B()},children:[D?f.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.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"}),f.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"})]}):f.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.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"}),f.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),f.jsx("kbd",{children:C})]}):null,e.status==="running"?f.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),ie()},children:"↻"}):null,t?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),Q()},children:"x"}):null]})}function h5({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:d,onClose:m}){const g=e?.job??null,p=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,w=e===null&&t,C=e?.updateAvailable===!0,x=y?"VS Code add-on":"Install VS Code add-on";return f.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":x,onClick:m,children:f.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{children:[f.jsx("h2",{children:x}),f.jsx("p",{children:w?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),f.jsxs("div",{className:"code-server-dialog-scroll",children:[f.jsxs("div",{className:"code-server-dialog-body",children:[f.jsxs("p",{children:["NTerminal installs code-server under ",f.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),w?f.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:f.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?f.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?f.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[f.jsxs("div",{className:"code-server-progress-heading",children:[f.jsx("span",{children:g.action}),f.jsx("strong",{children:g.status})]}),f.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
53
|
+
`):"Preparing..."})]}):null]}),f.jsxs("div",{className:"code-server-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:d,disabled:t||p||!b,children:"Check"}),y?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:C?"Update":"Reinstall"}),f.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):f.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function f5({notice:e}){return f.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function p5({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=Hx(e,t),c=o5(e,o),d=o===null?"?":l5(o),m=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return f.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:m,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[f.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),f.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),f.jsx("span",{children:d})]})}function m5({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return f.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[f.jsxs("header",{children:[f.jsx("strong",{children:e.message}),f.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?f.jsx("p",{children:e.detail}):null,c?f.jsxs("div",{className:"cache-keepalive-toast-actions",children:[f.jsx("button",{type:"button",onClick:t,children:"Send now"}),f.jsx("button",{type:"button",onClick:n,children:"Skip once"}),f.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const g5=Ai.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:d}){const m=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),w=v.useRef(""),C=v.useRef(null),x=v.useRef(null),[D,O]=v.useState([]),[N,B]=v.useState(!1),[V,W]=v.useState(""),[ie,Q]=v.useState(-1),[$,Se]=v.useState(!1),[ne,Te]=v.useState(-1),[te,Y]=v.useState(null),[G,F]=v.useState(null),[le,L]=v.useState(!1),[R,j]=v.useState(!0),[ae,be]=v.useState(!1),[M,K]=v.useState(null),[ce,we]=v.useState(!1);v.useEffect(()=>{function ye(We){We.key==="Escape"&&(We.preventDefault(),We.stopPropagation(),c())}return document.addEventListener("keydown",ye,!0),()=>document.removeEventListener("keydown",ye,!0)},[c]),v.useEffect(()=>{g.current+=1;const ye=g.current;return p.current=!1,y.current=!0,b.current=null,C.current=null,x.current=null,O([]),F(null),L(!1),K(null),we(!1),Q(-1),Te(-1),Y(null),ot(null,"initial",ye),()=>{g.current===ye&&(g.current+=1)}},[n,N,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ye=m.current;if(!ye)return;if(y.current){if(R||D.length===0)return;y.current=!1;const Je=()=>{ye.scrollTop=ye.scrollHeight};Je(),window.requestAnimationFrame?.(Je);return}const We=b.current;We!==null&&(b.current=null,ye.scrollTop+=ye.scrollHeight-We)},[D,R,N]);const Le=_o(r.provider),xe=Hh(D,N),Be=dx(xe),De=v5(Be),He=De.map(ye=>ye.key).join(""),ze=te?De.find(ye=>ye.key===te)?.entryIndex??null:null,re=V.trim().length>0,he=zA(Be,V),H=he.length,ue=H>0?ie>=0&&ie<H?ie:0:-1,Re=ue>=0?he[ue]?.entryIndex??null:null,Ne=ue>=0?he[ue]??null:null,ee=re?Re:ze,Ee=re?Re===null?null:"search":ze===null?null:"prompt",me=xe?xe.split(`
|
|
54
|
+
`).length-1:0,Oe=De.length>0&&ne>=0&&ne<De.length?ne:De.length-1,Ie=te??(Oe>=0?De[Oe]?.key??null:null),st=re?H>0?`${ue+1}/${H} ${H===1?"match":"matches"} · ${me} ${me===1?"line":"lines"}`:`0 matches · ${me} ${me===1?"line":"lines"}`:De.length>0?`${Oe+1}/${De.length} prompts · ${me} ${me===1?"line":"lines"}`:`0 prompts · ${me} ${me===1?"line":"lines"}`;v.useEffect(()=>{const ye=V.trim().toLowerCase();Q(We=>!ye||H===0?-1:w.current!==ye?0:We>=0&&We<H?We:0),w.current=ye},[V,H]),v.useEffect(()=>{if(re){Y(null);return}te&&!De.some(ye=>ye.key===te)&&Y(null),Te(ye=>{if(De.length===0)return x.current=null,-1;const We=x.current?De.findIndex(et=>et.key===x.current):-1,Je=We>=0?We:ye>=0&&ye<De.length?ye:De.length-1;return x.current=De[Je]?.key??null,Je})},[te,re,He]),v.useEffect(()=>{const ye=C.current;if(!ye||De.length===0)return;C.current=null;const We=ye.anchorKey?De.findIndex(et=>et.key===ye.anchorKey):-1,Je=We>0?We-1:0;Qe(Je)},[He]);async function ot(ye,We,Je=g.current){if(!p.current){p.current=!0,We==="initial"?j(!0):(be(!0),b.current=m.current?.scrollHeight??null),K(null);try{await Nt(ye,We,Je)}catch(et){if(g.current!==Je)return;K(et instanceof Error?et.message:"Failed to load transcript history.")}finally{g.current===Je&&(p.current=!1,j(!1),be(!1))}}}async function Nt(ye,We,Je){let et=ye,wt=0,ft=[];const xn=We==="initial"&&r.provider!=="claude"?Z3:G3;for(;g.current===Je;){const Oi=await n.getTerminalTranscriptHistory(t,{...et?{cursor:et}:{},...s5(m.current,o,We==="initial"?U3:K3),includeTools:N});if(g.current!==Je)return;if(!Oi.source){K("Transcript source is temporarily unavailable.");return}if(!M_(r,Oi.source)){we(!0),L(!1);return}const q=mv(Oi.output,r.provider,{includeTools:N}),Ke=pi(Oi,We,ft,q);if(q&&(ft=[q,...ft],Ke))return;if(!Oi.hasMore||!Oi.cursor||wt>=xn){ft.length>0&&O(Ge=>We==="older"?[...ft,...Ge]:ft);return}et=Oi.cursor,wt+=1}}function pi(ye,We,Je,et=mv(ye.output,r.provider,{includeTools:N})){if(F(ye.cursor),L(!!(ye.hasMore&&ye.cursor)),!et)return!1;const wt=[et,...Je];return Hh(wt,N)?(O(ft=>We==="older"?[...wt,...ft]:wt),!0):!1}function Cn(){const ye=m.current;ye&&(Bt(),!(ye.scrollTop>72||!le||!G||p.current)&&ot(G,"older"))}function Rt(ye){H!==0&&Q(We=>{const Je=ue>=0?ue:ye>0?-1:0;return((We>=0&&We<H?We:Je)+ye+H)%H})}function Qe(ye){const We=De[ye];We&&(x.current=We.key,Te(ye),Y(We.key))}async function gt(ye){if(De.length===0){ye<0&&le&&G&&!p.current&&(C.current={anchorKey:null},await ot(G,"older"));return}const Je=(ne>=0&&ne<De.length?ne:ye<0?De.length-1:-1)+ye;if(Je>=0&&Je<De.length){Qe(Je);return}ye<0&&Je<0&&le&&G&&!p.current&&(C.current={anchorKey:De[0]?.key??null},await ot(G,"older"))}function Bt(){if(re)return;const ye=m.current;if(!ye)return;const Je=ye.getBoundingClientRect().top+Math.min(140,Math.max(48,ye.clientHeight*.28));let et=null;for(const wt of w5(ye)){const ft=C5(wt);if(ft!==null)if(wt.getBoundingClientRect().top<=Je)et=ft;else break}if(et!==null){const wt=De[et]?.key??null;x.current=wt,Te(et),te&&te!==wt&&Y(null)}}return f.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>{ye.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>ye.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"transcript-dialog-title",children:[Le," JSONL"]}),f.jsx("span",{title:r.sessionId,children:r.sessionId})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),f.jsxs("div",{className:"transcript-dialog-controls",children:[f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:N,onChange:ye=>B(ye.currentTarget.checked)}),"Show tool output"]}),f.jsx("label",{className:"transcript-search",children:f.jsx("input",{type:"search",value:V,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ye=>W(ye.currentTarget.value),onKeyDown:ye=>{ye.key==="Enter"&&(ye.preventDefault(),re?Rt(ye.shiftKey?-1:1):gt(ye.shiftKey?-1:1))}})}),f.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":$,"aria-label":"Toggle prompt list",onClick:()=>Se(ye=>!ye),disabled:De.length===0,children:"List"}),f.jsxs("div",{className:"transcript-search-actions","aria-label":re?"Search result navigation":"Prompt navigation",children:[f.jsx("button",{type:"button",onClick:()=>re?Rt(-1):void gt(-1),disabled:re?H===0:De.length===0&&!le,"aria-label":re?"Previous search match":"Previous user prompt",title:re?"Previous search match":"Previous user prompt",children:"Prev"}),f.jsx("button",{type:"button",onClick:()=>re?Rt(1):void gt(1),disabled:re?H===0:De.length===0,"aria-label":re?"Next search match":"Next user prompt",title:re?"Next search match":"Next user prompt",children:"Next"})]}),f.jsx("span",{className:"transcript-result-count",children:st})]}),$?f.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:De.length>0?De.map((ye,We)=>f.jsxs("button",{type:"button",className:Ie===ye.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>Qe(We),children:[f.jsx("span",{children:ye.timestampLabel}),f.jsx("strong",{children:ye.snippet})]},`${ye.key}:${We}`)):f.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,f.jsxs("div",{ref:m,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Cn,children:[ae?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&le?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,xe?f.jsx(cx,{entries:Be,searchQuery:V,activeEntryIndex:ee,activeEntryMode:Ee,activeSearchMatch:Ne,fontSize:o}):null,R?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,ce?f.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",f.jsx("button",{type:"button",onClick:()=>{d()},children:"Load current session"})]}):null,!ce&&!R&&!xe&&!M?le&&G?f.jsxs("div",{className:"transcript-dialog-status",children:[N?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{ot(G,"older")},disabled:ae,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,M?f.jsx("div",{className:"transcript-dialog-error",children:M}):null]})]})})});function v5(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:_5(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const d=n.get(c.contentKey)??0;n.set(c.contentKey,d+1),r.set(o,JSON.stringify([c.contentKey,d]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:y5(o.entry.body),timestampLabel:S5(o.entry.header)}))}function _5(e){return JSON.stringify([e.header??"",e.body.length,b5(e.body)])}function b5(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function y5(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function S5(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function w5(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function C5(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const n=Number(t);return Number.isInteger(n)&&n>=0?n:null}function x5(e){return e.includes("\r")||e.includes(`
|
|
55
|
+
`)}function Xm(e){return e instanceof Bn&&e.status===404}function Kc(e){return Ux(e)||Kx(e)}function Ux(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function Kx(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function k5(e){if(Kc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function E5(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function ch(e){const t=[];for(const n of e){const r=Fx(n);r&&t.push(r)}return t}function Fx(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!P3.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function Gm(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function T5(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function Xw(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function Vn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function uh(e,t){return!t||Vn(e)}function Gw(e){return Vn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function D5(e,t,n,r,o,c,d,m){const g=p=>{const y=M5(p);if(y!==0){if(d()){if(L5(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),m(y);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),R5(t,y,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function R5(e,t,n,r,o,c){const d=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(wv,d);return}d()}function M5(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function N5(e,t,n,r,o,c,d,m,g){let p=null,y=0;const b={passive:!1};function w(D){p=Zm(D),y=0}function C(D){const O=Zm(D);if(O===null){p=null,y=0;return}if(p===null){p=O;return}const N=O.clientY-p.clientY;if(p=O,D.cancelable&&D.preventDefault(),N===0)return;if(A5(t)&&O5(t,O,-N)){y=0;return}y-=N/n();const B=y<0?Math.ceil(y):Math.floor(y);if(B!==0){if(y-=B,m()){g(B);return}c();try{t.scrollLines(B)}finally{d()}r(),B<0&&t.buffer.active.viewportY<=3&&o(B)}}function x(D){if(D.touches.length>0){p=Zm(D);return}p=null,y=0}return e.addEventListener("touchstart",w,b),e.addEventListener("touchmove",C,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",w,b),e.removeEventListener("touchmove",C,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Zm(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function A5(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function L5(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function O5(e,t,n){const r=e.element;return r?(r.dispatchEvent(B5(t,n)),!0):!1}function B5(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function xv({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:d=!1,tabId:m,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:w=[],totalPanes:C,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:B,onCloseEditor:V,onAuthClose:W}){const ie=C??kv(e);if(w.length===0&&b){const ne=Ev(e),Te=ne.some(te=>te.key===b)?b:ne[0]?.key;if(ne.length>1&&Te)return f.jsx("div",{className:"mobile-focused-split",children:ne.map(te=>{const Y=te.key===Te;if(te.type==="editor"){const F=n[te.editorId];return f.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:F?f.jsx(D0,{api:r,editor:F,canClose:ie>1,onClose:()=>V(te.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},te.key)}const G=t[te.terminalId];return G?f.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:f.jsx(Fw,{terminal:G,serverApi:r,active:Y,visible:c&&Y,canClose:ie>1,refreshCwdOnEnter:d&&Y,tabId:m,codeServerContext:g,onSelect:()=>x(te.terminalId),onClose:()=>D(te.terminalId),onExit:F=>N(te.terminalId,F),onSnapshot:B,...W?{onAuthClose:W}:{}})},te.key):f.jsx("div",{className:"mobile-focused-pane","data-active":Y,"aria-hidden":!Y,children:f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},te.key)})})}if(e.type==="pane"){const ne=t[e.terminalId];if(!ne)return f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const Te=f.jsx(Fw,{terminal:ne,serverApi:r,active:e.terminalId===o,visible:c,canClose:ie>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>D(e.terminalId),onExit:Y=>N(e.terminalId,Y),onSnapshot:B,...W?{onAuthClose:W}:{}});return p&&y!==e.terminalId?f.jsxs("div",{className:"pane-drop-host",children:[Te,f.jsx(dh,{terminalId:e.terminalId,side:"top"}),f.jsx(dh,{terminalId:e.terminalId,side:"right"}),f.jsx(dh,{terminalId:e.terminalId,side:"bottom"}),f.jsx(dh,{terminalId:e.terminalId,side:"left"})]}):Te}if(e.type==="editor"){const ne=n[e.editorId];return ne?f.jsx(D0,{api:r,editor:ne,canClose:ie>1,onClose:()=>V(e.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const Q=Math.max(.1,Math.min(.9,e.ratio)),$=1-Q,Se=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${Q}fr) 1px minmax(0, ${$}fr)`}:{gridTemplateRows:`minmax(0, ${Q}fr) 1px minmax(0, ${$}fr)`};return f.jsxs("div",{className:"split-pane","data-direction":e.direction,style:Se,children:[f.jsx("div",{className:"split-cell",children:f.jsx(xv,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,0],totalPanes:ie,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:B,onCloseEditor:V,...W?{onAuthClose:W}:{}})}),f.jsx(j5,{direction:e.direction,path:w,onResize:O}),f.jsx("div",{className:"split-cell",children:f.jsx(xv,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...w,1],totalPanes:ie,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:B,onCloseEditor:V,...W?{onAuthClose:W}:{}})})]})}function dh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=e_({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return f.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function j5({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=c.parentElement;if(!d)return;const m=d.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return f.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:f.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function kv(e){return e.type==="pane"||e.type==="editor"?1:kv(e.first)+kv(e.second)}function Ev(e){return e.type==="pane"?[{key:z5(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:I5(e.editorId),type:"editor",editorId:e.editorId}]:[...Ev(e.first),...Ev(e.second)]}function z5(e){return`terminal:${e}`}function I5(e){return`editor:${e}`}const pf="workspace-default",P5="NTerminal";function H5(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function U5(e,t){switch(t.type){case"workspace.hydrated":return Tv(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return K5(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return q5(e,t.workspaceId);case"workspace.selected":return Wx(e,t.workspaceId);case"workspace.renamed":return F5(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return W5(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return $5(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return $x(e,t.terminal);case"terminal.split":return V5(e,t.terminal,t.direction);case"terminal.updated":return sO(e,t.terminal);case"terminal.exited":return rO(e,t.terminalId,t.exitCode);case"terminal.closed":return Yx(e,t.terminalId);case"terminal.detached":return aO(e,t.terminalId,t.workspaceId);case"editor.split":return Y5(e,t.editorId,t.title,t.direction);case"editor.closed":return oO(e,t.editorId);case"pane.selected":return iO(e,t.terminalId);case"pane.resized":return nO(e,t.path,t.ratio);case"tab.selected":return G5(e,t.tabId);case"tab.renamed":return tO(e,t.tabId,t.title);case"tab.reordered":return O_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return Z5(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return qx(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return Vx(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return Q5(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return X5(e);default:return e}}function K5(e,t){if(e.workspaces.some(r=>r.id===t.id))return Wx(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Cs(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function Wx(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function F5(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(d=>d.id!==t||d.title===r?d:(o=!0,{...d,title:r}));return o?{...e,workspaces:c}:e}function W5(e,t,n){const r=Cs(n);let o=!1;const c=e.workspaces.map(d=>d.id!==t||d.defaultCwd===r?d:(o=!0,{...d,defaultCwd:r}));return o?{...e,workspaces:c}:e}function $5(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const d=e.workspaces.slice(),[m]=d.splice(o,1);if(!m)return e;const g=d.findIndex(b=>b.id===n);if(g<0)return e;const p=r==="before"?g:g+1,y=d.slice();return y.splice(p,0,m),eO(e.workspaces,y)?e:{...e,workspaces:y}}function q5(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),r=new Set(n?qh(n):[]),o={...e.terminals};for(const m of r)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),d=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:d,terminals:o}}function $x(e,t){const n=Gx(e),r=So(n)??gf(),o=tk(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Cs(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>d!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:ek(c,t.id))}}function V5(e,t,n){const r=So(e),o=r?mf(r):void 0;if(!r||!o)return $x(e,t);const c=o.activeTerminalId,d=hu(o.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(m=>m.id===r.id?{...m,defaultCwd:m.defaultCwd??Cs(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:d,activeTerminalId:t.id}:g)}:ek(m,t.id))}}function Y5(e,t,n,r){const o=So(e),c=o?mf(o):void 0;if(!o||!c)return e;const d=c.activeTerminalId,m=hu(c.root,d,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:m,activeTerminalId:d}:p)}:g)}}function X5(e){const t=So(e),n=t?mf(t):void 0;return n?Yx(e,n.activeTerminalId):e}function G5(e,t){const n=So(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function O_(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const d=o.tabs.slice(),[m]=d.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(d.length,n)),p=d.slice();return p.splice(g,0,m),J5(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function Z5(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(x=>x.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=_l(y.root,n);if(!b){const x=g.tabs.filter((D,O)=>O!==p);return{...g,tabs:x}}const w={...y,root:b,activeTerminalId:Ui(b)[0]??y.activeTerminalId},C=g.tabs.slice();return C[p]=w,{...g,tabs:C}});const d=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(D=>Ui(D.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:n},w={type:"split",direction:d,ratio:.5,first:m?b:{type:"pane",terminalId:r},second:m?{type:"pane",terminalId:r}:b},C=hu(y.root,r,w),x=g.tabs.slice();return x[p]={...y,root:C,activeTerminalId:n},{...g,tabs:x,activeTabId:y.id}}),Gx({...e,workspaces:c})}function qx(e,t,n,r){let o=-1,c=-1;for(let O=0;O<e.workspaces.length;O+=1){const N=e.workspaces[O].tabs.findIndex(B=>B.id===t);if(N>=0){o=O,c=N;break}}if(o<0)return e;const d=e.workspaces[o],m=d.tabs[c],g=Ui(m.root);if(!g.includes(n))return e;if(g.length===1)return O_(e,t,r);const p=_l(m.root,n);if(!p)return e;const y={...m,root:p,activeTerminalId:Ui(p)[0]??m.activeTerminalId},b=e.terminals[n],w={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},C=d.tabs.slice();C[c]=y;const x=Math.max(0,Math.min(C.length,r));C.splice(x,0,w);const D=e.workspaces.slice();return D[o]={...d,tabs:C,activeTabId:w.id},{...e,workspaces:D}}function Vx(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=Zx(e.workspaces,t),c=e.workspaces.find(p=>p.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:O_(e,t,r);const d=Ui(o.tab.root),m=d.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return wo({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===n){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??Cs(m?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!d.includes(w)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function Q5(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(C=>C.id===r),d=Zx(e.workspaces,t);if(!c||!d||!e.terminals[n]||!Ui(d.tab.root).includes(n))return e;if(d.workspace.id===r)return qx(e,t,n,o);if(Ui(d.tab.root).length===1)return Vx(e,t,r,o);const g=_l(d.tab.root,n);if(!g)return e;const p={...d.tab,root:g,activeTerminalId:Ui(g)[0]??d.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},w=e.workspaces.map(C=>{if(C.id===d.workspace.id)return wo({...C,tabs:C.tabs.map(x=>x.id===t?p:x)});if(C.id===r){const x=C.tabs.slice(),D=Math.max(0,Math.min(x.length,o));return x.splice(D,0,b),{...C,defaultCwd:C.defaultCwd??Cs(y.cwd),detachedTerminalIds:C.detachedTerminalIds.filter(O=>O!==n),tabs:x,activeTabId:b.id}}return C});return{...e,workspaces:w,activeWorkspaceId:r}}function J5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function eO(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function tO(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(d=>{let m=!1;const g=d.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,m=!0,{...p,title:r}));return m?{...d,tabs:g}:d});return o?{...e,workspaces:c}:e}function iO(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>bl(c.root,t))),r=n?.tabs.find(o=>bl(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function nO(e,t,n){const r=So(e),o=r?mf(r):void 0;if(!r||!o)return e;const c=Lv(o.root,t,sk(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===r.id?{...d,tabs:d.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:d)}}function Tv(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),d=new Set,m=!!(n&&n.some(b=>ik(b))||t&&t.some(b=>nk(b)));let g=lO(t,n,c,d);g.length===0&&(g=[gf()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??pf;for(const b of e)if(!d.has(b.id)){if(m)g=dO(g,y,b.id,b);else{const w=tk(b);g=fO(g,y,w,b)}d.add(b.id)}return{workspaces:g.map(b=>wo(hO(b,o))),activeWorkspaceId:p,terminals:o}}function du(e){return Ui(e.root)}function Dv(e){return Ov(e.root)}function qh(e){return B_([...e.tabs.flatMap(t=>Ui(t.root)),...e.detachedTerminalIds])}function Qm(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=Nv(o.root);return c?[{...o,root:c}]:[]});return wo({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function sO(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>bl(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function rO(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function Yx(e,t){const n={...e.terminals};return delete n[t],Xx(e,t,n)}function aO(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??cO(e,t)?.id??uO(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??pf,o=e.workspaces.find(c=>c.id===r);return!o||!Jx(o,t)?e:Xx(e,t,{...e.terminals},{detachToWorkspaceId:r})}function Xx(e,t,n,r={}){let o=e.workspaces.map(d=>{const m=[];for(const g of d.tabs){const p=_l(g.root,t);if(!p)continue;const y=Ui(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:p,activeTerminalId:b})}return wo({...d,detachedTerminalIds:d.detachedTerminalIds.filter(g=>g!==t),tabs:m})});r.detachToWorkspaceId&&n[t]&&(o=o.map(d=>d.id===r.detachToWorkspaceId?Qx(d,t,n[t]):d));const c=o.some(d=>d.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function oO(e,t){const n=e.workspaces.map(o=>{const c=[];for(const d of o.tabs){const m=Rv(d.root,t);if(!m)continue;const g=Ui(m),p=g.includes(d.activeTerminalId)?d.activeTerminalId:g[0];p&&c.push({...d,root:m,activeTerminalId:p})}return wo({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function lO(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)ik(c)&&o.push(Zw(c,n,r));if(o.length>0)return o}return[Zw({...gf(),tabs:e??[]},n,r)]}function Zw(e,t,n){const r=[];for(const c of e.tabs){if(!nk(c))continue;const d=Mv(c.root,t);if(!d)continue;const m=Ui(d);for(const p of m)n.add(p);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&r.push({...c,root:d,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return wo({...e,defaultCwd:Cs(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function Gx(e){return So(e)?e:{...e,workspaces:[gf()],activeWorkspaceId:pf}}function So(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function mf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function Zx(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function cO(e,t){return e.workspaces.find(n=>n.tabs.some(r=>bl(r.root,t)))}function uO(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function dO(e,t,n,r){return e.map(o=>o.id===t?Qx(o,n,r):o)}function Qx(e,t,n){return Jx(e,t)?{...e,defaultCwd:e.defaultCwd??Cs(n?.cwd),detachedTerminalIds:B_([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function Jx(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<wl}function ek(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function hO(e,t){if(e.defaultCwd)return e;const n=qh(e).find(o=>!!t[o]),r=n?Cs(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function gf(){return{id:pf,title:P5,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function wo(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Cs(e.defaultCwd),detachedTerminalIds:B_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function fO(e,t,n,r){const o=Ui(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Cs(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(d=>!o.includes(d)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function tk(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function hu(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:hu(e.first,t,n),second:hu(e.second,t,n)}}function _l(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=_l(e.first,t),r=_l(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function Rv(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=Rv(e.first,t),r=Rv(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function Mv(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Mv(e.first,t),r=Mv(e.second,t);return n&&r?{...e,ratio:sk(e.ratio),first:n,second:r}:n??r}function Nv(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Nv(e.first),n=Nv(e.second);return t&&n?{...e,first:t,second:n}:t??n}function ik(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 nk(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Av(t.root)}function Av(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")&&Av(t.first)&&Av(t.second):!1}function Lv(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const c=Lv(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=Lv(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function sk(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Cs(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function B_(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function bl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:bl(e.first,t)||bl(e.second,t)}function Ui(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ui(e.first),...Ui(e.second)]}function Ov(e){return e.type==="pane"||e.type==="editor"?1:Ov(e.first)+Ov(e.second)}const Aa=new Map,fu=new Map,pu=new Map,mu=new Map,gu=new Map;function Tl(e){return e??"__local__"}function pO(e){return{agentId:e,state:H5(),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 Ut(e){const t=Tl(e);let n=Aa.get(t);return n||(n=pO(e),Aa.set(t,n)),n}function rk(e,t){const n=Tl(e);let r=fu.get(n);return r||(r=new Set,fu.set(n,r)),r.add(t),()=>{r.delete(t)}}function mO(e){const t=Tl(e),n=fu.get(t);if(n)for(const r of Array.from(n))r()}function Dl(e,t){Aa.set(Tl(e),t),mO(e)}const Bv=new Set;function gO(e){return Bv.add(e),()=>{Bv.delete(e)}}function nl(e,t){const n=Ut(e),r=Tl(e);t.type==="workspace.hydrated"&&(pu.delete(r),mu.delete(r),gu.delete(r));const o=U5(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const p=n.state.terminals[t.terminal.id],y=xO(r),b=kO(r),w=_O(r);if(t.terminal.agentStatus){const C=t.terminal.agentStatus.state,x=t.terminal.agentStatus.sessionId,D=w.get(t.terminal.id),O=!!(p&&(p.currentCommand!==t.terminal.currentCommand||p.agentStatus?.provider!==t.terminal.agentStatus.provider||vO(D,x)));O&&(b.delete(t.terminal.id),y.delete(t.terminal.id),w.delete(t.terminal.id)),x&&w.set(t.terminal.id,x),t.notifyCompletion===!0&&(C==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):C==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!O&&(C==="done"||C==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(d=e1(o,t.terminal.id,p?.currentCommand??null,C==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),C==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{p?.agentStatus&&(b.delete(t.terminal.id),w.delete(t.terminal.id));const C=p?.activity==="busy",x=t.terminal.activity==="busy",D=t.terminal.activity==="idle";t.notifyCompletion===!0&&x&&y.add(t.terminal.id),t.notifyCompletion===!0&&C&&D&&y.has(t.terminal.id)&&(d=e1(o,t.terminal.id,p?.currentCommand??null,"finished")),(D||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(d){const C=ak(o,t.terminal.id);C&&(C.workspace.activeTabId!==C.tab.id||C.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id),w.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=bO(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(w=>w.id===t.workspaceId);p=b?.tabs.find(w=>w.id===b.activeTabId)??null}const y=p?Ui(p.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const w of y)b.delete(w);c=b}}const m=o!==n.state,g=c!==n.unreadCompletions;if((m||g)&&Dl(e,{...n,state:o,unreadCompletions:c}),g&&j_(),d)for(const p of Array.from(Bv))p({agentId:e,...d})}function vO(e,t){return e!==void 0&&t!==void 0&&e!==t}function _O(e){let t=gu.get(e);return t||(t=new Map,gu.set(e,t)),t}function ak(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Ui(r.root).includes(t))return{workspace:n,tab:r};return null}function bO(e,t){for(const n of e.workspaces){const r=n.tabs.find(o=>o.id===t);if(r)return{workspace:n,tab:r}}return null}const jv=new Set;function yO(e){return jv.add(e),()=>{jv.delete(e)}}function SO(){let e=0;for(const t of Aa.values())e+=t.unreadCompletions.size;return e}function j_(){for(const e of Array.from(jv))e()}function Qw(e,t){const n=Ut(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Dl(e,{...n,unreadCompletions:r}),j_()}function Jw(e,t){const n=Ut(e);t!==n.state&&Dl(e,{...n,state:t})}function Jm(e,t){const n=Ut(e),r=t(n.editors);r!==n.editors&&Dl(e,{...n,editors:r})}function ba(e,t,n){const r=Ut(e);r.loaded===t&&r.error===n||Dl(e,{...r,loaded:t,error:n})}function Lc(e,t,n){const r=Ut(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Dl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n})}function wO(e){const t=Ut(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function CO(e){const t=Tl(e),n=Aa.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1;Aa.delete(t),fu.delete(t),pu.delete(t),mu.delete(t),gu.delete(t),r&&j_()}function eg(){for(const e of Aa.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Aa.clear(),fu.clear(),pu.clear(),mu.clear(),gu.clear()}function xO(e){let t=pu.get(e);return t||(t=new Set,pu.set(e,t)),t}function kO(e){let t=mu.get(e);return t||(t=new Set,mu.set(e,t)),t}function e1(e,t,n,r){const o=ak(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function zv(e,t){let n=!1,r=!1,o=null,c=!1;for(const d of du(e)){const m=t[d];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(r=!0,n=!0,!o&&m.currentCommand&&(o=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function z_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function Iv(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function EO(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function TO({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:d,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:w,onRenameTab:C,activePaneAvailable:x}){const[D,O]=v.useState(null),[N,B]=v.useState(!1),[V,W]=v.useState(null),ie=v.useRef(null),Q=e.findIndex(F=>F.id===t),$=Q>=0?e[Q]:e[0]??null,Se=$?zv($,n):null,ne=$?Dv($):0,Te=$?Iv($,n):"No tab";v.useEffect(()=>{ie.current?.focus(),ie.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!N)return;const F=le=>{le.key==="Escape"&&B(!1)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[N]),v.useEffect(()=>{N&&e.length===0&&B(!1)},[N,e.length]);function te(F,le){O({tabId:F,title:le})}function Y(){if(!D)return;const F=D.title.trim();F&&C(D.tabId,F),O(null)}function G(){return f.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${ID()}`,onClick:b,disabled:!x,children:f.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${PD()}`,onClick:w,disabled:!x,children:f.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return f.jsxs(f.Fragment,{children:[f.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[f.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:f.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})}),f.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Te,onClick:()=>B(!0),disabled:e.length===0,children:[Se?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":Se.state,"aria-hidden":"true",title:z_(Se)}):null,f.jsx("span",{children:Te}),f.jsxs("small",{children:[Q>=0?Q+1:0,"/",e.length||0,ne>1?` / ${ne}`:""]})]}),f.jsxs("div",{className:"terminal-tab-list",children:[e.map((F,le)=>{const L=du(F),R=Dv(F),j=Iv(F,n),ae=F.id===t,be=D?.tabId===F.id,M=zv(F,n),K=r?.has(F.id)??!1;return f.jsxs(Ai.Fragment,{children:[f.jsx(t1,{index:le}),f.jsx(DO,{tab:F,active:ae,editing:be,title:j,paneCount:R,terminalIds:L,canClose:e.length>1,editValue:be?D.title:null,editInputRef:be?ie:null,activity:M,unread:K,onSelect:()=>c(F.id),onBeginRename:()=>te(F.id,j),onCloseAll:()=>g(L),onCommitRename:Y,onCancelRename:()=>O(null),onRenameChange:ce=>O({tabId:F.id,title:ce})})]},F.id)}),f.jsx(t1,{index:e.length}),f.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:d,children:"+"}),(o?.length??0)>0?f.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(F=>f.jsx(MO,{terminal:F,onReattach:()=>p?.(F.id),onDelete:()=>W(F)},F.id))}):null]}),f.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:d,children:"+"}),x?G():null]}),N?f.jsx(RO,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:D,editInputRef:ie,onClose:()=>B(!1),onSelectTab:F=>{c(F),B(!1)},onCreateTab:()=>{d(),B(!1)},onBeginRename:te,onCloseTerminals:F=>{g(F),B(!1)},onCommitRename:Y,onCancelRename:()=>O(null),onRenameChange:(F,le)=>O({tabId:F,title:le}),onReattachTerminal:F=>{p?.(F),B(!1)},onDeleteTerminal:F=>{W(F),B(!1)}}):null,V?f.jsx(NO,{terminal:V,onCancel:()=>W(null),onConfirm:()=>{y?.(V.id),W(null)}}):null]})}function DO({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:d,editInputRef:m,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:w,onCommitRename:C,onCancelRename:x,onRenameChange:D}){const{attributes:O,listeners:N,setNodeRef:B,transform:V,isDragging:W}=B1({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),ie={transform:ag.Translate.toString(V),opacity:W?.4:void 0,zIndex:W?2:void 0};return f.jsxs("div",{ref:B,className:"terminal-tab","data-active":t,"data-dragging":W,"data-unread":p?"true":void 0,style:ie,...O,...N,children:[g?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:z_(g)}):null,n&&m&&d!==null?f.jsxs("form",{className:"terminal-tab-editor",onSubmit:Q=>{Q.preventDefault(),C()},children:[f.jsx("input",{ref:m,"aria-label":`Rename ${r}`,value:d,onBlur:C,onChange:Q=>D(Q.target.value),onKeyDown:Q=>{if(Q.key==="Enter"){Q.preventDefault(),C();return}Q.key==="Escape"&&(Q.preventDefault(),x())}}),f.jsx("small",{children:o})]}):f.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:Q=>{Q.preventDefault(),b()},children:[f.jsx("span",{children:r}),f.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?f.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),w()},children:"x"}):null]})}function RO({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:d,onClose:m,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:w,onCancelRename:C,onRenameChange:x,onReattachTerminal:D,onDeleteTerminal:O}){const N=v.useRef(null);return v.useEffect(()=>{N.current?.scrollIntoView?.({block:"nearest"})},[t]),f.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:f.jsxs("section",{className:"mobile-tab-sheet",onClick:B=>B.stopPropagation(),children:[f.jsxs("header",{children:[f.jsxs("div",{children:[f.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),f.jsxs("small",{children:[e.length," open"]})]}),f.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[f.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),f.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((B,V)=>{const W=du(B),ie=Dv(B),Q=Iv(B,n),$=B.id===t,Se=c?.tabId===B.id,ne=zv(B,n),Te=r?.has(B.id)??!1;return f.jsxs("div",{ref:$?N:null,className:"mobile-tab-sheet-row","data-active":$,"data-unread":Te?"true":void 0,children:[Se&&c?f.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:te=>{te.preventDefault(),w()},children:f.jsx("input",{ref:d,"aria-label":`Rename ${Q}`,value:c.title,onBlur:w,onChange:te=>x(B.id,te.target.value),onKeyDown:te=>{if(te.key==="Enter"){te.preventDefault(),w();return}te.key==="Escape"&&(te.preventDefault(),C())}})}):f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${Q}`,onClick:()=>g(B.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:V+1}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:Q}),f.jsx("small",{children:EO(B,n,ie,ne)})]}),f.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ne?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":ne.state,"aria-hidden":"true",title:z_(ne)}):null,f.jsx("span",{children:ie})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-actions",children:[Se?f.jsx("button",{type:"button","aria-label":`Done renaming ${Q}`,onClick:w,children:"Done"}):f.jsx("button",{type:"button","aria-label":`Rename ${Q}`,onClick:()=>y(B.id,Q),children:"Rename"}),e.length>1?f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${Q}`,onClick:()=>b(W),children:"×"}):null]})]},B.id)}),(o?.length??0)>0?f.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[f.jsx("span",{children:"Detached"}),(o??[]).map(B=>{const V=B.title||B.cwd||B.id.slice(0,8);return f.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${V}`,onClick:()=>D(B.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:V}),f.jsx("small",{children:B.cwd})]}),f.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),f.jsx("div",{className:"mobile-tab-sheet-actions",children:f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${V}`,onClick:()=>O(B),children:"×"})})]},B.id)})]}):null]})]})})}function t1({index:e}){const{setNodeRef:t,isOver:n}=e_({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return f.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function MO({terminal:e,onReattach:t,onDelete:n}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
56
|
+
${e.cwd}
|
|
57
|
+
(detached — click to re-open, × to delete)`;return f.jsxs("span",{className:"terminal-detached-pill",title:o,children:[f.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),f.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function NO({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:"Delete this terminal?"}),f.jsx("span",{children:r}),f.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function AO({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const d=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return f.jsxs("aside",{className:`upload-toast upload-toast-${zO(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[f.jsxs("header",{className:"upload-toast-header",children:[f.jsx("strong",{children:e.length===1?xh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),f.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),f.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>f.jsx(LO,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function LO({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return f.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":xh(e),children:[f.jsxs("div",{className:"upload-queue-item-header",children:[f.jsx("strong",{children:xh(e)}),f.jsxs("div",{className:"upload-queue-actions",children:[m?f.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?f.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,f.jsx("button",{type:"button","aria-label":`Dismiss ${xh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?f.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?f.jsx(OO,{toast:e}):null,c&&"message"in e&&e.message?f.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?f.jsx(BO,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?f.jsx("p",{children:e.message}):null]})}function OO({toast:e}){const t=e.percent===null?IO(e.loaded):`${e.percent}%`;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"upload-progress-row",children:[f.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),f.jsx("span",{children:t})]}),f.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:f.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function BO({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),r=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?f.jsx("ul",{className:"upload-result-list",children:c.map((d,m)=>f.jsx(jO,{result:d},`${d.relativePath}-${m}`))}):null,e.results.length>c.length?f.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function jO({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return f.jsxs("li",{"data-status":e.status,children:[f.jsx("span",{className:"upload-result-path",children:t}),n?f.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?f.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function xh(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function zO(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 IO(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function PO({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function d(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return f.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:m,children:[f.jsxs("header",{className:"completion-toast-header",children:[f.jsxs("div",{className:"completion-toast-copy",children:[f.jsx("strong",{children:r.tabTitle}),f.jsx("span",{children:c})]}),f.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:d,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),f.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const HO=Wc(0,0,1,1),xr=1e-6;function UO(e){return ok(e).map(t=>t.terminalId)}function ok(e){return Fc(e,HO).sort($O).map((t,n)=>({...t,index:n+1}))}function KO(e,t,n){const r=ok(e),o=r.find(d=>d.terminalId===t);return o?r.filter(d=>d.terminalId!==t).map(d=>WO(o,d,n)).filter(d=>d!==null).sort(qO)[0]?.entry.terminalId??null:null}function FO(e,t){return!Number.isInteger(t)||t<1?null:UO(e)[t-1]??null}function Fc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=VO(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Fc(e.first,Wc(t.left,t.top,o,t.bottom)),...Fc(e.second,Wc(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...Fc(e.first,Wc(t.left,t.top,t.right,r)),...Fc(e.second,Wc(t.left,r,t.right,t.bottom))]}function WO(e,t,n){const r=e.bounds,o=t.bounds,c=i1(r.left,r.right,o.left,o.right),d=i1(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-xr||d<=xr?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"right":return o.centerX<=r.centerX+xr||d<=xr?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:d};case"up":return o.centerY>=r.centerY-xr||c<=xr?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+xr||c<=xr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function $O(e,t){return ul(e.bounds.top,t.bounds.top)||ul(e.bounds.left,t.bounds.left)}function qO(e,t){return ul(e.primaryDistance,t.primaryDistance)||ul(e.perpendicularDistance,t.perpendicularDistance)||ul(t.overlap,e.overlap)||ul(e.entry.index,t.entry.index)}function ul(e,t){const n=e-t;return Math.abs(n)<=xr?0:n}function i1(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function Wc(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function VO(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class YO extends Error{constructor(t){super(t),this.name="UploadDropError"}}function n1(e){return e?Array.from(e.types??[]).includes("Files")||dk(e.items).some(n=>n.kind==="file")?!0:hk(e.files).length>0:!1}async function XO(e){const t=dk(e.items).filter(n=>n.kind==="file");return t.length>0?GO(t):ZO(e.files)}async function GO(e){const t=[];for(const n of e){const r=tB(n);if(r){await lk(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:ck(o),file:o});continue}throw new YO("Folder upload is not supported by this browser.")}return t}function ZO(e){return hk(e).map(t=>({relativePath:ck(t),file:t}))}async function lk(e,t,n){const r=nB(t,e.name);if(e.isFile){const d=await QO(e);n.push({relativePath:r,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),c=await JO(o);for(const d of c)await lk(d,r,n)}function QO(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function JO(e){const t=[];for(;;){const n=await eB(e);if(n.length===0)return t;t.push(...n)}}function eB(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function ck(e){const t=e.webkitRelativePath;return uk(typeof t=="string"&&t?t:e.name)}function tB(e){const t=e.webkitGetAsEntry?.();return iB(t)?t:null}function iB(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 nB(e,t){return uk(e?`${e}/${t}`:t)}function uk(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function dk(e){return e?Array.from(e):[]}function hk(e){return e?Array.from(e):[]}const s1="nterminal.terminalWorkspaces.v2",fk="nterminal.sidebarCollapsed.v1",sB=75,r1=I1.map(e=>e.url),rB=I1[0].url,aB=6;function oB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:d=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??Xh(),[e]),p=v.useMemo(()=>t??fl(null),[t]),y=v.useMemo(()=>DB(n),[n]),b=v.useMemo(()=>k=>rk(n,k),[n]),w=v.useMemo(()=>()=>Ut(n),[n]),C=v.useSyncExternalStore(b,w,w),x=C.state,D=C.editors,O=!C.loaded,N=C.error,[B,V]=v.useState(!1),[W,ie]=v.useState(()=>BB()),[Q,$]=v.useState("servers"),[Se,ne]=v.useState(!1),Te=v.useSyncExternalStore(XD,C0,C0);v.useSyncExternalStore(Gc,w0,w0);const[te,Y]=v.useState(0),[G,F]=v.useState(null),[le,L]=v.useState(()=>[null]),[R,j]=v.useState(()=>({[Xi]:"Local"})),[ae,be]=v.useState(0),[M,K]=v.useState(()=>[n]),[ce,we]=v.useState(()=>new Set),[Le,xe]=v.useState({}),[Be,De]=v.useState(null),He=v.useRef(0),ze=v.useRef(0),[re,he]=v.useState(null),[H,ue]=v.useState(null),Re=v.useRef(null),Ne=v.useRef(0),ee=v.useRef(null),Ee=v.useRef(null),me=v.useRef(null),Oe=v.useRef(null),Ie=v.useRef(()=>{}),[st,ot]=v.useState(null),Nt=dT(e0(M1,{activationConstraint:{distance:8}}),e0(N1,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>GD(g),[g]);function pi(k){const T=k.active.data.current;if(T){if(T.kind==="tab"&&typeof T.tabId=="string"&&typeof T.terminalId=="string"){ot({tabId:T.tabId,terminalId:T.terminalId});return}T.kind==="pane"&&typeof T.sourceTabId=="string"&&typeof T.terminalId=="string"&&ot({tabId:T.sourceTabId,terminalId:T.terminalId})}}function Cn(k){ot(null);const T=k.active.data.current,I=k.over?.data.current;if(!(!T||!I||typeof T.terminalId!="string")){if(T.kind==="tab"&&typeof T.tabId=="string"){if(I.kind==="tab-position"&&typeof I.index=="number"){ct({type:"tab.reordered",sourceTabId:T.tabId,targetIndex:I.index});return}if(I.kind==="workspace"&&typeof I.workspaceId=="string"){ct({type:"tab.moved_to_workspace",sourceTabId:T.tabId,targetWorkspaceId:I.workspaceId});return}I.kind==="pane-zone"&&typeof I.terminalId=="string"&&(I.side==="top"||I.side==="right"||I.side==="bottom"||I.side==="left")&&ct({type:"tab.dropped_into_pane",sourceTabId:T.tabId,sourceTerminalId:T.terminalId,targetTerminalId:I.terminalId,side:I.side});return}if(T.kind==="pane"&&typeof T.sourceTabId=="string"){if(I.kind==="tab-position"&&typeof I.index=="number"){ct({type:"terminal.extracted_to_tab",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetIndex:I.index});return}if(I.kind==="workspace"&&typeof I.workspaceId=="string"){ct({type:"terminal.extracted_to_workspace",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetWorkspaceId:I.workspaceId});return}I.kind==="pane-zone"&&typeof I.terminalId=="string"&&(I.side==="top"||I.side==="right"||I.side==="bottom"||I.side==="left")&&ct({type:"tab.dropped_into_pane",sourceTabId:T.sourceTabId,sourceTerminalId:T.terminalId,targetTerminalId:I.terminalId,side:I.side})}}}function Rt(){ot(null)}const Qe=x.workspaces.find(k=>k.id===x.activeWorkspaceId)??x.workspaces[0],gt=Qe?.tabs.find(k=>k.id===Qe.activeTabId)??Qe?.tabs[0],Bt=gt?.activeTerminalId??null,ye=Bt?x.terminals[Bt]:void 0,We=wB("(max-width: 760px)"),Je=v.useMemo(()=>gt?Vh(gt.root):[],[gt]),et=Qe&>?$c(n,Qe.id,gt.id):null,wt=gt?pk(Je,gt.activeTerminalId,et?Le[et]:void 0):null,ft=We&&Je.length>1,xn=v.useMemo(()=>(Qe?.detachedTerminalIds??[]).flatMap(k=>{const T=x.terminals[k];return T?[T]:[]}),[Qe?.detachedTerminalIds,x.terminals]),Oi=v.useMemo(()=>{const k=new Set;for(const T of Qe?.tabs??[])du(T).some(I=>C.unreadCompletions.has(I))&&k.add(T.id);return k},[Qe?.tabs,C.unreadCompletions]),[q,Ke]=v.useState([]),Ge=v.useRef([]),at=v.useRef(null),[xt,jt]=v.useState(null),[qt,Vt]=v.useState(null),[$t,Ci]=v.useState([]),[Yt,ii]=v.useState(()=>po()),mi=v.useRef(0),xi=v.useRef(n),Fi=v.useRef(r1),gn=v.useRef(Yt),gi=v.useRef(()=>{});gi.current=Rs,Ie.current=gs;const vi=v.useCallback(async()=>{try{const k=await g.listNotificationAssets();Ci(k.assets.filter(T=>T.enabled).map(T=>T.url))}catch{Ci([])}},[g]),en=v.useCallback(k=>{j(T=>{const I={...T};for(const se of k)I[Hv(se.agentId)]=se.label;return tg(T,I)?T:I})},[]);v.useEffect(()=>{K(k=>k.some(T=>pn(T,n))?k:[...k,n])},[n]);const Bi=v.useCallback(k=>{const T=Ut(k),I=fl(k);for(const se of Object.keys(T.state.terminals))Uc(I.createWebSocketUrl(se)),rh(se);CO(k),K(se=>se.filter(ve=>!pn(ve,k))),we(se=>{const ve=`${Eh(k)}:`;let fe=!1;const ke=new Set;for(const Ve of se){if(Ve.startsWith(ve)){fe=!0;continue}ke.add(Ve)}return fe?ke:se}),xe(se=>{const ve=`${Eh(k)}:`;let fe=!1;const ke={};for(const[Ve,vt]of Object.entries(se)){if(Ve.startsWith(ve)){fe=!0;continue}ke[Ve]=vt}return fe?ke:se})},[]);v.useEffect(()=>{let k=!1;return g.getMainInfo().then(T=>{if(k)return;const I=T.name?.trim()||"Local";j(se=>{const ve={...se,[Xi]:I};return tg(se,ve)?se:ve})}).catch(()=>{}),g.listAgents().then(T=>{if(!k){const I=T.agents.map(ve=>ve.id),se=hD(T.serverOrder,T.agents);j(ve=>{const fe={[Xi]:ve[Xi]??"Local"};for(const ke of T.agents)fe[ke.id]=ke.name;return tg(ve,fe)?ve:fe}),n!==null&&!I.includes(n)&&(Bi(n),r?.(null)),L(se)}}).catch(()=>{}),()=>{k=!0}},[n,g,Bi,r,ae]);const Qt=v.useCallback(k=>{Bi(k),be(T=>T+1),pn(k,xi.current)&&r?.(null)},[Bi,r]);v.useEffect(()=>{L(k=>k.some(T=>pn(T,n))?k:[...k,n])},[n]),v.useEffect(()=>{xi.current=n},[n]),v.useEffect(()=>{F(null)},[n]),v.useEffect(()=>{const k=ee.current;if(!k)return;if(!pn(k.agentId,n)){ee.current=null;return}if(!C.loaded||x.workspaces.length===0)return;ee.current=null;const T=k.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];T&&T.id!==x.activeWorkspaceId&&ct({type:"workspace.selected",workspaceId:T.id})},[n,C.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const k=Ee.current;if(k){if(!pn(k.agentId,n)){Ee.current=null;return}C.loaded&&(Ee.current=null,x.workspaces.some(T=>T.id===k.workspaceId)&&ct({type:"workspace.selected",workspaceId:k.workspaceId}))}},[n,C.loaded,x.workspaces]),v.useEffect(()=>{const k=me.current;if(k){if(!pn(k.agentId,n)){me.current=null;return}C.loaded&&(me.current=null,C.error||qs())}},[n,C.error,C.loaded]),v.useEffect(()=>{dn()},[n,C.loaded,x]),v.useEffect(()=>{const k=()=>{const se=xB();se&&Ie.current(se)},T=se=>{const ve=kB(se.data);ve&&Ie.current(ve)},I=se=>{const ve=tf(se.detail);ve&&Ie.current(ve)};return k(),window.addEventListener("hashchange",k),window.addEventListener(hg,I),navigator.serviceWorker?.addEventListener?.("message",T),()=>{window.removeEventListener("hashchange",k),window.removeEventListener(hg,I),navigator.serviceWorker?.removeEventListener?.("message",T)}},[]),v.useEffect(()=>{vi()},[vi]),v.useEffect(()=>q1(()=>ii(po())),[]),v.useEffect(()=>{const k=T=>{gi.current(T)};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{Fi.current=$t.length>0?$t:r1},[$t]),v.useEffect(()=>{gn.current=Yt},[Yt]),v.useEffect(()=>{if(!C.loaded||!Qe||!gt)return;const k=$c(n,Qe.id,gt.id);we(T=>{if(T.has(k))return T;const I=new Set(T);return I.add(k),I})},[n,C.loaded,Qe?.id,gt?.id]),v.useEffect(()=>()=>{ir()},[]),v.useEffect(()=>{const k=nD(g),T=aD(g);return()=>{k(),T()}},[g]),v.useEffect(()=>gO(k=>{const T=Ut(k.agentId).state,I=T.workspaces.flatMap(ke=>ke.tabs).find(ke=>ke.id===k.tabId),se=T.terminals[k.terminalId],ve=I?.title?.trim()||se?.title||k.commandName||"terminal",fe=document.visibilityState==="visible"&&pn(k.agentId,xi.current)&&k.tabId===TB(T);if(fe||Z2({agentId:k.agentId,tabTitle:ve,commandName:k.commandName,terminalId:k.terminalId,outcome:k.outcome}),!fe&&document.visibilityState==="visible"&&gn.current.enabled){const ke=mi.current+1;mi.current=ke;const Ve=Fi.current;jt({id:ke,agentId:k.agentId,terminalId:k.terminalId,tabId:k.tabId,tabTitle:ve,commandName:k.commandName,outcome:k.outcome,assetSrc:Ve[Math.floor(Math.random()*Ve.length)]??rB})}}),[]),v.useEffect(()=>{if(!xt||Yt.persistUntilDismissed)return;const k=window.setTimeout(()=>{jt(T=>T?.id===xt.id?null:T)},Yt.durationSeconds*1e3);return()=>window.clearTimeout(k)},[xt,Yt]),v.useEffect(()=>{jB(W),W&&Xn()},[W]),v.useEffect(()=>{let k=!1;async function T(){if(!Ut(n).loaded){ba(n,!1,null);try{let se=null,ve=null;try{se=RB(y)}catch(vt){if(!(vt instanceof Yh))throw vt;ve=vt}const[fe,ke]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Ve=fe.terminals.length>0?fe.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!k){const vt=ke.layout?gk(ke.layout):null;if(!vt&&ve)throw ve;const li=vt??se??{},ni=Tv(Ve,void 0,li.savedWorkspaces,li.savedActiveWorkspaceId),Fr=Qm(ni);Jw(n,ni),Lc(n,ke.revision,JSON.stringify(Fr)),ba(n,!0,null),!vt&&se&&nr(Fr,{baseRevision:ke.revision})}}catch(se){!k&&!Wi(se)&&ba(n,!0,ya(se))}}}return T(),()=>{k=!0}},[n,p,te]);function ki(){ba(n,!1,null),Y(k=>k+1)}function Xn(){He.current+=1,ze.current+=1,De(null)}function Oa(k){He.current+=1,ze.current+=1,De(T=>T&&{...T,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function qs(){He.current+=1,ze.current+=1;const k=x.workspaces.length+1,T=Ys();De({mode:"create",workspaceId:null,title:`Workspace ${k}`,cwd:T,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),T&&xs(T)}function Ba(k){if(pn(k,n)){qs();return}me.current={agentId:k},r?.(k)}function Vs(k){if(W&&!B)return;const T=x.workspaces.find(se=>se.id===k);if(!T)return;He.current+=1,ze.current+=1;const I=T.defaultCwd??ye?.cwd??"";De({mode:"edit",workspaceId:k,title:T.title,cwd:I,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),I&&xs(I)}function Ys(){return Qe?.defaultCwd??ye?.cwd??""}async function xs(k){const T=He.current+1;He.current=T;const I=k.trim();if(De(se=>se&&{...se,cwd:k,browseStatus:I?"loading":"idle",browseRoot:null,browseEntries:[],error:I?null:"Choose a default working directory."}),!!I)try{const se=await p.createFileRoot({path:I}),ve=await p.listFiles({rootToken:se.rootToken,path:""});if(He.current!==T)return;De(fe=>fe&&{...fe,cwd:se.rootPath,browseRoot:{rootToken:se.rootToken,rootPath:se.rootPath},browseEntries:ve.entries.filter(ke=>ke.kind==="directory"),browseStatus:"idle",error:null})}catch(se){if(He.current!==T)return;De(ve=>ve&&{...ve,browseStatus:"idle",error:ya(se)})}}async function ks(){const k=Be;if(!k)return;const T=k.title.trim(),I=k.cwd.trim();if(!T||!I){De({...k,submitStatus:"idle",error:T?"Choose a default working directory.":"Workspace name is required."});return}const se=ze.current+1;ze.current=se,De({...k,submitStatus:"submitting",error:null});try{const ve=await p.createFileRoot({path:I});if(ze.current!==se)return;if(k.mode==="create"){const fe=x.workspaces.length+1;ct({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${fe}`,title:T,defaultCwd:ve.rootPath})}else k.workspaceId&&(ct({type:"workspace.renamed",workspaceId:k.workspaceId,title:T}),ct({type:"workspace.defaultCwdChanged",workspaceId:k.workspaceId,defaultCwd:ve.rootPath}));De(null)}catch(ve){if(ze.current!==se)return;De(fe=>fe&&{...fe,submitStatus:"idle",error:ya(ve)})}}function ps(k){ze.current+=1,De(k)}function Es(k,T,I){if(k===T)return;const se=x.workspaces.some(fe=>fe.id===k),ve=x.workspaces.some(fe=>fe.id===T);!se||!ve||ct({type:"workspace.reordered",sourceWorkspaceId:k,targetWorkspaceId:T,placement:I})}function cn(k,T){const I=x.workspaces.findIndex(ve=>ve.id===k),se=x.workspaces[I+T];I<0||!se||Es(k,se.id,T<0?"before":"after")}function ai(k,T){T.pointerType==="mouse"&&T.button!==0||(T.preventDefault(),T.stopPropagation(),Re.current={sourceId:k,pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,active:!1,targetId:null,placement:"after"},T.currentTarget.setPointerCapture?.(T.pointerId))}function Or(k){const T=Re.current;if(!T||T.pointerId!==k.pointerId)return;const I=Math.hypot(k.clientX-T.startX,k.clientY-T.startY);if(!T.active){if(I<aB)return;T.active=!0,he(T.sourceId)}const ve=document.elementFromPoint(k.clientX,k.clientY)?.closest("[data-workspace-id]"),fe=ve?.dataset.workspaceId??null;if(!ve||!fe||fe===T.sourceId||!x.workspaces.some(vt=>vt.id===fe)){T.targetId=null,ue(null);return}const ke=ve.getBoundingClientRect(),Ve=k.clientY<ke.top+ke.height/2?"before":"after";T.targetId=fe,T.placement=Ve,ue({workspaceId:fe,placement:Ve})}function oi(k){const T=Re.current;!T||T.pointerId!==k.pointerId||(k.preventDefault(),k.stopPropagation(),k.currentTarget.releasePointerCapture?.(k.pointerId),Re.current=null,he(null),ue(null),T.active&&T.targetId&&Es(T.sourceId,T.targetId,T.placement))}function zn(k){const T=Re.current;T&&T.pointerId===k.pointerId&&k.currentTarget.releasePointerCapture?.(k.pointerId),Re.current=null,he(null),ue(null)}async function _i(){await Gn(async()=>{const k=Qe?.defaultCwd?{cols:80,rows:24,cwd:Qe.defaultCwd}:{cols:80,rows:24},T=await p.createTerminal(k);ct({type:"terminal.created",terminal:T.terminal})})}async function Xs(k){await Gn(async()=>{const T=Bt?{parentTerminalId:Bt,cols:80,rows:24}:Qe?.defaultCwd?{cols:80,rows:24,cwd:Qe.defaultCwd}:{cols:80,rows:24},I=await p.createTerminal(T);ct({type:"terminal.split",terminal:I.terminal,direction:k})})}async function Co(k){let T=Bt,I=et;const se=Qe?.defaultCwd?.trim();if(!T&&!se)throw new Error("No active pane is available.");const ve=await p.readFile(k);if(!T&&se){const Ve=await p.createTerminal({cols:80,rows:24,cwd:se});T=Ve.terminal.id,ct({type:"terminal.created",terminal:Ve.terminal})}if(T){ct({type:"pane.selected",terminalId:T});const Ve=Ut(n).state,vt=Ve.workspaces.find(ni=>ni.id===Ve.activeWorkspaceId)??Ve.workspaces[0],li=vt?.tabs.find(ni=>ni.id===vt.activeTabId)??vt?.tabs[0];I=vt&&li?$c(n,vt.id,li.id):null}const fe=`editor-${Date.now().toString(36)}-${wO(n)}`,ke=OB(ve.path);Jm(n,Ve=>({...Ve,[fe]:{id:fe,title:ke,rootToken:k.rootToken,path:ve.path,read:ve}})),I&&xe(Ve=>({...Ve,[I]:mk(fe)})),ct({type:"editor.split",editorId:fe,title:ke,direction:"vertical"})}function Ts(k){Jm(n,T=>{const I={...T};return delete I[k],I}),ct({type:"editor.closed",editorId:k})}function ja(k){Gs([k])}function Gs(k){const T=[...new Set(k)].filter(se=>x.terminals[se]);if(T.length===0)return;const I=T.length===1?x.terminals[T[0]]?.title||x.terminals[T[0]]?.cwd||T[0]:`${T.length} panes`;F(null),Vt({terminalIds:T,label:I,workspaceId:Qe?.id??x.activeWorkspaceId??null})}function Ds(k,T){const I=Hr(k,T);if(!I)return!1;const se=k.filter(ve=>!I.detachedTerminalIds.includes(ve));if(I.detachedTerminalIds.length+se.length>wl)return F(NB(I.detachedTerminalIds.length)),!1;F(null);for(const ve of k)ct(I.id?{type:"terminal.detached",terminalId:ve,workspaceId:I.id}:{type:"terminal.detached",terminalId:ve});return!0}async function vn(k){await Gn(async()=>{for(const T of k)await ms(T),Uc(p.createWebSocketUrl(T)),rh(T),ct({type:"terminal.closed",terminalId:T})})}async function Ei(k){const T=x.workspaces.find(I=>I.id===k);!T||x.workspaces.length<=1||window.confirm(`Delete workspace "${T.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Gn(async()=>{const I=qh(T),se=[];let ve=null;for(const ke of I)try{await ms(ke)}catch(Ve){se.push(ya(Ve)),Ve instanceof Bn&&Ve.status===401&&!p.isAgent&&(ve=Ve)}finally{Uc(p.createWebSocketUrl(ke)),rh(ke)}const fe=T.tabs.flatMap(ke=>Pv(ke.root));if(fe.length>0){const ke=new Set(fe);Jm(n,Ve=>{const vt={...Ve};for(const li of ke)delete vt[li];return vt})}if(ct({type:"workspace.closed",workspaceId:k}),ve)throw ve;if(se.length>0)throw new Error(`Workspace was removed, but ${se.length} terminal session${se.length===1?"":"s"} may still be running. ${se[0]}`)})}async function Br(k){await Gn(async()=>{await ms(k),Uc(p.createWebSocketUrl(k)),rh(k),ct({type:"terminal.closed",terminalId:k})})}async function Zs(k,T){const I=T.trim();if(!I)return;let se=null;for(const ve of x.workspaces){const fe=ve.tabs.find(ke=>ke.id===k);if(fe){se=fe.activeTerminalId;break}}if(ct({type:"tab.renamed",tabId:k,title:I}),!!se)try{const ve=await p.renameTerminal(se,I);zr({type:"terminal.updated",terminal:ve.terminal})}catch(ve){ba(n,!0,ya(ve))}}function tn(k){const T=x.terminals[k];T&&ct({type:"terminal.created",terminal:T})}async function ms(k){try{await p.closeTerminal(k)}catch(T){if(T instanceof Bn&&T.status===404)return;throw T}}async function jr(){await Gn(async()=>{await d()})}async function Gn(k){ba(n,!0,null);try{await k()}catch(T){if(Wi(T))return;ba(n,!0,ya(T))}}function Wi(k){return k instanceof Bn&&k.status===401&&!p.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function ct(k){nl(n,k);const T=Ut(n),I=T.state;if(!T.loaded||I.workspaces.length===0)return;const se=Qm(I);JSON.stringify(se)!==T.lastPersistedLayoutJson&&tr(se)}function zr(k){nl(n,k)}function kn(k,T,I,se){const ve=$c(k,T,I);xe(fe=>({...fe,[ve]:se}))}function Zn(k){et&&xe(T=>({...T,[et]:k}))}function Ir(k,T){const I=tu(k);T?kn(n,T.workspaceId,T.tabId,I):Zn(I),ct({type:"pane.selected",terminalId:k})}function Qn(k){Zn(k.key),k.type==="terminal"&&ct({type:"pane.selected",terminalId:k.terminalId})}function Rs(k){if(Se||qt||k.isComposing||k.key==="Process"||fB(k.target))return;const T=cB(k);if(!T)return;if(k.preventDefault(),k.stopPropagation(),T.type==="server.previous"||T.type==="server.next"){Qs(T.type==="server.next"?1:-1);return}const I=Ut(n).state,se=I.workspaces.find(ke=>ke.id===I.activeWorkspaceId)??I.workspaces[0],ve=se?.tabs.find(ke=>ke.id===se.activeTabId)??se?.tabs[0];if(T.type==="split"){if(!ve)return;Xs(T.direction);return}if(!se||!ve)return;if(T.type==="tab.previous"||T.type==="tab.next"){const ke=hB(se.tabs,ve.id,T.type==="tab.next"?1:-1);ke&&ct({type:"tab.selected",tabId:ke.id});return}if(T.type==="tab.index"){const ke=se.tabs[T.index-1];ke&&ct({type:"tab.selected",tabId:ke.id});return}const fe=uB(ve.root,ve.activeTerminalId,T);fe&&Ir(fe,{workspaceId:se.id,tabId:ve.id})}function Pr(k,T){if(!r||le.length===0)return;const I=le.findIndex(ke=>pn(ke,n)),ve=((I===-1?0:I)+k+le.length)%le.length,fe=le[ve]??null;pn(fe,n)||(T&&(ee.current={agentId:fe,edge:T}),r(fe))}function Qs(k){const T=Ut(n).state,I=T.workspaces;if(I.length===0){Pr(k,k===1?"first":"last");return}const se=I.findIndex(ke=>ke.id===T.activeWorkspaceId),fe=(se===-1?0:se)+k;if(fe>=0&&fe<I.length){ct({type:"workspace.selected",workspaceId:I[fe].id});return}Pr(k,k===1?"first":"last")}function za(k,T){if(pn(k,n)){ct({type:"workspace.selected",workspaceId:T});return}Ee.current={agentId:k,workspaceId:T},r?.(k)}function Hr(k,T){if(T)return x.workspaces.find(I=>I.id===T)??null;for(const I of k){const se=x.workspaces.find(fe=>fe.tabs.some(ke=>du(ke).includes(I)));if(se)return se;const ve=x.workspaces.find(fe=>fe.detachedTerminalIds.includes(I));if(ve)return ve}return x.workspaces.find(I=>I.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Rl(k){n1(k.dataTransfer)&&(k.preventDefault(),k.dataTransfer.dropEffect="copy")}function Ur(k){if(!n1(k.dataTransfer))return;k.preventDefault();const T=AB(Ut(n).state),I=Ne.current+1;if(Ne.current=I,!T){Js({id:I,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Js({id:I,status:"queued",fileCount:0,terminalId:T.id,message:"Preparing upload..."}),Ia(I,T.id,k.dataTransfer)}async function Ia(k,T,I){try{const se=await XO(I);if(se.length===0)throw new Error("No files were found in the drop.");Kt(k,{id:k,status:"queued",fileCount:se.length,message:"Queued"},{terminalId:T,files:se})}catch(se){Kt(k,{id:k,status:"failed",fileCount:0,message:ya(se)},{terminalId:T})}finally{Ms()}}async function Jt(k){const T=Ge.current.find(fe=>fe.id===k);if(!T?.terminalId||!T.files||T.files.length===0)return;const I=T.terminalId,se=T.files,ve=new AbortController;at.current=k,Kt(k,{id:k,status:"uploading",fileCount:se.length,loaded:0,total:null,percent:null},{terminalId:I,files:se,abortController:ve});try{const fe=await cR({terminalId:I,files:se,signal:ve.signal,onProgress:li=>{Kt(k,{id:k,status:"uploading",fileCount:se.length,loaded:li.loaded,total:li.total,percent:li.percent},{terminalId:I,files:se,abortController:ve})}}),ke=fe.failed>0?fe.uploaded>0?"partial":"failed":"success",Ve=fe.failed>0?LB(fe):void 0,vt={id:k,status:ke,fileCount:se.length,response:fe};Ve&&(vt.message=Ve),Kt(k,vt,{terminalId:I,files:se})}catch(fe){Kt(k,{id:k,status:"failed",fileCount:se.length,message:ve.signal.aborted?"Upload canceled.":ya(fe)},{terminalId:I,files:se})}finally{at.current===k&&(at.current=null),Ms()}}function Ms(){if(at.current!==null)return;const k=Ge.current.find(T=>T.status==="queued");k?.terminalId&&k.files&&k.files.length>0&&Jt(k.id)}function Js(k){un(T=>[...T,k])}function Kt(k,T,I={}){un(se=>se.map(ve=>{if(ve.id!==k)return ve;const fe={...T},ke=I.terminalId??ve.terminalId,Ve=I.files??ve.files;return ke!==void 0&&(fe.terminalId=ke),Ve!==void 0&&(fe.files=Ve),I.abortController!==void 0&&(fe.abortController=I.abortController),fe}))}function un(k){const T=k(Ge.current);Ge.current=T,Ke(T)}function er(k){Ge.current.find(I=>I.id===k)?.abortController?.abort(),at.current===k&&(at.current=null),un(I=>I.filter(se=>se.id!==k)),Ms()}function Kr(){for(const k of Ge.current)k.abortController?.abort();at.current=null,un(()=>[])}function Ns(k){const T=Ge.current.find(I=>I.id===k);if(T){if(T.status==="queued"){er(k);return}T.abortController?.abort()}}function nn(k){const T=Ge.current.find(se=>se.id===k);if(!T?.terminalId||!T.files||T.files.length===0)return;const I=En(T);if(I.length===0){Kt(k,{id:k,status:"failed",fileCount:T.fileCount,message:"No failed files are available to retry."},{terminalId:T.terminalId,files:T.files});return}Kt(k,{id:k,status:"queued",fileCount:I.length,message:"Queued"},{terminalId:T.terminalId,files:I}),Ms()}function En(k){const T=k.files??[],I="response"in k?k.response:void 0;if(!I)return T;const se=I.results.filter(ke=>ke.status==="failed").map(ke=>ke.relativePath);if(se.length===0)return[];const ve=new Map;for(const ke of T){const Ve=ve.get(ke.relativePath)??[];Ve.push(ke),ve.set(ke.relativePath,Ve)}const fe=[];for(const ke of se){const vt=ve.get(ke)?.shift();vt&&fe.push(vt)}return fe}function Pa(k){const I=Ut(k.agentId).state.workspaces.find(se=>se.tabs.some(ve=>ve.id===k.tabId));I&&kn(k.agentId,I.id,k.tabId,tu(k.terminalId)),nl(k.agentId,{type:"pane.selected",terminalId:k.terminalId}),Qw(k.agentId,k.terminalId),pn(k.agentId,n)||r?.(k.agentId),jt(null)}function gs(k){if(Oe.current=k,!pn(k.agentId,n)){r?r(k.agentId):Oe.current=null;return}dn()}function dn(){const k=Oe.current;if(!k||!pn(k.agentId,n)||!C.loaded)return;const T=Ut(k.agentId),I=EB(T.state,k.terminalId);Oe.current=null,I&&(kn(k.agentId,I.workspaceId,I.tabId,tu(k.terminalId)),nl(k.agentId,{type:"pane.selected",terminalId:k.terminalId}),Qw(k.agentId,k.terminalId))}function tr(k){const T=Ut(n).mutable.saveCoord;T.pendingLayoutSave=k,Oc(k,y),T.saveTimer!==null&&window.clearTimeout(T.saveTimer),T.saveTimer=window.setTimeout(()=>{T.saveTimer=null;const I=T.pendingLayoutSave;T.pendingLayoutSave=null,I&&nr(I)},sB)}function ir(){const k=Ut(n).mutable.saveCoord;k.saveTimer!==null&&(window.clearTimeout(k.saveTimer),k.saveTimer=null);const T=k.pendingLayoutSave;k.pendingLayoutSave=null,T&&(Oc(T,y),nr(T))}function nr(k,T={}){const I=Ut(n).mutable.saveCoord;I.nextPersistLayout=k,T.baseRevision!==void 0&&(I.queuedBaseRevision=T.baseRevision),!I.nextPersistQueued&&(I.nextPersistQueued=!0,I.persistChain=I.persistChain.then(async()=>{I.nextPersistQueued=!1;const se=I.nextPersistLayout,ve=I.queuedBaseRevision;I.nextPersistLayout=null,I.queuedBaseRevision=void 0,se&&await As(se,ve!==void 0?{baseRevision:ve}:{})}))}async function As(k,T={}){const I=Ut(n),se=T.baseRevision??I.layoutRevision,ve={layout:k,...typeof se=="number"?{baseRevision:se}:{}};try{const fe=await p.saveTerminalLayout(ve),ke=fe.layout??k;Lc(n,fe.revision,JSON.stringify(ke)),Oc(ke,y);return}catch(fe){if(fe instanceof Bn&&fe.status===400&&fe.message===_2){MB(n,y),ba(n,!0,vk());return}if(fe instanceof Bn&&fe.status===409)try{const ke=await p.getTerminalLayout(),Ve=Ut(n).mutable.saveCoord;if(Ve.nextPersistLayout||Ve.pendingLayoutSave){const vt=ke.layout?JSON.stringify(ke.layout):Ut(n).lastPersistedLayoutJson;Lc(n,ke.revision,vt);return}if(ke.layout){const vt=Ut(n).state,li=Tv(Object.values(vt.terminals),void 0,ke.layout.workspaces,ke.layout.activeWorkspaceId),ni=Qm(li);Jw(n,li),Lc(n,ke.revision,JSON.stringify(ni)),Oc(ni,y)}else Lc(n,ke.revision,I.lastPersistedLayoutJson);return}catch{}Oc(k,y)}}const vs=zB(o),In=!W||B,bi=In?Q:"servers";function Tn(k){const T=k.active?C:Ut(k.agentId),I=k.active?x:T.state,se=k.active?C.loaded:T.loaded,ve=k.active?N:T.error;return f.jsxs("div",{className:`workspace-list-panel${k.active?" workspace-list-panel--active-server":""}`,"aria-label":`${k.label} workspaces`,children:[f.jsxs("div",{className:"workspace-list-header",children:[f.jsx("span",{children:"Workspaces"}),f.jsx("button",{type:"button","aria-label":`New workspace on ${k.label}`,title:"New workspace",onClick:()=>Ba(k.agentId),children:"+"})]}),se?ve?f.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(k.agentId),children:ve}):f.jsx("div",{className:"workspace-list-items",children:I.workspaces.map(fe=>{const ke=k.active&&fe.id===Qe?.id,Ve=qh(fe).length,vt=k.active&&I.workspaces.length>1,li=H?.workspaceId===fe.id&&re!==fe.id?H.placement:null;return f.jsxs(_B,{workspaceId:fe.id,active:ke,disabled:!k.active,reorderable:vt,dragging:re===fe.id,dropPlacement:li,children:[vt?f.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":fe.id,title:"Drag to reorder","aria-label":`Reorder ${fe.title}`,"aria-grabbed":re===fe.id,onPointerDown:ni=>ai(fe.id,ni),onPointerMove:Or,onPointerUp:oi,onPointerCancel:zn,onKeyDown:ni=>{(ni.key==="ArrowUp"||ni.key==="ArrowDown")&&(ni.preventDefault(),ni.stopPropagation(),cn(fe.id,ni.key==="ArrowUp"?-1:1))},onClick:ni=>ni.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":ke?"page":void 0,title:fe.defaultCwd??void 0,onClick:()=>za(k.agentId,fe.id),onDoubleClick:()=>{k.active&&Vs(fe.id)},children:[f.jsx("span",{className:"workspace-list-name",children:fe.title}),f.jsxs("small",{children:[fe.defaultCwd??"No folder"," · ",Ve," ",Ve===1?"session":"sessions"]})]}),k.active?f.jsxs("div",{className:"workspace-list-actions",children:[f.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${fe.title}`,title:"Edit workspace",onClick:()=>Vs(fe.id),children:"..."}),f.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${fe.title}`,title:"Delete workspace",disabled:I.workspaces.length<=1,onClick:()=>{Ei(fe.id)},children:"x"})]}):null]},fe.id)})}):f.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(k.agentId),children:"Open server to load workspaces"})]})}return f.jsx(d2,{sensors:Nt,onDragStart:pi,onDragEnd:Cn,onDragCancel:Rt,children:f.jsxs("main",{className:"terminal-shell","data-collapsed":W,"data-sidebar-open":B,onDragOver:Rl,onDrop:Ur,children:[f.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>V(!1)}),f.jsxs("aside",{className:"workspace-sidebar",children:[f.jsxs("header",{className:"workspace-brand",children:[f.jsxs("div",{className:"workspace-brand-lockup",children:[In?f.jsx(m1,{height:20}):f.jsx(p1,{size:24}),c&&In?f.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),f.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":W?"Expand sidebar":"Collapse sidebar",title:W?"Expand sidebar":"Collapse sidebar",onClick:()=>ie(k=>!k),children:W?">":"<"}),f.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>V(!1),children:"x"})]}),f.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${bi==="files"?"files":"servers"}`,children:[In?f.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[f.jsx("button",{type:"button",role:"tab","aria-selected":Q==="servers",onClick:()=>{$("servers")},children:"Workspaces"}),f.jsx("button",{type:"button",role:"tab","aria-selected":Q==="files",onClick:()=>{$("files")},children:"Files"})]}):null,bi==="servers"&&In?f.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:f.jsx(S0,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:en,renderServerChildren:Tn})}):null,In?null:f.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:f.jsx(S0,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:en,compact:!0})}),bi==="files"?f.jsx(pR,{api:p,activeTerminalId:Bt,activeTerminalCwd:ye?.cwd??null,workspaceRootPath:Bt?null:Qe?.defaultCwd??null,onOpenFile:Co},`${n??"local"}:${Qe?.id??"no-workspace"}`):null]}),f.jsxs("div",{className:"workspace-sidebar-footer",children:[In?f.jsx("span",{children:vs}):null,f.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[f.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ne(!0),children:[f.jsx(o1,{name:"settings"}),Te.hasUpdates?f.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),In?f.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{jr()},children:f.jsx(o1,{name:"logout"})}):null]})]})]}),Se?f.jsx(aR,{api:g,onClose:()=>ne(!1),updateAvailable:Te.hasUpdates,onNotificationAssetsChanged:()=>{vi()},onAgentRemoved:Qt}):null,Be?f.jsx(pB,{dialog:Be,activePaneCwd:ye?.cwd??null,activeWorkspaceCwd:Qe?.defaultCwd??null,onChange:ps,onManualCwdChange:Oa,onBrowse:xs,onCancel:Xn,onSubmit:()=>{ks()}}):null,f.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":ft?"true":void 0,children:[f.jsx(TO,{tabs:Qe?.tabs??[],activeTabId:Qe?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Oi,detachedTerminals:xn,onSelectTab:k=>ct({type:"tab.selected",tabId:k}),onCreateTab:()=>{_i()},onToggleWorkspaces:()=>V(k=>!k),onCloseTerminals:k=>Gs(k),onReattachTerminal:k=>tn(k),onDeleteTerminal:k=>{Br(k)},onSplitVertical:()=>{Xs("vertical")},onSplitHorizontal:()=>{Xs("horizontal")},onRenameTab:(k,T)=>{Zs(k,T)},activePaneAvailable:!!Bt}),ft?f.jsx(yB,{targets:Je,activeLeafKey:wt,terminals:x.terminals,editors:D,onSelect:Qn}):null,N?f.jsxs("div",{className:"workspace-error",role:"alert",children:[f.jsx("span",{children:N}),f.jsxs("div",{className:"workspace-error-actions",children:[f.jsx("button",{type:"button",onClick:ki,children:"Retry"}),n!==null&&r?f.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,f.jsxs("section",{className:"workspace-body","aria-busy":O,children:[O?f.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!O&&!gt?f.jsx(vB,{onCreate:()=>{_i()}}):null,M.map(k=>{const T=pn(k,n);return f.jsx(lB,{agentId:k,serverName:R[Hv(k)]??(k===null?"Local":"Server"),active:T,activeServerApi:T?p:void 0,visitedTabKeys:ce,refreshCwdOnEnter:T,draggingTab:T?st:null,mobileSplitFocus:We,mobileFocusedLeafByTabKey:Le,onSelect:I=>{T&&Ir(I)},onClose:I=>{T&&ja(I)},onCloseEditor:I=>{T&&Ts(I)},onResize:(I,se)=>{T&&ct({type:"pane.resized",path:I,ratio:se})},onExit:(I,se)=>{T?zr({type:"terminal.exited",terminalId:I,exitCode:se}):nl(k,{type:"terminal.exited",terminalId:I,exitCode:se})},onSnapshot:(I,se)=>{const ve={type:"terminal.updated",terminal:I,notifyCompletion:se?.notifyCompletion===!0};T?zr(ve):nl(k,ve)},...m?{onAuthClose:I=>m({...I,source:I?.source??"terminal-ws-1008",activeAgentId:k})}:{}},Eh(k))})]}),qt?f.jsx(bB,{label:qt.label,count:qt.terminalIds.length,warning:G,onCancel:()=>{F(null),Vt(null)},onHide:()=>{Ds(qt.terminalIds,qt.workspaceId)&&Vt(null)},onDelete:()=>{const k=qt.terminalIds;F(null),Vt(null),vn(k)}}):null,f.jsx(PO,{toast:xt,onActivate:Pa,onDismiss:()=>jt(null)}),f.jsx(AO,{uploads:q,onDismiss:er,onDismissAll:Kr,onRetry:nn,onCancel:Ns})]})]})})}function lB({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:d,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:y,onCloseEditor:b,onResize:w,onExit:C,onSnapshot:x,onAuthClose:D}){const O=v.useMemo(()=>Te=>rk(e,Te),[e]),N=v.useMemo(()=>()=>Ut(e),[e]),B=v.useSyncExternalStore(O,N,N),V=v.useMemo(()=>fl(e),[e]),W=r??V,ie=B.state,Q=ie.workspaces.find(Te=>Te.id===ie.activeWorkspaceId)??ie.workspaces[0],$=Q?.id??null,ne=(Q?.tabs.find(Te=>Te.id===Q.activeTabId)??Q?.tabs[0])?.id??null;return!B.loaded||ie.workspaces.length===0?null:f.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:ie.workspaces.flatMap(Te=>Te.tabs.map(te=>{const Y=n&&Te.id===$&&te.id===ne,G=$c(e,Te.id,te.id),F=Vh(te.root),le=m&&F.length>1?pk(F,te.activeTerminalId,g[G]):null;return!Y&&!o.has(G)?null:f.jsx("div",{className:"workspace-tab-surface","data-active":Y,"aria-hidden":!Y,children:f.jsx(xv,{node:te.root,terminals:ie.terminals,editors:B.editors,api:W,activeTerminalId:te.activeTerminalId,visible:Y,refreshCwdOnEnter:Y&&c,tabId:te.id,codeServerContext:{serverKey:Hv(e),serverName:t,tabName:te.title||ie.terminals[te.activeTerminalId]?.title||"Terminal"},dropZoneActive:Y&&d!==null,draggingTerminalId:Y?d?.terminalId??null:null,mobileFocusLeafKey:le,onSelect:p,onClose:y,onCloseEditor:b,onResize:w,onExit:C,onSnapshot:x,...D?{onAuthClose:D}:{}})},te.id)}))})}function cB(e){const t=uC(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=dB(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function uB(e,t,n){switch(n.type){case"pane.direction":return KO(e,t,n.direction);case"pane.index":return FO(e,n.index);default:return null}}function dB(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function hB(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function Vh(e){return e.type==="pane"?[{key:tu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:mk(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Vh(e.first),...Vh(e.second)]}function Pv(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Pv(e.first),...Pv(e.second)]}function pk(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?tu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function tu(e){return`terminal:${e}`}function mk(e){return`editor:${e}`}function fB(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 pB({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:d,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(C=>C.kind==="directory"),y=e.submitStatus==="submitting";function b(C){r(x=>x&&{...x,...C})}function w(C){C&&(b({cwd:C,error:null}),c(C))}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:d,children:f.jsxs("form",{className:"security-panel workspace-dialog",onClick:C=>C.stopPropagation(),onSubmit:C=>{C.preventDefault(),y||m()},children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:d,children:"x"})]}),f.jsxs("section",{className:"workspace-dialog-body",children:[f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Name"}),f.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:C=>b({title:C.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Default cwd"}),f.jsxs("div",{className:"workspace-dialog-path-row",children:[f.jsx("input",{value:e.cwd,disabled:y,onChange:C=>o(C.currentTarget.value),placeholder:"/home/user/project"}),f.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),f.jsxs("div",{className:"workspace-dialog-quick-actions",children:[f.jsx("button",{type:"button",onClick:()=>w(t),disabled:y||!t,children:"Use active pane"}),f.jsx("button",{type:"button",onClick:()=>w(n),disabled:y||!n,children:"Use current workspace"})]}),f.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[f.jsxs("div",{className:"workspace-dialog-browser-header",children:[f.jsx("span",{title:g,children:g||"No folder selected"}),f.jsx("button",{type:"button",onClick:()=>{c(gB(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?f.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?f.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?f.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(C=>f.jsxs("button",{type:"button","aria-label":`Choose folder ${C.name}`,disabled:y,onClick:()=>{c(mB(g,C.path))},children:[f.jsx("span",{children:C.name}),f.jsx("small",{children:C.path})]},C.path))}):null]}),e.error?f.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),f.jsxs("div",{className:"workspace-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:d,children:"Cancel"}),f.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function mB(e,t){return t?t.startsWith("/")?kh(t):kh(`${e||"/"}/${t}`):kh(e)}function gB(e){const t=kh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function kh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function vB({onCreate:e}){return f.jsxs("div",{className:"empty-workspace",children:[f.jsx("span",{children:"No terminal is open."}),f.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function _B({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:d}){const{setNodeRef:m,isOver:g}=e_({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),p=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return f.jsx("div",{ref:m,className:p,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:d})}function bB({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:d=>d.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),f.jsx("span",{children:e}),f.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?f.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function yB({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,d]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(w=>w.key===t):-1,g=m>=0?m:0,p=e[g]??e[0],y=a1(p,n,r);function b(w){const C=(g+w+e.length)%e.length,x=e[C];x&&o(x)}return f.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[f.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),f.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>d(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),f.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?f.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:f.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[f.jsxs("header",{children:[f.jsx("strong",{children:"Panes"}),f.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),f.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,C)=>{const x=a1(w,n,r),D=SB(w,n,r),O=w.key===p.key;return f.jsxs("button",{type:"button","data-active":O,onClick:()=>{o(w),d(!1)},children:[f.jsx("span",{className:"mobile-pane-sheet-index",children:C+1}),f.jsxs("span",{className:"mobile-pane-sheet-copy",children:[f.jsx("strong",{children:x}),f.jsx("small",{children:D})]}),f.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function a1(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function SB(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function wB(e){const[t,n]=v.useState(()=>CB(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function CB(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function xB(){if(typeof window>"u")return null;const e=R2(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 kB(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:tf(t.focus)}function EB(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Ui(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function pn(e,t){return e===t}function TB(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 Eh(e){return e??"__local__"}function $c(e,t,n){return`${Eh(e)}:${t}:${n}`}class Yh extends Error{constructor(){super(vk())}}function DB(e){return e?{workspaceKey:`${s1}:${e}`}:{workspaceKey:s1}}function RB(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(z1(n))throw new Yh;const r=j1(n);return r?gk(r):null}catch(n){if(n instanceof Yh)throw n;return null}}function gk(e){if(z1(e))throw new Yh;const t=j1(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Oc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function MB(e,t){const n=Ut(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function NB(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${wl}. Re-open or delete hidden sessions before hiding more.`}function vk(){return`A saved terminal layout has more than ${wl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function AB(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function LB(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function OB(e){return e.split("/").filter(Boolean).pop()??e}function BB(){try{return localStorage.getItem(fk)==="true"}catch{return!1}}function jB(e){try{localStorage.setItem(fk,e?"true":"false")}catch{}}function Hv(e){return e??Xi}function tg(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function zB(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function o1({name:e}){return f.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M4 7h9"}),f.jsx("path",{d:"M17 7h3"}),f.jsx("circle",{cx:"15",cy:"7",r:"2"}),f.jsx("path",{d:"M4 12h3"}),f.jsx("path",{d:"M11 12h9"}),f.jsx("circle",{cx:"9",cy:"12",r:"2"}),f.jsx("path",{d:"M4 17h9"}),f.jsx("path",{d:"M17 17h3"}),f.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M10 6H6v12h4"}),f.jsx("path",{d:"M13 8l4 4-4 4"}),f.jsx("path",{d:"M8 12h9"})]}):null]})}function ya(e){return e instanceof Error?e.message:"Request failed"}function IB({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[d,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[w,C]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(O=>{D||(r(O.qrDataUrl),c(O.secret))}).catch(O=>{D||C(O instanceof Error?O.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function x(D){if(D.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(O){b(O instanceof Error?O.message:"Verification failed")}finally{p(!1)}}}return w?f.jsx("p",{className:"form-error",children:w}):!n||!o?f.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):f.jsxs("div",{className:"totp-setup",children:[f.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."}),f.jsx("div",{className:"totp-qr-container",children:f.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),f.jsxs("details",{className:"totp-secret-details",children:[f.jsx("summary",{children:"Can't scan? Enter manually"}),f.jsx("p",{className:"totp-secret-text",children:o})]}),f.jsxs("form",{className:"auth-form",onSubmit:x,children:[f.jsxs("label",{children:["Verification code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?f.jsx("p",{className:"form-error",children:y}):null,f.jsx("button",{type:"submit",disabled:g||d.length!==6,children:"Activate 2FA"})]})]})}function PB(e){return{source:ig(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:ig(e.terminalId)}:{},...e?.detail?{detail:ig(e.detail)}:{}}}function HB(e){return{invalidationSource:e.source}}function UB(e){yn("auth.session_invalid.request",_k(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),t_("session-invalid-request").catch(()=>{}))}function KB(e,t){yn("auth.session_invalid.result",{..._k(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),t_("session-invalid-result").catch(()=>{}))}function _k(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 ig(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function FB({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??Xh(),[e]),c=v.useMemo(()=>t??fl(null),[t]),[d,m]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let N=!1;return o.getSession().then(B=>{N||(m(B),p(null))}).catch(B=>{N||(p(fo(B)),m(null))}),()=>{N=!0}},[o]);const w=VB(d);v.useEffect(()=>{const N=b.current;yn("auth.view",{view:w,previousView:N,authenticated:d?.authenticated??null,passwordSet:d?.passwordSet??null,totpEnabled:d?.totpEnabled??null,deviceTrusted:d?.deviceTrusted??null,currentIpWhitelisted:d?.currentIpWhitelisted??null}),N==="workspace"&&w!=="workspace"&&t_(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[d,w]);async function C(){const N=await o.getSession();m(N),p(null)}async function x(){$m(),eg(),Dw(),p(null),m(null);try{await C()}catch(N){p(fo(N))}}function D(N){const B=PB(N);if(UB(B),y.current)return y.current;const V=(async()=>{p(null);try{const W=await o.getSession(HB(B));if(KB(B,W.authenticated),m(W),W.authenticated){h3();return}$m(),eg(),Dw()}catch(W){p(fo(W))}finally{y.current=null}})();return y.current=V,V}if(w==="workspace")return f.jsx(oB,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:d?.expiresAt??null,previewMode:d?.previewMode===!0,onSessionInvalid:N=>{D(N)},onLogout:async()=>{$m(),eg();const N=await o.logout();m(N)}});const O={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return f.jsxs("main",{className:"auth-screen",children:[f.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[f.jsx("div",{className:"auth-grid"}),f.jsx("div",{className:"auth-glow"})]}),f.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[f.jsxs("header",{className:"auth-header",children:[f.jsxs("div",{className:"auth-brand",children:[f.jsx(p1,{size:26}),f.jsxs("div",{children:[f.jsx(m1,{height:17}),f.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),f.jsx("h1",{children:O[w]})]}),g?f.jsx("p",{className:"form-error",children:g}):null,w==="loading"?f.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,w==="setup_password"?f.jsx(WB,{api:o,onSession:N=>{m(N)}}):null,w==="setup_totp"?f.jsx(IB,{api:o,onDone:()=>{C()}}):null,w==="login"?f.jsx($B,{api:o,session:d,onSession:m,onRefresh:C}):null,w==="reauth"?f.jsx(qB,{api:o,session:d,onSession:m,onFullLogin:()=>m(N=>N&&{...N,deviceTrusted:!1})}):null]})]})}function WB({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[d,m]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),m(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(w){p(fo(w))}finally{m(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:y,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),f.jsxs("label",{children:["Confirm password",f.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?f.jsx("p",{className:"form-error",children:g}):null,f.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function $B({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[d,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[w,C]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function O(N){N.preventDefault(),b(!0),C(null);try{n(await e.login({password:o,...x?{otp:d}:{},rememberNetwork:g}))}catch(B){C(fo(B))}finally{b(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:O,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:N=>c(N.currentTarget.value),required:!0})]}),x?f.jsxs("label",{children:["Authenticator code",f.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:N=>m(N.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:g,onChange:N=>p(N.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?f.jsx("p",{className:"form-error",children:w}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:y||o.length===0||x&&d.length!==6,children:"Unlock"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function qB({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,d]=v.useState(""),[m,g]=v.useState(!1),[p,y]=v.useState(!1),[b,w]=v.useState(!1),[C,x]=v.useState(!1),[D,O]=v.useState(null),N=Ai.useCallback(async(V,W)=>{y(!0),O(null);try{n(await e.reauth({...V?{otp:V}:{},rememberNetwork:W}))}catch(ie){O(fo(ie))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let V=!1;w(!0),x(!1),O(null);const W=window.setTimeout(()=>{V||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(ie=>{V||n(ie)}).catch(ie=>{V||(O(fo(ie)),x(!0))}).finally(()=>{window.clearTimeout(W),V||w(!1)}),()=>{V=!0,window.clearTimeout(W)}}},[e,o,n]);async function B(V){V.preventDefault(),await N(c,m)}return o&&b&&!C&&!D?f.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):f.jsxs("form",{className:"auth-form",onSubmit:B,children:[o&&C&&!D?f.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,f.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),f.jsxs("label",{children:["Authenticator code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:V=>d(V.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:m,onChange:V=>g(V.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?f.jsx("p",{className:"form-error",children:D}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function VB(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function fo(e){return e instanceof Error?e.message:"Request failed"}const l1="NTerminal",Uv="nterminal.activeAgentId";function YB(){const[e,t]=v.useState(()=>XB()),n=v.useMemo(()=>Xh(),[]),r=v.useMemo(()=>fl(e),[e]);v.useEffect(()=>{const c=()=>{const d=SO();document.title=d>0?`(${d}) ${l1}`:l1};return c(),yO(c)},[]);function o(c){GB(c),t(c)}return f.jsx(FB,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function XB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Uv);return e&&e.trim()?e:null}catch{return null}}function GB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Uv,e);return}window.localStorage.removeItem(Uv)}catch{}}const c1=["gesturestart","gesturechange","gestureend"],ZB=[".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 QB(e=window){if(!e4(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!JB(c.target))&&r(c)}for(const c of c1)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of c1)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function JB(e){return e instanceof Element&&e.closest(ZB)!==null}function e4(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}L2();uL();QB();qv();$E.createRoot(document.getElementById("root")).render(f.jsx(Ai.StrictMode,{children:f.jsx(YB,{})}));export{Ai as R,jE as g,f as j};
|