nterminal 1.2.86 → 1.2.88

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.
@@ -0,0 +1,57 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-BCyFRE6U.js","assets/index-DcP0SS12.js","assets/TranscriptMarkdownBody-CvclqHm3.js"])))=>i.map(i=>d[i]);
2
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function kE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Om={exports:{}},jc={};var v0;function TE(){if(v0)return jc;v0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var m in o)m!=="key"&&(c[m]=o[m])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:c}}return jc.Fragment=t,jc.jsx=n,jc.jsxs=n,jc}var _0;function EE(){return _0||(_0=1,Om.exports=TE()),Om.exports}var f=EE(),Bm={exports:{}},st={};var b0;function DE(){if(b0)return st;b0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),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"),S=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||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 j(){}j.prototype=N.prototype;function q(M,K,ce){this.props=M,this.context=K,this.refs=O,this.updater=ce||x}var F=q.prototype=new j;F.constructor=q,D(F,N.prototype),F.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 De(M,K){return ne(M.type,K,M.props)}function se(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function V(M){var K={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ce){return K[ce]})}var X=/\/+/g;function W(M,K){return typeof M=="object"&&M!==null&&M.key!=null?V(""+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===""?"."+W(M,0):we,ie(Le)?(ce="",Be!=null&&(ce=Be.replace(X,"$&/")+"/"),L(Le,K,ce,"",function(Fe){return Fe})):Le!=null&&(se(Le)&&(Le=De(Le,ce+(Le.key==null||M&&M.key===Le.key?"":(""+Le.key).replace(X,"$&/")+"/")+Be)),K.push(Le)),1;Be=0;var Re=we===""?".":we+":";if(ie(M))for(var He=0;He<M.length;He++)we=M[He],xe=Re+W(we,He),Be+=L(we,K,ce,xe,Le);else if(He=w(M),typeof He=="function")for(M=He.call(M),He=0;!(we=M.next()).done;)we=we.value,xe=Re+W(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 B(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)},ye={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(!se(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return st.Activity=b,st.Children=ye,st.Component=N,st.Fragment=n,st.Profiler=o,st.PureComponent=q,st.StrictMode=r,st.Suspense=g,st.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,st.__COMPILER_RUNTIME={__proto__:null,c:function(M){return $.H.useMemoCache(M)}},st.cache=function(M){return function(){return M.apply(null,arguments)}},st.cacheSignal=function(){return null},st.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),Re=0;Re<xe;Re++)Be[Re]=arguments[Re+2];we.children=Be}return ne(M.type,Le,we)},st.createContext=function(M){return M={$$typeof:u,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},st.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 Re=Array(Be),He=0;He<Be;He++)Re[He]=arguments[He+2];Le.children=Re}if(M&&M.defaultProps)for(we in Be=M.defaultProps,Be)Le[we]===void 0&&(Le[we]=Be[we]);return ne(M,xe,Le)},st.createRef=function(){return{current:null}},st.forwardRef=function(M){return{$$typeof:m,render:M}},st.isValidElement=se,st.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:B}},st.memo=function(M,K){return{$$typeof:p,type:M,compare:K===void 0?null:K}},st.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}},st.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},st.use=function(M){return $.H.use(M)},st.useActionState=function(M,K,ce){return $.H.useActionState(M,K,ce)},st.useCallback=function(M,K){return $.H.useCallback(M,K)},st.useContext=function(M){return $.H.useContext(M)},st.useDebugValue=function(){},st.useDeferredValue=function(M,K){return $.H.useDeferredValue(M,K)},st.useEffect=function(M,K){return $.H.useEffect(M,K)},st.useEffectEvent=function(M){return $.H.useEffectEvent(M)},st.useId=function(){return $.H.useId()},st.useImperativeHandle=function(M,K,ce){return $.H.useImperativeHandle(M,K,ce)},st.useInsertionEffect=function(M,K){return $.H.useInsertionEffect(M,K)},st.useLayoutEffect=function(M,K){return $.H.useLayoutEffect(M,K)},st.useMemo=function(M,K){return $.H.useMemo(M,K)},st.useOptimistic=function(M,K){return $.H.useOptimistic(M,K)},st.useReducer=function(M,K,ce){return $.H.useReducer(M,K,ce)},st.useRef=function(M){return $.H.useRef(M)},st.useState=function(M){return $.H.useState(M)},st.useSyncExternalStore=function(M,K,ce){return $.H.useSyncExternalStore(M,K,ce)},st.useTransition=function(){return $.H.useTransition()},st.version="19.2.6",st}var y0;function g_(){return y0||(y0=1,Bm.exports=DE()),Bm.exports}var v=g_();const Ni=kE(v);var jm={exports:{}},Ic={},Im={exports:{}},zm={};var S0;function RE(){return S0||(S0=1,(function(e){function t(L,R){var B=L.length;L.push(R);e:for(;0<B;){var ae=B-1>>>1,ye=L[ae];if(0<o(ye,R))L[ae]=R,L[B]=ye,B=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],B=L.pop();if(B!==R){L[0]=B;e:for(var ae=0,ye=L.length,M=ye>>>1;ae<M;){var K=2*(ae+1)-1,ce=L[K],we=K+1,Le=L[we];if(0>o(ce,B))we<ye&&0>o(Le,ce)?(L[ae]=Le,L[we]=B,ae=we):(L[ae]=ce,L[K]=B,ae=K);else if(we<ye&&0>o(Le,B))L[ae]=Le,L[we]=B,ae=we;else break e}}return R}function o(L,R){var B=L.sortIndex-R.sortIndex;return B!==0?B: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 u=Date,m=u.now();e.unstable_now=function(){return u.now()-m}}var g=[],p=[],y=1,b=null,S=3,w=!1,x=!1,D=!1,O=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,q=typeof setImmediate<"u"?setImmediate:null;function F(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,F(L),!x)if(n(g)!==null)x=!0,Q||(Q=!0,V());else{var R=n(p);R!==null&&le(ie,R.startTime-L)}}var Q=!1,$=-1,Se=5,ne=-1;function De(){return O?!0:!(e.unstable_now()-ne<Se)}function se(){if(O=!1,Q){var L=e.unstable_now();ne=L;var R=!0;try{e:{x=!1,D&&(D=!1,j($),$=-1),w=!0;var B=S;try{t:{for(F(L),b=n(g);b!==null&&!(b.expirationTime>L&&De());){var ae=b.callback;if(typeof ae=="function"){b.callback=null,S=b.priorityLevel;var ye=ae(b.expirationTime<=L);if(L=e.unstable_now(),typeof ye=="function"){b.callback=ye,F(L),R=!0;break t}b===n(g)&&r(g),F(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,S=B,w=!1}R=void 0}}finally{R?V():Q=!1}}}var V;if(typeof q=="function")V=function(){q(se)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,W=X.port2;X.port1.onmessage=se,V=function(){W.postMessage(null)}}else V=function(){N(se,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 S},e.unstable_next=function(L){switch(S){case 1:case 2:case 3:var R=3;break;default:R=S}var B=S;S=R;try{return L()}finally{S=B}},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 B=S;S=L;try{return R()}finally{S=B}},e.unstable_scheduleCallback=function(L,R,B){var ae=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?ae+B:ae):B=ae,L){case 1:var ye=-1;break;case 2:ye=250;break;case 5:ye=1073741823;break;case 4:ye=1e4;break;default:ye=5e3}return ye=B+ye,L={id:y++,callback:R,priorityLevel:L,startTime:B,expirationTime:ye,sortIndex:-1},B>ae?(L.sortIndex=B,t(p,L),n(g)===null&&L===n(p)&&(D?(j($),$=-1):D=!0,le(ie,B-ae))):(L.sortIndex=ye,t(g,L),x||w||(x=!0,Q||(Q=!0,V()))),L},e.unstable_shouldYield=De,e.unstable_wrapCallback=function(L){var R=S;return function(){var B=S;S=R;try{return L.apply(this,arguments)}finally{S=B}}}})(zm)),zm}var w0;function ME(){return w0||(w0=1,Im.exports=RE()),Im.exports}var Pm={exports:{}},hn={};var C0;function NE(){if(C0)return hn;C0=1;var e=g_();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var 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 u=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 hn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,hn.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)},hn.flushSync=function(g){var p=u.T,y=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=p,r.p=y,r.d.f()}},hn.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))},hn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},hn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),S=typeof p.integrity=="string"?p.integrity:void 0,w=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:S,fetchPriority:w}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:S,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},hn.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)},hn.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})}},hn.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)},hn.requestFormReset=function(g){r.d.r(g)},hn.unstable_batchedUpdates=function(g,p){return g(p)},hn.useFormState=function(g,p,y){return u.H.useFormState(g,p,y)},hn.useFormStatus=function(){return u.H.useHostTransitionStatus()},hn.version="19.2.6",hn}var x0;function F1(){if(x0)return Pm.exports;x0=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(),Pm.exports=NE(),Pm.exports}var k0;function AE(){if(k0)return Ic;k0=1;var e=ME(),t=g_(),n=F1();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function u(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function 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 d=a.return;if(d===null)break;var h=d.alternate;if(h===null){if(l=d.return,l!==null){a=l;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===a)return g(d),i;if(h===l)return g(d),s;h=h.sibling}throw Error(r(188))}if(a.return!==l.return)a=d,l=h;else{for(var _=!1,T=d.child;T;){if(T===a){_=!0,a=d,l=h;break}if(T===l){_=!0,l=d,a=h;break}T=T.sibling}if(!_){for(T=h.child;T;){if(T===a){_=!0,a=h,l=d;break}if(T===l){_=!0,l=h,a=d;break}T=T.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,S=Symbol.for("react.element"),w=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"),j=Symbol.for("react.consumer"),q=Symbol.for("react.context"),F=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"),De=Symbol.for("react.memo_cache_sentinel"),se=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=se&&i[se]||i["@@iterator"],typeof i=="function"?i:null)}var X=Symbol.for("react.client.reference");function W(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===X?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case 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 q:return i.displayName||"Context";case j:return(i._context.displayName||"Context")+".Consumer";case F:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return s=i.displayName||null,s!==null?s:W(i.type)||"Memo";case Se:s=i._payload,i=i._init;try{return W(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,B={pending:!1,data:null,method:null,action:null},ae=[],ye=-1;function M(i){return{current:i}}function K(i){0>ye||(i.current=ae[ye],ae[ye]=null,ye--)}function ce(i,s){ye++,ae[ye]=i.current,i.current=s}var we=M(null),Le=M(null),xe=M(null),Be=M(null);function Re(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)?HS(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=HS(s),i=US(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 Fe(i){i.memoizedState!==null&&ce(Be,i);var s=we.current,a=US(s,i.type);s!==a&&(ce(Le,i),ce(we,a))}function ee(i){Le.current===i&&(K(we),K(Le)),Be.current===i&&(K(Be),Ac._currentValue=B)}var fe,H;function ue(i){if(fe===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);fe=s&&s[1]||"",H=-1<a.stack.indexOf(`
3
+ at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
+ `+fe+i+H}var ke=!1;function Ne(i,s){if(!i||ke)return"";ke=!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 d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),_=h[0],T=h[1];if(_&&T){var A=_.split(`
5
+ `),G=T.split(`
6
+ `);for(d=l=0;l<A.length&&!A[l].includes("DetermineComponentFrameRoot");)l++;for(;d<G.length&&!G[d].includes("DetermineComponentFrameRoot");)d++;if(l===A.length||d===G.length)for(l=A.length-1,d=G.length-1;1<=l&&0<=d&&A[l]!==G[d];)d--;for(;1<=l&&0<=d;l--,d--)if(A[l]!==G[d]){if(l!==1||d!==1)do if(l--,d--,0>d||A[l]!==G[d]){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<=d);break}}}finally{ke=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?ue(a):""}function te(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+=te(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,ze=e.unstable_cancelCallback,Je=e.unstable_shouldYield,rt=e.unstable_requestPaint,zt=e.unstable_now,gn=e.unstable_getCurrentPriorityLevel,oi=e.unstable_ImmediatePriority,mi=e.unstable_UserBlockingPriority,qe=e.unstable_NormalPriority,Ct=e.unstable_LowPriority,$t=e.unstable_IdlePriority,_e=e.log,Ve=e.unstable_setDisableYieldValue,nt=null,Xe=null;function xt(i){if(typeof _e=="function"&&Ve(i),Xe&&typeof Xe.setStrictMode=="function")try{Xe.setStrictMode(nt,i)}catch{}}var lt=Math.clz32?Math.clz32:Z,Tn=Math.log,gi=Math.LN2;function Z(i){return i>>>=0,i===0?32:31-(Tn(i)/gi|0)|0}var Ie=256,it=262144,Qe=4194304;function wt(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function qt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var d=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var T=l&134217727;return T!==0?(l=T&~h,l!==0?d=wt(l):(_&=T,_!==0?d=wt(_):a||(a=T&~i,a!==0&&(d=wt(a))))):(T=l&~h,T!==0?d=wt(T):_!==0?d=wt(_):a||(a=l&~i,a!==0&&(d=wt(a)))),d===0?0:s!==0&&s!==d&&(s&h)===0&&(h=d&-d,a=s&-s,h>=a||h===32&&(a&4194048)!==0)?s:d}function Pt(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function li(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 Vt(){var i=Qe;return Qe<<=1,(Qe&62914560)===0&&(Qe=4194304),i}function ii(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function ci(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ht(i,s,a,l,d,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 T=i.entanglements,A=i.expirationTimes,G=i.hiddenUpdates;for(a=_&~a;0<a;){var de=31-lt(a),ge=1<<de;T[de]=0,A[de]=-1;var J=G[de];if(J!==null)for(G[de]=null,de=0;de<J.length;de++){var oe=J[de];oe!==null&&(oe.lane&=-536870913)}a&=~ge}l!==0&&ln(i,l,0),h!==0&&d===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~s))}function ln(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-lt(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function Qt(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-lt(a),d=1<<l;d&s|i[l]&s&&(i[l]|=s),a&=~d}}function Hi(i,s){var a=s&-s;return a=(a&42)!==0?1:vn(a),(a&(i.suspendedLanes|s))!==0?0:a}function vn(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 _n(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Jt(){var i=R.p;return i!==0?i:(i=window.event,i===void 0?32:u0(i.type))}function Qi(i,s){var a=R.p;try{return R.p=i,s()}finally{R.p=a}}var ni=Math.random().toString(36).slice(2),vi="__reactFiber$"+ni,_i="__reactProps$"+ni,Bn="__reactContainer$"+ni,Ir="__reactEvents$"+ni,Lo="__reactListeners$"+ni,zr="__reactHandles$"+ni,Gs="__reactResources$"+ni,ds="__reactMarker$"+ni;function Zs(i){delete i[vi],delete i[_i],delete i[Ir],delete i[Lo],delete i[zr]}function hs(i){var s=i[vi];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Bn]||a[vi]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=YS(i);i!==null;){if(a=i[vi])return a;i=YS(i)}return s}i=a,a=i.parentNode}return null}function Ts(i){if(i=i[vi]||i[Bn]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function fs(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function Es(i){var s=i[Gs];return s||(s=i[Gs]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function At(i){i[ds]=!0}var Oo=new Set,Pr={};function Ut(i,s){jn(i,s),jn(i+"Capture",s)}function jn(i,s){for(Pr[i]=s,i=0;i<s.length;i++)Oo.add(s[i])}var Ji=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]*$"),Hr={},Bo={};function Qs(i){return me.call(Bo,i)?!0:me.call(Hr,i)?!1:Ji.test(i)?Bo[i]=!0:(Hr[i]=!0,!1)}function ps(i,s,a){if(Qs(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 Ur(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 bn(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 Ui(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Ds(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Fa(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var d=l.get,h=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.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 ms(i){if(!i._valueTracker){var s=Ds(i)?"checked":"value";i._valueTracker=Fa(i,s,""+i[s])}}function Ki(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Ds(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function gs(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 Rs=/[\n"\\]/g;function Li(i){return i.replace(Rs,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function ft(i,s,a,l,d,h,_,T){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=""+Ui(s)):i.value!==""+Ui(s)&&(i.value=""+Ui(s)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),s!=null?Js(i,_,Ui(s)):a!=null?Js(i,_,Ui(a)):l!=null&&i.removeAttribute("value"),d==null&&h!=null&&(i.defaultChecked=!!h),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?i.name=""+Ui(T):i.removeAttribute("name")}function vs(i,s,a,l,d,h,_,T){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)){ms(i);return}a=a!=null?""+Ui(a):"",s=s!=null?""+Ui(s):a,T||s===i.value||(i.value=s),i.defaultValue=s}l=l??d,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=T?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),ms(i)}function Js(i,s,a){s==="number"&&gs(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function cn(i,s,a,l){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Ui(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,l&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function Kr(i,s,a){if(s!=null&&(s=""+Ui(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Ui(a):""}function $a(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=Ui(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),ms(i)}function un(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var jo=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 Wr(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||jo.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function er(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var d in s)l=s[d],s.hasOwnProperty(d)&&a[d]!==l&&Wr(i,d,l)}else for(var h in s)s.hasOwnProperty(h)&&Wr(i,h,s[h])}function Fr(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 Io=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"]]),Fl=/^[\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 _s(i){return Fl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Yn(){}var bi=null;function $r(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Wi=null,si=null;function Ms(i){var s=Ts(i);if(s&&(i=s.stateNode)){var a=i[_i]||null;e:switch(i=s.stateNode,s.type){case"input":if(ft(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="'+Li(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var d=l[_i]||null;if(!d)throw Error(r(90));ft(l,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&Ki(l)}break e;case"textarea":Kr(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&cn(i,!!a.multiple,s,!1)}}}var tr=!1;function qa(i,s,a){if(tr)return i(s,a);tr=!0;try{var l=i(s);return l}finally{if(tr=!1,(Wi!==null||si!==null)&&(Pd(),Wi&&(s=Wi,i=si,si=Wi=null,Ms(s),i)))for(s=0;s<i.length;s++)Ms(i[s])}}function In(i,s){var a=i.stateNode;if(a===null)return null;var l=a[_i]||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 yi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),qr=!1;if(yi)try{var ir={};Object.defineProperty(ir,"passive",{get:function(){qr=!0}}),window.addEventListener("test",ir,ir),window.removeEventListener("test",ir,ir)}catch{qr=!1}var yn=null,Ns=null,As=null;function nr(){if(As)return As;var i,s=Ns,a=s.length,l,d="value"in yn?yn.value:yn.textContent,h=d.length;for(i=0;i<a&&s[i]===d[i];i++);var _=a-i;for(l=1;l<=_&&s[a-l]===d[h-l];l++);return As=d.slice(i,1<l?1-l:void 0)}function sr(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 Ls(){return!0}function dn(){return!1}function xi(i){function s(a,l,d,h,_){this._reactName=a,this._targetInst=d,this.type=l,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(h):h[T]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ls:dn,this.isPropagationStopped=dn,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=Ls)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Ls)},persist:function(){},isPersistent:Ls}),s}var Xn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},C=xi(Xn),E=b({},Xn,{view:0,detail:0}),z=xi(E),re,be,he,Te=b({},E,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Os,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!==he&&(he&&i.type==="mousemove"?(re=i.screenX-he.screenX,be=i.screenY-he.screenY):be=re=0,he=i),re)},movementY:function(i){return"movementY"in i?i.movementY:be}}),Ge=xi(Te),gt=b({},Te,{dataTransfer:0}),ki=xi(gt),Yt=b({},E,{relatedTarget:0}),Vr=xi(Yt),Bf=b({},Xn,{animationName:0,elapsedTime:0,pseudoElement:0}),zo=xi(Bf),Yr=b({},Xn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),$l=xi(Yr),en=b({},Xn,{data:0}),Po=xi(en),Ho={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Wu={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"},Fu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $u(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=Fu[i])?!!s[i]:!1}function Os(){return $u}var tn=b({},E,{key:function(i){if(i.key){var s=Ho[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=sr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Wu[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Os,charCode:function(i){return i.type==="keypress"?sr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?sr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),jf=xi(tn),qu=b({},Te,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ql=xi(qu),Vu=b({},E,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Os}),If=xi(Vu),Yu=b({},Xn,{propertyName:0,elapsedTime:0,pseudoElement:0}),rr=xi(Yu),Vl=b({},Te,{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}),zf=xi(Vl),Pf=b({},Xn,{newState:0,oldState:0}),Hf=xi(Pf),Yl=[9,13,27,32],Va=yi&&"CompositionEvent"in window,ar=null;yi&&"documentMode"in document&&(ar=document.documentMode);var Uo=yi&&"TextEvent"in window&&!ar,Xl=yi&&(!Va||ar&&8<ar&&11>=ar),Gl=" ",Xu=!1;function Zl(i,s){switch(i){case"keyup":return Yl.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Gu(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Xr=!1;function Uf(i,s){switch(i){case"compositionend":return Gu(s);case"keypress":return s.which!==32?null:(Xu=!0,Gl);case"textInput":return i=s.data,i===Gl&&Xu?null:i;default:return null}}function Zu(i,s){if(Xr)return i==="compositionend"||!Va&&Zl(i,s)?(i=nr(),As=Ns=yn=null,Xr=!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 Xl&&s.locale!=="ko"?null:s.data;default:return null}}var Ql={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 Ya(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!Ql[i.type]:s==="textarea"}function Jl(i,s,a,l){Wi?si?si.push(l):si=[l]:Wi=l,s=qd(s,"onChange"),0<s.length&&(a=new C("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var Gr=null,Xa=null;function Qu(i){OS(i,0)}function Ga(i){var s=fs(i);if(Ki(s))return i}function ec(i,s){if(i==="change")return s}var Ju=!1;if(yi){var Ko;if(yi){var Gn="oninput"in document;if(!Gn){var ed=document.createElement("div");ed.setAttribute("oninput","return;"),Gn=typeof ed.oninput=="function"}Ko=Gn}else Ko=!1;Ju=Ko&&(!document.documentMode||9<document.documentMode)}function td(){Gr&&(Gr.detachEvent("onpropertychange",tc),Xa=Gr=null)}function tc(i){if(i.propertyName==="value"&&Ga(Xa)){var s=[];Jl(s,Xa,i,$r(i)),qa(Qu,s)}}function Kf(i,s,a){i==="focusin"?(td(),Gr=s,Xa=a,Gr.attachEvent("onpropertychange",tc)):i==="focusout"&&td()}function Wf(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ga(Xa)}function or(i,s){if(i==="click")return Ga(s)}function Ff(i,s){if(i==="input"||i==="change")return Ga(s)}function $f(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var Sn=typeof Object.is=="function"?Object.is:$f;function Zr(i,s){if(Sn(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var d=a[l];if(!me.call(s,d)||!Sn(i[d],s[d]))return!1}return!0}function bs(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function id(i,s){var a=bs(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=bs(a)}}function nd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?nd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function sd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=gs(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=gs(i.document)}return s}function Za(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 qf=yi&&"documentMode"in document&&11>=document.documentMode,lr=null,k=null,I=null,Ce=!1;function $e(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Ce||lr==null||lr!==gs(l)||(l=lr,"selectionStart"in l&&Za(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}),I&&Zr(I,l)||(I=l,l=qd(k,"onSelect"),0<l.length&&(s=new C("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=lr)))}function Ke(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var at={animationend:Ke("Animation","AnimationEnd"),animationiteration:Ke("Animation","AnimationIteration"),animationstart:Ke("Animation","AnimationStart"),transitionrun:Ke("Transition","TransitionRun"),transitionstart:Ke("Transition","TransitionStart"),transitioncancel:Ke("Transition","TransitionCancel"),transitionend:Ke("Transition","TransitionEnd")},ct={},ht={};yi&&(ht=document.createElement("div").style,"AnimationEvent"in window||(delete at.animationend.animation,delete at.animationiteration.animation,delete at.animationstart.animation),"TransitionEvent"in window||delete at.transitionend.transition);function We(i){if(ct[i])return ct[i];if(!at[i])return i;var s=at[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in ht)return ct[i]=s[a];return i}var Kt=We("animationend"),Rt=We("animationiteration"),Dt=We("animationstart"),Bs=We("transitionrun"),Wo=We("transitionstart"),js=We("transitioncancel"),ic=We("transitionend"),nc=new Map,Vf="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(" ");Vf.push("scrollEnd");function ys(i,s){nc.set(i,s),Ut(s,[i])}var rd=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Zn=[],Fo=0,Yf=0;function ad(){for(var i=Fo,s=Yf=Fo=0;s<i;){var a=Zn[s];Zn[s++]=null;var l=Zn[s];Zn[s++]=null;var d=Zn[s];Zn[s++]=null;var h=Zn[s];if(Zn[s++]=null,l!==null&&d!==null){var _=l.pending;_===null?d.next=d:(d.next=_.next,_.next=d),l.pending=d}h!==0&&mb(a,d,h)}}function od(i,s,a,l){Zn[Fo++]=i,Zn[Fo++]=s,Zn[Fo++]=a,Zn[Fo++]=l,Yf|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Xf(i,s,a,l){return od(i,s,a,l),ld(i)}function Qa(i,s){return od(i,null,null,s),ld(i)}function mb(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var d=!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||(d=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,d&&s!==null&&(d=31-lt(a),i=h.hiddenUpdates,l=i[d],l===null?i[d]=[s]:l.push(s),s.lane=a|536870912),h):null}function ld(i){if(50<kc)throw kc=0,sm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var $o={};function lT(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 zn(i,s,a,l){return new lT(i,s,a,l)}function Gf(i){return i=i.prototype,!(!i||!i.isReactComponent)}function cr(i,s){var a=i.alternate;return a===null?(a=zn(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 gb(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 cd(i,s,a,l,d,h){var _=0;if(l=i,typeof i=="function")Gf(i)&&(_=1);else if(typeof i=="string")_=fE(i,a,we.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ne:return i=zn(31,a,s,d),i.elementType=ne,i.lanes=h,i;case D:return Ja(a.children,d,h,s);case O:_=8,d|=24;break;case N:return i=zn(12,a,s,d|2),i.elementType=N,i.lanes=h,i;case ie:return i=zn(13,a,s,d),i.elementType=ie,i.lanes=h,i;case Q:return i=zn(19,a,s,d),i.elementType=Q,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case q:_=10;break e;case j:_=9;break e;case F:_=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=zn(_,a,s,d),s.elementType=i,s.type=l,s.lanes=h,s}function Ja(i,s,a,l){return i=zn(7,i,l,s),i.lanes=a,i}function Zf(i,s,a){return i=zn(6,i,null,s),i.lanes=a,i}function vb(i){var s=zn(18,null,null,0);return s.stateNode=i,s}function Qf(i,s,a){return s=zn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var _b=new WeakMap;function Qn(i,s){if(typeof i=="object"&&i!==null){var a=_b.get(i);return a!==void 0?a:(s={value:i,source:s,stack:Ee(s)},_b.set(i,s),s)}return{value:i,source:s,stack:Ee(s)}}var qo=[],Vo=0,ud=null,sc=0,Jn=[],es=0,Qr=null,Is=1,zs="";function ur(i,s){qo[Vo++]=sc,qo[Vo++]=ud,ud=i,sc=s}function bb(i,s,a){Jn[es++]=Is,Jn[es++]=zs,Jn[es++]=Qr,Qr=i;var l=Is;i=zs;var d=32-lt(l)-1;l&=~(1<<d),a+=1;var h=32-lt(s)+d;if(30<h){var _=d-d%5;h=(l&(1<<_)-1).toString(32),l>>=_,d-=_,Is=1<<32-lt(s)+d|a<<d|l,zs=h+i}else Is=1<<h|a<<d|l,zs=i}function Jf(i){i.return!==null&&(ur(i,1),bb(i,1,0))}function ep(i){for(;i===ud;)ud=qo[--Vo],qo[Vo]=null,sc=qo[--Vo],qo[Vo]=null;for(;i===Qr;)Qr=Jn[--es],Jn[es]=null,zs=Jn[--es],Jn[es]=null,Is=Jn[--es],Jn[es]=null}function yb(i,s){Jn[es++]=Is,Jn[es++]=zs,Jn[es++]=Qr,Is=s.id,zs=s.overflow,Qr=i}var nn=null,Xt=null,St=!1,Jr=null,ts=!1,tp=Error(r(519));function ea(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw rc(Qn(s,i)),tp}function Sb(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[vi]=i,s[_i]=l,a){case"dialog":_t("cancel",s),_t("close",s);break;case"iframe":case"object":case"embed":_t("load",s);break;case"video":case"audio":for(a=0;a<Ec.length;a++)_t(Ec[a],s);break;case"source":_t("error",s);break;case"img":case"image":case"link":_t("error",s),_t("load",s);break;case"details":_t("toggle",s);break;case"input":_t("invalid",s),vs(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":_t("invalid",s);break;case"textarea":_t("invalid",s),$a(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||zS(s.textContent,a)?(l.popover!=null&&(_t("beforetoggle",s),_t("toggle",s)),l.onScroll!=null&&_t("scroll",s),l.onScrollEnd!=null&&_t("scrollend",s),l.onClick!=null&&(s.onclick=Yn),s=!0):s=!1,s||ea(i,!0)}function wb(i){for(nn=i.return;nn;)switch(nn.tag){case 5:case 31:case 13:ts=!1;return;case 27:case 3:ts=!0;return;default:nn=nn.return}}function Yo(i){if(i!==nn)return!1;if(!St)return wb(i),St=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||bm(i.type,i.memoizedProps)),a=!a),a&&Xt&&ea(i),wb(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,pa(i.type)?(i=xm,xm=null,Xt=i):Xt=s):Xt=nn?ns(i.stateNode.nextSibling):null;return!0}function eo(){Xt=nn=null,St=!1}function ip(){var i=Jr;return i!==null&&(Mn===null?Mn=i:Mn.push.apply(Mn,i),Jr=null),i}function rc(i){Jr===null?Jr=[i]:Jr.push(i)}var np=M(null),to=null,dr=null;function ta(i,s,a){ce(np,s._currentValue),s._currentValue=a}function hr(i){i._currentValue=np.current,K(np)}function sp(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 rp(i,s,a,l){var d=i.child;for(d!==null&&(d.return=i);d!==null;){var h=d.dependencies;if(h!==null){var _=d.child;h=h.firstContext;e:for(;h!==null;){var T=h;h=d;for(var A=0;A<s.length;A++)if(T.context===s[A]){h.lanes|=a,T=h.alternate,T!==null&&(T.lanes|=a),sp(h.return,a,i),l||(_=null);break e}h=T.next}}else if(d.tag===18){if(_=d.return,_===null)throw Error(r(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),sp(_,a,i),_=null}else _=d.child;if(_!==null)_.return=d;else for(_=d;_!==null;){if(_===i){_=null;break}if(d=_.sibling,d!==null){d.return=_.return,_=d;break}_=_.return}d=_}}function Xo(i,s,a,l){i=null;for(var d=s,h=!1;d!==null;){if(!h){if((d.flags&524288)!==0)h=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var _=d.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var T=d.type;Sn(d.pendingProps.value,_.value)||(i!==null?i.push(T):i=[T])}}else if(d===Be.current){if(_=d.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(i!==null?i.push(Ac):i=[Ac])}d=d.return}i!==null&&rp(s,i,a,l),s.flags|=262144}function dd(i){for(i=i.firstContext;i!==null;){if(!Sn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function io(i){to=i,dr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function sn(i){return Cb(to,i)}function hd(i,s){return to===null&&io(i),Cb(i,s)}function Cb(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},dr===null){if(i===null)throw Error(r(308));dr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else dr=dr.next=s;return a}var cT=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()})}},uT=e.unstable_scheduleCallback,dT=e.unstable_NormalPriority,Ti={$$typeof:q,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ap(){return{controller:new cT,data:new Map,refCount:0}}function ac(i){i.refCount--,i.refCount===0&&uT(dT,function(){i.controller.abort()})}var oc=null,op=0,Go=0,Zo=null;function hT(i,s){if(oc===null){var a=oc=[];op=0,Go=um(),Zo={status:"pending",value:void 0,then:function(l){a.push(l)}}}return op++,s.then(xb,xb),s}function xb(){if(--op===0&&oc!==null){Zo!==null&&(Zo.status="fulfilled");var i=oc;oc=null,Go=0,Zo=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function fT(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(d){a.push(d)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var d=0;d<a.length;d++)(0,a[d])(s)},function(d){for(l.status="rejected",l.reason=d,d=0;d<a.length;d++)(0,a[d])(void 0)}),l}var kb=L.S;L.S=function(i,s){lS=zt(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&hT(i,s),kb!==null&&kb(i,s)};var no=M(null);function lp(){var i=no.current;return i!==null?i:Wt.pooledCache}function fd(i,s){s===null?ce(no,no.current):ce(no,s.pool)}function Tb(){var i=lp();return i===null?null:{parent:Ti._currentValue,pool:i}}var Qo=Error(r(460)),cp=Error(r(474)),pd=Error(r(542)),md={then:function(){}};function Eb(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Db(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Yn,Yn),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Mb(i),i;default:if(typeof s.status=="string")s.then(Yn,Yn);else{if(i=Wt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var d=s;d.status="fulfilled",d.value=l}},function(l){if(s.status==="pending"){var d=s;d.status="rejected",d.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,Mb(i),i}throw ro=s,Qo}}function so(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ro=a,Qo):a}}var ro=null;function Rb(){if(ro===null)throw Error(r(459));var i=ro;return ro=null,i}function Mb(i){if(i===Qo||i===pd)throw Error(r(483))}var Jo=null,lc=0;function gd(i){var s=lc;return lc+=1,Jo===null&&(Jo=[]),Db(Jo,i,s)}function cc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function vd(i,s){throw s.$$typeof===S?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function Nb(i){function s(U,P){if(i){var Y=U.deletions;Y===null?(U.deletions=[P],U.flags|=16):Y.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 d(U,P){return U=cr(U,P),U.index=0,U.sibling=null,U}function h(U,P,Y){return U.index=Y,i?(Y=U.alternate,Y!==null?(Y=Y.index,Y<P?(U.flags|=67108866,P):Y):(U.flags|=67108866,P)):(U.flags|=1048576,P)}function _(U){return i&&U.alternate===null&&(U.flags|=67108866),U}function T(U,P,Y,pe){return P===null||P.tag!==6?(P=Zf(Y,U.mode,pe),P.return=U,P):(P=d(P,Y),P.return=U,P)}function A(U,P,Y,pe){var Ye=Y.type;return Ye===D?de(U,P,Y.props.children,pe,Y.key):P!==null&&(P.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===Se&&so(Ye)===P.type)?(P=d(P,Y.props),cc(P,Y),P.return=U,P):(P=cd(Y.type,Y.key,Y.props,null,U.mode,pe),cc(P,Y),P.return=U,P)}function G(U,P,Y,pe){return P===null||P.tag!==4||P.stateNode.containerInfo!==Y.containerInfo||P.stateNode.implementation!==Y.implementation?(P=Qf(Y,U.mode,pe),P.return=U,P):(P=d(P,Y.children||[]),P.return=U,P)}function de(U,P,Y,pe,Ye){return P===null||P.tag!==7?(P=Ja(Y,U.mode,pe,Ye),P.return=U,P):(P=d(P,Y),P.return=U,P)}function ge(U,P,Y){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=Zf(""+P,U.mode,Y),P.return=U,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case w:return Y=cd(P.type,P.key,P.props,null,U.mode,Y),cc(Y,P),Y.return=U,Y;case x:return P=Qf(P,U.mode,Y),P.return=U,P;case Se:return P=so(P),ge(U,P,Y)}if(le(P)||V(P))return P=Ja(P,U.mode,Y,null),P.return=U,P;if(typeof P.then=="function")return ge(U,gd(P),Y);if(P.$$typeof===q)return ge(U,hd(U,P),Y);vd(U,P)}return null}function J(U,P,Y,pe){var Ye=P!==null?P.key:null;if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Ye!==null?null:T(U,P,""+Y,pe);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case w:return Y.key===Ye?A(U,P,Y,pe):null;case x:return Y.key===Ye?G(U,P,Y,pe):null;case Se:return Y=so(Y),J(U,P,Y,pe)}if(le(Y)||V(Y))return Ye!==null?null:de(U,P,Y,pe,null);if(typeof Y.then=="function")return J(U,P,gd(Y),pe);if(Y.$$typeof===q)return J(U,P,hd(U,Y),pe);vd(U,Y)}return null}function oe(U,P,Y,pe,Ye){if(typeof pe=="string"&&pe!==""||typeof pe=="number"||typeof pe=="bigint")return U=U.get(Y)||null,T(P,U,""+pe,Ye);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case w:return U=U.get(pe.key===null?Y:pe.key)||null,A(P,U,pe,Ye);case x:return U=U.get(pe.key===null?Y:pe.key)||null,G(P,U,pe,Ye);case Se:return pe=so(pe),oe(U,P,Y,pe,Ye)}if(le(pe)||V(pe))return U=U.get(Y)||null,de(P,U,pe,Ye,null);if(typeof pe.then=="function")return oe(U,P,Y,gd(pe),Ye);if(pe.$$typeof===q)return oe(U,P,Y,hd(P,pe),Ye);vd(P,pe)}return null}function Pe(U,P,Y,pe){for(var Ye=null,kt=null,Ue=P,ut=P=0,yt=null;Ue!==null&&ut<Y.length;ut++){Ue.index>ut?(yt=Ue,Ue=null):yt=Ue.sibling;var Tt=J(U,Ue,Y[ut],pe);if(Tt===null){Ue===null&&(Ue=yt);break}i&&Ue&&Tt.alternate===null&&s(U,Ue),P=h(Tt,P,ut),kt===null?Ye=Tt:kt.sibling=Tt,kt=Tt,Ue=yt}if(ut===Y.length)return a(U,Ue),St&&ur(U,ut),Ye;if(Ue===null){for(;ut<Y.length;ut++)Ue=ge(U,Y[ut],pe),Ue!==null&&(P=h(Ue,P,ut),kt===null?Ye=Ue:kt.sibling=Ue,kt=Ue);return St&&ur(U,ut),Ye}for(Ue=l(Ue);ut<Y.length;ut++)yt=oe(Ue,U,ut,Y[ut],pe),yt!==null&&(i&&yt.alternate!==null&&Ue.delete(yt.key===null?ut:yt.key),P=h(yt,P,ut),kt===null?Ye=yt:kt.sibling=yt,kt=yt);return i&&Ue.forEach(function(ba){return s(U,ba)}),St&&ur(U,ut),Ye}function Ze(U,P,Y,pe){if(Y==null)throw Error(r(151));for(var Ye=null,kt=null,Ue=P,ut=P=0,yt=null,Tt=Y.next();Ue!==null&&!Tt.done;ut++,Tt=Y.next()){Ue.index>ut?(yt=Ue,Ue=null):yt=Ue.sibling;var ba=J(U,Ue,Tt.value,pe);if(ba===null){Ue===null&&(Ue=yt);break}i&&Ue&&ba.alternate===null&&s(U,Ue),P=h(ba,P,ut),kt===null?Ye=ba:kt.sibling=ba,kt=ba,Ue=yt}if(Tt.done)return a(U,Ue),St&&ur(U,ut),Ye;if(Ue===null){for(;!Tt.done;ut++,Tt=Y.next())Tt=ge(U,Tt.value,pe),Tt!==null&&(P=h(Tt,P,ut),kt===null?Ye=Tt:kt.sibling=Tt,kt=Tt);return St&&ur(U,ut),Ye}for(Ue=l(Ue);!Tt.done;ut++,Tt=Y.next())Tt=oe(Ue,U,ut,Tt.value,pe),Tt!==null&&(i&&Tt.alternate!==null&&Ue.delete(Tt.key===null?ut:Tt.key),P=h(Tt,P,ut),kt===null?Ye=Tt:kt.sibling=Tt,kt=Tt);return i&&Ue.forEach(function(xE){return s(U,xE)}),St&&ur(U,ut),Ye}function Bt(U,P,Y,pe){if(typeof Y=="object"&&Y!==null&&Y.type===D&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case w:e:{for(var Ye=Y.key;P!==null;){if(P.key===Ye){if(Ye=Y.type,Ye===D){if(P.tag===7){a(U,P.sibling),pe=d(P,Y.props.children),pe.return=U,U=pe;break e}}else if(P.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===Se&&so(Ye)===P.type){a(U,P.sibling),pe=d(P,Y.props),cc(pe,Y),pe.return=U,U=pe;break e}a(U,P);break}else s(U,P);P=P.sibling}Y.type===D?(pe=Ja(Y.props.children,U.mode,pe,Y.key),pe.return=U,U=pe):(pe=cd(Y.type,Y.key,Y.props,null,U.mode,pe),cc(pe,Y),pe.return=U,U=pe)}return _(U);case x:e:{for(Ye=Y.key;P!==null;){if(P.key===Ye)if(P.tag===4&&P.stateNode.containerInfo===Y.containerInfo&&P.stateNode.implementation===Y.implementation){a(U,P.sibling),pe=d(P,Y.children||[]),pe.return=U,U=pe;break e}else{a(U,P);break}else s(U,P);P=P.sibling}pe=Qf(Y,U.mode,pe),pe.return=U,U=pe}return _(U);case Se:return Y=so(Y),Bt(U,P,Y,pe)}if(le(Y))return Pe(U,P,Y,pe);if(V(Y)){if(Ye=V(Y),typeof Ye!="function")throw Error(r(150));return Y=Ye.call(Y),Ze(U,P,Y,pe)}if(typeof Y.then=="function")return Bt(U,P,gd(Y),pe);if(Y.$$typeof===q)return Bt(U,P,hd(U,Y),pe);vd(U,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,P!==null&&P.tag===6?(a(U,P.sibling),pe=d(P,Y),pe.return=U,U=pe):(a(U,P),pe=Zf(Y,U.mode,pe),pe.return=U,U=pe),_(U)):a(U,P)}return function(U,P,Y,pe){try{lc=0;var Ye=Bt(U,P,Y,pe);return Jo=null,Ye}catch(Ue){if(Ue===Qo||Ue===pd)throw Ue;var kt=zn(29,Ue,null,U.mode);return kt.lanes=pe,kt.return=U,kt}}}var ao=Nb(!0),Ab=Nb(!1),ia=!1;function up(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function dp(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 na(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function sa(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Et&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,s=ld(i),mb(i,null,a),s}return od(i,l,s,a),ld(i)}function uc(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,Qt(i,a)}}function hp(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var d=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?d=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?d=h=s:h=h.next=s}else d=h=s;a={baseState:l.baseState,firstBaseUpdate:d,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 fp=!1;function dc(){if(fp){var i=Zo;if(i!==null)throw i}}function hc(i,s,a,l){fp=!1;var d=i.updateQueue;ia=!1;var h=d.firstBaseUpdate,_=d.lastBaseUpdate,T=d.shared.pending;if(T!==null){d.shared.pending=null;var A=T,G=A.next;A.next=null,_===null?h=G:_.next=G,_=A;var de=i.alternate;de!==null&&(de=de.updateQueue,T=de.lastBaseUpdate,T!==_&&(T===null?de.firstBaseUpdate=G:T.next=G,de.lastBaseUpdate=A))}if(h!==null){var ge=d.baseState;_=0,de=G=A=null,T=h;do{var J=T.lane&-536870913,oe=J!==T.lane;if(oe?(bt&J)===J:(l&J)===J){J!==0&&J===Go&&(fp=!0),de!==null&&(de=de.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var Pe=i,Ze=T;J=s;var Bt=a;switch(Ze.tag){case 1:if(Pe=Ze.payload,typeof Pe=="function"){ge=Pe.call(Bt,ge,J);break e}ge=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Ze.payload,J=typeof Pe=="function"?Pe.call(Bt,ge,J):Pe,J==null)break e;ge=b({},ge,J);break e;case 2:ia=!0}}J=T.callback,J!==null&&(i.flags|=64,oe&&(i.flags|=8192),oe=d.callbacks,oe===null?d.callbacks=[J]:oe.push(J))}else oe={lane:J,tag:T.tag,payload:T.payload,callback:T.callback,next:null},de===null?(G=de=oe,A=ge):de=de.next=oe,_|=J;if(T=T.next,T===null){if(T=d.shared.pending,T===null)break;oe=T,T=oe.next,oe.next=null,d.lastBaseUpdate=oe,d.shared.pending=null}}while(!0);de===null&&(A=ge),d.baseState=A,d.firstBaseUpdate=G,d.lastBaseUpdate=de,h===null&&(d.shared.lanes=0),ca|=_,i.lanes=_,i.memoizedState=ge}}function Lb(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function Ob(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Lb(a[i],s)}var el=M(null),_d=M(0);function Bb(i,s){i=Sr,ce(_d,i),ce(el,s),Sr=i|s.baseLanes}function pp(){ce(_d,Sr),ce(el,el.current)}function mp(){Sr=_d.current,K(el),K(_d)}var Pn=M(null),is=null;function ra(i){var s=i.alternate;ce(Si,Si.current&1),ce(Pn,i),is===null&&(s===null||el.current!==null||s.memoizedState!==null)&&(is=i)}function gp(i){ce(Si,Si.current),ce(Pn,i),is===null&&(is=i)}function jb(i){i.tag===22?(ce(Si,Si.current),ce(Pn,i),is===null&&(is=i)):aa()}function aa(){ce(Si,Si.current),ce(Pn,Pn.current)}function Hn(i){K(Pn),is===i&&(is=null),K(Si)}var Si=M(0);function bd(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||wm(a)||Cm(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 fr=0,ot=null,Lt=null,Ei=null,yd=!1,tl=!1,oo=!1,Sd=0,fc=0,il=null,pT=0;function ui(){throw Error(r(321))}function vp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!Sn(i[a],s[a]))return!1;return!0}function _p(i,s,a,l,d,h){return fr=h,ot=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,L.H=i===null||i.memoizedState===null?by:Lp,oo=!1,h=a(l,d),oo=!1,tl&&(h=zb(s,a,l,d)),Ib(i),h}function Ib(i){L.H=gc;var s=Lt!==null&&Lt.next!==null;if(fr=0,Ei=Lt=ot=null,yd=!1,fc=0,il=null,s)throw Error(r(300));i===null||Di||(i=i.dependencies,i!==null&&dd(i)&&(Di=!0))}function zb(i,s,a,l){ot=i;var d=0;do{if(tl&&(il=null),fc=0,tl=!1,25<=d)throw Error(r(301));if(d+=1,Ei=Lt=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=yy,h=s(a,l)}while(tl);return h}function mT(){var i=L.H,s=i.useState()[0];return s=typeof s.then=="function"?pc(s):s,i=i.useState()[0],(Lt!==null?Lt.memoizedState:null)!==i&&(ot.flags|=1024),s}function bp(){var i=Sd!==0;return Sd=0,i}function yp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Sp(i){if(yd){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}yd=!1}fr=0,Ei=Lt=ot=null,tl=!1,fc=Sd=0,il=null}function wn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ei===null?ot.memoizedState=Ei=i:Ei=Ei.next=i,Ei}function wi(){if(Lt===null){var i=ot.alternate;i=i!==null?i.memoizedState:null}else i=Lt.next;var s=Ei===null?ot.memoizedState:Ei.next;if(s!==null)Ei=s,Lt=i;else{if(i===null)throw ot.alternate===null?Error(r(467)):Error(r(310));Lt=i,i={memoizedState:Lt.memoizedState,baseState:Lt.baseState,baseQueue:Lt.baseQueue,queue:Lt.queue,next:null},Ei===null?ot.memoizedState=Ei=i:Ei=Ei.next=i}return Ei}function wd(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function pc(i){var s=fc;return fc+=1,il===null&&(il=[]),i=Db(il,i,s),s=ot,(Ei===null?s.memoizedState:Ei.next)===null&&(s=s.alternate,L.H=s===null||s.memoizedState===null?by:Lp),i}function Cd(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return pc(i);if(i.$$typeof===q)return sn(i)}throw Error(r(438,String(i)))}function wp(i){var s=null,a=ot.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=ot.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(d){return d.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=wd(),ot.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]=De;return s.index++,a}function pr(i,s){return typeof s=="function"?s(i):s}function xd(i){var s=wi();return Cp(s,Lt,i)}function Cp(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var d=i.baseQueue,h=l.pending;if(h!==null){if(d!==null){var _=d.next;d.next=h.next,h.next=_}s.baseQueue=d=h,l.pending=null}if(h=i.baseState,d===null)i.memoizedState=h;else{s=d.next;var T=_=null,A=null,G=s,de=!1;do{var ge=G.lane&-536870913;if(ge!==G.lane?(bt&ge)===ge:(fr&ge)===ge){var J=G.revertLane;if(J===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),ge===Go&&(de=!0);else if((fr&J)===J){G=G.next,J===Go&&(de=!0);continue}else ge={lane:0,revertLane:G.revertLane,gesture:null,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},A===null?(T=A=ge,_=h):A=A.next=ge,ot.lanes|=J,ca|=J;ge=G.action,oo&&a(h,ge),h=G.hasEagerState?G.eagerState:a(h,ge)}else J={lane:ge,revertLane:G.revertLane,gesture:G.gesture,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null},A===null?(T=A=J,_=h):A=A.next=J,ot.lanes|=ge,ca|=ge;G=G.next}while(G!==null&&G!==s);if(A===null?_=h:A.next=T,!Sn(h,i.memoizedState)&&(Di=!0,de&&(a=Zo,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=A,l.lastRenderedState=h}return d===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function xp(i){var s=wi(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,d=a.pending,h=s.memoizedState;if(d!==null){a.pending=null;var _=d=d.next;do h=i(h,_.action),_=_.next;while(_!==d);Sn(h,s.memoizedState)||(Di=!0),s.memoizedState=h,s.baseQueue===null&&(s.baseState=h),a.lastRenderedState=h}return[h,l]}function Pb(i,s,a){var l=ot,d=wi(),h=St;if(h){if(a===void 0)throw Error(r(407));a=a()}else a=s();var _=!Sn((Lt||d).memoizedState,a);if(_&&(d.memoizedState=a,Di=!0),d=d.queue,Ep(Kb.bind(null,l,d,i),[i]),d.getSnapshot!==s||_||Ei!==null&&Ei.memoizedState.tag&1){if(l.flags|=2048,nl(9,{destroy:void 0},Ub.bind(null,l,d,a,s),null),Wt===null)throw Error(r(349));h||(fr&127)!==0||Hb(l,s,a)}return a}function Hb(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=ot.updateQueue,s===null?(s=wd(),ot.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function Ub(i,s,a,l){s.value=a,s.getSnapshot=l,Wb(s)&&Fb(i)}function Kb(i,s,a){return a(function(){Wb(s)&&Fb(i)})}function Wb(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!Sn(i,a)}catch{return!0}}function Fb(i){var s=Qa(i,2);s!==null&&Nn(s,i,2)}function kp(i){var s=wn();if(typeof i=="function"){var a=i;if(i=a(),oo){xt(!0);try{a()}finally{xt(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:i},s}function $b(i,s,a,l){return i.baseState=a,Cp(i,Lt,typeof l=="function"?l:pr)}function gT(i,s,a,l,d){if(Ed(i))throw Error(r(485));if(i=s.action,i!==null){var h={payload:d,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,qb(s,h)):(h.next=a.next,s.pending=a.next=h)}}function qb(i,s){var a=s.action,l=s.payload,d=i.state;if(s.isTransition){var h=L.T,_={};L.T=_;try{var T=a(d,l),A=L.S;A!==null&&A(_,T),Vb(i,s,T)}catch(G){Tp(i,s,G)}finally{h!==null&&_.types!==null&&(h.types=_.types),L.T=h}}else try{h=a(d,l),Vb(i,s,h)}catch(G){Tp(i,s,G)}}function Vb(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Yb(i,s,l)},function(l){return Tp(i,s,l)}):Yb(i,s,a)}function Yb(i,s,a){s.status="fulfilled",s.value=a,Xb(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,qb(i,a)))}function Tp(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,Xb(s),s=s.next;while(s!==l)}i.action=null}function Xb(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function Gb(i,s){return s}function Zb(i,s){if(St){var a=Wt.formState;if(a!==null){e:{var l=ot;if(St){if(Xt){t:{for(var d=Xt,h=ts;d.nodeType!==8;){if(!h){d=null;break t}if(d=ns(d.nextSibling),d===null){d=null;break t}}h=d.data,d=h==="F!"||h==="F"?d:null}if(d){Xt=ns(d.nextSibling),l=d.data==="F!";break e}}ea(l)}l=!1}l&&(s=a[0])}}return a=wn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gb,lastRenderedState:s},a.queue=l,a=gy.bind(null,ot,l),l.dispatch=a,l=kp(!1),h=Ap.bind(null,ot,!1,l.queue),l=wn(),d={state:s,dispatch:null,action:i,pending:null},l.queue=d,a=gT.bind(null,ot,d,h,a),d.dispatch=a,l.memoizedState=i,[s,a,!1]}function Qb(i){var s=wi();return Jb(s,Lt,i)}function Jb(i,s,a){if(s=Cp(i,s,Gb)[0],i=xd(pr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=pc(s)}catch(_){throw _===Qo?pd:_}else l=s;s=wi();var d=s.queue,h=d.dispatch;return a!==s.memoizedState&&(ot.flags|=2048,nl(9,{destroy:void 0},vT.bind(null,d,a),null)),[l,h,i]}function vT(i,s){i.action=s}function ey(i){var s=wi(),a=Lt;if(a!==null)return Jb(s,a,i);wi(),s=s.memoizedState,a=wi();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function nl(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=ot.updateQueue,s===null&&(s=wd(),ot.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 ty(){return wi().memoizedState}function kd(i,s,a,l){var d=wn();ot.flags|=i,d.memoizedState=nl(1|s,{destroy:void 0},a,l===void 0?null:l)}function Td(i,s,a,l){var d=wi();l=l===void 0?null:l;var h=d.memoizedState.inst;Lt!==null&&l!==null&&vp(l,Lt.memoizedState.deps)?d.memoizedState=nl(s,h,a,l):(ot.flags|=i,d.memoizedState=nl(1|s,h,a,l))}function iy(i,s){kd(8390656,8,i,s)}function Ep(i,s){Td(2048,8,i,s)}function _T(i){ot.flags|=4;var s=ot.updateQueue;if(s===null)s=wd(),ot.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function ny(i){var s=wi().memoizedState;return _T({ref:s,nextImpl:i}),function(){if((Et&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function sy(i,s){return Td(4,2,i,s)}function ry(i,s){return Td(4,4,i,s)}function ay(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 oy(i,s,a){a=a!=null?a.concat([i]):null,Td(4,4,ay.bind(null,s,i),a)}function Dp(){}function ly(i,s){var a=wi();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&vp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function cy(i,s){var a=wi();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&vp(s,l[1]))return l[0];if(l=i(),oo){xt(!0);try{i()}finally{xt(!1)}}return a.memoizedState=[l,s],l}function Rp(i,s,a){return a===void 0||(fr&1073741824)!==0&&(bt&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=uS(),ot.lanes|=i,ca|=i,a)}function uy(i,s,a,l){return Sn(a,s)?a:el.current!==null?(i=Rp(i,a,l),Sn(i,s)||(Di=!0),i):(fr&42)===0||(fr&1073741824)!==0&&(bt&261930)===0?(Di=!0,i.memoizedState=a):(i=uS(),ot.lanes|=i,ca|=i,s)}function dy(i,s,a,l,d){var h=R.p;R.p=h!==0&&8>h?h:8;var _=L.T,T={};L.T=T,Ap(i,!1,s,a);try{var A=d(),G=L.S;if(G!==null&&G(T,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var de=fT(A,l);mc(i,s,de,Wn(i))}else mc(i,s,l,Wn(i))}catch(ge){mc(i,s,{then:function(){},status:"rejected",reason:ge},Wn())}finally{R.p=h,_!==null&&T.types!==null&&(_.types=T.types),L.T=_}}function bT(){}function Mp(i,s,a,l){if(i.tag!==5)throw Error(r(476));var d=hy(i).queue;dy(i,d,s,B,a===null?bT:function(){return fy(i),a(l)})}function hy(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:B},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function fy(i){var s=hy(i);s.next===null&&(s=i.alternate.memoizedState),mc(i,s.next.queue,{},Wn())}function Np(){return sn(Ac)}function py(){return wi().memoizedState}function my(){return wi().memoizedState}function yT(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Wn();i=na(a);var l=sa(s,i,a);l!==null&&(Nn(l,s,a),uc(l,s,a)),s={cache:ap()},i.payload=s;return}s=s.return}}function ST(i,s,a){var l=Wn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ed(i)?vy(s,a):(a=Xf(i,s,a,l),a!==null&&(Nn(a,i,l),_y(a,s,l)))}function gy(i,s,a){var l=Wn();mc(i,s,a,l)}function mc(i,s,a,l){var d={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ed(i))vy(s,d);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var _=s.lastRenderedState,T=h(_,a);if(d.hasEagerState=!0,d.eagerState=T,Sn(T,_))return od(i,s,d,0),Wt===null&&ad(),!1}catch{}if(a=Xf(i,s,d,l),a!==null)return Nn(a,i,l),_y(a,s,l),!0}return!1}function Ap(i,s,a,l){if(l={lane:2,revertLane:um(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ed(i)){if(s)throw Error(r(479))}else s=Xf(i,a,l,2),s!==null&&Nn(s,i,2)}function Ed(i){var s=i.alternate;return i===ot||s!==null&&s===ot}function vy(i,s){tl=yd=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function _y(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,Qt(i,a)}}var gc={readContext:sn,use:Cd,useCallback:ui,useContext:ui,useEffect:ui,useImperativeHandle:ui,useLayoutEffect:ui,useInsertionEffect:ui,useMemo:ui,useReducer:ui,useRef:ui,useState:ui,useDebugValue:ui,useDeferredValue:ui,useTransition:ui,useSyncExternalStore:ui,useId:ui,useHostTransitionStatus:ui,useFormState:ui,useActionState:ui,useOptimistic:ui,useMemoCache:ui,useCacheRefresh:ui};gc.useEffectEvent=ui;var by={readContext:sn,use:Cd,useCallback:function(i,s){return wn().memoizedState=[i,s===void 0?null:s],i},useContext:sn,useEffect:iy,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,kd(4194308,4,ay.bind(null,s,i),a)},useLayoutEffect:function(i,s){return kd(4194308,4,i,s)},useInsertionEffect:function(i,s){kd(4,2,i,s)},useMemo:function(i,s){var a=wn();s=s===void 0?null:s;var l=i();if(oo){xt(!0);try{i()}finally{xt(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=wn();if(a!==void 0){var d=a(s);if(oo){xt(!0);try{a(s)}finally{xt(!1)}}}else d=s;return l.memoizedState=l.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},l.queue=i,i=i.dispatch=ST.bind(null,ot,i),[l.memoizedState,i]},useRef:function(i){var s=wn();return i={current:i},s.memoizedState=i},useState:function(i){i=kp(i);var s=i.queue,a=gy.bind(null,ot,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:Dp,useDeferredValue:function(i,s){var a=wn();return Rp(a,i,s)},useTransition:function(){var i=kp(!1);return i=dy.bind(null,ot,i.queue,!0,!1),wn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=ot,d=wn();if(St){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Wt===null)throw Error(r(349));(bt&127)!==0||Hb(l,s,a)}d.memoizedState=a;var h={value:a,getSnapshot:s};return d.queue=h,iy(Kb.bind(null,l,h,i),[i]),l.flags|=2048,nl(9,{destroy:void 0},Ub.bind(null,l,h,a,s),null),a},useId:function(){var i=wn(),s=Wt.identifierPrefix;if(St){var a=zs,l=Is;a=(l&~(1<<32-lt(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Sd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=pT++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:Np,useFormState:Zb,useActionState:Zb,useOptimistic:function(i){var s=wn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=Ap.bind(null,ot,!0,a),a.dispatch=s,[i,s]},useMemoCache:wp,useCacheRefresh:function(){return wn().memoizedState=yT.bind(null,ot)},useEffectEvent:function(i){var s=wn(),a={impl:i};return s.memoizedState=a,function(){if((Et&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Lp={readContext:sn,use:Cd,useCallback:ly,useContext:sn,useEffect:Ep,useImperativeHandle:oy,useInsertionEffect:sy,useLayoutEffect:ry,useMemo:cy,useReducer:xd,useRef:ty,useState:function(){return xd(pr)},useDebugValue:Dp,useDeferredValue:function(i,s){var a=wi();return uy(a,Lt.memoizedState,i,s)},useTransition:function(){var i=xd(pr)[0],s=wi().memoizedState;return[typeof i=="boolean"?i:pc(i),s]},useSyncExternalStore:Pb,useId:py,useHostTransitionStatus:Np,useFormState:Qb,useActionState:Qb,useOptimistic:function(i,s){var a=wi();return $b(a,Lt,i,s)},useMemoCache:wp,useCacheRefresh:my};Lp.useEffectEvent=ny;var yy={readContext:sn,use:Cd,useCallback:ly,useContext:sn,useEffect:Ep,useImperativeHandle:oy,useInsertionEffect:sy,useLayoutEffect:ry,useMemo:cy,useReducer:xp,useRef:ty,useState:function(){return xp(pr)},useDebugValue:Dp,useDeferredValue:function(i,s){var a=wi();return Lt===null?Rp(a,i,s):uy(a,Lt.memoizedState,i,s)},useTransition:function(){var i=xp(pr)[0],s=wi().memoizedState;return[typeof i=="boolean"?i:pc(i),s]},useSyncExternalStore:Pb,useId:py,useHostTransitionStatus:Np,useFormState:ey,useActionState:ey,useOptimistic:function(i,s){var a=wi();return Lt!==null?$b(a,Lt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:wp,useCacheRefresh:my};yy.useEffectEvent=ny;function Op(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 Bp={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=na(l);d.payload=s,a!=null&&(d.callback=a),s=sa(i,d,l),s!==null&&(Nn(s,i,l),uc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=na(l);d.tag=1,d.payload=s,a!=null&&(d.callback=a),s=sa(i,d,l),s!==null&&(Nn(s,i,l),uc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Wn(),l=na(a);l.tag=2,s!=null&&(l.callback=s),s=sa(i,l,a),s!==null&&(Nn(s,i,a),uc(s,i,a))}};function Sy(i,s,a,l,d,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):s.prototype&&s.prototype.isPureReactComponent?!Zr(a,l)||!Zr(d,h):!0}function wy(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&&Bp.enqueueReplaceState(s,s.state,null)}function lo(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var d in i)a[d]===void 0&&(a[d]=i[d])}return a}function Cy(i){rd(i)}function xy(i){console.error(i)}function ky(i){rd(i)}function Dd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Ty(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function jp(i,s,a){return a=na(a),a.tag=3,a.payload={element:null},a.callback=function(){Dd(i,s)},a}function Ey(i){return i=na(i),i.tag=3,i}function Dy(i,s,a,l){var d=a.type.getDerivedStateFromError;if(typeof d=="function"){var h=l.value;i.payload=function(){return d(h)},i.callback=function(){Ty(s,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Ty(s,a,l),typeof d!="function"&&(ua===null?ua=new Set([this]):ua.add(this));var T=l.stack;this.componentDidCatch(l.value,{componentStack:T!==null?T:""})})}function wT(i,s,a,l,d){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Xo(s,a,d,!0),a=Pn.current,a!==null){switch(a.tag){case 31:case 13:return is===null?Hd():a.alternate===null&&di===0&&(di=3),a.flags&=-257,a.flags|=65536,a.lanes=d,l===md?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),om(i,l,d)),!1;case 22:return a.flags|=65536,l===md?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)),om(i,l,d)),!1}throw Error(r(435,a.tag))}return om(i,l,d),Hd(),!1}if(St)return s=Pn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=d,l!==tp&&(i=Error(r(422),{cause:l}),rc(Qn(i,a)))):(l!==tp&&(s=Error(r(423),{cause:l}),rc(Qn(s,a))),i=i.current.alternate,i.flags|=65536,d&=-d,i.lanes|=d,l=Qn(l,a),d=jp(i.stateNode,l,d),hp(i,d),di!==4&&(di=2)),!1;var h=Error(r(520),{cause:l});if(h=Qn(h,a),xc===null?xc=[h]:xc.push(h),di!==4&&(di=2),s===null)return!0;l=Qn(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=d&-d,a.lanes|=i,i=jp(a.stateNode,l,i),hp(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"&&(ua===null||!ua.has(h))))return a.flags|=65536,d&=-d,a.lanes|=d,d=Ey(d),Dy(d,i,a,l),hp(a,d),!1}a=a.return}while(a!==null);return!1}var Ip=Error(r(461)),Di=!1;function rn(i,s,a,l){s.child=i===null?Ab(s,null,a,l):ao(s,i.child,a,l)}function Ry(i,s,a,l,d){a=a.render;var h=s.ref;if("ref"in l){var _={};for(var T in l)T!=="ref"&&(_[T]=l[T])}else _=l;return io(s),l=_p(i,s,a,_,h,d),T=bp(),i!==null&&!Di?(yp(i,s,d),mr(i,s,d)):(St&&T&&Jf(s),s.flags|=1,rn(i,s,l,d),s.child)}function My(i,s,a,l,d){if(i===null){var h=a.type;return typeof h=="function"&&!Gf(h)&&h.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=h,Ny(i,s,h,l,d)):(i=cd(a.type,null,l,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(h=i.child,!$p(i,d)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Zr,a(_,l)&&i.ref===s.ref)return mr(i,s,d)}return s.flags|=1,i=cr(h,l),i.ref=s.ref,i.return=s,s.child=i}function Ny(i,s,a,l,d){if(i!==null){var h=i.memoizedProps;if(Zr(h,l)&&i.ref===s.ref)if(Di=!1,s.pendingProps=l=h,$p(i,d))(i.flags&131072)!==0&&(Di=!0);else return s.lanes=i.lanes,mr(i,s,d)}return zp(i,s,a,l,d)}function Ay(i,s,a,l){var d=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,d=0;l!==null;)d=d|l.lanes|l.childLanes,l=l.sibling;l=d&~h}else l=0,s.child=null;return Ly(i,s,h,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&fd(s,h!==null?h.cachePool:null),h!==null?Bb(s,h):pp(),jb(s);else return l=s.lanes=536870912,Ly(i,s,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(fd(s,h.cachePool),Bb(s,h),aa(),s.memoizedState=null):(i!==null&&fd(s,null),pp(),aa());return rn(i,s,d,a),s.child}function vc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function Ly(i,s,a,l,d){var h=lp();return h=h===null?null:{parent:Ti._currentValue,pool:h},s.memoizedState={baseLanes:a,cachePool:h},i!==null&&fd(s,null),pp(),jb(s),i!==null&&Xo(i,s,l,!0),s.childLanes=d,null}function Rd(i,s){return s=Nd({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function Oy(i,s,a){return ao(s,i.child,null,a),i=Rd(s,s.pendingProps),i.flags|=2,Hn(s),s.memoizedState=null,i}function CT(i,s,a){var l=s.pendingProps,d=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(St){if(l.mode==="hidden")return i=Rd(s,l),s.lanes=536870912,vc(null,i);if(gp(s),(i=Xt)?(i=qS(i,ts),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:Is,overflow:zs}:null,retryLane:536870912,hydrationErrors:null},a=vb(i),a.return=s,s.child=a,nn=s,Xt=null)):i=null,i===null)throw ea(s);return s.lanes=536870912,null}return Rd(s,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(gp(s),d)if(s.flags&256)s.flags&=-257,s=Oy(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Di||Xo(i,s,a,!1),d=(a&i.childLanes)!==0,Di||d){if(l=Wt,l!==null&&(_=Hi(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,Qa(i,_),Nn(l,i,_),Ip;Hd(),s=Oy(i,s,a)}else i=h.treeContext,Xt=ns(_.nextSibling),nn=s,St=!0,Jr=null,ts=!1,i!==null&&yb(s,i),s=Rd(s,l),s.flags|=4096;return s}return i=cr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Md(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 zp(i,s,a,l,d){return io(s),a=_p(i,s,a,l,void 0,d),l=bp(),i!==null&&!Di?(yp(i,s,d),mr(i,s,d)):(St&&l&&Jf(s),s.flags|=1,rn(i,s,a,d),s.child)}function By(i,s,a,l,d,h){return io(s),s.updateQueue=null,a=zb(s,l,a,d),Ib(i),l=bp(),i!==null&&!Di?(yp(i,s,h),mr(i,s,h)):(St&&l&&Jf(s),s.flags|=1,rn(i,s,a,h),s.child)}function jy(i,s,a,l,d){if(io(s),s.stateNode===null){var h=$o,_=a.contextType;typeof _=="object"&&_!==null&&(h=sn(_)),h=new a(l,h),s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Bp,s.stateNode=h,h._reactInternals=s,h=s.stateNode,h.props=l,h.state=s.memoizedState,h.refs={},up(s),_=a.contextType,h.context=typeof _=="object"&&_!==null?sn(_):$o,h.state=s.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Op(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&&Bp.enqueueReplaceState(h,h.state,null),hc(s,l,h,d),dc(),h.state=s.memoizedState),typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){h=s.stateNode;var T=s.memoizedProps,A=lo(a,T);h.props=A;var G=h.context,de=a.contextType;_=$o,typeof de=="object"&&de!==null&&(_=sn(de));var ge=a.getDerivedStateFromProps;de=typeof ge=="function"||typeof h.getSnapshotBeforeUpdate=="function",T=s.pendingProps!==T,de||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(T||G!==_)&&wy(s,h,l,_),ia=!1;var J=s.memoizedState;h.state=J,hc(s,l,h,d),dc(),G=s.memoizedState,T||J!==G||ia?(typeof ge=="function"&&(Op(s,a,ge,l),G=s.memoizedState),(A=ia||Sy(s,a,A,l,J,G,_))?(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=G),h.props=l,h.state=G,h.context=_,l=A):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{h=s.stateNode,dp(i,s),_=s.memoizedProps,de=lo(a,_),h.props=de,ge=s.pendingProps,J=h.context,G=a.contextType,A=$o,typeof G=="object"&&G!==null&&(A=sn(G)),T=a.getDerivedStateFromProps,(G=typeof T=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==ge||J!==A)&&wy(s,h,l,A),ia=!1,J=s.memoizedState,h.state=J,hc(s,l,h,d),dc();var oe=s.memoizedState;_!==ge||J!==oe||ia||i!==null&&i.dependencies!==null&&dd(i.dependencies)?(typeof T=="function"&&(Op(s,a,T,l),oe=s.memoizedState),(de=ia||Sy(s,a,de,l,J,oe,A)||i!==null&&i.dependencies!==null&&dd(i.dependencies))?(G||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,Md(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=ao(s,i.child,null,d),s.child=ao(s,null,a,d)):rn(i,s,a,d),s.memoizedState=h.state,i=s.child):i=mr(i,s,d),i}function Iy(i,s,a,l){return eo(),s.flags|=256,rn(i,s,a,l),s.child}var Pp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hp(i){return{baseLanes:i,cachePool:Tb()}}function Up(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Kn),i}function zy(i,s,a){var l=s.pendingProps,d=!1,h=(s.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(Si.current&2)!==0),_&&(d=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,i===null){if(St){if(d?ra(s):aa(),(i=Xt)?(i=qS(i,ts),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:Is,overflow:zs}:null,retryLane:536870912,hydrationErrors:null},a=vb(i),a.return=s,s.child=a,nn=s,Xt=null)):i=null,i===null)throw ea(s);return Cm(i)?s.lanes=32:s.lanes=536870912,null}var T=l.children;return l=l.fallback,d?(aa(),d=s.mode,T=Nd({mode:"hidden",children:T},d),l=Ja(l,d,a,null),T.return=s,l.return=s,T.sibling=l,s.child=T,l=s.child,l.memoizedState=Hp(a),l.childLanes=Up(i,_,a),s.memoizedState=Pp,vc(null,l)):(ra(s),Kp(s,T))}var A=i.memoizedState;if(A!==null&&(T=A.dehydrated,T!==null)){if(h)s.flags&256?(ra(s),s.flags&=-257,s=Wp(i,s,a)):s.memoizedState!==null?(aa(),s.child=i.child,s.flags|=128,s=null):(aa(),T=l.fallback,d=s.mode,l=Nd({mode:"visible",children:l.children},d),T=Ja(T,d,a,null),T.flags|=2,l.return=s,T.return=s,l.sibling=T,s.child=l,ao(s,i.child,null,a),l=s.child,l.memoizedState=Hp(a),l.childLanes=Up(i,_,a),s.memoizedState=Pp,s=vc(null,l));else if(ra(s),Cm(T)){if(_=T.nextSibling&&T.nextSibling.dataset,_)var G=_.dgst;_=G,l=Error(r(419)),l.stack="",l.digest=_,rc({value:l,source:null,stack:null}),s=Wp(i,s,a)}else if(Di||Xo(i,s,a,!1),_=(a&i.childLanes)!==0,Di||_){if(_=Wt,_!==null&&(l=Hi(_,a),l!==0&&l!==A.retryLane))throw A.retryLane=l,Qa(i,l),Nn(_,i,l),Ip;wm(T)||Hd(),s=Wp(i,s,a)}else wm(T)?(s.flags|=192,s.child=i.child,s=null):(i=A.treeContext,Xt=ns(T.nextSibling),nn=s,St=!0,Jr=null,ts=!1,i!==null&&yb(s,i),s=Kp(s,l.children),s.flags|=4096);return s}return d?(aa(),T=l.fallback,d=s.mode,A=i.child,G=A.sibling,l=cr(A,{mode:"hidden",children:l.children}),l.subtreeFlags=A.subtreeFlags&65011712,G!==null?T=cr(G,T):(T=Ja(T,d,a,null),T.flags|=2),T.return=s,l.return=s,l.sibling=T,s.child=l,vc(null,l),l=s.child,T=i.child.memoizedState,T===null?T=Hp(a):(d=T.cachePool,d!==null?(A=Ti._currentValue,d=d.parent!==A?{parent:A,pool:A}:d):d=Tb(),T={baseLanes:T.baseLanes|a,cachePool:d}),l.memoizedState=T,l.childLanes=Up(i,_,a),s.memoizedState=Pp,vc(i.child,l)):(ra(s),a=i.child,i=a.sibling,a=cr(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 Kp(i,s){return s=Nd({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function Nd(i,s){return i=zn(22,i,null,s),i.lanes=0,i}function Wp(i,s,a){return ao(s,i.child,null,a),i=Kp(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function Py(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),sp(i.return,s,a)}function Fp(i,s,a,l,d,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:d,treeForkCount:h}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=d,_.treeForkCount=h)}function Hy(i,s,a){var l=s.pendingProps,d=l.revealOrder,h=l.tail;l=l.children;var _=Si.current,T=(_&2)!==0;if(T?(_=_&1|2,s.flags|=128):_&=1,ce(Si,_),rn(i,s,l,a),l=St?sc:0,!T&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Py(i,a,s);else if(i.tag===19)Py(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&bd(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),Fp(s,!1,d,a,h,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&bd(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}Fp(s,!0,a,null,h,l);break;case"together":Fp(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function mr(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),ca|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Xo(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=cr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=cr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function $p(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&dd(i)))}function xT(i,s,a){switch(s.tag){case 3:Re(s,s.stateNode.containerInfo),ta(s,Ti,i.memoizedState.cache),eo();break;case 27:case 5:Fe(s);break;case 4:Re(s,s.stateNode.containerInfo);break;case 10:ta(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,gp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(ra(s),s.flags|=128,null):(a&s.child.childLanes)!==0?zy(i,s,a):(ra(s),i=mr(i,s,a),i!==null?i.sibling:null);ra(s);break;case 19:var d=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Xo(i,s,a,!1),l=(a&s.childLanes)!==0),d){if(l)return Hy(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),ce(Si,Si.current),l)break;return null;case 22:return s.lanes=0,Ay(i,s,a,s.pendingProps);case 24:ta(s,Ti,i.memoizedState.cache)}return mr(i,s,a)}function Uy(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Di=!0;else{if(!$p(i,a)&&(s.flags&128)===0)return Di=!1,xT(i,s,a);Di=(i.flags&131072)!==0}else Di=!1,St&&(s.flags&1048576)!==0&&bb(s,sc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=so(s.elementType),s.type=i,typeof i=="function")Gf(i)?(l=lo(i,l),s.tag=1,s=jy(null,s,i,l,a)):(s.tag=0,s=zp(null,s,i,l,a));else{if(i!=null){var d=i.$$typeof;if(d===F){s.tag=11,s=Ry(null,s,i,l,a);break e}else if(d===$){s.tag=14,s=My(null,s,i,l,a);break e}}throw s=W(i)||i,Error(r(306,s,""))}}return s;case 0:return zp(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,d=lo(l,s.pendingProps),jy(i,s,l,d,a);case 3:e:{if(Re(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var h=s.memoizedState;d=h.element,dp(i,s),hc(s,l,null,a);var _=s.memoizedState;if(l=_.cache,ta(s,Ti,l),l!==h.cache&&rp(s,[Ti],a,!0),dc(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){s=Iy(i,s,l,a);break e}else if(l!==d){d=Qn(Error(r(424)),s),rc(d),s=Iy(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=ns(i.firstChild),nn=s,St=!0,Jr=null,ts=!0,a=Ab(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(eo(),l===d){s=mr(i,s,a);break e}rn(i,s,l,a)}s=s.child}return s;case 26:return Md(i,s),i===null?(a=QS(s.type,null,s.pendingProps,null))?s.memoizedState=a:St||(a=s.type,i=s.pendingProps,l=Vd(xe.current).createElement(a),l[vi]=s,l[_i]=i,an(l,a,i),At(l),s.stateNode=l):s.memoizedState=QS(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return Fe(s),i===null&&St&&(l=s.stateNode=XS(s.type,s.pendingProps,xe.current),nn=s,ts=!0,d=Xt,pa(s.type)?(xm=d,Xt=ns(l.firstChild)):Xt=d),rn(i,s,s.pendingProps.children,a),Md(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&St&&((d=l=Xt)&&(l=eE(l,s.type,s.pendingProps,ts),l!==null?(s.stateNode=l,nn=s,Xt=ns(l.firstChild),ts=!1,d=!0):d=!1),d||ea(s)),Fe(s),d=s.type,h=s.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,bm(d,h)?l=null:_!==null&&bm(d,_)&&(s.flags|=32),s.memoizedState!==null&&(d=_p(i,s,mT,null,null,a),Ac._currentValue=d),Md(i,s),rn(i,s,l,a),s.child;case 6:return i===null&&St&&((i=a=Xt)&&(a=tE(a,s.pendingProps,ts),a!==null?(s.stateNode=a,nn=s,Xt=null,i=!0):i=!1),i||ea(s)),null;case 13:return zy(i,s,a);case 4:return Re(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=ao(s,null,l,a):rn(i,s,l,a),s.child;case 11:return Ry(i,s,s.type,s.pendingProps,a);case 7:return rn(i,s,s.pendingProps,a),s.child;case 8:return rn(i,s,s.pendingProps.children,a),s.child;case 12:return rn(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,ta(s,s.type,l.value),rn(i,s,l.children,a),s.child;case 9:return d=s.type._context,l=s.pendingProps.children,io(s),d=sn(d),l=l(d),s.flags|=1,rn(i,s,l,a),s.child;case 14:return My(i,s,s.type,s.pendingProps,a);case 15:return Ny(i,s,s.type,s.pendingProps,a);case 19:return Hy(i,s,a);case 31:return CT(i,s,a);case 22:return Ay(i,s,a,s.pendingProps);case 24:return io(s),l=sn(Ti),i===null?(d=lp(),d===null&&(d=Wt,h=ap(),d.pooledCache=h,h.refCount++,h!==null&&(d.pooledCacheLanes|=a),d=h),s.memoizedState={parent:l,cache:d},up(s),ta(s,Ti,d)):((i.lanes&a)!==0&&(dp(i,s),hc(s,null,null,a),dc()),d=i.memoizedState,h=s.memoizedState,d.parent!==l?(d={parent:l,cache:l},s.memoizedState=d,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=d),ta(s,Ti,l)):(l=h.cache,ta(s,Ti,l),l!==d.cache&&rp(s,[Ti],a,!0))),rn(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function gr(i){i.flags|=4}function qp(i,s,a,l,d){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(d&335544128)===d)if(i.stateNode.complete)i.flags|=8192;else if(pS())i.flags|=8192;else throw ro=md,cp}else i.flags&=-16777217}function Ky(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!n0(s))if(pS())i.flags|=8192;else throw ro=md,cp}function Ad(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Vt():536870912,i.lanes|=s,ol|=s)}function _c(i,s){if(!St)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 d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags&65011712,l|=d.flags&65011712,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function kT(i,s,a){var l=s.pendingProps;switch(ep(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),hr(Ti),He(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Yo(s)?gr(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,ip())),Gt(s),null;case 26:var d=s.type,h=s.memoizedState;return i===null?(gr(s),h!==null?(Gt(s),Ky(s,h)):(Gt(s),qp(s,d,null,l,a))):h?h!==i.memoizedState?(gr(s),Gt(s),Ky(s,h)):(Gt(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&gr(s),Gt(s),qp(s,d,i,l,a)),null;case 27:if(ee(s),a=xe.current,d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Gt(s),null}i=we.current,Yo(s)?Sb(s):(i=XS(d,l,a),s.stateNode=i,gr(s))}return Gt(s),null;case 5:if(ee(s),d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Gt(s),null}if(h=we.current,Yo(s))Sb(s);else{var _=Vd(xe.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);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(d,{is:l.is}):_.createElement(d)}}h[vi]=s,h[_i]=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(an(h,d,l),d){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&gr(s)}}return Gt(s),qp(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&gr(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=xe.current,Yo(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,d=nn,d!==null)switch(d.tag){case 27:case 5:l=d.memoizedProps}i[vi]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||zS(i.nodeValue,a)),i||ea(s,!0)}else i=Vd(i).createTextNode(l),i[vi]=s,s.stateNode=i}return Gt(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=Yo(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[vi]=s}else eo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Gt(s),i=!1}else a=ip(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Hn(s),s):(Hn(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(d=Yo(s),l!==null&&l.dehydrated!==null){if(i===null){if(!d)throw Error(r(318));if(d=s.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[vi]=s}else eo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Gt(s),d=!1}else d=ip(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return s.flags&256?(Hn(s),s):(Hn(s),null)}return Hn(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,d=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(d=l.alternate.memoizedState.cachePool.pool),h=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(h=l.memoizedState.cachePool.pool),h!==d&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Ad(s,s.updateQueue),Gt(s),null);case 4:return He(),i===null&&pm(s.stateNode.containerInfo),Gt(s),null;case 10:return hr(s.type),Gt(s),null;case 19:if(K(Si),l=s.memoizedState,l===null)return Gt(s),null;if(d=(s.flags&128)!==0,h=l.rendering,h===null)if(d)_c(l,!1);else{if(di!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(h=bd(i),h!==null){for(s.flags|=128,_c(l,!1),i=h.updateQueue,s.updateQueue=i,Ad(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)gb(a,i),a=a.sibling;return ce(Si,Si.current&1|2),St&&ur(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&zt()>Id&&(s.flags|=128,d=!0,_c(l,!1),s.lanes=4194304)}else{if(!d)if(i=bd(h),i!==null){if(s.flags|=128,d=!0,i=i.updateQueue,s.updateQueue=i,Ad(s,i),_c(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!St)return Gt(s),null}else 2*zt()-l.renderingStartTime>Id&&a!==536870912&&(s.flags|=128,d=!0,_c(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=zt(),i.sibling=null,a=Si.current,ce(Si,d?a&1|2:a&1),St&&ur(s,l.treeForkCount),i):(Gt(s),null);case 22:case 23:return Hn(s),mp(),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&&Ad(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(no),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),hr(Ti),Gt(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function TT(i,s){switch(ep(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return hr(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 ee(s),null;case 31:if(s.memoizedState!==null){if(Hn(s),s.alternate===null)throw Error(r(340));eo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Hn(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));eo()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return K(Si),null;case 4:return He(),null;case 10:return hr(s.type),null;case 22:case 23:return Hn(s),mp(),i!==null&&K(no),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return hr(Ti),null;case 25:return null;default:return null}}function Wy(i,s){switch(ep(s),s.tag){case 3:hr(Ti),He();break;case 26:case 27:case 5:ee(s);break;case 4:He();break;case 31:s.memoizedState!==null&&Hn(s);break;case 13:Hn(s);break;case 19:K(Si);break;case 10:hr(s.type);break;case 22:case 23:Hn(s),mp(),i!==null&&K(no);break;case 24:hr(Ti)}}function bc(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var d=l.next;a=d;do{if((a.tag&i)===i){l=void 0;var h=a.create,_=a.inst;l=h(),_.destroy=l}a=a.next}while(a!==d)}}catch(T){Nt(s,s.return,T)}}function oa(i,s,a){try{var l=s.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var h=d.next;l=h;do{if((l.tag&i)===i){var _=l.inst,T=_.destroy;if(T!==void 0){_.destroy=void 0,d=s;var A=a,G=T;try{G()}catch(de){Nt(d,A,de)}}}l=l.next}while(l!==h)}}catch(de){Nt(s,s.return,de)}}function Fy(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{Ob(s,a)}catch(l){Nt(i,i.return,l)}}}function $y(i,s,a){a.props=lo(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){Nt(i,s,l)}}function yc(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(d){Nt(i,s,d)}}function Ps(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(d){Nt(i,s,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(d){Nt(i,s,d)}else a.current=null}function qy(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(d){Nt(i,i.return,d)}}function Vp(i,s,a){try{var l=i.stateNode;YT(l,i.type,a,s),l[_i]=s}catch(d){Nt(i,i.return,d)}}function Vy(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&pa(i.type)||i.tag===4}function Yp(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&&pa(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 Xp(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=Yn));else if(l!==4&&(l===27&&pa(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(Xp(i,s,a),i=i.sibling;i!==null;)Xp(i,s,a),i=i.sibling}function Ld(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&&pa(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Ld(i,s,a),i=i.sibling;i!==null;)Ld(i,s,a),i=i.sibling}function Yy(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,d=s.attributes;d.length;)s.removeAttributeNode(d[0]);an(s,l,a),s[vi]=i,s[_i]=a}catch(h){Nt(i,i.return,h)}}var vr=!1,Ri=!1,Gp=!1,Xy=typeof WeakSet=="function"?WeakSet:Set,Fi=null;function ET(i,s){if(i=i.containerInfo,vm=eh,i=sd(i),Za(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,T=-1,A=-1,G=0,de=0,ge=i,J=null;t:for(;;){for(var oe;ge!==a||d!==0&&ge.nodeType!==3||(T=_+d),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&&++G===d&&(T=_),J===h&&++de===l&&(A=_),(oe=ge.nextSibling)!==null)break;ge=J,J=ge.parentNode}ge=oe}a=T===-1||A===-1?null:{start:T,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(_m={focusedElem:i,selectionRange:a},eh=!1,Fi=s;Fi!==null;)if(s=Fi,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,Fi=i;else for(;Fi!==null;){switch(s=Fi,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++)d=i[a],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=s,d=h.memoizedProps,h=h.memoizedState,l=a.stateNode;try{var Pe=lo(a.type,d);i=l.getSnapshotBeforeUpdate(Pe,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Ze){Nt(a,a.return,Ze)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Sm(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Sm(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,Fi=i;break}Fi=s.return}}function Gy(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:br(i,a),l&4&&bc(5,a);break;case 1:if(br(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(_){Nt(a,a.return,_)}else{var d=lo(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(d,s,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Nt(a,a.return,_)}}l&64&&Fy(a),l&512&&yc(a,a.return);break;case 3:if(br(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{Ob(i,s)}catch(_){Nt(a,a.return,_)}}break;case 27:s===null&&l&4&&Yy(a);case 26:case 5:br(i,a),s===null&&l&4&&qy(a),l&512&&yc(a,a.return);break;case 12:br(i,a);break;case 31:br(i,a),l&4&&Jy(i,a);break;case 13:br(i,a),l&4&&eS(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=jT.bind(null,a),iE(i,a))));break;case 22:if(l=a.memoizedState!==null||vr,!l){s=s!==null&&s.memoizedState!==null||Ri,d=vr;var h=Ri;vr=l,(Ri=s)&&!h?yr(i,a,(a.subtreeFlags&8772)!==0):br(i,a),vr=d,Ri=h}break;case 30:break;default:br(i,a)}}function Zy(i){var s=i.alternate;s!==null&&(i.alternate=null,Zy(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&Zs(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,En=!1;function _r(i,s,a){for(a=a.child;a!==null;)Qy(i,s,a),a=a.sibling}function Qy(i,s,a){if(Xe&&typeof Xe.onCommitFiberUnmount=="function")try{Xe.onCommitFiberUnmount(nt,a)}catch{}switch(a.tag){case 26:Ri||Ps(a,s),_r(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ri||Ps(a,s);var l=ei,d=En;pa(a.type)&&(ei=a.stateNode,En=!1),_r(i,s,a),Rc(a.stateNode),ei=l,En=d;break;case 5:Ri||Ps(a,s);case 6:if(l=ei,d=En,ei=null,_r(i,s,a),ei=l,En=d,ei!==null)if(En)try{(ei.nodeType===9?ei.body:ei.nodeName==="HTML"?ei.ownerDocument.body:ei).removeChild(a.stateNode)}catch(h){Nt(a,s,h)}else try{ei.removeChild(a.stateNode)}catch(h){Nt(a,s,h)}break;case 18:ei!==null&&(En?(i=ei,FS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),ml(i)):FS(ei,a.stateNode));break;case 4:l=ei,d=En,ei=a.stateNode.containerInfo,En=!0,_r(i,s,a),ei=l,En=d;break;case 0:case 11:case 14:case 15:oa(2,a,s),Ri||oa(4,a,s),_r(i,s,a);break;case 1:Ri||(Ps(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&$y(a,s,l)),_r(i,s,a);break;case 21:_r(i,s,a);break;case 22:Ri=(l=Ri)||a.memoizedState!==null,_r(i,s,a),Ri=l;break;default:_r(i,s,a)}}function Jy(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{ml(i)}catch(a){Nt(s,s.return,a)}}}function eS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{ml(i)}catch(a){Nt(s,s.return,a)}}function DT(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new Xy),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new Xy),s;default:throw Error(r(435,i.tag))}}function Od(i,s){var a=DT(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var d=IT.bind(null,i,l);l.then(d,d)}})}function Dn(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var d=a[l],h=i,_=s,T=_;e:for(;T!==null;){switch(T.tag){case 27:if(pa(T.type)){ei=T.stateNode,En=!1;break e}break;case 5:ei=T.stateNode,En=!1;break e;case 3:case 4:ei=T.stateNode.containerInfo,En=!0;break e}T=T.return}if(ei===null)throw Error(r(160));Qy(h,_,d),ei=null,En=!1,h=d.alternate,h!==null&&(h.return=null),d.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)tS(s,i),s=s.sibling}var Ss=null;function tS(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Dn(s,i),Rn(i),l&4&&(oa(3,i,i.return),bc(3,i),oa(5,i,i.return));break;case 1:Dn(s,i),Rn(i),l&512&&(Ri||a===null||Ps(a,a.return)),l&64&&vr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var d=Ss;if(Dn(s,i),Rn(i),l&512&&(Ri||a===null||Ps(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,d=d.ownerDocument||d;t:switch(l){case"title":h=d.getElementsByTagName("title")[0],(!h||h[ds]||h[vi]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=d.createElement(l),d.head.insertBefore(h,d.querySelector("head > title"))),an(h,l,a),h[vi]=i,At(h),l=h;break e;case"link":var _=t0("link","href",d).get(l+(a.href||""));if(_){for(var T=0;T<_.length;T++)if(h=_[T],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(T,1);break t}}h=d.createElement(l),an(h,l,a),d.head.appendChild(h);break;case"meta":if(_=t0("meta","content",d).get(l+(a.content||""))){for(T=0;T<_.length;T++)if(h=_[T],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(T,1);break t}}h=d.createElement(l),an(h,l,a),d.head.appendChild(h);break;default:throw Error(r(468,l))}h[vi]=i,At(h),l=h}i.stateNode=l}else i0(d,i.type,i.stateNode);else i.stateNode=e0(d,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?i0(d,i.type,i.stateNode):e0(d,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Vp(i,i.memoizedProps,a.memoizedProps)}break;case 27:Dn(s,i),Rn(i),l&512&&(Ri||a===null||Ps(a,a.return)),a!==null&&l&4&&Vp(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Dn(s,i),Rn(i),l&512&&(Ri||a===null||Ps(a,a.return)),i.flags&32){d=i.stateNode;try{un(d,"")}catch(Pe){Nt(i,i.return,Pe)}}l&4&&i.stateNode!=null&&(d=i.memoizedProps,Vp(i,d,a!==null?a.memoizedProps:d)),l&1024&&(Gp=!0);break;case 6:if(Dn(s,i),Rn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Pe){Nt(i,i.return,Pe)}}break;case 3:if(Gd=null,d=Ss,Ss=Yd(s.containerInfo),Dn(s,i),Ss=d,Rn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{ml(s.containerInfo)}catch(Pe){Nt(i,i.return,Pe)}Gp&&(Gp=!1,iS(i));break;case 4:l=Ss,Ss=Yd(i.stateNode.containerInfo),Dn(s,i),Rn(i),Ss=l;break;case 12:Dn(s,i),Rn(i);break;case 31:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Od(i,l)));break;case 13:Dn(s,i),Rn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(jd=zt()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Od(i,l)));break;case 22:d=i.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,G=vr,de=Ri;if(vr=G||d,Ri=de||A,Dn(s,i),Ri=de,vr=G,Rn(i),l&8192)e:for(s=i.stateNode,s._visibility=d?s._visibility&-2:s._visibility|1,d&&(a===null||A||vr||Ri||co(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){A=a=s;try{if(h=A.stateNode,d)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{T=A.stateNode;var ge=A.memoizedProps.style,J=ge!=null&&ge.hasOwnProperty("display")?ge.display:null;T.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(Pe){Nt(A,A.return,Pe)}}}else if(s.tag===6){if(a===null){A=s;try{A.stateNode.nodeValue=d?"":A.memoizedProps}catch(Pe){Nt(A,A.return,Pe)}}}else if(s.tag===18){if(a===null){A=s;try{var oe=A.stateNode;d?$S(oe,!0):$S(A.stateNode,!1)}catch(Pe){Nt(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,Od(i,a))));break;case 19:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Od(i,l)));break;case 30:break;case 21:break;default:Dn(s,i),Rn(i)}}function Rn(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 d=a.stateNode,h=Yp(i);Ld(i,h,d);break;case 5:var _=a.stateNode;a.flags&32&&(un(_,""),a.flags&=-33);var T=Yp(i);Ld(i,T,_);break;case 3:case 4:var A=a.stateNode.containerInfo,G=Yp(i);Xp(i,G,A);break;default:throw Error(r(161))}}catch(de){Nt(i,i.return,de)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function iS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;iS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function br(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)Gy(i,s.alternate,s),s=s.sibling}function co(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:oa(4,s,s.return),co(s);break;case 1:Ps(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&$y(s,s.return,a),co(s);break;case 27:Rc(s.stateNode);case 26:case 5:Ps(s,s.return),co(s);break;case 22:s.memoizedState===null&&co(s);break;case 30:co(s);break;default:co(s)}i=i.sibling}}function yr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,d=i,h=s,_=h.flags;switch(h.tag){case 0:case 11:case 15:yr(d,h,a),bc(4,h);break;case 1:if(yr(d,h,a),l=h,d=l.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(G){Nt(l,l.return,G)}if(l=h,d=l.updateQueue,d!==null){var T=l.stateNode;try{var A=d.shared.hiddenCallbacks;if(A!==null)for(d.shared.hiddenCallbacks=null,d=0;d<A.length;d++)Lb(A[d],T)}catch(G){Nt(l,l.return,G)}}a&&_&64&&Fy(h),yc(h,h.return);break;case 27:Yy(h);case 26:case 5:yr(d,h,a),a&&l===null&&_&4&&qy(h),yc(h,h.return);break;case 12:yr(d,h,a);break;case 31:yr(d,h,a),a&&_&4&&Jy(d,h);break;case 13:yr(d,h,a),a&&_&4&&eS(d,h);break;case 22:h.memoizedState===null&&yr(d,h,a),yc(h,h.return);break;case 30:break;default:yr(d,h,a)}s=s.sibling}}function Zp(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&&ac(a))}function Qp(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&ac(i))}function ws(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)nS(i,s,a,l),s=s.sibling}function nS(i,s,a,l){var d=s.flags;switch(s.tag){case 0:case 11:case 15:ws(i,s,a,l),d&2048&&bc(9,s);break;case 1:ws(i,s,a,l);break;case 3:ws(i,s,a,l),d&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&ac(i)));break;case 12:if(d&2048){ws(i,s,a,l),i=s.stateNode;try{var h=s.memoizedProps,_=h.id,T=h.onPostCommit;typeof T=="function"&&T(_,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(A){Nt(s,s.return,A)}}else ws(i,s,a,l);break;case 31:ws(i,s,a,l);break;case 13:ws(i,s,a,l);break;case 23:break;case 22:h=s.stateNode,_=s.alternate,s.memoizedState!==null?h._visibility&2?ws(i,s,a,l):Sc(i,s):h._visibility&2?ws(i,s,a,l):(h._visibility|=2,sl(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),d&2048&&Zp(_,s);break;case 24:ws(i,s,a,l),d&2048&&Qp(s.alternate,s);break;default:ws(i,s,a,l)}}function sl(i,s,a,l,d){for(d=d&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var h=i,_=s,T=a,A=l,G=_.flags;switch(_.tag){case 0:case 11:case 15:sl(h,_,T,A,d),bc(8,_);break;case 23:break;case 22:var de=_.stateNode;_.memoizedState!==null?de._visibility&2?sl(h,_,T,A,d):Sc(h,_):(de._visibility|=2,sl(h,_,T,A,d)),d&&G&2048&&Zp(_.alternate,_);break;case 24:sl(h,_,T,A,d),d&&G&2048&&Qp(_.alternate,_);break;default:sl(h,_,T,A,d)}s=s.sibling}}function Sc(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,d=l.flags;switch(l.tag){case 22:Sc(a,l),d&2048&&Zp(l.alternate,l);break;case 24:Sc(a,l),d&2048&&Qp(l.alternate,l);break;default:Sc(a,l)}s=s.sibling}}var wc=8192;function rl(i,s,a){if(i.subtreeFlags&wc)for(i=i.child;i!==null;)sS(i,s,a),i=i.sibling}function sS(i,s,a){switch(i.tag){case 26:rl(i,s,a),i.flags&wc&&i.memoizedState!==null&&pE(a,Ss,i.memoizedState,i.memoizedProps);break;case 5:rl(i,s,a);break;case 3:case 4:var l=Ss;Ss=Yd(i.stateNode.containerInfo),rl(i,s,a),Ss=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=wc,wc=16777216,rl(i,s,a),wc=l):rl(i,s,a));break;default:rl(i,s,a)}}function rS(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 Cc(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];Fi=l,oS(l,i)}rS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)aS(i),i=i.sibling}function aS(i){switch(i.tag){case 0:case 11:case 15:Cc(i),i.flags&2048&&oa(9,i,i.return);break;case 3:Cc(i);break;case 12:Cc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,Bd(i)):Cc(i);break;default:Cc(i)}}function Bd(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];Fi=l,oS(l,i)}rS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:oa(8,s,s.return),Bd(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,Bd(s));break;default:Bd(s)}i=i.sibling}}function oS(i,s){for(;Fi!==null;){var a=Fi;switch(a.tag){case 0:case 11:case 15:oa(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:ac(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Fi=l;else e:for(a=i;Fi!==null;){l=Fi;var d=l.sibling,h=l.return;if(Zy(l),l===a){Fi=null;break e}if(d!==null){d.return=h,Fi=d;break e}Fi=h}}}var RT={getCacheForType:function(i){var s=sn(Ti),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return sn(Ti).controller.signal}},MT=typeof WeakMap=="function"?WeakMap:Map,Et=0,Wt=null,vt=null,bt=0,Mt=0,Un=null,la=!1,al=!1,Jp=!1,Sr=0,di=0,ca=0,uo=0,em=0,Kn=0,ol=0,xc=null,Mn=null,tm=!1,jd=0,lS=0,Id=1/0,zd=null,ua=null,Oi=0,da=null,ll=null,wr=0,im=0,nm=null,cS=null,kc=0,sm=null;function Wn(){return(Et&2)!==0&&bt!==0?bt&-bt:L.T!==null?um():Jt()}function uS(){if(Kn===0)if((bt&536870912)===0||St){var i=it;it<<=1,(it&3932160)===0&&(it=262144),Kn=i}else Kn=536870912;return i=Pn.current,i!==null&&(i.flags|=32),Kn}function Nn(i,s,a){(i===Wt&&(Mt===2||Mt===9)||i.cancelPendingCommit!==null)&&(cl(i,0),ha(i,bt,Kn,!1)),ci(i,a),((Et&2)===0||i!==Wt)&&(i===Wt&&((Et&2)===0&&(uo|=a),di===4&&ha(i,bt,Kn,!1)),Hs(i))}function dS(i,s,a){if((Et&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Pt(i,s),d=l?LT(i,s):am(i,s,!0),h=l;do{if(d===0){al&&!l&&ha(i,s,0,!1);break}else{if(a=i.current.alternate,h&&!NT(a)){d=am(i,s,!1),h=!1;continue}if(d===2){if(h=s,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var T=i;d=xc;var A=T.current.memoizedState.isDehydrated;if(A&&(cl(T,_).flags|=256),_=am(T,_,!1),_!==2){if(Jp&&!A){T.errorRecoveryDisabledLanes|=h,uo|=h,d=4;break e}h=Mn,Mn=d,h!==null&&(Mn===null?Mn=h:Mn.push.apply(Mn,h))}d=_}if(h=!1,d!==2)continue}}if(d===1){cl(i,0),ha(i,s,0,!0);break}e:{switch(l=i,h=d,h){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:ha(l,s,Kn,!la);break e;case 2:Mn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(d=jd+300-zt(),10<d)){if(ha(l,s,Kn,!la),qt(l,0,!0)!==0)break e;wr=s,l.timeoutHandle=KS(hS.bind(null,l,a,Mn,zd,tm,s,Kn,uo,ol,la,h,"Throttled",-0,0),d);break e}hS(l,a,Mn,zd,tm,s,Kn,uo,ol,la,h,null,-0,0)}}break}while(!0);Hs(i)}function hS(i,s,a,l,d,h,_,T,A,G,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:Yn},sS(s,h,ge);var Pe=(h&62914560)===h?jd-zt():(h&4194048)===h?lS-zt():0;if(Pe=mE(ge,Pe),Pe!==null){wr=h,i.cancelPendingCommit=Pe(yS.bind(null,i,s,h,a,l,d,_,T,A,de,ge,null,J,oe)),ha(i,h,_,!G);return}}yS(i,s,h,a,l,d,_,T,A)}function NT(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var d=a[l],h=d.getSnapshot;d=d.value;try{if(!Sn(h(),d))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function ha(i,s,a,l){s&=~em,s&=~uo,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var d=s;0<d;){var h=31-lt(d),_=1<<h;l[h]=-1,d&=~_}a!==0&&ln(i,a,s)}function Pd(){return(Et&6)===0?(Tc(0),!1):!0}function rm(){if(vt!==null){if(Mt===0)var i=vt.return;else i=vt,dr=to=null,Sp(i),Jo=null,lc=0,i=vt;for(;i!==null;)Wy(i.alternate,i),i=i.return;vt=null}}function cl(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,ZT(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),wr=0,rm(),Wt=i,vt=a=cr(i.current,null),bt=s,Mt=0,Un=null,la=!1,al=Pt(i,s),Jp=!1,ol=Kn=em=uo=ca=di=0,Mn=xc=null,tm=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var d=31-lt(l),h=1<<d;s|=i[d],l&=~h}return Sr=s,ad(),a}function fS(i,s){ot=null,L.H=gc,s===Qo||s===pd?(s=Rb(),Mt=3):s===cp?(s=Rb(),Mt=4):Mt=s===Ip?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Un=s,vt===null&&(di=1,Dd(i,Qn(s,i.current)))}function pS(){var i=Pn.current;return i===null?!0:(bt&4194048)===bt?is===null:(bt&62914560)===bt||(bt&536870912)!==0?i===is:!1}function mS(){var i=L.H;return L.H=gc,i===null?gc:i}function gS(){var i=L.A;return L.A=RT,i}function Hd(){di=4,la||(bt&4194048)!==bt&&Pn.current!==null||(al=!0),(ca&134217727)===0&&(uo&134217727)===0||Wt===null||ha(Wt,bt,Kn,!1)}function am(i,s,a){var l=Et;Et|=2;var d=mS(),h=gS();(Wt!==i||bt!==s)&&(zd=null,cl(i,s)),s=!1;var _=di;e:do try{if(Mt!==0&&vt!==null){var T=vt,A=Un;switch(Mt){case 8:rm(),_=6;break e;case 3:case 2:case 9:case 6:Pn.current===null&&(s=!0);var G=Mt;if(Mt=0,Un=null,ul(i,T,A,G),a&&al){_=0;break e}break;default:G=Mt,Mt=0,Un=null,ul(i,T,A,G)}}AT(),_=di;break}catch(de){fS(i,de)}while(!0);return s&&i.shellSuspendCounter++,dr=to=null,Et=l,L.H=d,L.A=h,vt===null&&(Wt=null,bt=0,ad()),_}function AT(){for(;vt!==null;)vS(vt)}function LT(i,s){var a=Et;Et|=2;var l=mS(),d=gS();Wt!==i||bt!==s?(zd=null,Id=zt()+500,cl(i,s)):al=Pt(i,s);e:do try{if(Mt!==0&&vt!==null){s=vt;var h=Un;t:switch(Mt){case 1:Mt=0,Un=null,ul(i,s,h,1);break;case 2:case 9:if(Eb(h)){Mt=0,Un=null,_S(s);break}s=function(){Mt!==2&&Mt!==9||Wt!==i||(Mt=7),Hs(i)},h.then(s,s);break e;case 3:Mt=7;break e;case 4:Mt=5;break e;case 7:Eb(h)?(Mt=0,Un=null,_S(s)):(Mt=0,Un=null,ul(i,s,h,7));break;case 5:var _=null;switch(vt.tag){case 26:_=vt.memoizedState;case 5:case 27:var T=vt;if(_?n0(_):T.stateNode.complete){Mt=0,Un=null;var A=T.sibling;if(A!==null)vt=A;else{var G=T.return;G!==null?(vt=G,Ud(G)):vt=null}break t}}Mt=0,Un=null,ul(i,s,h,5);break;case 6:Mt=0,Un=null,ul(i,s,h,6);break;case 8:rm(),di=6;break e;default:throw Error(r(462))}}OT();break}catch(de){fS(i,de)}while(!0);return dr=to=null,L.H=l,L.A=d,Et=a,vt!==null?0:(Wt=null,bt=0,ad(),di)}function OT(){for(;vt!==null&&!Je();)vS(vt)}function vS(i){var s=Uy(i.alternate,i,Sr);i.memoizedProps=i.pendingProps,s===null?Ud(i):vt=s}function _S(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=By(a,s,s.pendingProps,s.type,void 0,bt);break;case 11:s=By(a,s,s.pendingProps,s.type.render,s.ref,bt);break;case 5:Sp(s);default:Wy(a,s),s=vt=gb(s,Sr),s=Uy(a,s,Sr)}i.memoizedProps=i.pendingProps,s===null?Ud(i):vt=s}function ul(i,s,a,l){dr=to=null,Sp(s),Jo=null,lc=0;var d=s.return;try{if(wT(i,d,s,a,bt)){di=1,Dd(i,Qn(a,i.current)),vt=null;return}}catch(h){if(d!==null)throw vt=d,h;di=1,Dd(i,Qn(a,i.current)),vt=null;return}s.flags&32768?(St||l===1?i=!0:al||(bt&536870912)!==0?i=!1:(la=i=!0,(l===2||l===9||l===3||l===6)&&(l=Pn.current,l!==null&&l.tag===13&&(l.flags|=16384))),bS(s,i)):Ud(s)}function Ud(i){var s=i;do{if((s.flags&32768)!==0){bS(s,la);return}i=s.return;var a=kT(s.alternate,s,Sr);if(a!==null){vt=a;return}if(s=s.sibling,s!==null){vt=s;return}vt=s=i}while(s!==null);di===0&&(di=5)}function bS(i,s){do{var a=TT(i.alternate,i);if(a!==null){a.flags&=32767,vt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){vt=i;return}vt=i=a}while(i!==null);di=6,vt=null}function yS(i,s,a,l,d,h,_,T,A){i.cancelPendingCommit=null;do Kd();while(Oi!==0);if((Et&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(h=s.lanes|s.childLanes,h|=Yf,Ht(i,a,h,_,T,A),i===Wt&&(vt=Wt=null,bt=0),ll=s,da=i,wr=a,im=h,nm=d,cS=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,zT(qe,function(){return kS(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=L.T,L.T=null,d=R.p,R.p=2,_=Et,Et|=4;try{ET(i,s,a)}finally{Et=_,R.p=d,L.T=l}}Oi=1,SS(),wS(),CS()}}function SS(){if(Oi===1){Oi=0;var i=da,s=ll,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 d=Et;Et|=4;try{tS(s,i);var h=_m,_=sd(i.containerInfo),T=h.focusedElem,A=h.selectionRange;if(_!==T&&T&&T.ownerDocument&&nd(T.ownerDocument.documentElement,T)){if(A!==null&&Za(T)){var G=A.start,de=A.end;if(de===void 0&&(de=G),"selectionStart"in T)T.selectionStart=G,T.selectionEnd=Math.min(de,T.value.length);else{var ge=T.ownerDocument||document,J=ge&&ge.defaultView||window;if(J.getSelection){var oe=J.getSelection(),Pe=T.textContent.length,Ze=Math.min(A.start,Pe),Bt=A.end===void 0?Ze:Math.min(A.end,Pe);!oe.extend&&Ze>Bt&&(_=Bt,Bt=Ze,Ze=_);var U=id(T,Ze),P=id(T,Bt);if(U&&P&&(oe.rangeCount!==1||oe.anchorNode!==U.node||oe.anchorOffset!==U.offset||oe.focusNode!==P.node||oe.focusOffset!==P.offset)){var Y=ge.createRange();Y.setStart(U.node,U.offset),oe.removeAllRanges(),Ze>Bt?(oe.addRange(Y),oe.extend(P.node,P.offset)):(Y.setEnd(P.node,P.offset),oe.addRange(Y))}}}}for(ge=[],oe=T;oe=oe.parentNode;)oe.nodeType===1&&ge.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<ge.length;T++){var pe=ge[T];pe.element.scrollLeft=pe.left,pe.element.scrollTop=pe.top}}eh=!!vm,_m=vm=null}finally{Et=d,R.p=l,L.T=a}}i.current=s,Oi=2}}function wS(){if(Oi===2){Oi=0;var i=da,s=ll,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 d=Et;Et|=4;try{Gy(i,s.alternate,s)}finally{Et=d,R.p=l,L.T=a}}Oi=3}}function CS(){if(Oi===4||Oi===3){Oi=0,rt();var i=da,s=ll,a=wr,l=cS;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Oi=5:(Oi=0,ll=da=null,xS(i,i.pendingLanes));var d=i.pendingLanes;if(d===0&&(ua=null),_n(a),s=s.stateNode,Xe&&typeof Xe.onCommitFiberRoot=="function")try{Xe.onCommitFiberRoot(nt,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=L.T,d=R.p,R.p=2,L.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var T=l[_];h(T.value,{componentStack:T.stack})}}finally{L.T=s,R.p=d}}(wr&3)!==0&&Kd(),Hs(i),d=i.pendingLanes,(a&261930)!==0&&(d&42)!==0?i===sm?kc++:(kc=0,sm=i):kc=0,Tc(0)}}function xS(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,ac(s)))}function Kd(){return SS(),wS(),CS(),kS()}function kS(){if(Oi!==5)return!1;var i=da,s=im;im=0;var a=_n(wr),l=L.T,d=R.p;try{R.p=32>a?32:a,L.T=null,a=nm,nm=null;var h=da,_=wr;if(Oi=0,ll=da=null,wr=0,(Et&6)!==0)throw Error(r(331));var T=Et;if(Et|=4,aS(h.current),nS(h,h.current,_,a),Et=T,Tc(0,!1),Xe&&typeof Xe.onPostCommitFiberRoot=="function")try{Xe.onPostCommitFiberRoot(nt,h)}catch{}return!0}finally{R.p=d,L.T=l,xS(i,s)}}function TS(i,s,a){s=Qn(a,s),s=jp(i.stateNode,s,2),i=sa(i,s,2),i!==null&&(ci(i,2),Hs(i))}function Nt(i,s,a){if(i.tag===3)TS(i,i,a);else for(;s!==null;){if(s.tag===3){TS(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ua===null||!ua.has(l))){i=Qn(a,i),a=Ey(2),l=sa(s,a,2),l!==null&&(Dy(a,l,s,i),ci(l,2),Hs(l));break}}s=s.return}}function om(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new MT;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(a)||(Jp=!0,d.add(a),i=BT.bind(null,i,s,a),s.then(i,i))}function BT(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Wt===i&&(bt&a)===a&&(di===4||di===3&&(bt&62914560)===bt&&300>zt()-jd?(Et&2)===0&&cl(i,0):em|=a,ol===bt&&(ol=0)),Hs(i)}function ES(i,s){s===0&&(s=Vt()),i=Qa(i,s),i!==null&&(ci(i,s),Hs(i))}function jT(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),ES(i,a)}function IT(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,d=i.memoizedState;d!==null&&(a=d.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),ES(i,a)}function zT(i,s){return Oe(i,s)}var Wd=null,dl=null,lm=!1,Fd=!1,cm=!1,fa=0;function Hs(i){i!==dl&&i.next===null&&(dl===null?Wd=dl=i:dl=dl.next=i),Fd=!0,lm||(lm=!0,HT())}function Tc(i,s){if(!cm&&Fd){cm=!0;do for(var a=!1,l=Wd;l!==null;){if(i!==0){var d=l.pendingLanes;if(d===0)var h=0;else{var _=l.suspendedLanes,T=l.pingedLanes;h=(1<<31-lt(42|i)+1)-1,h&=d&~(_&~T),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,NS(l,h))}else h=bt,h=qt(l,l===Wt?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||Pt(l,h)||(a=!0,NS(l,h));l=l.next}while(a);cm=!1}}function PT(){DS()}function DS(){Fd=lm=!1;var i=0;fa!==0&&GT()&&(i=fa);for(var s=zt(),a=null,l=Wd;l!==null;){var d=l.next,h=RS(l,s);h===0?(l.next=null,a===null?Wd=d:a.next=d,d===null&&(dl=a)):(a=l,(i!==0||(h&3)!==0)&&(Fd=!0)),l=d}Oi!==0&&Oi!==5||Tc(i),fa!==0&&(fa=0)}function RS(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,d=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-lt(h),T=1<<_,A=d[_];A===-1?((T&a)===0||(T&l)!==0)&&(d[_]=li(T,s)):A<=s&&(i.expiredLanes|=T),h&=~T}if(s=Wt,a=bt,a=qt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Mt===2||Mt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&ze(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Pt(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&ze(l),_n(a)){case 2:case 8:a=mi;break;case 32:a=qe;break;case 268435456:a=$t;break;default:a=qe}return l=MS.bind(null,i),a=Oe(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&ze(l),i.callbackPriority=2,i.callbackNode=null,2}function MS(i,s){if(Oi!==0&&Oi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Kd()&&i.callbackNode!==a)return null;var l=bt;return l=qt(i,i===Wt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(dS(i,l,s),RS(i,zt()),i.callbackNode!=null&&i.callbackNode===a?MS.bind(null,i):null)}function NS(i,s){if(Kd())return null;dS(i,s,!0)}function HT(){QT(function(){(Et&6)!==0?Oe(oi,PT):DS()})}function um(){if(fa===0){var i=Go;i===0&&(i=Ie,Ie<<=1,(Ie&261888)===0&&(Ie=256)),fa=i}return fa}function AS(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:_s(""+i)}function LS(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 UT(i,s,a,l,d){if(s==="submit"&&a&&a.stateNode===d){var h=AS((d[_i]||null).action),_=l.submitter;_&&(s=(s=_[_i]||null)?AS(s.formAction):_.getAttribute("formAction"),s!==null&&(h=s,_=null));var T=new C("action","action",null,l,d);i.push({event:T,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(fa!==0){var A=_?LS(d,_):new FormData(d);Mp(a,{pending:!0,data:A,method:d.method,action:h},null,A)}}else typeof h=="function"&&(T.preventDefault(),A=_?LS(d,_):new FormData(d),Mp(a,{pending:!0,data:A,method:d.method,action:h},h,A))},currentTarget:d}]})}}for(var dm=0;dm<Vf.length;dm++){var hm=Vf[dm],KT=hm.toLowerCase(),WT=hm[0].toUpperCase()+hm.slice(1);ys(KT,"on"+WT)}ys(Kt,"onAnimationEnd"),ys(Rt,"onAnimationIteration"),ys(Dt,"onAnimationStart"),ys("dblclick","onDoubleClick"),ys("focusin","onFocus"),ys("focusout","onBlur"),ys(Bs,"onTransitionRun"),ys(Wo,"onTransitionStart"),ys(js,"onTransitionCancel"),ys(ic,"onTransitionEnd"),jn("onMouseEnter",["mouseout","mouseover"]),jn("onMouseLeave",["mouseout","mouseover"]),jn("onPointerEnter",["pointerout","pointerover"]),jn("onPointerLeave",["pointerout","pointerover"]),Ut("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ut("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ut("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ut("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ut("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ut("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ec="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(" "),FT=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ec));function OS(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],d=l.event;l=l.listeners;e:{var h=void 0;if(s)for(var _=l.length-1;0<=_;_--){var T=l[_],A=T.instance,G=T.currentTarget;if(T=T.listener,A!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=G;try{h(d)}catch(de){rd(de)}d.currentTarget=null,h=A}else for(_=0;_<l.length;_++){if(T=l[_],A=T.instance,G=T.currentTarget,T=T.listener,A!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=G;try{h(d)}catch(de){rd(de)}d.currentTarget=null,h=A}}}}function _t(i,s){var a=s[Ir];a===void 0&&(a=s[Ir]=new Set);var l=i+"__bubble";a.has(l)||(BS(s,i,2,!1),a.add(l))}function fm(i,s,a){var l=0;s&&(l|=4),BS(a,i,l,s)}var $d="_reactListening"+Math.random().toString(36).slice(2);function pm(i){if(!i[$d]){i[$d]=!0,Oo.forEach(function(a){a!=="selectionchange"&&(FT.has(a)||fm(a,!1,i),fm(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[$d]||(s[$d]=!0,fm("selectionchange",!1,s))}}function BS(i,s,a,l){switch(u0(s)){case 2:var d=_E;break;case 8:d=bE;break;default:d=Rm}a=d.bind(null,s,a,i),d=void 0,!qr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),l?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function mm(i,s,a,l,d){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 T=l.stateNode.containerInfo;if(T===d)break;if(_===4)for(_=l.return;_!==null;){var A=_.tag;if((A===3||A===4)&&_.stateNode.containerInfo===d)return;_=_.return}for(;T!==null;){if(_=hs(T),_===null)return;if(A=_.tag,A===5||A===6||A===26||A===27){l=h=_;continue e}T=T.parentNode}}l=l.return}qa(function(){var G=h,de=$r(a),ge=[];e:{var J=nc.get(i);if(J!==void 0){var oe=C,Pe=i;switch(i){case"keypress":if(sr(a)===0)break e;case"keydown":case"keyup":oe=jf;break;case"focusin":Pe="focus",oe=Vr;break;case"focusout":Pe="blur",oe=Vr;break;case"beforeblur":case"afterblur":oe=Vr;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=Ge;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":oe=ki;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":oe=If;break;case Kt:case Rt:case Dt:oe=zo;break;case ic:oe=rr;break;case"scroll":case"scrollend":oe=z;break;case"wheel":oe=zf;break;case"copy":case"cut":case"paste":oe=$l;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":oe=ql;break;case"toggle":case"beforetoggle":oe=Hf}var Ze=(s&4)!==0,Bt=!Ze&&(i==="scroll"||i==="scrollend"),U=Ze?J!==null?J+"Capture":null:J;Ze=[];for(var P=G,Y;P!==null;){var pe=P;if(Y=pe.stateNode,pe=pe.tag,pe!==5&&pe!==26&&pe!==27||Y===null||U===null||(pe=In(P,U),pe!=null&&Ze.push(Dc(P,pe,Y))),Bt)break;P=P.return}0<Ze.length&&(J=new oe(J,Pe,null,a,de),ge.push({event:J,listeners:Ze}))}}if((s&7)===0){e:{if(J=i==="mouseover"||i==="pointerover",oe=i==="mouseout"||i==="pointerout",J&&a!==bi&&(Pe=a.relatedTarget||a.fromElement)&&(hs(Pe)||Pe[Bn]))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=G,Pe=Pe?hs(Pe):null,Pe!==null&&(Bt=c(Pe),Ze=Pe.tag,Pe!==Bt||Ze!==5&&Ze!==27&&Ze!==6)&&(Pe=null)):(oe=null,Pe=G),oe!==Pe)){if(Ze=Ge,pe="onMouseLeave",U="onMouseEnter",P="mouse",(i==="pointerout"||i==="pointerover")&&(Ze=ql,pe="onPointerLeave",U="onPointerEnter",P="pointer"),Bt=oe==null?J:fs(oe),Y=Pe==null?J:fs(Pe),J=new Ze(pe,P+"leave",oe,a,de),J.target=Bt,J.relatedTarget=Y,pe=null,hs(de)===G&&(Ze=new Ze(U,P+"enter",Pe,a,de),Ze.target=Y,Ze.relatedTarget=Bt,pe=Ze),Bt=pe,oe&&Pe)t:{for(Ze=$T,U=oe,P=Pe,Y=0,pe=U;pe;pe=Ze(pe))Y++;pe=0;for(var Ye=P;Ye;Ye=Ze(Ye))pe++;for(;0<Y-pe;)U=Ze(U),Y--;for(;0<pe-Y;)P=Ze(P),pe--;for(;Y--;){if(U===P||P!==null&&U===P.alternate){Ze=U;break t}U=Ze(U),P=Ze(P)}Ze=null}else Ze=null;oe!==null&&jS(ge,J,oe,Ze,!1),Pe!==null&&Bt!==null&&jS(ge,Bt,Pe,Ze,!0)}}e:{if(J=G?fs(G):window,oe=J.nodeName&&J.nodeName.toLowerCase(),oe==="select"||oe==="input"&&J.type==="file")var kt=ec;else if(Ya(J))if(Ju)kt=Ff;else{kt=Wf;var Ue=Kf}else oe=J.nodeName,!oe||oe.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?G&&Fr(G.elementType)&&(kt=ec):kt=or;if(kt&&(kt=kt(i,G))){Jl(ge,kt,a,de);break e}Ue&&Ue(i,J,G),i==="focusout"&&G&&J.type==="number"&&G.memoizedProps.value!=null&&Js(J,"number",J.value)}switch(Ue=G?fs(G):window,i){case"focusin":(Ya(Ue)||Ue.contentEditable==="true")&&(lr=Ue,k=G,I=null);break;case"focusout":I=k=lr=null;break;case"mousedown":Ce=!0;break;case"contextmenu":case"mouseup":case"dragend":Ce=!1,$e(ge,a,de);break;case"selectionchange":if(qf)break;case"keydown":case"keyup":$e(ge,a,de)}var ut;if(Va)e:{switch(i){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else Xr?Zl(i,a)&&(yt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(yt="onCompositionStart");yt&&(Xl&&a.locale!=="ko"&&(Xr||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&Xr&&(ut=nr()):(yn=de,Ns="value"in yn?yn.value:yn.textContent,Xr=!0)),Ue=qd(G,yt),0<Ue.length&&(yt=new Po(yt,i,null,a,de),ge.push({event:yt,listeners:Ue}),ut?yt.data=ut:(ut=Gu(a),ut!==null&&(yt.data=ut)))),(ut=Uo?Uf(i,a):Zu(i,a))&&(yt=qd(G,"onBeforeInput"),0<yt.length&&(Ue=new Po("onBeforeInput","beforeinput",null,a,de),ge.push({event:Ue,listeners:yt}),Ue.data=ut)),UT(ge,i,G,a,de)}OS(ge,s)})}function Dc(i,s,a){return{instance:i,listener:s,currentTarget:a}}function qd(i,s){for(var a=s+"Capture",l=[];i!==null;){var d=i,h=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||h===null||(d=In(i,a),d!=null&&l.unshift(Dc(i,d,h)),d=In(i,s),d!=null&&l.push(Dc(i,d,h))),i.tag===3)return l;i=i.return}return[]}function $T(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function jS(i,s,a,l,d){for(var h=s._reactName,_=[];a!==null&&a!==l;){var T=a,A=T.alternate,G=T.stateNode;if(T=T.tag,A!==null&&A===l)break;T!==5&&T!==26&&T!==27||G===null||(A=G,d?(G=In(a,h),G!=null&&_.unshift(Dc(a,G,A))):d||(G=In(a,h),G!=null&&_.push(Dc(a,G,A)))),a=a.return}_.length!==0&&i.push({event:s,listeners:_})}var qT=/\r\n?/g,VT=/\u0000|\uFFFD/g;function IS(i){return(typeof i=="string"?i:""+i).replace(qT,`
10
+ `).replace(VT,"")}function zS(i,s){return s=IS(s),IS(i)===s}function Ot(i,s,a,l,d,h){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||un(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&un(i,""+l);break;case"className":Ur(i,"class",l);break;case"tabIndex":Ur(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Ur(i,a,l);break;case"style":er(i,l,h);break;case"data":if(s!=="object"){Ur(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=_s(""+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"&&Ot(i,s,"name",d.name,d,null),Ot(i,s,"formEncType",d.formEncType,d,null),Ot(i,s,"formMethod",d.formMethod,d,null),Ot(i,s,"formTarget",d.formTarget,d,null)):(Ot(i,s,"encType",d.encType,d,null),Ot(i,s,"method",d.method,d,null),Ot(i,s,"target",d.target,d,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=_s(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Yn);break;case"onScroll":l!=null&&_t("scroll",i);break;case"onScrollEnd":l!=null&&_t("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=_s(""+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":_t("beforetoggle",i),_t("toggle",i),ps(i,"popover",l);break;case"xlinkActuate":bn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":bn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":bn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":bn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":bn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":bn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":bn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":bn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":bn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":ps(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=Io.get(a)||a,ps(i,a,l))}}function gm(i,s,a,l,d,h){switch(a){case"style":er(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(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?un(i,l):(typeof l=="number"||typeof l=="bigint")&&un(i,""+l);break;case"onScroll":l!=null&&_t("scroll",i);break;case"onScrollEnd":l!=null&&_t("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Yn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Pr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(d=a.endsWith("Capture"),s=a.slice(2,d?a.length-7:void 0),h=i[_i]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(s,h,d),typeof l=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,d);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):ps(i,a,l)}}}function an(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":_t("error",i),_t("load",i);var l=!1,d=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":l=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ot(i,s,h,_,a,null)}}d&&Ot(i,s,"srcSet",a.srcSet,a,null),l&&Ot(i,s,"src",a.src,a,null);return;case"input":_t("invalid",i);var T=h=_=d=null,A=null,G=null;for(l in a)if(a.hasOwnProperty(l)){var de=a[l];if(de!=null)switch(l){case"name":d=de;break;case"type":_=de;break;case"checked":A=de;break;case"defaultChecked":G=de;break;case"value":h=de;break;case"defaultValue":T=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(137,s));break;default:Ot(i,s,l,de,a,null)}}vs(i,h,T,A,G,_,d,!1);return;case"select":_t("invalid",i),l=_=h=null;for(d in a)if(a.hasOwnProperty(d)&&(T=a[d],T!=null))switch(d){case"value":h=T;break;case"defaultValue":_=T;break;case"multiple":l=T;default:Ot(i,s,d,T,a,null)}s=h,a=_,i.multiple=!!l,s!=null?cn(i,!!l,s,!1):a!=null&&cn(i,!!l,a,!0);return;case"textarea":_t("invalid",i),h=d=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(T=a[_],T!=null))switch(_){case"value":l=T;break;case"defaultValue":d=T;break;case"children":h=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:Ot(i,s,_,T,a,null)}$a(i,l,d,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":Ot(i,s,A,l,a,null));return;case"dialog":_t("beforetoggle",i),_t("toggle",i),_t("cancel",i),_t("close",i);break;case"iframe":case"object":_t("load",i);break;case"video":case"audio":for(l=0;l<Ec.length;l++)_t(Ec[l],i);break;case"image":_t("error",i),_t("load",i);break;case"details":_t("toggle",i);break;case"embed":case"source":case"link":_t("error",i),_t("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(G in a)if(a.hasOwnProperty(G)&&(l=a[G],l!=null))switch(G){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ot(i,s,G,l,a,null)}return;default:if(Fr(s)){for(de in a)a.hasOwnProperty(de)&&(l=a[de],l!==void 0&&gm(i,s,de,l,a,void 0));return}}for(T in a)a.hasOwnProperty(T)&&(l=a[T],l!=null&&Ot(i,s,T,l,a,null))}function YT(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,h=null,_=null,T=null,A=null,G=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)||Ot(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":d=oe;break;case"checked":G=oe;break;case"defaultChecked":de=oe;break;case"value":_=oe;break;case"defaultValue":T=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,s));break;default:oe!==ge&&Ot(i,s,J,oe,l,ge)}}ft(i,_,T,A,G,de,h,d);return;case"select":oe=_=T=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)||Ot(i,s,h,null,l,A)}for(d in l)if(h=l[d],A=a[d],l.hasOwnProperty(d)&&(h!=null||A!=null))switch(d){case"value":J=h;break;case"defaultValue":T=h;break;case"multiple":_=h;default:h!==A&&Ot(i,s,d,h,l,A)}s=T,a=_,l=oe,J!=null?cn(i,!!a,J,!1):!!l!=!!a&&(s!=null?cn(i,!!a,s,!0):cn(i,!!a,a?[]:"",!1));return;case"textarea":oe=J=null;for(T in a)if(d=a[T],a.hasOwnProperty(T)&&d!=null&&!l.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:Ot(i,s,T,null,l,d)}for(_ in l)if(d=l[_],h=a[_],l.hasOwnProperty(_)&&(d!=null||h!=null))switch(_){case"value":J=d;break;case"defaultValue":oe=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==h&&Ot(i,s,_,d,l,h)}Kr(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:Ot(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":Ot(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 Ze in a)J=a[Ze],a.hasOwnProperty(Ze)&&J!=null&&!l.hasOwnProperty(Ze)&&Ot(i,s,Ze,null,l,J);for(G in l)if(J=l[G],oe=a[G],l.hasOwnProperty(G)&&J!==oe&&(J!=null||oe!=null))switch(G){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(r(137,s));break;default:Ot(i,s,G,J,l,oe)}return;default:if(Fr(s)){for(var Bt in a)J=a[Bt],a.hasOwnProperty(Bt)&&J!==void 0&&!l.hasOwnProperty(Bt)&&gm(i,s,Bt,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||gm(i,s,de,J,l,oe);return}}for(var U in a)J=a[U],a.hasOwnProperty(U)&&J!=null&&!l.hasOwnProperty(U)&&Ot(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||Ot(i,s,ge,J,l,oe)}function PS(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function XT(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var d=a[l],h=d.transferSize,_=d.initiatorType,T=d.duration;if(h&&T&&PS(_)){for(_=0,T=d.responseEnd,l+=1;l<a.length;l++){var A=a[l],G=A.startTime;if(G>T)break;var de=A.transferSize,ge=A.initiatorType;de&&PS(ge)&&(A=A.responseEnd,_+=de*(A<T?1:(T-G)/(A-G)))}if(--l,s+=8*(h+_)/(d.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var vm=null,_m=null;function Vd(i){return i.nodeType===9?i:i.ownerDocument}function HS(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 US(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 bm(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var ym=null;function GT(){var i=window.event;return i&&i.type==="popstate"?i===ym?!1:(ym=i,!0):(ym=null,!1)}var KS=typeof setTimeout=="function"?setTimeout:void 0,ZT=typeof clearTimeout=="function"?clearTimeout:void 0,WS=typeof Promise=="function"?Promise:void 0,QT=typeof queueMicrotask=="function"?queueMicrotask:typeof WS<"u"?function(i){return WS.resolve(null).then(i).catch(JT)}:KS;function JT(i){setTimeout(function(){throw i})}function pa(i){return i==="head"}function FS(i,s){var a=s,l=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(d),ml(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Rc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Rc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,T=h.nodeName;h[ds]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&Rc(i.ownerDocument.body);a=d}while(a);ml(s)}function $S(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 Sm(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":Sm(a),Zs(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function eE(i,s,a,l){for(;i.nodeType===1;){var d=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[ds])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!==d.rel||i.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||i.getAttribute("title")!==(d.title==null?null:d.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(d.src==null?null:d.src)||i.getAttribute("type")!==(d.type==null?null:d.type)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var h=d.name==null?null:""+d.name;if(d.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=ns(i.nextSibling),i===null)break}return null}function tE(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ns(i.nextSibling),i===null))return null;return i}function qS(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=ns(i.nextSibling),i===null))return null;return i}function wm(i){return i.data==="$?"||i.data==="$~"}function Cm(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function iE(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 ns(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 xm=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 ns(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function YS(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 XS(i,s,a){switch(s=Vd(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 Rc(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);Zs(i)}var ss=new Map,GS=new Set;function Yd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Cr=R.d;R.d={f:nE,r:sE,D:rE,C:aE,L:oE,m:lE,X:uE,S:cE,M:dE};function nE(){var i=Cr.f(),s=Pd();return i||s}function sE(i){var s=Ts(i);s!==null&&s.tag===5&&s.type==="form"?fy(s):Cr.r(i)}var hl=typeof document>"u"?null:document;function ZS(i,s,a){var l=hl;if(l&&typeof s=="string"&&s){var d=Li(s);d='link[rel="'+i+'"][href="'+d+'"]',typeof a=="string"&&(d+='[crossorigin="'+a+'"]'),GS.has(d)||(GS.add(d),i={rel:i,crossOrigin:a,href:s},l.querySelector(d)===null&&(s=l.createElement("link"),an(s,"link",i),At(s),l.head.appendChild(s)))}}function rE(i){Cr.D(i),ZS("dns-prefetch",i,null)}function aE(i,s){Cr.C(i,s),ZS("preconnect",i,s)}function oE(i,s,a){Cr.L(i,s,a);var l=hl;if(l&&i&&s){var d='link[rel="preload"][as="'+Li(s)+'"]';s==="image"&&a&&a.imageSrcSet?(d+='[imagesrcset="'+Li(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(d+='[imagesizes="'+Li(a.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var h=d;switch(s){case"style":h=fl(i);break;case"script":h=pl(i)}ss.has(h)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),ss.set(h,i),l.querySelector(d)!==null||s==="style"&&l.querySelector(Mc(h))||s==="script"&&l.querySelector(Nc(h))||(s=l.createElement("link"),an(s,"link",i),At(s),l.head.appendChild(s)))}}function lE(i,s){Cr.m(i,s);var a=hl;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+Li(l)+'"][href="'+Li(i)+'"]',h=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=pl(i)}if(!ss.has(h)&&(i=b({rel:"modulepreload",href:i},s),ss.set(h,i),a.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Nc(h)))return}l=a.createElement("link"),an(l,"link",i),At(l),a.head.appendChild(l)}}}function cE(i,s,a){Cr.S(i,s,a);var l=hl;if(l&&i){var d=Es(l).hoistableStyles,h=fl(i);s=s||"default";var _=d.get(h);if(!_){var T={loading:0,preload:null};if(_=l.querySelector(Mc(h)))T.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=ss.get(h))&&km(i,a);var A=_=l.createElement("link");At(A),an(A,"link",i),A._p=new Promise(function(G,de){A.onload=G,A.onerror=de}),A.addEventListener("load",function(){T.loading|=1}),A.addEventListener("error",function(){T.loading|=2}),T.loading|=4,Xd(_,s,l)}_={type:"stylesheet",instance:_,count:1,state:T},d.set(h,_)}}}function uE(i,s){Cr.X(i,s);var a=hl;if(a&&i){var l=Es(a).hoistableScripts,d=pl(i),h=l.get(d);h||(h=a.querySelector(Nc(d)),h||(i=b({src:i,async:!0},s),(s=ss.get(d))&&Tm(i,s),h=a.createElement("script"),At(h),an(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function dE(i,s){Cr.M(i,s);var a=hl;if(a&&i){var l=Es(a).hoistableScripts,d=pl(i),h=l.get(d);h||(h=a.querySelector(Nc(d)),h||(i=b({src:i,async:!0,type:"module"},s),(s=ss.get(d))&&Tm(i,s),h=a.createElement("script"),At(h),an(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function QS(i,s,a,l){var d=(d=xe.current)?Yd(d):null;if(!d)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=fl(a.href),a=Es(d).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=fl(a.href);var h=Es(d).hoistableStyles,_=h.get(i);if(_||(d=d.ownerDocument||d,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=d.querySelector(Mc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),ss.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},ss.set(i,a),h||hE(d,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=pl(a),a=Es(d).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function fl(i){return'href="'+Li(i)+'"'}function Mc(i){return'link[rel="stylesheet"]['+i+"]"}function JS(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function hE(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}),an(s,"link",a),At(s),i.head.appendChild(s))}function pl(i){return'[src="'+Li(i)+'"]'}function Nc(i){return"script[async]"+i}function e0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+Li(a.href)+'"]');if(l)return s.instance=l,At(l),l;var d=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),At(l),an(l,"style",d),Xd(l,a.precedence,i),s.instance=l;case"stylesheet":d=fl(a.href);var h=i.querySelector(Mc(d));if(h)return s.state.loading|=4,s.instance=h,At(h),h;l=JS(a),(d=ss.get(d))&&km(l,d),h=(i.ownerDocument||i).createElement("link"),At(h);var _=h;return _._p=new Promise(function(T,A){_.onload=T,_.onerror=A}),an(h,"link",l),s.state.loading|=4,Xd(h,a.precedence,i),s.instance=h;case"script":return h=pl(a.src),(d=i.querySelector(Nc(h)))?(s.instance=d,At(d),d):(l=a,(d=ss.get(h))&&(l=b({},a),Tm(l,d)),i=i.ownerDocument||i,d=i.createElement("script"),At(d),an(d,"link",l),i.head.appendChild(d),s.instance=d);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,Xd(l,a.precedence,i));return s.instance}function Xd(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,h=d,_=0;_<l.length;_++){var T=l[_];if(T.dataset.precedence===s)h=T;else if(h!==d)break}h?h.parentNode.insertBefore(i,h.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function km(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Tm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var Gd=null;function t0(i,s,a){if(Gd===null){var l=new Map,d=Gd=new Map;d.set(a,l)}else d=Gd,l=d.get(a),l||(l=new Map,d.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),d=0;d<a.length;d++){var h=a[d];if(!(h[ds]||h[vi]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(s)||"";_=i+_;var T=l.get(_);T?T.push(h):l.set(_,[h])}}return l}function i0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function fE(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 n0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function pE(i,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var d=fl(l.href),h=s.querySelector(Mc(d));if(h){s=h._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=Zd.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=h,At(h);return}h=s.ownerDocument||s,l=JS(l),(d=ss.get(d))&&km(l,d),h=h.createElement("link"),At(h);var _=h;_._p=new Promise(function(T,A){_.onload=T,_.onerror=A}),an(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=Zd.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var Em=0;function mE(i,s){return i.stylesheets&&i.count===0&&Jd(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&Jd(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+s);0<i.imgBytes&&Em===0&&(Em=62500*XT());var d=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Jd(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>Em?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function Zd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Jd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Qd=null;function Jd(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Qd=new Map,s.forEach(gE,i),Qd=null,Zd.call(i))}function gE(i,s){if(!(s.state.loading&4)){var a=Qd.get(i);if(a)var l=a.get(null);else{a=new Map,Qd.set(i,a);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<d.length;h++){var _=d[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}d=s.instance,_=d.getAttribute("data-precedence"),h=a.get(_)||l,h===l&&a.set(null,d),a.set(_,d),this.count++,l=Zd.bind(this),d.addEventListener("load",l),d.addEventListener("error",l),h?h.parentNode.insertBefore(d,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(d,i.firstChild)),s.state.loading|=4}}var Ac={$$typeof:q,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function vE(i,s,a,l,d,h,_,T,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=ii(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ii(0),this.hiddenUpdates=ii(null),this.identifierPrefix=l,this.onUncaughtError=d,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function s0(i,s,a,l,d,h,_,T,A,G,de,ge){return i=new vE(i,s,a,_,A,G,de,ge,T),s=1,h===!0&&(s|=24),h=zn(3,null,null,s),i.current=h,h.stateNode=i,s=ap(),s.refCount++,i.pooledCache=s,s.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:s},up(h),i}function r0(i){return i?(i=$o,i):$o}function a0(i,s,a,l,d,h){d=r0(d),l.context===null?l.context=d:l.pendingContext=d,l=na(s),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=sa(i,l,s),a!==null&&(Nn(a,i,s),uc(a,i,s))}function o0(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function Dm(i,s){o0(i,s),(i=i.alternate)&&o0(i,s)}function l0(i){if(i.tag===13||i.tag===31){var s=Qa(i,67108864);s!==null&&Nn(s,i,67108864),Dm(i,67108864)}}function c0(i){if(i.tag===13||i.tag===31){var s=Wn();s=vn(s);var a=Qa(i,s);a!==null&&Nn(a,i,s),Dm(i,s)}}var eh=!0;function _E(i,s,a,l){var d=L.T;L.T=null;var h=R.p;try{R.p=2,Rm(i,s,a,l)}finally{R.p=h,L.T=d}}function bE(i,s,a,l){var d=L.T;L.T=null;var h=R.p;try{R.p=8,Rm(i,s,a,l)}finally{R.p=h,L.T=d}}function Rm(i,s,a,l){if(eh){var d=Mm(l);if(d===null)mm(i,s,l,th,a),d0(i,l);else if(SE(d,i,s,a,l))l.stopPropagation();else if(d0(i,l),s&4&&-1<yE.indexOf(i)){for(;d!==null;){var h=Ts(d);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=wt(h.pendingLanes);if(_!==0){var T=h;for(T.pendingLanes|=2,T.entangledLanes|=2;_;){var A=1<<31-lt(_);T.entanglements[1]|=A,_&=~A}Hs(h),(Et&6)===0&&(Id=zt()+500,Tc(0))}}break;case 31:case 13:T=Qa(h,2),T!==null&&Nn(T,h,2),Pd(),Dm(h,2)}if(h=Mm(l),h===null&&mm(i,s,l,th,a),h===d)break;d=h}d!==null&&l.stopPropagation()}else mm(i,s,l,null,a)}}function Mm(i){return i=$r(i),Nm(i)}var th=null;function Nm(i){if(th=null,i=hs(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=u(s),i!==null)return i;i=null}else if(a===31){if(i=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 th=i,null}function u0(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(gn()){case oi:return 2;case mi:return 8;case qe:case Ct:return 32;case $t:return 268435456;default:return 32}default:return 32}}var Am=!1,ma=null,ga=null,va=null,Lc=new Map,Oc=new Map,_a=[],yE="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 d0(i,s){switch(i){case"focusin":case"focusout":ma=null;break;case"dragenter":case"dragleave":ga=null;break;case"mouseover":case"mouseout":va=null;break;case"pointerover":case"pointerout":Lc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Oc.delete(s.pointerId)}}function Bc(i,s,a,l,d,h){return i===null||i.nativeEvent!==h?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[d]},s!==null&&(s=Ts(s),s!==null&&l0(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function SE(i,s,a,l,d){switch(s){case"focusin":return ma=Bc(ma,i,s,a,l,d),!0;case"dragenter":return ga=Bc(ga,i,s,a,l,d),!0;case"mouseover":return va=Bc(va,i,s,a,l,d),!0;case"pointerover":var h=d.pointerId;return Lc.set(h,Bc(Lc.get(h)||null,i,s,a,l,d)),!0;case"gotpointercapture":return h=d.pointerId,Oc.set(h,Bc(Oc.get(h)||null,i,s,a,l,d)),!0}return!1}function h0(i){var s=hs(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){i.blockedOn=s,Qi(i.priority,function(){c0(a)});return}}else if(s===31){if(s=m(a),s!==null){i.blockedOn=s,Qi(i.priority,function(){c0(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 ih(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Mm(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);bi=l,a.target.dispatchEvent(l),bi=null}else return s=Ts(a),s!==null&&l0(s),i.blockedOn=a,!1;s.shift()}return!0}function f0(i,s,a){ih(i)&&a.delete(s)}function wE(){Am=!1,ma!==null&&ih(ma)&&(ma=null),ga!==null&&ih(ga)&&(ga=null),va!==null&&ih(va)&&(va=null),Lc.forEach(f0),Oc.forEach(f0)}function nh(i,s){i.blockedOn===s&&(i.blockedOn=null,Am||(Am=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,wE)))}var sh=null;function p0(i){sh!==i&&(sh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){sh===i&&(sh=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],d=i[s+2];if(typeof l!="function"){if(Nm(l||a)===null)continue;break}var h=Ts(a);h!==null&&(i.splice(s,3),s-=3,Mp(h,{pending:!0,data:d,method:a.method,action:l},l,d))}}))}function ml(i){function s(A){return nh(A,i)}ma!==null&&nh(ma,i),ga!==null&&nh(ga,i),va!==null&&nh(va,i),Lc.forEach(s),Oc.forEach(s);for(var a=0;a<_a.length;a++){var l=_a[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<_a.length&&(a=_a[0],a.blockedOn===null);)h0(a),a.blockedOn===null&&_a.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var d=a[l],h=a[l+1],_=d[_i]||null;if(typeof h=="function")_||p0(a);else if(_){var T=null;if(h&&h.hasAttribute("formAction")){if(d=h,_=h[_i]||null)T=_.formAction;else if(Nm(d)!==null)continue}else T=_.action;typeof T=="function"?a[l+1]=T:(a.splice(l,3),l-=3),p0(a)}}}function m0(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return d=_})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=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,d=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),d!==null&&(d(),d=null)}}}function Lm(i){this._internalRoot=i}rh.prototype.render=Lm.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Wn();a0(a,l,i,s,null,null)},rh.prototype.unmount=Lm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;a0(i.current,2,null,i,null,null),Pd(),s[Bn]=null}};function rh(i){this._internalRoot=i}rh.prototype.unstable_scheduleHydration=function(i){if(i){var s=Jt();i={blockedOn:null,target:i,priority:s};for(var a=0;a<_a.length&&s!==0&&s<_a[a].priority;a++);_a.splice(a,0,i),a===0&&h0(i)}};var g0=t.version;if(g0!=="19.2.6")throw Error(r(527,g0,"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 CE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ah=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ah.isDisabled&&ah.supportsFiber)try{nt=ah.inject(CE),Xe=ah}catch{}}return Ic.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",d=Cy,h=xy,_=ky;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(h=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=s0(i,1,!1,null,null,a,l,null,d,h,_,m0),i[Bn]=s.current,pm(i),new Lm(s)},Ic.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,d="",h=Cy,_=xy,T=ky,A=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(T=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),s=s0(i,1,!0,s,a??null,l,d,A,h,_,T,m0),s.context=r0(null),a=s.current,l=Wn(),l=vn(l),d=na(l),d.callback=null,sa(a,d,l),a=l,s.current.lanes=a,ci(s,a),Hs(s),i[Bn]=s.current,pm(i),new rh(s)},Ic.version="19.2.6",Ic}var T0;function LE(){if(T0)return jm.exports;T0=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(),jm.exports=AE(),jm.exports}var OE=LE();class Ln extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function hf(e=fetch){return{getSession:(t={})=>Me(e,`/api/auth/session${Fs(t)}`),setupPassword:t=>Me(e,"/api/auth/password",et("POST",t)),login:t=>Me(e,"/api/auth/login",et("POST",t)),reauth:t=>Me(e,"/api/auth/reauth",et("POST",t)),logout:()=>Me(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Me(e,"/api/client-diagnostics",et("POST",t)),setupTotp:()=>Me(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Me(e,"/api/auth/totp/activate",et("POST",t)),disableTotp:()=>Me(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Me(e,"/api/auth/devices"),revokeDevice:async t=>{await bl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Me(e,"/api/auth/networks"),addNetwork:t=>Me(e,"/api/auth/networks",et("POST",t)),removeNetwork:async t=>{await bl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Me(e,"/api/agents"),addAgent:t=>Me(e,"/api/agents",et("POST",t)),reorderAgents:t=>Me(e,"/api/agents/order",et("PUT",{serverIds:t})),renameAgent:(t,n)=>Me(e,`/api/agents/${encodeURIComponent(t)}`,et("PATCH",{name:n})),getMainInfo:()=>Me(e,"/api/main"),renameMain:t=>Me(e,"/api/main",et("PATCH",{name:t})),removeAgent:async t=>{await bl(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${Fs(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",et("POST",t)),stopCodeServer:(t={})=>Me(e,"/api/code-server/stop",et("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",et("PUT",t)),createFileRoot:t=>Me(e,"/api/files/root",et("POST",t)),listFiles:t=>Me(e,"/api/files/list",et("POST",t)),readFile:t=>Me(e,"/api/files/read",et("POST",t)),writeFile:t=>Me(e,"/api/files/write",et("POST",t)),createFileEntry:t=>Me(e,"/api/files/create",et("POST",t)),moveFileEntry:t=>Me(e,"/api/files/move",et("POST",t)),previewDeleteFileEntry:t=>Me(e,"/api/files/delete-preview",et("POST",t)),deleteFileEntry:t=>Me(e,"/api/files/delete",et("POST",t)),openFileInTerminal:t=>Me(e,"/api/files/open",et("POST",t)),previewFile:t=>$1(e,"/api/files/preview",et("POST",t)),createTerminal:(t={})=>Me(e,"/api/terminals",et("POST",t)),closeTerminal:async t=>{await bl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Me(e,`/api/terminals/${encodeURIComponent(t)}`,et("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Me(e,`/api/terminals/${encodeURIComponent(t)}/history${Fs(n)}`),getTerminalTranscriptHistory:(t,n={})=>Me(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Fs(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${Fs(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",et("PUT",t)),deleteNotificationAsset:async t=>{await bl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Me(e,`/api/push-notifications/status${t||n?Fs({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Me(e,"/api/push-notifications/prepare",et("POST",{clientId:t})),subscribePushNotifications:t=>Me(e,"/api/push-notifications/subscription",et("POST",t)),updatePushNotificationDevice:t=>Me(e,"/api/push-notifications/device",et("PATCH",t)),unsubscribePushNotifications:t=>Me(e,"/api/push-notifications/unsubscribe",et("POST",t)),updatePushPresence:t=>Me(e,"/api/push-notifications/presence",et("POST",t)),testPushNotification:t=>Me(e,"/api/push-notifications/test",et("POST",t))}}function Dl(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"),et("POST",r)),closeTerminal:async r=>{await bl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Me(t,n(`terminals/${encodeURIComponent(r)}`),et("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Me(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${Fs(o)}`),getTerminalTranscriptHistory:(r,o={})=>Me(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Fs(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`)}${Fs(c)}`),getTerminalLayout:()=>Me(t,n("terminal-layout")),saveTerminalLayout:r=>Me(t,n("terminal-layout"),et("PUT",r)),createFileRoot:r=>Me(t,n("files/root"),et("POST",r)),listFiles:r=>Me(t,n("files/list"),et("POST",r)),readFile:r=>Me(t,n("files/read"),et("POST",r)),writeFile:r=>Me(t,n("files/write"),et("POST",r)),createFileEntry:r=>Me(t,n("files/create"),et("POST",r)),moveFileEntry:r=>Me(t,n("files/move"),et("POST",r)),previewDeleteFileEntry:r=>Me(t,n("files/delete-preview"),et("POST",r)),deleteFileEntry:r=>Me(t,n("files/delete"),et("POST",r)),openFileInTerminal:r=>Me(t,n("files/open"),et("POST",r)),previewFile:r=>$1(t,n("files/preview"),et("POST",r)),getCodeServerStatus:(r={})=>Me(t,`${n("code-server/status")}${Fs(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"),et("POST",r)),stopCodeServer:(r={})=>Me(t,n("code-server/stop"),et("POST",r)),uninstallCodeServer:()=>Me(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>BE(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function BE(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 et(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Fs(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 v_(r);try{return await r.json()}catch{throw new Ln(r.status,"invalid_json_response")}}async function bl(e,t,n){const r=await e(t,n);await v_(r)}async function $1(e,t,n){const r=await e(t,n);return await v_(r),r.blob()}async function v_(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 Ln(e.status,t)}const __="nterminal.theme.id",q1="nterminal.theme.accent",Eg="nterminal:theme",Uh=[{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",...E0({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",...E0({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Rl="midnight";function ff(e){return Uh.some(t=>t.id===e)?e:Rl}function b_(e){return Uh.find(t=>t.id===e)??Uh[0]}function Ba(){if(typeof window>"u")return Rl;try{const e=window.localStorage.getItem(__);return e?ff(e):HE(window.localStorage.getItem(q1))}catch{return Rl}}function jE(e){const t=ff(e);if(typeof window<"u"){try{window.localStorage.setItem(__,t)}catch{}y_(t),window.dispatchEvent(new CustomEvent(Eg,{detail:t}))}return t}function y_(e=Ba()){if(typeof document>"u")return;const t=b_(ff(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),dt(n,"--nt-bg",t.tokens.bg),dt(n,"--nt-bg-2",t.tokens.bg2),dt(n,"--nt-bg-sidebar",t.tokens.bgSidebar),dt(n,"--nt-line",t.tokens.line),dt(n,"--nt-line-2",t.tokens.line2),dt(n,"--nt-fg",t.tokens.fg),dt(n,"--nt-fg-2",t.tokens.fg2),dt(n,"--nt-fg-3",t.tokens.fg3),dt(n,"--nt-fg-4",t.tokens.fg4),dt(n,"--nt-accent",t.tokens.accent),dt(n,"--nt-accent-soft",t.tokens.accentSoft),dt(n,"--nt-accent-glow",t.tokens.accentGlow),dt(n,"--nt-on-accent",t.tokens.onAccent),dt(n,"--nt-ok",t.tokens.ok),dt(n,"--nt-danger",t.tokens.danger),dt(n,"--nt-on-danger",t.tokens.onDanger),dt(n,"--nt-danger-soft",t.tokens.dangerSoft),dt(n,"--nt-danger-line",t.tokens.dangerLine),dt(n,"--nt-warning",t.tokens.warning),dt(n,"--nt-warn",t.tokens.warning),dt(n,"--nt-warning-soft",t.tokens.warningSoft),dt(n,"--nt-warning-glow",t.tokens.warningGlow),dt(n,"--nt-scrim",t.tokens.scrim),dt(n,"--nt-scrim-soft",t.tokens.scrimSoft),dt(n,"--nt-shadow",t.tokens.shadow),dt(n,"--nt-shadow-strong",t.tokens.shadowStrong),dt(n,"--nt-floating-bg",t.tokens.floatingBg),dt(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),dt(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),dt(n,"--nt-subtle-fill",t.tokens.subtleFill),dt(n,"--nt-hover-fill",t.tokens.hoverFill),dt(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),dt(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),dt(n,"--nt-transcript-user",t.tokens.transcriptUser),dt(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),dt(n,"--nt-transcript-tool",t.tokens.transcriptTool),dt(n,"--nt-transcript-command",t.tokens.transcriptCommand),dt(n,"--nt-transcript-code",t.tokens.transcriptCode),dt(n,"--nt-transcript-search",t.tokens.transcriptSearch),dt(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),dt(n,"--nt-qr-bg",t.tokens.qrBg)}function IE(e=Ba()){return b_(ff(e)).xterm}function S_(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===__||n.key===q1)&&(y_(Ba()),e())};return window.addEventListener(Eg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Eg,e),window.removeEventListener("storage",t)}}function dt(e,t,n){e.style.setProperty(t,n)}function E0(e){const t=zE(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 zE(e){const t=[];for(let n=16;n<=e;n+=1)t.push(PE(n));return t}function PE(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 D0(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return D0(t,t,t)}return"#000000"}function D0(e,t,n){return`#${Hm(e)}${Hm(t)}${Hm(n)}`}function Hm(e){return e.toString(16).padStart(2,"0")}function HE(e){return e==="signal-red"?"signal-red":Rl}function V1(){const e=v.useSyncExternalStore(S_,Ba,()=>Rl);return b_(e).mode==="light"?"-light":""}function Y1({size:e=22}){const t=V1();return f.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function X1({height:e=18}){const t=V1(),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 Xc=F1();const pf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Bl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function w_(e){return"nodeType"in e}function On(e){var t,n;return e?Bl(e)?e:w_(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function C_(e){const{Document:t}=On(e);return e instanceof t}function Bu(e){return Bl(e)?!1:e instanceof On(e).HTMLElement}function G1(e){return e instanceof On(e).SVGElement}function jl(e){return e?Bl(e)?e.document:w_(e)?C_(e)?e:Bu(e)||G1(e)?e.ownerDocument:document:document:document}const ja=pf?v.useLayoutEffect:v.useEffect;function x_(e){const t=v.useRef(e);return ja(()=>{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 UE(){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 vu(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return ja(()=>{n.current!==e&&(n.current=e)},t),n}function ju(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Kh(e){const t=x_(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Dg(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Um={};function mf(e,t){return v.useMemo(()=>{if(t)return t;const n=Um[e]==null?0:Um[e]+1;return Um[e]=n,e+"-"+n},[e,t])}function Z1(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,u)=>{const m=Object.entries(u);for(const[g,p]of m){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const Tl=Z1(1),Wh=Z1(-1);function KE(e){return"clientX"in e&&"clientY"in e}function Q1(e){if(!e)return!1;const{KeyboardEvent:t}=On(e.target);return t&&e instanceof t}function WE(e){if(!e)return!1;const{TouchEvent:t}=On(e.target);return t&&e instanceof t}function Rg(e){if(WE(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 KE(e)?{x:e.clientX,y:e.clientY}:null}const Mg=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[Mg.Translate.toString(e),Mg.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),R0="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function FE(e){return e.matches(R0)?e:e.querySelector(R0)}const $E={display:"none"};function qE(e){let{id:t,value:n}=e;return Ni.createElement("div",{id:t,style:$E},n)}function VE(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 Ni.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function YE(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const J1=v.createContext(null);function XE(e){const t=v.useContext(J1);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function GE(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(u=>{var m;return(m=u[o])==null?void 0:m.call(u,c)})},[e]),t]}const ZE={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
+ `},QE={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 JE(e){let{announcements:t=QE,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=ZE}=e;const{announce:c,announcement:u}=YE(),m=mf("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),XE(v.useMemo(()=>({onDragStart(b){let{active:S}=b;c(t.onDragStart({active:S}))},onDragMove(b){let{active:S,over:w}=b;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(b){let{active:S,over:w}=b;c(t.onDragOver({active:S,over:w}))},onDragEnd(b){let{active:S,over:w}=b;c(t.onDragEnd({active:S,over:w}))},onDragCancel(b){let{active:S,over:w}=b;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const y=Ni.createElement(Ni.Fragment,null,Ni.createElement(qE,{id:r,value:o.draggable}),Ni.createElement(VE,{id:m,announcement:u}));return n?Xc.createPortal(y,n):y}var Ii;(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"})(Ii||(Ii={}));function Fh(){}function M0(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function e2(){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 xs=Object.freeze({x:0,y:0});function t2(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function i2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function n2(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),u=o-r,m=c-n;if(r<o&&n<c){const g=t.width*t.height,p=e.width*e.height,y=u*m,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const s2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,m=n.get(u);if(m){const g=n2(m,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(t2)};function r2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function eC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:xs}function a2(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((u,m)=>({...u,top:u.top+e*m.y,bottom:u.bottom+e*m.y,left:u.left+e*m.x,right:u.right+e*m.x}),{...n})}}const o2=a2(1);function l2(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 c2(e,t,n){const r=l2(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:m}=r,g=e.left-u-(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 u2={ignoreTransform:!1};function Iu(e,t){t===void 0&&(t=u2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=On(e).getComputedStyle(e);p&&(n=c2(n,p,y))}const{top:r,left:o,width:c,height:u,bottom:m,right:g}=n;return{top:r,left:o,width:c,height:u,bottom:m,right:g}}function N0(e){return Iu(e,{ignoreTransform:!0})}function d2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function h2(e,t){return t===void 0&&(t=On(e).getComputedStyle(e)),t.position==="fixed"}function f2(e,t){t===void 0&&(t=On(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 k_(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(C_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Bu(o)||G1(o)||n.includes(o))return n;const c=On(e).getComputedStyle(o);return o!==e&&f2(o,c)&&n.push(o),h2(o,c)?n:r(o.parentNode)}return e?r(e):n}function tC(e){const[t]=k_(e,1);return t??null}function Km(e){return!pf||!e?null:Bl(e)?e:w_(e)?C_(e)||e===jl(e).scrollingElement?window:Bu(e)?e:null:null}function iC(e){return Bl(e)?e.scrollX:e.scrollLeft}function nC(e){return Bl(e)?e.scrollY:e.scrollTop}function Ng(e){return{x:iC(e),y:nC(e)}}var qi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(qi||(qi={}));function sC(e){return!pf||!e?!1:e===document.scrollingElement}function rC(e){const t={x:0,y:0},n=sC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,u=e.scrollTop>=r.y,m=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:u,isRight:m,maxScroll:r,minScroll:t}}const p2={x:.2,y:.2};function m2(e,t,n,r,o){let{top:c,left:u,right:m,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=p2);const{isTop:p,isBottom:y,isLeft:b,isRight:S}=rC(e),w={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?(w.y=qi.Backward,x.y=r*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(w.y=qi.Forward,x.y=r*Math.abs((t.bottom-D.height-g)/D.height)),!S&&m>=t.right-D.width?(w.x=qi.Forward,x.x=r*Math.abs((t.right-D.width-m)/D.width)):!b&&u<=t.left+D.width&&(w.x=qi.Backward,x.x=r*Math.abs((t.left+D.width-u)/D.width)),{direction:w,speed:x}}function g2(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function aC(e){return e.reduce((t,n)=>Tl(t,Ng(n)),xs)}function v2(e){return e.reduce((t,n)=>t+iC(n),0)}function _2(e){return e.reduce((t,n)=>t+nC(n),0)}function b2(e,t){if(t===void 0&&(t=Iu),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);tC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const y2=[["x",["left","right"],v2],["y",["top","bottom"],_2]];class T_{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=k_(n),o=aC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,m]of y2)for(const g of u)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 au{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 S2(e){const{EventTarget:t}=On(e);return e instanceof t?e:jl(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 os;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(os||(os={}));function A0(e){e.preventDefault()}function w2(e){e.stopPropagation()}var Ft;(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"})(Ft||(Ft={}));const oC={start:[Ft.Space,Ft.Enter],cancel:[Ft.Esc],end:[Ft.Space,Ft.Enter,Ft.Tab]},C2=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Ft.Right:return{...n,x:n.x+25};case Ft.Left:return{...n,x:n.x-25};case Ft.Down:return{...n,y:n.y+25};case Ft.Up:return{...n,y:n.y-25}}};class lC{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 au(jl(n)),this.windowListeners=new au(On(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(os.Resize,this.handleCancel),this.windowListeners.add(os.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(os.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&b2(r),n(xs)}handleKeyDown(t){if(Q1(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=oC,coordinateGetter:u=C2,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}:xs;this.referenceCoordinates||(this.referenceCoordinates=y);const b=u(t,{active:n,context:r.current,currentCoordinates:y});if(b){const S=Wh(b,y),w={x:0,y:0},{scrollableAncestors:x}=r.current;for(const D of x){const O=t.code,{isTop:N,isRight:j,isLeft:q,isBottom:F,maxScroll:ie,minScroll:Q}=rC(D),$=g2(D),Se={x:Math.min(O===Ft.Right?$.right-$.width/2:$.right,Math.max(O===Ft.Right?$.left:$.left+$.width/2,b.x)),y:Math.min(O===Ft.Down?$.bottom-$.height/2:$.bottom,Math.max(O===Ft.Down?$.top:$.top+$.height/2,b.y))},ne=O===Ft.Right&&!j||O===Ft.Left&&!q,De=O===Ft.Down&&!F||O===Ft.Up&&!N;if(ne&&Se.x!==b.x){const se=D.scrollLeft+S.x,V=O===Ft.Right&&se<=ie.x||O===Ft.Left&&se>=Q.x;if(V&&!S.y){D.scrollTo({left:se,behavior:m});return}V?w.x=D.scrollLeft-se:w.x=O===Ft.Right?D.scrollLeft-ie.x:D.scrollLeft-Q.x,w.x&&D.scrollBy({left:-w.x,behavior:m});break}else if(De&&Se.y!==b.y){const se=D.scrollTop+S.y,V=O===Ft.Down&&se<=ie.y||O===Ft.Up&&se>=Q.y;if(V&&!S.x){D.scrollTo({top:se,behavior:m});return}V?w.y=D.scrollTop-se:w.y=O===Ft.Down?D.scrollTop-ie.y:D.scrollTop-Q.y,w.y&&D.scrollBy({top:-w.y,behavior:m});break}}this.handleMove(t,Tl(Wh(b,this.referenceCoordinates),w))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}lC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=oC,onActivation:o}=t,{active:c}=n;const{code:u}=e.nativeEvent;if(r.start.includes(u)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function L0(e){return!!(e&&"distance"in e)}function O0(e){return!!(e&&"delay"in e)}class E_{constructor(t,n,r){var o;r===void 0&&(r=S2(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:u}=c;this.props=t,this.events=n,this.document=jl(u),this.documentListeners=new au(this.document),this.listeners=new au(r),this.windowListeners=new au(On(u)),this.initialCoordinates=(o=Rg(c))!=null?o:xs,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(os.Resize,this.handleCancel),this.windowListeners.add(os.DragStart,A0),this.windowListeners.add(os.VisibilityChange,this.handleCancel),this.windowListeners.add(os.ContextMenu,A0),this.documentListeners.add(os.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(O0(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(L0(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(os.Click,w2,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(os.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=Rg(t))!=null?n:xs,p=Wh(o,g);if(!r&&m){if(L0(m)){if(m.tolerance!=null&&Wm(p,m.tolerance))return this.handleCancel();if(Wm(p,m.distance))return this.handleStart()}if(O0(m)&&Wm(p,m.tolerance))return this.handleCancel();this.handlePending(m,p);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Ft.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const x2={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cC extends E_{constructor(t){const{event:n}=t,r=jl(n.target);super(t,x2,r)}}cC.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 k2={move:{name:"mousemove"},end:{name:"mouseup"}};var Ag;(function(e){e[e.RightClick=2]="RightClick"})(Ag||(Ag={}));class uC extends E_{constructor(t){super(t,k2,jl(t.event.target))}}uC.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Ag.RightClick?!1:(r?.({event:n}),!0)}}];const Fm={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class dC extends E_{constructor(t){super(t,Fm)}static setup(){return window.addEventListener(Fm.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Fm.move.name,t)};function t(){}}}dC.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 ou;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ou||(ou={}));var $h;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})($h||($h={}));function T2(e){let{acceleration:t,activator:n=ou.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:m=$h.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:S}=e;const w=D2({delta:b,disabled:!c}),[x,D]=UE(),O=v.useRef({x:0,y:0}),N=v.useRef({x:0,y:0}),j=v.useMemo(()=>{switch(n){case ou.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case ou.DraggableRect:return o}},[n,o,g]),q=v.useRef(null),F=v.useCallback(()=>{const Q=q.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===$h.TreeOrder?[...p].reverse():p,[m,p]);v.useEffect(()=>{if(!c||!p.length||!j){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:De}=m2(Q,Se,j,t,S);for(const se of["x","y"])w[se][ne[se]]||(De[se]=0,ne[se]=0);if(De.x>0||De.y>0){D(),q.current=Q,x(F,u),O.current=De,N.current=ne;return}}O.current={x:0,y:0},N.current={x:0,y:0},D()},[t,F,r,D,c,u,JSON.stringify(j),JSON.stringify(w),x,p,ie,y,JSON.stringify(S)])}const E2={x:{[qi.Backward]:!1,[qi.Forward]:!1},y:{[qi.Backward]:!1,[qi.Forward]:!1}};function D2(e){let{delta:t,disabled:n}=e;const r=Dg(t);return ju(o=>{if(n||!r||!o)return E2;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[qi.Backward]:o.x[qi.Backward]||c.x===-1,[qi.Forward]:o.x[qi.Forward]||c.x===1},y:{[qi.Backward]:o.y[qi.Backward]||c.y===-1,[qi.Forward]:o.y[qi.Forward]||c.y===1}}},[n,t,r])}function R2(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return ju(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function M2(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...n,...c]},[]),[e,t])}var _u;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(_u||(_u={}));var Lg;(function(e){e.Optimized="optimized"})(Lg||(Lg={}));const B0=new Map;function N2(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:m,measure:g,strategy:p}=o,y=v.useRef(e),b=O(),S=vu(b),w=v.useCallback(function(N){N===void 0&&(N=[]),!S.current&&u(j=>j===null?N:j.concat(N.filter(q=>!j.includes(q))))},[S]),x=v.useRef(null),D=ju(N=>{if(b&&!n)return B0;if(!N||N===B0||y.current!==e||c!=null){const j=new Map;for(let q of e){if(!q)continue;if(c&&c.length>0&&!c.includes(q.id)&&q.rect.current){j.set(q.id,q.rect.current);continue}const F=q.node.current,ie=F?new T_(g(F),F):null;q.rect.current=ie,ie&&j.set(q.id,ie)}return j}return N},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||w()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},m))},[m,b,w,...r]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function O(){switch(p){case _u.Always:return!1;case _u.BeforeDragging:return n;default:return!n}}}function hC(e,t){return ju(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function A2(e,t){return hC(e,t)}function L2(e){let{callback:t,disabled:n}=e;const r=x_(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 gf(e){let{callback:t,disabled:n}=e;const r=x_(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 O2(e){return new T_(Iu(e),e)}function j0(e,t,n){t===void 0&&(t=O2);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 u=L2({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=gf({callback:c});return ja(()=>{c(),e?(m?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),u?.disconnect())},[e]),r}function B2(e){const t=hC(e);return eC(e,t)}const I0=[];function j2(e){const t=v.useRef(e),n=ju(r=>e?r&&r!==I0&&e&&t.current&&e.parentNode===t.current.parentNode?r:k_(e):I0,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function I2(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=Km(c.target);u&&n(m=>m?(m.set(u,Ng(u)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const m=e.map(g=>{const p=Km(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Ng(p)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),r.current=e}return()=>{u(e),u(c)};function u(m){m.forEach(g=>{const p=Km(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>Tl(c,u),xs):aC(e):xs,[e,t])}function z0(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==xs;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Wh(e,n.current):xs}function z2(e){v.useEffect(()=>{if(!pf)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 P2(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=u=>{c(u,t)},n},{}),[e,t])}function fC(e){return v.useMemo(()=>e?d2(e):null,[e])}const P0=[];function H2(e,t){t===void 0&&(t=Iu);const[n]=e,r=fC(n?On(n):null),[o,c]=v.useState(P0);function u(){c(()=>e.length?e.map(g=>sC(g)?r:new T_(t(g),g)):P0)}const m=gf({callback:u});return ja(()=>{m?.disconnect(),u(),e.forEach(g=>m?.observe(g))},[e]),o}function U2(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Bu(t)?t:e}function K2(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if(Bu(y)){r(b=>{const S=t(y);return b?{...b,width:S.width,height:S.height}:S});break}},[t]),c=gf({callback:o}),u=v.useCallback(p=>{const y=U2(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[m,g]=Kh(u);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const W2=[{sensor:cC,options:{}},{sensor:lC,options:{}}],F2={current:{}},xh={draggable:{measure:N0},droppable:{measure:N0,strategy:_u.WhileDragging,frequency:Lg.Optimized},dragOverlay:{measure:Iu}};class lu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const $2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new lu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Fh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:xh,measureDroppableContainers:Fh,windowRect:null,measuringScheduled:!1},q2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Fh,draggableNodes:new Map,over:null,measureDroppableContainers:Fh},vf=v.createContext(q2),V2=v.createContext($2);function Y2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new lu}}}function X2(e,t){switch(t.type){case Ii.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ii.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 Ii.DragEnd:case Ii.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ii.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new lu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case Ii.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const u=new lu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case Ii.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new lu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function G2(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(vf),c=Dg(r),u=Dg(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!Q1(c)||document.activeElement===c.target)return;const m=o.get(u);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=FE(y);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function Z2(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function Q2(e){return v.useMemo(()=>({draggable:{...xh.draggable,...e?.draggable},droppable:{...xh.droppable,...e?.droppable},dragOverlay:{...xh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function J2(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:m}=typeof o=="boolean"?{x:o,y:o}:o;ja(()=>{if(!u&&!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=eC(y,r);if(u||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const S=tC(p);S&&S.scrollBy({top:b.y,left:b.x})}},[t,u,m,r,n])}const pC=v.createContext({...xs,scaleX:1,scaleY:1});var Ta;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ta||(Ta={}));const eD=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:m,autoScroll:g=!0,children:p,sensors:y=W2,collisionDetection:b=s2,measuring:S,modifiers:w,...x}=t;const D=v.useReducer(X2,void 0,Y2),[O,N]=D,[j,q]=GE(),[F,ie]=v.useState(Ta.Uninitialized),Q=F===Ta.Initialized,{draggable:{active:$,nodes:Se,translate:ne},droppable:{containers:De}}=O,se=$!=null?Se.get($):null,V=v.useRef({initial:null,translated:null}),X=v.useMemo(()=>{var Qe;return $!=null?{id:$,data:(Qe=se?.data)!=null?Qe:F2,rect:V}:null},[$,se]),W=v.useRef(null),[le,L]=v.useState(null),[R,B]=v.useState(null),ae=vu(x,Object.values(x)),ye=mf("DndDescribedBy",u),M=v.useMemo(()=>De.getEnabled(),[De]),K=Q2(S),{droppableRects:ce,measureDroppableContainers:we,measuringScheduled:Le}=N2(M,{dragging:Q,dependencies:[ne.x,ne.y],config:K.droppable}),xe=R2(Se,$),Be=v.useMemo(()=>R?Rg(R):null,[R]),Re=it(),He=A2(xe,K.draggable.measure);J2({activeNode:$!=null?Se.get($):null,config:Re.layoutShiftCompensation,initialRect:He,measure:K.draggable.measure});const Fe=j0(xe,K.draggable.measure,He),ee=j0(xe?xe.parentElement:null),fe=v.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ce,draggableNodes:Se,draggingNode:null,draggingNodeRect:null,droppableContainers:De,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),H=De.getNodeFor((n=fe.current.over)==null?void 0:n.id),ue=K2({measure:K.dragOverlay.measure}),ke=(r=ue.nodeRef.current)!=null?r:xe,Ne=Q?(o=ue.rect)!=null?o:Fe:null,te=!!(ue.nodeRef.current&&ue.rect),Ee=B2(te?null:Fe),me=fC(ke?On(ke):null),Oe=j2(Q?H??xe:null),ze=H2(Oe),Je=Z2(w,{transform:{x:ne.x-Ee.x,y:ne.y-Ee.y,scaleX:1,scaleY:1},activatorEvent:R,active:X,activeNodeRect:Fe,containerNodeRect:ee,draggingNodeRect:Ne,over:fe.current.over,overlayNodeRect:ue.rect,scrollableAncestors:Oe,scrollableAncestorRects:ze,windowRect:me}),rt=Be?Tl(Be,ne):null,zt=I2(Oe),gn=z0(zt),oi=z0(zt,[Fe]),mi=Tl(Je,gn),qe=Ne?o2(Ne,Je):null,Ct=X&&qe?b({active:X,collisionRect:qe,droppableRects:ce,droppableContainers:M,pointerCoordinates:rt}):null,$t=i2(Ct,"id"),[_e,Ve]=v.useState(null),nt=te?Je:Tl(Je,oi),Xe=r2(nt,(c=_e?.rect)!=null?c:null,Fe),xt=v.useRef(null),lt=v.useCallback((Qe,wt)=>{let{sensor:qt,options:Pt}=wt;if(W.current==null)return;const li=Se.get(W.current);if(!li)return;const Vt=Qe.nativeEvent,ii=new qt({active:W.current,activeNode:li,event:Vt,options:Pt,context:fe,onAbort(Ht){if(!Se.get(Ht))return;const{onDragAbort:Qt}=ae.current,Hi={id:Ht};Qt?.(Hi),j({type:"onDragAbort",event:Hi})},onPending(Ht,ln,Qt,Hi){if(!Se.get(Ht))return;const{onDragPending:_n}=ae.current,Jt={id:Ht,constraint:ln,initialCoordinates:Qt,offset:Hi};_n?.(Jt),j({type:"onDragPending",event:Jt})},onStart(Ht){const ln=W.current;if(ln==null)return;const Qt=Se.get(ln);if(!Qt)return;const{onDragStart:Hi}=ae.current,vn={activatorEvent:Vt,active:{id:ln,data:Qt.data,rect:V}};Xc.unstable_batchedUpdates(()=>{Hi?.(vn),ie(Ta.Initializing),N({type:Ii.DragStart,initialCoordinates:Ht,active:ln}),j({type:"onDragStart",event:vn}),L(xt.current),B(Vt)})},onMove(Ht){N({type:Ii.DragMove,coordinates:Ht})},onEnd:ci(Ii.DragEnd),onCancel:ci(Ii.DragCancel)});xt.current=ii;function ci(Ht){return async function(){const{active:Qt,collisions:Hi,over:vn,scrollAdjustedTranslate:_n}=fe.current;let Jt=null;if(Qt&&_n){const{cancelDrop:Qi}=ae.current;Jt={activatorEvent:Vt,active:Qt,collisions:Hi,delta:_n,over:vn},Ht===Ii.DragEnd&&typeof Qi=="function"&&await Promise.resolve(Qi(Jt))&&(Ht=Ii.DragCancel)}W.current=null,Xc.unstable_batchedUpdates(()=>{N({type:Ht}),ie(Ta.Uninitialized),Ve(null),L(null),B(null),xt.current=null;const Qi=Ht===Ii.DragEnd?"onDragEnd":"onDragCancel";if(Jt){const ni=ae.current[Qi];ni?.(Jt),j({type:Qi,event:Jt})}})}}},[Se]),Tn=v.useCallback((Qe,wt)=>(qt,Pt)=>{const li=qt.nativeEvent,Vt=Se.get(Pt);if(W.current!==null||!Vt||li.dndKit||li.defaultPrevented)return;const ii={active:Vt};Qe(qt,wt.options,ii)===!0&&(li.dndKit={capturedBy:wt.sensor},W.current=Pt,lt(qt,wt))},[Se,lt]),gi=M2(y,Tn);z2(y),ja(()=>{Fe&&F===Ta.Initializing&&ie(Ta.Initialized)},[Fe,F]),v.useEffect(()=>{const{onDragMove:Qe}=ae.current,{active:wt,activatorEvent:qt,collisions:Pt,over:li}=fe.current;if(!wt||!qt)return;const Vt={active:wt,activatorEvent:qt,collisions:Pt,delta:{x:mi.x,y:mi.y},over:li};Xc.unstable_batchedUpdates(()=>{Qe?.(Vt),j({type:"onDragMove",event:Vt})})},[mi.x,mi.y]),v.useEffect(()=>{const{active:Qe,activatorEvent:wt,collisions:qt,droppableContainers:Pt,scrollAdjustedTranslate:li}=fe.current;if(!Qe||W.current==null||!wt||!li)return;const{onDragOver:Vt}=ae.current,ii=Pt.get($t),ci=ii&&ii.rect.current?{id:ii.id,rect:ii.rect.current,data:ii.data,disabled:ii.disabled}:null,Ht={active:Qe,activatorEvent:wt,collisions:qt,delta:{x:li.x,y:li.y},over:ci};Xc.unstable_batchedUpdates(()=>{Ve(ci),Vt?.(Ht),j({type:"onDragOver",event:Ht})})},[$t]),ja(()=>{fe.current={activatorEvent:R,active:X,activeNode:xe,collisionRect:qe,collisions:Ct,droppableRects:ce,draggableNodes:Se,draggingNode:ke,draggingNodeRect:Ne,droppableContainers:De,over:_e,scrollableAncestors:Oe,scrollAdjustedTranslate:mi},V.current={initial:Ne,translated:qe}},[X,xe,Ct,qe,Se,ke,Ne,ce,De,_e,Oe,mi]),T2({...Re,delta:ne,draggingRect:qe,pointerCoordinates:rt,scrollableAncestors:Oe,scrollableAncestorRects:ze});const Z=v.useMemo(()=>({active:X,activeNode:xe,activeNodeRect:Fe,activatorEvent:R,collisions:Ct,containerNodeRect:ee,dragOverlay:ue,draggableNodes:Se,droppableContainers:De,droppableRects:ce,over:_e,measureDroppableContainers:we,scrollableAncestors:Oe,scrollableAncestorRects:ze,measuringConfiguration:K,measuringScheduled:Le,windowRect:me}),[X,xe,Fe,R,Ct,ee,ue,Se,De,ce,_e,we,Oe,ze,K,Le,me]),Ie=v.useMemo(()=>({activatorEvent:R,activators:gi,active:X,activeNodeRect:Fe,ariaDescribedById:{draggable:ye},dispatch:N,draggableNodes:Se,over:_e,measureDroppableContainers:we}),[R,gi,X,Fe,N,ye,Se,_e,we]);return Ni.createElement(J1.Provider,{value:q},Ni.createElement(vf.Provider,{value:Ie},Ni.createElement(V2.Provider,{value:Z},Ni.createElement(pC.Provider,{value:Xe},p)),Ni.createElement(G2,{disabled:m?.restoreFocus===!1})),Ni.createElement(JE,{...m,hiddenTextDescribedById:ye}));function it(){const Qe=le?.autoScrollEnabled===!1,wt=typeof g=="object"?g.enabled===!1:g===!1,qt=Q&&!Qe&&!wt;return typeof g=="object"?{...g,enabled:qt}:{enabled:qt}}}),tD=v.createContext(null),H0="button",iD="Draggable";function mC(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=mf(iD),{activators:u,activatorEvent:m,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:S}=v.useContext(vf),{role:w=H0,roleDescription:x="draggable",tabIndex:D=0}=o??{},O=g?.id===t,N=v.useContext(O?pC:tD),[j,q]=Kh(),[F,ie]=Kh(),Q=P2(u,t),$=vu(n);ja(()=>(b.set(t,{id:t,key:c,node:j,activatorNode:F,data:$}),()=>{const ne=b.get(t);ne&&ne.key===c&&b.delete(t)}),[b,t]);const Se=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":r,"aria-pressed":O&&w===H0?!0:void 0,"aria-roledescription":x,"aria-describedby":y.draggable}),[r,w,D,O,x,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:p,attributes:Se,isDragging:O,listeners:r?void 0:Q,node:j,over:S,setNodeRef:q,setActivatorNodeRef:ie,transform:N}}const nD="Droppable",sD={timeout:25};function D_(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=mf(nD),{active:u,dispatch:m,over:g,measureDroppableContainers:p}=v.useContext(vf),y=v.useRef({disabled:n}),b=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:O}={...sD,...o},N=vu(D??r),j=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{p(Array.isArray(N.current)?N.current:[N.current]),w.current=null},O)},[O]),q=gf({callback:j,disabled:x||!u}),F=v.useCallback((Se,ne)=>{q&&(ne&&(q.unobserve(ne),b.current=!1),Se&&q.observe(Se))},[q]),[ie,Q]=Kh(F),$=vu(t);return v.useEffect(()=>{!q||!ie.current||(q.disconnect(),b.current=!1,q.observe(ie.current))},[ie,q]),v.useEffect(()=>(m({type:Ii.RegisterDroppable,element:{id:r,key:c,disabled:n,node:ie,rect:S,data:$}}),()=>m({type:Ii.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:Ii.SetDroppableDisabled,id:r,key:c,disabled:n}),y.current.disabled=n)},[r,c,n,m]),{active:u,rect:S,isOver:g?.id===r,node:ie,over:g,setNodeRef:Q}}const rD=128,aD=512,Il=100,oD="too_many_detached_terminals",lD=64,cD=4096;function gC(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>rD)return null;const n=t.workspaces.map(uD);if(n.some(u=>u===null))return null;const r=n,o=new Set,c=new Set;for(const u of r){if(o.has(u.id))return null;o.add(u.id);for(const m of u.tabs){if(c.has(m.id))return null;c.add(m.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function vC(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>Il}):!1}function uD(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>aD)return null;const n=t.tabs.map(dD);if(n.some(o=>o===null))return null;const r=mD(t.detachedTerminalIds,Il);return r===null?null:{id:t.id,title:t.title,defaultCwd:pD(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function dD(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=hD(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function hD(e){if(!e||typeof e!="object")return null;let t=0;return Og(e,1,()=>(t+=1,t<=cD))}function Og(e,t,n){if(!e||typeof e!="object"||t>lD||!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=Og(r.first,t+1,n),c=Og(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:fD(r.ratio),first:o,second:c}}function fD(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function pD(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function mD(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 _C=[{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"}],gD="nterminal-focus",vD=/^[A-Za-z0-9_.:-]{1,128}$/;function _D(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(gD)!=="terminal"?null:_f({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function _f(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!U0(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!U0(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function U0(e){return typeof e=="string"&&vD.test(e)}const Vi="__main__",bC=128,bD=600*1e3,yC="nterminal.clientDiagnostics.v1",SC="nterminal.terminalDiagnosticsCursor.v1",bf=150,yD=24,SD=160,wD=48*1024,CD="terminal-connection-recovery";let K0=!1,zc=null,Pc=null,$m=0;function xD(){K0||typeof window>"u"||(K0=!0,mn("page.load",{navigation:UD(),visibility:document.visibilityState,online:navigator.onLine,viewport:TC(),standalone:HD()}),document.addEventListener("visibilitychange",()=>{mn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{mn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{mn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>mn("network.online")),window.addEventListener("offline",()=>mn("network.offline")),window.addEventListener("focus",()=>mn("window.focus")),window.addEventListener("blur",()=>mn("window.blur")),window.addEventListener("error",e=>{mn("runtime.error",{message:e.message,source:KD(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{mn("runtime.unhandledrejection",{reason:WD(e.reason)})}))}function mn(e,t={}){const n={id:LD(),at:new Date().toISOString(),event:bu(e,80),data:kC({...t,visibility:t.visibility??zD(),online:t.online??PD(),viewport:t.viewport??TC()})},r=R_();return r.push(n),ND(r.slice(-bf)),n}function R_(){try{const e=window.localStorage.getItem(yC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(AD).filter(n=>n!==null).slice(-bf):[]}catch{return[]}}async function M_(e,t=fetch){if(zc)return zc;const n=R_(),r={reason:bu(e,80),events:n},o=JSON.stringify(r);zc=(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 zc}finally{zc=null}}function yf(){return wC().events.length>0}async function kD(e=fetch){if(Pc)return Pc;Pc=TD(e);try{return await Pc}finally{Pc=null}}async function TD(e){const t=wC();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(MD(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function wC(){const e=CC(),t=R_().filter(o=>ED(o)&&RD(o,e)),n=[];let r=W0([]);for(const o of t){const c=[...n,o],u=W0(c);if(DD(u)>wD)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function W0(e){return JSON.stringify({reason:CD,events:e})}function ED(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function DD(e){return new TextEncoder().encode(e).byteLength}function RD(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(xC(e))}function CC(){try{const e=window.localStorage.getItem(SC);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-bf):[]}}catch{return null}}function MD(e){const t=e.at(-1);if(!t)return;const n=CC(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(xC(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-bf)};try{window.localStorage.setItem(SC,JSON.stringify(o))}catch{}}function ND(e){try{window.localStorage.setItem(yC,JSON.stringify(e))}catch{}}function AD(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:bu(t.id,128)}:{},at:t.at.slice(0,40),event:bu(t.event,80),...t.data&&typeof t.data=="object"?{data:kC(t.data)}:{}}}function LD(){return $m=($m+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${$m.toString(36)}`.slice(0,128)}function xC(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function kC(e){const t={};for(const[n,r]of Object.entries(e).slice(0,yD)){const o=bu(n,64);if(!o||OD(o))continue;const c=BD(r);c!==void 0&&(t[o]=c)}return t}function OD(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function BD(e){if(typeof e=="string")return jD(e,SD);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function bu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function jD(e,t){return ID(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function ID(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 zD(){return typeof document>"u"?void 0:document.visibilityState}function PD(){return typeof navigator>"u"?void 0:navigator.onLine}function TC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function HD(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function UD(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function KD(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 WD(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const EC="nterminal.notifications.completionEnabled",N_="nterminal.notifications.completionToastEnabled",A_="nterminal.notifications.completionToastDurationSeconds",L_="nterminal.notifications.completionToastPersistent",Bg="nterminal:completion-toast-display",jg="nterminal:notification-focus",cu=6.5,Ig=2,zg=60;function Sf(){return typeof window<"u"&&"Notification"in window}function O_(){try{return window.localStorage.getItem(EC)==="true"}catch{return!1}}function F0(e){try{window.localStorage.setItem(EC,e?"true":"false")}catch{}}function wo(){return{enabled:VD(),durationSeconds:qD(),persistUntilDismissed:YD()}}function FD(e){if(typeof window<"u"){try{window.localStorage.setItem(N_,e?"true":"false")}catch{}B_()}return wo()}function $0(e){const t=RC(e);if(typeof window<"u"){try{window.localStorage.setItem(A_,String(t))}catch{}B_()}return wo()}function $D(e){if(typeof window<"u"){try{window.localStorage.setItem(L_,e?"true":"false")}catch{}B_()}return wo()}function DC(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===N_||n.key===A_||n.key===L_)&&e()};return window.addEventListener(Bg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bg,e),window.removeEventListener("storage",t)}}function zl(){return Sf()?window.Notification.permission:"unsupported"}function qD(){if(typeof window>"u")return cu;try{const e=window.localStorage.getItem(A_);return e===null?cu:RC(Number(e))}catch{return cu}}function VD(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(N_)!=="false"}catch{return!0}}function YD(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(L_)==="true"}catch{return!1}}function RC(e){if(!Number.isFinite(e))return cu;const t=Math.round(e*2)/2;return Math.max(Ig,Math.min(zg,t))}function B_(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Bg))}async function MC(){if(!Sf())return"unsupported";try{return await window.Notification.requestPermission()}catch{return zl()}}function XD(e){if(!Sf()||zl()!=="granted"||!O_()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=_f({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(),GD(r)})}catch{}}function GD(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(jg,{detail:e}))}const q0="nterminal.push.clientId",ZD=2e4,V0=[5e3,3e4,12e4];function Rr(){try{const e=window.localStorage.getItem(q0);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Hg()}`;return window.localStorage.setItem(q0,t),t}catch{return`client-${Hg()}`}}function QD(){return`page-${Hg()}`}function wf(){const e=typeof window<"u"&&window.isSecureContext===!0,t=rR(),n=aR(),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 JD(e,t){const n=wf();if(!n.supported)throw new Error(n.reason);if((zl()==="granted"?"granted":await MC())!=="granted")throw new Error("permission_denied");const o=Rr(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await lR(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:LC(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:AC(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:NC(n.deviceKind),alwaysNotify:t})}async function eR(e){const t=wf();if(!t.supported||zl()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Rr(),c=await cR(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&Pg(r,u.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&Pg(r,m.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:LC(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:AC(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:NC(t.deviceKind),alwaysNotify:!1}),!0}function tR(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=y=>{t||n||(n=!0,eR(e).then(b=>{r=0,b&&mn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(mn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&r<V0.length){const S=V0[r++];o=window.setTimeout(()=>{o=null,u("retry")},S)}}).finally(()=>{n=!1}))},m=y=>{c(),r=0,u(y)},g=()=>m("online"),p=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function iR(e){const t=Rr();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 nR(e,t){await e.updatePushNotificationDevice({clientId:Rr(),alwaysNotify:t})}function sR(e){if(typeof window>"u")return()=>{};const t=Rr(),n=QD();let r=null,o=!1;const c=(p=!0)=>{const y=wf();e.updatePushPresence({clientId:t,pageId:n,visibilityState:oR(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:O_()&&zl()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),ZD))},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),u(),()=>{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 rR(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function aR(){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 NC(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function oR(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function AC(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 lR(e,t){const n=await e.pushManager.getSubscription();return n?Pg(n,t)?n:(await n.unsubscribe(),null):null}function Pg(e,t){const n=e.options.applicationServerKey;return n?OC(n)===t:!0}async function cR(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return OC(t)}function LC(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let u=0;u<r.length;u+=1)c[u]=r.charCodeAt(u);return o}function OC(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 Hg(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Dr(e,t){const n=[Vi,...t.map(u=>u.id)],r=new Set(n),o=new Set,c=[];for(const u of e??[])!r.has(u)||o.has(u)||(o.add(u),c.push(u));for(const u of n)o.has(u)||c.push(u);return c}function uR(e,t){return Dr(e,t).map(n=>n===Vi?null:n)}function dR(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function hR(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Y0="Local",fR=3e4,pR=2,mR=6,BC="nterminal.serverList.viewMode.v1";function gR(){try{return window.localStorage.getItem(BC)==="list"?"list":"stats"}catch{return"stats"}}function vR(e){try{window.localStorage.setItem(BC,e)}catch{}}function _R(e,t){const n=new Map(e.map(r=>[r.id,r]));return Dr(t,e).flatMap(r=>{if(r===Vi)return[{kind:"main",id:Vi}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function X0(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function jC(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${cs(e.value.cpuPercent)} ${j_(e.value)}`,`MEM ${cs(e.value.memoryPercent)} ${Ar(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${cs(e.value.diskPercent)} ${Ar(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${cs(e.value.swapPercent)} ${Ar(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function G0(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${cs(e.value.cpuPercent)} (${j_(e.value)})`,`RAM ${cs(e.value.memoryPercent)} (${Ar(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${cs(e.value.diskPercent)} (${Ar(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${cs(e.value.swapPercent)} (${Ar(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function bR(e,t){const n=jC(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function cs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function j_(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`:`${Ug(e.cpuPercent/100*t)}/${t} cores`}function Ar(e,t){return!Z0(e)||!Z0(t)?"–/–":yR(e,t)}function yR(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Ug(e/r)}/${Ug(t/r)} ${n}`}function Ug(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Z0(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function oh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function SR(e){return[{label:"CPU",percent:cs(e.cpuPercent),detail:j_(e),tone:oh(e.cpuPercent)},{label:"MEM",percent:cs(e.memoryPercent),detail:Ar(e.memoryUsedBytes,e.memoryTotalBytes),tone:oh(e.memoryPercent)},{label:"DISK",percent:cs(e.diskPercent),detail:Ar(e.diskUsedBytes,e.diskTotalBytes),tone:oh(e.diskPercent)},{label:"SWAP",percent:cs(e.swapPercent),detail:Ar(e.swapUsedBytes,e.swapTotalBytes),tone:oh(e.swapPercent)}]}function wR({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:G0(e),"aria-label":G0(e),children:SR(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 Q0({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,renderServerChildren:u,compact:m=!1}){const[g,p]=v.useState([]),[y,b]=v.useState([Vi]),[S,w]=v.useState(null),[x,D]=v.useState(null),[O,N]=v.useState(""),j=v.useRef(null),[q,F]=v.useState(()=>gR()),[ie,Q]=v.useState(null),[$,Se]=v.useState(null),[ne,De]=v.useState({}),se=v.useRef({}),V=v.useRef(0),X=v.useRef([]),W=v.useRef([Vi]),le=v.useRef(null);v.useEffect(()=>{X.current=g},[g]),v.useEffect(()=>{const ee=Dr(y,g);W.current=ee,X0(ee,y)||b(ee)},[g,y]),v.useEffect(()=>{let ee=!1;return e.listAgents().then(fe=>{ee||(p(fe.agents),b(Dr(fe.serverOrder,fe.agents)))}).catch(()=>{}),e.getMainInfo().then(fe=>{ee||w(fe.name)}).catch(()=>{}),()=>{ee=!0}},[e,o]),v.useEffect(()=>{x&&(j.current?.focus(),j.current?.select())},[x]),v.useEffect(()=>{let ee=!1;function fe(){const ue=[{key:Vi,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}))],ke=new Set(ue.map(Ne=>Ne.key));for(const Ne of Object.keys(se.current))ke.has(Ne)||delete se.current[Ne];De(Ne=>{const te={};for(const Ee of ke)Ee in Ne&&(te[Ee]=Ne[Ee]);return te});for(const Ne of ue)Ne.load().then(te=>{ee||(se.current[Ne.key]=0,De(Ee=>ke.has(Ne.key)?{...Ee,[Ne.key]:{status:"online",value:te,stale:!1}}:Ee))}).catch(async te=>{if(ee)return;if(te instanceof Ln&&te.status===401&&Ne.key===Vi){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(Ne.key===Vi&&te instanceof Ln){se.current[Ne.key]=0,De(me=>{if(!ke.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(ee)return;se.current[Ne.key]=0,De(me=>{if(!ke.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(ee)return;if(me instanceof Ln&&me.status===401){r?.({source:Ne.key===Vi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const Ee=(se.current[Ne.key]??0)+1;se.current[Ne.key]=Ee,Ee>=pR&&De(me=>ke.has(Ne.key)?{...me,[Ne.key]:{status:"offline",value:me[Ne.key]?.value??null,stale:!0}}:me)})}fe();const H=window.setInterval(fe,fR);return()=>{ee=!0,window.clearInterval(H)}},[e,g,r]);function L(ee){ee==="main"?(N(S??""),D({kind:"main"})):(N(ee.name),D({kind:"agent",id:ee.id}))}async function R(){if(!x)return;const ee=O.trim(),fe=x;if(D(null),fe.kind==="main"){const H=ee||"";try{const ue=await e.renameMain(H);w(ue.name)}catch{}}else{if(!ee)return;const H=g.find(ue=>ue.id===fe.id)?.name;p(ue=>ue.map(ke=>ke.id===fe.id?{...ke,name:ee}:ke));try{await e.renameAgent(fe.id,ee)}catch{H!==void 0&&p(ue=>ue.map(ke=>ke.id===fe.id?{...ke,name:H}:ke))}}}function B(){D(null)}function ae(ee){F(ee),vR(ee)}function ye(ee,fe,H){if(ee===fe)return;const ue=Dr(W.current,X.current),ke=ue.findIndex(Je=>Je===ee),Ne=ue.findIndex(Je=>Je===fe);if(ke<0||Ne<0)return;const te=[...ue],[Ee]=te.splice(ke,1);if(!Ee)return;const me=te.findIndex(Je=>Je===fe);if(me<0)return;const Oe=H==="before"?me:me+1;if(te.splice(Oe,0,Ee),X0(te,ue))return;const ze=V.current+1;V.current=ze,W.current=te,b(te),e.reorderAgents(te).then(Je=>{if(V.current===ze){X.current=Je.agents;const rt=Dr(Je.serverOrder,Je.agents);W.current=rt,p(Je.agents),b(rt)}}).catch(async()=>{if(V.current===ze)try{const Je=await e.listAgents();if(V.current===ze){X.current=Je.agents;const rt=Dr(Je.serverOrder,Je.agents);W.current=rt,p(Je.agents),b(rt)}}catch{V.current===ze&&(W.current=ue,b(ue))}})}function M(ee,fe){const H=Dr(W.current,X.current),ue=H.findIndex(Ne=>Ne===ee),ke=H[ue+fe];ue<0||!ke||ye(ee,ke,fe<0?"before":"after")}function K(ee,fe){fe.pointerType==="mouse"&&fe.button!==0||(fe.stopPropagation(),le.current={sourceId:ee,pointerId:fe.pointerId,startX:fe.clientX,startY:fe.clientY,active:!1,targetId:null,placement:"after"},fe.currentTarget.setPointerCapture?.(fe.pointerId))}function ce(ee){const fe=le.current;if(!fe||fe.pointerId!==ee.pointerId)return;const H=Math.hypot(ee.clientX-fe.startX,ee.clientY-fe.startY);if(!fe.active){if(H<mR)return;fe.active=!0,Q(fe.sourceId)}const ke=document.elementFromPoint(ee.clientX,ee.clientY)?.closest("[data-server-id]"),Ne=ke?.dataset.serverId??null;if(!ke||!Ne||Ne===fe.sourceId){fe.targetId=null,Se(null);return}const te=ke.getBoundingClientRect(),Ee=ee.clientY<te.top+te.height/2?"before":"after";fe.targetId=Ne,fe.placement=Ee,Se({serverId:Ne,placement:Ee})}function we(ee){const fe=le.current;!fe||fe.pointerId!==ee.pointerId||(ee.stopPropagation(),ee.currentTarget.releasePointerCapture?.(ee.pointerId),le.current=null,Q(null),Se(null),fe.active&&fe.targetId&&ye(fe.sourceId,fe.targetId,fe.placement))}function Le(ee){const fe=le.current;fe&&fe.pointerId===ee.pointerId&&ee.currentTarget.releasePointerCapture?.(ee.pointerId),le.current=null,Q(null),Se(null)}const xe=S?.trim()||Y0,Be=x?.kind==="main",Re=q==="stats",He=_R(g,y),Fe=He.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:xe},...g.map(ee=>({agentId:ee.id,label:ee.name}))])},[g,xe,c]),m?f.jsx("div",{className:"server-list server-list--compact",children:He.map(ee=>{const fe=ee.kind==="main",H=fe?xe:ee.agent.name,ue=fe?Vi:ee.id,ke=ne[ue],Ne=jC(ke);return f.jsxs("button",{type:"button",className:`server-list-chip${(fe?t===null:t===ee.id)?" server-list-chip--active":""}`,onClick:()=>n(fe?null:ee.id),"aria-label":`${H}${Ne?` — ${Ne}`:""}`,title:`${H}${Ne?` — ${Ne}`:""}`,children:[f.jsx("span",{className:"server-list-chip-initial",children:hR(H)}),f.jsx("span",{className:"server-list-chip-pip","data-status":dR(ke)})]},ee.id)})}):f.jsxs("div",{className:`server-list server-list--${q}`,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":q==="list",onClick:()=>ae("list"),title:"Show server names only",children:"List"}),f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":q==="stats",onClick:()=>ae("stats"),title:"Show resource usage",children:"Stats"})]}),He.map(ee=>{const fe=ee.kind==="main",H=fe?xe:ee.agent.name,ue=fe?Vi:ee.id,ke=fe?t===null:t===ee.id,Ne=fe?Be:x?.kind==="agent"&&x.id===ee.id,te=u?.({agentId:fe?null:ee.id,serverId:ee.id,label:H,active:ke}),Ee=$?.serverId===ee.id&&ie!==ee.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===ee.id?"server-list-row--dragging":"",$?.serverId===ee.id&&ie!==ee.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ee.id,children:Ne?f.jsxs(f.Fragment,{children:[Fe?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:j,"aria-label":fe?"Rename main server":`Rename ${H}`,value:O,onChange:me=>N(me.target.value),onBlur:()=>{R()},onKeyDown:me=>{me.key==="Escape"&&(me.preventDefault(),B())},placeholder:fe?Y0:void 0})})]}):f.jsxs(f.Fragment,{children:[Fe?f.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ee.id,title:"Drag to reorder","aria-label":`Reorder ${H}`,"aria-grabbed":ie===ee.id,onPointerDown:me=>K(ee.id,me),onPointerMove:ce,onPointerUp:we,onPointerCancel:Le,onKeyDown:me=>{(me.key==="ArrowUp"||me.key==="ArrowDown")&&(me.preventDefault(),me.stopPropagation(),M(ee.id,me.key==="ArrowUp"?-1:1))},onClick:me=>me.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:`server-list-item${ke?" server-list-item--active":""}`,onClick:()=>n(fe?null:ee.id),onDoubleClick:me=>{me.preventDefault(),L(fe?"main":{id:ee.id,name:H})},title:bR(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:fe?void 0:ee.agent.url??"Outbound connection to main",children:H})]}),Re?f.jsx(wR,{entry:ne[ue]}):null]})]})}),te?f.jsx("div",{className:"server-list-children",children:te}):null]},ee.id)})]})}function CR({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[m,g]=v.useState(null),[p,y]=v.useState(""),[b,S]=v.useState("");async function w(){try{const[N,j,q]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(N.devices),o(j.networks),u(q.totpEnabled),g(null)}catch(N){g(N instanceof Error?N.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(N){await e.revokeDevice(N),await w()}async function D(N){await e.removeNetwork(N),await w()}async function O(N){N.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),S(""),await w()}catch(j){g(j instanceof Error?j.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=>S(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 w()},children:"Disable 2FA"})]}):null]})}const xR=1500,I_="nterminal.terminal.fontSize",z_="nterminal.terminal.fontFamily",Kg="nterminal:terminal-font-size",Wg="nterminal:terminal-font-family",Fg=11,$g=20,_o=14,qh=[{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";qg(Ml);async function qm(e=_o,t=Ml){if(typeof document>"u"||!document.fonts)return;const n=PC(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,xR)})])}function IC(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return _o;const n=Math.round(t);return Math.max(Fg,Math.min($g,n))}function zC(e){return qh.some(t=>t.id===e)?e:Ml}function qg(e){return PC(e).cssFamily}function PC(e){return qh.find(t=>t.id===e)??qh[0]}function Vg(){if(typeof window>"u")return _o;try{const e=window.localStorage.getItem(I_);return e?IC(e):_o}catch{return _o}}function Yg(){if(typeof window>"u")return Ml;try{return zC(window.localStorage.getItem(z_))}catch{return Ml}}function lh(e){const t=IC(e);if(typeof window>"u")return t;try{window.localStorage.setItem(I_,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Kg,{detail:t})),t}function kR(e){const t=zC(e);if(typeof window>"u")return t;try{window.localStorage.setItem(z_,t)}catch{}return window.dispatchEvent(new CustomEvent(Wg,{detail:t})),t}function HC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===I_&&e()};return window.addEventListener(Kg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Kg,e),window.removeEventListener("storage",t)}}function UC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===z_&&e()};return window.addEventListener(Wg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Wg,e),window.removeEventListener("storage",t)}}const P_="nterminal.terminal.showScrollProgress",Xg="nterminal:terminal-scroll-progress",H_="nterminal.terminal.tmuxScrollback.shell",U_="nterminal.terminal.tmuxScrollback.agent",K_="nterminal.terminal.tmuxScrollback.overrides",yu="nterminal:terminal-tmux-scrollback",TR=200;function Gg(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(P_)!=="false"}catch{return!0}}function ER(e){if(typeof window<"u"){try{window.localStorage.setItem(P_,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Xg,{detail:e}))}return e}function KC(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===P_&&e()};return window.addEventListener(Xg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Xg,e),window.removeEventListener("storage",t)}}function Zg(){return WC(H_,!0)}function DR(e){return FC(H_,e,yu)}function Qg(){return WC(U_,!0)}function RR(e){return FC(U_,e,yu)}function kh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===H_||n.key===U_||n.key===K_)&&e()};return window.addEventListener(yu,e),window.addEventListener("storage",t),()=>{window.removeEventListener(yu,e),window.removeEventListener("storage",t)}}function Vm(e){const n=$C()[e];return typeof n=="boolean"?n:null}function MR(e,t){if(typeof window<"u"){try{const n=$C(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-TR);window.localStorage.setItem(K_,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(yu,{detail:{terminalId:e,enabled:t}}))}return t}function WC(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 FC(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 $C(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(K_);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 W_="nterminal.shortcuts.workspace.v1",Jg="nterminal:workspace-shortcuts",Su=[{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}],Cf={"server.previous":hi("ArrowUp",{ctrlKey:!0}),"server.next":hi("ArrowDown",{ctrlKey:!0}),"tab.previous":hi("ArrowLeft",{ctrlKey:!0}),"tab.next":hi("ArrowRight",{ctrlKey:!0}),"tab.index":hi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":hi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":hi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":hi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":hi("KeyH",{altKey:!0}),"subagents.toggle":hi("KeyA",{altKey:!0}),"scrollback.toggle":hi("KeyS",{altKey:!0})},NR={"server.previous":hi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":hi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":hi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":hi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":hi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":hi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":hi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":hi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":hi("KeyH",{altKey:!0}),"subagents.toggle":hi("KeyA",{altKey:!0}),"scrollback.toggle":hi("KeyS",{altKey:!0})};function Co(){const e=YC(Cf);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(W_);if(!t)return e;const n=JSON.parse(t);for(const r of Su){const o=n[r.id];if(PR(o)){const c=XC(o,r);zR(c,NR[r.id])||(e[r.id]=c)}}}catch{return e}return e}function J0(){return JSON.stringify(Co())}function AR(e,t){const n=Co(),r=Su.find(o=>o.id===e);return r&&(n[e]=XC(t,r),F_(n)),n}function LR(e){const t=Co();return t[e]={...Cf[e]},F_(t),t}function OR(){const e=YC(Cf);return F_(e),e}function uu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===W_&&e()};return window.addEventListener(Jg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Jg,e),window.removeEventListener("storage",t)}}function BR(e,t){const n=QC(e);return!n||UR(n)||t.indexed&&ZC(e)===null||t.requiresPrimaryModifier&&!GC(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function qC(e){const t=Co();for(const n of Su){const r=t[n.id];if(!(!r||!HR(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=ZC(e);if(o!==null)return{id:n.id,index:o};continue}if(QC(e)===r.code)return{id:n.id,index:null}}}return null}function du(e){return VC(Co()[e])}function VC(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(KR(e.code)),t.join("+")}const jR=()=>du("split.right"),IR=()=>du("split.down");function hi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function YC(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function zR(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function F_(e){if(!(typeof window>"u")){try{window.localStorage.setItem(W_,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Jg))}}function XC(e,t){return t.requiresPrimaryModifier&&!GC(e)?{...Cf[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function GC(e){return e.ctrlKey||e.altKey||e.metaKey}function PR(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 HR(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function ZC(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 QC(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 UR(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function KR(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 WR="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 FR(e="nterminal",t=new Date){return{reason:"permission",message:WR,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function $R(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 JC=3600*1e3,qR="local",ev=new Set,Ma=new Map;let Ia={checking:!1,hasUpdates:!1,lastCheckedAt:null},$_=null,hu=null,Vh=0,ka=null;function VR(e){return ev.add(e),()=>{ev.delete(e)}}function ew(){return Ia}function YR(e){const t=JR();$_=e,q_(),tv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!za(e,t))return;const r=Ia.lastCheckedAt;(r===null||Date.now()-r>=JC)&&tv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),za(e,t)&&QR()}}function XR(e,t){Ma.set(e,ex(t)),Nl({...Ia,hasUpdates:V_(),lastCheckedAt:Date.now()})}function Ym(e){e===void 0?Ma.clear():Ma.set(e,!1),Nl({...Ia,hasUpdates:V_()})}async function tv(e,t){if(!za(e,t))return;if(ka&&ka.api===e&&ka.runId===t)return ka.promise;Nl({...Ia,checking:!0});const n=GR(e,t).finally(()=>{ka?.promise===n&&(ka=null),za(e,t)&&(Nl({...Ia,checking:!1,lastCheckedAt:Date.now()}),ZR(e,t))});return ka={api:e,runId:t,promise:n},n}async function GR(e,t){try{const n=await e.listAgents();if(!za(e,t))return;const r=[{key:qR,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const u=await c.check();o.set(c.key,ex(u))}catch{o.set(c.key,Ma.get(c.key)??!1)}})),!za(e,t))return;Ma.clear();for(const[c,u]of o)Ma.set(c,u);Nl({...Ia,hasUpdates:V_()})}catch{}}function ZR(e,t){za(e,t)&&(q_(),hu=window.setTimeout(()=>{hu=null,za(e,t)&&tv(e,t)},JC))}function QR(){Vh+=1,q_(),$_=null,ka=null,Ma.clear(),Nl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function q_(){hu!==null&&(window.clearTimeout(hu),hu=null)}function JR(){return Vh+=1,Vh}function za(e,t){return $_===e&&Vh===t}function ex(e){return e.updateAvailable===!0}function V_(){return Array.from(Ma.values()).some(Boolean)}function Nl(e){Ia=e;for(const t of Array.from(ev))t()}const eM=e=>new Promise(t=>setTimeout(t,e));function tM({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[u,m]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[S,w]=v.useState({});function x(R,B){c(ae=>({...ae,[R]:{...ae[R],...B}}))}function D(R,B){w(ae=>({...ae,[R]:{status:ae[R]?.status??null,busy:ae[R]?.busy??!1,error:ae[R]?.error??null,...B}}))}const O=R=>R.id===null?e.getVersion():e.getAgentVersion(R.id),N=R=>R.id===null?e.checkUpdate():e.checkAgentUpdate(R.id),j=R=>R.id===null?e.runUpdate():e.runAgentUpdate(R.id),q=R=>R.id===null?e:Dl(R.id);v.useEffect(()=>{let R=!1;return e.listAgents().then(async B=>{if(R)return;let ae="Local";try{ae=(await e.getMainInfo()).name?.trim()||ae}catch{}if(R)return;const ye=new Map(B.agents.map(K=>[K.id,K])),M=Dr(B.serverOrder,B.agents).flatMap(K=>{if(K===Vi)return[{key:"local",id:null,name:ae}];const ce=ye.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"})),W(K)}).catch(()=>{}),()=>{R=!0}},[]);async function F(R){x(R.key,{busy:!0,status:"checking…",error:void 0});try{const B=await N(R);XR(R.key,B),x(R.key,{latestVersion:B.latestVersion,updateAvailable:B.updateAvailable,status:se(B),...B.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(B){x(R.key,{busy:!1,error:B instanceof Error?B.message:"check failed"})}}async function ie(){m(!0),await Promise.all(n.map(R=>F(R))),m(!1)}async function Q(R,B){const ae=Date.now()+18e4;for(;Date.now()<ae;){await eM(3e3);try{const ye=await O(R);if(B&&ye.runningVersion!==B.runningVersion)return ye}catch{}}return null}async function $(R){let B=o[R.key]?.version;if(!B)try{B=await O(R),x(R.key,{version:B,manualUpdate:B.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 j(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??($R(ae.message)?FR():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}),Ym(R.key),"unchanged";x(R.key,{status:"restarting…"});const ye=await Q(R,B);return ye?(x(R.key,{busy:!1,version:ye,updateAvailable:!1,status:"updated",manualUpdate:ye.manualUpdate??null}),Ym(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(ye=>ye.filter(M=>M.key!==R.key)),c(ye=>{const M={...ye};return delete M[R.key],M}),Ym(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),B=n.find(ce=>ce.id===null),ae=await Promise.all(R.map(ce=>$(ce))),ye=ae.filter(ce=>ce==="failed").length;let M=ae.filter(ce=>ce==="manual").length,K=null;if(B&&(K=await $(B),K==="manual"&&(M+=1),K==="updated")){ye>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}ye>0&&M>0?p("Some servers failed and some need manual update. Check each marked row."):ye>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 De(R){return R?R.error?R.error:R.status?R.status:R.manualUpdate?"manual update required":R.version?`v${R.version.version}`:"…":"…"}function se(R){return R.error?R.error:typeof R.updateAvailable=="boolean"?R.updateAvailable?`latest v${R.latestVersion??"available"}`:"up to date":"unknown"}function V(R){const B=R?.version;return B?`npm package v${B.runningVersion}`:""}async function X(R,B){try{await nM(B),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 W(R,B=!1){try{const ae=await q(R).getCodeServerStatus(B?{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,B){if(B==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${R.name} and stop its running VS Code sessions?`))return;const ae=q(R);D(R.key,{busy:!0,error:null});try{if(B==="install"){const ye=await ae.installCodeServer();D(R.key,{status:ye.status})}else if(B==="update"){const ye=await ae.updateCodeServer();D(R.key,{status:ye.status})}else if(B==="stop")D(R.key,{status:await ae.stopCodeServer()});else{const ye=await ae.uninstallCodeServer();D(R.key,{status:ye.status})}}catch(ye){D(R.key,{error:ye instanceof Error?ye.message:"code-server action failed"})}finally{D(R.key,{busy:!1})}}const L=n.filter(R=>S[R.key]?.status?.job?.status==="running").map(R=>R.key).join("|");return v.useEffect(()=>{const R=n.filter(ae=>S[ae.key]?.status?.job?.status==="running");if(R.length===0)return;const B=window.setInterval(()=>{for(const ae of R)W(ae)},1e3);return()=>window.clearInterval(B)},[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:u,children:"Check for updates"}),f.jsx("button",{type:"button",onClick:()=>{ne()},disabled:u,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 B=o[R.key],ae=V(B),ye=B?.manualUpdate??null,M=S[R.key]??{status:null,busy:!1,error:null},K=B?.version!==void 0&&B?.updateAvailable!==!1&&!B?.busy&&!u,ce=R.id!==null&&!B?.busy&&!u;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} — `:"",De(B)]})]}),ye?f.jsxs("div",{className:"server-manual-update",children:[f.jsx("span",{children:ye.message}),f.jsxs("div",{className:"server-manual-command",children:[f.jsx("code",{children:ye.command}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{X(R.key,ye.command)},children:B?.copiedCommand?"Copied":"Copy"})]})]}):null,f.jsx(iM,{status:M.status,busy:M.busy,error:M.error,onCheck:()=>{W(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:B?.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 iM({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onStop:u,onUninstall:m}){const g=e?.job??null,p=g?.status==="running",y=e!==null,b=e?.installed===!0,S=(e?.instances.length??0)>0,w=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:[w?x?"checking...":b?`code-server v${e?.version??"unknown"}${S?` — ${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||!w,children:"Check"}),b?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||p||!w,children:e?.updateAvailable?"Update code-server":"Reinstall"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!S,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||!w,children:"Install code-server"})]})]})}async function nM(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 ch=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function sM({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??hf(),[t]),[u,m]=v.useState(()=>Vg()),[g,p]=v.useState(()=>Yg()),[y,b]=v.useState(()=>Gg()),[S,w]=v.useState(()=>Zg()),[x,D]=v.useState(()=>Qg()),[O,N]=v.useState(()=>Ba()),[j,q]=v.useState(()=>Co()),[F,ie]=v.useState(null),[Q,$]=v.useState(null),[Se,ne]=v.useState("appearance"),[De,se]=v.useState(()=>O_()),[V,X]=v.useState(()=>wo()),[W,le]=v.useState(()=>zl()),[L,R]=v.useState([]),[B,ae]=v.useState([]),[ye,M]=v.useState([]),[K,ce]=v.useState(5*1024*1024),[we,Le]=v.useState(!1),[xe,Be]=v.useState(null),[Re,He]=v.useState(null),[Fe,ee]=v.useState(!1),[fe,H]=v.useState(null),[ue,ke]=v.useState(null),Ne=v.useRef(null),te=v.useRef(null),Ee=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),me=v.useMemo(()=>new Set(B),[B]),Oe=!aM(B,ye),ze=v.useMemo(()=>wf(),[]),Je=Re?.displayMode==="standalone"&&(Re.deviceKind==="mobile"||Re.deviceKind==="tablet");v.useEffect(()=>HC(()=>m(Vg())),[]),v.useEffect(()=>UC(()=>p(Yg())),[]),v.useEffect(()=>KC(()=>b(Gg())),[]),v.useEffect(()=>kh(()=>{w(Zg()),D(Qg())}),[]),v.useEffect(()=>S_(()=>N(Ba())),[]),v.useEffect(()=>uu(()=>q(Co())),[]),v.useEffect(()=>DC(()=>X(wo())),[]),v.useEffect(()=>{if(!F)return;const Z=Su.find(it=>it.id===F);if(!Z)return;const Ie=it=>{if(it.preventDefault(),it.stopPropagation(),it.key==="Escape"){ie(null),$(null);return}const Qe=BR(it,Z);if(!Qe){$(rM(Z));return}q(AR(F,Qe)),ie(null),$(null)};return window.addEventListener("keydown",Ie,!0),()=>window.removeEventListener("keydown",Ie,!0)},[F]),v.useEffect(()=>{let Z=!1;return c.listNotificationAssets().then(Ie=>{Z||Ct(Ie)}).catch(Ie=>{Z||Be(yl(Ie))}),()=>{Z=!0}},[c]),v.useEffect(()=>{let Z=!1;return c.getPushNotificationStatus(Rr()).then(Ie=>{Z||(He(Ie.currentDevice),H(null))}).catch(Ie=>{Z||H(yl(Ie))}),()=>{Z=!0}},[c]);function rt(Z){m(lh(Number(Z)))}function zt(Z){X($0(Number(Z)))}function gn(Z){ne(Z);const Ie=te.current,it=Ee.current[Z];if(!Ie||!it)return;const Qe=Math.max(0,tw(it,Ie)-12);typeof Ie.scrollTo=="function"?Ie.scrollTo({top:Qe,behavior:"smooth"}):Ie.scrollTop=Qe}function oi(){const Z=te.current;if(!Z)return;if(Z.scrollTop+Z.clientHeight>=Z.scrollHeight-2){ne(ch[ch.length-1].id);return}let Ie="appearance";const it=Z.scrollTop+Math.min(180,Math.max(48,Z.clientHeight*.28));for(const Qe of ch){const wt=Ee.current[Qe.id];wt&&tw(wt,Z)<=it&&(Ie=Qe.id)}ne(Ie)}function mi(Z){q(LR(Z)),ie(null),$(null)}function qe(){q(OR()),ie(null),$(null)}function Ct(Z){const Ie=Z.assets.filter(it=>it.enabled).map(it=>it.id);R(Z.assets),ae(Ie),M(Ie),ce(Z.maxFileBytes),Be(null)}async function $t(){if(De){F0(!1),se(!1);return}let Z=W;Z==="default"&&(Z=await MC(),le(Z)),Z==="granted"&&(F0(!0),se(!0))}async function _e(){ee(!0),H(null),ke(null);try{if(Re)await iR(c),He(null);else{await JD(c,!1);const Z=await c.getPushNotificationStatus(Rr());He(Z.currentDevice)}}catch(Z){H(Gm(Z))}finally{ee(!1)}}async function Ve(Z){ee(!0),H(null),ke(null);try{await nR(c,Z);const Ie=await c.getPushNotificationStatus(Rr());He(Ie.currentDevice)}catch(Ie){H(Gm(Ie))}finally{ee(!1)}}async function nt(){ee(!0),H(null),ke(null);try{await c.testPushNotification({clientId:Rr()}),ke("Test notification accepted by the push service.")}catch(Z){H(Gm(Z))}finally{ee(!1)}}async function Xe(Z){const Ie=Z?.[0];if(Ie){if(Ie.size>K){Be(`File must be ${Xm(K)} or smaller.`),lt();return}if(Ie.type!=="video/mp4"&&Ie.type!=="video/webm"){Be("Upload an MP4 or WebM video."),lt();return}Le(!0),Be(null);try{await c.uploadNotificationAsset(Ie),Ct(await c.listNotificationAssets()),r?.()}catch(it){Be(yl(it))}finally{Le(!1),lt()}}}async function xt(Z){Le(!0),Be(null);try{await c.deleteNotificationAsset(Z),Ct(await c.listNotificationAssets()),r?.()}catch(Ie){Be(yl(Ie))}finally{Le(!1)}}function lt(){Ne.current&&(Ne.current.value="")}function Tn(Z,Ie){const it=new Set(B);if(Ie?it.add(Z):it.delete(Z),it.size===0){Be("Keep at least one toast video selected.");return}Be(null),ae(Array.from(it))}async function gi(){if(B.length===0){Be("Keep at least one toast video selected.");return}Le(!0),Be(null);try{const Z=await c.updateNotificationAssetSelection({enabledAssetIds:B});Ct(Z),r?.()}catch(Z){Be(yl(Z))}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:Z=>Z.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:ch.map(Z=>f.jsxs("button",{type:"button","data-active":Se===Z.id?"true":"false","aria-current":Se===Z.id?"true":void 0,onClick:()=>gn(Z.id),children:[Z.label,Z.id==="servers"&&n?f.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},Z.id))}),f.jsxs("div",{ref:te,className:"settings-content",onScroll:oi,children:[f.jsxs("section",{id:"settings-appearance",ref:Z=>{Ee.current.appearance=Z},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:Uh.map(Z=>f.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":O===Z.id,"data-active":O===Z.id?"true":"false",onClick:()=>N(jE(Z.id)),style:{"--settings-theme-bg":Z.tokens.bg,"--settings-theme-bg-2":Z.tokens.bg2,"--settings-theme-sidebar":Z.tokens.bgSidebar,"--settings-theme-line":Z.tokens.line,"--settings-theme-fg":Z.tokens.fg,"--settings-theme-fg-2":Z.tokens.fg2,"--settings-theme-accent":Z.tokens.accent,"--settings-theme-xterm-bg":Z.xterm.background,"--settings-theme-xterm-fg":Z.xterm.foreground,"--settings-theme-xterm-selection":Z.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:Z.label}),f.jsx("small",{children:Z.description})]})]},Z.id))}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font size"}),f.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),f.jsx("input",{type:"range",min:Fg,max:$g,step:1,value:u,"aria-label":"Terminal font size",onChange:Z=>rt(Z.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row",children:[f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(lh(u-1)),children:"-"}),f.jsx("input",{type:"number",min:Fg,max:$g,step:1,value:u,"aria-label":"Terminal font size value",onChange:Z=>rt(Z.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(lh(u+1)),children:"+"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(lh(_o)),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:Z=>p(kR(Z.currentTarget.value)),children:qh.map(Z=>f.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:y,onChange:Z=>b(ER(Z.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:S,onChange:Z=>w(DR(Z.currentTarget.checked))}),"Shell panes"]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:x,onChange:Z=>D(RR(Z.currentTarget.checked))}),"Codex/Claude panes"]})]}),f.jsxs("section",{id:"settings-shortcuts",ref:Z=>{Ee.current.shortcuts=Z},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:Su.map(Z=>{const Ie=F===Z.id;return f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"settings-shortcut-label",children:Z.label}),f.jsx("span",{className:"settings-shortcut-group",children:Z.group})]}),f.jsxs("div",{className:"settings-shortcut-actions",children:[f.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ie?"true":"false",onClick:()=>{ie(Z.id),$(null)},children:Ie?"Press keys…":VC(j[Z.id])}),f.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>mi(Z.id),children:"Reset"})]})]},Z.id)})})]}),f.jsxs("section",{id:"settings-notifications",ref:Z=>{Ee.current.notifications=Z},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:De&&W==="granted",onChange:()=>{$t()},disabled:W==="denied"}),"System notification when page is hidden"]}),W==="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:!!Re,onChange:()=>{_e()},disabled:Fe||!ze.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."}),ze.supported?null:f.jsx("p",{className:"muted",children:Th(ze.reason)}),Re?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"muted",children:["Registered as ",Re.label,". Last active ",new Date(Re.lastActiveAt).toLocaleString(),"."]}),f.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{nt()},disabled:Fe,children:"Send test notification"})]}):null,Je?f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Re?.alwaysNotify===!0,onChange:Z=>{Ve(Z.currentTarget.checked)},disabled:Fe||!Re}),"Always notify this mobile device"]}):null,fe?f.jsx("p",{className:"form-error",children:fe}):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:V.enabled,onChange:Z=>X(FD(Z.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:V.persistUntilDismissed?"Until closed":`${V.durationSeconds}s`}),f.jsx("input",{type:"range",min:Ig,max:zg,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:Z=>zt(Z.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[f.jsx("input",{type:"number",min:Ig,max:zg,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:Z=>zt(Z.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!V.enabled||V.persistUntilDismissed,onClick:()=>X($0(cu)),children:"Reset"})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:V.persistUntilDismissed,disabled:!V.enabled,onChange:Z=>X($D(Z.currentTarget.checked))}),"Keep toast until dismissed"]}),f.jsxs("div",{className:"settings-assets-header",children:[f.jsx("span",{children:"Toast videos"}),f.jsxs("span",{children:[Xm(K)," max"]})]}),f.jsx("input",{ref:Ne,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:Z=>{Xe(Z.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(Z=>f.jsxs("li",{"data-enabled":me.has(Z.id)?"true":"false",children:[f.jsxs("label",{className:"settings-asset-choice",children:[f.jsx("input",{type:"checkbox",checked:me.has(Z.id),disabled:we,"aria-label":`Use ${Z.filename}`,onChange:Ie=>Tn(Z.id,Ie.currentTarget.checked)}),f.jsx("video",{src:Z.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),f.jsxs("span",{className:"settings-asset-copy",children:[f.jsx("span",{children:Z.filename}),f.jsx("small",{children:Z.source==="built-in"?"Built-in":Xm(Z.size)})]})]}),Z.source==="uploaded"?f.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:we,"aria-label":`Delete ${Z.filename}`,onClick:()=>{xt(Z.id)},children:"x"}):null]},Z.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:()=>{gi()},children:"Save selected videos"})]}),f.jsx("div",{id:"settings-security",ref:Z=>{Ee.current.security=Z},className:"settings-section-group",children:f.jsx(CR,{api:c})}),f.jsx("div",{id:"settings-servers",ref:Z=>{Ee.current.servers=Z},className:"settings-section-group",children:f.jsx(tM,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function tw(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Xm(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 yl(e){return e instanceof Error?e.message:"Request failed."}function Th(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 Gm(e){const t=yl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Th("not_standalone"):t==="insecure"?Th("insecure"):t==="not_mobile"?Th("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 rM(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 aM(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}class ho extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function oM(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let u=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{u||(u=!0,m(),o(b))},p=b=>{u||(u=!0,m(),c(b))},y=()=>{t.abort(),p(new ho(0,"Upload aborted."))};if(e.signal?.aborted){p(new ho(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 ho(t.status,"Invalid upload response."))}return}p(new ho(t.status,lM(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new ho(0,"Upload failed.")),t.onabort=()=>p(new ho(0,"Upload aborted.")),t.ontimeout=()=>p(new ho(0,"Upload timed out.")),t.send(n)})}function lM(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 cM="modulepreload",uM=function(e){return"/"+e},iw={},Y_=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 u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");o=g(n.map(p=>{if(p=uM(p),p in iw)return;iw[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const S=document.createElement("link");if(S.rel=y?"stylesheet":cM,y||(S.as="script"),S.crossOrigin="",S.href=p,m&&S.setAttribute("nonce",m),document.head.appendChild(S),y)return new Promise((w,x)=>{S.addEventListener("load",w),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(u){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=u,window.dispatchEvent(m),!m.defaultPrevented)throw u}return o.then(u=>{for(const m of u||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},dM=v.lazy(()=>Y_(()=>import("./MarkdownPreview-BCyFRE6U.js"),__vite__mapDeps([0,1])));function hM({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[m,g]=v.useState(""),[p,y]=v.useState({}),[b,S]=v.useState(()=>new Set),[w,x]=v.useState(null),[D,O]=v.useState({type:"empty"}),[N,j]=v.useState("idle"),[q,F]=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 De=ne.current,se=r?pM(r):t?nw(t,n):null,V=c?[c.rootPath,m].filter(Boolean).join("/"):"",X=w?.path??null;v.useEffect(()=>($.current=!0,()=>{$.current=!1,Se.current+=1,ee()}),[]),v.useEffect(()=>{ne.current=t,Q.current=null,W(se)},[e]),v.useEffect(()=>{r&&se!==Q.current&&le(r,se)},[r,se]),v.useEffect(()=>{if(r||!De||t!==De)return;const te=nw(De,n);te!==Q.current&&L(De,te)},[De,t,n,r]);async function W(te=se){if(r){await le(r,te);return}await L(t,te)}async function le(te,Ee=se){const me=fe();if(Q.current=Ee,ee(),u(null),g(""),y({}),S(new Set),x(null),O({type:"empty"}),F(null),!te){j("idle");return}j("loading");try{const Oe=await e.createFileRoot({path:te});if(!H(me))return;u({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const ze=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!H(me))return;ae(ze),j("idle")}catch(Oe){H(me)&&(F(xr(Oe)),j("idle"))}}async function L(te,Ee=se){const me=fe();if(Q.current=Ee,ee(),u(null),g(""),y({}),S(new Set),x(null),O({type:"empty"}),F(null),!te){j("idle");return}j("loading");try{const Oe=await e.createFileRoot({terminalId:te});if(!H(me))return;u({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const ze=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!H(me))return;ae(ze),j("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(F(xr(Oe)),j("idle"))}}async function R(te=m,Ee=c){if(!Ee)return;const me=fe();j("loading"),F(null);try{const Oe=await e.listFiles({rootToken:Ee.rootToken,path:te});if(!H(me))return;ae(Oe),j("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(F(xr(Oe)),j("idle"))}}async function B(){if(r){await le(r,se);return}ne.current=t,await L(t,se)}function ae(te){y(Ee=>({...Ee,[te.path]:mM(te.entries)}))}async function ye(te){if(!(!Zm(te)||!c)){if(x(te),F(null),te.kind==="directory"){g(te.path),Fe(),await K(te);return}if(g(fo(te.path)),te.editable){await we(te);return}te.previewKind!=="none"&&await xe(te,te.previewKind)}}async function M(te){if(!(!Zm(te)||!c)){if(x(te),F(null),te.kind==="directory"){g(te.path),Fe(),await K(te);return}if(g(fo(te.path)),te.editable){await Le(te);return}te.previewKind!=="none"&&await xe(te,te.previewKind)}}async function K(te){if(b.has(te.path)){S(Ee=>{const me=new Set(Ee);return me.delete(te.path),me});return}S(Ee=>new Set(Ee).add(te.path)),await R(te.path)}function ce(te,Ee){te.key==="Enter"&&(te.preventDefault(),M(Ee))}async function we(te){if(!c)return;const Ee=fe();j("loading"),ee();try{const me=await e.readFile({rootToken:c.rootToken,path:te.path});if(!H(Ee))return;O({type:"text-preview",file:te,read:me}),j("idle")}catch(me){if(await ue(me,Ee))return;H(Ee)&&(F(xr(me)),j("idle"))}}async function Le(te){if(!c)return;const Ee=fe();j("loading");try{await o({rootToken:c.rootToken,path:te.path,...t?{terminalId:t}:{}}),H(Ee)&&j("idle")}catch(me){if(await ue(me,Ee))return;H(Ee)&&(F(xr(me)),j("idle"))}}async function xe(te,Ee){if(!c)return;const me=fe();j("loading"),ee();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:te.path});if(!H(me))return;const ze=URL.createObjectURL(Oe);if(!H(me)){URL.revokeObjectURL(ze);return}ie.current=ze,O({type:"preview",file:te,previewKind:Ee,url:ze}),j("idle")}catch(Oe){if(await ue(Oe,me))return;H(me)&&(F(xr(Oe)),j("idle"))}}async function Be(te){if(!c)return;const Ee=te==="file"?"New file":"New folder",me=window.prompt(Ee,""),Oe=w?w.kind==="directory"?w.path:fo(w.path):m,ze=sw(me,Oe);if(ze){F(null);try{const Je=await e.createFileEntry({rootToken:c.rootToken,path:ze,kind:te});x(Je.entry),await R(Oe)}catch(Je){if(await ue(Je))return;F(xr(Je))}}}async function Re(){if(!c||!w)return;const te=window.prompt("Move selected entry",w.path),Ee=sw(te,"");if(!Ee||Ee===w.path)return;const me=fo(w.path),Oe=fo(Ee);F(null);try{const ze=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:Ee});x(ze.entry),g(ze.entry.kind==="directory"?ze.entry.path:fo(ze.entry.path)),Fe(),await R(me),Oe!==me&&await R(Oe)}catch(ze){if(await ue(ze))return;F(xr(ze))}}async function He(){if(!c||!w)return;const te=w.path,Ee=fo(te);F(null);try{const me=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.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:w.path,previewToken:me.previewToken}),x(null),g(Ee),S(ze=>{const Je=new Set(ze);for(const rt of ze)(rt===te||rt.startsWith(`${te}/`))&&Je.delete(rt);return Je}),Fe(),await R(Ee)}catch(me){if(await ue(me))return;F(xr(me))}}function Fe(){Se.current+=1,ee(),O({type:"empty"})}function ee(){ie.current&&(URL.revokeObjectURL(ie.current),ie.current=null)}function fe(){return Se.current+=1,Se.current}function H(te){return $.current&&te===Se.current}async function ue(te,Ee){return gM(te)?(Ee!==void 0&&!H(Ee)||await W(se),!0):!1}function ke(te,Ee){const me=Zm(te),Oe=te.kind==="directory"&&b.has(te.path),ze=p[te.path]??[],Je={"--file-tree-depth":Ee};return f.jsxs(Ni.Fragment,{children:[f.jsxs("button",{type:"button",className:"file-entry-button","data-kind":te.kind,"data-expanded":Oe,"data-active":X===te.path,disabled:!me,style:Je,"aria-expanded":te.kind==="directory"?Oe:void 0,"aria-label":`${te.kind==="directory"?"Open folder":"Open file"} ${te.name}`,title:te.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ye(te)},onDoubleClick:()=>{M(te)},onKeyDown:rt=>ce(rt,te),children:[f.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:te.kind==="directory"?Oe?"▾":"▸":""}),f.jsx("span",{className:"file-entry-name",children:te.name}),f.jsx("small",{children:fM(te)})]}),Oe?f.jsx("div",{className:"file-tree-children",role:"group",children:ze.map(rt=>ke(rt,Ee+1))}):null]},te.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:V,children:V||"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:()=>{B()},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:"▣"})]})]}),q?f.jsx("div",{className:"file-explorer-alert",role:"alert",children:q}):null,f.jsxs("div",{className:"file-explorer-layout",children:[f.jsx("div",{className:"file-tree","aria-label":V?`Files in ${V}`:"Files",children:Ne.map(te=>ke(te,0))}),f.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[f.jsxs("div",{className:"file-detail-header",children:[f.jsx("strong",{children:w?.name??"detail"}),f.jsxs("div",{className:"file-detail-actions",children:[f.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{Re()},children:"Move"}),f.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,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(dM,{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 Zm(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function fM(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function nw(e,t){return`${e}\0${t??""}`}function pM(e){return`workspace\0${e}`}function mM(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function fo(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function sw(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 xr(e){return e instanceof Error?e.message:"Request failed"}function gM(e){return e instanceof Ln&&e.status===409&&e.message==="terminal_cwd_changed"}const vM=v.lazy(()=>Y_(()=>import("./MarkdownPreview-BCyFRE6U.js"),__vite__mapDeps([0,1])));function rw({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,m]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[S,w]=v.useState(!1),[x,D]=v.useState("edit"),O=v.useRef(t),N=v.useRef(t.read),j=v.useRef(t.read.content),q=v.useRef(!1),F=v.useRef(!1),ie=v.useRef(0),Q=u!==o.content&&g!=="saving"&&!S;v.useEffect(()=>(F.current=!0,()=>{F.current=!1,ie.current+=1}),[]),v.useEffect(()=>{ie.current+=1,q.current=!1,O.current=t,N.current=t.read,j.current=t.read.content,c(t.read),m(t.read.content),p("idle"),b(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{O.current=t},[t]),v.useEffect(()=>{N.current=o},[o]),v.useEffect(()=>{j.current=u},[u]),v.useEffect(()=>{if(u===o.content||S)return;const se=window.setInterval(()=>{!q.current&&j.current!==N.current.content&&$()},1e3);return()=>window.clearInterval(se)},[u===o.content,S,t.id]);async function $(){if(q.current)return;const se=j.current,V=N.current;if(se===V.content)return;const X=O.current,W=ie.current;q.current=!0,p("saving"),b(null),w(!1);try{const le=await e.writeFile({rootToken:X.rootToken,path:X.path,content:se,expectedVersion:V.version});if(!F.current||W!==ie.current)return;const L={...V,content:se,version:le.version};N.current=L,c(L),p(j.current===se?"saved":"idle")}catch(le){if(!F.current||W!==ie.current)return;if(le instanceof Ln&&le.status===409){w(!0),p("idle");return}b(_M(le)),p("idle")}finally{W===ie.current&&(q.current=!1)}}const Se=g==="saving"?"saving":g==="saved"?"saved":o.language,ne=o.language==="markdown",De=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":`${De?"Edit":"Preview"} ${t.title}`,onClick:()=>D(se=>se==="preview"?"edit":"preview"),children:De?"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,S?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,De?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(vM,{content:u})})}):f.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:se=>{const V=se.target.value;j.current=V,m(V),p("idle"),b(null),w(!1)}})]})}function _M(e){return e instanceof Error?e.message:"Request failed"}var bM=2,yM=1,SM=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),u={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=u.top+u.bottom,g=u.right+u.left,p=r-m,y=o-g-t;return{cols:Math.max(bM,Math.floor(y/e.css.cell.width)),rows:Math.max(yM,Math.floor(p/e.css.cell.height))}}};var tx=Object.defineProperty,wM=Object.getOwnPropertyDescriptor,CM=(e,t)=>{for(var n in t)tx(e,n,{get:t[n],enumerable:!0})},pi=(e,t,n,r)=>{for(var o=r>1?void 0:r?wM(t,n):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,n,o):u(o))||o);return r&&o&&tx(t,n,o),o},je=(e,t)=>(n,r)=>t(n,r,e),aw="Terminal input",iv={get:()=>aw,set:e=>aw=e},ow="Too much output to announce, navigate to rows manually to read",nv={get:()=>ow,set:e=>ow=e};function xM(e){return e.replace(/\r?\n/g,"\r")}function kM(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function TM(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function EM(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");ix(o,t,n,r)}}function ix(e,t,n,r){e=xM(e),e=kM(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function nx(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 lw(e,t,n,r,o){nx(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ea(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xf(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 DM=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=n)return this._interim=u,r;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[r++]=(u-55296)*1024+m-56320+65536:(t[r++]=u,t[r++]=m);continue}u!==65279&&(t[r++]=u)}return r}},RM=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,u,m,g=0,p=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)w<<=6,w|=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--,S=!0;break}else this.interim[x++]=D,w<<=6,w|=D&63}S||(O===2?w<128?p--:t[r++]=w:O===3?w<2048||w>=55296&&w<=57343||w===65279||(t[r++]=w):w<65536||w>1114111||(t[r++]=w)),this.interim.fill(0)}let y=n-4,b=p;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((u=e[b+2])&128)&&!((m=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=u,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(u=e[b++],(u&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=u,r;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(u&63)<<6|m&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},sx="",Ra=" ",zu=class rx{constructor(){this.fg=0,this.bg=0,this.extended=new Yh}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 rx;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}},Yh=class ax{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 ax(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},us=class ox extends zu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Yh,this.combinedData=""}static fromCharData(t){let n=new ox;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?Ea(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()]}},cw="di$target",sv="di$dependencies",Qm=new Map;function MM(e){return e[sv]||[]}function Zi(e){if(Qm.has(e))return Qm.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");NM(t,n,o)};return t._id=e,Qm.set(e,t),t}function NM(e,t,n){t[cw]===t?t[sv].push({id:e,index:n}):(t[sv]=[{id:e,index:n}],t[cw]=t)}var xn=Zi("BufferService"),lx=Zi("CoreMouseService"),Ro=Zi("CoreService"),AM=Zi("CharsetService"),X_=Zi("InstantiationService"),cx=Zi("LogService"),kn=Zi("OptionsService"),ux=Zi("OscLinkService"),LM=Zi("UnicodeService"),Pu=Zi("DecorationService"),rv=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 us,u=n.getTrimmedLength(),m=-1,g=-1,p=!1;for(let y=0;y<u;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===u-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let S={start:{x:g+1,y:e},end:{x:y+(!p&&y===u-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||r.push({text:b,range:S,activate:(x,D)=>o?o.activate(x,D,S):OM(x,D),hover:(x,D)=>o?.hover?.(x,D,S),leave:(x,D)=>o?.leave?.(x,D,S)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(r)}};rv=pi([je(0,xn),je(1,kn),je(2,ux)],rv);function OM(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 kf=Zi("CharSizeService"),Br=Zi("CoreBrowserService"),G_=Zi("MouseService"),jr=Zi("RenderService"),BM=Zi("SelectionService"),dx=Zi("CharacterJoinerService"),Pl=Zi("ThemeService"),hx=Zi("LinkProviderService"),jM=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?uw.isErrorNoTelemetry(e)?new uw(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)}},IM=new jM;function Eh(e){zM(e)||IM.onUnexpectedError(e)}var av="Canceled";function zM(e){return e instanceof PM?!0:e instanceof Error&&e.name===av&&e.message===av}var PM=class extends Error{constructor(){super(av),this.name=this.message}};function HM(e){return new Error(`Illegal argument: ${e}`)}var uw=class ov extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ov)return t;let n=new ov;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},lv=class fx extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,fx.prototype)}};function Fn(e,t=0){return e[e.length-(1+t)]}var UM;(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})(UM||={});function KM(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var px;(e=>{function t(F){return F&&typeof F=="object"&&typeof F[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o(F){yield F}e.single=o;function c(F){return t(F)?F:o(F)}e.wrap=c;function u(F){return F||n}e.from=u;function*m(F){for(let ie=F.length-1;ie>=0;ie--)yield F[ie]}e.reverse=m;function g(F){return!F||F[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(F){return F[Symbol.iterator]().next().value}e.first=p;function y(F,ie){let Q=0;for(let $ of F)if(ie($,Q++))return!0;return!1}e.some=y;function b(F,ie){for(let Q of F)if(ie(Q))return Q}e.find=b;function*S(F,ie){for(let Q of F)ie(Q)&&(yield Q)}e.filter=S;function*w(F,ie){let Q=0;for(let $ of F)yield ie($,Q++)}e.map=w;function*x(F,ie){let Q=0;for(let $ of F)yield*ie($,Q++)}e.flatMap=x;function*D(...F){for(let ie of F)yield*ie}e.concat=D;function O(F,ie,Q){let $=Q;for(let Se of F)$=ie($,Se);return $}e.reduce=O;function*N(F,ie,Q=F.length){for(ie<0&&(ie+=F.length),Q<0?Q+=F.length:Q>F.length&&(Q=F.length);ie<Q;ie++)yield F[ie]}e.slice=N;function j(F,ie=Number.POSITIVE_INFINITY){let Q=[];if(ie===0)return[Q,F];let $=F[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=j;async function q(F){let ie=[];for await(let Q of F)ie.push(Q);return Promise.resolve(ie)}e.asyncToArray=q})(px||={});function xo(e){if(px.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 WM(...e){return ti(()=>xo(e))}function ti(e){return{dispose:KM(()=>{e()})}}var mx=class gx{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{xo(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?gx.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)}};mx.DISABLE_DISPOSED_WARNING=!1;var Na=mx,mt=class{constructor(){this._store=new Na,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 Al=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}},Mr=typeof window=="object"?window:globalThis,cv=class uv{constructor(t){this.element=t,this.next=uv.Undefined,this.prev=uv.Undefined}};cv.Undefined=new cv(void 0);var ri=cv,dw=class{constructor(){this._first=ri.Undefined,this._last=ri.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ri.Undefined}clear(){let e=this._first;for(;e!==ri.Undefined;){let t=e.next;e.prev=ri.Undefined,e.next=ri.Undefined,e=t}this._first=ri.Undefined,this._last=ri.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ri(e);if(this._first===ri.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!==ri.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ri.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ri.Undefined&&e.next!==ri.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ri.Undefined&&e.next===ri.Undefined?(this._first=ri.Undefined,this._last=ri.Undefined):e.next===ri.Undefined?(this._last=this._last.prev,this._last.next=ri.Undefined):e.prev===ri.Undefined&&(this._first=this._first.next,this._first.prev=ri.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ri.Undefined;)yield e.element,e=e.next}},FM=globalThis.performance&&typeof globalThis.performance.now=="function",$M=class vx{static create(t){return new vx(t)}constructor(t){this._now=FM&&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}},on;(e=>{e.None=()=>mt.None;function t(V,X){return b(V,()=>{},0,void 0,!0,void 0,X)}e.defer=t;function n(V){return(X,W=null,le)=>{let L=!1,R;return R=V(B=>{if(!L)return R?R.dispose():L=!0,X.call(W,B)},null,le),L&&R.dispose(),R}}e.once=n;function r(V,X,W){return p((le,L=null,R)=>V(B=>le.call(L,X(B)),null,R),W)}e.map=r;function o(V,X,W){return p((le,L=null,R)=>V(B=>{X(B),le.call(L,B)},null,R),W)}e.forEach=o;function c(V,X,W){return p((le,L=null,R)=>V(B=>X(B)&&le.call(L,B),null,R),W)}e.filter=c;function u(V){return V}e.signal=u;function m(...V){return(X,W=null,le)=>{let L=WM(...V.map(R=>R(B=>X.call(W,B))));return y(L,le)}}e.any=m;function g(V,X,W,le){let L=W;return r(V,R=>(L=X(L,R),L),le)}e.reduce=g;function p(V,X){let W,le={onWillAddFirstListener(){W=V(L.fire,L)},onDidRemoveLastListener(){W?.dispose()}},L=new Ae(le);return X?.add(L),L.event}function y(V,X){return X instanceof Array?X.push(V):X&&X.add(V),V}function b(V,X,W=100,le=!1,L=!1,R,B){let ae,ye,M,K=0,ce,we={leakWarningThreshold:R,onWillAddFirstListener(){ae=V(xe=>{K++,ye=X(ye,xe),le&&!M&&(Le.fire(ye),ye=void 0),ce=()=>{let Be=ye;ye=void 0,M=void 0,(!le||K>1)&&Le.fire(Be),K=0},typeof W=="number"?(clearTimeout(M),M=setTimeout(ce,W)):M===void 0&&(M=0,queueMicrotask(ce))})},onWillRemoveListener(){L&&K>0&&ce?.()},onDidRemoveLastListener(){ce=void 0,ae.dispose()}},Le=new Ae(we);return B?.add(Le),Le.event}e.debounce=b;function S(V,X=0,W){return e.debounce(V,(le,L)=>le?(le.push(L),le):[L],X,void 0,!0,void 0,W)}e.accumulate=S;function w(V,X=(le,L)=>le===L,W){let le=!0,L;return c(V,R=>{let B=le||!X(R,L);return le=!1,L=R,B},W)}e.latch=w;function x(V,X,W){return[e.filter(V,X,W),e.filter(V,le=>!X(le),W)]}e.split=x;function D(V,X=!1,W=[],le){let L=W.slice(),R=V(ye=>{L?L.push(ye):ae.fire(ye)});le&&le.add(R);let B=()=>{L?.forEach(ye=>ae.fire(ye)),L=null},ae=new Ae({onWillAddFirstListener(){R||(R=V(ye=>ae.fire(ye)),le&&le.add(R))},onDidAddFirstListener(){L&&(X?setTimeout(B):B())},onDidRemoveLastListener(){R&&R.dispose(),R=null}});return le&&le.add(ae),ae.event}e.buffer=D;function O(V,X){return(W,le,L)=>{let R=X(new j);return V(function(B){let ae=R.evaluate(B);ae!==N&&W.call(le,ae)},void 0,L)}}e.chain=O;let N=Symbol("HaltChainable");class j{constructor(){this.steps=[]}map(X){return this.steps.push(X),this}forEach(X){return this.steps.push(W=>(X(W),W)),this}filter(X){return this.steps.push(W=>X(W)?W:N),this}reduce(X,W){let le=W;return this.steps.push(L=>(le=X(le,L),le)),this}latch(X=(W,le)=>W===le){let W=!0,le;return this.steps.push(L=>{let R=W||!X(L,le);return W=!1,le=L,R?L:N}),this}evaluate(X){for(let W of this.steps)if(X=W(X),X===N)break;return X}}function q(V,X,W=le=>le){let le=(...ae)=>B.fire(W(...ae)),L=()=>V.on(X,le),R=()=>V.removeListener(X,le),B=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:R});return B.event}e.fromNodeEventEmitter=q;function F(V,X,W=le=>le){let le=(...ae)=>B.fire(W(...ae)),L=()=>V.addEventListener(X,le),R=()=>V.removeEventListener(X,le),B=new Ae({onWillAddFirstListener:L,onDidRemoveLastListener:R});return B.event}e.fromDOMEventEmitter=F;function ie(V){return new Promise(X=>n(V)(X))}e.toPromise=ie;function Q(V){let X=new Ae;return V.then(W=>{X.fire(W)},()=>{X.fire(void 0)}).finally(()=>{X.dispose()}),X.event}e.fromPromise=Q;function $(V,X){return V(W=>X.fire(W))}e.forward=$;function Se(V,X,W){return X(W),V(le=>X(le))}e.runAndSubscribe=Se;class ne{constructor(X,W){this._observable=X,this._counter=0,this._hasChanged=!1;let le={onWillAddFirstListener:()=>{X.addObserver(this)},onDidRemoveLastListener:()=>{X.removeObserver(this)}};this.emitter=new Ae(le),W&&W.add(this.emitter)}beginUpdate(X){this._counter++}handlePossibleChange(X){}handleChange(X,W){this._hasChanged=!0}endUpdate(X){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function De(V,X){return new ne(V,X).emitter.event}e.fromObservable=De;function se(V){return(X,W,le)=>{let L=0,R=!1,B={beginUpdate(){L++},endUpdate(){L--,L===0&&(V.reportChanges(),R&&(R=!1,X.call(W)))},handlePossibleChange(){},handleChange(){R=!0}};V.addObserver(B),V.reportChanges();let ae={dispose(){V.removeObserver(B)}};return le instanceof Na?le.add(ae):Array.isArray(le)&&le.push(ae),ae}}e.fromObservableLight=se})(on||={});var dv=class hv{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${hv._idPool++}`,hv.all.add(this)}start(t){this._stopWatch=new $M,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}}};dv.all=new Set,dv._idPool=0;var qM=dv,VM=-1,_x=class bx{constructor(t,n,r=(bx._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,u]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(m),console.warn(c);let g=new GM(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}};_x._idPool=1;var YM=_x,XM=class yx{constructor(t){this.value=t}static create(){let t=new Error;return new yx(t.stack??"")}print(){console.warn(this.value.split(`
23
+ `).slice(2).join(`
24
+ `))}},GM=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ZM=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},QM=0,Jm=class{constructor(e){this.value=e,this.id=QM++}},JM=2,eN,Ae=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new YM(e?.onListenerError??Eh,this._options?.leakWarningThreshold??VM):void 0,this._perfMon=this._options?._profName?new qM(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new ZM(`${u}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||Eh)(g),mt.None}if(this._disposed)return mt.None;t&&(e=e.bind(t));let r=new Jm(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=XM.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Jm?(this._deliveryQueue??=new tN,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 Na?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*JM<=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||Eh;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 Jm)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}},tN=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}},fv=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}};fv.INSTANCE=new fv;var Z_=fv;function iN(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Z_.INSTANCE.onDidChangeZoomLevel;function nN(e){return Z_.INSTANCE.getZoomFactor(e)}Z_.INSTANCE.onDidChangeFullscreen;var Hl=typeof navigator=="object"?navigator.userAgent:"",pv=Hl.indexOf("Firefox")>=0,sN=Hl.indexOf("AppleWebKit")>=0,Q_=Hl.indexOf("Chrome")>=0,rN=!Q_&&Hl.indexOf("Safari")>=0;Hl.indexOf("Electron/")>=0;Hl.indexOf("Android")>=0;var eg=!1;if(typeof Mr.matchMedia=="function"){let e=Mr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Mr.matchMedia("(display-mode: fullscreen)");eg=e.matches,iN(Mr,e,({matches:n})=>{eg&&t.matches||(eg=n)})}var wl="en",mv=!1,gv=!1,Dh=!1,Sx=!1,uh,Rh=wl,hw=wl,aN,Tr,bo=globalThis,Vn;typeof bo.vscode<"u"&&typeof bo.vscode.process<"u"?Vn=bo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Vn=process);var oN=typeof Vn?.versions?.electron=="string",lN=oN&&Vn?.type==="renderer";if(typeof Vn=="object"){mv=Vn.platform==="win32",gv=Vn.platform==="darwin",Dh=Vn.platform==="linux",Dh&&Vn.env.SNAP&&Vn.env.SNAP_REVISION,Vn.env.CI||Vn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,uh=wl,Rh=wl;let e=Vn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);uh=t.userLocale,hw=t.osLocale,Rh=t.resolvedLanguage||wl,aN=t.languagePack?.translationsConfigFile}catch{}Sx=!0}else typeof navigator=="object"&&!lN?(Tr=navigator.userAgent,mv=Tr.indexOf("Windows")>=0,gv=Tr.indexOf("Macintosh")>=0,(Tr.indexOf("Macintosh")>=0||Tr.indexOf("iPad")>=0||Tr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Dh=Tr.indexOf("Linux")>=0,Tr?.indexOf("Mobi")>=0,Rh=globalThis._VSCODE_NLS_LANGUAGE||wl,uh=navigator.language.toLowerCase(),hw=uh):console.error("Unable to resolve platform.");var wx=mv,qs=gv,cN=Dh,fw=Sx,Ys=Tr,ya=Rh,uN;(e=>{function t(){return ya}e.value=t;function n(){return ya.length===2?ya==="en":ya.length>=3?ya[0]==="e"&&ya[1]==="n"&&ya[2]==="-":!1}e.isDefaultVariant=n;function r(){return ya==="en"}e.isDefault=r})(uN||={});var dN=typeof bo.postMessage=="function"&&!bo.importScripts;(()=>{if(dN){let e=[];bo.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}),bo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var hN=!!(Ys&&Ys.indexOf("Chrome")>=0);Ys&&Ys.indexOf("Firefox")>=0;!hN&&Ys&&Ys.indexOf("Safari")>=0;Ys&&Ys.indexOf("Edg/")>=0;Ys&&Ys.indexOf("Android")>=0;var gl=typeof navigator=="object"?navigator:{};fw||document.queryCommandSupported&&document.queryCommandSupported("copy")||gl&&gl.clipboard&&gl.clipboard.writeText,fw||gl&&gl.clipboard&&gl.clipboard.readText;var J_=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}},tg=new J_,pw=new J_,mw=new J_,fN=new Array(230),Cx;(e=>{function t(m){return tg.keyCodeToStr(m)}e.toString=t;function n(m){return tg.strToKeyCode(m)}e.fromString=n;function r(m){return pw.keyCodeToStr(m)}e.toUserSettingsUS=r;function o(m){return mw.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return pw.strToKeyCode(m)||mw.strToKeyCode(m)}e.fromUserSettings=c;function u(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 tg.keyCodeToStr(m)}e.toElectronAccelerator=u})(Cx||={});var pN=class xx{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 xx&&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 mN([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},mN=class{constructor(e){if(e.length===0)throw HM("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 gN(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Cx.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(pv)switch(t){case 59:return 85;case 60:if(cN)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(qs)return 57;break}else if(sN&&(qs&&t===93||!qs&&t===92))return 57;return fN[t]||0}var vN=qs?256:2048,_N=512,bN=1024,yN=qs?2048:256,gw=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=gN(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|=vN),this.altKey&&(t|=_N),this.shiftKey&&(t|=bN),this.metaKey&&(t|=yN),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new pN(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},vw=new WeakMap;function SN(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 wN=class{static getSameOriginWindowChain(e){let t=vw.get(e);if(!t){t=[],vw.set(e,t);let n=e,r;do r=SN(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(n+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,r+=m.left}return{top:n,left:r}}},dh=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=wN.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},_w=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(Q_){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*u):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?pv&&!qs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")rN&&wx?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*u):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?pv&&!qs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},kx=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),CN;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof xN?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:on.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:kx})})(CN||={});var xN=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?kx:(this._emitter||(this._emitter=new Ae),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},eb=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 lv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new lv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},kN=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 lv("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}},TN;(e=>{async function t(r){let o,c=await Promise.all(r.map(u=>u.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(u){c(u)}})}e.withAsyncBody=n})(TN||={});var bw=class as{static fromArray(t){return new as(n=>{n.emitMany(t)})}static fromPromise(t){return new as(async n=>{n.emitMany(await t)})}static fromPromises(t){return new as(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new as(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 on.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new as(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return as.map(this,t)}static filter(t,n){return new as(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return as.filter(this,t)}static coalesce(t){return as.filter(t,n=>!!n)}coalesce(){return as.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return as.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())}};bw.EMPTY=bw.fromArray([]);var{getWindow:$s,getWindowId:EN,onDidRegisterWindow:DN}=(function(){let e=new Map,t={window:Mr,disposables:new Na};e.set(Mr.vscodeWindowId,t);let n=new Ae,r=new Ae,o=new Ae;function c(u,m){return(typeof u=="number"?e.get(u):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return mt.None;let m=new Na,g={window:u,disposables:m.add(new Na)};return e.set(u.vscodeWindowId,g),m.add(ti(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),m.add(tt(u,$i.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:c,getWindow(u){let m=u;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:Mr},getDocument(u){return $s(u).document}}})(),RN=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 tt(e,t,n,r){return new RN(e,t,n,r)}var yw=function(e,t,n,r){return tt(e,t,n,r)},tb,MN=class extends kN{constructor(e){super(),this.defaultTarget=e&&$s(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Sw=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){Eh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let u=e.get(c)??[];for(t.set(c,u),e.set(c,[]),r.set(c,!0);u.length>0;)u.sort(Sw.sort),u.shift().execute();r.set(c,!1)};tb=(c,u,m=0)=>{let g=EN(c),p=new Sw(u,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 NN(e){let t=e.getBoundingClientRect(),n=$s(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var $i={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"},AN=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=An(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=An(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=An(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=An(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=An(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=An(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=An(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=An(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=An(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=An(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=An(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=An(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=An(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=An(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 An(e){return typeof e=="number"?`${e}px`:e}function fu(e){return new AN(e)}var Tx=class{constructor(){this._hooks=new Na,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=$s(e)}this._hooks.add(tt(c,$i.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(tt(c,$i.POINTER_UP,u=>this.stopMonitoring(!0)))}};function LN(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[c]}}var Ws;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ws||={});var Gc=class pn extends mt{constructor(){super(),this.dispatched=!1,this.targets=new dw,this.ignoreTargets=new dw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(on.runAndSubscribe(DN,({window:t,disposables:n})=>{n.add(tt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(tt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(tt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Mr,disposables:this._store}))}static addTarget(t){if(!pn.isTouchDevice())return mt.None;pn.INSTANCE||(pn.INSTANCE=new pn);let n=pn.INSTANCE.targets.push(t);return ti(n)}static ignoreTarget(t){if(!pn.isTouchDevice())return mt.None;pn.INSTANCE||(pn.INSTANCE=new pn);let n=pn.INSTANCE.ignoreTargets.push(t);return ti(n)}static isTouchDevice(){return"ontouchstart"in Mr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let u=this.newGestureEvent(Ws.Start,c.target);u.pageX=c.pageX,u.pageY=c.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=n.changedTouches.length;c<u;c++){let 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<pn.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(Ws.Tap,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(p>=pn.HOLD_DELAY&&Math.abs(g.initialPageX-Fn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Fn(g.rollingPageY))<30){let y=this.newGestureEvent(Ws.Contextmenu,g.initialTarget);y.pageX=Fn(g.rollingPageX),y.pageY=Fn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Fn(g.rollingPageX),b=Fn(g.rollingPageY),S=Fn(g.rollingTimestamps)-g.rollingTimestamps[0],w=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(w)/S,w>0?1:-1,y,Math.abs(x)/S,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Ws.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===Ws.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>pn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Ws.Change||t.type===Ws.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,u,m,g,p){this.handle=tb(t,()=>{let y=Date.now(),b=y-r,S=0,w=0,x=!0;o+=pn.SCROLL_FRICTION*b,m+=pn.SCROLL_FRICTION*b,o>0&&(x=!1,S=c*o*b),m>0&&(x=!1,w=g*m*b);let D=this.newGestureEvent(Ws.Change);D.translationX=S,D.translationY=w,n.forEach(O=>O.dispatchEvent(D)),x||this.inertia(t,n,y,o,c,u+S,m,g,p+w)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let u=this.activeTouches[c.identifier],m=this.newGestureEvent(Ws.Change,u.initialTarget);m.translationX=c.pageX-Fn(u.rollingPageX),m.translationY=c.pageY-Fn(u.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(c.pageX),u.rollingPageY.push(c.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Gc.SCROLL_FRICTION=-.005,Gc.HOLD_DELAY=700,Gc.CLEAR_TAP_COUNT_TIME=400,pi([LN],Gc,"isTouchDevice",1);var ON=Gc,ib=class extends mt{onclick(e,t){this._register(tt(e,$i.CLICK,n=>t(new dh($s(e),n))))}onmousedown(e,t){this._register(tt(e,$i.MOUSE_DOWN,n=>t(new dh($s(e),n))))}onmouseover(e,t){this._register(tt(e,$i.MOUSE_OVER,n=>t(new dh($s(e),n))))}onmouseleave(e,t){this._register(tt(e,$i.MOUSE_LEAVE,n=>t(new dh($s(e),n))))}onkeydown(e,t){this._register(tt(e,$i.KEY_DOWN,n=>t(new gw(n))))}onkeyup(e,t){this._register(tt(e,$i.KEY_UP,n=>t(new gw(n))))}oninput(e,t){this._register(tt(e,$i.INPUT,t))}onblur(e,t){this._register(tt(e,$i.BLUR,t))}onfocus(e,t){this._register(tt(e,$i.FOCUS,t))}onchange(e,t){this._register(tt(e,$i.CHANGE,t))}ignoreGesture(e){return ON.ignoreTarget(e)}},ww=11,BN=class extends ib{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=ww+"px",this.domNode.style.height=ww+"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 Tx),this._register(yw(this.bgDomNode,$i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(yw(this.domNode,$i.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new MN),this._pointerdownScheduleRepeatTimer=this._register(new eb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,$s(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()}},jN=class vv{constructor(t,n,r,o,c,u,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,u=u|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>u&&(m=u-c),m<0&&(m=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=u,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 vv(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 vv(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,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:u,scrollHeightChanged:m,scrollTopChanged:g}}},IN=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 jN(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 xw(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=xw.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)))}},Cw=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function ig(e,t){let n=t-e;return function(r){return e+n*HN(r)}}function zN(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var xw=class _v{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),zN(ig(t,o),ig(c,n),.33)}return ig(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 Cw(r,o,!1)}return new Cw(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return _v.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new _v(t,n,o,r)}};function PN(e){return Math.pow(e,3)}function HN(e){return 1-PN(1-e)}var UN=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 eb)}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":"")))}},KN=140,Ex=class extends ib{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 UN(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Tx),this._shouldRender=!0,this.domNode=fu(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(tt(this.domNode.domNode,$i.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new BN(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=fu(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(tt(this.slider.domNode,$i.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=NN(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),u=Math.abs(c-n);if(wx&&u>KN){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()}},Dx=class bv{constructor(t,n,r,o,c,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new bv(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,c){let u=Math.max(0,r-t),m=Math.max(0,u-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(u),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(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=bv._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)}},WN=class extends Ex{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Dx(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}},FN=class extends Ex{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Dx(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}},$N=500,kw=50,qN=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},yv=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(Q_){let n=$s(t.browserEvent),r=nN(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 qN(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),p=Math.max(Math.min(c,m),1),y=Math.max(o,u),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}};yv.INSTANCE=new yv;var VN=yv,YN=class extends ib{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=GN(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 FN(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new WN(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=fu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=fu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=fu(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 eb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xo(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,qs&&(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 _w(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new _w(n))};this._mouseWheelToDispose.push(tt(this._listenOnDomNode,$i.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=VN.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let u=!qs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=kw*o,y=m.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=kw*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(),$N)}},XN=class extends YN{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 GN(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,qs&&(t.className+=" mac"),t}var Sv=class extends mt{constructor(e,t,n,r,o,c,u,m){super(),this._bufferService=n,this._optionsService=u,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 IN({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>tb(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new XN(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(on.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(on.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}};Sv=pi([je(2,xn),je(3,Br),je(4,lx),je(5,Pl),je(6,kn),je(7,jr)],Sv);var wv=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()}};wv=pi([je(1,xn),je(2,Br),je(3,Pu),je(4,jr)],wv);var ZN=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)}},Us={full:0,left:0,center:0,right:0},Sa={full:0,left:0,center:0,right:0},Hc={full:0,left:0,center:0,right:0},Xh=class extends mt{constructor(e,t,n,r,o,c,u,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=m,this._colorZoneStore=new ZN,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);Sa.full=this._canvas.width,Sa.left=e,Sa.center=t,Sa.right=e,this._refreshDrawHeightConstants(),Hc.full=1,Hc.left=1,Hc.center=1+Sa.left,Hc.right=1+Sa.left+Sa.center}_refreshDrawHeightConstants(){Us.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);Us.left=t,Us.center=t,Us.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Us.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Us.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Us.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Us.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(Hc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Us[e.position||"full"]/2),Sa[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Us[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}))}};Xh=pi([je(2,xn),je(3,Pu),je(4,jr),je(5,kn),je(6,Pl),je(7,Br)],Xh);var ve;(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=""))(ve||={});var Mh;(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="Ÿ"))(Mh||={});var Rx;(e=>e.ST=`${ve.ESC}\\`)(Rx||={});var Cv=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(`${ve.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)}}};Cv=pi([je(2,xn),je(3,kn),je(4,Ro),je(5,jr)],Cv);var Yi=0,Xi=0,Gi=0,fi=0,Tw={css:"#00000000",rgba:0},Ai;(e=>{function t(o,c,u,m){return m!==void 0?`#${po(o)}${po(c)}${po(u)}${po(m)}`:`#${po(o)}${po(c)}${po(u)}`}e.toCss=t;function n(o,c,u,m=255){return(o<<24|c<<16|u<<8|m)>>>0}e.toRgba=n;function r(o,c,u,m){return{css:e.toCss(o,c,u,m),rgba:e.toRgba(o,c,u,m)}}e.toColor=r})(Ai||={});var Zt;(e=>{function t(g,p){if(fi=(p.rgba&255)/255,fi===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,S=p.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Yi=w+Math.round((y-w)*fi),Xi=x+Math.round((b-x)*fi),Gi=D+Math.round((S-D)*fi);let O=Ai.toCss(Yi,Xi,Gi),N=Ai.toRgba(Yi,Xi,Gi);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=Nh.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return Ai.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Yi,Xi,Gi]=Nh.toChannels(p),{css:Ai.toCss(Yi,Xi,Gi),rgba:p}}e.opaque=o;function c(g,p){return fi=Math.round(p*255),[Yi,Xi,Gi]=Nh.toChannels(g.rgba),{css:Ai.toCss(Yi,Xi,Gi,fi),rgba:Ai.toRgba(Yi,Xi,Gi,fi)}}e.opacity=c;function u(g,p){return fi=g.rgba&255,c(g,fi*p/255)}e.multiplyOpacity=u;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(Zt||={});var ai;(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 Yi=parseInt(o.slice(1,2).repeat(2),16),Xi=parseInt(o.slice(2,3).repeat(2),16),Gi=parseInt(o.slice(3,4).repeat(2),16),Ai.toColor(Yi,Xi,Gi);case 5:return Yi=parseInt(o.slice(1,2).repeat(2),16),Xi=parseInt(o.slice(2,3).repeat(2),16),Gi=parseInt(o.slice(3,4).repeat(2),16),fi=parseInt(o.slice(4,5).repeat(2),16),Ai.toColor(Yi,Xi,Gi,fi);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 Yi=parseInt(c[1]),Xi=parseInt(c[2]),Gi=parseInt(c[3]),fi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Ai.toColor(Yi,Xi,Gi,fi);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),[Yi,Xi,Gi,fi]=t.getImageData(0,0,1,1).data,fi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ai.toRgba(Yi,Xi,Gi,fi),css:o}}e.toColor=r})(ai||={});var Cn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let u=r/255,m=o/255,g=c/255,p=u<=.03928?u/12.92:Math.pow((u+.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})(Cn||={});var Nh;(e=>{function t(u,m){if(fi=(m&255)/255,fi===1)return m;let g=m>>24&255,p=m>>16&255,y=m>>8&255,b=u>>24&255,S=u>>16&255,w=u>>8&255;return Yi=b+Math.round((g-b)*fi),Xi=S+Math.round((p-S)*fi),Gi=w+Math.round((y-w)*fi),Ai.toRgba(Yi,Xi,Gi)}e.blend=t;function n(u,m,g){let p=Cn.relativeLuminance(u>>8),y=Cn.relativeLuminance(m>>8);if(kr(p,y)<g){if(y<p){let w=r(u,m,g),x=kr(p,Cn.relativeLuminance(w>>8));if(x<g){let D=o(u,m,g),O=kr(p,Cn.relativeLuminance(D>>8));return x>O?w:D}return w}let b=o(u,m,g),S=kr(p,Cn.relativeLuminance(b>>8));if(S<g){let w=r(u,m,g),x=kr(p,Cn.relativeLuminance(w>>8));return S>x?b:w}return b}}e.ensureContrastRatio=n;function r(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,S=m>>24&255,w=m>>16&255,x=m>>8&255,D=kr(Cn.relativeLuminance2(S,w,x),Cn.relativeLuminance2(p,y,b));for(;D<g&&(S>0||w>0||x>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=kr(Cn.relativeLuminance2(S,w,x),Cn.relativeLuminance2(p,y,b));return(S<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=r;function o(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,S=m>>24&255,w=m>>16&255,x=m>>8&255,D=kr(Cn.relativeLuminance2(S,w,x),Cn.relativeLuminance2(p,y,b));for(;D<g&&(S<255||w<255||x<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=kr(Cn.relativeLuminance2(S,w,x),Cn.relativeLuminance2(p,y,b));return(S<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(Nh||={});function po(e){let t=e.toString(16);return t.length<2?"0"+t:t}function kr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var QN=class extends zu{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()]}},Gh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new us}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,c=0,u=0,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,u,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=p,u=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ra.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,u,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),u=[];try{u=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++)Gh._mergeRanges(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,u=e[r];if(u){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),p=t.getString(m).length||Ra.length;if(g!==0){if(!o&&u[0]<=c&&(u[0]=m,o=!0),u[1]<=c){if(u[1]=m,u=e[++r],!u)break;u[0]<=c?(u[0]=m,o=!0):o=!1}c+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Gh=pi([je(0,xn)],Gh);function JN(e){return 57508<=e&&e<=57558}function eA(e){return 9472<=e&&e<=9631}function tA(e){return JN(e)||eA(e)}function iA(){return{css:{canvas:hh(),cell:hh()},device:{canvas:hh(),cell:hh(),char:{width:0,height:0,left:0,top:0}}}}function hh(){return{width:0,height:0}}var xv=class{constructor(e,t,n,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new us,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,u,m,g,p,y){let b=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();n&&x<c+1&&(x=c+1);let D,O=0,N="",j=0,q=0,F=0,ie=0,Q=!1,$=0,Se=!1,ne=0,De=0,se=[],V=p!==-1&&y!==-1;for(let X=0;X<x;X++){e.loadCell(X,this._workCell);let W=this._workCell.getWidth();if(W===0)continue;let le=!1,L=X>=De,R=X,B=this._workCell;if(S.length>0&&X===S[0][0]&&L){let H=S.shift(),ue=this._isCellInSelection(H[0],t);for(j=H[0]+1;j<H[1];j++)L&&=ue===this._isCellInSelection(j,t);L&&=!n||c<H[0]||c>=H[1],L?(le=!0,B=new QN(this._workCell,e.translateToString(!0,H[0],H[1]),H[1]-H[0]),R=H[1]-1,W=B.getWidth()):De=H[1]}let ae=this._isCellInSelection(X,t),ye=n&&X===c,M=V&&X>=p&&X<=y,K=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,H=>{K=!0});let ce=B.getChars()||Ra;if(ce===" "&&(B.isUnderline()||B.isOverline())&&(ce=" "),ne=W*m-g.get(ce,B.isBold(),B.isItalic()),!D)D=this._document.createElement("span");else if(O&&(ae&&Se||!ae&&!Se&&B.bg===q)&&(ae&&Se&&w.selectionForeground||B.fg===F)&&B.extended.ext===ie&&M===Q&&ne===$&&!ye&&!le&&!K&&L){B.isInvisible()?N+=Ra:N+=ce,O++;continue}else O&&(D.textContent=N),D=this._document.createElement("span"),O=0,N="";if(q=B.bg,F=B.fg,ie=B.extended.ext,Q=M,$=ne,Se=ae,le&&c>=X&&c<=R&&(c=X),!this._coreService.isCursorHidden&&ye&&this._coreService.isCursorInitialized){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&se.push("xterm-cursor-blink"),se.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline");break}}if(B.isBold()&&se.push("xterm-bold"),B.isItalic()&&se.push("xterm-italic"),B.isDim()&&se.push("xterm-dim"),B.isInvisible()?N=Ra:N=B.getChars()||Ra,B.isUnderline()&&(se.push(`xterm-underline-${B.extended.underlineStyle}`),N===" "&&(N=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${zu.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let H=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&H<8&&(H+=8),D.style.textDecorationColor=w.ansi[H].css}B.isOverline()&&(se.push("xterm-overline"),N===" "&&(N=" ")),B.isStrikethrough()&&se.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let we=B.getFgColor(),Le=B.getFgColorMode(),xe=B.getBgColor(),Be=B.getBgColorMode(),Re=!!B.isInverse();if(Re){let H=we;we=xe,xe=H;let ue=Le;Le=Be,Be=ue}let He,Fe,ee=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,H=>{H.options.layer!=="top"&&ee||(H.backgroundColorRGB&&(Be=50331648,xe=H.backgroundColorRGB.rgba>>8&16777215,He=H.backgroundColorRGB),H.foregroundColorRGB&&(Le=50331648,we=H.foregroundColorRGB.rgba>>8&16777215,Fe=H.foregroundColorRGB),ee=H.options.layer==="top")}),!ee&&ae&&(He=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,xe=He.rgba>>8&16777215,Be=50331648,ee=!0,w.selectionForeground&&(Le=50331648,we=w.selectionForeground.rgba>>8&16777215,Fe=w.selectionForeground)),ee&&se.push("xterm-decoration-top");let fe;switch(Be){case 16777216:case 33554432:fe=w.ansi[xe],se.push(`xterm-bg-${xe}`);break;case 50331648:fe=Ai.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(D,`background-color:#${Ew((xe>>>0).toString(16),"0",6)}`);break;default:Re?(fe=w.foreground,se.push("xterm-bg-257")):fe=w.background}switch(He||B.isDim()&&(He=Zt.multiplyOpacity(fe,.5)),Le){case 16777216:case 33554432:B.isBold()&&we<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(we+=8),this._applyMinimumContrast(D,fe,w.ansi[we],B,He,void 0)||se.push(`xterm-fg-${we}`);break;case 50331648:let H=Ai.toColor(we>>16&255,we>>8&255,we&255);this._applyMinimumContrast(D,fe,H,B,He,Fe)||this._addStyle(D,`color:#${Ew(we.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,fe,w.foreground,B,He,Fe)||Re&&se.push("xterm-fg-257")}se.length&&(D.className=se.join(" "),se.length=0),!ye&&!le&&!K&&L?O++:D.textContent=N,ne!==this.defaultSpacing&&(D.style.letterSpacing=`${ne}px`),b.push(D),X=R}return D&&O&&(D.textContent=N),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||tA(r.getCode()))return!1;let u=this._getContrastCache(r),m;if(!o&&!c&&(m=u.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),u.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]}};xv=pi([je(1,dx),je(2,kn),je(3,Br),je(4,Ro),je(5,Pu),je(6,Pl)],xv);function Ew(e,t,n){for(;e.length<n;)e=t+e;return e}var nA=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,r,o,c],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),n&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},sA=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,u=n[1]-o,m=Math.max(c,0),g=Math.min(u,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=u,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 rA(){return new sA}var ng="xterm-dom-renderer-owner-",rs="xterm-rows",fh="xterm-fg-",Dw="xterm-bg-",Uc="xterm-focus",ph="xterm-selection",aA=1,kv=class extends mt{constructor(e,t,n,r,o,c,u,m,g,p,y,b,S,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=u,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=S,this._themeService=w,this._terminalClass=aA++,this._rowElements=[],this._selectionRenderModel=rA(),this.onRequestRedraw=this._register(new Ae).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(rs),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(ph),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=iA(),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(xv,document),this._element.classList.add(ng+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(ti(()=>{this._element.classList.remove(ng+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new nA(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} .${rs} 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} .${rs} { 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} .${rs} .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} .${rs}.${Uc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${rs}.${Uc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${rs}.${Uc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${rs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ph} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ph} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ph} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${fh}${c} { color: ${u.css}; }${this._terminalSelector} .${fh}${c}.xterm-dim { color: ${Zt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Dw}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${fh}257 { color: ${Zt.opaque(e.background).css}; }${this._terminalSelector} .${fh}257.xterm-dim { color: ${Zt.multiplyOpacity(Zt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Dw}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(Uc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Uc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,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],u-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=u-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==u){let b=o===u?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(u,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,u=this.dimensions.css.cell.width*(n-t);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,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,u,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ng}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,c){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),o=Math.min(o,this._bufferService.cols);let 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,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=r;++w){let x=w+m.ydisp,D=this._rowElements[w],O=m.lines.get(x);if(!D||!O)break;D.replaceChildren(...this._rowFactory.createRow(O,x,x===g,b,S,p,y,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===r?t:o)-1:-1))}}};kv=pi([je(7,X_),je(8,kf),je(9,kn),je(10,xn),je(11,Ro),je(12,Br),je(13,Pl)],kv);var Tv=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 lA(this._optionsService))}catch{this._measureStrategy=this._register(new oA(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())}};Tv=pi([je(2,kn)],Tv);var Mx=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)}},oA=class extends Mx{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}},lA=class extends Mx{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}},cA=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 uA(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(on.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(tt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(tt(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}},uA=class extends mt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Al),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=tt(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)}},dA=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 nb(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function hA(e,t,n,r,o,c,u,m,g){if(!c)return;let p=nb(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),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 Ev=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return hA(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=nb(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])}}};Ev=pi([je(0,jr),je(1,kf)],Ev);var fA=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=[]}},Nx={};CM(Nx,{getSafariVersion:()=>mA,isChromeOS:()=>Bx,isFirefox:()=>Ax,isIpad:()=>gA,isIphone:()=>vA,isLegacyEdge:()=>pA,isLinux:()=>sb,isMac:()=>Zh,isNode:()=>Tf,isSafari:()=>Lx,isWindows:()=>Ox});var Tf=typeof process<"u"&&"title"in process,Hu=Tf?"node":navigator.userAgent,Uu=Tf?"node":navigator.platform,Ax=Hu.includes("Firefox"),pA=Hu.includes("Edge"),Lx=/^((?!chrome|android).)*safari/i.test(Hu);function mA(){if(!Lx)return 0;let e=Hu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Zh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Uu),gA=Uu==="iPad",vA=Uu==="iPhone",Ox=["Windows","Win16","Win32","WinCE"].includes(Uu),sb=Uu.indexOf("Linux")>=0,Bx=/\bCrOS\b/.test(Hu),jx=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()}},_A=class extends jx{_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())}}},bA=class extends jx{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Qh=!Tf&&"requestIdleCallback"in window?bA:_A,yA=class{constructor(){this._queue=new Qh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Dv=class extends mt{constructor(e,t,n,r,o,c,u,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new Al),this._pausedResizeTask=new yA,this._observerDisposable=this._register(new Al),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 fA((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new SA(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ti(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=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()}};Dv=pi([je(2,kn),je(3,kf),je(4,Ro),je(5,Pu),je(6,xn),je(7,Br),je(8,Pl)],Dv);var SA=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 wA(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return kA(o,c,e,t,n,r)+Ef(c,t,n,r)+TA(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",Cu(Math.abs(o-e),wu(u,r));u=c>t?"D":"C";let m=Math.abs(c-t),g=xA(c>t?e:o,n)+(m-1)*n.cols+1+CA(c>t?o:e);return Cu(g,wu(u,r))}function CA(e,t){return e-1}function xA(e,t){return t.cols-e}function kA(e,t,n,r,o,c){return Ef(t,r,o,c).length===0?"":Cu(zx(e,t,e,t-ko(t,o),!1,o).length,wu("D",c))}function Ef(e,t,n,r){let o=e-ko(e,n),c=t-ko(t,n),u=Math.abs(o-c)-EA(e,t,n);return Cu(u,wu(Ix(e,t),r))}function TA(e,t,n,r,o,c){let u;Ef(t,r,o,c).length>0?u=r-ko(r,o):u=t;let m=r,g=DA(e,t,n,r,o,c);return Cu(zx(e,u,n,m,g==="C",o).length,wu(g,c))}function EA(e,t,n){let r=0,o=e-ko(e,n),c=t-ko(t,n);for(let u=0;u<Math.abs(o-c);u++){let m=Ix(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*u)?.isWrapped&&r++}return r}function ko(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 DA(e,t,n,r,o,c){let u;return Ef(n,r,o,c).length>0?u=r-ko(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function Ix(e,t){return e>t?"A":"B"}function zx(e,t,n,r,o,c){let u=e,m=t,g="";for(;(u!==n||m!==r)&&m>=0&&m<c.buffer.lines.length;)u+=o?1:-1,o&&u>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,u),u=0,e=0,m++):!o&&u<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),u=c.cols-1,e=u,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,u)}function wu(e,t){let n=t?"O":"[";return ve.ESC+n+e}function Cu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var RA=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 Rw(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 sg=50,MA=15,NA=50,AA=500,LA=" ",OA=new RegExp(LA,"g"),Rv=class extends mt{constructor(e,t,n,r,o,c,u,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=u,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new us,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 RA(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 u=e[1];u<=t[1];u++){let m=n.translateBufferLineToString(u,!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 u=n.lines.get(c),m=n.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=m:r.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(OA," ")).join(Ox?`\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())),sb&&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=Rw(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=nb(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,-sg),sg),t/=sg,t/Math.abs(t)+Math.round(t*(MA-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(),NA)}_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<AA&&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=wA(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let u=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,p=e[0]-m,y=0,b=0,S=0,w=0;if(u.charAt(m)===" "){for(;m>0&&u.charAt(m-1)===" ";)m--;for(;g<u.length&&u.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 j=c.getString(N).length;for(j>1&&(w+=j-1,g+=j-1);O>0&&m>0&&!this._isCharWordSeparator(c.loadCell(O-1,this._workCell));){c.loadCell(O-1,this._workCell);let q=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,O--):q>1&&(S+=q-1,m-=q-1),m--,O--}for(;N<c.length&&g+1<u.length&&!this._isCharWordSeparator(c.loadCell(N+1,this._workCell));){c.loadCell(N+1,this._workCell);let q=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,N++):q>1&&(w+=q-1,g+=q-1),g++,N++}}g++;let x=m+p-y+S,D=Math.min(this._bufferService.cols,g-m+y+b-S-w);if(!(!t&&u.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 j=this._bufferService.cols-N.start;x-=j,D+=j}}}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=Rw(n,this._bufferService.cols)}};Rv=pi([je(3,xn),je(4,Ro),je(5,G_),je(6,kn),je(7,jr),je(8,Br)],Rv);var Mw=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={}}},Nw=class{constructor(){this._color=new Mw,this._css=new Mw}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()}},Bi=Object.freeze((()=>{let e=[ai.toColor("#2e3436"),ai.toColor("#cc0000"),ai.toColor("#4e9a06"),ai.toColor("#c4a000"),ai.toColor("#3465a4"),ai.toColor("#75507b"),ai.toColor("#06989a"),ai.toColor("#d3d7cf"),ai.toColor("#555753"),ai.toColor("#ef2929"),ai.toColor("#8ae234"),ai.toColor("#fce94f"),ai.toColor("#729fcf"),ai.toColor("#ad7fa8"),ai.toColor("#34e2e2"),ai.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:Ai.toCss(r,o,c),rgba:Ai.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ai.toCss(r,r,r),rgba:Ai.toRgba(r,r,r)})}return e})()),mo=ai.toColor("#ffffff"),Zc=ai.toColor("#000000"),Aw=ai.toColor("#ffffff"),Lw=Zc,Kc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},BA=mo,Mv=class extends mt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Nw,this._halfContrastCache=new Nw,this._onChangeColors=this._register(new Ae),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:mo,background:Zc,cursor:Aw,cursorAccent:Lw,selectionForeground:void 0,selectionBackgroundTransparent:Kc,selectionBackgroundOpaque:Zt.blend(Zc,Kc),selectionInactiveBackgroundTransparent:Kc,selectionInactiveBackgroundOpaque:Zt.blend(Zc,Kc),scrollbarSliderBackground:Zt.opacity(mo,.2),scrollbarSliderHoverBackground:Zt.opacity(mo,.4),scrollbarSliderActiveBackground:Zt.opacity(mo,.5),overviewRulerBorder:mo,ansi:Bi.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=jt(e.foreground,mo),t.background=jt(e.background,Zc),t.cursor=Zt.blend(t.background,jt(e.cursor,Aw)),t.cursorAccent=Zt.blend(t.background,jt(e.cursorAccent,Lw)),t.selectionBackgroundTransparent=jt(e.selectionBackground,Kc),t.selectionBackgroundOpaque=Zt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=jt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Zt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?jt(e.selectionForeground,Tw):void 0,t.selectionForeground===Tw&&(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=jt(e.scrollbarSliderBackground,Zt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=jt(e.scrollbarSliderHoverBackground,Zt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=jt(e.scrollbarSliderActiveBackground,Zt.opacity(t.foreground,.5)),t.overviewRulerBorder=jt(e.overviewRulerBorder,BA),t.ansi=Bi.slice(),t.ansi[0]=jt(e.black,Bi[0]),t.ansi[1]=jt(e.red,Bi[1]),t.ansi[2]=jt(e.green,Bi[2]),t.ansi[3]=jt(e.yellow,Bi[3]),t.ansi[4]=jt(e.blue,Bi[4]),t.ansi[5]=jt(e.magenta,Bi[5]),t.ansi[6]=jt(e.cyan,Bi[6]),t.ansi[7]=jt(e.white,Bi[7]),t.ansi[8]=jt(e.brightBlack,Bi[8]),t.ansi[9]=jt(e.brightRed,Bi[9]),t.ansi[10]=jt(e.brightGreen,Bi[10]),t.ansi[11]=jt(e.brightYellow,Bi[11]),t.ansi[12]=jt(e.brightBlue,Bi[12]),t.ansi[13]=jt(e.brightMagenta,Bi[13]),t.ansi[14]=jt(e.brightCyan,Bi[14]),t.ansi[15]=jt(e.brightWhite,Bi[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]=jt(e.extendedAnsi[r],Bi[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()}}};Mv=pi([je(0,kn)],Mv);function jt(e,t){if(e!==void 0)try{return ai.toColor(e)}catch{}return t}var jA=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)}},IA=class{constructor(){this._services=new jA,this._services.set(X_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=MM(e).sort((c,u)=>c.index-u.index),r=[];for(let c of n){let u=this._services.get(c.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},zA={trace:0,debug:1,info:2,warn:3,error:4,off:5},PA="xterm.js: ",Nv=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=zA[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?"":PA)+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)}};Nv=pi([je(0,kn)],Nv);var Ow=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,Mi=Object.freeze(new zu),mh=0,rg=2,Qc=class Px{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*pt);let o=n||us.fromCharData([0,sx,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?Ea(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?Ea(n&2097151):""}isProtected(t){return this._data[t*pt+2]&536870912}loadCell(t,n){return mh=t*pt,n.content=this._data[mh+0],n.fg=this._data[mh+1],n.bg=this._data[mh+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]+=Ea(n):o&2097151?(this._combined[t]=Ea(o&2097151)+Ea(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 us;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 us;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*rg<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 u=0;u<o.length;u++){let m=parseInt(o[u],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let u=0;u<c.length;u++){let m=parseInt(c[u],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,r*4*rg<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*rg<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 Px(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 u=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]=u[(n+g)*pt+p];u[(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]=u[(n+g)*pt+p];u[(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 u=this._data[n*pt+0],m=u&2097151,g=u&2097152?this._combined[n]:m?Ea(m):Ra;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function HA(e,t,n,r,o,c){let u=[];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,S=xu(y,b,t),w=1,x=0;for(;w<y.length;){let O=xu(y,w,t),N=O-x,j=n-S,q=Math.min(N,j);y[b].copyCellsFrom(y[w],x,S,q,!1),S+=q,S===n&&(b++,S=0),x+=q,x===O&&(w++,x=0),S===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,S++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(S,n,o);let D=0;for(let O=y.length-1;O>0&&(O>b||y[O].getTrimmedLength()===0);O--)D++;D>0&&(u.push(m+y.length-D),u.push(D)),m+=y.length-1}return u}function UA(e,t){let n=[],r=0,o=t[r],c=0;for(let u=0;u<e.length;u++)if(o===u){let m=t[++r];e.onDeleteEmitter.fire({index:u-c,amount:m}),u+=m-1,c+=m,o=t[++r]}else n.push(u);return{layout:n,countRemoved:c}}function KA(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 WA(e,t,n){let r=[],o=e.map((g,p)=>xu(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,m=0;for(;m<o;){if(o-m<n){r.push(o-m);break}c+=n;let g=xu(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let y=p?n-1:n;r.push(y),m+=y}return r}function xu(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 Hx=class Ux{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ux._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(),xo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Hx._nextId=1;var FA=Hx,Pi={},go=Pi.B;Pi[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Pi.A={"#":"£"};Pi.B=void 0;Pi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pi.C=Pi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pi.E=Pi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pi.H=Pi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Bw=4294967295,jw=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=Mi.clone(),this.savedCharset=go,this.markers=[],this._nullCell=us.fromCharData([0,sx,1,0]),this._whitespaceCell=us.fromCharData([0,Ra,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Qh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ow(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 Yh),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 Yh),this._whitespaceCell}getBlankLine(e,t){return new Qc(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>Bw?Bw:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Mi);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 Ow(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Mi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let c=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Qc(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 Qc(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=HA(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Mi),n);if(r.length>0){let o=UA(this.lines,r);KA(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Mi),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Qc(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(Mi),o=[],c=0;for(let u=this.lines.length-1;u>=0;u--){let m=this.lines.get(u);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&u>0;)m=this.lines.get(--u),g.unshift(m);if(!n){let q=this.ybase+this.y;if(q>=u&&q<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=WA(g,this._cols,e),b=y.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+b):S=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let q=0;q<b;q++){let F=this.getBlankLine(Mi,!0);w.push(F)}w.length>0&&(o.push({start:u+g.length+c,newLines:w}),c+=w.length),g.push(...w);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 q=Math.min(N,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[O],N-q,D-q,q,!0),D-=q,D===0&&(x--,D=y[x]),N-=q,N===0){O--;let F=Math.max(O,0);N=xu(g,F,this._cols)}}for(let q=0;q<g.length;q++)y[q]<e&&g[q].setCell(y[q],r);let j=b-S;for(;j-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],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 S=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>p+S){for(let O=b.newLines.length-1;O>=0;O--)this.lines.set(D--,b.newLines[O]);D++,u.push({index:p+1,amount:b.newLines.length}),S+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[p--]);let w=0;for(let D=u.length-1;D>=0;D--)u[D].index+=w,this.lines.onInsertEmitter.fire(u[D]),w+=u[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 FA(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)}},$A=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 jw(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new jw(!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)}},Kx=2,Wx=1,Av=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,Kx),this.rows=Math.max(e.rawOptions.rows||0,Wx),this.buffers=this._register(new $A(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;c===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=c-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(c,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Av=pi([je(0,kn)],Av);var vl={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:{}},qA=["normal","bold","100","200","300","400","500","600","700","800","900"],VA=class extends mt{constructor(e){super(),this._onOptionChange=this._register(new Ae),this.onOptionChange=this._onOptionChange.event;let t={...vl};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 vl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in vl))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=vl[e]),!YA(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=vl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=qA.includes(t)?t:vl[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 YA(e){return e==="block"||e==="underline"||e==="bar"}function Jc(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]&&Jc(e[r],t-1);return n}var Iw=Object.freeze({insertMode:!1}),zw=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Lv=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=Jc(Iw),this.decPrivateModes=Jc(zw)}reset(){this.modes=Jc(Iw),this.decPrivateModes=Jc(zw)}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))}};Lv=pi([je(0,xn),je(1,cx),je(2,kn)],Lv);var Pw={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 ag(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 og=String.fromCharCode,Hw={DEFAULT:e=>{let t=[ag(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${og(t[0])}${og(t[1])}${og(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ag(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ag(e,!0)};${e.x};${e.y}${t}`}},Ov=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(Pw))this.addProtocol(r,Pw[r]);for(let r of Object.keys(Hw))this.addEncoding(r,Hw[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)}};Ov=pi([je(0,xn),je(1,Ro),je(2,kn)],Ov);var lg=[[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]],XA=[[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]],ji;function GA(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 ZA=class{constructor(){if(this.version="6",!ji){ji=new Uint8Array(65536),ji.fill(1),ji[0]=0,ji.fill(0,1,32),ji.fill(0,127,160),ji.fill(2,4352,4448),ji[9001]=2,ji[9002]=2,ji.fill(2,11904,42192),ji[12351]=1,ji.fill(2,44032,55204),ji.fill(2,63744,64256),ji.fill(2,65040,65050),ji.fill(2,65072,65136),ji.fill(2,65280,65377),ji.fill(2,65504,65511);for(let e=0;e<lg.length;++e)ji.fill(0,lg[e][0],lg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ji[e]:GA(e,XA)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=vo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return vo.createPropertyValue(0,n,r)}},vo=class Ah{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ae,this.onChange=this._onChange.event;let t=new ZA;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let c=0;c<o;++c){let u=t.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=o)return n+this.wcwidth(u);let p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let m=this.charProperties(u,r),g=Ah.extractWidth(m);Ah.extractShouldJoin(m)&&(g-=Ah.extractWidth(r)),n+=g,r=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},QA=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 Wc=2147483647,JA=256,Fx=class Bv{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>JA)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 Bv;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 Bv(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>Wc?Wc: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>Wc?Wc: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,Wc):t}},Fc=[],eL=class{constructor(){this._state=0,this._active=Fc,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=Fc}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=Fc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fc,!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",xf(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=Fc,this._id=-1,this._state=0}}},$n=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=xf(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}},$c=[],tL=class{constructor(){this._handlers=Object.create(null),this._active=$c,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=$c}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=$c,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||$c,!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",xf(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=$c,this._ident=0}},eu=new Fx;eu.addParam(0);var Kw=class{constructor(e){this._handler=e,this._data="",this._params=eu,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():eu,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=xf(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=eu,this._data="",this._hitLimit=!1,n));return this._params=eu,this._data="",this._hitLimit=!1,t}},iL=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}},ls=160,nL=(function(){let e=new iL(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),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in c)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ls,0,2,0),e.add(ls,8,5,8),e.add(ls,6,0,6),e.add(ls,11,0,11),e.add(ls,13,13,13),e})(),sL=class extends mt{constructor(e=nL){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 Fx,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 eL),this._dcsParser=this._register(new tL),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(r=e[m],o=this._transitions.table[this.currentState<<8|(r<160?r:ls)],o>>4){case 2:for(let S=m+1;;++S){if(S>=t||(r=e[S])<32||r>126&&r<ls){this._printHandler(e,m,S),m=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<ls){this._printHandler(e,m,S),m=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<ls){this._printHandler(e,m,S),m=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<ls){this._printHandler(e,m,S),m=S-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&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,m),u;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++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&&(u=y[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,y,b,o,m),u;b<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let S=m+1;;++S)if(S>=t||(r=e[S])===24||r===26||r===27||r>127&&r<ls){this._dcsParser.put(e,m,S),m=S-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let S=m+1;;S++)if(S>=t||(r=e[S])<32||r>127&&r<ls){this._oscParser.put(e,m,S),m=S-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},rL=/^([\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})$/,aL=/^[\da-f]+$/;function Ww(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=rL.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),aL.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 cg(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 oL(e,t=16){let[n,r,o]=e;return`rgb:${cg(n,t)}/${cg(r,t)}/${cg(o,t)}`}var lL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},wa=131072,Fw=10;function $w(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 qw=5e3,Vw=0,cL=class extends mt{constructor(e,t,n,r,o,c,u,m,g=new sL){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=u,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new DM,this._utf8Decoder=new RM,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.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 jv(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(ve.BEL,()=>this.bell()),this._parser.setExecuteHandler(ve.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ve.BS,()=>this.backspace()),this._parser.setExecuteHandler(ve.HT,()=>this.tab()),this._parser.setExecuteHandler(ve.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ve.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Mh.IND,()=>this.index()),this._parser.setExecuteHandler(Mh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Mh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new $n(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new $n(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new $n(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new $n(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new $n(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new $n(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new $n(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new $n(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new $n(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new $n(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new $n(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new $n(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Pi)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 Kw((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"),qw))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${qw} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>wa&&(c=this._parseStack.position+wa)}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<wa&&(this._parseBuffer=new Uint32Array(Math.min(e.length,wa))),u||this._dirtyRowTracker.clearRange(),e.length>wa)for(let p=c;p<e.length;p+=wa){let y=p+wa<e.length?p+wa: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(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let 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,u=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 S=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(r=e[w],r<127&&c){let N=c[String.fromCharCode(r)];N&&(r=N.charCodeAt(0))}let x=this._unicodeService.charProperties(r,S);o=vo.extractWidth(x);let D=vo.extractShouldJoin(x),O=D?vo.extractWidth(S):0;if(S=x,u&&this._onA11yChar.fire(Ea(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,j=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 Qc&&b.copyCellsFrom(N,j,0,O,!1);j<m;)N.setCellFromCodepoint(j++,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 j=o-O;--j>=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=S,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=>$w(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Kw(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $n(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Mi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=vo.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*n),m=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;u[m++]=y,p+=y>65535?2:1}let g=m;for(let p=1;p<n;++p)u.copyWithin(g,0,m),g+=m;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ve.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ve.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ve.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ve.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ve.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,go),this._charsetService.setgCharset(1,go),this._charsetService.setgCharset(2,go),this._charsetService.setgCharset(3,go);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,u=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:p,alt:y}=m,b=this._optionsService.rawOptions,S=(D,O)=>(u.triggerDataEvent(`${ve.ESC}[${t?"":"?"}${D};${O}$y`),!0),w=D=>D?1:2,x=e.params[0];return t?x===2?S(x,4):x===4?S(x,w(u.modes.insertMode)):x===12?S(x,3):x===20?S(x,w(b.convertEol)):S(x,0):x===1?S(x,w(r.applicationCursorKeys)):x===3?S(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?S(x,w(r.origin)):x===7?S(x,w(r.wraparound)):x===8?S(x,3):x===9?S(x,w(o==="X10")):x===12?S(x,w(b.cursorBlink)):x===25?S(x,w(!u.isCursorHidden)):x===45?S(x,w(r.reverseWraparound)):x===66?S(x,w(r.applicationKeypad)):x===67?S(x,4):x===1e3?S(x,w(o==="VT200")):x===1002?S(x,w(o==="DRAG")):x===1003?S(x,w(o==="ANY")):x===1004?S(x,w(r.sendFocus)):x===1005?S(x,4):x===1006?S(x,w(c==="SGR")):x===1015?S(x,4):x===1016?S(x,w(c==="SGR_PIXELS")):x===1048?S(x,1):x===47||x===1047||x===1049?S(x,w(p===y)):x===2004?S(x,w(r.bracketedPasteMode)):x===2026?S(x,w(r.synchronizedOutput)):S(x,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=zu.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let u=e.getSubParams(t+c),m=0;do r[1]===5&&(o=1),r[c+m+1+o]=u[m];while(++m<u.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 u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Mi.fg,e.bg=Mi.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|=Mi.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Mi.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|=Mi.fg&16777215,r.bg&=-67108864,r.bg|=Mi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ve.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.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(`${ve.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=Mi.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(!$w(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(`${ve.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(Yw(c))if(o==="?")t.push({type:0,index:c});else{let u=Ww(o);u&&t.push({type:1,index:c,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Ww(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]);Yw(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,go),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(lL[e[0]],Pi[e[1]]||go),!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=Mi.clone(),this._eraseAttrDataInternal=Mi.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 us;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ve.ESC}${u}${ve.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)}},jv=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&&(Vw=e,e=t,t=Vw),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};jv=pi([je(0,xn)],jv);function Yw(e){return 0<=e&&e<256}var uL=5e7,Xw=12,dL=50,hL=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>uL)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let u=m=>performance.now()-n>=Xw?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=Xw)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dL&&(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()}},Iv=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),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Iv=pi([je(0,xn)],Iv);var Gw=!1,fL=class extends mt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Al),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 IA,this.optionsService=this._register(new VA(e)),this._instantiationService.setService(kn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Av)),this._instantiationService.setService(xn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Nv)),this._instantiationService.setService(cx,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Lv)),this._instantiationService.setService(Ro,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ov)),this._instantiationService.setService(lx,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(vo)),this._instantiationService.setService(LM,this.unicodeService),this._charsetService=this._instantiationService.createInstance(QA),this._instantiationService.setService(AM,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Iv),this._instantiationService.setService(ux,this._oscLinkService),this._inputHandler=this._register(new cL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(on.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(on.forward(this._bufferService.onResize,this._onResize)),this._register(on.forward(this.coreService.onData,this._onData)),this._register(on.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 hL((t,n)=>this._inputHandler.parse(t,n))),this._register(on.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&&!Gw&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gw=!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,Kx),t=Math.max(t,Wx),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()})}}},pL={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 mL(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=ve.ESC+"OA":o.key=ve.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ve.DEL,e.altKey&&(o.key=ve.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ve.ESC+"[Z";break}o.key=ve.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ve.ESC+ve.CR:ve.CR,o.cancel=!0;break;case 27:o.key=ve.ESC,e.altKey&&(o.key=ve.ESC+ve.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=ve.ESC+"[1;"+(c+1)+"D":t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=ve.ESC+"[1;"+(c+1)+"C":t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=ve.ESC+"[1;"+(c+1)+"A":t?o.key=ve.ESC+"OA":o.key=ve.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=ve.ESC+"[1;"+(c+1)+"B":t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ve.ESC+"[2~");break;case 46:c?o.key=ve.ESC+"[3;"+(c+1)+"~":o.key=ve.ESC+"[3~";break;case 36:c?o.key=ve.ESC+"[1;"+(c+1)+"H":t?o.key=ve.ESC+"OH":o.key=ve.ESC+"[H";break;case 35:c?o.key=ve.ESC+"[1;"+(c+1)+"F":t?o.key=ve.ESC+"OF":o.key=ve.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ve.ESC+"[5;"+(c+1)+"~":o.key=ve.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ve.ESC+"[6;"+(c+1)+"~":o.key=ve.ESC+"[6~";break;case 112:c?o.key=ve.ESC+"[1;"+(c+1)+"P":o.key=ve.ESC+"OP";break;case 113:c?o.key=ve.ESC+"[1;"+(c+1)+"Q":o.key=ve.ESC+"OQ";break;case 114:c?o.key=ve.ESC+"[1;"+(c+1)+"R":o.key=ve.ESC+"OR";break;case 115:c?o.key=ve.ESC+"[1;"+(c+1)+"S":o.key=ve.ESC+"OS";break;case 116:c?o.key=ve.ESC+"[15;"+(c+1)+"~":o.key=ve.ESC+"[15~";break;case 117:c?o.key=ve.ESC+"[17;"+(c+1)+"~":o.key=ve.ESC+"[17~";break;case 118:c?o.key=ve.ESC+"[18;"+(c+1)+"~":o.key=ve.ESC+"[18~";break;case 119:c?o.key=ve.ESC+"[19;"+(c+1)+"~":o.key=ve.ESC+"[19~";break;case 120:c?o.key=ve.ESC+"[20;"+(c+1)+"~":o.key=ve.ESC+"[20~";break;case 121:c?o.key=ve.ESC+"[21;"+(c+1)+"~":o.key=ve.ESC+"[21~";break;case 122:c?o.key=ve.ESC+"[23;"+(c+1)+"~":o.key=ve.ESC+"[23~";break;case 123:c?o.key=ve.ESC+"[24;"+(c+1)+"~":o.key=ve.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=ve.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ve.DEL:e.keyCode===219?o.key=ve.ESC:e.keyCode===220?o.key=ve.FS:e.keyCode===221&&(o.key=ve.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=pL[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=ve.ESC+u;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=ve.ESC+g}else if(e.keyCode===32)o.key=ve.ESC+(e.ctrlKey?ve.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=ve.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=ve.US),e.key==="@"&&(o.key=ve.NUL));break}return o}var Ci=0,gL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Qh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Qh,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||(Ci=this._search(t),Ci===-1)||this._getKey(this._array[Ci])!==t)return!1;do if(this._array[Ci]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ci),!0;while(++Ci<this._array.length&&this._getKey(this._array[Ci])===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&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do yield this._array[Ci];while(++Ci<this._array.length&&this._getKey(this._array[Ci])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ci=this._search(e),!(Ci<0||Ci>=this._array.length)&&this._getKey(this._array[Ci])===e))do t(this._array[Ci]);while(++Ci<this._array.length&&this._getKey(this._array[Ci])===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}},ug=0,Zw=0,vL=class extends mt{constructor(){super(),this._decorations=new gL(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 _L(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=>{ug=o.options.x??0,Zw=ug+(o.options.width??1),e>=ug&&e<Zw&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},_L=class extends Na{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=ai.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ai.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},bL=1e3,yL=class{constructor(e,t=bL){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)}},Qw=20,Jh=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 yL(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(tt(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<Qw+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
30
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qw+1&&(this._liveRegion.textContent+=nv.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),u=[],m=c?.translateToString(!0,void 0,void 0,u)||"",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,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let u,m;if(t===0?(u=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(u=this._rowElements.shift(),m=n,this._rowContainer.removeChild(u)),u.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 S=g<b.length?b[g]:b.slice(-1)[0]+1;return S>=this._terminal.cols&&(++y,S=0),{row:y,column:S}},c=o(t),u=o(n);if(!(!c||!u)){if(c.row>u.row||c.row===u.row&&c.column>=u.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(u.row-c.row)*this._terminal.cols-c.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};Jh=pi([je(1,X_),je(2,Br),je(3,jr)],Jh);var zv=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(()=>{xo(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(tt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(tt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(tt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(tt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(m=>({link:m}));this._activeProviderReplies?.set(r,u),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let u=o[c],m=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=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(u=>this._linkAtPosition(u.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&SL(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,xo(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}}};zv=pi([je(1,G_),je(2,jr),je(3,xn),je(4,hx)],zv);function SL(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 wL=class extends fL{constructor(e={}){super(e),this._linkifier=this._register(new Al),this.browser=Nx,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Al),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(vL),this._instantiationService.setService(Pu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(dA),this._instantiationService.setService(hx,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rv)),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(on.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(on.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(on.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(on.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(`${ve.ESC}]${r};${oL(o)}${Rx.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Ai.toColor(...t.color));else{let c=n;this._themeService.modifyColors(u=>u[c]=Ai.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(Jh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ve.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(ve.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(tt(this.element,"copy",t=>{this.hasSelection()&&TM(t,this._selectionService)}));let e=t=>EM(t,this.textarea,this.coreService,this.optionsService);this._register(tt(this.textarea,"paste",e)),this._register(tt(this.element,"paste",e)),Ax?this._register(tt(this.element,"mousedown",t=>{t.button===2&&lw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(tt(this.element,"contextmenu",t=>{lw(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sb&&this._register(tt(this.element,"auxclick",t=>{t.button===1&&nx(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(tt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(tt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(tt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(tt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(tt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(tt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(tt(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(tt(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",iv.get()),Bx||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(cA,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Br,this._coreBrowserService),this._register(tt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(tt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Tv,this._document,this._helperContainer),this._instantiationService.setService(kf,this._charSizeService),this._themeService=this._instantiationService.createInstance(Mv),this._instantiationService.setService(Pl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Gh),this._instantiationService.setService(dx,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Dv,this.rows,this.screenElement)),this._instantiationService.setService(jr,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(Cv,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Ev),this._instantiationService.setService(G_,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(zv,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(Sv,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(BM,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(on.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(wv,this.screenElement)),this._register(tt(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(Jh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Xh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Xh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(kv,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let 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:u.col,row:u.row,x:u.x,y:u.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(tt(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(tt(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let u=ve.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){ix(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=mL(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===ve.ETX||n.key===ve.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)&&(CL(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(Mi));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(ve.ESC+"[I"):this.coreService.triggerDataEvent(ve.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(`${ve.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(`${ve.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function CL(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var xL=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)}},kL=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 us)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Jw=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 kL(t)}getNullCell(){return new us}},TL=class extends mt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ae),this.onBufferChange=this._onBufferChange.event,this._normal=new Jw(this._core.buffers.normal,"normal"),this._alternate=new Jw(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)}},EL=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)}},DL=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}},RL=["cols","rows"],Ks=0,ML=class extends mt{constructor(e){super(),this._core=this._register(new wL(e)),this._addonManager=this._register(new xL),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(RL.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 EL(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new DL(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 TL(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 iv.get()},set promptLabel(e){iv.set(e)},get tooMuchOutput(){return nv.get()},set tooMuchOutput(e){nv.set(e)}}}_verifyIntegers(...e){for(Ks of e)if(Ks===1/0||isNaN(Ks)||Ks%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ks of e)if(Ks&&(Ks===1/0||isNaN(Ks)||Ks%1!==0||Ks<0))throw new Error("This API only accepts positive integers")}};const NL=Ni.lazy(()=>Y_(()=>import("./TranscriptMarkdownBody-CvclqHm3.js"),__vite__mapDeps([2,1])));function $x({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=u.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let 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:S=>{S?u.current.set(p,S):u.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:qx(g.header,t)}):null,g.body?f.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?f.jsx(e1,{text:g.body,searchQuery:t}):f.jsx(Ni.Suspense,{fallback:f.jsx(e1,{text:g.body,searchQuery:t}),children:f.jsx(NL,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function e1({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-${jL(r,o===0||n[o-1]?.trim()==="")}`,children:qx(r,t)},o))})}function qx(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let u=0,m=r.indexOf(o);for(;m!==-1;){m>u&&c.push(e.slice(u,m));const g=m+n.length;c.push(f.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),u=g,m=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function AL(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 Vx(e){const t=e.endsWith(`
35
+ `)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function u(){const m=LL(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=OL(m);g?(u(),r=m,o=g):c.push(m)}return u(),n}function LL(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function OL(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 BL(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,u=AL(c,t);for(let m=0;m<u;m+=1)n.push({entryIndex:r,matchIndexInEntry:m})}return n}function jL(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)||Gx(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 To(e){return e==="codex"?"Codex":"Claude"}function Pv(e,t,n={}){const r=`[nterminal] ${To(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=Yx(o),u=n.includeTools?c:Xx(c);return u?`${u}
43
+ `:""}function Yx(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=IL(n);return r?`[${r}]`:t})}function IL(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=qc(t.getMonth()+1),o=qc(t.getDate()),c=qc(t.getHours()),u=qc(t.getMinutes()),m=qc(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${m}`}function qc(e){return e.toString().padStart(2,"0")}function ef(e,t){return e.map(n=>t?n:Xx(n)).filter(Boolean).map(n=>n.endsWith(`
44
+ `)?n:`${n}
45
+ `).join("")}function Xx(e){if(!e)return"";const t=e.split(`
46
+ `),n=[];let r=!1,o=!1,c=!0;for(const u of t){const m=u.trim()==="",g=c?zL(u):null;if(g&&(r=g==="tool",o=!1),Gx(u)){o=!0,c=!1;continue}if(o){m?(o=!1,r||n.push(u),c=!0):c=!1;continue}r||n.push(u),c=m}return n.join(`
47
+ `).replace(/\n{3,}/g,`
48
+
49
+ `).trimEnd()}function zL(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function Gx(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function rb(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function gh(e,t){return e===null?t===null:t!==null&&rb(e,t)}const PL=5e3,HL=200,UL=1200,KL=4,WL=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const u=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(!1),[S,w]=v.useState(null),[x,D]=v.useState(null),[O,N]=v.useState(null),[j,q]=v.useState(()=>new Set),[F,ie]=v.useState(!1),[Q,$]=v.useState(!1),[Se,ne]=v.useState([]),[De,se]=v.useState(null),[V,X]=v.useState(!1),[W,le]=v.useState(!1),[L,R]=v.useState(!1),[B,ae]=v.useState(null),ye=S?.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),w(ue=>ue&&YL(ue,H.subagents)?ue:H.subagents),!b.current){const ue=H.subagents.find(ke=>ke.hasTranscript);ue&&(b.current=!0,N(ke=>ke??ue.id))}}catch(H){D(H instanceof Error?H.message:"Failed to load subagents."),w(ue=>ue??[])}},[n,t]);v.useEffect(()=>{M();const H=window.setInterval(()=>{document.hidden||M()},PL);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([]),se(null),X(!1),ae(null),O&&K(null,"initial",H),()=>{m.current===H&&(m.current+=1)}},[n,t,O,Q]),v.useLayoutEffect(()=>{const H=u.current;if(!H)return;if(p.current){if(W||Se.length===0)return;p.current=!1;const ke=()=>{H.scrollTop=H.scrollHeight};ke(),window.requestAnimationFrame?.(ke);return}const ue=y.current;ue!==null&&(y.current=null,H.scrollTop+=H.scrollHeight-ue)},[Se,W,Q]);async function K(H,ue,ke=m.current){const Ne=O;if(!(!Ne||g.current)){g.current=!0,ue==="initial"?le(!0):(R(!0),y.current=u.current?.scrollHeight??null),ae(null);try{let te=H,Ee=0,me=0,Oe=[];for(;m.current===ke;){const ze=await n.getTerminalSubagentTranscriptHistory(t,Ne,{...te?{cursor:te}:{},limit:HL,maxLines:UL,includeTools:Q});if(m.current!==ke)return;if(!ze.source){if(me<1){me+=1,await new Promise(rt=>setTimeout(rt,600));continue}ae("Subagent transcript is unavailable.");return}const Je=Pv(ze.output,ze.source.provider,{includeTools:Q});if(se(ze.cursor),X(!!(ze.hasMore&&ze.cursor)),Je&&(Oe=[Je,...Oe],ef(Oe,Q))){ne(rt=>ue==="older"?[...Oe,...rt]:Oe);return}if(!ze.hasMore||!ze.cursor||Ee>=KL){Oe.length>0&&ne(rt=>ue==="older"?[...Oe,...rt]:Oe);return}te=ze.cursor,Ee+=1}}catch(te){if(m.current!==ke)return;ae(te instanceof Error?te.message:"Failed to load subagent transcript.")}finally{m.current===ke&&(g.current=!1,le(!1),R(!1))}}}function ce(){const H=u.current;H&&(H.scrollTop>72||!V||!De||g.current||K(De,"older"))}function we(H){q(ue=>{const ke=new Set(ue);return ke.delete(H)||ke.add(H),ke})}function Le(H){b.current=!0,ie(!0),H.id!==O&&N(H.id),xe(H.id)}function xe(H){const ue=qL(S??[],H);ue.length!==0&&q(ke=>{if(ue.every(te=>ke.has(te)))return ke;const Ne=new Set(ke);for(const te of ue)Ne.add(te);return Ne})}function Be(){m.current+=1;const H=m.current;g.current=!1,p.current=!0,y.current=null,ne([]),se(null),X(!1),ae(null),K(null,"initial",H)}const Re=v.useMemo(()=>ef(Se,Q),[Se,Q]),He=v.useMemo(()=>Vx(Re),[Re]),Fe=S===null;v.useEffect(()=>{if(W||L||!V||!De||g.current)return;const H=u.current;!H||Se.length===0||H.scrollHeight<=H.clientHeight+4&&K(De,"older")},[Se,V,De,W,L]);const ee=S?.filter(H=>H.state==="working").length??0,fe=v.useMemo(()=>Jx(FL(S??[]),j),[S,j]);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":F?"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",S&&S.length>0?f.jsx("span",{className:"subagents-count",children:ee>0?`${ee} working · ${S.length} total`:`${S.length} total`}):null]}),f.jsxs("span",{title:r.sessionId,children:[To(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:[Fe?f.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Fe&&x?f.jsx("div",{className:"subagents-list-status subagents-list-error",children:x}):null,!Fe&&!x&&S!==null&&S.length===0?f.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,fe.map(H=>{const ue=H.subagent,ke=j.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":ke,"aria-label":`${ke?"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:ke?"▾":"▸"}),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"?To(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:[XL(ue.state),ue.model?` · ${ue.model}`:"",ue.updatedAt?` · ${GL(ue.updatedAt)}`:"",H.nestedCount>0&&!ke?` · ${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:ye?ye.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:!ye,onClick:Be,children:"↻"})]}),ye?f.jsx("div",{className:"subagents-transcript-hint",children:VL(ye)}):null,f.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:ce,children:[L?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!W&&V?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Re?f.jsx($x,{entries:He,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,W?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!W&&ye&&!Re&&!B?V&&De?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(De,"older")},disabled:L,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!ye&&!Fe&&!Re?f.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,B?f.jsx("div",{className:"transcript-dialog-error",children:B}):null]})]})]})]})})});function FL(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=$L(r,t);o?o.children.push(r):n.push(r)}for(const r of n)Zx(r);return Qx(n),n}function $L(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const u=c.subagent.parentId;c=u?t.get(u):void 0}return r}function Zx(e){let t=0,n=0;for(const r of e.children)Zx(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,Qx(e.children)}function Qx(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 Jx(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(...Jx(o.children,t,n+1));return r}function qL(e,t){const n=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function VL(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 YL(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 XL(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function GL(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 ZL{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():nk.has(t)?this.acceptConsonant(t):sk.has(t)?this.acceptVowel(t):t3(t)&&this.canReplacePendingWith(t)?(this.pending=i1(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(rk.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=e3.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=JL.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=t1.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=n1({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=t1.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=i1(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=n1(this.pending);return this.pending=null,t}}const tf=44032,nf=21,Cl=28,QL=19*nf*Cl,ek=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],tk=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],ik=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],nk=ab(ek),sk=ab(tk),rk=ab(ik),JL=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),ak=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],e3=new Map(ak),t1=new Map(ak.map(([e,t])=>[t,[e[0],e[1]]]));function ab(e){return new Map(e.map((t,n)=>[t,n]))}function t3(e){const t=e.codePointAt(0);return t!==void 0&&t>=tf&&t<tf+QL}function i1(e){const t=e.codePointAt(0)-tf,n=Math.floor(t/(nf*Cl)),r=Math.floor(t%(nf*Cl)/Cl),o=t%Cl,c={initial:ek[n],vowel:tk[r]};return o===0?c:{...c,final:ik[o]}}function n1(e){if(!e.vowel)return e.initial;const t=nk.get(e.initial),n=sk.get(e.vowel),r=e.final?rk.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(tf+(t*nf+n)*Cl+r)}const i3=[{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 n3({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.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"}),i3.map(u=>f.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.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 s3={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function r3(e){return s3[e]}function a3(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const ok="--nterminal-viewport-height",lk="--nterminal-keyboard-inset-bottom",ck="data-nterminal-keyboard-visible",Df="data-nterminal-compose-open",sf="nterminal:viewport-refresh",o3=120;function l3(e=window){const t=e.document.documentElement,n=e.visualViewport,r=p3(e);function o(){ob(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(sf,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(sf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(ok),t.style.removeProperty(lk),t.removeAttribute(ck)}}function ob(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=Hv(e),o=c3(e,r);return o!==null&&s1(t,ok,`${o}px`),s1(t,lk,`${n}px`),u3(t,ck,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function Hv(e=window){const t=d3(e);return{keyboardInsetBottom:t,keyboardVisible:t>o3}}function c3(e,t){if((e.document.documentElement.hasAttribute(Df)||t)&&yo(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return yo(n)?n:yo(e.innerHeight)?e.innerHeight:null}function yo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function s1(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function u3(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function d3(e){return Math.max(h3(e),f3(e))}function h3(e){const t=e.visualViewport?.height;if(!yo(t)||!yo(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 f3(e){if(!yo(e.innerHeight))return 0;const n=uk(e)?.boundingRect?.height;return!yo(n)||n>=e.innerHeight*.8?0:Math.round(n)}function uk(e){return e.navigator.virtualKeyboard}function p3(e){const t=uk(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Ku=new Map,ku=new Map,m3=Object.freeze({open:!1,text:""});function g3(e){let t=ku.get(e);return t||(t=new Set,ku.set(e,t)),t}function dk(e){const t=ku.get(e);if(t)for(const n of Array.from(t))n()}function Rf(e){return Ku.get(e)??m3}function v3(e,t){const n=g3(e);return n.add(t),()=>{n.delete(t)}}function _3(e,t){const n=Rf(e);n.open!==t&&(Ku.set(e,{...n,open:t}),dk(e))}function b3(e,t){const n=Rf(e);n.text!==t&&(Ku.set(e,{...n,text:t}),dk(e))}function vh(e){Ku.delete(e),ku.delete(e)}function r1(){Ku.clear(),ku.clear()}const y3=120,S3="\x1B[200~",w3="\x1B[201~";function a1(e,t){const n=t.stripTrailingLineBreaks===!1?e:lb(e),r=x3(n);return r?t.bracketedPasteMode?`${S3}${r}${w3}`:r:""}function C3(e){return e==="queue"?" ":"\r"}function lb(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function x3(e){return e.replace(/\r\n/g,`
50
+ `).replace(/\r/g,`
51
+ `).replace(/\n/g,"\r")}const k3=420,T3=3e3,o1=650,E3=80,D3=3,Lh=new Set;let El=null;function R3({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1}){const o=v.useMemo(()=>j=>v3(e,j),[e]),c=v.useMemo(()=>()=>Rf(e),[e]),u=v.useSyncExternalStore(o,c,c),{open:m,text:g}=u,p=v.useRef(null),y=v.useRef(null),b=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!m||!Oh()))return N3(e),()=>A3(e)},[m,e]),v.useLayoutEffect(()=>{const j=p.current?.closest(".terminal-pane");if(!j)return;function q(){j?.removeAttribute("data-compose-open"),j?.style.removeProperty("--compose-drawer-panel-height")}if(!m){q();return}const F=y.current;j.setAttribute("data-compose-open","true");function ie(){const ne=F?.getBoundingClientRect().height??0;ne>0&&j?.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"&&F?new ResizeObserver(ie):null;return Se&&F&&Se.observe(F),()=>{for(const ne of Q)window.clearTimeout(ne);$!==null&&window.cancelAnimationFrame?.($),Se?.disconnect(),q()}},[m]),v.useEffect(()=>{if(!m){S.current?.(),S.current=null;return}l1(b.current),N()},[m]);function w(j){_3(e,j)}function x(j){b3(e,j)}function D(){M3(p.current),w(!1),c1()}function O(j="send"){if(!(r||!g)&&t(g,j)){if(x(""),Oh()){b.current?.blur(),c1();return}window.setTimeout(()=>b.current?.focus(),y3+20)}}function N(){Oh()&&(S.current?.(),S.current=L3())}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:()=>w(!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:j=>x(j.target.value),onFocus:N,onKeyDown:j=>{if(j.key==="Enter"&&(j.metaKey||j.ctrlKey)){if(j.preventDefault(),j.shiftKey){n&&O("queue");return}O("send");return}j.key==="Escape"&&(j.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(""),l1(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 M3(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function l1(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Oh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function c1(){if(!Oh())return;const e=xl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function N3(e){El!==null&&(window.clearTimeout(El),El=null),Lh.add(e),document.documentElement.setAttribute(Df,"true"),xl()}function A3(e){if(Lh.delete(e),Lh.size>0||El!==null){xl();return}El=window.setTimeout(()=>{if(El=null,Lh.size>0){xl();return}document.documentElement.removeAttribute(Df),xl()},k3),xl()}function L3(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,m=O3();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(S){if(!e){if(S<o1&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,E3)}}function b(){if(e)return;g();const S=ob(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===r?o+=1:(o=S.keyboardInsetBottom>0?1:0,r=S.keyboardInsetBottom),w>=T3||w>=o1&&o>=D3){p();return}y(w)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),p}function xl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,ob()}function O3(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function B3(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(z3(u))return u.preventDefault(),u.stopPropagation(),j3(e),!1;if(I3(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(P3(u)){const m=Uv(e);return m?(u.preventDefault(),u.stopPropagation(),Kv(m),!1):!0}return H3(u)?(u.preventDefault(),u.stopPropagation(),U3(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const m=Uv(e);if(m){if(u.clipboardData){u.clipboardData.setData("text/plain",m),u.preventDefault();return}u.preventDefault(),Kv(m)}},c=u=>{const m=u.clipboardData?.getData("text/plain");if(!m)return;const g=lb(m);u.preventDefault(),u.stopImmediatePropagation(),hk(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 j3(e){const t=Uv(e);t&&await Kv(t)}function I3(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function z3(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 P3(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function H3(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 U3(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;hk(e,lb(n),t)}catch{}}function hk(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function Uv(e){return e.hasSelection()?e.getSelection():K3(e.element??null)}function K3(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 Kv(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}W3(e)}function W3(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 F3=[4,10,11,12];function $3(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>u1(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>u1(r)),e.parser.registerCsiHandler({final:"n"},r=>q3(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>V3(r)),e.parser.registerCsiHandler({final:"t"},r=>Y3(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...F3.map(r=>e.parser.registerOscHandler(r,o=>X3(o)))];return{dispose(){for(const r of n)r.dispose()}}}function u1(e){return Mf(e)===0}function q3(e){const t=Mf(e);return t===5||t===6}function V3(e){return Mf(e)===6}function Y3(e){const t=Mf(e);return t===14||t===16||t===18}function X3(e){return e.split(";").some(t=>t==="?")}function Mf(e){const t=e[0];return typeof t=="number"?t:0}const Lr=new Map,dg=2*1024*1024,G3=1500,d1=25e3,fk=2500,Z3=1e3,Q3=3e4,J3=16*1024*1024,Wv=256,pk=bD-3e4,e5=3e3,mk=1e4,t5=3e3,Fv=16*1024*1024,Nf=4*1024*1024,rf=25,i5=1e3,n5=3e3,hg=8,s5=100,gk=1e3,h1=[2e3,5e3,15e3,6e4];let r5=0,a5=0,fg=0,pg=null,Bh=!1,$v=0,jh=0,Aa=!1,f1=!1,pu=null,p1=!1,qv=0,Tu=document.visibilityState!=="hidden";const af=new Set,o5=new TextEncoder,l5=M5();function c5(e,t){d5(),_5(),yf()&&Nr(0);let n=Lr.get(e);n||(n=p5(e),Lr.set(e,n),Ul(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>cb(n));const o=(m,g)=>y5(n,m,g),c=m=>{m?(n.foregroundAttachments.add(r),vk(n)):n.foregroundAttachments.delete(r)},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function tu(e){const t=Lr.get(e);t&&(R5(t),Lr.delete(e))}function u5(e){const t=Lr.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Ha(t),Cs(t),Xs(t),Ua(t),Vs(t,"reconnecting"),Wa(t);const n=t.socket;return t.socket=null,Da(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Ul(t),!0}function d5(){if(p1)return;p1=!0;const e=()=>{if(document.visibilityState==="hidden"){Tu=!1,qv+=1,bk(),h5();return}_k()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e)}function vk(e){if(document.visibilityState!=="hidden"){if(!Tu||e?.heartbeatSuspended){_k(e);return}e&&Vv(e)}}function _k(e){if(document.visibilityState==="hidden")return;Tu=!0;const t=++qv;bk();const n=Array.from(Lr.values()).filter(u=>!u.exited&&u.reconnectEnabled&&u.status!=="unauthorized"),r=n.filter(u=>u===e||u.foregroundAttachments.size>0||w5(u)),o=new Set(r),c=n.filter(u=>!o.has(u));for(const u of r)Vv(u);for(let u=0;u<c.length;u+=hg){const m=c.slice(u,u+hg),g=Math.floor(u/hg)*s5,p=window.setTimeout(()=>{if(af.delete(p),!(t!==qv||!Tu||document.visibilityState==="hidden"))for(const y of m)Vv(y)},g);af.add(p)}}function bk(){for(const e of af)window.clearTimeout(e);af.clear()}function Vv(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,Ul(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<Z3)return Promise.resolve("alive");Vs(e,"reconnecting"),Wa(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++r5).toString(36)}`;let o;const c=new Promise(m=>{o=m}),u={socket:t,nonce:r,timeout:0,promise:c,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(Eo("terminal.connection.resume_timeout",e,{pendingInputs:La(e)}),Vs(e,"reconnecting"),Oa(e))},fk);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{Vs(e,"reconnecting"),Oa(e)}return c}function h5(){Tu=!1;for(const e of Lr.values())e.heartbeatSuspended=!0,Ha(e),Cs(e),Xs(e),Ua(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,Vs(e,"skipped"),Wa(e)}function f5(){Aa=!1,yf()&&Nr(0);for(const e of Lr.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ha(e),Cs(e),Xs(e),Ua(e),Vs(e,"reconnecting"),Wa(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Ul(e)}}function mg(){for(const e of Array.from(Lr.keys()))tu(e)}function p5(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:rf,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function Ul(e){if(!e.reconnectEnabled)return;Da(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,Cs(e),Xs(e),Ua(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,Ha(e),Cs(e),Da(e,"connected"),Pa(e,t),yk(e,t),e.isAlive=!0,m1(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(z5(c)){P5(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),Aa&&(Aa=!1,yf()&&Nr(0));return}if(e.inputProtocolMode==="unknown"&&Ck(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),La(e)>0&&Eo("terminal.connection.resume_alive",e,{pendingInputs:La(e)}),Vs(e,"alive"),Pa(e,t),m1(e),Do(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(Du(e),Eo("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:La(e)}),Oa(e));return}if(c.type==="input_ack"){O5(e,t,c);return}if(c.type==="input_received"){B5(e,t,c);return}if(c.type==="error"&&j5(e,c),c.type==="input_ack_confirmed"){U5(e,c);return}const u=g5(e,c);if(Eu(e,{type:"message",message:u}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;cb(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Ha(e),Cs(e),Xs(e),Ua(e),Vs(e,"reconnecting"),Wa(e),r.code===1008){e.reconnectEnabled=!1,Da(e,m5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=Q3)&&(e.lastUpgradeAuthProbeAt=o,Eu(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Da(e,"closed");return}Da(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Ul(e)},G3)}}),t.addEventListener("error",()=>{})}function m1(e){if(Wa(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>d1*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)}))},d1)}function Wa(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function m5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function g5(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+Or(r),0),g1(e),e.exited&&Ih(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=Or(t.data),g1(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Ih(e)),t):(t.type==="exit"&&(e.exited=!0,Ih(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function g1(e){for(;e.outputBytes>dg&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=Or(t)}e.outputBytes>dg&&e.output.length===1&&(e.output[0]=W5(e.output[0],dg),e.outputBytes=Or(e.output[0]))}function Da(e,t){e.status!==t&&(e.status=t,Eu(e,{type:"status",status:t}))}function Eu(e,t){for(const n of Array.from(e.listeners))n(t)}function La(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function v5(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function Eo(e,t,n={}){mn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:La(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??v5(t)}),$v+=1,jh=0,Nr(gk)}function _5(){if(f1)return;f1=!0;const e=()=>{document.visibilityState==="hidden"||Aa||yf()&&Nr(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Nr(e){if(Bh){pu=pu===null?e:Math.min(pu,e);return}pg!==null||Aa||document.visibilityState==="hidden"||navigator.onLine===!1||(pg=window.setTimeout(()=>{pg=null,b5()},e))}async function b5(){if(Bh||Aa||document.visibilityState==="hidden"||navigator.onLine===!1)return;Bh=!0;const e=$v;try{const t=await kD();if(t.outcome==="auth_blocked"){Aa=!0;return}if(t.outcome==="retryable"){const n=h1[Math.min(jh,h1.length-1)];jh+=1,Nr(n);return}if(jh=0,t.outcome==="sent"&&t.hasMore){Nr(0);return}}finally{Bh=!1;const t=pu;pu=null,t!==null&&Nr(t),$v!==e&&!Aa&&Nr(gk)}}function y5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=A5(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=Or(o);if(c>J3)return"rejected";const u=n.durability!=="live-only",m={message:r,encoded:o,bytes:c,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:u};if(!L5(e,m))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(Eo("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:La(e)}),vk(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Nf))return!u&&r.type==="input"?"rejected":S5(e,r)?(p&&g&&Pa(e,g),"queued"):e.pendingOut.length>=Wv||e.pendingOutBytes+c>Fv?"rejected":(e.pendingOut.push(m),e.pendingOutBytes+=c,_1(e,m),p&&g&&Pa(e,g),"queued");if(p){_1(e,m);try{return g.send(o),wk(e,m),"sent"}catch{if(b&&u&&e.pendingOut.length<Wv&&e.pendingOutBytes+c<=Fv)return e.pendingOut.push(m),e.pendingOutBytes+=c,g.close(),"queued";Mo(e,m),g.close()}}return"rejected"}function Pa(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){Cs(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Nf){K5(e,t),x5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){yk(e,t);return}try{t.send(r.encoded),wk(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=rf,n=!0}e.outboundFlushDelayMs=rf,Cs(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&Eu(e,{type:"outbound_flushed"})})}function S5(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=Or(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function Ha(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=rf}function Cs(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function of(e){return e.pendingOut.some(t=>t.message.type==="input")}function w5(e){return of(e)||e.unackedInputs.size>0}function C5(e){if(!of(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function x5(e,t){e.outboundStallWatchdog!==null||!of(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!of(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Nf;if(!n&&!r){Pa(e,t);return}C5(e),Oa(e)},n5))}function Xs(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function yk(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&Oa(e)},t5))}function Sk(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function Du(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function Ua(e){Sk(e),Du(e)}function Do(e){Sk(e),Yv(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=v1(e),r=k5(e),o=E5(e);if(n===null&&r===null&&o===null){Du(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+e5,u=Math.max(0,Math.min(c,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(Yv(e,{notifyImmediately:!0})){Do(e);return}if(T5(e),v1(e)===null){Do(e);return}D5(e,t)},u)}function k5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+mk;t=t===null?r:Math.min(t,r)}return t}function T5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<mk||(n.writeSlowReported=!0,Eo("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function v1(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function E5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+pk;t=t===null?r:Math.min(t,r)}return t}function D5(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Nf){Oa(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++a5).toString(36)}`;Eo("terminal.input.delivery_probe_started",e,{pendingInputs:La(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(Eo("terminal.input.delivery_probe_timeout",e,{pendingInputs:La(e)}),Du(e),Oa(e))},fk);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{Du(e),Oa(e)}}function Vs(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function Oa(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ha(e),Cs(e),Xs(e),Ua(e),Vs(e,"reconnecting"),Wa(e);const t=e.socket;e.socket=null,Da(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Ul(e)}function R5(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Ha(e),Cs(e),Xs(e),Ua(e),Vs(e,"skipped"),Wa(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Ih(e),e.listeners.clear()}function M5(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function N5(){return fg=(fg+1)%Number.MAX_SAFE_INTEGER,`${l5}-${fg.toString(36)}`.slice(0,bC)}function A5(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=N5();return n.length===0||n.length>bC?null:{...t,messageId:n}}function L5(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<Wv&&e.unackedInputBytes+t.bytes<=Fv)}function _1(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function Mo(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 O5(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&&Xv(e,t,c);return}if(Mo(e,r),Do(e),!ub(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),Xv(e,t,o)}function B5(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",Do(e))}function j5(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(Mo(e,n),Do(e))}function wk(e,t){if(t.message.type!=="input"||!t.message.messageId||!ub(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",Do(e)}function I5(e){if(Yv(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){Mo(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function Yv(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=pk&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&Mo(e,u)}return o>0&&(kk(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&cb(e)),!0}function z5(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function P5(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){Ck(e,t);return}Xs(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(I5(e),H5(e,t)):c!==null&&(xk(e),Tk(e)),Pa(e,t)}function Ck(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",Xs(e),e.serverInstanceId=null,xk(e),Tk(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;Mo(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=Or(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}Pa(e,t)}}function xk(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&Mo(e,o)}n>0&&kk(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function kk(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function cb(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)Eu(e,{type:"message",message:{type:"error",message:n.message}})}}function Ih(e){Ha(e),Cs(e),Xs(e),Ua(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function Xv(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!ub(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function ub(e){return e==="ack"||e==="receipt-ack"}function H5(e,t){for(const n of e.pendingAckReceipts.values())if(Xv(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function U5(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function Tk(e){e.pendingAckReceipts.clear()}function K5(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(i5,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Pa(e,t)},n)}function Or(e){return o5.encode(e).byteLength}function W5(e,t){if(Or(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);Or(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 F5=[0,50,150,350],$5=[100,300,750],q5=2,V5=[300,1200,2500],Y5=1e3,X5=1e5,G5="",Gv="\x1B[?1049l\x1B[?1047l\x1B[?47l",Z5=new Set(["47","1047","1049"]),Q5=400,J5=9,eO=9,tO=32,iO=1.42,nO=2,sO=24,rO=720,aO=60,oO=1260,lO=6,cO=2,b1=[500,1500,3e3,5e3,8e3],y1=15e3,uO=2,dO=1e3,S1="Do not take action. Wait for my next input.",lf=6e4,hO=lf+5*6e4,w1=lf+6e4,fO=40,_h=240,pO=5e3,mu=new Map,Sl=new Map;function C1({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:m,onSelect:g,onClose:p,onExit:y,onSnapshot:b,onAuthClose:S}){const w=v.useSyncExternalStore(HC,Vg,()=>_o),x=v.useSyncExternalStore(UC,Yg,()=>Ml),D=v.useSyncExternalStore(KC,Gg,()=>!0),O=v.useSyncExternalStore(kh,Zg,()=>!0),N=v.useSyncExternalStore(kh,Qg,()=>!0),j=v.useSyncExternalStore(S_,Ba,()=>Rl),q=v.useSyncExternalStore(uu,()=>du("history.toggle"),()=>"Alt+H"),F=v.useSyncExternalStore(uu,()=>du("scrollback.toggle"),()=>"Alt+S"),ie=v.useSyncExternalStore(uu,()=>du("subagents.toggle"),()=>"Alt+A"),Q=v.useRef(null),$=v.useRef(null),Se=v.useRef(null),ne=v.useRef(null),De=v.useRef(null),se=v.useRef(e.id),V=v.useRef({onExit:y,onSnapshot:b}),X=v.useRef(t.createWebSocketUrl),W=v.useRef(S),le=v.useRef(null),L=v.useRef(null),R=v.useRef(null),B=v.useRef(!1),ae=v.useRef(new Map),ye=v.useRef(new Map),M=v.useRef(new Set),K=v.useRef([]),ce=v.useRef(!1),we=v.useRef(null),Le=v.useRef(0),xe=v.useRef(!1),Be=v.useRef(!1),Re=v.useRef(!1),He=v.useRef({terminalId:e.id,enabled:!1}),Fe=v.useRef([]),ee=v.useRef([]),fe=v.useRef(0),H=v.useRef(!1),ue=v.useRef(null),ke=v.useRef(0),Ne=v.useRef(0),te=v.useRef(null),Ee=v.useRef(null),me=v.useRef(!1),Oe=v.useRef(!1),ze=v.useRef(!1),Je=v.useRef(null),rt=v.useRef(!1),zt=v.useRef(null),gn=v.useRef(null),oi=v.useRef(!1),mi=v.useRef(!1),qe=v.useRef(!1),Ct=v.useRef(!1),$t=v.useRef(!1),_e=v.useRef(!1),Ve=v.useRef(!1),nt=v.useRef(n),Xe=v.useRef(r),xt=v.useRef(c),lt=v.useRef(w),Tn=v.useRef(x),gi=v.useRef(!1),Z=v.useRef(!1),Ie=v.useRef(null),it=v.useRef(0),Qe=v.useRef(0),wt=v.useRef(e.id),qt=v.useRef(()=>{}),Pt=v.useRef(null),li=v.useRef(null),Vt=v.useRef(!1),ii=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),ci=v.useRef(0),Ht=v.useRef(null),ln=v.useRef(0),Qt=v.useRef(null),Hi=v.useRef(0),vn=v.useRef(!1),_n=v.useRef(!1),Jt=v.useRef(null),Qi=v.useRef(null),[,ni]=v.useState("connecting"),[vi,_i]=v.useState(!1),[Bn,Ir]=v.useState(null),[Lo,zr]=v.useState(!1),[Gs,ds]=v.useState(null),[Zs,hs]=v.useState(!1),[Ts,fs]=v.useState(!1),[Es,At]=v.useState(!1),[Oo,Pr]=v.useState(!1),[Ut,jn]=v.useState(null),Ji=e.agentCache&&Ut&&e.agentCache.source.provider===Ut.provider&&e.agentCache.source.sessionId===Ut.sessionId?e.agentCache:null,[Hr,Bo]=v.useState(()=>Date.now()),[Qs,ps]=v.useState(!1),[Ur,bn]=v.useState(null),[Ui,Ds]=v.useState(!1),[Fa,ms]=v.useState(!1),[Ki,gs]=v.useState(null),[Rs,Li]=v.useState(!1),[ft,vs]=v.useState(!1),[Js,cn]=v.useState(null),[Kr,$a]=v.useState(null),un=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[jo,Wr]=v.useState(()=>Vm(e.id)),er=Ut?.provider??e.agentStatus?.provider??null,Fr=er!==null||iu(e.currentCommand),Io=er==="claude"||Nk(e.currentCommand),Fl=er!==null||iu(e.currentCommand),_s=e.capabilities?.tmuxScrollback===!0,bi=_s&&(jo??(Fl?N:O)),[$r,Wi]=v.useState(!1);v.useLayoutEffect(()=>{nt.current=n},[n]),v.useLayoutEffect(()=>{Xe.current=r},[r]),v.useLayoutEffect(()=>{xt.current=c},[c]),v.useLayoutEffect(()=>{lt.current=w},[w]),v.useLayoutEffect(()=>{Tn.current=x},[x]),v.useLayoutEffect(()=>{gi.current=Ui},[Ui]),v.useLayoutEffect(()=>{Z.current=Fa},[Fa]),v.useLayoutEffect(()=>{Ie.current=Ut},[Ut]);const si=v.useCallback((k,I={})=>{!k&&I.preserveOnNull||(gh(Ie.current,k)||(Qe.current+=1),Ie.current=k,jn(Ce=>Ce&&k&&Ce.provider===k.provider&&Ce.sessionId===k.sessionId?Ce:k))},[]),Ms=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),tr=v.useCallback(()=>{const k=Ie.current,I=Qe.current;k&&(async()=>{let Ce=k;try{Ce=await Ms()??Ce}catch{}Ce&&wt.current===e.id&&Qe.current===I&&gh(k,Ie.current)&&(si(Ce,{preserveOnNull:!0}),Pt.current=_g(e.id,Ce),ms(!1),Ds(!0))})()},[si,Ms,e.id]),qa=v.useCallback(()=>{Ie.current&&(Ds(!1),ms(!0))},[]),In=v.useCallback(async(k={})=>{const I=await k1(un,t,k);return gs(I),I},[un,t]),yi=v.useCallback((k,I="info")=>{Qt.current!==null&&window.clearTimeout(Qt.current),$a({id:ln.current++,message:k,tone:I}),Qt.current=window.setTimeout(()=>{$a(null),Qt.current=null},3200)},[]),qr=v.useCallback(()=>{const k=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Ce=m?.tabName.trim()||e.title||"Terminal",$e=Ki?.instances.find(ct=>ct.cwd===e.cwd);if($e&&T1(bh(k,$e.id))){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if($e&&gg(bh(k,$e.id),$e.url)){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ke=null;const at=()=>((!Ke||Dk(Ke))&&(Ke=window.open("about:blank","_blank"),mO(Ke)),Ke);Ki?.installed!==!0&&at(),vs(!0),cn(null),(async()=>{let ct=Ki;if(ct?.installed||(ct=await In({force:!0})),!ct?.installed||ct.supported===!1){vg(Ke),Li(!0);return}const ht=ct.instances.find(Rt=>Rt.cwd===e.cwd);if(ht){const Rt=bh(k,ht.id);if(E1(Ke,Rt,ht.url)||gg(Rt,ht.url)!==null){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const We=at();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Ce}),targetPopup:We}})().then(ct=>{if(!ct)return;const{response:ht,targetPopup:We}=ct;Zv(un,ht.status),gs(ht.status);const Kt=bh(k,ht.instance.id);if(T1(Kt)){vg(We),yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}E1(We,Kt,ht.url)||gg(Kt,ht.url)?yi("Opening VS Code..."):yi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(ct=>{vg(Ke),Li(!0),cn(yh(ct))}).finally(()=>vs(!1))},[m?.serverName,m?.tabName,un,Ki,In,t,yi,e.cwd,e.id,e.title]);v.useEffect(()=>{let k=!1;return k1(un,t).then(I=>{k||gs(I)}).catch(()=>{}),()=>{k=!0}},[un,t]),v.useEffect(()=>{if(Ki?.job?.status!=="running")return;const k=window.setInterval(()=>{In({force:!0}).catch(I=>cn(yh(I)))},1e3);return()=>window.clearInterval(k)},[Ki?.job?.status,In]),v.useEffect(()=>()=>{Qt.current!==null&&window.clearTimeout(Qt.current)},[]),v.useLayoutEffect(()=>{qt.current=tr},[tr]),v.useLayoutEffect(()=>{li.current=Ji},[Ji]),v.useLayoutEffect(()=>{Vt.current=Qs},[Qs]),v.useLayoutEffect(()=>{vn.current=Fr},[Fr]),v.useLayoutEffect(()=>{_n.current=Io},[Io]),v.useLayoutEffect(()=>{const k=He.current;Be.current=bi,Re.current=_s,He.current={terminalId:e.id,enabled:bi},R1(Q.current,bi),k.terminalId===e.id&&k.enabled&&!bi&&Xa(),bi||At(!1)},[e.id,bi,_s]),v.useEffect(()=>{Wr(Vm(e.id)),Le.current=0,xe.current=!1,At(!1),Ya()},[e.id]),v.useEffect(()=>kh(()=>{Wr(Vm(e.id))}),[e.id]),v.useEffect(()=>()=>{Ko()},[]),v.useEffect(()=>{De.current?.(r&&e.status==="running"),r&&e.status==="running"&&C()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&bs("auto")},[n,r,e.status]),v.useEffect(()=>{V.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{X.current=t.createWebSocketUrl,W.current=S},[t,S]),v.useLayoutEffect(()=>{se.current=e.id,Ve.current=!1,Pr(!1)},[e.id]),v.useEffect(()=>{let k=!1,I=null,Ce=0;const $e=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ke=$e||IO(e.currentCommand),at=$e||iu(e.currentCommand);function ct(){I!==null&&(window.clearTimeout(I),I=null)}function ht(Kt){if(k)return;let Rt;if(Kt)Rt=y1;else if(Ce<b1.length){if(!Ke)return;Rt=b1[Ce++]}else{if(!at)return;Rt=y1}I=window.setTimeout(()=>{I=null,We()},Rt)}async function We(){try{const Kt=Ie.current!==null,Rt=await Ms();if(k)return;if(Rt){it.current=0,si(Rt),ht(!0);return}it.current+=1;const Dt=!!(Kt&&Ke&&it.current<uO);si(null,{preserveOnNull:Dt}),ht(Dt)}catch(Kt){if(k)return;bg(Kt)&&si(null),ht(!1)}}return wt.current!==e.id&&(wt.current=e.id,Qe.current+=1,Ie.current=null,it.current=0,jn(null)),e.status!=="running"?(Qe.current+=1,Ie.current=null,it.current=0,jn(null),()=>{k=!0,ct()}):(We(),()=>{k=!0,ct()})},[si,Ms,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const k=_g(e.id,Ut),I=Pt.current;I!==null&&k!==null&&I!==k&&(Ee.current=null,me.current=!1,Oe.current=!1,gi.current&&Ds(!1),ms(!1)),Pt.current=k},[e.id,Ut?.provider,Ut?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!Ut){ps(!1);return}const k=window.setInterval(()=>{Bo(Date.now())},dO);return()=>{window.clearInterval(k)}},[e.status,Ut?.provider,Ut?.sessionId]),v.useEffect(()=>{const k=_O(Ji);ii.current.key!==k&&(ii.current={key:k,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[Ji?.expiresAt,Ji?.source?.provider,Ji?.source?.sessionId]),v.useEffect(()=>{if(!Qs||!Ji||Ji.status!=="ready")return;const k=Rk(Ji,Hr);if(k===null||k<=0)return;const I=ii.current;!I.warnedFiveMinutes&&k<=hO&&k>w1&&(I.warnedFiveMinutes=!0,Gn({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."})),!I.warnedOneMinute&&k<=w1&&k>lf&&(I.warnedOneMinute=!0,Gn({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&k<=lf&&tc()},[Qs,Hr,Ji,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function k(I){if(!nt.current||!Xe.current||I.isComposing||I.key==="Process"||SO(I.target))return;const Ce=qC(I);if(Ce?.id==="history.toggle"&&Ie.current){I.preventDefault(),I.stopPropagation(),gi.current?Ds(!1):qt.current();return}if(Ce?.id==="subagents.toggle"&&Ie.current){I.preventDefault(),I.stopPropagation(),Z.current?ms(!1):qa();return}if(Ce?.id==="scrollback.toggle"&&Re.current){I.preventDefault(),I.stopPropagation(),ec();return}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{const k=$.current;k&&(k.options.disableStdin=e.status==="exited"),e.status==="exited"&&ni("closed")},[e.status]),v.useEffect(()=>{const k=$.current;k&&(k.options.fontSize=w,qm(w,Tn.current).then(()=>{lt.current===w&&en()}))},[w]),v.useEffect(()=>{const k=$.current;k&&(k.options.fontFamily=qg(x),qm(lt.current,x).then(()=>{Tn.current===x&&en()}))},[x]),v.useEffect(()=>{const k=$.current;k&&(k.options.theme=x1(j))},[j]),v.useEffect(()=>{const k=Q.current;if(!k)return;let I=!1,Ce=null,$e=null,Ke=null,at=null,ct=null,ht=null,We=null;le.current=null,$t.current=!1,_e.current=!1,rt.current=!1,Wu(),Fu(),yn(),ce.current=!1;const Kt=lt.current,Rt=Tn.current,Dt=new ML({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:qg(Rt),fontSize:Kt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:X5,theme:{...x1(Ba())}}),Bs=new SM;return Dt.loadAddon(Bs),at=$3(Dt),$.current=Dt,Se.current=Bs,qm(Kt,Rt).then(()=>{if(I)return;Dt.open(k),R1(k,Be.current),$t.current=!0,Ce=B3(Dt,{onPasteText:$f,onInterrupt:Ff,shouldInterruptPlainCtrlC:()=>_n.current}),Xe.current&&nt.current&&e.status==="running"&&bs("auto"),en(),ct=WO(k,Dt,()=>lt.current*1.2,Os,js=>{dn(js)},Va,ar,()=>Be.current,Gr),ht=HO(k,Dt,Os,js=>{dn(js)},Va,ar,()=>Be.current,Gr);const Wo=new ZL;$e=Dt.onData(js=>{if(Ve.current){const nc=a3(js);if(nc){Za(!1),or(nc);return}}const ic=Wo.accept(js);ic&&or(ic)}),Ke=Dt.onScroll(js=>{if(mi.current||Ct.current||qe.current){tn();return}ql(),qn(Dt)&&rr({scrollToBottom:!0}),Os(),!Be.current&&js<=3&&dn()}),We=new ResizeObserver(()=>{he()}),We.observe(k),_e.current&&(sr(),_e.current=!1,en()),$l()}),()=>{Qu(ne.current,{updateUi:!1}),I=!0,$t.current=!1,_e.current=!1,Wu(),Fu(),L.current=null,R.current=null,B.current=!1,$u(),ce.current=!1,qu(),qe.current=!1,H.current=!1,ke.current+=1,Ne.current+=1,ue.current=null,Jt.current=null,Qi.current=null,ze.current=!1,Je.current=null,_i(!1),ct?.(),ht?.(),We?.disconnect(),Ce?.dispose(),$e?.dispose(),Ke?.dispose(),at?.dispose(),Dt.dispose(),$.current=null,Se.current=null}},[e.id]),v.useEffect(()=>{const k=X.current(e.id),I=c5(k,ir);return ne.current=I.send,De.current=I.setForeground,I.setForeground(Xe.current&&e.status==="running"),ni(I.status),I.status==="connected"&&en(),I.snapshot&&(V.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),$.current&&(en(),Ns(I.output,I.history),en())),()=>{Qu(I.send,{updateUi:!1}),I.setForeground(!1),I.detach(),ne.current=null,De.current=null}},[e.id,e.status]);function ir(k){if(k.type==="status"){ni(k.status),k.status==="unauthorized"&&W.current?.({source:"terminal-ws-1008",terminalId:e.id}),k.status==="connected"&&(en(),Po());return}if(k.type==="upgrade_rejected"){W.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(k.type==="outbound_flushed"){ce.current&&(ce.current=!1,Zr());return}z(k.message)}function yn(k=[],I=null){Fe.current=[],ee.current=Sh(k),fe.current=0,H.current=!1,ue.current=null,qe.current=!1,ke.current+=1,te.current=I,Ee.current=null,me.current=!1,Oe.current=!1,ze.current=!1,Je.current=null,_e.current=!1,Jt.current=null,Qi.current=null,zt.current=null,oi.current=!1,_i(!1),Ir(null),zr(!1),ds(null),hs(!1),fs(!1)}function Ns(k=[],I=null){if(qe.current||H.current){Qi.current={output:k,history:I,appendFromLiveOutputIndex:ee.current.length};return}yn(k,I),nr()}function As(){if(qe.current||H.current)return!1;const k=Qi.current;if(!k)return!1;const I=ee.current.slice(k.appendFromLiveOutputIndex);return Qi.current=null,yn([...k.output,...I],k.history),nr(),!0}function nr(){if(!$.current||!$t.current){_e.current=!0;return}_e.current=!1,sr()}async function sr(){const k=$.current;if(!k)return;const I=wh(k,oi.current),Ce=I?ee.current.length:fe.current,$e=await Ls(k,{liveOutputLimit:Ce,scrollToBottom:I});$.current===k&&(tn(),$e&&Po())}function Ls(k,I={}){return new Promise(Ce=>{qe.current=!0,H.current=!1;const $e=ke.current+1;ke.current=$e;const Ke=Math.max(0,Math.min(I.liveOutputLimit??ee.current.length,ee.current.length)),at=I.historyPages??Fe.current,ct=()=>$.current===k&&ke.current===$e,ht=()=>ct()&&(I.isCurrent?.()??!0),We=()=>{ct()&&(qe.current=!1),Ce(!1)},Kt=()=>{if(!ht()){We();return}try{fe.current=Ke,I.scrollToBottom&&Uo(k)}finally{if(qe.current=!1,As()){Ce(!1);return}const Dt=Yu();Dt?rr(Dt):I.applyDeferredSnapshot!==!1&&Yl(),Ce(!0)}},Rt=()=>{if(!ht()){We();return}k.clear();const Dt=Sh([...at,...ee.current.slice(0,Ke)]);if(Dt.length===0){Kt();return}for(let Bs=0;Bs<Dt.length;Bs+=1){const Wo=Dt[Bs];Bs===Dt.length-1?k.write(Wo,Kt):k.write(Wo)}};if(k.buffer.active.type==="alternate"){k.write(Gv,Rt);return}Rt()})}async function dn(k=0){const I=$.current;if(ze.current||!I)return;if(Vl(I)){tn();return}const Ce=te.current,$e=Ne.current,Ke=Symbol("history-load"),at=()=>$.current===I&&Ne.current===$e;Je.current=Ke,ze.current=!0,_i(!0);const ct=I.buffer.active.viewportY;try{let ht=!!(Ce&&!Ce.hasMore);if(!ht)try{const We=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:Y5});if(!at()||te.current!==Ce)return;const Kt=()=>at()&&te.current===Ce;if(We.invalidated){E();return}const Rt=We.hasMore&&We.snapshotHistorySize!==void 0&&We.snapshotPaneWidth!==void 0,Dt={startLine:We.startLine,endLine:We.endLine,hasMore:Rt,...We.snapshotHistorySize!==void 0?{snapshotHistorySize:We.snapshotHistorySize}:{},...We.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:We.snapshotHistoryLimit}:{},...We.snapshotHistoryToken!==void 0?{snapshotHistoryToken:We.snapshotHistoryToken}:{},...We.snapshotPaneWidth!==void 0?{snapshotPaneWidth:We.snapshotPaneWidth}:{}};if(We.output.length>0){await Xn(I,We.output,ct,k)&&Kt()&&(te.current=Dt);return}if(!Kt())return;te.current=Dt,ht=!Rt}catch(We){ht=at()&&bg(We)}if(ht){if(!at()||Vl(I)){tn();return}await xi(I,ct,k,at)}}catch{}finally{Je.current===Ke&&(Je.current=null,ze.current=!1,_i(!1))}}async function xi(k,I,Ce,$e){if(!$e()||me.current||Oe.current)return;const Ke=Ie.current,at=Qe.current,ct=Ee.current,ht=()=>$e()&&Qe.current===at&&gh(Ke,Ie.current)&&Ee.current===ct;try{const We=await t.getTerminalTranscriptHistory(e.id,{...ct?{cursor:ct}:{},limit:Q5}),Kt=We.output.map(Yx);if(!We.source||We.terminalId!==e.id||!ht())return;if(Ke&&!rb(Ke,We.source)){Ee.current=null,me.current=!1,Oe.current=!1,si(We.source);return}if(Kt.length===0){si(We.source),Ee.current=We.cursor,Oe.current=!We.hasMore||!We.cursor;return}await Xn(k,Kt,I,Ce,ht)&&ht()&&(si(We.source),Ee.current=We.cursor,Oe.current=!We.hasMore||!We.cursor)}catch(We){ht()&&bg(We)&&(me.current=!0)}}async function Xn(k,I,Ce,$e,Ke){if(Vl(k)||Ke&&!Ke())return tn(),!1;const at=Fe.current,ct=[...I,...at],ht=zO(I),We=ke.current+1,Kt=await Ls(k,{liveOutputLimit:fe.current,scrollToBottom:!1,historyPages:ct,applyDeferredSnapshot:!1,...Ke?{isCurrent:Ke}:{}}),Rt=Ke!==void 0&&!Ke();return!Kt||Rt||$.current!==k?(Rt&&$.current===k&&ke.current===We&&await Ls(k,{liveOutputLimit:fe.current,scrollToBottom:!1,historyPages:at,applyDeferredSnapshot:!1})&&$.current===k&&(Xl(k,Ce),oi.current=!qn(k),Os()),!1):(Fe.current=ct,Xl(k,Math.max(0,Ce+ht+Math.min(0,$e))),oi.current=!qn(k),Os(),!0)}v.useEffect(()=>{const k=window.visualViewport;function I(){document.visibilityState!=="hidden"&&C()}function Ce(){C()}function $e(){C()}function Ke(){he()}function at(){Ge()}return document.addEventListener("visibilitychange",I),window.addEventListener("pageshow",Ce),window.addEventListener("online",$e),window.addEventListener("resize",Ke),window.addEventListener(sf,at),k?.addEventListener("resize",Ke),k?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",I),window.removeEventListener("pageshow",Ce),window.removeEventListener("online",$e),window.removeEventListener("resize",Ke),window.removeEventListener(sf,at),k?.removeEventListener("resize",Ke),k?.removeEventListener("scroll",Ke)}},[e.id]);function C(){document.visibilityState==="hidden"||!Xe.current||(Po(),en())}function E(){const k=X.current(e.id);Ne.current+=1,rt.current=!0,Jt.current=null,ni("reconnecting"),en(),u5(k)}function z(k){if(k.type==="snapshot"&&k.terminal.id===e.id){Ne.current+=1,V.current.onSnapshot(k.terminal,{notifyCompletion:!1});const Ce=rt.current;rt.current=!1;const $e=$.current;if(!$e)return;if(en(),Ce){re(k.output,k.history??null);return}if(zf($e,k.terminal)){Hf(k.output,k.history??null),tn(),en();return}Ns(k.output,k.history??null),en();return}if(k.type==="terminal_updated"&&k.terminal.id===e.id){V.current.onSnapshot(k.terminal,{notifyCompletion:!0});return}if(k.type==="output"&&k.terminalId===e.id){const Ce=Ak(k.data);if(!Ce)return;ee.current.push(Ce),$.current&&$t.current?rr({scrollToBottom:!0}):_e.current=!0;return}const I=$.current;if(I){if(k.type==="exit"&&k.terminalId===e.id){V.current.onExit(k.exitCode),ni("closed");return}k.type==="error"&&I.writeln(`\r
52
+ [nterminal] ${k.message}`)}}function re(k,I){Ns(k,I),en()}function be(k=25){if(document.visibilityState==="hidden"||!Xe.current||ae.current.has(k))return;const I=window.setTimeout(()=>{ae.current.delete(k),!Te()&&Uf()},k);ae.current.set(k,I)}function he(){Te()||$l()}function Te(){const k=Yt();return k&&gt(k)?(B.current=!0,R.current=k,!0):k&&ki(k)?(B.current=!1,R.current=null,!0):((!k||!k.composeOpen&&!k.keyboardVisible)&&(B.current=!1,R.current=null),!1)}function Ge(){if(!B.current)return;const k=Yt();k&&(k.composeOpen||k.keyboardVisible)||(B.current=!1,R.current=null)}function gt(k){if(!k.mobileLike||!k.composeOpen&&!k.keyboardVisible)return!1;const I=L.current;return I?Yr(k.windowWidth,I.windowWidth)&&Yr(k.visualViewportWidth,I.visualViewportWidth)&&Yr(k.containerWidth,I.containerWidth):!1}function ki(k){if(!k.mobileLike||k.composeOpen||k.keyboardVisible)return!1;const I=R.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:Yr(k.windowWidth,I.windowWidth)&&Yr(k.visualViewportWidth,I.visualViewportWidth)&&Yr(k.containerWidth,I.containerWidth)}function Yt(){const k=Q.current;if(!k||k.isConnected===!1)return null;const I=k.getBoundingClientRect(),Ce=zo(window.innerWidth)??0,$e=zo(window.visualViewport?.width)??Ce,Ke=zo(I.width)??zo(k.clientWidth)??Ce;if(Ce<=0||$e<=0||Ke<=0)return null;const{keyboardVisible:at}=Hv(),ct=document.documentElement.hasAttribute(Df),ht=Vr()||at;return{windowWidth:Ce,visualViewportWidth:$e,containerWidth:Ke,composeOpen:ct,keyboardVisible:at,mobileLike:ht}}function Vr(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Bf(){return Hv().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function zo(k){return typeof k=="number"&&Number.isFinite(k)&&k>0?k:null}function Yr(k,I){return Math.abs(k-I)<=q5}function $l(){for(const k of F5)be(k)}function en(){le.current=null,$l()}function Po(){if(Ho(),M.current.size===0&&typeof window.requestAnimationFrame=="function"){const k=window.requestAnimationFrame(()=>{M.current.delete(k),Ho();const I=window.requestAnimationFrame(()=>{M.current.delete(I),Ho()});M.current.add(I)});M.current.add(k)}for(const k of $5){if(ye.current.has(k))continue;const I=window.setTimeout(()=>{ye.current.delete(k),Ho()},k);ye.current.set(k,I)}}function Ho(){const k=$.current;if(!(!k||!$t.current||document.visibilityState==="hidden"||!Xe.current||Q.current?.isConnected===!1))try{k.refresh(0,Math.max(0,k.rows-1))}catch{}}function Wu(){for(const k of ae.current.values())window.clearTimeout(k);ae.current.clear()}function Fu(){for(const k of ye.current.values())window.clearTimeout(k);ye.current.clear();for(const k of M.current)window.cancelAnimationFrame(k);M.current.clear()}function $u(){for(const k of K.current)window.clearTimeout(k);K.current=[]}function Os(){if(tn(),!zt.current){zr(!1);return}zr(!0),qu(),gn.current=window.setTimeout(()=>{gn.current=null,zr(!1)},1200)}function tn(){const k=$.current,I=k?PO(k):null;if(zt.current=I,Ir(I),fs(!!(k&&I)),hs(!!(k&&I&&!qn(k))),I||!k||!jf()){ds(null);return}ds({alternate:k.buffer.active.type==="alternate"})}function jf(){const k=te.current;return Fe.current.length>0||!!k?.hasMore}function qu(){gn.current!==null&&(window.clearTimeout(gn.current),gn.current=null)}function ql(){const k=$.current;k&&(oi.current=!qn(k),tn())}function Vu(k){ue.current=yg(ue.current,k)}function If(k){const I=ue.current;return ue.current=null,yg(I,k)}function Yu(){const k=ue.current;return ue.current=null,k}function rr(k={}){const I=$.current;if(!I||!$t.current){_e.current=!0;return}if(Jt.current&&!qe.current&&!H.current&&qn(I)){Yl();return}if(qe.current){Vu(k);return}if(H.current){Vu(k);return}const Ce=If(k);if(!Ce.force&&!wh(I,oi.current)){tn();return}H.current=!0;const $e=ke.current,Ke=()=>{if($.current!==I||ke.current!==$e)return;if(!Ce.force&&!wh(I,oi.current)){if(H.current=!1,As())return;tn();return}const at=fe.current,ct=ee.current[at];if(ct===void 0){if(H.current=!1,As())return;Ce.scrollToBottom&&Uo(I),tn();const ht=Yu();ht?rr(yg(Ce,ht)):Yl();return}I.write(ct,()=>{$.current!==I||ke.current!==$e||(fe.current=at+1,Ke())})};Ke()}function Vl(k){return Jt.current!==null||!qn(k)&&(Pf()||H.current||qe.current)}function zf(k,I){return(I?.agentStatus?.provider==="codex"||I?.agentStatus?.provider==="claude"||vn.current||iu(I?.currentCommand))&&!qn(k)}function Pf(){return fe.current<ee.current.length}function Hf(k,I){Jt.current={output:k,history:I,appendFromLiveOutputIndex:ee.current.length}}function Yl(){const k=$.current,I=Jt.current;if(!k||!I||!qn(k)||H.current||qe.current)return;const Ce=Sh(I.output),$e=Sh(ee.current.slice(I.appendFromLiveOutputIndex));Jt.current=null,Ns([...Ce,...$e],I.history),en()}function Va(){Ct.current=!0}function ar(){ql(),Ct.current=!1;const k=$.current;k&&qn(k)&&rr({scrollToBottom:!0})}function Uo(k){Gl(()=>M1(k))&&(oi.current=!1)}function Xl(k,I){Gl(()=>(k.scrollToLine(I),!0))}function Gl(k){mi.current=!0;try{return k()}finally{mi.current=!1}}function Xu(){const k=$.current;if(!k)return;const I=()=>{Be.current&&(Ga(ne.current),At(!1)),M1(k),oi.current=!1,tn(),rr({force:!0,scrollToBottom:!0}),bs("scroll-action")};if(k.buffer.active.type==="alternate"){k.write(Gv,I);return}I()}function Zl(k){const I=$.current,Ce=Q.current;if(!I||!Ce)return;const $e=Ce.getBoundingClientRect();if($e.height<=0)return;const Ke=Math.max(0,Math.min(1,(k-$e.top)/$e.height)),at=Math.round(I.buffer.active.baseY*Ke);Va();try{I.scrollToLine(at)}finally{ar()}oi.current=!qn(I),tn(),Os(),at<=3&&dn()}function Gu(k){k.preventDefault(),k.stopPropagation(),k.currentTarget.setPointerCapture?.(k.pointerId),Zl(k.clientY)}function Xr(k){(k.buttons&1)!==0&&(k.preventDefault(),k.stopPropagation(),Zl(k.clientY))}function Uf(){const k=$.current,I=Se.current;if(!(!k||!I)&&!(document.visibilityState==="hidden"||!Xe.current||Q.current?.isConnected===!1))try{const Ce=wh(k,oi.current),$e=Yt();I.fit(),$e&&(L.current=$e),Ce&&Uo(k),k.refresh(0,Math.max(0,k.rows-1)),tn();const Ke={cols:k.cols,rows:k.rows},at=le.current;if(at&&at.cols===Ke.cols&&at.rows===Ke.rows)return;Ql({type:"resize",terminalId:e.id,cols:Ke.cols,rows:Ke.rows})&&(le.current=Ke)}catch{}}function Zu(k,I){const Ce=ne.current;return Ce?Ce(k,I):"rejected"}function Ql(k){return Zu(k)!=="rejected"}function Ya(){we.current!==null&&(window.clearTimeout(we.current),we.current=null)}function Jl(){Ya();const k=Math.max(-_h,Math.min(_h,Le.current));if(Le.current=0,k===0)return!1;const I=Ql({type:"scrollback_scroll",terminalId:e.id,lines:k});return I&&(xe.current=!0,k<0&&At(!0)),I}function Gr(k){if(!Be.current||k===0)return;const I=Le.current+k;Le.current=Math.max(-_h,Math.min(_h,I)),we.current===null&&(we.current=window.setTimeout(()=>{we.current=null,Jl()},fO))}function Xa(){Ga(ne.current)}function Qu(k=ne.current,I={}){const Ce=xe.current;Ya(),Le.current=0,xe.current=!1,I.updateUi!==!1&&At(!1),Ce&&k?.({type:"cancel_scrollback",terminalId:e.id})}function Ga(k){Ya(),Le.current=0,xe.current=!1,At(!1),k?.({type:"cancel_scrollback",terminalId:e.id})}function ec(){if(!Re.current)return;const k=!Be.current;Wr(MR(se.current,k)),Wf()}function Ju(){const k=!Vt.current;Vt.current=k,ps(k),Gn({tone:k?"info":"skipped",message:k?"Cache keep-alive enabled":"Cache keep-alive off",...k?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function Ko(){Ht.current!==null&&(window.clearTimeout(Ht.current),Ht.current=null)}function Gn(k,I={}){Ko();const Ce=ci.current+1;ci.current=Ce,bn({...k,id:Ce}),!I.sticky&&(Ht.current=window.setTimeout(()=>{Ht.current=null,bn($e=>$e?.id===Ce?null:$e)},12e3))}function ed(){ii.current.skipped=!0,Gn({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function td(){Vt.current=!1,ps(!1),Gn({tone:"skipped",message:"Cache keep-alive off"})}async function tc(){const k=ii.current;if(k.sent||k.skipped)return;const I=Kf();if(k.sent=!0,I){Gn({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}if(or(`${S1}\r`,{userInitiated:!1})==="rejected"){Gn({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Gn({tone:"success",message:"Cache keep-alive sent",detail:S1})}function Kf(){const k=li.current,I=Ie.current;return Vt.current?e.status!=="running"?"Pane is not running.":!k||k.status!=="ready"||!k.source||!I?"Transcript cache status is unavailable.":k.source.provider!==I.provider||k.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${To(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Rf(e.id).text.trim()?"Compose has an unsent draft.":wO(Q.current)?"Pane input is focused.":Date.now()-Hi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function Wf(){const k=$.current;k&&(Uo(k),tn())}function or(k,I={}){Jl();const Ce=xe.current;rr({force:!0,scrollToBottom:!0});const $e=Zu({type:"input",terminalId:e.id,data:k,...Ce?{cancelScrollbackMode:!0}:{}},{durability:I.userInitiated===!1?"live-only":"durable"});return $e==="rejected"?(I.userInitiated!==!1&&yi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),$e):(I.userInitiated!==!1&&(Hi.current=Date.now()),Ce&&(xe.current=!1,At(!1)),jO(k)&&($e==="sent"?Zr():$e==="queued"&&(ce.current=!0)),$e)}function Ff(){Ve.current&&Za(!1),or(G5)}function $f(k){const I=a1(k,{bracketedPasteMode:$.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&or(I)}function Sn(k,I){const Ce=a1(k,{bracketedPasteMode:$.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});return Ce?or(`${Ce}${C3(I)}`)!=="rejected":!1}function Zr(){!xt.current||!nt.current||($u(),K.current=V5.map(k=>{const I=window.setTimeout(()=>{K.current=K.current.filter(Ce=>Ce!==I),xt.current&&nt.current&&Ql({type:"refresh_cwd",terminalId:e.id})},k);return I}))}function bs(k="terminal-interaction"){gi.current||Bf()&&(k==="auto"||k==="scroll-action")||$.current?.focus()}const id=v.useCallback(()=>{Ds(!1)},[]),nd=v.useCallback(async()=>{const k=Ie.current,I=Qe.current;try{const Ce=await t.getTerminalTranscriptSource(e.id);if(!Ce.source||wt.current!==e.id||Qe.current!==I||!gh(k,Ie.current))return;Ee.current=null,me.current=!1,Oe.current=!1,si(Ce.source),Pt.current=_g(e.id,Ce.source)}catch{}},[si,t,e.id]);function sd(){Pr(k=>{const I=!k;return Ve.current=I,I}),bs("input-action")}function Za(k){Ve.current=k,Pr(k)}function qf(k){Ve.current&&Za(!1),or(r3(k)),bs("input-action")}async function lr(k="install"){vs(!0),cn(null);try{const I=k==="update"?await t.updateCodeServer():await t.installCodeServer();Zv(un,I.status),gs(I.status)}catch(I){cn(yh(I))}finally{vs(!1)}}return f.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":bi?"true":"false",onMouseDown:()=>{n||g()},children:[f.jsx(CO,{terminal:e,canClose:o,tabId:u,transcriptSource:Ut,transcriptShortcutLabel:q,subagentsShortcutLabel:ie,transcriptCacheStatus:Ji,transcriptCacheNow:Hr,cacheKeepAliveEnabled:Qs,codeServerAvailable:!0,codeServerInstallState:Ki===null?"unknown":Ki.installed?"installed":"missing",codeServerBusy:ft||Ki?.job?.status==="running",codeServerSupported:Ki?.supported!==!1,scrollbackShortcutLabel:F,tmuxScrollbackSupported:_s,tmuxScrollbackEnabled:bi,onToggleCacheKeepAlive:Ju,onOpenCodeServer:qr,onToggleTmuxScrollback:ec,onOpenTranscript:tr,onOpenSubagents:qa,onReload:E,onClose:p}),f.jsx("div",{className:"xterm-container",ref:Q}),vi?f.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:f.jsx("span",{"aria-hidden":"true"})}):null,D&&!bi&&Bn?f.jsxs("div",{className:"terminal-scroll-progress","data-active":Lo,"aria-hidden":"true",children:[Bn.current,"/",Bn.total]}):D&&!bi&&Gs?f.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Gs.alternate?"alternate":"normal","aria-hidden":"true",children:[Gs.alternate?"alt ":"","0/?"]}):null,Zs||bi&&Es?f.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:k=>k.stopPropagation(),onMouseDown:k=>k.stopPropagation(),onClick:k=>{k.stopPropagation(),Xu()},children:"↓"}):null,Ts&&!bi?f.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Gu,onPointerMove:Xr,children:f.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?$r?f.jsx(n3,{ctrlActive:Oo,onCtrl:sd,onStandaloneKey:qf,onPreserveFocus:()=>bs("input-action"),onHide:()=>Wi(!1)}):f.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:k=>{k.stopPropagation(),bs("input-action")},onPointerDown:k=>{k.stopPropagation(),bs("input-action")},onClick:()=>Wi(!0),children:"⌨"}):null,f.jsx(R3,{terminalId:e.id,onSubmit:Sn,queueAvailable:er==="codex"||Mk(e.currentCommand),disabled:e.status!=="running"}),f.jsx(EO,{toast:Ur,onSendNow:()=>{tc()},onSkipOnce:ed,onTurnOff:td,onDismiss:()=>bn(null)}),Ui&&Ut?f.jsx(DO,{terminalId:e.id,serverApi:t,source:Ut,fontSize:w,onClose:id,onReloadLatest:nd}):null,Fa&&Ut?f.jsx(WL,{terminalId:e.id,serverApi:t,source:Ut,fontSize:w,onClose:()=>ms(!1)}):null,Kr?f.jsx(kO,{notice:Kr}):null,Rs?f.jsx(xO,{status:Ki,busy:ft,error:Js,onInstall:()=>{lr("install")},onUpdate:()=>{lr("update")},onOpen:qr,onRefresh:()=>{In({checkLatest:!0}).catch(k=>cn(yh(k)))},onClose:()=>Li(!1)}):null]})}function x1(e){return IE(e)}async function k1(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=Sl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=pO)return u.status;if(u?.inflight&&(!r||u.inflightCheckLatest))return u.inflight;let m;return m=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(Zv(e,g),g)).catch(g=>{const p=Sl.get(e);throw p?.inflight===m&&(p.status?Sl.set(e,{status:p.status,fetchedAt:p.fetchedAt}):Sl.delete(e)),g}),Sl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:r}),m}function Zv(e,t){Sl.set(e,{status:t,fetchedAt:Date.now()})}function bh(e,t){return`${e}:${t}`}function Ek(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function T1(e){const t=mu.get(e);if(!t)return!1;try{return t.closed?(mu.delete(e),!1):(t.focus(),!0)}catch{return mu.delete(e),!1}}function gg(e,t){const n=window.open(t,Ek(e));if(!n)return null;mu.set(e,n);try{n.focus()}catch{}return n}function E1(e,t,n){if(!e||Dk(e))return!1;try{return e.name=Ek(t),e.location.href=n,mu.set(t,e),e.focus(),!0}catch{return!1}}function mO(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 Dk(e){if(!e)return!0;try{return e.closed}catch{return!0}}function vg(e){if(e)try{e.closed||e.close()}catch{}}function gO(e,t,n){const r=vO(e,t),o=D1(r*Math.max(1,n),aO,oO);return{limit:D1(Math.ceil(o/nO),sO,rO),maxLines:o}}function vO(e,t){const n=e?.clientHeight??0;if(n<=0)return tO;const r=Math.max(10,t*iO);return Math.max(1,Math.floor(n/r))}function D1(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function _O(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function _g(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function Rk(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 bO(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function yO(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),u=r%24;return u>0?`${c}d ${u}h`:`${c}d`}function SO(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function yh(e){return e instanceof Ln||e instanceof Error?e.message:"Something went wrong."}function wO(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function CO({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:m,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:y,codeServerBusy:b,codeServerSupported:S,scrollbackShortcutLabel:w,tmuxScrollbackSupported:x,tmuxScrollbackEnabled:D,onToggleCacheKeepAlive:O,onOpenCodeServer:N,onToggleTmuxScrollback:j,onOpenTranscript:q,onOpenSubagents:F,onReload:ie,onClose:Q}){const $=mC({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:!S||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 ${To(r.provider)} transcript history`,"aria-label":`View ${To(r.provider)} transcript history`,onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),q()},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(),F()},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(TO,{status:u,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 (${w})`,title:D?`Scroll input uses tmux scrollback (${w}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${w}).`,onPointerDown:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),onClick:ne=>{ne.stopPropagation(),j()},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:w})]}):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 xO({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:m}){const g=e?.job??null,p=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,S=e===null&&t,w=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:S?"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."]}),S?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:u,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:w?"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 kO({notice:e}){return f.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function TO({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=Rk(e,t),c=bO(e,o),u=o===null?"?":yO(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:u})]})}function EO({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 DO=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const m=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),S=v.useRef(""),w=v.useRef(null),x=v.useRef(null),[D,O]=v.useState([]),[N,j]=v.useState(!1),[q,F]=v.useState(""),[ie,Q]=v.useState(-1),[$,Se]=v.useState(!1),[ne,De]=v.useState(-1),[se,V]=v.useState(null),[X,W]=v.useState(null),[le,L]=v.useState(!1),[R,B]=v.useState(!0),[ae,ye]=v.useState(!1),[M,K]=v.useState(null),[ce,we]=v.useState(!1);v.useEffect(()=>{function _e(Ve){Ve.key==="Escape"&&(Ve.preventDefault(),Ve.stopPropagation(),c())}return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[c]),v.useEffect(()=>{g.current+=1;const _e=g.current;return p.current=!1,y.current=!0,b.current=null,w.current=null,x.current=null,O([]),W(null),L(!1),K(null),we(!1),Q(-1),De(-1),V(null),rt(null,"initial",_e),()=>{g.current===_e&&(g.current+=1)}},[n,N,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const _e=m.current;if(!_e)return;if(y.current){if(R||D.length===0)return;y.current=!1;const nt=()=>{_e.scrollTop=_e.scrollHeight};nt(),window.requestAnimationFrame?.(nt);return}const Ve=b.current;Ve!==null&&(b.current=null,_e.scrollTop+=_e.scrollHeight-Ve)},[D,R,N]);const Le=To(r.provider),xe=ef(D,N),Be=Vx(xe),Re=RO(Be),He=Re.map(_e=>_e.key).join(""),Fe=se?Re.find(_e=>_e.key===se)?.entryIndex??null:null,ee=q.trim().length>0,fe=BL(Be,q),H=fe.length,ue=H>0?ie>=0&&ie<H?ie:0:-1,ke=ue>=0?fe[ue]?.entryIndex??null:null,Ne=ue>=0?fe[ue]??null:null,te=ee?ke:Fe,Ee=ee?ke===null?null:"search":Fe===null?null:"prompt",me=xe?xe.split(`
54
+ `).length-1:0,Oe=Re.length>0&&ne>=0&&ne<Re.length?ne:Re.length-1,ze=se??(Oe>=0?Re[Oe]?.key??null:null),Je=ee?H>0?`${ue+1}/${H} ${H===1?"match":"matches"} · ${me} ${me===1?"line":"lines"}`:`0 matches · ${me} ${me===1?"line":"lines"}`:Re.length>0?`${Oe+1}/${Re.length} prompts · ${me} ${me===1?"line":"lines"}`:`0 prompts · ${me} ${me===1?"line":"lines"}`;v.useEffect(()=>{const _e=q.trim().toLowerCase();Q(Ve=>!_e||H===0?-1:S.current!==_e?0:Ve>=0&&Ve<H?Ve:0),S.current=_e},[q,H]),v.useEffect(()=>{if(ee){V(null);return}se&&!Re.some(_e=>_e.key===se)&&V(null),De(_e=>{if(Re.length===0)return x.current=null,-1;const Ve=x.current?Re.findIndex(Xe=>Xe.key===x.current):-1,nt=Ve>=0?Ve:_e>=0&&_e<Re.length?_e:Re.length-1;return x.current=Re[nt]?.key??null,nt})},[se,ee,He]),v.useEffect(()=>{const _e=w.current;if(!_e||Re.length===0)return;w.current=null;const Ve=_e.anchorKey?Re.findIndex(Xe=>Xe.key===_e.anchorKey):-1,nt=Ve>0?Ve-1:0;qe(nt)},[He]);async function rt(_e,Ve,nt=g.current){if(!p.current){p.current=!0,Ve==="initial"?B(!0):(ye(!0),b.current=m.current?.scrollHeight??null),K(null);try{await zt(_e,Ve,nt)}catch(Xe){if(g.current!==nt)return;K(Xe instanceof Error?Xe.message:"Failed to load transcript history.")}finally{g.current===nt&&(p.current=!1,B(!1),ye(!1))}}}async function zt(_e,Ve,nt){let Xe=_e,xt=0,lt=[];const Tn=Ve==="initial"&&r.provider!=="claude"?cO:lO;for(;g.current===nt;){const gi=await n.getTerminalTranscriptHistory(t,{...Xe?{cursor:Xe}:{},...gO(m.current,o,Ve==="initial"?J5:eO),includeTools:N});if(g.current!==nt)return;if(!gi.source){K("Transcript source is temporarily unavailable.");return}if(!rb(r,gi.source)){we(!0),L(!1);return}const Z=Pv(gi.output,r.provider,{includeTools:N}),Ie=gn(gi,Ve,lt,Z);if(Z&&(lt=[Z,...lt],Ie))return;if(!gi.hasMore||!gi.cursor||xt>=Tn){lt.length>0&&O(it=>Ve==="older"?[...lt,...it]:lt);return}Xe=gi.cursor,xt+=1}}function gn(_e,Ve,nt,Xe=Pv(_e.output,r.provider,{includeTools:N})){if(W(_e.cursor),L(!!(_e.hasMore&&_e.cursor)),!Xe)return!1;const xt=[Xe,...nt];return ef(xt,N)?(O(lt=>Ve==="older"?[...xt,...lt]:xt),!0):!1}function oi(){const _e=m.current;_e&&($t(),!(_e.scrollTop>72||!le||!X||p.current)&&rt(X,"older"))}function mi(_e){H!==0&&Q(Ve=>{const nt=ue>=0?ue:_e>0?-1:0;return((Ve>=0&&Ve<H?Ve:nt)+_e+H)%H})}function qe(_e){const Ve=Re[_e];Ve&&(x.current=Ve.key,De(_e),V(Ve.key))}async function Ct(_e){if(Re.length===0){_e<0&&le&&X&&!p.current&&(w.current={anchorKey:null},await rt(X,"older"));return}const nt=(ne>=0&&ne<Re.length?ne:_e<0?Re.length-1:-1)+_e;if(nt>=0&&nt<Re.length){qe(nt);return}_e<0&&nt<0&&le&&X&&!p.current&&(w.current={anchorKey:Re[0]?.key??null},await rt(X,"older"))}function $t(){if(ee)return;const _e=m.current;if(!_e)return;const nt=_e.getBoundingClientRect().top+Math.min(140,Math.max(48,_e.clientHeight*.28));let Xe=null;for(const xt of OO(_e)){const lt=BO(xt);if(lt!==null)if(xt.getBoundingClientRect().top<=nt)Xe=lt;else break}if(Xe!==null){const xt=Re[Xe]?.key??null;x.current=xt,De(Xe),se&&se!==xt&&V(null)}}return f.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>_e.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:_e=>j(_e.currentTarget.checked)}),"Show tool output"]}),f.jsx("label",{className:"transcript-search",children:f.jsx("input",{type:"search",value:q,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:_e=>F(_e.currentTarget.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),ee?mi(_e.shiftKey?-1:1):Ct(_e.shiftKey?-1:1))}})}),f.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":$,"aria-label":"Toggle prompt list",onClick:()=>Se(_e=>!_e),disabled:Re.length===0,children:"List"}),f.jsxs("div",{className:"transcript-search-actions","aria-label":ee?"Search result navigation":"Prompt navigation",children:[f.jsx("button",{type:"button",onClick:()=>ee?mi(-1):void Ct(-1),disabled:ee?H===0:Re.length===0&&!le,"aria-label":ee?"Previous search match":"Previous user prompt",title:ee?"Previous search match":"Previous user prompt",children:"Prev"}),f.jsx("button",{type:"button",onClick:()=>ee?mi(1):void Ct(1),disabled:ee?H===0:Re.length===0,"aria-label":ee?"Next search match":"Next user prompt",title:ee?"Next search match":"Next user prompt",children:"Next"})]}),f.jsx("span",{className:"transcript-result-count",children:Je})]}),$?f.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Re.length>0?Re.map((_e,Ve)=>f.jsxs("button",{type:"button",className:ze===_e.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>qe(Ve),children:[f.jsx("span",{children:_e.timestampLabel}),f.jsx("strong",{children:_e.snippet})]},`${_e.key}:${Ve}`)):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:oi,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($x,{entries:Be,searchQuery:q,activeEntryIndex:te,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:()=>{u()},children:"Load current session"})]}):null,!ce&&!R&&!xe&&!M?le&&X?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:()=>{rt(X,"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 RO(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:MO(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=n.get(c.contentKey)??0;n.set(c.contentKey,u+1),r.set(o,JSON.stringify([c.contentKey,u]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:AO(o.entry.body),timestampLabel:LO(o.entry.header)}))}function MO(e){return JSON.stringify([e.header??"",e.body.length,NO(e.body)])}function NO(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 AO(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function LO(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function OO(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function BO(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 jO(e){return e.includes("\r")||e.includes(`
55
+ `)}function bg(e){return e instanceof Ln&&e.status===404}function iu(e){return Mk(e)||Nk(e)}function Mk(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function Nk(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function IO(e){if(iu(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function zO(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 Sh(e){const t=[];for(const n of e){const r=Ak(n);r&&t.push(r)}return t}function Ak(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!Z5.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function yg(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function PO(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 R1(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 qn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function wh(e,t){return!t||qn(e)}function M1(e){return qn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function HO(e,t,n,r,o,c,u,m){const g=p=>{const y=KO(p);if(y!==0){if(u()){if($O(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),m(y);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),UO(t,y,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function UO(e,t,n,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(Gv,u);return}u()}function KO(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 WO(e,t,n,r,o,c,u,m,g){let p=null,y=0;const b={passive:!1};function S(D){p=Sg(D),y=0}function w(D){const O=Sg(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(FO(t)&&qO(t,O,-N)){y=0;return}y-=N/n();const j=y<0?Math.ceil(y):Math.floor(y);if(j!==0){if(y-=j,m()){g(j);return}c();try{t.scrollLines(j)}finally{u()}r(),j<0&&t.buffer.active.viewportY<=3&&o(j)}}function x(D){if(D.touches.length>0){p=Sg(D);return}p=null,y=0}return e.addEventListener("touchstart",S,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",S,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Sg(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function FO(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function $O(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function qO(e,t,n){const r=e.element;return r?(r.dispatchEvent(VO(t,n)),!0):!1}function VO(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 Qv({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:m,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:S=[],totalPanes:w,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:j,onCloseEditor:q,onAuthClose:F}){const ie=w??Jv(e);if(S.length===0&&b){const ne=e_(e),De=ne.some(se=>se.key===b)?b:ne[0]?.key;if(ne.length>1&&De)return f.jsx("div",{className:"mobile-focused-split",children:ne.map(se=>{const V=se.key===De;if(se.type==="editor"){const W=n[se.editorId];return f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:W?f.jsx(rw,{api:r,editor:W,canClose:ie>1,onClose:()=>q(se.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},se.key)}const X=t[se.terminalId];return X?f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx(C1,{terminal:X,serverApi:r,active:V,visible:c&&V,canClose:ie>1,refreshCwdOnEnter:u&&V,tabId:m,codeServerContext:g,onSelect:()=>x(se.terminalId),onClose:()=>D(se.terminalId),onExit:W=>N(se.terminalId,W),onSnapshot:j,...F?{onAuthClose:F}:{}})},se.key):f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},se.key)})})}if(e.type==="pane"){const ne=t[e.terminalId];if(!ne)return f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const De=f.jsx(C1,{terminal:ne,serverApi:r,active:e.terminalId===o,visible:c,canClose:ie>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>x(e.terminalId),onClose:()=>D(e.terminalId),onExit:V=>N(e.terminalId,V),onSnapshot:j,...F?{onAuthClose:F}:{}});return p&&y!==e.terminalId?f.jsxs("div",{className:"pane-drop-host",children:[De,f.jsx(Ch,{terminalId:e.terminalId,side:"top"}),f.jsx(Ch,{terminalId:e.terminalId,side:"right"}),f.jsx(Ch,{terminalId:e.terminalId,side:"bottom"}),f.jsx(Ch,{terminalId:e.terminalId,side:"left"})]}):De}if(e.type==="editor"){const ne=n[e.editorId];return ne?f.jsx(rw,{api:r,editor:ne,canClose:ie>1,onClose:()=>q(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(Qv,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...S,0],totalPanes:ie,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:j,onCloseEditor:q,...F?{onAuthClose:F}:{}})}),f.jsx(YO,{direction:e.direction,path:S,onResize:O}),f.jsx("div",{className:"split-cell",children:f.jsx(Qv,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...S,1],totalPanes:ie,onSelect:x,onClose:D,onResize:O,onExit:N,onSnapshot:j,onCloseEditor:q,...F?{onAuthClose:F}:{}})})]})}function Ch({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=D_({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 YO({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const u=c.parentElement;if(!u)return;const m=u.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 Jv(e){return e.type==="pane"||e.type==="editor"?1:Jv(e.first)+Jv(e.second)}function e_(e){return e.type==="pane"?[{key:XO(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:GO(e.editorId),type:"editor",editorId:e.editorId}]:[...e_(e.first),...e_(e.second)]}function XO(e){return`terminal:${e}`}function GO(e){return`editor:${e}`}const Af="workspace-default",ZO="NTerminal";function QO(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function JO(e,t){switch(t.type){case"workspace.hydrated":return t_(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return eB(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return sB(e,t.workspaceId);case"workspace.selected":return Lk(e,t.workspaceId);case"workspace.renamed":return tB(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return iB(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return nB(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return Ok(e,t.terminal);case"terminal.split":return rB(e,t.terminal,t.direction);case"terminal.updated":return gB(e,t.terminal);case"terminal.exited":return vB(e,t.terminalId,t.exitCode);case"terminal.closed":return Ik(e,t.terminalId);case"terminal.detached":return _B(e,t.terminalId,t.workspaceId);case"editor.split":return aB(e,t.editorId,t.title,t.direction);case"editor.closed":return bB(e,t.editorId);case"pane.selected":return pB(e,t.terminalId);case"pane.resized":return mB(e,t.path,t.ratio);case"tab.selected":return lB(e,t.tabId);case"tab.renamed":return fB(e,t.tabId,t.title);case"tab.reordered":return db(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return cB(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return Bk(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return jk(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return uB(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return oB(e);default:return e}}function eB(e,t){if(e.workspaces.some(r=>r.id===t.id))return Lk(e,t.id);const n={id:t.id,title:t.title,defaultCwd:ks(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function Lk(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function tB(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.title===r?u:(o=!0,{...u,title:r}));return o?{...e,workspaces:c}:e}function iB(e,t,n){const r=ks(n);let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.defaultCwd===r?u:(o=!0,{...u,defaultCwd:r}));return o?{...e,workspaces:c}:e}function nB(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const u=e.workspaces.slice(),[m]=u.splice(o,1);if(!m)return e;const g=u.findIndex(b=>b.id===n);if(g<0)return e;const p=r==="before"?g:g+1,y=u.slice();return y.splice(p,0,m),hB(e.workspaces,y)?e:{...e,workspaces:y}}function sB(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?cf(n):[]),o={...e.terminals};for(const m of r)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),u=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:u,terminals:o}}function Ok(e,t){const n=Pk(e),r=No(n)??Of(),o=Fk(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??ks(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:Wk(c,t.id))}}function rB(e,t,n){const r=No(e),o=r?Lf(r):void 0;if(!r||!o)return Ok(e,t);const c=o.activeTerminalId,u=Mu(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??ks(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:Wk(m,t.id))}}function aB(e,t,n,r){const o=No(e),c=o?Lf(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,m=Mu(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:m,activeTerminalId:u}:p)}:g)}}function oB(e){const t=No(e),n=t?Lf(t):void 0;return n?Ik(e,n.activeTerminalId):e}function lB(e,t){const n=No(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 db(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const u=o.tabs.slice(),[m]=u.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(u.length,n)),p=u.slice();return p.splice(g,0,m),dB(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function cB(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=Ll(y.root,n);if(!b){const x=g.tabs.filter((D,O)=>O!==p);return{...g,tabs:x}}const S={...y,root:b,activeTerminalId:zi(b)[0]??y.activeTerminalId},w=g.tabs.slice();return w[p]=S,{...g,tabs:w}});const u=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(D=>zi(D.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:n},S={type:"split",direction:u,ratio:.5,first:m?b:{type:"pane",terminalId:r},second:m?{type:"pane",terminalId:r}:b},w=Mu(y.root,r,S),x=g.tabs.slice();return x[p]={...y,root:w,activeTerminalId:n},{...g,tabs:x,activeTabId:y.id}}),Pk({...e,workspaces:c})}function Bk(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(j=>j.id===t);if(N>=0){o=O,c=N;break}}if(o<0)return e;const u=e.workspaces[o],m=u.tabs[c],g=zi(m.root);if(!g.includes(n))return e;if(g.length===1)return db(e,t,r);const p=Ll(m.root,n);if(!p)return e;const y={...m,root:p,activeTerminalId:zi(p)[0]??m.activeTerminalId},b=e.terminals[n],S={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=u.tabs.slice();w[c]=y;const x=Math.max(0,Math.min(w.length,r));w.splice(x,0,S);const D=e.workspaces.slice();return D[o]={...u,tabs:w,activeTabId:S.id},{...e,workspaces:D}}function jk(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=Hk(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:db(e,t,r);const u=zi(o.tab.root),m=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Ao({...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??ks(m?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(S=>!u.includes(S)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function uB(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===r),u=Hk(e.workspaces,t);if(!c||!u||!e.terminals[n]||!zi(u.tab.root).includes(n))return e;if(u.workspace.id===r)return Bk(e,t,n,o);if(zi(u.tab.root).length===1)return jk(e,t,r,o);const g=Ll(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:zi(g)[0]??u.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}},S=e.workspaces.map(w=>{if(w.id===u.workspace.id)return Ao({...w,tabs:w.tabs.map(x=>x.id===t?p:x)});if(w.id===r){const x=w.tabs.slice(),D=Math.max(0,Math.min(x.length,o));return x.splice(D,0,b),{...w,defaultCwd:w.defaultCwd??ks(y.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(O=>O!==n),tabs:x,activeTabId:b.id}}return w});return{...e,workspaces:S,activeWorkspaceId:r}}function dB(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 hB(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 fB(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>{let m=!1;const g=u.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,m=!0,{...p,title:r}));return m?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function pB(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>Ol(c.root,t))),r=n?.tabs.find(o=>Ol(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 mB(e,t,n){const r=No(e),o=r?Lf(r):void 0;if(!r||!o)return e;const c=o_(o.root,t,Vk(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===r.id?{...u,tabs:u.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:u)}}function t_(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,m=!!(n&&n.some(b=>$k(b))||t&&t.some(b=>qk(b)));let g=yB(t,n,c,u);g.length===0&&(g=[Of()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??Af;for(const b of e)if(!u.has(b.id)){if(m)g=CB(g,y,b.id,b);else{const S=Fk(b);g=kB(g,y,S,b)}u.add(b.id)}return{workspaces:g.map(b=>Ao(xB(b,o))),activeWorkspaceId:p,terminals:o}}function Ru(e){return zi(e.root)}function i_(e){return l_(e.root)}function cf(e){return hb([...e.tabs.flatMap(t=>zi(t.root)),...e.detachedTerminalIds])}function wg(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=r_(o.root);return c?[{...o,root:c}]:[]});return Ao({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function gB(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>Ol(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function vB(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function Ik(e,t){const n={...e.terminals};return delete n[t],zk(e,t,n)}function _B(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??SB(e,t)?.id??wB(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Af,o=e.workspaces.find(c=>c.id===r);return!o||!Kk(o,t)?e:zk(e,t,{...e.terminals},{detachToWorkspaceId:r})}function zk(e,t,n,r={}){let o=e.workspaces.map(u=>{const m=[];for(const g of u.tabs){const p=Ll(g.root,t);if(!p)continue;const y=zi(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:p,activeTerminalId:b})}return Ao({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:m})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?Uk(u,t,n[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function bB(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const m=n_(u.root,t);if(!m)continue;const g=zi(m),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:m,activeTerminalId:p})}return Ao({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function yB(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)$k(c)&&o.push(N1(c,n,r));if(o.length>0)return o}return[N1({...Of(),tabs:e??[]},n,r)]}function N1(e,t,n){const r=[];for(const c of e.tabs){if(!qk(c))continue;const u=s_(c.root,t);if(!u)continue;const m=zi(u);for(const p of m)n.add(p);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&r.push({...c,root:u,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return Ao({...e,defaultCwd:ks(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function Pk(e){return No(e)?e:{...e,workspaces:[Of()],activeWorkspaceId:Af}}function No(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Lf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function Hk(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 SB(e,t){return e.workspaces.find(n=>n.tabs.some(r=>Ol(r.root,t)))}function wB(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function CB(e,t,n,r){return e.map(o=>o.id===t?Uk(o,n,r):o)}function Uk(e,t,n){return Kk(e,t)?{...e,defaultCwd:e.defaultCwd??ks(n?.cwd),detachedTerminalIds:hb([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function Kk(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Il}function Wk(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function xB(e,t){if(e.defaultCwd)return e;const n=cf(e).find(o=>!!t[o]),r=n?ks(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Of(){return{id:Af,title:ZO,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ao(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:ks(e.defaultCwd),detachedTerminalIds:hb(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function kB(e,t,n,r){const o=zi(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??ks(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function Fk(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Mu(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Mu(e.first,t,n),second:Mu(e.second,t,n)}}function Ll(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Ll(e.first,t),r=Ll(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function n_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=n_(e.first,t),r=n_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function s_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=s_(e.first,t),r=s_(e.second,t);return n&&r?{...e,ratio:Vk(e.ratio),first:n,second:r}:n??r}function r_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=r_(e.first),n=r_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function $k(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 qk(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&a_(t.root)}function a_(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")&&a_(t.first)&&a_(t.second):!1}function o_(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=o_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=o_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function Vk(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ks(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function hb(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function Ol(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Ol(e.first,t)||Ol(e.second,t)}function zi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...zi(e.first),...zi(e.second)]}function l_(e){return e.type==="pane"||e.type==="editor"?1:l_(e.first)+l_(e.second)}const Ka=new Map,Nu=new Map,Au=new Map,Lu=new Map,Ou=new Map;function Kl(e){return e??"__local__"}function TB(e){return{agentId:e,state:QO(),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 It(e){const t=Kl(e);let n=Ka.get(t);return n||(n=TB(e),Ka.set(t,n)),n}function Yk(e,t){const n=Kl(e);let r=Nu.get(n);return r||(r=new Set,Nu.set(n,r)),r.add(t),()=>{r.delete(t)}}function EB(e){const t=Kl(e),n=Nu.get(t);if(n)for(const r of Array.from(n))r()}function Wl(e,t){Ka.set(Kl(e),t),EB(e)}const c_=new Set;function DB(e){return c_.add(e),()=>{c_.delete(e)}}function _l(e,t){const n=It(e),r=Kl(e);t.type==="workspace.hydrated"&&(Au.delete(r),Lu.delete(r),Ou.delete(r));const o=JO(n.state,t);let c=n.unreadCompletions,u=null;if(t.type==="terminal.updated"){const p=n.state.terminals[t.terminal.id],y=jB(r),b=IB(r),S=MB(r);if(t.terminal.agentStatus){const w=t.terminal.agentStatus.state,x=t.terminal.agentStatus.sessionId,D=S.get(t.terminal.id),O=!!(p&&(p.currentCommand!==t.terminal.currentCommand||p.agentStatus?.provider!==t.terminal.agentStatus.provider||RB(D,x)));O&&(b.delete(t.terminal.id),y.delete(t.terminal.id),S.delete(t.terminal.id)),x&&S.set(t.terminal.id,x),t.notifyCompletion===!0&&(w==="working"?(b.add(t.terminal.id),y.delete(t.terminal.id)):w==="unknown"&&t.terminal.activity==="busy"&&y.add(t.terminal.id)),!O&&(w==="done"||w==="stopped")&&(b.has(t.terminal.id)||y.has(t.terminal.id))&&(u=O1(o,t.terminal.id,p?.currentCommand??null,w==="stopped"?"stopped":"finished"),b.delete(t.terminal.id),y.delete(t.terminal.id)),w==="idle"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}else{p?.agentStatus&&(b.delete(t.terminal.id),S.delete(t.terminal.id));const w=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&&w&&D&&y.has(t.terminal.id)&&(u=O1(o,t.terminal.id,p?.currentCommand??null,"finished")),(D||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(u){const w=Xk(o,t.terminal.id);w&&(w.workspace.activeTabId!==w.tab.id||w.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),S.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=NB(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(S=>S.id===t.workspaceId);p=b?.tabs.find(S=>S.id===b.activeTabId)??null}const y=p?zi(p.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const S of y)b.delete(S);c=b}}const m=o!==n.state,g=c!==n.unreadCompletions;if((m||g)&&Wl(e,{...n,state:o,unreadCompletions:c}),g&&fb(),u)for(const p of Array.from(c_))p({agentId:e,...u})}function RB(e,t){return e!==void 0&&t!==void 0&&e!==t}function MB(e){let t=Ou.get(e);return t||(t=new Map,Ou.set(e,t)),t}function Xk(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(zi(r.root).includes(t))return{workspace:n,tab:r};return null}function NB(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 u_=new Set;function AB(e){return u_.add(e),()=>{u_.delete(e)}}function LB(){let e=0;for(const t of Ka.values())e+=t.unreadCompletions.size;return e}function fb(){for(const e of Array.from(u_))e()}function A1(e,t){const n=It(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Wl(e,{...n,unreadCompletions:r}),fb()}function L1(e,t){const n=It(e);t!==n.state&&Wl(e,{...n,state:t})}function Cg(e,t){const n=It(e),r=t(n.editors);r!==n.editors&&Wl(e,{...n,editors:r})}function Ca(e,t,n){const r=It(e);r.loaded===t&&r.error===n||Wl(e,{...r,loaded:t,error:n})}function Vc(e,t,n){const r=It(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Wl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n})}function OB(e){const t=It(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function BB(e){const t=Kl(e),n=Ka.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1;Ka.delete(t),Nu.delete(t),Au.delete(t),Lu.delete(t),Ou.delete(t),r&&fb()}function xg(){for(const e of Ka.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Ka.clear(),Nu.clear(),Au.clear(),Lu.clear(),Ou.clear()}function jB(e){let t=Au.get(e);return t||(t=new Set,Au.set(e,t)),t}function IB(e){let t=Lu.get(e);return t||(t=new Set,Lu.set(e,t)),t}function O1(e,t,n,r){const o=Xk(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function d_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of Ru(e)){const m=t[u];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 pb(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function h_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function zB(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 PB({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:u,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:x}){const[D,O]=v.useState(null),[N,j]=v.useState(!1),[q,F]=v.useState(null),ie=v.useRef(null),Q=e.findIndex(W=>W.id===t),$=Q>=0?e[Q]:e[0]??null,Se=$?d_($,n):null,ne=$?i_($):0,De=$?h_($,n):"No tab";v.useEffect(()=>{ie.current?.focus(),ie.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!N)return;const W=le=>{le.key==="Escape"&&j(!1)};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[N]),v.useEffect(()=>{N&&e.length===0&&j(!1)},[N,e.length]);function se(W,le){O({tabId:W,title:le})}function V(){if(!D)return;const W=D.title.trim();W&&w(D.tabId,W),O(null)}function X(){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 - ${jR()}`,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 - ${IR()}`,onClick:S,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:De,onClick:()=>j(!0),disabled:e.length===0,children:[Se?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":Se.state,"aria-hidden":"true",title:pb(Se)}):null,f.jsx("span",{children:De}),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((W,le)=>{const L=Ru(W),R=i_(W),B=h_(W,n),ae=W.id===t,ye=D?.tabId===W.id,M=d_(W,n),K=r?.has(W.id)??!1;return f.jsxs(Ni.Fragment,{children:[f.jsx(B1,{index:le}),f.jsx(HB,{tab:W,active:ae,editing:ye,title:B,paneCount:R,terminalIds:L,canClose:e.length>1,editValue:ye?D.title:null,editInputRef:ye?ie:null,activity:M,unread:K,onSelect:()=>c(W.id),onBeginRename:()=>se(W.id,B),onCloseAll:()=>g(L),onCommitRename:V,onCancelRename:()=>O(null),onRenameChange:ce=>O({tabId:W.id,title:ce})})]},W.id)}),f.jsx(B1,{index:e.length}),f.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:u,children:"+"}),(o?.length??0)>0?f.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(W=>f.jsx(KB,{terminal:W,onReattach:()=>p?.(W.id),onDelete:()=>F(W)},W.id))}):null]}),f.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:u,children:"+"}),x?X():null]}),N?f.jsx(UB,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:D,editInputRef:ie,onClose:()=>j(!1),onSelectTab:W=>{c(W),j(!1)},onCreateTab:()=>{u(),j(!1)},onBeginRename:se,onCloseTerminals:W=>{g(W),j(!1)},onCommitRename:V,onCancelRename:()=>O(null),onRenameChange:(W,le)=>O({tabId:W,title:le}),onReattachTerminal:W=>{p?.(W),j(!1)},onDeleteTerminal:W=>{F(W),j(!1)}}):null,q?f.jsx(WB,{terminal:q,onCancel:()=>F(null),onConfirm:()=>{y?.(q.id),F(null)}}):null]})}function HB({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:m,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:S,onCommitRename:w,onCancelRename:x,onRenameChange:D}){const{attributes:O,listeners:N,setNodeRef:j,transform:q,isDragging:F}=mC({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),ie={transform:Mg.Translate.toString(q),opacity:F?.4:void 0,zIndex:F?2:void 0};return f.jsxs("div",{ref:j,className:"terminal-tab","data-active":t,"data-dragging":F,"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:pb(g)}):null,n&&m&&u!==null?f.jsxs("form",{className:"terminal-tab-editor",onSubmit:Q=>{Q.preventDefault(),w()},children:[f.jsx("input",{ref:m,"aria-label":`Rename ${r}`,value:u,onBlur:w,onChange:Q=>D(Q.target.value),onKeyDown:Q=>{if(Q.key==="Enter"){Q.preventDefault(),w();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(),S()},children:"x"}):null]})}function UB({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:u,onClose:m,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:S,onCancelRename:w,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:j=>j.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((j,q)=>{const F=Ru(j),ie=i_(j),Q=h_(j,n),$=j.id===t,Se=c?.tabId===j.id,ne=d_(j,n),De=r?.has(j.id)??!1;return f.jsxs("div",{ref:$?N:null,className:"mobile-tab-sheet-row","data-active":$,"data-unread":De?"true":void 0,children:[Se&&c?f.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:se=>{se.preventDefault(),S()},children:f.jsx("input",{ref:u,"aria-label":`Rename ${Q}`,value:c.title,onBlur:S,onChange:se=>x(j.id,se.target.value),onKeyDown:se=>{if(se.key==="Enter"){se.preventDefault(),S();return}se.key==="Escape"&&(se.preventDefault(),w())}})}):f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${Q}`,onClick:()=>g(j.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:q+1}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:Q}),f.jsx("small",{children:zB(j,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:pb(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:S,children:"Done"}):f.jsx("button",{type:"button","aria-label":`Rename ${Q}`,onClick:()=>y(j.id,Q),children:"Rename"}),e.length>1?f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${Q}`,onClick:()=>b(F),children:"×"}):null]})]},j.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(j=>{const q=j.title||j.cwd||j.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 ${q}`,onClick:()=>D(j.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:q}),f.jsx("small",{children:j.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 ${q}`,onClick:()=>O(j),children:"×"})})]},j.id)})]}):null]})]})})}function B1({index:e}){const{setNodeRef:t,isOver:n}=D_({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 KB({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 WB({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 FB({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return f.jsxs("aside",{className:`upload-toast upload-toast-${XB(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[f.jsxs("header",{className:"upload-toast-header",children:[f.jsx("strong",{children:e.length===1?zh(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($B,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function $B({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return f.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":zh(e),children:[f.jsxs("div",{className:"upload-queue-item-header",children:[f.jsx("strong",{children:zh(e)}),f.jsxs("div",{className:"upload-queue-actions",children:[m?f.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?f.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,f.jsx("button",{type:"button","aria-label":`Dismiss ${zh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?f.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?f.jsx(qB,{toast:e}):null,c&&"message"in e&&e.message?f.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?f.jsx(VB,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?f.jsx("p",{children:e.message}):null]})}function qB({toast:e}){const t=e.percent===null?GB(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 VB({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return 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((u,m)=>f.jsx(YB,{result:u},`${u.relativePath}-${m}`))}):null,e.results.length>c.length?f.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function YB({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 zh(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 XB(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 GB(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function ZB({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function 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:u,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 QB=su(0,0,1,1),Er=1e-6;function JB(e){return Gk(e).map(t=>t.terminalId)}function Gk(e){return nu(e,QB).sort(n4).map((t,n)=>({...t,index:n+1}))}function e4(e,t,n){const r=Gk(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>i4(o,u,n)).filter(u=>u!==null).sort(s4)[0]?.entry.terminalId??null:null}function t4(e,t){return!Number.isInteger(t)||t<1?null:JB(e)[t-1]??null}function nu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=r4(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...nu(e.first,su(t.left,t.top,o,t.bottom)),...nu(e.second,su(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...nu(e.first,su(t.left,t.top,t.right,r)),...nu(e.second,su(t.left,r,t.right,t.bottom))]}function i4(e,t,n){const r=e.bounds,o=t.bounds,c=j1(r.left,r.right,o.left,o.right),u=j1(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Er||u<=Er?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"right":return o.centerX<=r.centerX+Er||u<=Er?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"up":return o.centerY>=r.centerY-Er||c<=Er?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+Er||c<=Er?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function n4(e,t){return kl(e.bounds.top,t.bounds.top)||kl(e.bounds.left,t.bounds.left)}function s4(e,t){return kl(e.primaryDistance,t.primaryDistance)||kl(e.perpendicularDistance,t.perpendicularDistance)||kl(t.overlap,e.overlap)||kl(e.entry.index,t.entry.index)}function kl(e,t){const n=e-t;return Math.abs(n)<=Er?0:n}function j1(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function su(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function r4(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class a4 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function I1(e){return e?Array.from(e.types??[]).includes("Files")||eT(e.items).some(n=>n.kind==="file")?!0:tT(e.files).length>0:!1}async function o4(e){const t=eT(e.items).filter(n=>n.kind==="file");return t.length>0?l4(t):c4(e.files)}async function l4(e){const t=[];for(const n of e){const r=f4(n);if(r){await Zk(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Qk(o),file:o});continue}throw new a4("Folder upload is not supported by this browser.")}return t}function c4(e){return tT(e).map(t=>({relativePath:Qk(t),file:t}))}async function Zk(e,t,n){const r=m4(t,e.name);if(e.isFile){const u=await u4(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await d4(o);for(const u of c)await Zk(u,r,n)}function u4(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function d4(e){const t=[];for(;;){const n=await h4(e);if(n.length===0)return t;t.push(...n)}}function h4(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Qk(e){const t=e.webkitRelativePath;return Jk(typeof t=="string"&&t?t:e.name)}function f4(e){const t=e.webkitGetAsEntry?.();return p4(t)?t:null}function p4(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 m4(e,t){return Jk(e?`${e}/${t}`:t)}function Jk(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function eT(e){return e?Array.from(e):[]}function tT(e){return e?Array.from(e):[]}const z1="nterminal.terminalWorkspaces.v2",iT="nterminal.sidebarCollapsed.v1",g4=75,P1=_C.map(e=>e.url),v4=_C[0].url,_4=6;function b4({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??hf(),[e]),p=v.useMemo(()=>t??Dl(null),[t]),y=v.useMemo(()=>H4(n),[n]),b=v.useMemo(()=>C=>Yk(n,C),[n]),S=v.useMemo(()=>()=>It(n),[n]),w=v.useSyncExternalStore(b,S,S),x=w.state,D=w.editors,O=!w.loaded,N=w.error,[j,q]=v.useState(!1),[F,ie]=v.useState(()=>V4()),[Q,$]=v.useState("servers"),[Se,ne]=v.useState(!1),De=v.useSyncExternalStore(VR,ew,ew);v.useSyncExternalStore(uu,J0,J0);const[se,V]=v.useState(0),[X,W]=v.useState(null),[le,L]=v.useState(()=>[null]),[R,B]=v.useState(()=>({[Vi]:"Local"})),[ae,ye]=v.useState(0),[M,K]=v.useState(()=>[n]),[ce,we]=v.useState(()=>new Set),[Le,xe]=v.useState({}),[Be,Re]=v.useState(null),He=v.useRef(0),Fe=v.useRef(0),[ee,fe]=v.useState(null),[H,ue]=v.useState(null),ke=v.useRef(null),Ne=v.useRef(0),te=v.useRef(null),Ee=v.useRef(null),me=v.useRef(null),Oe=v.useRef(null),ze=v.useRef(()=>{}),[Je,rt]=v.useState(null),zt=e2(M0(uC,{activationConstraint:{distance:8}}),M0(dC,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>YR(g),[g]);function gn(C){const E=C.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){rt({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&rt({tabId:E.sourceTabId,terminalId:E.terminalId})}}function oi(C){rt(null);const E=C.active.data.current,z=C.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){ft({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){ft({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&ft({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){ft({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){ft({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&ft({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function mi(){rt(null)}const qe=x.workspaces.find(C=>C.id===x.activeWorkspaceId)??x.workspaces[0],Ct=qe?.tabs.find(C=>C.id===qe.activeTabId)??qe?.tabs[0],$t=Ct?.activeTerminalId??null,_e=$t?x.terminals[$t]:void 0,Ve=O4("(max-width: 760px)"),nt=v.useMemo(()=>Ct?uf(Ct.root):[],[Ct]),Xe=qe&&Ct?ru(n,qe.id,Ct.id):null,xt=Ct?nT(nt,Ct.activeTerminalId,Xe?Le[Xe]:void 0):null,lt=Ve&&nt.length>1,Tn=v.useMemo(()=>(qe?.detachedTerminalIds??[]).flatMap(C=>{const E=x.terminals[C];return E?[E]:[]}),[qe?.detachedTerminalIds,x.terminals]),gi=v.useMemo(()=>{const C=new Set;for(const E of qe?.tabs??[])Ru(E).some(z=>w.unreadCompletions.has(z))&&C.add(E.id);return C},[qe?.tabs,w.unreadCompletions]),[Z,Ie]=v.useState([]),it=v.useRef([]),Qe=v.useRef(null),[wt,qt]=v.useState(null),[Pt,li]=v.useState(null),[Vt,ii]=v.useState([]),[ci,Ht]=v.useState(()=>wo()),ln=v.useRef(0),Qt=v.useRef(n),Hi=v.useRef(P1),vn=v.useRef(ci),_n=v.useRef(()=>{});_n.current=un,ze.current=ir;const Jt=v.useCallback(async()=>{try{const C=await g.listNotificationAssets();ii(C.assets.filter(E=>E.enabled).map(E=>E.url))}catch{ii([])}},[g]),Qi=v.useCallback(C=>{B(E=>{const z={...E};for(const re of C)z[p_(re.agentId)]=re.label;return kg(E,z)?E:z})},[]);v.useEffect(()=>{K(C=>C.some(E=>fn(E,n))?C:[...C,n])},[n]);const ni=v.useCallback(C=>{const E=It(C),z=Dl(C);for(const re of Object.keys(E.state.terminals))tu(z.createWebSocketUrl(re)),vh(re);BB(C),K(re=>re.filter(be=>!fn(be,C))),we(re=>{const be=`${Hh(C)}:`;let he=!1;const Te=new Set;for(const Ge of re){if(Ge.startsWith(be)){he=!0;continue}Te.add(Ge)}return he?Te:re}),xe(re=>{const be=`${Hh(C)}:`;let he=!1;const Te={};for(const[Ge,gt]of Object.entries(re)){if(Ge.startsWith(be)){he=!0;continue}Te[Ge]=gt}return he?Te:re})},[]);v.useEffect(()=>{let C=!1;return g.getMainInfo().then(E=>{if(C)return;const z=E.name?.trim()||"Local";B(re=>{const be={...re,[Vi]:z};return kg(re,be)?re:be})}).catch(()=>{}),g.listAgents().then(E=>{if(!C){const z=E.agents.map(be=>be.id),re=uR(E.serverOrder,E.agents);B(be=>{const he={[Vi]:be[Vi]??"Local"};for(const Te of E.agents)he[Te.id]=Te.name;return kg(be,he)?be:he}),n!==null&&!z.includes(n)&&(ni(n),r?.(null)),L(re)}}).catch(()=>{}),()=>{C=!0}},[n,g,ni,r,ae]);const vi=v.useCallback(C=>{ni(C),ye(E=>E+1),fn(C,Qt.current)&&r?.(null)},[ni,r]);v.useEffect(()=>{L(C=>C.some(E=>fn(E,n))?C:[...C,n])},[n]),v.useEffect(()=>{Qt.current=n},[n]),v.useEffect(()=>{W(null)},[n]),v.useEffect(()=>{const C=te.current;if(!C)return;if(!fn(C.agentId,n)){te.current=null;return}if(!w.loaded||x.workspaces.length===0)return;te.current=null;const E=C.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];E&&E.id!==x.activeWorkspaceId&&ft({type:"workspace.selected",workspaceId:E.id})},[n,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const C=Ee.current;if(C){if(!fn(C.agentId,n)){Ee.current=null;return}w.loaded&&(Ee.current=null,x.workspaces.some(E=>E.id===C.workspaceId)&&ft({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,w.loaded,x.workspaces]),v.useEffect(()=>{const C=me.current;if(C){if(!fn(C.agentId,n)){me.current=null;return}w.loaded&&(me.current=null,w.error||Lo())}},[n,w.error,w.loaded]),v.useEffect(()=>{yn()},[n,w.loaded,x]),v.useEffect(()=>{const C=()=>{const re=j4();re&&ze.current(re)},E=re=>{const be=I4(re.data);be&&ze.current(be)},z=re=>{const be=_f(re.detail);be&&ze.current(be)};return C(),window.addEventListener("hashchange",C),window.addEventListener(jg,z),navigator.serviceWorker?.addEventListener?.("message",E),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(jg,z),navigator.serviceWorker?.removeEventListener?.("message",E)}},[]),v.useEffect(()=>{Jt()},[Jt]),v.useEffect(()=>DC(()=>Ht(wo())),[]),v.useEffect(()=>{const C=E=>{_n.current(E)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{Hi.current=Vt.length>0?Vt:P1},[Vt]),v.useEffect(()=>{vn.current=ci},[ci]),v.useEffect(()=>{if(!w.loaded||!qe||!Ct)return;const C=ru(n,qe.id,Ct.id);we(E=>{if(E.has(C))return E;const z=new Set(E);return z.add(C),z})},[n,w.loaded,qe?.id,Ct?.id]),v.useEffect(()=>()=>{As()},[]),v.useEffect(()=>{const C=tR(g),E=sR(g);return()=>{C(),E()}},[g]),v.useEffect(()=>DB(C=>{const E=It(C.agentId).state,z=E.workspaces.flatMap(Te=>Te.tabs).find(Te=>Te.id===C.tabId),re=E.terminals[C.terminalId],be=z?.title?.trim()||re?.title||C.commandName||"terminal",he=document.visibilityState==="visible"&&fn(C.agentId,Qt.current)&&C.tabId===P4(E);if(he||XD({agentId:C.agentId,tabTitle:be,commandName:C.commandName,terminalId:C.terminalId,outcome:C.outcome}),!he&&document.visibilityState==="visible"&&vn.current.enabled){const Te=ln.current+1;ln.current=Te;const Ge=Hi.current;qt({id:Te,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:be,commandName:C.commandName,outcome:C.outcome,assetSrc:Ge[Math.floor(Math.random()*Ge.length)]??v4})}}),[]),v.useEffect(()=>{if(!wt||ci.persistUntilDismissed)return;const C=window.setTimeout(()=>{qt(E=>E?.id===wt.id?null:E)},ci.durationSeconds*1e3);return()=>window.clearTimeout(C)},[wt,ci]),v.useEffect(()=>{Y4(F),F&&Bn()},[F]),v.useEffect(()=>{let C=!1;async function E(){if(!It(n).loaded){Ca(n,!1,null);try{let re=null,be=null;try{re=U4(y)}catch(gt){if(!(gt instanceof df))throw gt;be=gt}const[he,Te]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Ge=he.terminals.length>0?he.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!C){const gt=Te.layout?rT(Te.layout):null;if(!gt&&be)throw be;const ki=gt??re??{},Yt=t_(Ge,void 0,ki.savedWorkspaces,ki.savedActiveWorkspaceId),Vr=wg(Yt);L1(n,Yt),Vc(n,Te.revision,JSON.stringify(Vr)),Ca(n,!0,null),!gt&&re&&nr(Vr,{baseRevision:Te.revision})}}catch(re){!C&&!Li(re)&&Ca(n,!0,xa(re))}}}return E(),()=>{C=!0}},[n,p,se]);function _i(){Ca(n,!1,null),V(C=>C+1)}function Bn(){He.current+=1,Fe.current+=1,Re(null)}function Ir(C){He.current+=1,Fe.current+=1,Re(E=>E&&{...E,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Lo(){He.current+=1,Fe.current+=1;const C=x.workspaces.length+1,E=ds();Re({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Zs(E)}function zr(C){if(fn(C,n)){Lo();return}me.current={agentId:C},r?.(C)}function Gs(C){if(F&&!j)return;const E=x.workspaces.find(re=>re.id===C);if(!E)return;He.current+=1,Fe.current+=1;const z=E.defaultCwd??_e?.cwd??"";Re({mode:"edit",workspaceId:C,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Zs(z)}function ds(){return qe?.defaultCwd??_e?.cwd??""}async function Zs(C){const E=He.current+1;He.current=E;const z=C.trim();if(Re(re=>re&&{...re,cwd:C,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const re=await p.createFileRoot({path:z}),be=await p.listFiles({rootToken:re.rootToken,path:""});if(He.current!==E)return;Re(he=>he&&{...he,cwd:re.rootPath,browseRoot:{rootToken:re.rootToken,rootPath:re.rootPath},browseEntries:be.entries.filter(Te=>Te.kind==="directory"),browseStatus:"idle",error:null})}catch(re){if(He.current!==E)return;Re(be=>be&&{...be,browseStatus:"idle",error:xa(re)})}}async function hs(){const C=Be;if(!C)return;const E=C.title.trim(),z=C.cwd.trim();if(!E||!z){Re({...C,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const re=Fe.current+1;Fe.current=re,Re({...C,submitStatus:"submitting",error:null});try{const be=await p.createFileRoot({path:z});if(Fe.current!==re)return;if(C.mode==="create"){const he=x.workspaces.length+1;ft({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${he}`,title:E,defaultCwd:be.rootPath})}else C.workspaceId&&(ft({type:"workspace.renamed",workspaceId:C.workspaceId,title:E}),ft({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:be.rootPath}));Re(null)}catch(be){if(Fe.current!==re)return;Re(he=>he&&{...he,submitStatus:"idle",error:xa(be)})}}function Ts(C){Fe.current+=1,Re(C)}function fs(C,E,z){if(C===E)return;const re=x.workspaces.some(he=>he.id===C),be=x.workspaces.some(he=>he.id===E);!re||!be||ft({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:E,placement:z})}function Es(C,E){const z=x.workspaces.findIndex(be=>be.id===C),re=x.workspaces[z+E];z<0||!re||fs(C,re.id,E<0?"before":"after")}function At(C,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),ke.current={sourceId:C,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function Oo(C){const E=ke.current;if(!E||E.pointerId!==C.pointerId)return;const z=Math.hypot(C.clientX-E.startX,C.clientY-E.startY);if(!E.active){if(z<_4)return;E.active=!0,fe(E.sourceId)}const be=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),he=be?.dataset.workspaceId??null;if(!be||!he||he===E.sourceId||!x.workspaces.some(gt=>gt.id===he)){E.targetId=null,ue(null);return}const Te=be.getBoundingClientRect(),Ge=C.clientY<Te.top+Te.height/2?"before":"after";E.targetId=he,E.placement=Ge,ue({workspaceId:he,placement:Ge})}function Pr(C){const E=ke.current;!E||E.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),ke.current=null,fe(null),ue(null),E.active&&E.targetId&&fs(E.sourceId,E.targetId,E.placement))}function Ut(C){const E=ke.current;E&&E.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),ke.current=null,fe(null),ue(null)}async function jn(){await Rs(async()=>{const C=qe?.defaultCwd?{cols:80,rows:24,cwd:qe.defaultCwd}:{cols:80,rows:24},E=await p.createTerminal(C);ft({type:"terminal.created",terminal:E.terminal})})}async function Ji(C){await Rs(async()=>{const E=$t?{parentTerminalId:$t,cols:80,rows:24}:qe?.defaultCwd?{cols:80,rows:24,cwd:qe.defaultCwd}:{cols:80,rows:24},z=await p.createTerminal(E);ft({type:"terminal.split",terminal:z.terminal,direction:C})})}async function Hr(C){let E=$t,z=Xe;const re=qe?.defaultCwd?.trim();if(!E&&!re)throw new Error("No active pane is available.");const be=await p.readFile(C);if(!E&&re){const Ge=await p.createTerminal({cols:80,rows:24,cwd:re});E=Ge.terminal.id,ft({type:"terminal.created",terminal:Ge.terminal})}if(E){ft({type:"pane.selected",terminalId:E});const Ge=It(n).state,gt=Ge.workspaces.find(Yt=>Yt.id===Ge.activeWorkspaceId)??Ge.workspaces[0],ki=gt?.tabs.find(Yt=>Yt.id===gt.activeTabId)??gt?.tabs[0];z=gt&&ki?ru(n,gt.id,ki.id):null}const he=`editor-${Date.now().toString(36)}-${OB(n)}`,Te=q4(be.path);Cg(n,Ge=>({...Ge,[he]:{id:he,title:Te,rootToken:C.rootToken,path:be.path,read:be}})),z&&xe(Ge=>({...Ge,[z]:sT(he)})),ft({type:"editor.split",editorId:he,title:Te,direction:"vertical"})}function Bo(C){Cg(n,E=>{const z={...E};return delete z[C],z}),ft({type:"editor.closed",editorId:C})}function Qs(C){ps([C])}function ps(C){const E=[...new Set(C)].filter(re=>x.terminals[re]);if(E.length===0)return;const z=E.length===1?x.terminals[E[0]]?.title||x.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;W(null),li({terminalIds:E,label:z,workspaceId:qe?.id??x.activeWorkspaceId??null})}function Ur(C,E){const z=Fr(C,E);if(!z)return!1;const re=C.filter(be=>!z.detachedTerminalIds.includes(be));if(z.detachedTerminalIds.length+re.length>Il)return W(W4(z.detachedTerminalIds.length)),!1;W(null);for(const be of C)ft(z.id?{type:"terminal.detached",terminalId:be,workspaceId:z.id}:{type:"terminal.detached",terminalId:be});return!0}async function bn(C){await Rs(async()=>{for(const E of C)await Ki(E),tu(p.createWebSocketUrl(E)),vh(E),ft({type:"terminal.closed",terminalId:E})})}async function Ui(C){const E=x.workspaces.find(z=>z.id===C);!E||x.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Rs(async()=>{const z=cf(E),re=[];let be=null;for(const Te of z)try{await Ki(Te)}catch(Ge){re.push(xa(Ge)),Ge instanceof Ln&&Ge.status===401&&!p.isAgent&&(be=Ge)}finally{tu(p.createWebSocketUrl(Te)),vh(Te)}const he=E.tabs.flatMap(Te=>f_(Te.root));if(he.length>0){const Te=new Set(he);Cg(n,Ge=>{const gt={...Ge};for(const ki of Te)delete gt[ki];return gt})}if(ft({type:"workspace.closed",workspaceId:C}),be)throw be;if(re.length>0)throw new Error(`Workspace was removed, but ${re.length} terminal session${re.length===1?"":"s"} may still be running. ${re[0]}`)})}async function Ds(C){await Rs(async()=>{await Ki(C),tu(p.createWebSocketUrl(C)),vh(C),ft({type:"terminal.closed",terminalId:C})})}async function Fa(C,E){const z=E.trim();if(!z)return;let re=null;for(const be of x.workspaces){const he=be.tabs.find(Te=>Te.id===C);if(he){re=he.activeTerminalId;break}}if(ft({type:"tab.renamed",tabId:C,title:z}),!!re)try{const be=await p.renameTerminal(re,z);vs({type:"terminal.updated",terminal:be.terminal})}catch(be){Ca(n,!0,xa(be))}}function ms(C){const E=x.terminals[C];E&&ft({type:"terminal.created",terminal:E})}async function Ki(C){try{await p.closeTerminal(C)}catch(E){if(E instanceof Ln&&E.status===404)return;throw E}}async function gs(){await Rs(async()=>{await u()})}async function Rs(C){Ca(n,!0,null);try{await C()}catch(E){if(Li(E))return;Ca(n,!0,xa(E))}}function Li(C){return C instanceof Ln&&C.status===401&&!p.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function ft(C){_l(n,C);const E=It(n),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const re=wg(z);JSON.stringify(re)!==E.lastPersistedLayoutJson&&Ns(re)}function vs(C){_l(n,C)}function Js(C,E,z,re){const be=ru(C,E,z);xe(he=>({...he,[be]:re}))}function cn(C){Xe&&xe(E=>({...E,[Xe]:C}))}function Kr(C,E){const z=gu(C);E?Js(n,E.workspaceId,E.tabId,z):cn(z),ft({type:"pane.selected",terminalId:C})}function $a(C){cn(C.key),C.type==="terminal"&&ft({type:"pane.selected",terminalId:C.terminalId})}function un(C){if(Se||Pt||C.isComposing||C.key==="Process"||k4(C.target))return;const E=S4(C);if(!E)return;if(C.preventDefault(),C.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){Wr(E.type==="server.next"?1:-1);return}const z=It(n).state,re=z.workspaces.find(Te=>Te.id===z.activeWorkspaceId)??z.workspaces[0],be=re?.tabs.find(Te=>Te.id===re.activeTabId)??re?.tabs[0];if(E.type==="split"){if(!be)return;Ji(E.direction);return}if(!re||!be)return;if(E.type==="tab.previous"||E.type==="tab.next"){const Te=x4(re.tabs,be.id,E.type==="tab.next"?1:-1);Te&&ft({type:"tab.selected",tabId:Te.id});return}if(E.type==="tab.index"){const Te=re.tabs[E.index-1];Te&&ft({type:"tab.selected",tabId:Te.id});return}const he=w4(be.root,be.activeTerminalId,E);he&&Kr(he,{workspaceId:re.id,tabId:be.id})}function jo(C,E){if(!r||le.length===0)return;const z=le.findIndex(Te=>fn(Te,n)),be=((z===-1?0:z)+C+le.length)%le.length,he=le[be]??null;fn(he,n)||(E&&(te.current={agentId:he,edge:E}),r(he))}function Wr(C){const E=It(n).state,z=E.workspaces;if(z.length===0){jo(C,C===1?"first":"last");return}const re=z.findIndex(Te=>Te.id===E.activeWorkspaceId),he=(re===-1?0:re)+C;if(he>=0&&he<z.length){ft({type:"workspace.selected",workspaceId:z[he].id});return}jo(C,C===1?"first":"last")}function er(C,E){if(fn(C,n)){ft({type:"workspace.selected",workspaceId:E});return}Ee.current={agentId:C,workspaceId:E},r?.(C)}function Fr(C,E){if(E)return x.workspaces.find(z=>z.id===E)??null;for(const z of C){const re=x.workspaces.find(he=>he.tabs.some(Te=>Ru(Te).includes(z)));if(re)return re;const be=x.workspaces.find(he=>he.detachedTerminalIds.includes(z));if(be)return be}return x.workspaces.find(z=>z.id===x.activeWorkspaceId)??x.workspaces[0]??null}function Io(C){I1(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function Fl(C){if(!I1(C.dataTransfer))return;C.preventDefault();const E=F4(It(n).state),z=Ne.current+1;if(Ne.current=z,!E){$r({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}$r({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),_s(z,E.id,C.dataTransfer)}async function _s(C,E,z){try{const re=await o4(z);if(re.length===0)throw new Error("No files were found in the drop.");Wi(C,{id:C,status:"queued",fileCount:re.length,message:"Queued"},{terminalId:E,files:re})}catch(re){Wi(C,{id:C,status:"failed",fileCount:0,message:xa(re)},{terminalId:E})}finally{bi()}}async function Yn(C){const E=it.current.find(he=>he.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,re=E.files,be=new AbortController;Qe.current=C,Wi(C,{id:C,status:"uploading",fileCount:re.length,loaded:0,total:null,percent:null},{terminalId:z,files:re,abortController:be});try{const he=await oM({terminalId:z,files:re,signal:be.signal,onProgress:ki=>{Wi(C,{id:C,status:"uploading",fileCount:re.length,loaded:ki.loaded,total:ki.total,percent:ki.percent},{terminalId:z,files:re,abortController:be})}}),Te=he.failed>0?he.uploaded>0?"partial":"failed":"success",Ge=he.failed>0?$4(he):void 0,gt={id:C,status:Te,fileCount:re.length,response:he};Ge&&(gt.message=Ge),Wi(C,gt,{terminalId:z,files:re})}catch(he){Wi(C,{id:C,status:"failed",fileCount:re.length,message:be.signal.aborted?"Upload canceled.":xa(he)},{terminalId:z,files:re})}finally{Qe.current===C&&(Qe.current=null),bi()}}function bi(){if(Qe.current!==null)return;const C=it.current.find(E=>E.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&Yn(C.id)}function $r(C){si(E=>[...E,C])}function Wi(C,E,z={}){si(re=>re.map(be=>{if(be.id!==C)return be;const he={...E},Te=z.terminalId??be.terminalId,Ge=z.files??be.files;return Te!==void 0&&(he.terminalId=Te),Ge!==void 0&&(he.files=Ge),z.abortController!==void 0&&(he.abortController=z.abortController),he}))}function si(C){const E=C(it.current);it.current=E,Ie(E)}function Ms(C){it.current.find(z=>z.id===C)?.abortController?.abort(),Qe.current===C&&(Qe.current=null),si(z=>z.filter(re=>re.id!==C)),bi()}function tr(){for(const C of it.current)C.abortController?.abort();Qe.current=null,si(()=>[])}function qa(C){const E=it.current.find(z=>z.id===C);if(E){if(E.status==="queued"){Ms(C);return}E.abortController?.abort()}}function In(C){const E=it.current.find(re=>re.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=yi(E);if(z.length===0){Wi(C,{id:C,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}Wi(C,{id:C,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),bi()}function yi(C){const E=C.files??[],z="response"in C?C.response:void 0;if(!z)return E;const re=z.results.filter(Te=>Te.status==="failed").map(Te=>Te.relativePath);if(re.length===0)return[];const be=new Map;for(const Te of E){const Ge=be.get(Te.relativePath)??[];Ge.push(Te),be.set(Te.relativePath,Ge)}const he=[];for(const Te of re){const gt=be.get(Te)?.shift();gt&&he.push(gt)}return he}function qr(C){const z=It(C.agentId).state.workspaces.find(re=>re.tabs.some(be=>be.id===C.tabId));z&&Js(C.agentId,z.id,C.tabId,gu(C.terminalId)),_l(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),A1(C.agentId,C.terminalId),fn(C.agentId,n)||r?.(C.agentId),qt(null)}function ir(C){if(Oe.current=C,!fn(C.agentId,n)){r?r(C.agentId):Oe.current=null;return}yn()}function yn(){const C=Oe.current;if(!C||!fn(C.agentId,n)||!w.loaded)return;const E=It(C.agentId),z=z4(E.state,C.terminalId);Oe.current=null,z&&(Js(C.agentId,z.workspaceId,z.tabId,gu(C.terminalId)),_l(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),A1(C.agentId,C.terminalId))}function Ns(C){const E=It(n).mutable.saveCoord;E.pendingLayoutSave=C,Yc(C,y),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&nr(z)},g4)}function As(){const C=It(n).mutable.saveCoord;C.saveTimer!==null&&(window.clearTimeout(C.saveTimer),C.saveTimer=null);const E=C.pendingLayoutSave;C.pendingLayoutSave=null,E&&(Yc(E,y),nr(E))}function nr(C,E={}){const z=It(n).mutable.saveCoord;z.nextPersistLayout=C,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const re=z.nextPersistLayout,be=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,re&&await sr(re,be!==void 0?{baseRevision:be}:{})}))}async function sr(C,E={}){const z=It(n),re=E.baseRevision??z.layoutRevision,be={layout:C,...typeof re=="number"?{baseRevision:re}:{}};try{const he=await p.saveTerminalLayout(be),Te=he.layout??C;Vc(n,he.revision,JSON.stringify(Te)),Yc(Te,y);return}catch(he){if(he instanceof Ln&&he.status===400&&he.message===oD){K4(n,y),Ca(n,!0,aT());return}if(he instanceof Ln&&he.status===409)try{const Te=await p.getTerminalLayout(),Ge=It(n).mutable.saveCoord;if(Ge.nextPersistLayout||Ge.pendingLayoutSave){const gt=Te.layout?JSON.stringify(Te.layout):It(n).lastPersistedLayoutJson;Vc(n,Te.revision,gt);return}if(Te.layout){const gt=It(n).state,ki=t_(Object.values(gt.terminals),void 0,Te.layout.workspaces,Te.layout.activeWorkspaceId),Yt=wg(ki);L1(n,ki),Vc(n,Te.revision,JSON.stringify(Yt)),Yc(Yt,y)}else Vc(n,Te.revision,z.lastPersistedLayoutJson);return}catch{}Yc(C,y)}}const Ls=X4(o),dn=!F||j,xi=dn?Q:"servers";function Xn(C){const E=C.active?w:It(C.agentId),z=C.active?x:E.state,re=C.active?w.loaded:E.loaded,be=C.active?N:E.error;return f.jsxs("div",{className:`workspace-list-panel${C.active?" workspace-list-panel--active-server":""}`,"aria-label":`${C.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 ${C.label}`,title:"New workspace",onClick:()=>zr(C.agentId),children:"+"})]}),re?be?f.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(C.agentId),children:be}):f.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(he=>{const Te=C.active&&he.id===qe?.id,Ge=cf(he).length,gt=C.active&&z.workspaces.length>1,ki=H?.workspaceId===he.id&&ee!==he.id?H.placement:null;return f.jsxs(M4,{workspaceId:he.id,active:Te,disabled:!C.active,reorderable:gt,dragging:ee===he.id,dropPlacement:ki,children:[gt?f.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":he.id,title:"Drag to reorder","aria-label":`Reorder ${he.title}`,"aria-grabbed":ee===he.id,onPointerDown:Yt=>At(he.id,Yt),onPointerMove:Oo,onPointerUp:Pr,onPointerCancel:Ut,onKeyDown:Yt=>{(Yt.key==="ArrowUp"||Yt.key==="ArrowDown")&&(Yt.preventDefault(),Yt.stopPropagation(),Es(he.id,Yt.key==="ArrowUp"?-1:1))},onClick:Yt=>Yt.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Te?"page":void 0,title:he.defaultCwd??void 0,onClick:()=>er(C.agentId,he.id),onDoubleClick:()=>{C.active&&Gs(he.id)},children:[f.jsx("span",{className:"workspace-list-name",children:he.title}),f.jsxs("small",{children:[he.defaultCwd??"No folder"," · ",Ge," ",Ge===1?"session":"sessions"]})]}),C.active?f.jsxs("div",{className:"workspace-list-actions",children:[f.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${he.title}`,title:"Edit workspace",onClick:()=>Gs(he.id),children:"..."}),f.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${he.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Ui(he.id)},children:"x"})]}):null]},he.id)})}):f.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(C.agentId),children:"Open server to load workspaces"})]})}return f.jsx(eD,{sensors:zt,onDragStart:gn,onDragEnd:oi,onDragCancel:mi,children:f.jsxs("main",{className:"terminal-shell","data-collapsed":F,"data-sidebar-open":j,onDragOver:Io,onDrop:Fl,children:[f.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>q(!1)}),f.jsxs("aside",{className:"workspace-sidebar",children:[f.jsxs("header",{className:"workspace-brand",children:[f.jsxs("div",{className:"workspace-brand-lockup",children:[dn?f.jsx(X1,{height:20}):f.jsx(Y1,{size:24}),c&&dn?f.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),f.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":F?"Expand sidebar":"Collapse sidebar",title:F?"Expand sidebar":"Collapse sidebar",onClick:()=>ie(C=>!C),children:F?">":"<"}),f.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>q(!1),children:"x"})]}),f.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${xi==="files"?"files":"servers"}`,children:[dn?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,xi==="servers"&&dn?f.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:f.jsx(Q0,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Qi,renderServerChildren:Xn})}):null,dn?null:f.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:f.jsx(Q0,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Qi,compact:!0})}),xi==="files"?f.jsx(hM,{api:p,activeTerminalId:$t,activeTerminalCwd:_e?.cwd??null,workspaceRootPath:$t?null:qe?.defaultCwd??null,onOpenFile:Hr},`${n??"local"}:${qe?.id??"no-workspace"}`):null]}),f.jsxs("div",{className:"workspace-sidebar-footer",children:[dn?f.jsx("span",{children:Ls}):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(U1,{name:"settings"}),De.hasUpdates?f.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),dn?f.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{gs()},children:f.jsx(U1,{name:"logout"})}):null]})]})]}),Se?f.jsx(sM,{api:g,onClose:()=>ne(!1),updateAvailable:De.hasUpdates,onNotificationAssetsChanged:()=>{Jt()},onAgentRemoved:vi}):null,Be?f.jsx(T4,{dialog:Be,activePaneCwd:_e?.cwd??null,activeWorkspaceCwd:qe?.defaultCwd??null,onChange:Ts,onManualCwdChange:Ir,onBrowse:Zs,onCancel:Bn,onSubmit:()=>{hs()}}):null,f.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":lt?"true":void 0,children:[f.jsx(PB,{tabs:qe?.tabs??[],activeTabId:qe?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:gi,detachedTerminals:Tn,onSelectTab:C=>ft({type:"tab.selected",tabId:C}),onCreateTab:()=>{jn()},onToggleWorkspaces:()=>q(C=>!C),onCloseTerminals:C=>ps(C),onReattachTerminal:C=>ms(C),onDeleteTerminal:C=>{Ds(C)},onSplitVertical:()=>{Ji("vertical")},onSplitHorizontal:()=>{Ji("horizontal")},onRenameTab:(C,E)=>{Fa(C,E)},activePaneAvailable:!!$t}),lt?f.jsx(A4,{targets:nt,activeLeafKey:xt,terminals:x.terminals,editors:D,onSelect:$a}):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:_i,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&&!Ct?f.jsx(R4,{onCreate:()=>{jn()}}):null,M.map(C=>{const E=fn(C,n);return f.jsx(y4,{agentId:C,serverName:R[p_(C)]??(C===null?"Local":"Server"),active:E,activeServerApi:E?p:void 0,visitedTabKeys:ce,refreshCwdOnEnter:E,draggingTab:E?Je:null,mobileSplitFocus:Ve,mobileFocusedLeafByTabKey:Le,onSelect:z=>{E&&Kr(z)},onClose:z=>{E&&Qs(z)},onCloseEditor:z=>{E&&Bo(z)},onResize:(z,re)=>{E&&ft({type:"pane.resized",path:z,ratio:re})},onExit:(z,re)=>{E?vs({type:"terminal.exited",terminalId:z,exitCode:re}):_l(C,{type:"terminal.exited",terminalId:z,exitCode:re})},onSnapshot:(z,re)=>{const be={type:"terminal.updated",terminal:z,notifyCompletion:re?.notifyCompletion===!0};E?vs(be):_l(C,be)},...m?{onAuthClose:z=>m({...z,source:z?.source??"terminal-ws-1008",activeAgentId:C})}:{}},Hh(C))})]}),Pt?f.jsx(N4,{label:Pt.label,count:Pt.terminalIds.length,warning:X,onCancel:()=>{W(null),li(null)},onHide:()=>{Ur(Pt.terminalIds,Pt.workspaceId)&&li(null)},onDelete:()=>{const C=Pt.terminalIds;W(null),li(null),bn(C)}}):null,f.jsx(ZB,{toast:wt,onActivate:qr,onDismiss:()=>qt(null)}),f.jsx(FB,{uploads:Z,onDismiss:Ms,onDismissAll:tr,onRetry:In,onCancel:qa})]})]})})}function y4({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:y,onCloseEditor:b,onResize:S,onExit:w,onSnapshot:x,onAuthClose:D}){const O=v.useMemo(()=>De=>Yk(e,De),[e]),N=v.useMemo(()=>()=>It(e),[e]),j=v.useSyncExternalStore(O,N,N),q=v.useMemo(()=>Dl(e),[e]),F=r??q,ie=j.state,Q=ie.workspaces.find(De=>De.id===ie.activeWorkspaceId)??ie.workspaces[0],$=Q?.id??null,ne=(Q?.tabs.find(De=>De.id===Q.activeTabId)??Q?.tabs[0])?.id??null;return!j.loaded||ie.workspaces.length===0?null:f.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:ie.workspaces.flatMap(De=>De.tabs.map(se=>{const V=n&&De.id===$&&se.id===ne,X=ru(e,De.id,se.id),W=uf(se.root),le=m&&W.length>1?nT(W,se.activeTerminalId,g[X]):null;return!V&&!o.has(X)?null:f.jsx("div",{className:"workspace-tab-surface","data-active":V,"aria-hidden":!V,children:f.jsx(Qv,{node:se.root,terminals:ie.terminals,editors:j.editors,api:F,activeTerminalId:se.activeTerminalId,visible:V,refreshCwdOnEnter:V&&c,tabId:se.id,codeServerContext:{serverKey:p_(e),serverName:t,tabName:se.title||ie.terminals[se.activeTerminalId]?.title||"Terminal"},dropZoneActive:V&&u!==null,draggingTerminalId:V?u?.terminalId??null:null,mobileFocusLeafKey:le,onSelect:p,onClose:y,onCloseEditor:b,onResize:S,onExit:w,onSnapshot:x,...D?{onAuthClose:D}:{}})},se.id)}))})}function S4(e){const t=qC(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=C4(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function w4(e,t,n){switch(n.type){case"pane.direction":return e4(e,t,n.direction);case"pane.index":return t4(e,n.index);default:return null}}function C4(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function x4(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function uf(e){return e.type==="pane"?[{key:gu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:sT(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...uf(e.first),...uf(e.second)]}function f_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...f_(e.first),...f_(e.second)]}function nT(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?gu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function gu(e){return`terminal:${e}`}function sT(e){return`editor:${e}`}function k4(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 T4({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(w=>w.kind==="directory"),y=e.submitStatus==="submitting";function b(w){r(x=>x&&{...x,...w})}function S(w){w&&(b({cwd:w,error:null}),c(w))}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:f.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.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:u,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:w=>b({title:w.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:w=>o(w.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:()=>S(t),disabled:y||!t,children:"Use active pane"}),f.jsx("button",{type:"button",onClick:()=>S(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(D4(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(w=>f.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:y,onClick:()=>{c(E4(g,w.path))},children:[f.jsx("span",{children:w.name}),f.jsx("small",{children:w.path})]},w.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:u,children:"Cancel"}),f.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function E4(e,t){return t?t.startsWith("/")?Ph(t):Ph(`${e||"/"}/${t}`):Ph(e)}function D4(e){const t=Ph(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Ph(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function R4({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 M4({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:u}){const{setNodeRef:m,isOver:g}=D_({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:u})}function N4({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:u=>u.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 A4({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(S=>S.key===t):-1,g=m>=0?m:0,p=e[g]??e[0],y=H1(p,n,r);function b(S){const w=(g+S+e.length)%e.length,x=e[w];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:()=>u(!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:()=>u(!1),children:f.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[f.jsxs("header",{children:[f.jsx("strong",{children:"Panes"}),f.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),f.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const x=H1(S,n,r),D=L4(S,n,r),O=S.key===p.key;return f.jsxs("button",{type:"button","data-active":O,onClick:()=>{o(S),u(!1)},children:[f.jsx("span",{className:"mobile-pane-sheet-index",children:w+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:S.type})]},S.key)})})]})}):null]})}function H1(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 L4(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 O4(e){const[t,n]=v.useState(()=>B4(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 B4(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function j4(){if(typeof window>"u")return null;const e=_D(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 I4(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:_f(t.focus)}function z4(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(zi(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function fn(e,t){return e===t}function P4(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 Hh(e){return e??"__local__"}function ru(e,t,n){return`${Hh(e)}:${t}:${n}`}class df extends Error{constructor(){super(aT())}}function H4(e){return e?{workspaceKey:`${z1}:${e}`}:{workspaceKey:z1}}function U4(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(vC(n))throw new df;const r=gC(n);return r?rT(r):null}catch(n){if(n instanceof df)throw n;return null}}function rT(e){if(vC(e))throw new df;const t=gC(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Yc(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function K4(e,t){const n=It(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function W4(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Il}. Re-open or delete hidden sessions before hiding more.`}function aT(){return`A saved terminal layout has more than ${Il} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function F4(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 $4(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function q4(e){return e.split("/").filter(Boolean).pop()??e}function V4(){try{return localStorage.getItem(iT)==="true"}catch{return!1}}function Y4(e){try{localStorage.setItem(iT,e?"true":"false")}catch{}}function p_(e){return e??Vi}function kg(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function X4(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 U1({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 xa(e){return e instanceof Error?e.message:"Request failed"}function G4({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(O=>{D||(r(O.qrDataUrl),c(O.secret))}).catch(O=>{D||w(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:u}),t()}catch(O){b(O instanceof Error?O.message:"Verification failed")}finally{p(!1)}}}return S?f.jsx("p",{className:"form-error",children:S}):!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:u,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||u.length!==6,children:"Activate 2FA"})]})]})}function Z4(e){return{source:Tg(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Tg(e.terminalId)}:{},...e?.detail?{detail:Tg(e.detail)}:{}}}function Q4(e){return{invalidationSource:e.source}}function J4(e){mn("auth.session_invalid.request",oT(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),M_("session-invalid-request").catch(()=>{}))}function e6(e,t){mn("auth.session_invalid.result",{...oT(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),M_("session-invalid-result").catch(()=>{}))}function oT(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 Tg(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function t6({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??hf(),[e]),c=v.useMemo(()=>t??Dl(null),[t]),[u,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(j=>{N||(m(j),p(null))}).catch(j=>{N||(p(So(j)),m(null))}),()=>{N=!0}},[o]);const S=r6(u);v.useEffect(()=>{const N=b.current;mn("auth.view",{view:S,previousView:N,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),N==="workspace"&&S!=="workspace"&&M_(`auth-left-workspace-${S}`).catch(()=>{}),b.current=S},[u,S]);async function w(){const N=await o.getSession();m(N),p(null)}async function x(){mg(),xg(),r1(),p(null),m(null);try{await w()}catch(N){p(So(N))}}function D(N){const j=Z4(N);if(J4(j),y.current)return y.current;const q=(async()=>{p(null);try{const F=await o.getSession(Q4(j));if(e6(j,F.authenticated),m(F),F.authenticated){f5();return}mg(),xg(),r1()}catch(F){p(So(F))}finally{y.current=null}})();return y.current=q,q}if(S==="workspace")return f.jsx(b4,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:N=>{D(N)},onLogout:async()=>{mg(),xg();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":S==="loading",children:[f.jsxs("header",{className:"auth-header",children:[f.jsxs("div",{className:"auth-brand",children:[f.jsx(Y1,{size:26}),f.jsxs("div",{children:[f.jsx(X1,{height:17}),f.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),f.jsx("h1",{children:O[S]})]}),g?f.jsx("p",{className:"form-error",children:g}):null,S==="loading"?f.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,S==="setup_password"?f.jsx(i6,{api:o,onSession:N=>{m(N)}}):null,S==="setup_totp"?f.jsx(G4,{api:o,onDone:()=>{w()}}):null,S==="login"?f.jsx(n6,{api:o,session:u,onSession:m,onRefresh:w}):null,S==="reauth"?f.jsx(s6,{api:o,session:u,onSession:m,onFullLogin:()=>m(N=>N&&{...N,deviceTrusted:!1})}):null]})]})}function i6({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,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(S){p(So(S))}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:u||n.length<8||o.length<8,children:"Set password"})]})}function n6({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[S,w]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function O(N){N.preventDefault(),b(!0),w(null);try{n(await e.login({password:o,...x?{otp:u}:{},rememberNetwork:g}))}catch(j){w(So(j))}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:u,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)"]}),S?f.jsx("p",{className:"form-error",children:S}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:y||o.length===0||x&&u.length!==6,children:"Unlock"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function s6({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[m,g]=v.useState(!1),[p,y]=v.useState(!1),[b,S]=v.useState(!1),[w,x]=v.useState(!1),[D,O]=v.useState(null),N=Ni.useCallback(async(q,F)=>{y(!0),O(null);try{n(await e.reauth({...q?{otp:q}:{},rememberNetwork:F}))}catch(ie){O(So(ie))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let q=!1;S(!0),x(!1),O(null);const F=window.setTimeout(()=>{q||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(ie=>{q||n(ie)}).catch(ie=>{q||(O(So(ie)),x(!0))}).finally(()=>{window.clearTimeout(F),q||S(!1)}),()=>{q=!0,window.clearTimeout(F)}}},[e,o,n]);async function j(q){q.preventDefault(),await N(c,m)}return o&&b&&!w&&!D?f.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):f.jsxs("form",{className:"auth-form",onSubmit:j,children:[o&&w&&!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:q=>u(q.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:m,onChange:q=>g(q.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 r6(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function So(e){return e instanceof Error?e.message:"Request failed"}const K1="NTerminal",m_="nterminal.activeAgentId";function a6(){const[e,t]=v.useState(()=>o6()),n=v.useMemo(()=>hf(),[]),r=v.useMemo(()=>Dl(e),[e]);v.useEffect(()=>{const c=()=>{const u=LB();document.title=u>0?`(${u}) ${K1}`:K1};return c(),AB(c)},[]);function o(c){l6(c),t(c)}return f.jsx(t6,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function o6(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(m_);return e&&e.trim()?e:null}catch{return null}}function l6(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(m_,e);return}window.localStorage.removeItem(m_)}catch{}}const W1=["gesturestart","gesturechange","gestureend"],c6=[".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 u6(e=window){if(!h6(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const u=c.touches;!u||u.length===0||(u.length>1||!d6(c.target))&&r(c)}for(const c of W1)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of W1)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function d6(e){return e instanceof Element&&e.closest(c6)!==null}function h6(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}xD();l3();u6();y_();OE.createRoot(document.getElementById("root")).render(f.jsx(Ni.StrictMode,{children:f.jsx(a6,{})}));export{Ni as R,kE as g,f as j};