nterminal 1.2.70 → 1.2.72

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,55 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CLmBLNLL.js","assets/index-DO9sCZ_P.js","assets/TranscriptMarkdownBody-D39ylGl_.js"])))=>i.map(i=>d[i]);
2
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function n(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=n(l);fetch(l.href,c)}})();function Lk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tp={exports:{}},Po={};var Ub;function Bk(){if(Ub)return Po;Ub=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,l,c){var h=null;if(c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),"key"in l){c={};for(var p in l)p!=="key"&&(c[p]=l[p])}else c=l;return l=c.ref,{$$typeof:e,type:s,key:h,ref:l!==void 0?l:null,props:c}}return Po.Fragment=t,Po.jsx=n,Po.jsxs=n,Po}var Kb;function Ok(){return Kb||(Kb=1,tp.exports=Bk()),tp.exports}var m=Ok(),ip={exports:{}},Ze={};var Wb;function zk(){if(Wb)return Ze;Wb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=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 k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,L={};function A(M,Q,he){this.props=M,this.context=Q,this.refs=L,this.updater=he||k}A.prototype.isReactComponent={},A.prototype.setState=function(M,Q){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,Q,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function O(){}O.prototype=A.prototype;function Y(M,Q,he){this.props=M,this.context=Q,this.refs=L,this.updater=he||k}var P=Y.prototype=new O;P.constructor=Y,T(P,A.prototype),P.isPureReactComponent=!0;var q=Array.isArray;function re(){}var ne={H:null,A:null,T:null,S:null},ue=Object.prototype.hasOwnProperty;function ye(M,Q,he){var ge=he.ref;return{$$typeof:e,type:M,key:Q,ref:ge!==void 0?ge:null,props:he}}function U(M,Q){return ye(M.type,Q,M.props)}function K(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function W(M){var Q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(he){return Q[he]})}var H=/\/+/g;function j(M,Q){return typeof M=="object"&&M!==null&&M.key!=null?W(""+M.key):Q.toString(36)}function ae(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(re,re):(M.status="pending",M.then(function(Q){M.status==="pending"&&(M.status="fulfilled",M.value=Q)},function(Q){M.status==="pending"&&(M.status="rejected",M.reason=Q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function R(M,Q,he,ge,_e){var Se=typeof M;(Se==="undefined"||Se==="boolean")&&(M=null);var Ee=!1;if(M===null)Ee=!0;else switch(Se){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(M.$$typeof){case e:case t:Ee=!0;break;case b:return Ee=M._init,R(Ee(M._payload),Q,he,ge,_e)}}if(Ee)return _e=_e(M),Ee=ge===""?"."+j(M,0):ge,q(_e)?(he="",Ee!=null&&(he=Ee.replace(H,"$&/")+"/"),R(_e,Q,he,"",function(se){return se})):_e!=null&&(K(_e)&&(_e=U(_e,he+(_e.key==null||M&&M.key===_e.key?"":(""+_e.key).replace(H,"$&/")+"/")+Ee)),Q.push(_e)),1;Ee=0;var De=ge===""?".":ge+":";if(q(M))for(var Ie=0;Ie<M.length;Ie++)ge=M[Ie],Se=De+j(ge,Ie),Ee+=R(ge,Q,he,Se,_e);else if(Ie=w(M),typeof Ie=="function")for(M=Ie.call(M),Ie=0;!(ge=M.next()).done;)ge=ge.value,Se=De+j(ge,Ie++),Ee+=R(ge,Q,he,Se,_e);else if(Se==="object"){if(typeof M.then=="function")return R(ae(M),Q,he,ge,_e);throw Q=String(M),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.")}return Ee}function X(M,Q,he){if(M==null)return M;var ge=[],_e=0;return R(M,ge,"","",function(Se){return Q.call(he,Se,_e++)}),ge}function Z(M){if(M._status===-1){var Q=M._result;Q=Q(),Q.then(function(he){(M._status===0||M._status===-1)&&(M._status=1,M._result=he)},function(he){(M._status===0||M._status===-1)&&(M._status=2,M._result=he)}),M._status===-1&&(M._status=0,M._result=Q)}if(M._status===1)return M._result.default;throw M._result}var Ce=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},Te={map:X,forEach:function(M,Q,he){X(M,function(){Q.apply(this,arguments)},he)},count:function(M){var Q=0;return X(M,function(){Q++}),Q},toArray:function(M){return X(M,function(Q){return Q})||[]},only:function(M){if(!K(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ze.Activity=y,Ze.Children=Te,Ze.Component=A,Ze.Fragment=n,Ze.Profiler=l,Ze.PureComponent=Y,Ze.StrictMode=s,Ze.Suspense=g,Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ne,Ze.__COMPILER_RUNTIME={__proto__:null,c:function(M){return ne.H.useMemoCache(M)}},Ze.cache=function(M){return function(){return M.apply(null,arguments)}},Ze.cacheSignal=function(){return null},Ze.cloneElement=function(M,Q,he){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ge=T({},M.props),_e=M.key;if(Q!=null)for(Se in Q.key!==void 0&&(_e=""+Q.key),Q)!ue.call(Q,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Q.ref===void 0||(ge[Se]=Q[Se]);var Se=arguments.length-2;if(Se===1)ge.children=he;else if(1<Se){for(var Ee=Array(Se),De=0;De<Se;De++)Ee[De]=arguments[De+2];ge.children=Ee}return ye(M.type,_e,ge)},Ze.createContext=function(M){return M={$$typeof:h,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Ze.createElement=function(M,Q,he){var ge,_e={},Se=null;if(Q!=null)for(ge in Q.key!==void 0&&(Se=""+Q.key),Q)ue.call(Q,ge)&&ge!=="key"&&ge!=="__self"&&ge!=="__source"&&(_e[ge]=Q[ge]);var Ee=arguments.length-2;if(Ee===1)_e.children=he;else if(1<Ee){for(var De=Array(Ee),Ie=0;Ie<Ee;Ie++)De[Ie]=arguments[Ie+2];_e.children=De}if(M&&M.defaultProps)for(ge in Ee=M.defaultProps,Ee)_e[ge]===void 0&&(_e[ge]=Ee[ge]);return ye(M,Se,_e)},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(M){return{$$typeof:p,render:M}},Ze.isValidElement=K,Ze.lazy=function(M){return{$$typeof:b,_payload:{_status:-1,_result:M},_init:Z}},Ze.memo=function(M,Q){return{$$typeof:f,type:M,compare:Q===void 0?null:Q}},Ze.startTransition=function(M){var Q=ne.T,he={};ne.T=he;try{var ge=M(),_e=ne.S;_e!==null&&_e(he,ge),typeof ge=="object"&&ge!==null&&typeof ge.then=="function"&&ge.then(re,Ce)}catch(Se){Ce(Se)}finally{Q!==null&&he.types!==null&&(Q.types=he.types),ne.T=Q}},Ze.unstable_useCacheRefresh=function(){return ne.H.useCacheRefresh()},Ze.use=function(M){return ne.H.use(M)},Ze.useActionState=function(M,Q,he){return ne.H.useActionState(M,Q,he)},Ze.useCallback=function(M,Q){return ne.H.useCallback(M,Q)},Ze.useContext=function(M){return ne.H.useContext(M)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(M,Q){return ne.H.useDeferredValue(M,Q)},Ze.useEffect=function(M,Q){return ne.H.useEffect(M,Q)},Ze.useEffectEvent=function(M){return ne.H.useEffectEvent(M)},Ze.useId=function(){return ne.H.useId()},Ze.useImperativeHandle=function(M,Q,he){return ne.H.useImperativeHandle(M,Q,he)},Ze.useInsertionEffect=function(M,Q){return ne.H.useInsertionEffect(M,Q)},Ze.useLayoutEffect=function(M,Q){return ne.H.useLayoutEffect(M,Q)},Ze.useMemo=function(M,Q){return ne.H.useMemo(M,Q)},Ze.useOptimistic=function(M,Q){return ne.H.useOptimistic(M,Q)},Ze.useReducer=function(M,Q,he){return ne.H.useReducer(M,Q,he)},Ze.useRef=function(M){return ne.H.useRef(M)},Ze.useState=function(M){return ne.H.useState(M)},Ze.useSyncExternalStore=function(M,Q,he){return ne.H.useSyncExternalStore(M,Q,he)},Ze.useTransition=function(){return ne.H.useTransition()},Ze.version="19.2.6",Ze}var Fb;function vg(){return Fb||(Fb=1,ip.exports=zk()),ip.exports}var v=vg();const Mi=Lk(v);var np={exports:{}},Ho={},rp={exports:{}},sp={};var qb;function jk(){return qb||(qb=1,(function(e){function t(R,X){var Z=R.length;R.push(X);e:for(;0<Z;){var Ce=Z-1>>>1,Te=R[Ce];if(0<l(Te,X))R[Ce]=X,R[Z]=Te,Z=Ce;else break e}}function n(R){return R.length===0?null:R[0]}function s(R){if(R.length===0)return null;var X=R[0],Z=R.pop();if(Z!==X){R[0]=Z;e:for(var Ce=0,Te=R.length,M=Te>>>1;Ce<M;){var Q=2*(Ce+1)-1,he=R[Q],ge=Q+1,_e=R[ge];if(0>l(he,Z))ge<Te&&0>l(_e,he)?(R[Ce]=_e,R[ge]=Z,Ce=ge):(R[Ce]=he,R[Q]=Z,Ce=Q);else if(ge<Te&&0>l(_e,Z))R[Ce]=_e,R[ge]=Z,Ce=ge;else break e}}return X}function l(R,X){var Z=R.sortIndex-X.sortIndex;return Z!==0?Z:R.id-X.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 h=Date,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],b=1,y=null,S=3,w=!1,k=!1,T=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function P(R){for(var X=n(f);X!==null;){if(X.callback===null)s(f);else if(X.startTime<=R)s(f),X.sortIndex=X.expirationTime,t(g,X);else break;X=n(f)}}function q(R){if(T=!1,P(R),!k)if(n(g)!==null)k=!0,re||(re=!0,W());else{var X=n(f);X!==null&&ae(q,X.startTime-R)}}var re=!1,ne=-1,ue=5,ye=-1;function U(){return L?!0:!(e.unstable_now()-ye<ue)}function K(){if(L=!1,re){var R=e.unstable_now();ye=R;var X=!0;try{e:{k=!1,T&&(T=!1,O(ne),ne=-1),w=!0;var Z=S;try{t:{for(P(R),y=n(g);y!==null&&!(y.expirationTime>R&&U());){var Ce=y.callback;if(typeof Ce=="function"){y.callback=null,S=y.priorityLevel;var Te=Ce(y.expirationTime<=R);if(R=e.unstable_now(),typeof Te=="function"){y.callback=Te,P(R),X=!0;break t}y===n(g)&&s(g),P(R)}else s(g);y=n(g)}if(y!==null)X=!0;else{var M=n(f);M!==null&&ae(q,M.startTime-R),X=!1}}break e}finally{y=null,S=Z,w=!1}X=void 0}}finally{X?W():re=!1}}}var W;if(typeof Y=="function")W=function(){Y(K)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=K,W=function(){j.postMessage(null)}}else W=function(){A(K,0)};function ae(R,X){ne=A(function(){R(e.unstable_now())},X)}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(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ue=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(R){switch(S){case 1:case 2:case 3:var X=3;break;default:X=S}var Z=S;S=X;try{return R()}finally{S=Z}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(R,X){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var Z=S;S=R;try{return X()}finally{S=Z}},e.unstable_scheduleCallback=function(R,X,Z){var Ce=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Ce+Z:Ce):Z=Ce,R){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=Z+Te,R={id:b++,callback:X,priorityLevel:R,startTime:Z,expirationTime:Te,sortIndex:-1},Z>Ce?(R.sortIndex=Z,t(f,R),n(g)===null&&R===n(f)&&(T?(O(ne),ne=-1):T=!0,ae(q,Z-Ce))):(R.sortIndex=Te,t(g,R),k||w||(k=!0,re||(re=!0,W()))),R},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(R){var X=S;return function(){var Z=S;S=X;try{return R.apply(this,arguments)}finally{S=Z}}}})(sp)),sp}var $b;function Pk(){return $b||($b=1,rp.exports=jk()),rp.exports}var ap={exports:{}},tn={};var Vb;function Hk(){if(Vb)return tn;Vb=1;var e=vg();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={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},l=Symbol.for("react.portal");function c(g,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:y==null?null:""+y,children:g,containerInfo:f,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return tn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,tn.createPortal=function(g,f){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,b)},tn.flushSync=function(g){var f=h.T,b=s.p;try{if(h.T=null,s.p=2,g)return g()}finally{h.T=f,s.p=b,s.d.f()}},tn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},tn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},tn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:w}):b==="script"&&s.d.X(g,{crossOrigin:y,integrity:S,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},tn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},tn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);s.d.L(g,b,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},tn.preloadModule=function(g,f){if(typeof g=="string")if(f){var b=p(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},tn.requestFormReset=function(g){s.d.r(g)},tn.unstable_batchedUpdates=function(g,f){return g(f)},tn.useFormState=function(g,f,b){return h.H.useFormState(g,f,b)},tn.useFormStatus=function(){return h.H.useHostTransitionStatus()},tn.version="19.2.6",tn}var Yb;function tw(){if(Yb)return ap.exports;Yb=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(),ap.exports=Hk(),ap.exports}var Xb;function Ik(){if(Xb)return Ho;Xb=1;var e=Pk(),t=vg(),n=tw();function s(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function h(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function p(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var r=i.alternate;if(!r){if(r=c(i),r===null)throw Error(s(188));return r!==i?null:i}for(var a=i,o=r;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(o=u.return,o!==null){a=o;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===o)return g(u),r;d=d.sibling}throw Error(s(188))}if(a.return!==o.return)a=u,o=d;else{for(var _=!1,x=u.child;x;){if(x===a){_=!0,a=u,o=d;break}if(x===o){_=!0,o=u,a=d;break}x=x.sibling}if(!_){for(x=d.child;x;){if(x===a){_=!0,a=d,o=u;break}if(x===o){_=!0,o=d,a=u;break}x=x.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==o)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:r}function b(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=b(i),r!==null)return r;i=i.sibling}return null}var y=Object.assign,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),ue=Symbol.for("react.lazy"),ye=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function W(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===H?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case q:return"Suspense";case re:return"SuspenseList";case ye:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case k:return"Portal";case Y:return i.displayName||"Context";case O:return(i._context.displayName||"Context")+".Consumer";case P:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ne:return r=i.displayName||null,r!==null?r:j(i.type)||"Memo";case ue:r=i._payload,i=i._init;try{return j(i(r))}catch{}}return null}var ae=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Ce=[],Te=-1;function M(i){return{current:i}}function Q(i){0>Te||(i.current=Ce[Te],Ce[Te]=null,Te--)}function he(i,r){Te++,Ce[Te]=i.current,i.current=r}var ge=M(null),_e=M(null),Se=M(null),Ee=M(null);function De(i,r){switch(he(Se,r),he(_e,i),he(ge,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?ub(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=ub(r),i=hb(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Q(ge),he(ge,i)}function Ie(){Q(ge),Q(_e),Q(Se)}function se(i){i.memoizedState!==null&&he(Ee,i);var r=ge.current,a=hb(r,i.type);r!==a&&(he(_e,i),he(ge,a))}function me(i){_e.current===i&&(Q(ge),Q(_e)),Ee.current===i&&(Q(Ee),Bo._currentValue=Z)}var Le,be;function Me(i){if(Le===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);Le=r&&r[1]||"",be=-1<a.stack.indexOf(`
3
+ at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
4
+ `+Le+i+be}var Pe=!1;function je(i,r){if(!i||Pe)return"";Pe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(r){var ce=function(){throw Error()};if(Object.defineProperty(ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ce,[])}catch(ee){var G=ee}Reflect.construct(i,[],ce)}else{try{ce.call()}catch(ee){G=ee}i.call(ce.prototype)}}else{try{throw Error()}catch(ee){G=ee}(ce=i())&&typeof ce.catch=="function"&&ce.catch(function(){})}}catch(ee){if(ee&&G&&typeof ee.stack=="string")return[ee.stack,G.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=o.DetermineComponentFrameRoot(),_=d[0],x=d[1];if(_&&x){var N=_.split(`
5
+ `),V=x.split(`
6
+ `);for(u=o=0;o<N.length&&!N[o].includes("DetermineComponentFrameRoot");)o++;for(;u<V.length&&!V[u].includes("DetermineComponentFrameRoot");)u++;if(o===N.length||u===V.length)for(o=N.length-1,u=V.length-1;1<=o&&0<=u&&N[o]!==V[u];)u--;for(;1<=o&&0<=u;o--,u--)if(N[o]!==V[u]){if(o!==1||u!==1)do if(o--,u--,0>u||N[o]!==V[u]){var le=`
7
+ `+N[o].replace(" at new "," at ");return i.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",i.displayName)),le}while(1<=o&&0<=u);break}}}finally{Pe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Me(a):""}function ie(i,r){switch(i.tag){case 26:case 27:case 5:return Me(i.type);case 16:return Me("Lazy");case 13:return i.child!==r&&r!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return je(i.type,!1);case 11:return je(i.type.render,!1);case 1:return je(i.type,!0);case 31:return Me("Activity");default:return""}}function xe(i){try{var r="",a=null;do r+=ie(i,a),a=i,i=i.return;while(i);return r}catch(o){return`
8
+ Error generating stack: `+o.message+`
9
+ `+o.stack}}var Re=Object.prototype.hasOwnProperty,Be=e.unstable_scheduleCallback,Oe=e.unstable_cancelCallback,rt=e.unstable_shouldYield,qt=e.unstable_requestPaint,wt=e.unstable_now,Ki=e.unstable_getCurrentPriorityLevel,nt=e.unstable_ImmediatePriority,pt=e.unstable_UserBlockingPriority,fe=e.unstable_NormalPriority,Ue=e.unstable_LowPriority,st=e.unstable_IdlePriority,at=e.log,Et=e.unstable_setDisableYieldValue,Tt=null,Dt=null;function Rt(i){if(typeof at=="function"&&Et(i),Dt&&typeof Dt.setStrictMode=="function")try{Dt.setStrictMode(Tt,i)}catch{}}var F=Math.clz32?Math.clz32:$t,qe=Math.log,mt=Math.LN2;function $t(i){return i>>>=0,i===0?32:31-(qe(i)/mt|0)|0}var Si=256,Zi=262144,Ct=4194304;function _t(i){var r=i&42;if(r!==0)return r;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 Pt(i,r,a){var o=i.pendingLanes;if(o===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var x=o&134217727;return x!==0?(o=x&~d,o!==0?u=_t(o):(_&=x,_!==0?u=_t(_):a||(a=x&~i,a!==0&&(u=_t(a))))):(x=o&~d,x!==0?u=_t(x):_!==0?u=_t(_):a||(a=o&~i,a!==0&&(u=_t(a)))),u===0?0:r!==0&&r!==u&&(r&d)===0&&(d=u&-u,a=r&-r,d>=a||d===32&&(a&4194048)!==0)?r:u}function li(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function wi(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 jt(){var i=Ct;return Ct<<=1,(Ct&62914560)===0&&(Ct=4194304),i}function Li(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function Gt(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ht(i,r,a,o,u,d){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 x=i.entanglements,N=i.expirationTimes,V=i.hiddenUpdates;for(a=_&~a;0<a;){var le=31-F(a),ce=1<<le;x[le]=0,N[le]=-1;var G=V[le];if(G!==null)for(V[le]=null,le=0;le<G.length;le++){var ee=G[le];ee!==null&&(ee.lane&=-536870913)}a&=~ce}o!==0&&Wi(i,o,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~r))}function Wi(i,r,a){i.pendingLanes|=r,i.suspendedLanes&=~r;var o=31-F(r);i.entangledLanes|=r,i.entanglements[o]=i.entanglements[o]|1073741824|a&261930}function bt(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var o=31-F(a),u=1<<o;u&r|i[o]&r&&(i[o]|=r),a&=~u}}function oi(i,r){var a=r&-r;return a=(a&42)!==0?1:Fi(a),(a&(i.suspendedLanes|r))!==0?0:a}function Fi(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 Ci(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function sn(){var i=X.p;return i!==0?i:(i=window.event,i===void 0?32:Bb(i.type))}function dn(i,r){var a=X.p;try{return X.p=i,r()}finally{X.p=a}}var Bi=Math.random().toString(36).slice(2),ei="__reactFiber$"+Bi,xi="__reactProps$"+Bi,wn="__reactContainer$"+Bi,ia="__reactEvents$"+Bi,Qi="__reactListeners$"+Bi,na="__reactHandles$"+Bi,ra="__reactResources$"+Bi,Nr="__reactMarker$"+Bi;function Ar(i){delete i[ei],delete i[xi],delete i[ia],delete i[Qi],delete i[na]}function On(i){var r=i[ei];if(r)return r;for(var a=i.parentNode;a;){if(r=a[wn]||a[ei]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=vb(i);i!==null;){if(a=i[ei])return a;i=vb(i)}return r}i=a,a=i.parentNode}return null}function pr(i){if(i=i[ei]||i[wn]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function mr(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(s(33))}function tr(i){var r=i[ra];return r||(r=i[ra]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function It(i){i[Nr]=!0}var sa=new Set,Lr={};function ir(i,r){gr(i,r),gr(i+"Capture",r)}function gr(i,r){for(Lr[i]=r,i=0;i<r.length;i++)sa.add(r[i])}var Ql=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]*$"),as={},aa={};function Jl(i){return Re.call(aa,i)?!0:Re.call(as,i)?!1:Ql.test(i)?aa[i]=!0:(as[i]=!0,!1)}function ls(i,r,a){if(Jl(r))if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var o=r.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+a)}}function os(i,r,a){if(a===null)i.removeAttribute(r);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+a)}}function an(i,r,a,o){if(o===null)i.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(r,a,""+o)}}function Ji(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function cs(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function us(i,r,a){var o=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,d=o.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,r,{enumerable:o.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function qi(i){if(!i._valueTracker){var r=cs(i)?"checked":"value";i._valueTracker=us(i,r,""+i[r])}}function Br(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),o="";return i&&(o=cs(i)?i.checked?"true":"false":i.value),i=o,i!==a?(r.setValue(i),!0):!1}function We(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 hs=/[\n"\\]/g;function ki(i){return i.replace(hs,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function zn(i,r,a,o,u,d,_,x){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),r!=null?_==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Ji(r)):i.value!==""+Ji(r)&&(i.value=""+Ji(r)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),r!=null?la(i,_,Ji(r)):a!=null?la(i,_,Ji(a)):o!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"?i.name=""+Ji(x):i.removeAttribute("name")}function ti(i,r,a,o,u,d,_,x){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),r!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||r!=null)){qi(i);return}a=a!=null?""+Ji(a):"",r=r!=null?""+Ji(r):a,x||r===i.value||(i.value=r),i.defaultValue=r}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,i.checked=x?i.checked:!!o,i.defaultChecked=!!o,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),qi(i)}function la(i,r,a){r==="number"&&We(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function nr(i,r,a,o){if(i=i.options,r){r={};for(var u=0;u<a.length;u++)r["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=r.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&o&&(i[a].defaultSelected=!0)}else{for(a=""+Ji(a),r=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,o&&(i[u].defaultSelected=!0);return}r!==null||i[u].disabled||(r=i[u])}r!==null&&(r.selected=!0)}}function ds(i,r,a){if(r!=null&&(r=""+Ji(r),r!==i.value&&(i.value=r),a==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=a!=null?""+Ji(a):""}function oa(i,r,a,o){if(r==null){if(o!=null){if(a!=null)throw Error(s(92));if(ae(o)){if(1<o.length)throw Error(s(93));o=o[0]}a=o}a==null&&(a=""),r=a}a=Ji(r),i.defaultValue=a,o=i.textContent,o===a&&o!==""&&o!==null&&(i.value=o),qi(i)}function _r(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var Ya=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 jn(i,r,a){var o=r.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?o?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":o?i.setProperty(r,a):typeof a!="number"||a===0||Ya.has(r)?r==="float"?i.cssFloat=a:i[r]=(""+a).trim():i[r]=a+"px"}function fs(i,r,a){if(r!=null&&typeof r!="object")throw Error(s(62));if(i=i.style,a!=null){for(var o in a)!a.hasOwnProperty(o)||r!=null&&r.hasOwnProperty(o)||(o.indexOf("--")===0?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="");for(var u in r)o=r[u],r.hasOwnProperty(u)&&a[u]!==o&&jn(i,u,o)}else for(var d in r)r.hasOwnProperty(d)&&jn(i,d,r[d])}function ca(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 Xa=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"]]),ps=/^[\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 vr(i){return ps.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function ii(){}var Pn=null;function rr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var yr=null,sr=null;function Ga(i){var r=pr(i);if(r&&(i=r.stateNode)){var a=i[xi]||null;e:switch(i=r.stateNode,r.type){case"input":if(zn(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+ki(""+r)+'"][type="radio"]'),r=0;r<a.length;r++){var o=a[r];if(o!==i&&o.form===i.form){var u=o[xi]||null;if(!u)throw Error(s(90));zn(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(r=0;r<a.length;r++)o=a[r],o.form===i.form&&Br(o)}break e;case"textarea":ds(i,a.value,a.defaultValue);break e;case"select":r=a.value,r!=null&&nr(i,!!a.multiple,r,!1)}}}var ms=!1;function Za(i,r,a){if(ms)return i(r,a);ms=!0;try{var o=i(r);return o}finally{if(ms=!1,(yr!==null||sr!==null)&&(wu(),yr&&(r=yr,i=sr,sr=yr=null,Ga(r),i)))for(r=0;r<i.length;r++)Ga(i[r])}}function Or(i,r){var a=i.stateNode;if(a===null)return null;var o=a[xi]||null;if(o===null)return null;a=o[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(i=i.type,o=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!o;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,r,typeof a));return a}var fn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),br=!1;if(fn)try{var Hn={};Object.defineProperty(Hn,"passive",{get:function(){br=!0}}),window.addEventListener("test",Hn,Hn),window.removeEventListener("test",Hn,Hn)}catch{br=!1}var ln=null,gs=null,_s=null;function pn(){if(_s)return _s;var i,r=gs,a=r.length,o,u="value"in ln?ln.value:ln.textContent,d=u.length;for(i=0;i<a&&r[i]===u[i];i++);var _=a-i;for(o=1;o<=_&&r[a-o]===u[d-o];o++);return _s=u.slice(i,1<o?1-o:void 0)}function ar(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function zr(){return!0}function C(){return!1}function E(i){function r(a,o,u,d,_){this._reactName=a,this._targetInst=u,this.type=o,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var x in i)i.hasOwnProperty(x)&&(a=i[x],this[x]=a?a(d):d[x]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?zr:C,this.isPropagationStopped=C,this}return y(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=zr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=zr)},persist:function(){},isPersistent:zr}),r}var B={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},te=E(B),ve=y({},B,{view:0,detail:0}),pe=E(ve),we,$e,et,Ut=y({},ve,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:In,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!==et&&(et&&i.type==="mousemove"?(we=i.screenX-et.screenX,$e=i.screenY-et.screenY):$e=we=0,et=i),we)},movementY:function(i){return"movementY"in i?i.movementY:$e}}),Vt=E(Ut),D=y({},Ut,{dataTransfer:0}),J=E(D),Ke=y({},ve,{relatedTarget:0}),Ye=E(Ke),Ge=y({},B,{animationName:0,elapsedTime:0,pseudoElement:0}),ht=E(Ge),di=y({},B,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),en=E(di),Zt=y({},B,{data:0}),fi=E(Zt),ua={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cn={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"},Pc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sd(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Pc[i])?!!r[i]:!1}function In(){return sd}var Hc=y({},ve,{key:function(i){if(i.key){var r=ua[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=ar(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Cn[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:In,charCode:function(i){return i.type==="keypress"?ar(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ar(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Ic=E(Hc),$C=y({},Ut,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),m_=E($C),VC=y({},ve,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:In}),YC=E(VC),XC=y({},B,{propertyName:0,elapsedTime:0,pseudoElement:0}),GC=E(XC),ZC=y({},Ut,{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}),QC=E(ZC),JC=y({},B,{newState:0,oldState:0}),ex=E(JC),tx=[9,13,27,32],ad=fn&&"CompositionEvent"in window,eo=null;fn&&"documentMode"in document&&(eo=document.documentMode);var ix=fn&&"TextEvent"in window&&!eo,g_=fn&&(!ad||eo&&8<eo&&11>=eo),__=" ",v_=!1;function y_(i,r){switch(i){case"keyup":return tx.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function b_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Qa=!1;function nx(i,r){switch(i){case"compositionend":return b_(r);case"keypress":return r.which!==32?null:(v_=!0,__);case"textInput":return i=r.data,i===__&&v_?null:i;default:return null}}function rx(i,r){if(Qa)return i==="compositionend"||!ad&&y_(i,r)?(i=pn(),_s=gs=ln=null,Qa=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return g_&&r.locale!=="ko"?null:r.data;default:return null}}var sx={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 S_(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!sx[i.type]:r==="textarea"}function w_(i,r,a,o){yr?sr?sr.push(o):sr=[o]:yr=o,r=Ru(r,"onChange"),0<r.length&&(a=new te("onChange","change",null,a,o),i.push({event:a,listeners:r}))}var to=null,io=null;function ax(i){rb(i,0)}function Uc(i){var r=mr(i);if(Br(r))return i}function C_(i,r){if(i==="change")return r}var x_=!1;if(fn){var ld;if(fn){var od="oninput"in document;if(!od){var k_=document.createElement("div");k_.setAttribute("oninput","return;"),od=typeof k_.oninput=="function"}ld=od}else ld=!1;x_=ld&&(!document.documentMode||9<document.documentMode)}function E_(){to&&(to.detachEvent("onpropertychange",T_),io=to=null)}function T_(i){if(i.propertyName==="value"&&Uc(io)){var r=[];w_(r,io,i,rr(i)),Za(ax,r)}}function lx(i,r,a){i==="focusin"?(E_(),to=r,io=a,to.attachEvent("onpropertychange",T_)):i==="focusout"&&E_()}function ox(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Uc(io)}function cx(i,r){if(i==="click")return Uc(r)}function ux(i,r){if(i==="input"||i==="change")return Uc(r)}function hx(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var xn=typeof Object.is=="function"?Object.is:hx;function no(i,r){if(xn(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),o=Object.keys(r);if(a.length!==o.length)return!1;for(o=0;o<a.length;o++){var u=a[o];if(!Re.call(r,u)||!xn(i[u],r[u]))return!1}return!0}function D_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function R_(i,r){var a=D_(i);i=0;for(var o;a;){if(a.nodeType===3){if(o=i+a.textContent.length,i<=r&&o>=r)return{node:a,offset:r-i};i=o}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=D_(a)}}function M_(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?M_(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function N_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=We(i.document);r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=We(i.document)}return r}function cd(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var dx=fn&&"documentMode"in document&&11>=document.documentMode,Ja=null,ud=null,ro=null,hd=!1;function A_(i,r,a){var o=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;hd||Ja==null||Ja!==We(o)||(o=Ja,"selectionStart"in o&&cd(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),ro&&no(ro,o)||(ro=o,o=Ru(ud,"onSelect"),0<o.length&&(r=new te("onSelect","select",null,r,a),i.push({event:r,listeners:o}),r.target=Ja)))}function ha(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var el={animationend:ha("Animation","AnimationEnd"),animationiteration:ha("Animation","AnimationIteration"),animationstart:ha("Animation","AnimationStart"),transitionrun:ha("Transition","TransitionRun"),transitionstart:ha("Transition","TransitionStart"),transitioncancel:ha("Transition","TransitionCancel"),transitionend:ha("Transition","TransitionEnd")},dd={},L_={};fn&&(L_=document.createElement("div").style,"AnimationEvent"in window||(delete el.animationend.animation,delete el.animationiteration.animation,delete el.animationstart.animation),"TransitionEvent"in window||delete el.transitionend.transition);function da(i){if(dd[i])return dd[i];if(!el[i])return i;var r=el[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in L_)return dd[i]=r[a];return i}var B_=da("animationend"),O_=da("animationiteration"),z_=da("animationstart"),fx=da("transitionrun"),px=da("transitionstart"),mx=da("transitioncancel"),j_=da("transitionend"),P_=new Map,fd="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(" ");fd.push("scrollEnd");function lr(i,r){P_.set(i,r),ir(r,[i])}var Kc=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=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(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Un=[],tl=0,pd=0;function Wc(){for(var i=tl,r=pd=tl=0;r<i;){var a=Un[r];Un[r++]=null;var o=Un[r];Un[r++]=null;var u=Un[r];Un[r++]=null;var d=Un[r];if(Un[r++]=null,o!==null&&u!==null){var _=o.pending;_===null?u.next=u:(u.next=_.next,_.next=u),o.pending=u}d!==0&&H_(a,u,d)}}function Fc(i,r,a,o){Un[tl++]=i,Un[tl++]=r,Un[tl++]=a,Un[tl++]=o,pd|=o,i.lanes|=o,i=i.alternate,i!==null&&(i.lanes|=o)}function md(i,r,a,o){return Fc(i,r,a,o),qc(i)}function fa(i,r){return Fc(i,null,null,r),qc(i)}function H_(i,r,a){i.lanes|=a;var o=i.alternate;o!==null&&(o.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,o=d.alternate,o!==null&&(o.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&r!==null&&(u=31-F(a),i=d.hiddenUpdates,o=i[u],o===null?i[u]=[r]:o.push(r),r.lane=a|536870912),d):null}function qc(i){if(50<To)throw To=0,kf=null,Error(s(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var il={};function gx(i,r,a,o){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=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function kn(i,r,a,o){return new gx(i,r,a,o)}function gd(i){return i=i.prototype,!(!i||!i.isReactComponent)}function jr(i,r){var a=i.alternate;return a===null?(a=kn(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,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,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function I_(i,r){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=r,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,r=a.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function $c(i,r,a,o,u,d){var _=0;if(o=i,typeof i=="function")gd(i)&&(_=1);else if(typeof i=="string")_=Sk(i,a,ge.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ye:return i=kn(31,a,r,u),i.elementType=ye,i.lanes=d,i;case T:return pa(a.children,u,d,r);case L:_=8,u|=24;break;case A:return i=kn(12,a,r,u|2),i.elementType=A,i.lanes=d,i;case q:return i=kn(13,a,r,u),i.elementType=q,i.lanes=d,i;case re:return i=kn(19,a,r,u),i.elementType=re,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case O:_=9;break e;case P:_=11;break e;case ne:_=14;break e;case ue:_=16,o=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),o=null}return r=kn(_,a,r,u),r.elementType=i,r.type=o,r.lanes=d,r}function pa(i,r,a,o){return i=kn(7,i,o,r),i.lanes=a,i}function _d(i,r,a){return i=kn(6,i,null,r),i.lanes=a,i}function U_(i){var r=kn(18,null,null,0);return r.stateNode=i,r}function vd(i,r,a){return r=kn(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var K_=new WeakMap;function Kn(i,r){if(typeof i=="object"&&i!==null){var a=K_.get(i);return a!==void 0?a:(r={value:i,source:r,stack:xe(r)},K_.set(i,r),r)}return{value:i,source:r,stack:xe(r)}}var nl=[],rl=0,Vc=null,so=0,Wn=[],Fn=0,vs=null,Sr=1,wr="";function Pr(i,r){nl[rl++]=so,nl[rl++]=Vc,Vc=i,so=r}function W_(i,r,a){Wn[Fn++]=Sr,Wn[Fn++]=wr,Wn[Fn++]=vs,vs=i;var o=Sr;i=wr;var u=32-F(o)-1;o&=~(1<<u),a+=1;var d=32-F(r)+u;if(30<d){var _=u-u%5;d=(o&(1<<_)-1).toString(32),o>>=_,u-=_,Sr=1<<32-F(r)+u|a<<u|o,wr=d+i}else Sr=1<<d|a<<u|o,wr=i}function yd(i){i.return!==null&&(Pr(i,1),W_(i,1,0))}function bd(i){for(;i===Vc;)Vc=nl[--rl],nl[rl]=null,so=nl[--rl],nl[rl]=null;for(;i===vs;)vs=Wn[--Fn],Wn[Fn]=null,wr=Wn[--Fn],Wn[Fn]=null,Sr=Wn[--Fn],Wn[Fn]=null}function F_(i,r){Wn[Fn++]=Sr,Wn[Fn++]=wr,Wn[Fn++]=vs,Sr=r.id,wr=r.overflow,vs=i}var $i=null,Kt=null,gt=!1,ys=null,qn=!1,Sd=Error(s(519));function bs(i){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ao(Kn(r,i)),Sd}function q_(i){var r=i.stateNode,a=i.type,o=i.memoizedProps;switch(r[ei]=i,r[xi]=o,a){case"dialog":ut("cancel",r),ut("close",r);break;case"iframe":case"object":case"embed":ut("load",r);break;case"video":case"audio":for(a=0;a<Ro.length;a++)ut(Ro[a],r);break;case"source":ut("error",r);break;case"img":case"image":case"link":ut("error",r),ut("load",r);break;case"details":ut("toggle",r);break;case"input":ut("invalid",r),ti(r,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ut("invalid",r);break;case"textarea":ut("invalid",r),oa(r,o.value,o.defaultValue,o.children)}a=o.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||r.textContent===""+a||o.suppressHydrationWarning===!0||ob(r.textContent,a)?(o.popover!=null&&(ut("beforetoggle",r),ut("toggle",r)),o.onScroll!=null&&ut("scroll",r),o.onScrollEnd!=null&&ut("scrollend",r),o.onClick!=null&&(r.onclick=ii),r=!0):r=!1,r||bs(i,!0)}function $_(i){for($i=i.return;$i;)switch($i.tag){case 5:case 31:case 13:qn=!1;return;case 27:case 3:qn=!0;return;default:$i=$i.return}}function sl(i){if(i!==$i)return!1;if(!gt)return $_(i),gt=!0,!1;var r=i.tag,a;if((a=r!==3&&r!==27)&&((a=r===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||If(i.type,i.memoizedProps)),a=!a),a&&Kt&&bs(i),$_(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Kt=_b(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Kt=_b(i)}else r===27?(r=Kt,Bs(i.type)?(i=qf,qf=null,Kt=i):Kt=r):Kt=$i?Vn(i.stateNode.nextSibling):null;return!0}function ma(){Kt=$i=null,gt=!1}function wd(){var i=ys;return i!==null&&(vn===null?vn=i:vn.push.apply(vn,i),ys=null),i}function ao(i){ys===null?ys=[i]:ys.push(i)}var Cd=M(null),ga=null,Hr=null;function Ss(i,r,a){he(Cd,r._currentValue),r._currentValue=a}function Ir(i){i._currentValue=Cd.current,Q(Cd)}function xd(i,r,a){for(;i!==null;){var o=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,o!==null&&(o.childLanes|=r)):o!==null&&(o.childLanes&r)!==r&&(o.childLanes|=r),i===a)break;i=i.return}}function kd(i,r,a,o){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var x=d;d=u;for(var N=0;N<r.length;N++)if(x.context===r[N]){d.lanes|=a,x=d.alternate,x!==null&&(x.lanes|=a),xd(d.return,a,i),o||(_=null);break e}d=x.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),xd(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function al(i,r,a,o){i=null;for(var u=r,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var x=u.type;xn(u.pendingProps.value,_.value)||(i!==null?i.push(x):i=[x])}}else if(u===Ee.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(Bo):i=[Bo])}u=u.return}i!==null&&kd(r,i,a,o),r.flags|=262144}function Yc(i){for(i=i.firstContext;i!==null;){if(!xn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function _a(i){ga=i,Hr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Vi(i){return V_(ga,i)}function Xc(i,r){return ga===null&&_a(i),V_(i,r)}function V_(i,r){var a=r._currentValue;if(r={context:r,memoizedValue:a,next:null},Hr===null){if(i===null)throw Error(s(308));Hr=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Hr=Hr.next=r;return a}var _x=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(a,o){i.push(o)}};this.abort=function(){r.aborted=!0,i.forEach(function(a){return a()})}},vx=e.unstable_scheduleCallback,yx=e.unstable_NormalPriority,pi={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ed(){return{controller:new _x,data:new Map,refCount:0}}function lo(i){i.refCount--,i.refCount===0&&vx(yx,function(){i.controller.abort()})}var oo=null,Td=0,ll=0,ol=null;function bx(i,r){if(oo===null){var a=oo=[];Td=0,ll=Nf(),ol={status:"pending",value:void 0,then:function(o){a.push(o)}}}return Td++,r.then(Y_,Y_),r}function Y_(){if(--Td===0&&oo!==null){ol!==null&&(ol.status="fulfilled");var i=oo;oo=null,ll=0,ol=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function Sx(i,r){var a=[],o={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){o.status="fulfilled",o.value=r;for(var u=0;u<a.length;u++)(0,a[u])(r)},function(u){for(o.status="rejected",o.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),o}var X_=R.S;R.S=function(i,r){Ay=wt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&bx(i,r),X_!==null&&X_(i,r)};var va=M(null);function Dd(){var i=va.current;return i!==null?i:Ot.pooledCache}function Gc(i,r){r===null?he(va,va.current):he(va,r.pool)}function G_(){var i=Dd();return i===null?null:{parent:pi._currentValue,pool:i}}var cl=Error(s(460)),Rd=Error(s(474)),Zc=Error(s(542)),Qc={then:function(){}};function Z_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function Q_(i,r,a){switch(a=i[a],a===void 0?i.push(r):a!==r&&(r.then(ii,ii),r=a),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,ev(i),i;default:if(typeof r.status=="string")r.then(ii,ii);else{if(i=Ot,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=r,i.status="pending",i.then(function(o){if(r.status==="pending"){var u=r;u.status="fulfilled",u.value=o}},function(o){if(r.status==="pending"){var u=r;u.status="rejected",u.reason=o}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,ev(i),i}throw ba=r,cl}}function ya(i){try{var r=i._init;return r(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ba=a,cl):a}}var ba=null;function J_(){if(ba===null)throw Error(s(459));var i=ba;return ba=null,i}function ev(i){if(i===cl||i===Zc)throw Error(s(483))}var ul=null,co=0;function Jc(i){var r=co;return co+=1,ul===null&&(ul=[]),Q_(ul,i,r)}function uo(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function eu(i,r){throw r.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(r),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function tv(i){function r(I,z){if(i){var $=I.deletions;$===null?(I.deletions=[z],I.flags|=16):$.push(z)}}function a(I,z){if(!i)return null;for(;z!==null;)r(I,z),z=z.sibling;return null}function o(I){for(var z=new Map;I!==null;)I.key!==null?z.set(I.key,I):z.set(I.index,I),I=I.sibling;return z}function u(I,z){return I=jr(I,z),I.index=0,I.sibling=null,I}function d(I,z,$){return I.index=$,i?($=I.alternate,$!==null?($=$.index,$<z?(I.flags|=67108866,z):$):(I.flags|=67108866,z)):(I.flags|=1048576,z)}function _(I){return i&&I.alternate===null&&(I.flags|=67108866),I}function x(I,z,$,oe){return z===null||z.tag!==6?(z=_d($,I.mode,oe),z.return=I,z):(z=u(z,$),z.return=I,z)}function N(I,z,$,oe){var Fe=$.type;return Fe===T?le(I,z,$.props.children,oe,$.key):z!==null&&(z.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===ue&&ya(Fe)===z.type)?(z=u(z,$.props),uo(z,$),z.return=I,z):(z=$c($.type,$.key,$.props,null,I.mode,oe),uo(z,$),z.return=I,z)}function V(I,z,$,oe){return z===null||z.tag!==4||z.stateNode.containerInfo!==$.containerInfo||z.stateNode.implementation!==$.implementation?(z=vd($,I.mode,oe),z.return=I,z):(z=u(z,$.children||[]),z.return=I,z)}function le(I,z,$,oe,Fe){return z===null||z.tag!==7?(z=pa($,I.mode,oe,Fe),z.return=I,z):(z=u(z,$),z.return=I,z)}function ce(I,z,$){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=_d(""+z,I.mode,$),z.return=I,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case w:return $=$c(z.type,z.key,z.props,null,I.mode,$),uo($,z),$.return=I,$;case k:return z=vd(z,I.mode,$),z.return=I,z;case ue:return z=ya(z),ce(I,z,$)}if(ae(z)||W(z))return z=pa(z,I.mode,$,null),z.return=I,z;if(typeof z.then=="function")return ce(I,Jc(z),$);if(z.$$typeof===Y)return ce(I,Xc(I,z),$);eu(I,z)}return null}function G(I,z,$,oe){var Fe=z!==null?z.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return Fe!==null?null:x(I,z,""+$,oe);if(typeof $=="object"&&$!==null){switch($.$$typeof){case w:return $.key===Fe?N(I,z,$,oe):null;case k:return $.key===Fe?V(I,z,$,oe):null;case ue:return $=ya($),G(I,z,$,oe)}if(ae($)||W($))return Fe!==null?null:le(I,z,$,oe,null);if(typeof $.then=="function")return G(I,z,Jc($),oe);if($.$$typeof===Y)return G(I,z,Xc(I,$),oe);eu(I,$)}return null}function ee(I,z,$,oe,Fe){if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return I=I.get($)||null,x(z,I,""+oe,Fe);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case w:return I=I.get(oe.key===null?$:oe.key)||null,N(z,I,oe,Fe);case k:return I=I.get(oe.key===null?$:oe.key)||null,V(z,I,oe,Fe);case ue:return oe=ya(oe),ee(I,z,$,oe,Fe)}if(ae(oe)||W(oe))return I=I.get($)||null,le(z,I,oe,Fe,null);if(typeof oe.then=="function")return ee(I,z,$,Jc(oe),Fe);if(oe.$$typeof===Y)return ee(I,z,$,Xc(z,oe),Fe);eu(z,oe)}return null}function ze(I,z,$,oe){for(var Fe=null,vt=null,He=z,tt=z=0,ft=null;He!==null&&tt<$.length;tt++){He.index>tt?(ft=He,He=null):ft=He.sibling;var yt=G(I,He,$[tt],oe);if(yt===null){He===null&&(He=ft);break}i&&He&&yt.alternate===null&&r(I,He),z=d(yt,z,tt),vt===null?Fe=yt:vt.sibling=yt,vt=yt,He=ft}if(tt===$.length)return a(I,He),gt&&Pr(I,tt),Fe;if(He===null){for(;tt<$.length;tt++)He=ce(I,$[tt],oe),He!==null&&(z=d(He,z,tt),vt===null?Fe=He:vt.sibling=He,vt=He);return gt&&Pr(I,tt),Fe}for(He=o(He);tt<$.length;tt++)ft=ee(He,I,tt,$[tt],oe),ft!==null&&(i&&ft.alternate!==null&&He.delete(ft.key===null?tt:ft.key),z=d(ft,z,tt),vt===null?Fe=ft:vt.sibling=ft,vt=ft);return i&&He.forEach(function(Hs){return r(I,Hs)}),gt&&Pr(I,tt),Fe}function Ve(I,z,$,oe){if($==null)throw Error(s(151));for(var Fe=null,vt=null,He=z,tt=z=0,ft=null,yt=$.next();He!==null&&!yt.done;tt++,yt=$.next()){He.index>tt?(ft=He,He=null):ft=He.sibling;var Hs=G(I,He,yt.value,oe);if(Hs===null){He===null&&(He=ft);break}i&&He&&Hs.alternate===null&&r(I,He),z=d(Hs,z,tt),vt===null?Fe=Hs:vt.sibling=Hs,vt=Hs,He=ft}if(yt.done)return a(I,He),gt&&Pr(I,tt),Fe;if(He===null){for(;!yt.done;tt++,yt=$.next())yt=ce(I,yt.value,oe),yt!==null&&(z=d(yt,z,tt),vt===null?Fe=yt:vt.sibling=yt,vt=yt);return gt&&Pr(I,tt),Fe}for(He=o(He);!yt.done;tt++,yt=$.next())yt=ee(He,I,tt,yt.value,oe),yt!==null&&(i&&yt.alternate!==null&&He.delete(yt.key===null?tt:yt.key),z=d(yt,z,tt),vt===null?Fe=yt:vt.sibling=yt,vt=yt);return i&&He.forEach(function(Ak){return r(I,Ak)}),gt&&Pr(I,tt),Fe}function At(I,z,$,oe){if(typeof $=="object"&&$!==null&&$.type===T&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case w:e:{for(var Fe=$.key;z!==null;){if(z.key===Fe){if(Fe=$.type,Fe===T){if(z.tag===7){a(I,z.sibling),oe=u(z,$.props.children),oe.return=I,I=oe;break e}}else if(z.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===ue&&ya(Fe)===z.type){a(I,z.sibling),oe=u(z,$.props),uo(oe,$),oe.return=I,I=oe;break e}a(I,z);break}else r(I,z);z=z.sibling}$.type===T?(oe=pa($.props.children,I.mode,oe,$.key),oe.return=I,I=oe):(oe=$c($.type,$.key,$.props,null,I.mode,oe),uo(oe,$),oe.return=I,I=oe)}return _(I);case k:e:{for(Fe=$.key;z!==null;){if(z.key===Fe)if(z.tag===4&&z.stateNode.containerInfo===$.containerInfo&&z.stateNode.implementation===$.implementation){a(I,z.sibling),oe=u(z,$.children||[]),oe.return=I,I=oe;break e}else{a(I,z);break}else r(I,z);z=z.sibling}oe=vd($,I.mode,oe),oe.return=I,I=oe}return _(I);case ue:return $=ya($),At(I,z,$,oe)}if(ae($))return ze(I,z,$,oe);if(W($)){if(Fe=W($),typeof Fe!="function")throw Error(s(150));return $=Fe.call($),Ve(I,z,$,oe)}if(typeof $.then=="function")return At(I,z,Jc($),oe);if($.$$typeof===Y)return At(I,z,Xc(I,$),oe);eu(I,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,z!==null&&z.tag===6?(a(I,z.sibling),oe=u(z,$),oe.return=I,I=oe):(a(I,z),oe=_d($,I.mode,oe),oe.return=I,I=oe),_(I)):a(I,z)}return function(I,z,$,oe){try{co=0;var Fe=At(I,z,$,oe);return ul=null,Fe}catch(He){if(He===cl||He===Zc)throw He;var vt=kn(29,He,null,I.mode);return vt.lanes=oe,vt.return=I,vt}}}var Sa=tv(!0),iv=tv(!1),ws=!1;function Md(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Nd(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Cs(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function xs(i,r,a){var o=i.updateQueue;if(o===null)return null;if(o=o.shared,(St&2)!==0){var u=o.pending;return u===null?r.next=r:(r.next=u.next,u.next=r),o.pending=r,r=qc(i),H_(i,null,a),r}return Fc(i,o,r,a),qc(i)}function ho(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194048)!==0)){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,bt(i,a)}}function Ad(i,r){var a=i.updateQueue,o=i.alternate;if(o!==null&&(o=o.updateQueue,a===o)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=r:d=d.next=r}else u=d=r;a={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:o.shared,callbacks:o.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}var Ld=!1;function fo(){if(Ld){var i=ol;if(i!==null)throw i}}function po(i,r,a,o){Ld=!1;var u=i.updateQueue;ws=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,x=u.shared.pending;if(x!==null){u.shared.pending=null;var N=x,V=N.next;N.next=null,_===null?d=V:_.next=V,_=N;var le=i.alternate;le!==null&&(le=le.updateQueue,x=le.lastBaseUpdate,x!==_&&(x===null?le.firstBaseUpdate=V:x.next=V,le.lastBaseUpdate=N))}if(d!==null){var ce=u.baseState;_=0,le=V=N=null,x=d;do{var G=x.lane&-536870913,ee=G!==x.lane;if(ee?(dt&G)===G:(o&G)===G){G!==0&&G===ll&&(Ld=!0),le!==null&&(le=le.next={lane:0,tag:x.tag,payload:x.payload,callback:null,next:null});e:{var ze=i,Ve=x;G=r;var At=a;switch(Ve.tag){case 1:if(ze=Ve.payload,typeof ze=="function"){ce=ze.call(At,ce,G);break e}ce=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=Ve.payload,G=typeof ze=="function"?ze.call(At,ce,G):ze,G==null)break e;ce=y({},ce,G);break e;case 2:ws=!0}}G=x.callback,G!==null&&(i.flags|=64,ee&&(i.flags|=8192),ee=u.callbacks,ee===null?u.callbacks=[G]:ee.push(G))}else ee={lane:G,tag:x.tag,payload:x.payload,callback:x.callback,next:null},le===null?(V=le=ee,N=ce):le=le.next=ee,_|=G;if(x=x.next,x===null){if(x=u.shared.pending,x===null)break;ee=x,x=ee.next,ee.next=null,u.lastBaseUpdate=ee,u.shared.pending=null}}while(!0);le===null&&(N=ce),u.baseState=N,u.firstBaseUpdate=V,u.lastBaseUpdate=le,d===null&&(u.shared.lanes=0),Rs|=_,i.lanes=_,i.memoizedState=ce}}function nv(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function rv(i,r){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)nv(a[i],r)}var hl=M(null),tu=M(0);function sv(i,r){i=Xr,he(tu,i),he(hl,r),Xr=i|r.baseLanes}function Bd(){he(tu,Xr),he(hl,hl.current)}function Od(){Xr=tu.current,Q(hl),Q(tu)}var En=M(null),$n=null;function ks(i){var r=i.alternate;he(ci,ci.current&1),he(En,i),$n===null&&(r===null||hl.current!==null||r.memoizedState!==null)&&($n=i)}function zd(i){he(ci,ci.current),he(En,i),$n===null&&($n=i)}function av(i){i.tag===22?(he(ci,ci.current),he(En,i),$n===null&&($n=i)):Es()}function Es(){he(ci,ci.current),he(En,En.current)}function Tn(i){Q(En),$n===i&&($n=null),Q(ci)}var ci=M(0);function iu(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Wf(a)||Ff(a)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Ur=0,Qe=null,Mt=null,mi=null,nu=!1,dl=!1,wa=!1,ru=0,mo=0,fl=null,wx=0;function ni(){throw Error(s(321))}function jd(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!xn(i[a],r[a]))return!1;return!0}function Pd(i,r,a,o,u,d){return Ur=d,Qe=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,R.H=i===null||i.memoizedState===null?Wv:Jd,wa=!1,d=a(o,u),wa=!1,dl&&(d=ov(r,a,o,u)),lv(i),d}function lv(i){R.H=vo;var r=Mt!==null&&Mt.next!==null;if(Ur=0,mi=Mt=Qe=null,nu=!1,mo=0,fl=null,r)throw Error(s(300));i===null||gi||(i=i.dependencies,i!==null&&Yc(i)&&(gi=!0))}function ov(i,r,a,o){Qe=i;var u=0;do{if(dl&&(fl=null),mo=0,dl=!1,25<=u)throw Error(s(301));if(u+=1,mi=Mt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}R.H=Fv,d=r(a,o)}while(dl);return d}function Cx(){var i=R.H,r=i.useState()[0];return r=typeof r.then=="function"?go(r):r,i=i.useState()[0],(Mt!==null?Mt.memoizedState:null)!==i&&(Qe.flags|=1024),r}function Hd(){var i=ru!==0;return ru=0,i}function Id(i,r,a){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~a}function Ud(i){if(nu){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}nu=!1}Ur=0,mi=Mt=Qe=null,dl=!1,mo=ru=0,fl=null}function on(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mi===null?Qe.memoizedState=mi=i:mi=mi.next=i,mi}function ui(){if(Mt===null){var i=Qe.alternate;i=i!==null?i.memoizedState:null}else i=Mt.next;var r=mi===null?Qe.memoizedState:mi.next;if(r!==null)mi=r,Mt=i;else{if(i===null)throw Qe.alternate===null?Error(s(467)):Error(s(310));Mt=i,i={memoizedState:Mt.memoizedState,baseState:Mt.baseState,baseQueue:Mt.baseQueue,queue:Mt.queue,next:null},mi===null?Qe.memoizedState=mi=i:mi=mi.next=i}return mi}function su(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function go(i){var r=mo;return mo+=1,fl===null&&(fl=[]),i=Q_(fl,i,r),r=Qe,(mi===null?r.memoizedState:mi.next)===null&&(r=r.alternate,R.H=r===null||r.memoizedState===null?Wv:Jd),i}function au(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return go(i);if(i.$$typeof===Y)return Vi(i)}throw Error(s(438,String(i)))}function Kd(i){var r=null,a=Qe.updateQueue;if(a!==null&&(r=a.memoCache),r==null){var o=Qe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(r={data:o.data.map(function(u){return u.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),a===null&&(a=su(),Qe.updateQueue=a),a.memoCache=r,a=r.data[r.index],a===void 0)for(a=r.data[r.index]=Array(i),o=0;o<i;o++)a[o]=U;return r.index++,a}function Kr(i,r){return typeof r=="function"?r(i):r}function lu(i){var r=ui();return Wd(r,Mt,i)}function Wd(i,r,a){var o=i.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=a;var u=i.baseQueue,d=o.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}r.baseQueue=u=d,o.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{r=u.next;var x=_=null,N=null,V=r,le=!1;do{var ce=V.lane&-536870913;if(ce!==V.lane?(dt&ce)===ce:(Ur&ce)===ce){var G=V.revertLane;if(G===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ce===ll&&(le=!0);else if((Ur&G)===G){V=V.next,G===ll&&(le=!0);continue}else ce={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(x=N=ce,_=d):N=N.next=ce,Qe.lanes|=G,Rs|=G;ce=V.action,wa&&a(d,ce),d=V.hasEagerState?V.eagerState:a(d,ce)}else G={lane:ce,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(x=N=G,_=d):N=N.next=G,Qe.lanes|=ce,Rs|=ce;V=V.next}while(V!==null&&V!==r);if(N===null?_=d:N.next=x,!xn(d,i.memoizedState)&&(gi=!0,le&&(a=ol,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,o.lastRenderedState=d}return u===null&&(o.lanes=0),[i.memoizedState,o.dispatch]}function Fd(i){var r=ui(),a=r.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var o=a.dispatch,u=a.pending,d=r.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);xn(d,r.memoizedState)||(gi=!0),r.memoizedState=d,r.baseQueue===null&&(r.baseState=d),a.lastRenderedState=d}return[d,o]}function cv(i,r,a){var o=Qe,u=ui(),d=gt;if(d){if(a===void 0)throw Error(s(407));a=a()}else a=r();var _=!xn((Mt||u).memoizedState,a);if(_&&(u.memoizedState=a,gi=!0),u=u.queue,Vd(dv.bind(null,o,u,i),[i]),u.getSnapshot!==r||_||mi!==null&&mi.memoizedState.tag&1){if(o.flags|=2048,pl(9,{destroy:void 0},hv.bind(null,o,u,a,r),null),Ot===null)throw Error(s(349));d||(Ur&127)!==0||uv(o,r,a)}return a}function uv(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=Qe.updateQueue,r===null?(r=su(),Qe.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function hv(i,r,a,o){r.value=a,r.getSnapshot=o,fv(r)&&pv(i)}function dv(i,r,a){return a(function(){fv(r)&&pv(i)})}function fv(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!xn(i,a)}catch{return!0}}function pv(i){var r=fa(i,2);r!==null&&yn(r,i,2)}function qd(i){var r=on();if(typeof i=="function"){var a=i;if(i=a(),wa){Rt(!0);try{a()}finally{Rt(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kr,lastRenderedState:i},r}function mv(i,r,a,o){return i.baseState=a,Wd(i,Mt,typeof o=="function"?o:Kr)}function xx(i,r,a,o,u){if(uu(i))throw Error(s(485));if(i=r.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};R.T!==null?a(!0):d.isTransition=!1,o(d),a=r.pending,a===null?(d.next=r.pending=d,gv(r,d)):(d.next=a.next,r.pending=a.next=d)}}function gv(i,r){var a=r.action,o=r.payload,u=i.state;if(r.isTransition){var d=R.T,_={};R.T=_;try{var x=a(u,o),N=R.S;N!==null&&N(_,x),_v(i,r,x)}catch(V){$d(i,r,V)}finally{d!==null&&_.types!==null&&(d.types=_.types),R.T=d}}else try{d=a(u,o),_v(i,r,d)}catch(V){$d(i,r,V)}}function _v(i,r,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(o){vv(i,r,o)},function(o){return $d(i,r,o)}):vv(i,r,a)}function vv(i,r,a){r.status="fulfilled",r.value=a,yv(r),i.state=a,r=i.pending,r!==null&&(a=r.next,a===r?i.pending=null:(a=a.next,r.next=a,gv(i,a)))}function $d(i,r,a){var o=i.pending;if(i.pending=null,o!==null){o=o.next;do r.status="rejected",r.reason=a,yv(r),r=r.next;while(r!==o)}i.action=null}function yv(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function bv(i,r){return r}function Sv(i,r){if(gt){var a=Ot.formState;if(a!==null){e:{var o=Qe;if(gt){if(Kt){t:{for(var u=Kt,d=qn;u.nodeType!==8;){if(!d){u=null;break t}if(u=Vn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){Kt=Vn(u.nextSibling),o=u.data==="F!";break e}}bs(o)}o=!1}o&&(r=a[0])}}return a=on(),a.memoizedState=a.baseState=r,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bv,lastRenderedState:r},a.queue=o,a=Iv.bind(null,Qe,o),o.dispatch=a,o=qd(!1),d=Qd.bind(null,Qe,!1,o.queue),o=on(),u={state:r,dispatch:null,action:i,pending:null},o.queue=u,a=xx.bind(null,Qe,u,d,a),u.dispatch=a,o.memoizedState=i,[r,a,!1]}function wv(i){var r=ui();return Cv(r,Mt,i)}function Cv(i,r,a){if(r=Wd(i,r,bv)[0],i=lu(Kr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var o=go(r)}catch(_){throw _===cl?Zc:_}else o=r;r=ui();var u=r.queue,d=u.dispatch;return a!==r.memoizedState&&(Qe.flags|=2048,pl(9,{destroy:void 0},kx.bind(null,u,a),null)),[o,d,i]}function kx(i,r){i.action=r}function xv(i){var r=ui(),a=Mt;if(a!==null)return Cv(r,a,i);ui(),r=r.memoizedState,a=ui();var o=a.queue.dispatch;return a.memoizedState=i,[r,o,!1]}function pl(i,r,a,o){return i={tag:i,create:a,deps:o,inst:r,next:null},r=Qe.updateQueue,r===null&&(r=su(),Qe.updateQueue=r),a=r.lastEffect,a===null?r.lastEffect=i.next=i:(o=a.next,a.next=i,i.next=o,r.lastEffect=i),i}function kv(){return ui().memoizedState}function ou(i,r,a,o){var u=on();Qe.flags|=i,u.memoizedState=pl(1|r,{destroy:void 0},a,o===void 0?null:o)}function cu(i,r,a,o){var u=ui();o=o===void 0?null:o;var d=u.memoizedState.inst;Mt!==null&&o!==null&&jd(o,Mt.memoizedState.deps)?u.memoizedState=pl(r,d,a,o):(Qe.flags|=i,u.memoizedState=pl(1|r,d,a,o))}function Ev(i,r){ou(8390656,8,i,r)}function Vd(i,r){cu(2048,8,i,r)}function Ex(i){Qe.flags|=4;var r=Qe.updateQueue;if(r===null)r=su(),Qe.updateQueue=r,r.events=[i];else{var a=r.events;a===null?r.events=[i]:a.push(i)}}function Tv(i){var r=ui().memoizedState;return Ex({ref:r,nextImpl:i}),function(){if((St&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function Dv(i,r){return cu(4,2,i,r)}function Rv(i,r){return cu(4,4,i,r)}function Mv(i,r){if(typeof r=="function"){i=i();var a=r(i);return function(){typeof a=="function"?a():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Nv(i,r,a){a=a!=null?a.concat([i]):null,cu(4,4,Mv.bind(null,r,i),a)}function Yd(){}function Av(i,r){var a=ui();r=r===void 0?null:r;var o=a.memoizedState;return r!==null&&jd(r,o[1])?o[0]:(a.memoizedState=[i,r],i)}function Lv(i,r){var a=ui();r=r===void 0?null:r;var o=a.memoizedState;if(r!==null&&jd(r,o[1]))return o[0];if(o=i(),wa){Rt(!0);try{i()}finally{Rt(!1)}}return a.memoizedState=[o,r],o}function Xd(i,r,a){return a===void 0||(Ur&1073741824)!==0&&(dt&261930)===0?i.memoizedState=r:(i.memoizedState=a,i=By(),Qe.lanes|=i,Rs|=i,a)}function Bv(i,r,a,o){return xn(a,r)?a:hl.current!==null?(i=Xd(i,a,o),xn(i,r)||(gi=!0),i):(Ur&42)===0||(Ur&1073741824)!==0&&(dt&261930)===0?(gi=!0,i.memoizedState=a):(i=By(),Qe.lanes|=i,Rs|=i,r)}function Ov(i,r,a,o,u){var d=X.p;X.p=d!==0&&8>d?d:8;var _=R.T,x={};R.T=x,Qd(i,!1,r,a);try{var N=u(),V=R.S;if(V!==null&&V(x,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var le=Sx(N,o);_o(i,r,le,Mn(i))}else _o(i,r,o,Mn(i))}catch(ce){_o(i,r,{then:function(){},status:"rejected",reason:ce},Mn())}finally{X.p=d,_!==null&&x.types!==null&&(_.types=x.types),R.T=_}}function Tx(){}function Gd(i,r,a,o){if(i.tag!==5)throw Error(s(476));var u=zv(i).queue;Ov(i,u,r,Z,a===null?Tx:function(){return jv(i),a(o)})}function zv(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kr,lastRenderedState:Z},next:null};var a={};return r.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kr,lastRenderedState:a},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function jv(i){var r=zv(i);r.next===null&&(r=i.alternate.memoizedState),_o(i,r.next.queue,{},Mn())}function Zd(){return Vi(Bo)}function Pv(){return ui().memoizedState}function Hv(){return ui().memoizedState}function Dx(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var a=Mn();i=Cs(a);var o=xs(r,i,a);o!==null&&(yn(o,r,a),ho(o,r,a)),r={cache:Ed()},i.payload=r;return}r=r.return}}function Rx(i,r,a){var o=Mn();a={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},uu(i)?Uv(r,a):(a=md(i,r,a,o),a!==null&&(yn(a,i,o),Kv(a,r,o)))}function Iv(i,r,a){var o=Mn();_o(i,r,a,o)}function _o(i,r,a,o){var u={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(uu(i))Uv(r,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=r.lastRenderedReducer,d!==null))try{var _=r.lastRenderedState,x=d(_,a);if(u.hasEagerState=!0,u.eagerState=x,xn(x,_))return Fc(i,r,u,0),Ot===null&&Wc(),!1}catch{}if(a=md(i,r,u,o),a!==null)return yn(a,i,o),Kv(a,r,o),!0}return!1}function Qd(i,r,a,o){if(o={lane:2,revertLane:Nf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},uu(i)){if(r)throw Error(s(479))}else r=md(i,a,o,2),r!==null&&yn(r,i,2)}function uu(i){var r=i.alternate;return i===Qe||r!==null&&r===Qe}function Uv(i,r){dl=nu=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function Kv(i,r,a){if((a&4194048)!==0){var o=r.lanes;o&=i.pendingLanes,a|=o,r.lanes=a,bt(i,a)}}var vo={readContext:Vi,use:au,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};vo.useEffectEvent=ni;var Wv={readContext:Vi,use:au,useCallback:function(i,r){return on().memoizedState=[i,r===void 0?null:r],i},useContext:Vi,useEffect:Ev,useImperativeHandle:function(i,r,a){a=a!=null?a.concat([i]):null,ou(4194308,4,Mv.bind(null,r,i),a)},useLayoutEffect:function(i,r){return ou(4194308,4,i,r)},useInsertionEffect:function(i,r){ou(4,2,i,r)},useMemo:function(i,r){var a=on();r=r===void 0?null:r;var o=i();if(wa){Rt(!0);try{i()}finally{Rt(!1)}}return a.memoizedState=[o,r],o},useReducer:function(i,r,a){var o=on();if(a!==void 0){var u=a(r);if(wa){Rt(!0);try{a(r)}finally{Rt(!1)}}}else u=r;return o.memoizedState=o.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},o.queue=i,i=i.dispatch=Rx.bind(null,Qe,i),[o.memoizedState,i]},useRef:function(i){var r=on();return i={current:i},r.memoizedState=i},useState:function(i){i=qd(i);var r=i.queue,a=Iv.bind(null,Qe,r);return r.dispatch=a,[i.memoizedState,a]},useDebugValue:Yd,useDeferredValue:function(i,r){var a=on();return Xd(a,i,r)},useTransition:function(){var i=qd(!1);return i=Ov.bind(null,Qe,i.queue,!0,!1),on().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,a){var o=Qe,u=on();if(gt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=r(),Ot===null)throw Error(s(349));(dt&127)!==0||uv(o,r,a)}u.memoizedState=a;var d={value:a,getSnapshot:r};return u.queue=d,Ev(dv.bind(null,o,d,i),[i]),o.flags|=2048,pl(9,{destroy:void 0},hv.bind(null,o,d,a,r),null),a},useId:function(){var i=on(),r=Ot.identifierPrefix;if(gt){var a=wr,o=Sr;a=(o&~(1<<32-F(o)-1)).toString(32)+a,r="_"+r+"R_"+a,a=ru++,0<a&&(r+="H"+a.toString(32)),r+="_"}else a=wx++,r="_"+r+"r_"+a.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:Zd,useFormState:Sv,useActionState:Sv,useOptimistic:function(i){var r=on();r.memoizedState=r.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=a,r=Qd.bind(null,Qe,!0,a),a.dispatch=r,[i,r]},useMemoCache:Kd,useCacheRefresh:function(){return on().memoizedState=Dx.bind(null,Qe)},useEffectEvent:function(i){var r=on(),a={impl:i};return r.memoizedState=a,function(){if((St&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Jd={readContext:Vi,use:au,useCallback:Av,useContext:Vi,useEffect:Vd,useImperativeHandle:Nv,useInsertionEffect:Dv,useLayoutEffect:Rv,useMemo:Lv,useReducer:lu,useRef:kv,useState:function(){return lu(Kr)},useDebugValue:Yd,useDeferredValue:function(i,r){var a=ui();return Bv(a,Mt.memoizedState,i,r)},useTransition:function(){var i=lu(Kr)[0],r=ui().memoizedState;return[typeof i=="boolean"?i:go(i),r]},useSyncExternalStore:cv,useId:Pv,useHostTransitionStatus:Zd,useFormState:wv,useActionState:wv,useOptimistic:function(i,r){var a=ui();return mv(a,Mt,i,r)},useMemoCache:Kd,useCacheRefresh:Hv};Jd.useEffectEvent=Tv;var Fv={readContext:Vi,use:au,useCallback:Av,useContext:Vi,useEffect:Vd,useImperativeHandle:Nv,useInsertionEffect:Dv,useLayoutEffect:Rv,useMemo:Lv,useReducer:Fd,useRef:kv,useState:function(){return Fd(Kr)},useDebugValue:Yd,useDeferredValue:function(i,r){var a=ui();return Mt===null?Xd(a,i,r):Bv(a,Mt.memoizedState,i,r)},useTransition:function(){var i=Fd(Kr)[0],r=ui().memoizedState;return[typeof i=="boolean"?i:go(i),r]},useSyncExternalStore:cv,useId:Pv,useHostTransitionStatus:Zd,useFormState:xv,useActionState:xv,useOptimistic:function(i,r){var a=ui();return Mt!==null?mv(a,Mt,i,r):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Kd,useCacheRefresh:Hv};Fv.useEffectEvent=Tv;function ef(i,r,a,o){r=i.memoizedState,a=a(o,r),a=a==null?r:y({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var tf={enqueueSetState:function(i,r,a){i=i._reactInternals;var o=Mn(),u=Cs(o);u.payload=r,a!=null&&(u.callback=a),r=xs(i,u,o),r!==null&&(yn(r,i,o),ho(r,i,o))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var o=Mn(),u=Cs(o);u.tag=1,u.payload=r,a!=null&&(u.callback=a),r=xs(i,u,o),r!==null&&(yn(r,i,o),ho(r,i,o))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Mn(),o=Cs(a);o.tag=2,r!=null&&(o.callback=r),r=xs(i,o,a),r!==null&&(yn(r,i,a),ho(r,i,a))}};function qv(i,r,a,o,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(o,d,_):r.prototype&&r.prototype.isPureReactComponent?!no(a,o)||!no(u,d):!0}function $v(i,r,a,o){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,o),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,o),r.state!==i&&tf.enqueueReplaceState(r,r.state,null)}function Ca(i,r){var a=r;if("ref"in r){a={};for(var o in r)o!=="ref"&&(a[o]=r[o])}if(i=i.defaultProps){a===r&&(a=y({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Vv(i){Kc(i)}function Yv(i){console.error(i)}function Xv(i){Kc(i)}function hu(i,r){try{var a=i.onUncaughtError;a(r.value,{componentStack:r.stack})}catch(o){setTimeout(function(){throw o})}}function Gv(i,r,a){try{var o=i.onCaughtError;o(a.value,{componentStack:a.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function nf(i,r,a){return a=Cs(a),a.tag=3,a.payload={element:null},a.callback=function(){hu(i,r)},a}function Zv(i){return i=Cs(i),i.tag=3,i}function Qv(i,r,a,o){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=o.value;i.payload=function(){return u(d)},i.callback=function(){Gv(r,a,o)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Gv(r,a,o),typeof u!="function"&&(Ms===null?Ms=new Set([this]):Ms.add(this));var x=o.stack;this.componentDidCatch(o.value,{componentStack:x!==null?x:""})})}function Mx(i,r,a,o,u){if(a.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(r=a.alternate,r!==null&&al(r,a,u,!0),a=En.current,a!==null){switch(a.tag){case 31:case 13:return $n===null?Cu():a.alternate===null&&ri===0&&(ri=3),a.flags&=-257,a.flags|=65536,a.lanes=u,o===Qc?a.flags|=16384:(r=a.updateQueue,r===null?a.updateQueue=new Set([o]):r.add(o),Df(i,o,u)),!1;case 22:return a.flags|=65536,o===Qc?a.flags|=16384:(r=a.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([o])},a.updateQueue=r):(a=r.retryQueue,a===null?r.retryQueue=new Set([o]):a.add(o)),Df(i,o,u)),!1}throw Error(s(435,a.tag))}return Df(i,o,u),Cu(),!1}if(gt)return r=En.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=u,o!==Sd&&(i=Error(s(422),{cause:o}),ao(Kn(i,a)))):(o!==Sd&&(r=Error(s(423),{cause:o}),ao(Kn(r,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,o=Kn(o,a),u=nf(i.stateNode,o,u),Ad(i,u),ri!==4&&(ri=2)),!1;var d=Error(s(520),{cause:o});if(d=Kn(d,a),Eo===null?Eo=[d]:Eo.push(d),ri!==4&&(ri=2),r===null)return!0;o=Kn(o,a),a=r;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=nf(a.stateNode,o,i),Ad(a,i),!1;case 1:if(r=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(Ms===null||!Ms.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=Zv(u),Qv(u,i,a,o),Ad(a,u),!1}a=a.return}while(a!==null);return!1}var rf=Error(s(461)),gi=!1;function Yi(i,r,a,o){r.child=i===null?iv(r,null,a,o):Sa(r,i.child,a,o)}function Jv(i,r,a,o,u){a=a.render;var d=r.ref;if("ref"in o){var _={};for(var x in o)x!=="ref"&&(_[x]=o[x])}else _=o;return _a(r),o=Pd(i,r,a,_,d,u),x=Hd(),i!==null&&!gi?(Id(i,r,u),Wr(i,r,u)):(gt&&x&&yd(r),r.flags|=1,Yi(i,r,o,u),r.child)}function ey(i,r,a,o,u){if(i===null){var d=a.type;return typeof d=="function"&&!gd(d)&&d.defaultProps===void 0&&a.compare===null?(r.tag=15,r.type=d,ty(i,r,d,o,u)):(i=$c(a.type,null,o,r,r.mode,u),i.ref=r.ref,i.return=r,r.child=i)}if(d=i.child,!df(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:no,a(_,o)&&i.ref===r.ref)return Wr(i,r,u)}return r.flags|=1,i=jr(d,o),i.ref=r.ref,i.return=r,r.child=i}function ty(i,r,a,o,u){if(i!==null){var d=i.memoizedProps;if(no(d,o)&&i.ref===r.ref)if(gi=!1,r.pendingProps=o=d,df(i,u))(i.flags&131072)!==0&&(gi=!0);else return r.lanes=i.lanes,Wr(i,r,u)}return sf(i,r,a,o,u)}function iy(i,r,a,o){var u=o.children,d=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((r.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(o=r.child=i.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~d}else o=0,r.child=null;return ny(i,r,d,a,o)}if((a&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Gc(r,d!==null?d.cachePool:null),d!==null?sv(r,d):Bd(),av(r);else return o=r.lanes=536870912,ny(i,r,d!==null?d.baseLanes|a:a,a,o)}else d!==null?(Gc(r,d.cachePool),sv(r,d),Es(),r.memoizedState=null):(i!==null&&Gc(r,null),Bd(),Es());return Yi(i,r,u,a),r.child}function yo(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function ny(i,r,a,o,u){var d=Dd();return d=d===null?null:{parent:pi._currentValue,pool:d},r.memoizedState={baseLanes:a,cachePool:d},i!==null&&Gc(r,null),Bd(),av(r),i!==null&&al(i,r,o,!0),r.childLanes=u,null}function du(i,r){return r=pu({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function ry(i,r,a){return Sa(r,i.child,null,a),i=du(r,r.pendingProps),i.flags|=2,Tn(r),r.memoizedState=null,i}function Nx(i,r,a){var o=r.pendingProps,u=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(gt){if(o.mode==="hidden")return i=du(r,o),r.lanes=536870912,yo(null,i);if(zd(r),(i=Kt)?(i=gb(i,qn),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:vs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},a=U_(i),a.return=r,r.child=a,$i=r,Kt=null)):i=null,i===null)throw bs(r);return r.lanes=536870912,null}return du(r,o)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(zd(r),u)if(r.flags&256)r.flags&=-257,r=ry(i,r,a);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(s(558));else if(gi||al(i,r,a,!1),u=(a&i.childLanes)!==0,gi||u){if(o=Ot,o!==null&&(_=oi(o,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,fa(i,_),yn(o,i,_),rf;Cu(),r=ry(i,r,a)}else i=d.treeContext,Kt=Vn(_.nextSibling),$i=r,gt=!0,ys=null,qn=!1,i!==null&&F_(r,i),r=du(r,o),r.flags|=4096;return r}return i=jr(i.child,{mode:o.mode,children:o.children}),i.ref=r.ref,r.child=i,i.return=r,i}function fu(i,r){var a=r.ref;if(a===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(r.flags|=4194816)}}function sf(i,r,a,o,u){return _a(r),a=Pd(i,r,a,o,void 0,u),o=Hd(),i!==null&&!gi?(Id(i,r,u),Wr(i,r,u)):(gt&&o&&yd(r),r.flags|=1,Yi(i,r,a,u),r.child)}function sy(i,r,a,o,u,d){return _a(r),r.updateQueue=null,a=ov(r,o,a,u),lv(i),o=Hd(),i!==null&&!gi?(Id(i,r,d),Wr(i,r,d)):(gt&&o&&yd(r),r.flags|=1,Yi(i,r,a,d),r.child)}function ay(i,r,a,o,u){if(_a(r),r.stateNode===null){var d=il,_=a.contextType;typeof _=="object"&&_!==null&&(d=Vi(_)),d=new a(o,d),r.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=tf,r.stateNode=d,d._reactInternals=r,d=r.stateNode,d.props=o,d.state=r.memoizedState,d.refs={},Md(r),_=a.contextType,d.context=typeof _=="object"&&_!==null?Vi(_):il,d.state=r.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(ef(r,a,_,o),d.state=r.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&tf.enqueueReplaceState(d,d.state,null),po(r,o,d,u),fo(),d.state=r.memoizedState),typeof d.componentDidMount=="function"&&(r.flags|=4194308),o=!0}else if(i===null){d=r.stateNode;var x=r.memoizedProps,N=Ca(a,x);d.props=N;var V=d.context,le=a.contextType;_=il,typeof le=="object"&&le!==null&&(_=Vi(le));var ce=a.getDerivedStateFromProps;le=typeof ce=="function"||typeof d.getSnapshotBeforeUpdate=="function",x=r.pendingProps!==x,le||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(x||V!==_)&&$v(r,d,o,_),ws=!1;var G=r.memoizedState;d.state=G,po(r,o,d,u),fo(),V=r.memoizedState,x||G!==V||ws?(typeof ce=="function"&&(ef(r,a,ce,o),V=r.memoizedState),(N=ws||qv(r,a,N,o,G,V,_))?(le||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(r.flags|=4194308)):(typeof d.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=o,r.memoizedState=V),d.props=o,d.state=V,d.context=_,o=N):(typeof d.componentDidMount=="function"&&(r.flags|=4194308),o=!1)}else{d=r.stateNode,Nd(i,r),_=r.memoizedProps,le=Ca(a,_),d.props=le,ce=r.pendingProps,G=d.context,V=a.contextType,N=il,typeof V=="object"&&V!==null&&(N=Vi(V)),x=a.getDerivedStateFromProps,(V=typeof x=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==ce||G!==N)&&$v(r,d,o,N),ws=!1,G=r.memoizedState,d.state=G,po(r,o,d,u),fo();var ee=r.memoizedState;_!==ce||G!==ee||ws||i!==null&&i.dependencies!==null&&Yc(i.dependencies)?(typeof x=="function"&&(ef(r,a,x,o),ee=r.memoizedState),(le=ws||qv(r,a,le,o,G,ee,N)||i!==null&&i.dependencies!==null&&Yc(i.dependencies))?(V||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(o,ee,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(o,ee,N)),typeof d.componentDidUpdate=="function"&&(r.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(r.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(r.flags|=1024),r.memoizedProps=o,r.memoizedState=ee),d.props=o,d.state=ee,d.context=N,o=le):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(r.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(r.flags|=1024),o=!1)}return d=o,fu(i,r),o=(r.flags&128)!==0,d||o?(d=r.stateNode,a=o&&typeof a.getDerivedStateFromError!="function"?null:d.render(),r.flags|=1,i!==null&&o?(r.child=Sa(r,i.child,null,u),r.child=Sa(r,null,a,u)):Yi(i,r,a,u),r.memoizedState=d.state,i=r.child):i=Wr(i,r,u),i}function ly(i,r,a,o){return ma(),r.flags|=256,Yi(i,r,a,o),r.child}var af={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function lf(i){return{baseLanes:i,cachePool:G_()}}function of(i,r,a){return i=i!==null?i.childLanes&~a:0,r&&(i|=Rn),i}function oy(i,r,a){var o=r.pendingProps,u=!1,d=(r.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(ci.current&2)!==0),_&&(u=!0,r.flags&=-129),_=(r.flags&32)!==0,r.flags&=-33,i===null){if(gt){if(u?ks(r):Es(),(i=Kt)?(i=gb(i,qn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:vs!==null?{id:Sr,overflow:wr}:null,retryLane:536870912,hydrationErrors:null},a=U_(i),a.return=r,r.child=a,$i=r,Kt=null)):i=null,i===null)throw bs(r);return Ff(i)?r.lanes=32:r.lanes=536870912,null}var x=o.children;return o=o.fallback,u?(Es(),u=r.mode,x=pu({mode:"hidden",children:x},u),o=pa(o,u,a,null),x.return=r,o.return=r,x.sibling=o,r.child=x,o=r.child,o.memoizedState=lf(a),o.childLanes=of(i,_,a),r.memoizedState=af,yo(null,o)):(ks(r),cf(r,x))}var N=i.memoizedState;if(N!==null&&(x=N.dehydrated,x!==null)){if(d)r.flags&256?(ks(r),r.flags&=-257,r=uf(i,r,a)):r.memoizedState!==null?(Es(),r.child=i.child,r.flags|=128,r=null):(Es(),x=o.fallback,u=r.mode,o=pu({mode:"visible",children:o.children},u),x=pa(x,u,a,null),x.flags|=2,o.return=r,x.return=r,o.sibling=x,r.child=o,Sa(r,i.child,null,a),o=r.child,o.memoizedState=lf(a),o.childLanes=of(i,_,a),r.memoizedState=af,r=yo(null,o));else if(ks(r),Ff(x)){if(_=x.nextSibling&&x.nextSibling.dataset,_)var V=_.dgst;_=V,o=Error(s(419)),o.stack="",o.digest=_,ao({value:o,source:null,stack:null}),r=uf(i,r,a)}else if(gi||al(i,r,a,!1),_=(a&i.childLanes)!==0,gi||_){if(_=Ot,_!==null&&(o=oi(_,a),o!==0&&o!==N.retryLane))throw N.retryLane=o,fa(i,o),yn(_,i,o),rf;Wf(x)||Cu(),r=uf(i,r,a)}else Wf(x)?(r.flags|=192,r.child=i.child,r=null):(i=N.treeContext,Kt=Vn(x.nextSibling),$i=r,gt=!0,ys=null,qn=!1,i!==null&&F_(r,i),r=cf(r,o.children),r.flags|=4096);return r}return u?(Es(),x=o.fallback,u=r.mode,N=i.child,V=N.sibling,o=jr(N,{mode:"hidden",children:o.children}),o.subtreeFlags=N.subtreeFlags&65011712,V!==null?x=jr(V,x):(x=pa(x,u,a,null),x.flags|=2),x.return=r,o.return=r,o.sibling=x,r.child=o,yo(null,o),o=r.child,x=i.child.memoizedState,x===null?x=lf(a):(u=x.cachePool,u!==null?(N=pi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=G_(),x={baseLanes:x.baseLanes|a,cachePool:u}),o.memoizedState=x,o.childLanes=of(i,_,a),r.memoizedState=af,yo(i.child,o)):(ks(r),a=i.child,i=a.sibling,a=jr(a,{mode:"visible",children:o.children}),a.return=r,a.sibling=null,i!==null&&(_=r.deletions,_===null?(r.deletions=[i],r.flags|=16):_.push(i)),r.child=a,r.memoizedState=null,a)}function cf(i,r){return r=pu({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function pu(i,r){return i=kn(22,i,null,r),i.lanes=0,i}function uf(i,r,a){return Sa(r,i.child,null,a),i=cf(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function cy(i,r,a){i.lanes|=r;var o=i.alternate;o!==null&&(o.lanes|=r),xd(i.return,r,a)}function hf(i,r,a,o,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:o,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=o,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function uy(i,r,a){var o=r.pendingProps,u=o.revealOrder,d=o.tail;o=o.children;var _=ci.current,x=(_&2)!==0;if(x?(_=_&1|2,r.flags|=128):_&=1,he(ci,_),Yi(i,r,o,a),o=gt?so:0,!x&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&cy(i,a,r);else if(i.tag===19)cy(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=r.child,u=null;a!==null;)i=a.alternate,i!==null&&iu(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=r.child,r.child=null):(u=a.sibling,a.sibling=null),hf(r,!1,u,a,d,o);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=r.child,r.child=null;u!==null;){if(i=u.alternate,i!==null&&iu(i)===null){r.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}hf(r,!0,a,null,d,o);break;case"together":hf(r,!1,null,null,void 0,o);break;default:r.memoizedState=null}return r.child}function Wr(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Rs|=r.lanes,(a&r.childLanes)===0)if(i!==null){if(al(i,r,a,!1),(a&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(s(153));if(r.child!==null){for(i=r.child,a=jr(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=jr(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function df(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&Yc(i)))}function Ax(i,r,a){switch(r.tag){case 3:De(r,r.stateNode.containerInfo),Ss(r,pi,i.memoizedState.cache),ma();break;case 27:case 5:se(r);break;case 4:De(r,r.stateNode.containerInfo);break;case 10:Ss(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,zd(r),null;break;case 13:var o=r.memoizedState;if(o!==null)return o.dehydrated!==null?(ks(r),r.flags|=128,null):(a&r.child.childLanes)!==0?oy(i,r,a):(ks(r),i=Wr(i,r,a),i!==null?i.sibling:null);ks(r);break;case 19:var u=(i.flags&128)!==0;if(o=(a&r.childLanes)!==0,o||(al(i,r,a,!1),o=(a&r.childLanes)!==0),u){if(o)return uy(i,r,a);r.flags|=128}if(u=r.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),he(ci,ci.current),o)break;return null;case 22:return r.lanes=0,iy(i,r,a,r.pendingProps);case 24:Ss(r,pi,i.memoizedState.cache)}return Wr(i,r,a)}function hy(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps)gi=!0;else{if(!df(i,a)&&(r.flags&128)===0)return gi=!1,Ax(i,r,a);gi=(i.flags&131072)!==0}else gi=!1,gt&&(r.flags&1048576)!==0&&W_(r,so,r.index);switch(r.lanes=0,r.tag){case 16:e:{var o=r.pendingProps;if(i=ya(r.elementType),r.type=i,typeof i=="function")gd(i)?(o=Ca(i,o),r.tag=1,r=ay(null,r,i,o,a)):(r.tag=0,r=sf(null,r,i,o,a));else{if(i!=null){var u=i.$$typeof;if(u===P){r.tag=11,r=Jv(null,r,i,o,a);break e}else if(u===ne){r.tag=14,r=ey(null,r,i,o,a);break e}}throw r=j(i)||i,Error(s(306,r,""))}}return r;case 0:return sf(i,r,r.type,r.pendingProps,a);case 1:return o=r.type,u=Ca(o,r.pendingProps),ay(i,r,o,u,a);case 3:e:{if(De(r,r.stateNode.containerInfo),i===null)throw Error(s(387));o=r.pendingProps;var d=r.memoizedState;u=d.element,Nd(i,r),po(r,o,null,a);var _=r.memoizedState;if(o=_.cache,Ss(r,pi,o),o!==d.cache&&kd(r,[pi],a,!0),fo(),o=_.element,d.isDehydrated)if(d={element:o,isDehydrated:!1,cache:_.cache},r.updateQueue.baseState=d,r.memoizedState=d,r.flags&256){r=ly(i,r,o,a);break e}else if(o!==u){u=Kn(Error(s(424)),r),ao(u),r=ly(i,r,o,a);break e}else for(i=r.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Kt=Vn(i.firstChild),$i=r,gt=!0,ys=null,qn=!0,a=iv(r,null,o,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(ma(),o===u){r=Wr(i,r,a);break e}Yi(i,r,o,a)}r=r.child}return r;case 26:return fu(i,r),i===null?(a=wb(r.type,null,r.pendingProps,null))?r.memoizedState=a:gt||(a=r.type,i=r.pendingProps,o=Mu(Se.current).createElement(a),o[ei]=r,o[xi]=i,Xi(o,a,i),It(o),r.stateNode=o):r.memoizedState=wb(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return se(r),i===null&&gt&&(o=r.stateNode=yb(r.type,r.pendingProps,Se.current),$i=r,qn=!0,u=Kt,Bs(r.type)?(qf=u,Kt=Vn(o.firstChild)):Kt=u),Yi(i,r,r.pendingProps.children,a),fu(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&gt&&((u=o=Kt)&&(o=ok(o,r.type,r.pendingProps,qn),o!==null?(r.stateNode=o,$i=r,Kt=Vn(o.firstChild),qn=!1,u=!0):u=!1),u||bs(r)),se(r),u=r.type,d=r.pendingProps,_=i!==null?i.memoizedProps:null,o=d.children,If(u,d)?o=null:_!==null&&If(u,_)&&(r.flags|=32),r.memoizedState!==null&&(u=Pd(i,r,Cx,null,null,a),Bo._currentValue=u),fu(i,r),Yi(i,r,o,a),r.child;case 6:return i===null&&gt&&((i=a=Kt)&&(a=ck(a,r.pendingProps,qn),a!==null?(r.stateNode=a,$i=r,Kt=null,i=!0):i=!1),i||bs(r)),null;case 13:return oy(i,r,a);case 4:return De(r,r.stateNode.containerInfo),o=r.pendingProps,i===null?r.child=Sa(r,null,o,a):Yi(i,r,o,a),r.child;case 11:return Jv(i,r,r.type,r.pendingProps,a);case 7:return Yi(i,r,r.pendingProps,a),r.child;case 8:return Yi(i,r,r.pendingProps.children,a),r.child;case 12:return Yi(i,r,r.pendingProps.children,a),r.child;case 10:return o=r.pendingProps,Ss(r,r.type,o.value),Yi(i,r,o.children,a),r.child;case 9:return u=r.type._context,o=r.pendingProps.children,_a(r),u=Vi(u),o=o(u),r.flags|=1,Yi(i,r,o,a),r.child;case 14:return ey(i,r,r.type,r.pendingProps,a);case 15:return ty(i,r,r.type,r.pendingProps,a);case 19:return uy(i,r,a);case 31:return Nx(i,r,a);case 22:return iy(i,r,a,r.pendingProps);case 24:return _a(r),o=Vi(pi),i===null?(u=Dd(),u===null&&(u=Ot,d=Ed(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),r.memoizedState={parent:o,cache:u},Md(r),Ss(r,pi,u)):((i.lanes&a)!==0&&(Nd(i,r),po(r,null,null,a),fo()),u=i.memoizedState,d=r.memoizedState,u.parent!==o?(u={parent:o,cache:o},r.memoizedState=u,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=u),Ss(r,pi,o)):(o=d.cache,Ss(r,pi,o),o!==u.cache&&kd(r,[pi],a,!0))),Yi(i,r,r.pendingProps.children,a),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Fr(i){i.flags|=4}function ff(i,r,a,o,u){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(Py())i.flags|=8192;else throw ba=Qc,Rd}else i.flags&=-16777217}function dy(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Tb(r))if(Py())i.flags|=8192;else throw ba=Qc,Rd}function mu(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?jt():536870912,i.lanes|=r,vl|=r)}function bo(i,r){if(!gt)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:o.sibling=null}}function Wt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,o=0;if(r)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=o,i.childLanes=a,r}function Lx(i,r,a){var o=r.pendingProps;switch(bd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wt(r),null;case 1:return Wt(r),null;case 3:return a=r.stateNode,o=null,i!==null&&(o=i.memoizedState.cache),r.memoizedState.cache!==o&&(r.flags|=2048),Ir(pi),Ie(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(sl(r)?Fr(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,wd())),Wt(r),null;case 26:var u=r.type,d=r.memoizedState;return i===null?(Fr(r),d!==null?(Wt(r),dy(r,d)):(Wt(r),ff(r,u,null,o,a))):d?d!==i.memoizedState?(Fr(r),Wt(r),dy(r,d)):(Wt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==o&&Fr(r),Wt(r),ff(r,u,i,o,a)),null;case 27:if(me(r),a=Se.current,u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&Fr(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}i=ge.current,sl(r)?q_(r):(i=yb(u,o,a),r.stateNode=i,Fr(r))}return Wt(r),null;case 5:if(me(r),u=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==o&&Fr(r);else{if(!o){if(r.stateNode===null)throw Error(s(166));return Wt(r),null}if(d=ge.current,sl(r))q_(r);else{var _=Mu(Se.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof o.is=="string"?_.createElement("select",{is:o.is}):_.createElement("select"),o.multiple?d.multiple=!0:o.size&&(d.size=o.size);break;default:d=typeof o.is=="string"?_.createElement(u,{is:o.is}):_.createElement(u)}}d[ei]=r,d[xi]=o;e:for(_=r.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===r)break e;for(;_.sibling===null;){if(_.return===null||_.return===r)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}r.stateNode=d;e:switch(Xi(d,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Fr(r)}}return Wt(r),ff(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,a),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==o&&Fr(r);else{if(typeof o!="string"&&r.stateNode===null)throw Error(s(166));if(i=Se.current,sl(r)){if(i=r.stateNode,a=r.memoizedProps,o=null,u=$i,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}i[ei]=r,i=!!(i.nodeValue===a||o!==null&&o.suppressHydrationWarning===!0||ob(i.nodeValue,a)),i||bs(r,!0)}else i=Mu(i).createTextNode(o),i[ei]=r,r.stateNode=i}return Wt(r),null;case 31:if(a=r.memoizedState,i===null||i.memoizedState!==null){if(o=sl(r),a!==null){if(i===null){if(!o)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[ei]=r}else ma(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),i=!1}else a=wd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return r.flags&256?(Tn(r),r):(Tn(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Wt(r),null;case 13:if(o=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=sl(r),o!==null&&o.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=r.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[ei]=r}else ma(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Wt(r),u=!1}else u=wd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return r.flags&256?(Tn(r),r):(Tn(r),null)}return Tn(r),(r.flags&128)!==0?(r.lanes=a,r):(a=o!==null,i=i!==null&&i.memoizedState!==null,a&&(o=r.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048)),a!==i&&a&&(r.child.flags|=8192),mu(r,r.updateQueue),Wt(r),null);case 4:return Ie(),i===null&&Of(r.stateNode.containerInfo),Wt(r),null;case 10:return Ir(r.type),Wt(r),null;case 19:if(Q(ci),o=r.memoizedState,o===null)return Wt(r),null;if(u=(r.flags&128)!==0,d=o.rendering,d===null)if(u)bo(o,!1);else{if(ri!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(d=iu(i),d!==null){for(r.flags|=128,bo(o,!1),i=d.updateQueue,r.updateQueue=i,mu(r,i),r.subtreeFlags=0,i=a,a=r.child;a!==null;)I_(a,i),a=a.sibling;return he(ci,ci.current&1|2),gt&&Pr(r,o.treeForkCount),r.child}i=i.sibling}o.tail!==null&&wt()>bu&&(r.flags|=128,u=!0,bo(o,!1),r.lanes=4194304)}else{if(!u)if(i=iu(d),i!==null){if(r.flags|=128,u=!0,i=i.updateQueue,r.updateQueue=i,mu(r,i),bo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!d.alternate&&!gt)return Wt(r),null}else 2*wt()-o.renderingStartTime>bu&&a!==536870912&&(r.flags|=128,u=!0,bo(o,!1),r.lanes=4194304);o.isBackwards?(d.sibling=r.child,r.child=d):(i=o.last,i!==null?i.sibling=d:r.child=d,o.last=d)}return o.tail!==null?(i=o.tail,o.rendering=i,o.tail=i.sibling,o.renderingStartTime=wt(),i.sibling=null,a=ci.current,he(ci,u?a&1|2:a&1),gt&&Pr(r,o.treeForkCount),i):(Wt(r),null);case 22:case 23:return Tn(r),Od(),o=r.memoizedState!==null,i!==null?i.memoizedState!==null!==o&&(r.flags|=8192):o&&(r.flags|=8192),o?(a&536870912)!==0&&(r.flags&128)===0&&(Wt(r),r.subtreeFlags&6&&(r.flags|=8192)):Wt(r),a=r.updateQueue,a!==null&&mu(r,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048),i!==null&&Q(va),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),r.memoizedState.cache!==a&&(r.flags|=2048),Ir(pi),Wt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function Bx(i,r){switch(bd(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Ir(pi),Ie(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return me(r),null;case 31:if(r.memoizedState!==null){if(Tn(r),r.alternate===null)throw Error(s(340));ma()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Tn(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));ma()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return Q(ci),null;case 4:return Ie(),null;case 10:return Ir(r.type),null;case 22:case 23:return Tn(r),Od(),i!==null&&Q(va),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return Ir(pi),null;case 25:return null;default:return null}}function fy(i,r){switch(bd(r),r.tag){case 3:Ir(pi),Ie();break;case 26:case 27:case 5:me(r);break;case 4:Ie();break;case 31:r.memoizedState!==null&&Tn(r);break;case 13:Tn(r);break;case 19:Q(ci);break;case 10:Ir(r.type);break;case 22:case 23:Tn(r),Od(),i!==null&&Q(va);break;case 24:Ir(pi)}}function So(i,r){try{var a=r.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&i)===i){o=void 0;var d=a.create,_=a.inst;o=d(),_.destroy=o}a=a.next}while(a!==u)}}catch(x){kt(r,r.return,x)}}function Ts(i,r,a){try{var o=r.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var d=u.next;o=d;do{if((o.tag&i)===i){var _=o.inst,x=_.destroy;if(x!==void 0){_.destroy=void 0,u=r;var N=a,V=x;try{V()}catch(le){kt(u,N,le)}}}o=o.next}while(o!==d)}}catch(le){kt(r,r.return,le)}}function py(i){var r=i.updateQueue;if(r!==null){var a=i.stateNode;try{rv(r,a)}catch(o){kt(i,i.return,o)}}}function my(i,r,a){a.props=Ca(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(o){kt(i,r,o)}}function wo(i,r){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var o=i.stateNode;break;case 30:o=i.stateNode;break;default:o=i.stateNode}typeof a=="function"?i.refCleanup=a(o):a.current=o}}catch(u){kt(i,r,u)}}function Cr(i,r){var a=i.ref,o=i.refCleanup;if(a!==null)if(typeof o=="function")try{o()}catch(u){kt(i,r,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){kt(i,r,u)}else a.current=null}function gy(i){var r=i.type,a=i.memoizedProps,o=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":a.autoFocus&&o.focus();break e;case"img":a.src?o.src=a.src:a.srcSet&&(o.srcset=a.srcSet)}}catch(u){kt(i,i.return,u)}}function pf(i,r,a){try{var o=i.stateNode;ik(o,i.type,a,r),o[xi]=r}catch(u){kt(i,i.return,u)}}function _y(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Bs(i.type)||i.tag===4}function mf(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||_y(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&&Bs(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 gf(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,r):(r=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,r.appendChild(i),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=ii));else if(o!==4&&(o===27&&Bs(i.type)&&(a=i.stateNode,r=null),i=i.child,i!==null))for(gf(i,r,a),i=i.sibling;i!==null;)gf(i,r,a),i=i.sibling}function gu(i,r,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(o!==4&&(o===27&&Bs(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(gu(i,r,a),i=i.sibling;i!==null;)gu(i,r,a),i=i.sibling}function vy(i){var r=i.stateNode,a=i.memoizedProps;try{for(var o=i.type,u=r.attributes;u.length;)r.removeAttributeNode(u[0]);Xi(r,o,a),r[ei]=i,r[xi]=a}catch(d){kt(i,i.return,d)}}var qr=!1,_i=!1,_f=!1,yy=typeof WeakSet=="function"?WeakSet:Set,Oi=null;function Ox(i,r){if(i=i.containerInfo,Pf=ju,i=N_(i),cd(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var o=a.getSelection&&a.getSelection();if(o&&o.rangeCount!==0){a=o.anchorNode;var u=o.anchorOffset,d=o.focusNode;o=o.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,x=-1,N=-1,V=0,le=0,ce=i,G=null;t:for(;;){for(var ee;ce!==a||u!==0&&ce.nodeType!==3||(x=_+u),ce!==d||o!==0&&ce.nodeType!==3||(N=_+o),ce.nodeType===3&&(_+=ce.nodeValue.length),(ee=ce.firstChild)!==null;)G=ce,ce=ee;for(;;){if(ce===i)break t;if(G===a&&++V===u&&(x=_),G===d&&++le===o&&(N=_),(ee=ce.nextSibling)!==null)break;ce=G,G=ce.parentNode}ce=ee}a=x===-1||N===-1?null:{start:x,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(Hf={focusedElem:i,selectionRange:a},ju=!1,Oi=r;Oi!==null;)if(r=Oi,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Oi=i;else for(;Oi!==null;){switch(r=Oi,d=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&d!==null){i=void 0,a=r,u=d.memoizedProps,d=d.memoizedState,o=a.stateNode;try{var ze=Ca(a.type,u);i=o.getSnapshotBeforeUpdate(ze,d),o.__reactInternalSnapshotBeforeUpdate=i}catch(Ve){kt(a,a.return,Ve)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,a=i.nodeType,a===9)Kf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Kf(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(s(163))}if(i=r.sibling,i!==null){i.return=r.return,Oi=i;break}Oi=r.return}}function by(i,r,a){var o=a.flags;switch(a.tag){case 0:case 11:case 15:Vr(i,a),o&4&&So(5,a);break;case 1:if(Vr(i,a),o&4)if(i=a.stateNode,r===null)try{i.componentDidMount()}catch(_){kt(a,a.return,_)}else{var u=Ca(a.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(u,r,i.__reactInternalSnapshotBeforeUpdate)}catch(_){kt(a,a.return,_)}}o&64&&py(a),o&512&&wo(a,a.return);break;case 3:if(Vr(i,a),o&64&&(i=a.updateQueue,i!==null)){if(r=null,a.child!==null)switch(a.child.tag){case 27:case 5:r=a.child.stateNode;break;case 1:r=a.child.stateNode}try{rv(i,r)}catch(_){kt(a,a.return,_)}}break;case 27:r===null&&o&4&&vy(a);case 26:case 5:Vr(i,a),r===null&&o&4&&gy(a),o&512&&wo(a,a.return);break;case 12:Vr(i,a);break;case 31:Vr(i,a),o&4&&Cy(i,a);break;case 13:Vr(i,a),o&4&&xy(i,a),o&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Fx.bind(null,a),uk(i,a))));break;case 22:if(o=a.memoizedState!==null||qr,!o){r=r!==null&&r.memoizedState!==null||_i,u=qr;var d=_i;qr=o,(_i=r)&&!d?Yr(i,a,(a.subtreeFlags&8772)!==0):Vr(i,a),qr=u,_i=d}break;case 30:break;default:Vr(i,a)}}function Sy(i){var r=i.alternate;r!==null&&(i.alternate=null,Sy(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Ar(r)),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 Yt=null,mn=!1;function $r(i,r,a){for(a=a.child;a!==null;)wy(i,r,a),a=a.sibling}function wy(i,r,a){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(Tt,a)}catch{}switch(a.tag){case 26:_i||Cr(a,r),$r(i,r,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:_i||Cr(a,r);var o=Yt,u=mn;Bs(a.type)&&(Yt=a.stateNode,mn=!1),$r(i,r,a),No(a.stateNode),Yt=o,mn=u;break;case 5:_i||Cr(a,r);case 6:if(o=Yt,u=mn,Yt=null,$r(i,r,a),Yt=o,mn=u,Yt!==null)if(mn)try{(Yt.nodeType===9?Yt.body:Yt.nodeName==="HTML"?Yt.ownerDocument.body:Yt).removeChild(a.stateNode)}catch(d){kt(a,r,d)}else try{Yt.removeChild(a.stateNode)}catch(d){kt(a,r,d)}break;case 18:Yt!==null&&(mn?(i=Yt,pb(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),El(i)):pb(Yt,a.stateNode));break;case 4:o=Yt,u=mn,Yt=a.stateNode.containerInfo,mn=!0,$r(i,r,a),Yt=o,mn=u;break;case 0:case 11:case 14:case 15:Ts(2,a,r),_i||Ts(4,a,r),$r(i,r,a);break;case 1:_i||(Cr(a,r),o=a.stateNode,typeof o.componentWillUnmount=="function"&&my(a,r,o)),$r(i,r,a);break;case 21:$r(i,r,a);break;case 22:_i=(o=_i)||a.memoizedState!==null,$r(i,r,a),_i=o;break;default:$r(i,r,a)}}function Cy(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{El(i)}catch(a){kt(r,r.return,a)}}}function xy(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{El(i)}catch(a){kt(r,r.return,a)}}function zx(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new yy),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new yy),r;default:throw Error(s(435,i.tag))}}function _u(i,r){var a=zx(i);r.forEach(function(o){if(!a.has(o)){a.add(o);var u=qx.bind(null,i,o);o.then(u,u)}})}function gn(i,r){var a=r.deletions;if(a!==null)for(var o=0;o<a.length;o++){var u=a[o],d=i,_=r,x=_;e:for(;x!==null;){switch(x.tag){case 27:if(Bs(x.type)){Yt=x.stateNode,mn=!1;break e}break;case 5:Yt=x.stateNode,mn=!1;break e;case 3:case 4:Yt=x.stateNode.containerInfo,mn=!0;break e}x=x.return}if(Yt===null)throw Error(s(160));wy(d,_,u),Yt=null,mn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ky(r,i),r=r.sibling}var or=null;function ky(i,r){var a=i.alternate,o=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:gn(r,i),_n(i),o&4&&(Ts(3,i,i.return),So(3,i),Ts(5,i,i.return));break;case 1:gn(r,i),_n(i),o&512&&(_i||a===null||Cr(a,a.return)),o&64&&qr&&(i=i.updateQueue,i!==null&&(o=i.callbacks,o!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?o:a.concat(o))));break;case 26:var u=or;if(gn(r,i),_n(i),o&512&&(_i||a===null||Cr(a,a.return)),o&4){var d=a!==null?a.memoizedState:null;if(o=i.memoizedState,a===null)if(o===null)if(i.stateNode===null){e:{o=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Nr]||d[ei]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(o),u.head.insertBefore(d,u.querySelector("head > title"))),Xi(d,o,a),d[ei]=i,It(d),o=d;break e;case"link":var _=kb("link","href",u).get(o+(a.href||""));if(_){for(var x=0;x<_.length;x++)if(d=_[x],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(x,1);break t}}d=u.createElement(o),Xi(d,o,a),u.head.appendChild(d);break;case"meta":if(_=kb("meta","content",u).get(o+(a.content||""))){for(x=0;x<_.length;x++)if(d=_[x],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(x,1);break t}}d=u.createElement(o),Xi(d,o,a),u.head.appendChild(d);break;default:throw Error(s(468,o))}d[ei]=i,It(d),o=d}i.stateNode=o}else Eb(u,i.type,i.stateNode);else i.stateNode=xb(u,o,i.memoizedProps);else d!==o?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,o===null?Eb(u,i.type,i.stateNode):xb(u,o,i.memoizedProps)):o===null&&i.stateNode!==null&&pf(i,i.memoizedProps,a.memoizedProps)}break;case 27:gn(r,i),_n(i),o&512&&(_i||a===null||Cr(a,a.return)),a!==null&&o&4&&pf(i,i.memoizedProps,a.memoizedProps);break;case 5:if(gn(r,i),_n(i),o&512&&(_i||a===null||Cr(a,a.return)),i.flags&32){u=i.stateNode;try{_r(u,"")}catch(ze){kt(i,i.return,ze)}}o&4&&i.stateNode!=null&&(u=i.memoizedProps,pf(i,u,a!==null?a.memoizedProps:u)),o&1024&&(_f=!0);break;case 6:if(gn(r,i),_n(i),o&4){if(i.stateNode===null)throw Error(s(162));o=i.memoizedProps,a=i.stateNode;try{a.nodeValue=o}catch(ze){kt(i,i.return,ze)}}break;case 3:if(Lu=null,u=or,or=Nu(r.containerInfo),gn(r,i),or=u,_n(i),o&4&&a!==null&&a.memoizedState.isDehydrated)try{El(r.containerInfo)}catch(ze){kt(i,i.return,ze)}_f&&(_f=!1,Ey(i));break;case 4:o=or,or=Nu(i.stateNode.containerInfo),gn(r,i),_n(i),or=o;break;case 12:gn(r,i),_n(i);break;case 31:gn(r,i),_n(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,_u(i,o)));break;case 13:gn(r,i),_n(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(yu=wt()),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,_u(i,o)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,V=qr,le=_i;if(qr=V||u,_i=le||N,gn(r,i),_i=le,qr=V,_n(i),o&8192)e:for(r=i.stateNode,r._visibility=u?r._visibility&-2:r._visibility|1,u&&(a===null||N||qr||_i||xa(i)),a=null,r=i;;){if(r.tag===5||r.tag===26){if(a===null){N=a=r;try{if(d=N.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{x=N.stateNode;var ce=N.memoizedProps.style,G=ce!=null&&ce.hasOwnProperty("display")?ce.display:null;x.style.display=G==null||typeof G=="boolean"?"":(""+G).trim()}}catch(ze){kt(N,N.return,ze)}}}else if(r.tag===6){if(a===null){N=r;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(ze){kt(N,N.return,ze)}}}else if(r.tag===18){if(a===null){N=r;try{var ee=N.stateNode;u?mb(ee,!0):mb(N.stateNode,!1)}catch(ze){kt(N,N.return,ze)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;a===r&&(a=null),r=r.return}a===r&&(a=null),r.sibling.return=r.return,r=r.sibling}o&4&&(o=i.updateQueue,o!==null&&(a=o.retryQueue,a!==null&&(o.retryQueue=null,_u(i,a))));break;case 19:gn(r,i),_n(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,_u(i,o)));break;case 30:break;case 21:break;default:gn(r,i),_n(i)}}function _n(i){var r=i.flags;if(r&2){try{for(var a,o=i.return;o!==null;){if(_y(o)){a=o;break}o=o.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,d=mf(i);gu(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(_r(_,""),a.flags&=-33);var x=mf(i);gu(i,x,_);break;case 3:case 4:var N=a.stateNode.containerInfo,V=mf(i);gf(i,V,N);break;default:throw Error(s(161))}}catch(le){kt(i,i.return,le)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function Ey(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;Ey(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function Vr(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)by(i,r.alternate,r),r=r.sibling}function xa(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Ts(4,r,r.return),xa(r);break;case 1:Cr(r,r.return);var a=r.stateNode;typeof a.componentWillUnmount=="function"&&my(r,r.return,a),xa(r);break;case 27:No(r.stateNode);case 26:case 5:Cr(r,r.return),xa(r);break;case 22:r.memoizedState===null&&xa(r);break;case 30:xa(r);break;default:xa(r)}i=i.sibling}}function Yr(i,r,a){for(a=a&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var o=r.alternate,u=i,d=r,_=d.flags;switch(d.tag){case 0:case 11:case 15:Yr(u,d,a),So(4,d);break;case 1:if(Yr(u,d,a),o=d,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(V){kt(o,o.return,V)}if(o=d,u=o.updateQueue,u!==null){var x=o.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)nv(N[u],x)}catch(V){kt(o,o.return,V)}}a&&_&64&&py(d),wo(d,d.return);break;case 27:vy(d);case 26:case 5:Yr(u,d,a),a&&o===null&&_&4&&gy(d),wo(d,d.return);break;case 12:Yr(u,d,a);break;case 31:Yr(u,d,a),a&&_&4&&Cy(u,d);break;case 13:Yr(u,d,a),a&&_&4&&xy(u,d);break;case 22:d.memoizedState===null&&Yr(u,d,a),wo(d,d.return);break;case 30:break;default:Yr(u,d,a)}r=r.sibling}}function vf(i,r){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&lo(a))}function yf(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&lo(i))}function cr(i,r,a,o){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Ty(i,r,a,o),r=r.sibling}function Ty(i,r,a,o){var u=r.flags;switch(r.tag){case 0:case 11:case 15:cr(i,r,a,o),u&2048&&So(9,r);break;case 1:cr(i,r,a,o);break;case 3:cr(i,r,a,o),u&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&lo(i)));break;case 12:if(u&2048){cr(i,r,a,o),i=r.stateNode;try{var d=r.memoizedProps,_=d.id,x=d.onPostCommit;typeof x=="function"&&x(_,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){kt(r,r.return,N)}}else cr(i,r,a,o);break;case 31:cr(i,r,a,o);break;case 13:cr(i,r,a,o);break;case 23:break;case 22:d=r.stateNode,_=r.alternate,r.memoizedState!==null?d._visibility&2?cr(i,r,a,o):Co(i,r):d._visibility&2?cr(i,r,a,o):(d._visibility|=2,ml(i,r,a,o,(r.subtreeFlags&10256)!==0||!1)),u&2048&&vf(_,r);break;case 24:cr(i,r,a,o),u&2048&&yf(r.alternate,r);break;default:cr(i,r,a,o)}}function ml(i,r,a,o,u){for(u=u&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var d=i,_=r,x=a,N=o,V=_.flags;switch(_.tag){case 0:case 11:case 15:ml(d,_,x,N,u),So(8,_);break;case 23:break;case 22:var le=_.stateNode;_.memoizedState!==null?le._visibility&2?ml(d,_,x,N,u):Co(d,_):(le._visibility|=2,ml(d,_,x,N,u)),u&&V&2048&&vf(_.alternate,_);break;case 24:ml(d,_,x,N,u),u&&V&2048&&yf(_.alternate,_);break;default:ml(d,_,x,N,u)}r=r.sibling}}function Co(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var a=i,o=r,u=o.flags;switch(o.tag){case 22:Co(a,o),u&2048&&vf(o.alternate,o);break;case 24:Co(a,o),u&2048&&yf(o.alternate,o);break;default:Co(a,o)}r=r.sibling}}var xo=8192;function gl(i,r,a){if(i.subtreeFlags&xo)for(i=i.child;i!==null;)Dy(i,r,a),i=i.sibling}function Dy(i,r,a){switch(i.tag){case 26:gl(i,r,a),i.flags&xo&&i.memoizedState!==null&&wk(a,or,i.memoizedState,i.memoizedProps);break;case 5:gl(i,r,a);break;case 3:case 4:var o=or;or=Nu(i.stateNode.containerInfo),gl(i,r,a),or=o;break;case 22:i.memoizedState===null&&(o=i.alternate,o!==null&&o.memoizedState!==null?(o=xo,xo=16777216,gl(i,r,a),xo=o):gl(i,r,a));break;default:gl(i,r,a)}}function Ry(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function ko(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Oi=o,Ny(o,i)}Ry(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)My(i),i=i.sibling}function My(i){switch(i.tag){case 0:case 11:case 15:ko(i),i.flags&2048&&Ts(9,i,i.return);break;case 3:ko(i);break;case 12:ko(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,vu(i)):ko(i);break;default:ko(i)}}function vu(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var a=0;a<r.length;a++){var o=r[a];Oi=o,Ny(o,i)}Ry(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Ts(8,r,r.return),vu(r);break;case 22:a=r.stateNode,a._visibility&2&&(a._visibility&=-3,vu(r));break;default:vu(r)}i=i.sibling}}function Ny(i,r){for(;Oi!==null;){var a=Oi;switch(a.tag){case 0:case 11:case 15:Ts(8,a,r);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var o=a.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:lo(a.memoizedState.cache)}if(o=a.child,o!==null)o.return=a,Oi=o;else e:for(a=i;Oi!==null;){o=Oi;var u=o.sibling,d=o.return;if(Sy(o),o===a){Oi=null;break e}if(u!==null){u.return=d,Oi=u;break e}Oi=d}}}var jx={getCacheForType:function(i){var r=Vi(pi),a=r.data.get(i);return a===void 0&&(a=i(),r.data.set(i,a)),a},cacheSignal:function(){return Vi(pi).controller.signal}},Px=typeof WeakMap=="function"?WeakMap:Map,St=0,Ot=null,ct=null,dt=0,xt=0,Dn=null,Ds=!1,_l=!1,bf=!1,Xr=0,ri=0,Rs=0,ka=0,Sf=0,Rn=0,vl=0,Eo=null,vn=null,wf=!1,yu=0,Ay=0,bu=1/0,Su=null,Ms=null,Ei=0,Ns=null,yl=null,Gr=0,Cf=0,xf=null,Ly=null,To=0,kf=null;function Mn(){return(St&2)!==0&&dt!==0?dt&-dt:R.T!==null?Nf():sn()}function By(){if(Rn===0)if((dt&536870912)===0||gt){var i=Zi;Zi<<=1,(Zi&3932160)===0&&(Zi=262144),Rn=i}else Rn=536870912;return i=En.current,i!==null&&(i.flags|=32),Rn}function yn(i,r,a){(i===Ot&&(xt===2||xt===9)||i.cancelPendingCommit!==null)&&(bl(i,0),As(i,dt,Rn,!1)),Gt(i,a),((St&2)===0||i!==Ot)&&(i===Ot&&((St&2)===0&&(ka|=a),ri===4&&As(i,dt,Rn,!1)),xr(i))}function Oy(i,r,a){if((St&6)!==0)throw Error(s(327));var o=!a&&(r&127)===0&&(r&i.expiredLanes)===0||li(i,r),u=o?Ux(i,r):Tf(i,r,!0),d=o;do{if(u===0){_l&&!o&&As(i,r,0,!1);break}else{if(a=i.current.alternate,d&&!Hx(a)){u=Tf(i,r,!1),d=!1;continue}if(u===2){if(d=r,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){r=_;e:{var x=i;u=Eo;var N=x.current.memoizedState.isDehydrated;if(N&&(bl(x,_).flags|=256),_=Tf(x,_,!1),_!==2){if(bf&&!N){x.errorRecoveryDisabledLanes|=d,ka|=d,u=4;break e}d=vn,vn=u,d!==null&&(vn===null?vn=d:vn.push.apply(vn,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){bl(i,0),As(i,r,0,!0);break}e:{switch(o=i,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:As(o,r,Rn,!Ds);break e;case 2:vn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(u=yu+300-wt(),10<u)){if(As(o,r,Rn,!Ds),Pt(o,0,!0)!==0)break e;Gr=r,o.timeoutHandle=db(zy.bind(null,o,a,vn,Su,wf,r,Rn,ka,vl,Ds,d,"Throttled",-0,0),u);break e}zy(o,a,vn,Su,wf,r,Rn,ka,vl,Ds,d,null,-0,0)}}break}while(!0);xr(i)}function zy(i,r,a,o,u,d,_,x,N,V,le,ce,G,ee){if(i.timeoutHandle=-1,ce=r.subtreeFlags,ce&8192||(ce&16785408)===16785408){ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ii},Dy(r,d,ce);var ze=(d&62914560)===d?yu-wt():(d&4194048)===d?Ay-wt():0;if(ze=Ck(ce,ze),ze!==null){Gr=d,i.cancelPendingCommit=ze(Fy.bind(null,i,r,d,a,o,u,_,x,N,le,ce,null,G,ee)),As(i,d,_,!V);return}}Fy(i,r,d,a,o,u,_,x,N)}function Hx(i){for(var r=i;;){var a=r.tag;if((a===0||a===11||a===15)&&r.flags&16384&&(a=r.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var o=0;o<a.length;o++){var u=a[o],d=u.getSnapshot;u=u.value;try{if(!xn(d(),u))return!1}catch{return!1}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function As(i,r,a,o){r&=~Sf,r&=~ka,i.suspendedLanes|=r,i.pingedLanes&=~r,o&&(i.warmLanes|=r),o=i.expirationTimes;for(var u=r;0<u;){var d=31-F(u),_=1<<d;o[d]=-1,u&=~_}a!==0&&Wi(i,a,r)}function wu(){return(St&6)===0?(Do(0),!1):!0}function Ef(){if(ct!==null){if(xt===0)var i=ct.return;else i=ct,Hr=ga=null,Ud(i),ul=null,co=0,i=ct;for(;i!==null;)fy(i.alternate,i),i=i.return;ct=null}}function bl(i,r){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,sk(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Gr=0,Ef(),Ot=i,ct=a=jr(i.current,null),dt=r,xt=0,Dn=null,Ds=!1,_l=li(i,r),bf=!1,vl=Rn=Sf=ka=Rs=ri=0,vn=Eo=null,wf=!1,(r&8)!==0&&(r|=r&32);var o=i.entangledLanes;if(o!==0)for(i=i.entanglements,o&=r;0<o;){var u=31-F(o),d=1<<u;r|=i[u],o&=~d}return Xr=r,Wc(),a}function jy(i,r){Qe=null,R.H=vo,r===cl||r===Zc?(r=J_(),xt=3):r===Rd?(r=J_(),xt=4):xt=r===rf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Dn=r,ct===null&&(ri=1,hu(i,Kn(r,i.current)))}function Py(){var i=En.current;return i===null?!0:(dt&4194048)===dt?$n===null:(dt&62914560)===dt||(dt&536870912)!==0?i===$n:!1}function Hy(){var i=R.H;return R.H=vo,i===null?vo:i}function Iy(){var i=R.A;return R.A=jx,i}function Cu(){ri=4,Ds||(dt&4194048)!==dt&&En.current!==null||(_l=!0),(Rs&134217727)===0&&(ka&134217727)===0||Ot===null||As(Ot,dt,Rn,!1)}function Tf(i,r,a){var o=St;St|=2;var u=Hy(),d=Iy();(Ot!==i||dt!==r)&&(Su=null,bl(i,r)),r=!1;var _=ri;e:do try{if(xt!==0&&ct!==null){var x=ct,N=Dn;switch(xt){case 8:Ef(),_=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(r=!0);var V=xt;if(xt=0,Dn=null,Sl(i,x,N,V),a&&_l){_=0;break e}break;default:V=xt,xt=0,Dn=null,Sl(i,x,N,V)}}Ix(),_=ri;break}catch(le){jy(i,le)}while(!0);return r&&i.shellSuspendCounter++,Hr=ga=null,St=o,R.H=u,R.A=d,ct===null&&(Ot=null,dt=0,Wc()),_}function Ix(){for(;ct!==null;)Uy(ct)}function Ux(i,r){var a=St;St|=2;var o=Hy(),u=Iy();Ot!==i||dt!==r?(Su=null,bu=wt()+500,bl(i,r)):_l=li(i,r);e:do try{if(xt!==0&&ct!==null){r=ct;var d=Dn;t:switch(xt){case 1:xt=0,Dn=null,Sl(i,r,d,1);break;case 2:case 9:if(Z_(d)){xt=0,Dn=null,Ky(r);break}r=function(){xt!==2&&xt!==9||Ot!==i||(xt=7),xr(i)},d.then(r,r);break e;case 3:xt=7;break e;case 4:xt=5;break e;case 7:Z_(d)?(xt=0,Dn=null,Ky(r)):(xt=0,Dn=null,Sl(i,r,d,7));break;case 5:var _=null;switch(ct.tag){case 26:_=ct.memoizedState;case 5:case 27:var x=ct;if(_?Tb(_):x.stateNode.complete){xt=0,Dn=null;var N=x.sibling;if(N!==null)ct=N;else{var V=x.return;V!==null?(ct=V,xu(V)):ct=null}break t}}xt=0,Dn=null,Sl(i,r,d,5);break;case 6:xt=0,Dn=null,Sl(i,r,d,6);break;case 8:Ef(),ri=6;break e;default:throw Error(s(462))}}Kx();break}catch(le){jy(i,le)}while(!0);return Hr=ga=null,R.H=o,R.A=u,St=a,ct!==null?0:(Ot=null,dt=0,Wc(),ri)}function Kx(){for(;ct!==null&&!rt();)Uy(ct)}function Uy(i){var r=hy(i.alternate,i,Xr);i.memoizedProps=i.pendingProps,r===null?xu(i):ct=r}function Ky(i){var r=i,a=r.alternate;switch(r.tag){case 15:case 0:r=sy(a,r,r.pendingProps,r.type,void 0,dt);break;case 11:r=sy(a,r,r.pendingProps,r.type.render,r.ref,dt);break;case 5:Ud(r);default:fy(a,r),r=ct=I_(r,Xr),r=hy(a,r,Xr)}i.memoizedProps=i.pendingProps,r===null?xu(i):ct=r}function Sl(i,r,a,o){Hr=ga=null,Ud(r),ul=null,co=0;var u=r.return;try{if(Mx(i,u,r,a,dt)){ri=1,hu(i,Kn(a,i.current)),ct=null;return}}catch(d){if(u!==null)throw ct=u,d;ri=1,hu(i,Kn(a,i.current)),ct=null;return}r.flags&32768?(gt||o===1?i=!0:_l||(dt&536870912)!==0?i=!1:(Ds=i=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),Wy(r,i)):xu(r)}function xu(i){var r=i;do{if((r.flags&32768)!==0){Wy(r,Ds);return}i=r.return;var a=Lx(r.alternate,r,Xr);if(a!==null){ct=a;return}if(r=r.sibling,r!==null){ct=r;return}ct=r=i}while(r!==null);ri===0&&(ri=5)}function Wy(i,r){do{var a=Bx(i.alternate,i);if(a!==null){a.flags&=32767,ct=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!r&&(i=i.sibling,i!==null)){ct=i;return}ct=i=a}while(i!==null);ri=6,ct=null}function Fy(i,r,a,o,u,d,_,x,N){i.cancelPendingCommit=null;do ku();while(Ei!==0);if((St&6)!==0)throw Error(s(327));if(r!==null){if(r===i.current)throw Error(s(177));if(d=r.lanes|r.childLanes,d|=pd,Ht(i,a,d,_,x,N),i===Ot&&(ct=Ot=null,dt=0),yl=r,Ns=i,Gr=a,Cf=d,xf=u,Ly=o,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,$x(fe,function(){return Xy(),null})):(i.callbackNode=null,i.callbackPriority=0),o=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||o){o=R.T,R.T=null,u=X.p,X.p=2,_=St,St|=4;try{Ox(i,r,a)}finally{St=_,X.p=u,R.T=o}}Ei=1,qy(),$y(),Vy()}}function qy(){if(Ei===1){Ei=0;var i=Ns,r=yl,a=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=St;St|=4;try{ky(r,i);var d=Hf,_=N_(i.containerInfo),x=d.focusedElem,N=d.selectionRange;if(_!==x&&x&&x.ownerDocument&&M_(x.ownerDocument.documentElement,x)){if(N!==null&&cd(x)){var V=N.start,le=N.end;if(le===void 0&&(le=V),"selectionStart"in x)x.selectionStart=V,x.selectionEnd=Math.min(le,x.value.length);else{var ce=x.ownerDocument||document,G=ce&&ce.defaultView||window;if(G.getSelection){var ee=G.getSelection(),ze=x.textContent.length,Ve=Math.min(N.start,ze),At=N.end===void 0?Ve:Math.min(N.end,ze);!ee.extend&&Ve>At&&(_=At,At=Ve,Ve=_);var I=R_(x,Ve),z=R_(x,At);if(I&&z&&(ee.rangeCount!==1||ee.anchorNode!==I.node||ee.anchorOffset!==I.offset||ee.focusNode!==z.node||ee.focusOffset!==z.offset)){var $=ce.createRange();$.setStart(I.node,I.offset),ee.removeAllRanges(),Ve>At?(ee.addRange($),ee.extend(z.node,z.offset)):($.setEnd(z.node,z.offset),ee.addRange($))}}}}for(ce=[],ee=x;ee=ee.parentNode;)ee.nodeType===1&&ce.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<ce.length;x++){var oe=ce[x];oe.element.scrollLeft=oe.left,oe.element.scrollTop=oe.top}}ju=!!Pf,Hf=Pf=null}finally{St=u,X.p=o,R.T=a}}i.current=r,Ei=2}}function $y(){if(Ei===2){Ei=0;var i=Ns,r=yl,a=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=St;St|=4;try{by(i,r.alternate,r)}finally{St=u,X.p=o,R.T=a}}Ei=3}}function Vy(){if(Ei===4||Ei===3){Ei=0,qt();var i=Ns,r=yl,a=Gr,o=Ly;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ei=5:(Ei=0,yl=Ns=null,Yy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(Ms=null),Ci(a),r=r.stateNode,Dt&&typeof Dt.onCommitFiberRoot=="function")try{Dt.onCommitFiberRoot(Tt,r,void 0,(r.current.flags&128)===128)}catch{}if(o!==null){r=R.T,u=X.p,X.p=2,R.T=null;try{for(var d=i.onRecoverableError,_=0;_<o.length;_++){var x=o[_];d(x.value,{componentStack:x.stack})}}finally{R.T=r,X.p=u}}(Gr&3)!==0&&ku(),xr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===kf?To++:(To=0,kf=i):To=0,Do(0)}}function Yy(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,lo(r)))}function ku(){return qy(),$y(),Vy(),Xy()}function Xy(){if(Ei!==5)return!1;var i=Ns,r=Cf;Cf=0;var a=Ci(Gr),o=R.T,u=X.p;try{X.p=32>a?32:a,R.T=null,a=xf,xf=null;var d=Ns,_=Gr;if(Ei=0,yl=Ns=null,Gr=0,(St&6)!==0)throw Error(s(331));var x=St;if(St|=4,My(d.current),Ty(d,d.current,_,a),St=x,Do(0,!1),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(Tt,d)}catch{}return!0}finally{X.p=u,R.T=o,Yy(i,r)}}function Gy(i,r,a){r=Kn(a,r),r=nf(i.stateNode,r,2),i=xs(i,r,2),i!==null&&(Gt(i,2),xr(i))}function kt(i,r,a){if(i.tag===3)Gy(i,i,a);else for(;r!==null;){if(r.tag===3){Gy(r,i,a);break}else if(r.tag===1){var o=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ms===null||!Ms.has(o))){i=Kn(a,i),a=Zv(2),o=xs(r,a,2),o!==null&&(Qv(a,o,r,i),Gt(o,2),xr(o));break}}r=r.return}}function Df(i,r,a){var o=i.pingCache;if(o===null){o=i.pingCache=new Px;var u=new Set;o.set(r,u)}else u=o.get(r),u===void 0&&(u=new Set,o.set(r,u));u.has(a)||(bf=!0,u.add(a),i=Wx.bind(null,i,r,a),r.then(i,i))}function Wx(i,r,a){var o=i.pingCache;o!==null&&o.delete(r),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Ot===i&&(dt&a)===a&&(ri===4||ri===3&&(dt&62914560)===dt&&300>wt()-yu?(St&2)===0&&bl(i,0):Sf|=a,vl===dt&&(vl=0)),xr(i)}function Zy(i,r){r===0&&(r=jt()),i=fa(i,r),i!==null&&(Gt(i,r),xr(i))}function Fx(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Zy(i,a)}function qx(i,r){var a=0;switch(i.tag){case 31:case 13:var o=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:o=i.stateNode;break;case 22:o=i.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(r),Zy(i,a)}function $x(i,r){return Be(i,r)}var Eu=null,wl=null,Rf=!1,Tu=!1,Mf=!1,Ls=0;function xr(i){i!==wl&&i.next===null&&(wl===null?Eu=wl=i:wl=wl.next=i),Tu=!0,Rf||(Rf=!0,Yx())}function Do(i,r){if(!Mf&&Tu){Mf=!0;do for(var a=!1,o=Eu;o!==null;){if(i!==0){var u=o.pendingLanes;if(u===0)var d=0;else{var _=o.suspendedLanes,x=o.pingedLanes;d=(1<<31-F(42|i)+1)-1,d&=u&~(_&~x),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,tb(o,d))}else d=dt,d=Pt(o,o===Ot?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(d&3)===0||li(o,d)||(a=!0,tb(o,d));o=o.next}while(a);Mf=!1}}function Vx(){Qy()}function Qy(){Tu=Rf=!1;var i=0;Ls!==0&&rk()&&(i=Ls);for(var r=wt(),a=null,o=Eu;o!==null;){var u=o.next,d=Jy(o,r);d===0?(o.next=null,a===null?Eu=u:a.next=u,u===null&&(wl=a)):(a=o,(i!==0||(d&3)!==0)&&(Tu=!0)),o=u}Ei!==0&&Ei!==5||Do(i),Ls!==0&&(Ls=0)}function Jy(i,r){for(var a=i.suspendedLanes,o=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-F(d),x=1<<_,N=u[_];N===-1?((x&a)===0||(x&o)!==0)&&(u[_]=wi(x,r)):N<=r&&(i.expiredLanes|=x),d&=~x}if(r=Ot,a=dt,a=Pt(i,i===r?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o=i.callbackNode,a===0||i===r&&(xt===2||xt===9)||i.cancelPendingCommit!==null)return o!==null&&o!==null&&Oe(o),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||li(i,a)){if(r=a&-a,r===i.callbackPriority)return r;switch(o!==null&&Oe(o),Ci(a)){case 2:case 8:a=pt;break;case 32:a=fe;break;case 268435456:a=st;break;default:a=fe}return o=eb.bind(null,i),a=Be(a,o),i.callbackPriority=r,i.callbackNode=a,r}return o!==null&&o!==null&&Oe(o),i.callbackPriority=2,i.callbackNode=null,2}function eb(i,r){if(Ei!==0&&Ei!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(ku()&&i.callbackNode!==a)return null;var o=dt;return o=Pt(i,i===Ot?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o===0?null:(Oy(i,o,r),Jy(i,wt()),i.callbackNode!=null&&i.callbackNode===a?eb.bind(null,i):null)}function tb(i,r){if(ku())return null;Oy(i,r,!0)}function Yx(){ak(function(){(St&6)!==0?Be(nt,Vx):Qy()})}function Nf(){if(Ls===0){var i=ll;i===0&&(i=Si,Si<<=1,(Si&261888)===0&&(Si=256)),Ls=i}return Ls}function ib(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:vr(""+i)}function nb(i,r){var a=r.ownerDocument.createElement("input");return a.name=r.name,a.value=r.value,i.id&&a.setAttribute("form",i.id),r.parentNode.insertBefore(a,r),i=new FormData(i),a.parentNode.removeChild(a),i}function Xx(i,r,a,o,u){if(r==="submit"&&a&&a.stateNode===u){var d=ib((u[xi]||null).action),_=o.submitter;_&&(r=(r=_[xi]||null)?ib(r.formAction):_.getAttribute("formAction"),r!==null&&(d=r,_=null));var x=new te("action","action",null,o,u);i.push({event:x,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Ls!==0){var N=_?nb(u,_):new FormData(u);Gd(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(x.preventDefault(),N=_?nb(u,_):new FormData(u),Gd(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var Af=0;Af<fd.length;Af++){var Lf=fd[Af],Gx=Lf.toLowerCase(),Zx=Lf[0].toUpperCase()+Lf.slice(1);lr(Gx,"on"+Zx)}lr(B_,"onAnimationEnd"),lr(O_,"onAnimationIteration"),lr(z_,"onAnimationStart"),lr("dblclick","onDoubleClick"),lr("focusin","onFocus"),lr("focusout","onBlur"),lr(fx,"onTransitionRun"),lr(px,"onTransitionStart"),lr(mx,"onTransitionCancel"),lr(j_,"onTransitionEnd"),gr("onMouseEnter",["mouseout","mouseover"]),gr("onMouseLeave",["mouseout","mouseover"]),gr("onPointerEnter",["pointerout","pointerover"]),gr("onPointerLeave",["pointerout","pointerover"]),ir("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ir("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ir("onBeforeInput",["compositionend","keypress","textInput","paste"]),ir("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ir("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ro="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(" "),Qx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ro));function rb(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var o=i[a],u=o.event;o=o.listeners;e:{var d=void 0;if(r)for(var _=o.length-1;0<=_;_--){var x=o[_],N=x.instance,V=x.currentTarget;if(x=x.listener,N!==d&&u.isPropagationStopped())break e;d=x,u.currentTarget=V;try{d(u)}catch(le){Kc(le)}u.currentTarget=null,d=N}else for(_=0;_<o.length;_++){if(x=o[_],N=x.instance,V=x.currentTarget,x=x.listener,N!==d&&u.isPropagationStopped())break e;d=x,u.currentTarget=V;try{d(u)}catch(le){Kc(le)}u.currentTarget=null,d=N}}}}function ut(i,r){var a=r[ia];a===void 0&&(a=r[ia]=new Set);var o=i+"__bubble";a.has(o)||(sb(r,i,2,!1),a.add(o))}function Bf(i,r,a){var o=0;r&&(o|=4),sb(a,i,o,r)}var Du="_reactListening"+Math.random().toString(36).slice(2);function Of(i){if(!i[Du]){i[Du]=!0,sa.forEach(function(a){a!=="selectionchange"&&(Qx.has(a)||Bf(a,!1,i),Bf(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Du]||(r[Du]=!0,Bf("selectionchange",!1,r))}}function sb(i,r,a,o){switch(Bb(r)){case 2:var u=Ek;break;case 8:u=Tk;break;default:u=Gf}a=u.bind(null,r,a,i),u=void 0,!br||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(u=!0),o?u!==void 0?i.addEventListener(r,a,{capture:!0,passive:u}):i.addEventListener(r,a,!0):u!==void 0?i.addEventListener(r,a,{passive:u}):i.addEventListener(r,a,!1)}function zf(i,r,a,o,u){var d=o;if((r&1)===0&&(r&2)===0&&o!==null)e:for(;;){if(o===null)return;var _=o.tag;if(_===3||_===4){var x=o.stateNode.containerInfo;if(x===u)break;if(_===4)for(_=o.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;x!==null;){if(_=On(x),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){o=d=_;continue e}x=x.parentNode}}o=o.return}Za(function(){var V=d,le=rr(a),ce=[];e:{var G=P_.get(i);if(G!==void 0){var ee=te,ze=i;switch(i){case"keypress":if(ar(a)===0)break e;case"keydown":case"keyup":ee=Ic;break;case"focusin":ze="focus",ee=Ye;break;case"focusout":ze="blur",ee=Ye;break;case"beforeblur":case"afterblur":ee=Ye;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":ee=Vt;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=J;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=YC;break;case B_:case O_:case z_:ee=ht;break;case j_:ee=GC;break;case"scroll":case"scrollend":ee=pe;break;case"wheel":ee=QC;break;case"copy":case"cut":case"paste":ee=en;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=m_;break;case"toggle":case"beforetoggle":ee=ex}var Ve=(r&4)!==0,At=!Ve&&(i==="scroll"||i==="scrollend"),I=Ve?G!==null?G+"Capture":null:G;Ve=[];for(var z=V,$;z!==null;){var oe=z;if($=oe.stateNode,oe=oe.tag,oe!==5&&oe!==26&&oe!==27||$===null||I===null||(oe=Or(z,I),oe!=null&&Ve.push(Mo(z,oe,$))),At)break;z=z.return}0<Ve.length&&(G=new ee(G,ze,null,a,le),ce.push({event:G,listeners:Ve}))}}if((r&7)===0){e:{if(G=i==="mouseover"||i==="pointerover",ee=i==="mouseout"||i==="pointerout",G&&a!==Pn&&(ze=a.relatedTarget||a.fromElement)&&(On(ze)||ze[wn]))break e;if((ee||G)&&(G=le.window===le?le:(G=le.ownerDocument)?G.defaultView||G.parentWindow:window,ee?(ze=a.relatedTarget||a.toElement,ee=V,ze=ze?On(ze):null,ze!==null&&(At=c(ze),Ve=ze.tag,ze!==At||Ve!==5&&Ve!==27&&Ve!==6)&&(ze=null)):(ee=null,ze=V),ee!==ze)){if(Ve=Vt,oe="onMouseLeave",I="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(Ve=m_,oe="onPointerLeave",I="onPointerEnter",z="pointer"),At=ee==null?G:mr(ee),$=ze==null?G:mr(ze),G=new Ve(oe,z+"leave",ee,a,le),G.target=At,G.relatedTarget=$,oe=null,On(le)===V&&(Ve=new Ve(I,z+"enter",ze,a,le),Ve.target=$,Ve.relatedTarget=At,oe=Ve),At=oe,ee&&ze)t:{for(Ve=Jx,I=ee,z=ze,$=0,oe=I;oe;oe=Ve(oe))$++;oe=0;for(var Fe=z;Fe;Fe=Ve(Fe))oe++;for(;0<$-oe;)I=Ve(I),$--;for(;0<oe-$;)z=Ve(z),oe--;for(;$--;){if(I===z||z!==null&&I===z.alternate){Ve=I;break t}I=Ve(I),z=Ve(z)}Ve=null}else Ve=null;ee!==null&&ab(ce,G,ee,Ve,!1),ze!==null&&At!==null&&ab(ce,At,ze,Ve,!0)}}e:{if(G=V?mr(V):window,ee=G.nodeName&&G.nodeName.toLowerCase(),ee==="select"||ee==="input"&&G.type==="file")var vt=C_;else if(S_(G))if(x_)vt=ux;else{vt=ox;var He=lx}else ee=G.nodeName,!ee||ee.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?V&&ca(V.elementType)&&(vt=C_):vt=cx;if(vt&&(vt=vt(i,V))){w_(ce,vt,a,le);break e}He&&He(i,G,V),i==="focusout"&&V&&G.type==="number"&&V.memoizedProps.value!=null&&la(G,"number",G.value)}switch(He=V?mr(V):window,i){case"focusin":(S_(He)||He.contentEditable==="true")&&(Ja=He,ud=V,ro=null);break;case"focusout":ro=ud=Ja=null;break;case"mousedown":hd=!0;break;case"contextmenu":case"mouseup":case"dragend":hd=!1,A_(ce,a,le);break;case"selectionchange":if(dx)break;case"keydown":case"keyup":A_(ce,a,le)}var tt;if(ad)e:{switch(i){case"compositionstart":var ft="onCompositionStart";break e;case"compositionend":ft="onCompositionEnd";break e;case"compositionupdate":ft="onCompositionUpdate";break e}ft=void 0}else Qa?y_(i,a)&&(ft="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(ft="onCompositionStart");ft&&(g_&&a.locale!=="ko"&&(Qa||ft!=="onCompositionStart"?ft==="onCompositionEnd"&&Qa&&(tt=pn()):(ln=le,gs="value"in ln?ln.value:ln.textContent,Qa=!0)),He=Ru(V,ft),0<He.length&&(ft=new fi(ft,i,null,a,le),ce.push({event:ft,listeners:He}),tt?ft.data=tt:(tt=b_(a),tt!==null&&(ft.data=tt)))),(tt=ix?nx(i,a):rx(i,a))&&(ft=Ru(V,"onBeforeInput"),0<ft.length&&(He=new fi("onBeforeInput","beforeinput",null,a,le),ce.push({event:He,listeners:ft}),He.data=tt)),Xx(ce,i,V,a,le)}rb(ce,r)})}function Mo(i,r,a){return{instance:i,listener:r,currentTarget:a}}function Ru(i,r){for(var a=r+"Capture",o=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=Or(i,a),u!=null&&o.unshift(Mo(i,u,d)),u=Or(i,r),u!=null&&o.push(Mo(i,u,d))),i.tag===3)return o;i=i.return}return[]}function Jx(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function ab(i,r,a,o,u){for(var d=r._reactName,_=[];a!==null&&a!==o;){var x=a,N=x.alternate,V=x.stateNode;if(x=x.tag,N!==null&&N===o)break;x!==5&&x!==26&&x!==27||V===null||(N=V,u?(V=Or(a,d),V!=null&&_.unshift(Mo(a,V,N))):u||(V=Or(a,d),V!=null&&_.push(Mo(a,V,N)))),a=a.return}_.length!==0&&i.push({event:r,listeners:_})}var ek=/\r\n?/g,tk=/\u0000|\uFFFD/g;function lb(i){return(typeof i=="string"?i:""+i).replace(ek,`
10
+ `).replace(tk,"")}function ob(i,r){return r=lb(r),lb(i)===r}function Nt(i,r,a,o,u,d){switch(a){case"children":typeof o=="string"?r==="body"||r==="textarea"&&o===""||_r(i,o):(typeof o=="number"||typeof o=="bigint")&&r!=="body"&&_r(i,""+o);break;case"className":os(i,"class",o);break;case"tabIndex":os(i,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":os(i,a,o);break;case"style":fs(i,o,d);break;case"data":if(r!=="object"){os(i,"data",o);break}case"src":case"href":if(o===""&&(r!=="a"||a!=="href")){i.removeAttribute(a);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=vr(""+o),i.setAttribute(a,o);break;case"action":case"formAction":if(typeof o=="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 d=="function"&&(a==="formAction"?(r!=="input"&&Nt(i,r,"name",u.name,u,null),Nt(i,r,"formEncType",u.formEncType,u,null),Nt(i,r,"formMethod",u.formMethod,u,null),Nt(i,r,"formTarget",u.formTarget,u,null)):(Nt(i,r,"encType",u.encType,u,null),Nt(i,r,"method",u.method,u,null),Nt(i,r,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=vr(""+o),i.setAttribute(a,o);break;case"onClick":o!=null&&(i.onclick=ii);break;case"onScroll":o!=null&&ut("scroll",i);break;case"onScrollEnd":o!=null&&ut("scrollend",i);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":i.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){i.removeAttribute("xlink:href");break}a=vr(""+o),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":o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""+o):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":o&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":o===!0?i.setAttribute(a,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,o):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?i.setAttribute(a,o):i.removeAttribute(a);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?i.removeAttribute(a):i.setAttribute(a,o);break;case"popover":ut("beforetoggle",i),ut("toggle",i),ls(i,"popover",o);break;case"xlinkActuate":an(i,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":an(i,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":an(i,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":an(i,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":an(i,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":an(i,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":an(i,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":an(i,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":an(i,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ls(i,"is",o);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Xa.get(a)||a,ls(i,a,o))}}function jf(i,r,a,o,u,d){switch(a){case"style":fs(i,o,d);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof o=="string"?_r(i,o):(typeof o=="number"||typeof o=="bigint")&&_r(i,""+o);break;case"onScroll":o!=null&&ut("scroll",i);break;case"onScrollEnd":o!=null&&ut("scrollend",i);break;case"onClick":o!=null&&(i.onclick=ii);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),r=a.slice(2,u?a.length-7:void 0),d=i[xi]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(r,d,u),typeof o=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(r,o,u);break e}a in i?i[a]=o:o===!0?i.setAttribute(a,""):ls(i,a,o)}}}function Xi(i,r,a){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ut("error",i),ut("load",i);var o=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Nt(i,r,d,_,a,null)}}u&&Nt(i,r,"srcSet",a.srcSet,a,null),o&&Nt(i,r,"src",a.src,a,null);return;case"input":ut("invalid",i);var x=d=_=u=null,N=null,V=null;for(o in a)if(a.hasOwnProperty(o)){var le=a[o];if(le!=null)switch(o){case"name":u=le;break;case"type":_=le;break;case"checked":N=le;break;case"defaultChecked":V=le;break;case"value":d=le;break;case"defaultValue":x=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,r));break;default:Nt(i,r,o,le,a,null)}}ti(i,d,x,N,V,_,u,!1);return;case"select":ut("invalid",i),o=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(x=a[u],x!=null))switch(u){case"value":d=x;break;case"defaultValue":_=x;break;case"multiple":o=x;default:Nt(i,r,u,x,a,null)}r=d,a=_,i.multiple=!!o,r!=null?nr(i,!!o,r,!1):a!=null&&nr(i,!!o,a,!0);return;case"textarea":ut("invalid",i),d=u=o=null;for(_ in a)if(a.hasOwnProperty(_)&&(x=a[_],x!=null))switch(_){case"value":o=x;break;case"defaultValue":u=x;break;case"children":d=x;break;case"dangerouslySetInnerHTML":if(x!=null)throw Error(s(91));break;default:Nt(i,r,_,x,a,null)}oa(i,o,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(o=a[N],o!=null)&&(N==="selected"?i.selected=o&&typeof o!="function"&&typeof o!="symbol":Nt(i,r,N,o,a,null));return;case"dialog":ut("beforetoggle",i),ut("toggle",i),ut("cancel",i),ut("close",i);break;case"iframe":case"object":ut("load",i);break;case"video":case"audio":for(o=0;o<Ro.length;o++)ut(Ro[o],i);break;case"image":ut("error",i),ut("load",i);break;case"details":ut("toggle",i);break;case"embed":case"source":case"link":ut("error",i),ut("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(V in a)if(a.hasOwnProperty(V)&&(o=a[V],o!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Nt(i,r,V,o,a,null)}return;default:if(ca(r)){for(le in a)a.hasOwnProperty(le)&&(o=a[le],o!==void 0&&jf(i,r,le,o,a,void 0));return}}for(x in a)a.hasOwnProperty(x)&&(o=a[x],o!=null&&Nt(i,r,x,o,a,null))}function ik(i,r,a,o){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,x=null,N=null,V=null,le=null;for(ee in a){var ce=a[ee];if(a.hasOwnProperty(ee)&&ce!=null)switch(ee){case"checked":break;case"value":break;case"defaultValue":N=ce;default:o.hasOwnProperty(ee)||Nt(i,r,ee,null,o,ce)}}for(var G in o){var ee=o[G];if(ce=a[G],o.hasOwnProperty(G)&&(ee!=null||ce!=null))switch(G){case"type":d=ee;break;case"name":u=ee;break;case"checked":V=ee;break;case"defaultChecked":le=ee;break;case"value":_=ee;break;case"defaultValue":x=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,r));break;default:ee!==ce&&Nt(i,r,G,ee,o,ce)}}zn(i,_,x,N,V,le,d,u);return;case"select":ee=_=x=G=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":ee=N;default:o.hasOwnProperty(d)||Nt(i,r,d,null,o,N)}for(u in o)if(d=o[u],N=a[u],o.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":G=d;break;case"defaultValue":x=d;break;case"multiple":_=d;default:d!==N&&Nt(i,r,u,d,o,N)}r=x,a=_,o=ee,G!=null?nr(i,!!a,G,!1):!!o!=!!a&&(r!=null?nr(i,!!a,r,!0):nr(i,!!a,a?[]:"",!1));return;case"textarea":ee=G=null;for(x in a)if(u=a[x],a.hasOwnProperty(x)&&u!=null&&!o.hasOwnProperty(x))switch(x){case"value":break;case"children":break;default:Nt(i,r,x,null,o,u)}for(_ in o)if(u=o[_],d=a[_],o.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":G=u;break;case"defaultValue":ee=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&Nt(i,r,_,u,o,d)}ds(i,G,ee);return;case"option":for(var ze in a)G=a[ze],a.hasOwnProperty(ze)&&G!=null&&!o.hasOwnProperty(ze)&&(ze==="selected"?i.selected=!1:Nt(i,r,ze,null,o,G));for(N in o)G=o[N],ee=a[N],o.hasOwnProperty(N)&&G!==ee&&(G!=null||ee!=null)&&(N==="selected"?i.selected=G&&typeof G!="function"&&typeof G!="symbol":Nt(i,r,N,G,o,ee));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 Ve in a)G=a[Ve],a.hasOwnProperty(Ve)&&G!=null&&!o.hasOwnProperty(Ve)&&Nt(i,r,Ve,null,o,G);for(V in o)if(G=o[V],ee=a[V],o.hasOwnProperty(V)&&G!==ee&&(G!=null||ee!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(s(137,r));break;default:Nt(i,r,V,G,o,ee)}return;default:if(ca(r)){for(var At in a)G=a[At],a.hasOwnProperty(At)&&G!==void 0&&!o.hasOwnProperty(At)&&jf(i,r,At,void 0,o,G);for(le in o)G=o[le],ee=a[le],!o.hasOwnProperty(le)||G===ee||G===void 0&&ee===void 0||jf(i,r,le,G,o,ee);return}}for(var I in a)G=a[I],a.hasOwnProperty(I)&&G!=null&&!o.hasOwnProperty(I)&&Nt(i,r,I,null,o,G);for(ce in o)G=o[ce],ee=a[ce],!o.hasOwnProperty(ce)||G===ee||G==null&&ee==null||Nt(i,r,ce,G,o,ee)}function cb(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function nk(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=0,a=performance.getEntriesByType("resource"),o=0;o<a.length;o++){var u=a[o],d=u.transferSize,_=u.initiatorType,x=u.duration;if(d&&x&&cb(_)){for(_=0,x=u.responseEnd,o+=1;o<a.length;o++){var N=a[o],V=N.startTime;if(V>x)break;var le=N.transferSize,ce=N.initiatorType;le&&cb(ce)&&(N=N.responseEnd,_+=le*(N<x?1:(x-V)/(N-V)))}if(--o,r+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Pf=null,Hf=null;function Mu(i){return i.nodeType===9?i:i.ownerDocument}function ub(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 hb(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function If(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Uf=null;function rk(){var i=window.event;return i&&i.type==="popstate"?i===Uf?!1:(Uf=i,!0):(Uf=null,!1)}var db=typeof setTimeout=="function"?setTimeout:void 0,sk=typeof clearTimeout=="function"?clearTimeout:void 0,fb=typeof Promise=="function"?Promise:void 0,ak=typeof queueMicrotask=="function"?queueMicrotask:typeof fb<"u"?function(i){return fb.resolve(null).then(i).catch(lk)}:db;function lk(i){setTimeout(function(){throw i})}function Bs(i){return i==="head"}function pb(i,r){var a=r,o=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(o===0){i.removeChild(u),El(r);return}o--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")o++;else if(a==="html")No(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,No(a);for(var d=a.firstChild;d;){var _=d.nextSibling,x=d.nodeName;d[Nr]||x==="SCRIPT"||x==="STYLE"||x==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&No(i.ownerDocument.body);a=u}while(a);El(r)}function mb(i,r){var a=i;i=0;do{var o=a.nextSibling;if(a.nodeType===1?r?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(r?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),o&&o.nodeType===8)if(a=o.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=o}while(a)}function Kf(i){var r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var a=r;switch(r=r.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Kf(a),Ar(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function ok(i,r,a,o){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!o&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(o){if(!i[Nr])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=Vn(i.nextSibling),i===null)break}return null}function ck(i,r,a){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Vn(i.nextSibling),i===null))return null;return i}function gb(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=Vn(i.nextSibling),i===null))return null;return i}function Wf(i){return i.data==="$?"||i.data==="$~"}function Ff(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function uk(i,r){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||a.readyState!=="loading")r();else{var o=function(){r(),a.removeEventListener("DOMContentLoaded",o)};a.addEventListener("DOMContentLoaded",o),i._reactRetry=o}}function Vn(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var qf=null;function _b(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(r===0)return Vn(i.nextSibling);r--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||r++}i=i.nextSibling}return null}function vb(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(r===0)return i;r--}else a!=="/$"&&a!=="/&"||r++}i=i.previousSibling}return null}function yb(i,r,a){switch(r=Mu(a),i){case"html":if(i=r.documentElement,!i)throw Error(s(452));return i;case"head":if(i=r.head,!i)throw Error(s(453));return i;case"body":if(i=r.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function No(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Ar(i)}var Yn=new Map,bb=new Set;function Nu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Zr=X.d;X.d={f:hk,r:dk,D:fk,C:pk,L:mk,m:gk,X:vk,S:_k,M:yk};function hk(){var i=Zr.f(),r=wu();return i||r}function dk(i){var r=pr(i);r!==null&&r.tag===5&&r.type==="form"?jv(r):Zr.r(i)}var Cl=typeof document>"u"?null:document;function Sb(i,r,a){var o=Cl;if(o&&typeof r=="string"&&r){var u=ki(r);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),bb.has(u)||(bb.add(u),i={rel:i,crossOrigin:a,href:r},o.querySelector(u)===null&&(r=o.createElement("link"),Xi(r,"link",i),It(r),o.head.appendChild(r)))}}function fk(i){Zr.D(i),Sb("dns-prefetch",i,null)}function pk(i,r){Zr.C(i,r),Sb("preconnect",i,r)}function mk(i,r,a){Zr.L(i,r,a);var o=Cl;if(o&&i&&r){var u='link[rel="preload"][as="'+ki(r)+'"]';r==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+ki(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+ki(a.imageSizes)+'"]')):u+='[href="'+ki(i)+'"]';var d=u;switch(r){case"style":d=xl(i);break;case"script":d=kl(i)}Yn.has(d)||(i=y({rel:"preload",href:r==="image"&&a&&a.imageSrcSet?void 0:i,as:r},a),Yn.set(d,i),o.querySelector(u)!==null||r==="style"&&o.querySelector(Ao(d))||r==="script"&&o.querySelector(Lo(d))||(r=o.createElement("link"),Xi(r,"link",i),It(r),o.head.appendChild(r)))}}function gk(i,r){Zr.m(i,r);var a=Cl;if(a&&i){var o=r&&typeof r.as=="string"?r.as:"script",u='link[rel="modulepreload"][as="'+ki(o)+'"][href="'+ki(i)+'"]',d=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=kl(i)}if(!Yn.has(d)&&(i=y({rel:"modulepreload",href:i},r),Yn.set(d,i),a.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Lo(d)))return}o=a.createElement("link"),Xi(o,"link",i),It(o),a.head.appendChild(o)}}}function _k(i,r,a){Zr.S(i,r,a);var o=Cl;if(o&&i){var u=tr(o).hoistableStyles,d=xl(i);r=r||"default";var _=u.get(d);if(!_){var x={loading:0,preload:null};if(_=o.querySelector(Ao(d)))x.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":r},a),(a=Yn.get(d))&&$f(i,a);var N=_=o.createElement("link");It(N),Xi(N,"link",i),N._p=new Promise(function(V,le){N.onload=V,N.onerror=le}),N.addEventListener("load",function(){x.loading|=1}),N.addEventListener("error",function(){x.loading|=2}),x.loading|=4,Au(_,r,o)}_={type:"stylesheet",instance:_,count:1,state:x},u.set(d,_)}}}function vk(i,r){Zr.X(i,r);var a=Cl;if(a&&i){var o=tr(a).hoistableScripts,u=kl(i),d=o.get(u);d||(d=a.querySelector(Lo(u)),d||(i=y({src:i,async:!0},r),(r=Yn.get(u))&&Vf(i,r),d=a.createElement("script"),It(d),Xi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function yk(i,r){Zr.M(i,r);var a=Cl;if(a&&i){var o=tr(a).hoistableScripts,u=kl(i),d=o.get(u);d||(d=a.querySelector(Lo(u)),d||(i=y({src:i,async:!0,type:"module"},r),(r=Yn.get(u))&&Vf(i,r),d=a.createElement("script"),It(d),Xi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function wb(i,r,a,o){var u=(u=Se.current)?Nu(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(r=xl(a.href),a=tr(u).hoistableStyles,o=a.get(r),o||(o={type:"style",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=xl(a.href);var d=tr(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(Ao(i)))&&!d._p&&(_.instance=d,_.state.loading=5),Yn.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},Yn.set(i,a),d||bk(u,i,a,_.state))),r&&o===null)throw Error(s(528,""));return _}if(r&&o!==null)throw Error(s(529,""));return null;case"script":return r=a.async,a=a.src,typeof a=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=kl(a),a=tr(u).hoistableScripts,o=a.get(r),o||(o={type:"script",instance:null,count:0,state:null},a.set(r,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function xl(i){return'href="'+ki(i)+'"'}function Ao(i){return'link[rel="stylesheet"]['+i+"]"}function Cb(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function bk(i,r,a,o){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?o.loading=1:(r=i.createElement("link"),o.preload=r,r.addEventListener("load",function(){return o.loading|=1}),r.addEventListener("error",function(){return o.loading|=2}),Xi(r,"link",a),It(r),i.head.appendChild(r))}function kl(i){return'[src="'+ki(i)+'"]'}function Lo(i){return"script[async]"+i}function xb(i,r,a){if(r.count++,r.instance===null)switch(r.type){case"style":var o=i.querySelector('style[data-href~="'+ki(a.href)+'"]');if(o)return r.instance=o,It(o),o;var u=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return o=(i.ownerDocument||i).createElement("style"),It(o),Xi(o,"style",u),Au(o,a.precedence,i),r.instance=o;case"stylesheet":u=xl(a.href);var d=i.querySelector(Ao(u));if(d)return r.state.loading|=4,r.instance=d,It(d),d;o=Cb(a),(u=Yn.get(u))&&$f(o,u),d=(i.ownerDocument||i).createElement("link"),It(d);var _=d;return _._p=new Promise(function(x,N){_.onload=x,_.onerror=N}),Xi(d,"link",o),r.state.loading|=4,Au(d,a.precedence,i),r.instance=d;case"script":return d=kl(a.src),(u=i.querySelector(Lo(d)))?(r.instance=u,It(u),u):(o=a,(u=Yn.get(d))&&(o=y({},a),Vf(o,u)),i=i.ownerDocument||i,u=i.createElement("script"),It(u),Xi(u,"link",o),i.head.appendChild(u),r.instance=u);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(o=r.instance,r.state.loading|=4,Au(o,a.precedence,i));return r.instance}function Au(i,r,a){for(var o=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,d=u,_=0;_<o.length;_++){var x=o[_];if(x.dataset.precedence===r)d=x;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(r=a.nodeType===9?a.head:a,r.insertBefore(i,r.firstChild))}function $f(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Vf(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var Lu=null;function kb(i,r,a){if(Lu===null){var o=new Map,u=Lu=new Map;u.set(a,o)}else u=Lu,o=u.get(a),o||(o=new Map,u.set(a,o));if(o.has(i))return o;for(o.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Nr]||d[ei]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(r)||"";_=i+_;var x=o.get(_);x?x.push(d):o.set(_,[d])}}return o}function Eb(i,r,a){i=i.ownerDocument||i,i.head.insertBefore(a,r==="title"?i.querySelector("head > title"):null)}function Sk(i,r,a){if(a===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(i=r.disabled,typeof r.precedence=="string"&&i==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Tb(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function wk(i,r,a,o){if(a.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=xl(o.href),d=r.querySelector(Ao(u));if(d){r=d._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Bu.bind(i),r.then(i,i)),a.state.loading|=4,a.instance=d,It(d);return}d=r.ownerDocument||r,o=Cb(o),(u=Yn.get(u))&&$f(o,u),d=d.createElement("link"),It(d);var _=d;_._p=new Promise(function(x,N){_.onload=x,_.onerror=N}),Xi(d,"link",o),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,r),(r=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Bu.bind(i),r.addEventListener("load",a),r.addEventListener("error",a))}}var Yf=0;function Ck(i,r){return i.stylesheets&&i.count===0&&zu(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var o=setTimeout(function(){if(i.stylesheets&&zu(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+r);0<i.imgBytes&&Yf===0&&(Yf=62500*nk());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&zu(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>Yf?50:800)+r);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Bu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)zu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ou=null;function zu(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ou=new Map,r.forEach(xk,i),Ou=null,Bu.call(i))}function xk(i,r){if(!(r.state.loading&4)){var a=Ou.get(i);if(a)var o=a.get(null);else{a=new Map,Ou.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),o=_)}o&&a.set(null,o)}u=r.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||o,d===o&&a.set(null,u),a.set(_,u),this.count++,o=Bu.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),r.state.loading|=4}}var Bo={$$typeof:Y,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function kk(i,r,a,o,u,d,_,x,N){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=Li(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Li(0),this.hiddenUpdates=Li(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function Db(i,r,a,o,u,d,_,x,N,V,le,ce){return i=new kk(i,r,a,_,N,V,le,ce,x),r=1,d===!0&&(r|=24),d=kn(3,null,null,r),i.current=d,d.stateNode=i,r=Ed(),r.refCount++,i.pooledCache=r,r.refCount++,d.memoizedState={element:o,isDehydrated:a,cache:r},Md(d),i}function Rb(i){return i?(i=il,i):il}function Mb(i,r,a,o,u,d){u=Rb(u),o.context===null?o.context=u:o.pendingContext=u,o=Cs(r),o.payload={element:a},d=d===void 0?null:d,d!==null&&(o.callback=d),a=xs(i,o,r),a!==null&&(yn(a,i,r),ho(a,i,r))}function Nb(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Xf(i,r){Nb(i,r),(i=i.alternate)&&Nb(i,r)}function Ab(i){if(i.tag===13||i.tag===31){var r=fa(i,67108864);r!==null&&yn(r,i,67108864),Xf(i,67108864)}}function Lb(i){if(i.tag===13||i.tag===31){var r=Mn();r=Fi(r);var a=fa(i,r);a!==null&&yn(a,i,r),Xf(i,r)}}var ju=!0;function Ek(i,r,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=2,Gf(i,r,a,o)}finally{X.p=d,R.T=u}}function Tk(i,r,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=8,Gf(i,r,a,o)}finally{X.p=d,R.T=u}}function Gf(i,r,a,o){if(ju){var u=Zf(o);if(u===null)zf(i,r,o,Pu,a),Ob(i,o);else if(Rk(u,i,r,a,o))o.stopPropagation();else if(Ob(i,o),r&4&&-1<Dk.indexOf(i)){for(;u!==null;){var d=pr(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=_t(d.pendingLanes);if(_!==0){var x=d;for(x.pendingLanes|=2,x.entangledLanes|=2;_;){var N=1<<31-F(_);x.entanglements[1]|=N,_&=~N}xr(d),(St&6)===0&&(bu=wt()+500,Do(0))}}break;case 31:case 13:x=fa(d,2),x!==null&&yn(x,d,2),wu(),Xf(d,2)}if(d=Zf(o),d===null&&zf(i,r,o,Pu,a),d===u)break;u=d}u!==null&&o.stopPropagation()}else zf(i,r,o,null,a)}}function Zf(i){return i=rr(i),Qf(i)}var Pu=null;function Qf(i){if(Pu=null,i=On(i),i!==null){var r=c(i);if(r===null)i=null;else{var a=r.tag;if(a===13){if(i=h(r),i!==null)return i;i=null}else if(a===31){if(i=p(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return Pu=i,null}function Bb(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(Ki()){case nt:return 2;case pt:return 8;case fe:case Ue:return 32;case st:return 268435456;default:return 32}default:return 32}}var Jf=!1,Os=null,zs=null,js=null,Oo=new Map,zo=new Map,Ps=[],Dk="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 Ob(i,r){switch(i){case"focusin":case"focusout":Os=null;break;case"dragenter":case"dragleave":zs=null;break;case"mouseover":case"mouseout":js=null;break;case"pointerover":case"pointerout":Oo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":zo.delete(r.pointerId)}}function jo(i,r,a,o,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:r,domEventName:a,eventSystemFlags:o,nativeEvent:d,targetContainers:[u]},r!==null&&(r=pr(r),r!==null&&Ab(r)),i):(i.eventSystemFlags|=o,r=i.targetContainers,u!==null&&r.indexOf(u)===-1&&r.push(u),i)}function Rk(i,r,a,o,u){switch(r){case"focusin":return Os=jo(Os,i,r,a,o,u),!0;case"dragenter":return zs=jo(zs,i,r,a,o,u),!0;case"mouseover":return js=jo(js,i,r,a,o,u),!0;case"pointerover":var d=u.pointerId;return Oo.set(d,jo(Oo.get(d)||null,i,r,a,o,u)),!0;case"gotpointercapture":return d=u.pointerId,zo.set(d,jo(zo.get(d)||null,i,r,a,o,u)),!0}return!1}function zb(i){var r=On(i.target);if(r!==null){var a=c(r);if(a!==null){if(r=a.tag,r===13){if(r=h(a),r!==null){i.blockedOn=r,dn(i.priority,function(){Lb(a)});return}}else if(r===31){if(r=p(a),r!==null){i.blockedOn=r,dn(i.priority,function(){Lb(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Hu(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=Zf(i.nativeEvent);if(a===null){a=i.nativeEvent;var o=new a.constructor(a.type,a);Pn=o,a.target.dispatchEvent(o),Pn=null}else return r=pr(a),r!==null&&Ab(r),i.blockedOn=a,!1;r.shift()}return!0}function jb(i,r,a){Hu(i)&&a.delete(r)}function Mk(){Jf=!1,Os!==null&&Hu(Os)&&(Os=null),zs!==null&&Hu(zs)&&(zs=null),js!==null&&Hu(js)&&(js=null),Oo.forEach(jb),zo.forEach(jb)}function Iu(i,r){i.blockedOn===r&&(i.blockedOn=null,Jf||(Jf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Mk)))}var Uu=null;function Pb(i){Uu!==i&&(Uu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Uu===i&&(Uu=null);for(var r=0;r<i.length;r+=3){var a=i[r],o=i[r+1],u=i[r+2];if(typeof o!="function"){if(Qf(o||a)===null)continue;break}var d=pr(a);d!==null&&(i.splice(r,3),r-=3,Gd(d,{pending:!0,data:u,method:a.method,action:o},o,u))}}))}function El(i){function r(N){return Iu(N,i)}Os!==null&&Iu(Os,i),zs!==null&&Iu(zs,i),js!==null&&Iu(js,i),Oo.forEach(r),zo.forEach(r);for(var a=0;a<Ps.length;a++){var o=Ps[a];o.blockedOn===i&&(o.blockedOn=null)}for(;0<Ps.length&&(a=Ps[0],a.blockedOn===null);)zb(a),a.blockedOn===null&&Ps.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(o=0;o<a.length;o+=3){var u=a[o],d=a[o+1],_=u[xi]||null;if(typeof d=="function")_||Pb(a);else if(_){var x=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[xi]||null)x=_.formAction;else if(Qf(u)!==null)continue}else x=_.action;typeof x=="function"?a[o+1]=x:(a.splice(o,3),o-=3),Pb(a)}}}function Hb(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function r(){u!==null&&(u(),u=null),o||setTimeout(a,20)}function a(){if(!o&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(a,100),function(){o=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),u!==null&&(u(),u=null)}}}function ep(i){this._internalRoot=i}Ku.prototype.render=ep.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(s(409));var a=r.current,o=Mn();Mb(a,o,i,r,null,null)},Ku.prototype.unmount=ep.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Mb(i.current,2,null,i,null,null),wu(),r[wn]=null}};function Ku(i){this._internalRoot=i}Ku.prototype.unstable_scheduleHydration=function(i){if(i){var r=sn();i={blockedOn:null,target:i,priority:r};for(var a=0;a<Ps.length&&r!==0&&r<Ps[a].priority;a++);Ps.splice(a,0,i),a===0&&zb(i)}};var Ib=t.version;if(Ib!=="19.2.6")throw Error(s(527,Ib,"19.2.6"));X.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(r),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var Nk={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Wu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Wu.isDisabled&&Wu.supportsFiber)try{Tt=Wu.inject(Nk),Dt=Wu}catch{}}return Ho.createRoot=function(i,r){if(!l(i))throw Error(s(299));var a=!1,o="",u=Vv,d=Yv,_=Xv;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(o=r.identifierPrefix),r.onUncaughtError!==void 0&&(u=r.onUncaughtError),r.onCaughtError!==void 0&&(d=r.onCaughtError),r.onRecoverableError!==void 0&&(_=r.onRecoverableError)),r=Db(i,1,!1,null,null,a,o,null,u,d,_,Hb),i[wn]=r.current,Of(i),new ep(r)},Ho.hydrateRoot=function(i,r,a){if(!l(i))throw Error(s(299));var o=!1,u="",d=Vv,_=Yv,x=Xv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(x=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),r=Db(i,1,!0,r,a??null,o,u,N,d,_,x,Hb),r.context=Rb(null),a=r.current,o=Mn(),o=Fi(o),u=Cs(o),u.callback=null,xs(a,u,o),a=o,r.current.lanes=a,Gt(r,a),xr(r),i[wn]=r.current,Of(i),new Ku(r)},Ho.version="19.2.6",Ho}var Gb;function Uk(){if(Gb)return np.exports;Gb=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(),np.exports=Ik(),np.exports}var Kk=Uk();class hr extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function Hh(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Al(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",Je("POST",t)),login:t=>Ne(e,"/api/auth/login",Je("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",Je("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",Je("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",Je("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await Ml(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",Je("POST",t)),removeNetwork:async t=>{await Ml(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),addAgent:t=>Ne(e,"/api/agents",Je("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",Je("PUT",{serverIds:t})),renameAgent:(t,n)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,Je("PATCH",{name:n})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",Je("PATCH",{name:t})),removeAgent:async t=>{await Ml(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ne(e,"/api/stats"),getAgentStats:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ne(e,"/api/version"),checkUpdate:()=>Ne(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ne(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ne(e,"/api/terminals"),getTerminalLayout:()=>Ne(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ne(e,"/api/terminal-layout",Je("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",Je("POST",t)),listFiles:t=>Ne(e,"/api/files/list",Je("POST",t)),readFile:t=>Ne(e,"/api/files/read",Je("POST",t)),writeFile:t=>Ne(e,"/api/files/write",Je("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",Je("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",Je("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",Je("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",Je("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",Je("POST",t)),previewFile:t=>iw(e,"/api/files/preview",Je("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",Je("POST",t)),closeTerminal:async t=>{await Ml(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,Je("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Al(n)}`),getTerminalTranscriptHistory:(t,n={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Al(n)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",Je("PUT",t)),deleteNotificationAsset:async t=>{await Ml(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:t=>Ne(e,`/api/push-notifications/status${t?Al({clientId:t}):""}`),preparePushNotifications:t=>Ne(e,"/api/push-notifications/prepare",Je("POST",{clientId:t})),subscribePushNotifications:t=>Ne(e,"/api/push-notifications/subscription",Je("POST",t)),updatePushNotificationDevice:t=>Ne(e,"/api/push-notifications/device",Je("PATCH",t)),unsubscribePushNotifications:t=>Ne(e,"/api/push-notifications/unsubscribe",Je("POST",t)),updatePushPresence:t=>Ne(e,"/api/push-notifications/presence",Je("POST",t))}}function pc(e,t=fetch){const n=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,n("terminals")),createTerminal:(s={})=>Ne(t,n("terminals"),Je("POST",s)),closeTerminal:async s=>{await Ml(t,n(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,l)=>Ne(t,n(`terminals/${encodeURIComponent(s)}`),Je("PATCH",{title:l})),getTerminalHistory:(s,l={})=>Ne(t,`${n(`terminals/${encodeURIComponent(s)}/history`)}${Al(l)}`),getTerminalTranscriptHistory:(s,l={})=>Ne(t,`${n(`terminals/${encodeURIComponent(s)}/transcript-history`)}${Al(l)}`),getTerminalTranscriptSource:s=>Ne(t,n(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Ne(t,n("terminal-layout")),saveTerminalLayout:s=>Ne(t,n("terminal-layout"),Je("PUT",s)),createFileRoot:s=>Ne(t,n("files/root"),Je("POST",s)),listFiles:s=>Ne(t,n("files/list"),Je("POST",s)),readFile:s=>Ne(t,n("files/read"),Je("POST",s)),writeFile:s=>Ne(t,n("files/write"),Je("POST",s)),createFileEntry:s=>Ne(t,n("files/create"),Je("POST",s)),moveFileEntry:s=>Ne(t,n("files/move"),Je("POST",s)),previewDeleteFileEntry:s=>Ne(t,n("files/delete-preview"),Je("POST",s)),deleteFileEntry:s=>Ne(t,n("files/delete"),Je("POST",s)),openFileInTerminal:s=>Ne(t,n("files/open"),Je("POST",s)),previewFile:s=>iw(t,n("files/preview"),Je("POST",s)),createWebSocketUrl:(s,l=window.location.href)=>Wk(n(`terminals/${encodeURIComponent(s)}/ws`),l)}}function Wk(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function Je(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Al(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),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);const n=t.toString();return n?`?${n}`:""}async function Ne(e,t,n){const s=await e(t,n??{credentials:"same-origin"});await yg(s);try{return await s.json()}catch{throw new hr(s.status,"invalid_json_response")}}async function Ml(e,t,n){const s=await e(t,n);await yg(s)}async function iw(e,t,n){const s=await e(t,n);return await yg(s),s.blob()}async function yg(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),s=typeof n.error=="string"?n.error:n.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new hr(e.status,t)}const bg="nterminal.theme.id",nw="nterminal.theme.accent",Hp="nterminal:theme",_h=[{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",...Zb({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",...Zb({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Hl="midnight";function Ih(e){return _h.some(t=>t.id===e)?e:Hl}function Sg(e){return _h.find(t=>t.id===e)??_h[0]}function Zs(){if(typeof window>"u")return Hl;try{const e=window.localStorage.getItem(bg);return e?Ih(e):Yk(window.localStorage.getItem(nw))}catch{return Hl}}function Fk(e){const t=Ih(e);if(typeof window<"u"){try{window.localStorage.setItem(bg,t)}catch{}wg(t),window.dispatchEvent(new CustomEvent(Hp,{detail:t}))}return t}function wg(e=Zs()){if(typeof document>"u")return;const t=Sg(Ih(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),it(n,"--nt-bg",t.tokens.bg),it(n,"--nt-bg-2",t.tokens.bg2),it(n,"--nt-bg-sidebar",t.tokens.bgSidebar),it(n,"--nt-line",t.tokens.line),it(n,"--nt-line-2",t.tokens.line2),it(n,"--nt-fg",t.tokens.fg),it(n,"--nt-fg-2",t.tokens.fg2),it(n,"--nt-fg-3",t.tokens.fg3),it(n,"--nt-fg-4",t.tokens.fg4),it(n,"--nt-accent",t.tokens.accent),it(n,"--nt-accent-soft",t.tokens.accentSoft),it(n,"--nt-accent-glow",t.tokens.accentGlow),it(n,"--nt-on-accent",t.tokens.onAccent),it(n,"--nt-ok",t.tokens.ok),it(n,"--nt-danger",t.tokens.danger),it(n,"--nt-on-danger",t.tokens.onDanger),it(n,"--nt-danger-soft",t.tokens.dangerSoft),it(n,"--nt-danger-line",t.tokens.dangerLine),it(n,"--nt-warning",t.tokens.warning),it(n,"--nt-warn",t.tokens.warning),it(n,"--nt-warning-soft",t.tokens.warningSoft),it(n,"--nt-warning-glow",t.tokens.warningGlow),it(n,"--nt-scrim",t.tokens.scrim),it(n,"--nt-scrim-soft",t.tokens.scrimSoft),it(n,"--nt-shadow",t.tokens.shadow),it(n,"--nt-shadow-strong",t.tokens.shadowStrong),it(n,"--nt-floating-bg",t.tokens.floatingBg),it(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),it(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),it(n,"--nt-subtle-fill",t.tokens.subtleFill),it(n,"--nt-hover-fill",t.tokens.hoverFill),it(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),it(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),it(n,"--nt-transcript-user",t.tokens.transcriptUser),it(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),it(n,"--nt-transcript-tool",t.tokens.transcriptTool),it(n,"--nt-transcript-command",t.tokens.transcriptCommand),it(n,"--nt-transcript-code",t.tokens.transcriptCode),it(n,"--nt-transcript-search",t.tokens.transcriptSearch),it(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),it(n,"--nt-qr-bg",t.tokens.qrBg)}function qk(e=Zs()){return Sg(Ih(e)).xterm}function Cg(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===bg||n.key===nw)&&(wg(Zs()),e())};return window.addEventListener(Hp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Hp,e),window.removeEventListener("storage",t)}}function it(e,t,n){e.style.setProperty(t,n)}function Zb(e){const t=$k(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 $k(e){const t=[];for(let n=16;n<=e;n+=1)t.push(Vk(n));return t}function Vk(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],s=n[Math.floor(t/36)%6],l=n[Math.floor(t/6)%6],c=n[t%6];return Qb(s,l,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return Qb(t,t,t)}return"#000000"}function Qb(e,t,n){return`#${lp(e)}${lp(t)}${lp(n)}`}function lp(e){return e.toString(16).padStart(2,"0")}function Yk(e){return e==="signal-red"?"signal-red":Hl}function rw(){const e=v.useSyncExternalStore(Cg,Zs,()=>Hl);return Sg(e).mode==="light"?"-light":""}function sw({size:e=22}){const t=rw();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function aw({height:e=18}){const t=rw(),n=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var Go=tw();const Uh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ql(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function xg(e){return"nodeType"in e}function Sn(e){var t,n;return e?ql(e)?e:xg(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function kg(e){const{Document:t}=Sn(e);return e instanceof t}function Dc(e){return ql(e)?!1:e instanceof Sn(e).HTMLElement}function lw(e){return e instanceof Sn(e).SVGElement}function $l(e){return e?ql(e)?e.document:xg(e)?kg(e)?e:Dc(e)||lw(e)?e.ownerDocument:document:document:document}const Qs=Uh?v.useLayoutEffect:v.useEffect;function Eg(e){const t=v.useRef(e);return Qs(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,s=new Array(n),l=0;l<n;l++)s[l]=arguments[l];return t.current==null?void 0:t.current(...s)},[])}function Xk(){const e=v.useRef(null),t=v.useCallback((s,l)=>{e.current=setInterval(s,l)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function mc(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return Qs(()=>{n.current!==e&&(n.current=e)},t),n}function Rc(e,t){const n=v.useRef();return v.useMemo(()=>{const s=e(n.current);return n.current=s,s},[...t])}function vh(e){const t=Eg(e),n=v.useRef(null),s=v.useCallback(l=>{l!==n.current&&t?.(l,n.current),n.current=l},[]);return[n,s]}function Ip(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let op={};function Kh(e,t){return v.useMemo(()=>{if(t)return t;const n=op[e]==null?0:op[e]+1;return op[e]=n,e+"-"+n},[e,t])}function ow(e){return function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),l=1;l<n;l++)s[l-1]=arguments[l];return s.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const b=c[g];b!=null&&(c[g]=b+e*f)}return c},{...t})}}const jl=ow(1),yh=ow(-1);function Gk(e){return"clientX"in e&&"clientY"in e}function cw(e){if(!e)return!1;const{KeyboardEvent:t}=Sn(e.target);return t&&e instanceof t}function Zk(e){if(!e)return!1;const{TouchEvent:t}=Sn(e.target);return t&&e instanceof t}function Up(e){if(Zk(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 Gk(e)?{x:e.clientX,y:e.clientY}:null}const Kp=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[Kp.Translate.toString(e),Kp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:s}=e;return t+" "+n+"ms "+s}}}),Jb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Qk(e){return e.matches(Jb)?e:e.querySelector(Jb)}const Jk={display:"none"};function eE(e){let{id:t,value:n}=e;return Mi.createElement("div",{id:t,style:Jk},n)}function tE(e){let{id:t,announcement:n,ariaLiveType:s="assertive"}=e;const l={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 Mi.createElement("div",{id:t,style:l,role:"status","aria-live":s,"aria-atomic":!0},n)}function iE(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const uw=v.createContext(null);function nE(e){const t=v.useContext(uw);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function rE(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:l,event:c}=s;e.forEach(h=>{var p;return(p=h[l])==null?void 0:p.call(h,c)})},[e]),t]}const sE={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
+ `},aE={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 lE(e){let{announcements:t=aE,container:n,hiddenTextDescribedById:s,screenReaderInstructions:l=sE}=e;const{announce:c,announcement:h}=iE(),p=Kh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),nE(v.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:w}=y;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(y){let{active:S,over:w}=y;c(t.onDragOver({active:S,over:w}))},onDragEnd(y){let{active:S,over:w}=y;c(t.onDragEnd({active:S,over:w}))},onDragCancel(y){let{active:S,over:w}=y;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const b=Mi.createElement(Mi.Fragment,null,Mi.createElement(eE,{id:s,value:l.draggable}),Mi.createElement(tE,{id:p,announcement:h}));return n?Go.createPortal(b,n):b}var Ri;(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"})(Ri||(Ri={}));function bh(){}function eS(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function oE(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const dr=Object.freeze({x:0,y:0});function cE(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function uE(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function hE(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),l=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=l-s,p=c-n;if(s<l&&n<c){const g=t.width*t.height,f=e.width*e.height,b=h*p,y=b/(g+f-b);return Number(y.toFixed(4))}return 0}const dE=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const l=[];for(const c of s){const{id:h}=c,p=n.get(h);if(p){const g=hE(p,t);g>0&&l.push({id:h,data:{droppableContainer:c,value:g}})}}return l.sort(cE)};function fE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function hw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:dr}function pE(e){return function(n){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];return l.reduce((h,p)=>({...h,top:h.top+e*p.y,bottom:h.bottom+e*p.y,left:h.left+e*p.x,right:h.right+e*p.x}),{...n})}}const mE=pE(1);function gE(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 _E(e,t,n){const s=gE(t);if(!s)return e;const{scaleX:l,scaleY:c,x:h,y:p}=s,g=e.left-h-(1-l)*parseFloat(n),f=e.top-p-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),b=l?e.width/l:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:g+b,bottom:f+y,left:g}}const vE={ignoreTransform:!1};function Mc(e,t){t===void 0&&(t=vE);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=Sn(e).getComputedStyle(e);f&&(n=_E(n,f,b))}const{top:s,left:l,width:c,height:h,bottom:p,right:g}=n;return{top:s,left:l,width:c,height:h,bottom:p,right:g}}function tS(e){return Mc(e,{ignoreTransform:!0})}function yE(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function bE(e,t){return t===void 0&&(t=Sn(e).getComputedStyle(e)),t.position==="fixed"}function SE(e,t){t===void 0&&(t=Sn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=t[l];return typeof c=="string"?n.test(c):!1})}function Tg(e,t){const n=[];function s(l){if(t!=null&&n.length>=t||!l)return n;if(kg(l)&&l.scrollingElement!=null&&!n.includes(l.scrollingElement))return n.push(l.scrollingElement),n;if(!Dc(l)||lw(l)||n.includes(l))return n;const c=Sn(e).getComputedStyle(l);return l!==e&&SE(l,c)&&n.push(l),bE(l,c)?n:s(l.parentNode)}return e?s(e):n}function dw(e){const[t]=Tg(e,1);return t??null}function cp(e){return!Uh||!e?null:ql(e)?e:xg(e)?kg(e)||e===$l(e).scrollingElement?window:Dc(e)?e:null:null}function fw(e){return ql(e)?e.scrollX:e.scrollLeft}function pw(e){return ql(e)?e.scrollY:e.scrollTop}function Wp(e){return{x:fw(e),y:pw(e)}}var ji;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ji||(ji={}));function mw(e){return!Uh||!e?!1:e===document.scrollingElement}function gw(e){const t={x:0,y:0},n=mw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},l=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=s.y,p=e.scrollLeft>=s.x;return{isTop:l,isLeft:c,isBottom:h,isRight:p,maxScroll:s,minScroll:t}}const wE={x:.2,y:.2};function CE(e,t,n,s,l){let{top:c,left:h,right:p,bottom:g}=n;s===void 0&&(s=10),l===void 0&&(l=wE);const{isTop:f,isBottom:b,isLeft:y,isRight:S}=gw(e),w={x:0,y:0},k={x:0,y:0},T={height:t.height*l.y,width:t.width*l.x};return!f&&c<=t.top+T.height?(w.y=ji.Backward,k.y=s*Math.abs((t.top+T.height-c)/T.height)):!b&&g>=t.bottom-T.height&&(w.y=ji.Forward,k.y=s*Math.abs((t.bottom-T.height-g)/T.height)),!S&&p>=t.right-T.width?(w.x=ji.Forward,k.x=s*Math.abs((t.right-T.width-p)/T.width)):!y&&h<=t.left+T.width&&(w.x=ji.Backward,k.x=s*Math.abs((t.left+T.width-h)/T.width)),{direction:w,speed:k}}function xE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:n,right:s,bottom:l}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:l,width:e.clientWidth,height:e.clientHeight}}function _w(e){return e.reduce((t,n)=>jl(t,Wp(n)),dr)}function kE(e){return e.reduce((t,n)=>t+fw(n),0)}function EE(e){return e.reduce((t,n)=>t+pw(n),0)}function TE(e,t){if(t===void 0&&(t=Mc),!e)return;const{top:n,left:s,bottom:l,right:c}=t(e);dw(e)&&(l<=0||c<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const DE=[["x",["left","right"],kE],["y",["top","bottom"],EE]];class Dg{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 s=Tg(n),l=_w(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of DE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(s),b=l[c]-f;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class lc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var l;(l=this.target)==null||l.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function RE(e){const{EventTarget:t}=Sn(e);return e instanceof t?e:$l(e)}function up(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var Zn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Zn||(Zn={}));function iS(e){e.preventDefault()}function ME(e){e.stopPropagation()}var zt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(zt||(zt={}));const vw={start:[zt.Space,zt.Enter],cancel:[zt.Esc],end:[zt.Space,zt.Enter,zt.Tab]},NE=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case zt.Right:return{...n,x:n.x+25};case zt.Left:return{...n,x:n.x-25};case zt.Down:return{...n,y:n.y+25};case zt.Up:return{...n,y:n.y-25}}};class yw{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 lc($l(n)),this.windowListeners=new lc(Sn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zn.Resize,this.handleCancel),this.windowListeners.add(Zn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&TE(s),n(dr)}handleKeyDown(t){if(cw(t)){const{active:n,context:s,options:l}=this.props,{keyboardCodes:c=vw,coordinateGetter:h=NE,scrollBehavior:p="smooth"}=l,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,b=f?{x:f.left,y:f.top}:dr;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:n,context:s.current,currentCoordinates:b});if(y){const S=yh(y,b),w={x:0,y:0},{scrollableAncestors:k}=s.current;for(const T of k){const L=t.code,{isTop:A,isRight:O,isLeft:Y,isBottom:P,maxScroll:q,minScroll:re}=gw(T),ne=xE(T),ue={x:Math.min(L===zt.Right?ne.right-ne.width/2:ne.right,Math.max(L===zt.Right?ne.left:ne.left+ne.width/2,y.x)),y:Math.min(L===zt.Down?ne.bottom-ne.height/2:ne.bottom,Math.max(L===zt.Down?ne.top:ne.top+ne.height/2,y.y))},ye=L===zt.Right&&!O||L===zt.Left&&!Y,U=L===zt.Down&&!P||L===zt.Up&&!A;if(ye&&ue.x!==y.x){const K=T.scrollLeft+S.x,W=L===zt.Right&&K<=q.x||L===zt.Left&&K>=re.x;if(W&&!S.y){T.scrollTo({left:K,behavior:p});return}W?w.x=T.scrollLeft-K:w.x=L===zt.Right?T.scrollLeft-q.x:T.scrollLeft-re.x,w.x&&T.scrollBy({left:-w.x,behavior:p});break}else if(U&&ue.y!==y.y){const K=T.scrollTop+S.y,W=L===zt.Down&&K<=q.y||L===zt.Up&&K>=re.y;if(W&&!S.x){T.scrollTo({top:K,behavior:p});return}W?w.y=T.scrollTop-K:w.y=L===zt.Down?T.scrollTop-q.y:T.scrollTop-re.y,w.y&&T.scrollBy({top:-w.y,behavior:p});break}}this.handleMove(t,jl(yh(y,this.referenceCoordinates),w))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(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()}}yw.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=vw,onActivation:l}=t,{active:c}=n;const{code:h}=e.nativeEvent;if(s.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function nS(e){return!!(e&&"distance"in e)}function rS(e){return!!(e&&"delay"in e)}class Rg{constructor(t,n,s){var l;s===void 0&&(s=RE(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:h}=c;this.props=t,this.events=n,this.document=$l(h),this.documentListeners=new lc(this.document),this.listeners=new lc(s),this.windowListeners=new lc(Sn(h)),this.initialCoordinates=(l=Up(c))!=null?l:dr,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:s}}}=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(Zn.Resize,this.handleCancel),this.windowListeners.add(Zn.DragStart,iS),this.windowListeners.add(Zn.VisibilityChange,this.handleCancel),this.windowListeners.add(Zn.ContextMenu,iS),this.documentListeners.add(Zn.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(rS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(nS(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:s,onPending:l}=this.props;l(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Zn.Click,ME,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zn.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:l,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!l)return;const g=(n=Up(t))!=null?n:dr,f=yh(l,g);if(!s&&p){if(nS(p)){if(p.tolerance!=null&&up(f,p.tolerance))return this.handleCancel();if(up(f,p.distance))return this.handleStart()}if(rS(p)&&up(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(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===zt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const AE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class bw extends Rg{constructor(t){const{event:n}=t,s=$l(n.target);super(t,AE,s)}}bw.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const LE={move:{name:"mousemove"},end:{name:"mouseup"}};var Fp;(function(e){e[e.RightClick=2]="RightClick"})(Fp||(Fp={}));class Sw extends Rg{constructor(t){super(t,LE,$l(t.event.target))}}Sw.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===Fp.RightClick?!1:(s?.({event:n}),!0)}}];const hp={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ww extends Rg{constructor(t){super(t,hp)}static setup(){return window.addEventListener(hp.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(hp.move.name,t)};function t(){}}}ww.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:l}=n;return l.length>1?!1:(s?.({event:n}),!0)}}];var oc;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(oc||(oc={}));var Sh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Sh||(Sh={}));function BE(e){let{acceleration:t,activator:n=oc.Pointer,canScroll:s,draggingRect:l,enabled:c,interval:h=5,order:p=Sh.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:S}=e;const w=zE({delta:y,disabled:!c}),[k,T]=Xk(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),O=v.useMemo(()=>{switch(n){case oc.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case oc.DraggableRect:return l}},[n,l,g]),Y=v.useRef(null),P=v.useCallback(()=>{const re=Y.current;if(!re)return;const ne=L.current.x*A.current.x,ue=L.current.y*A.current.y;re.scrollBy(ne,ue)},[]),q=v.useMemo(()=>p===Sh.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!O){T();return}for(const re of q){if(s?.(re)===!1)continue;const ne=f.indexOf(re),ue=b[ne];if(!ue)continue;const{direction:ye,speed:U}=CE(re,ue,O,t,S);for(const K of["x","y"])w[K][ye[K]]||(U[K]=0,ye[K]=0);if(U.x>0||U.y>0){T(),Y.current=re,k(P,h),L.current=U,A.current=ye;return}}L.current={x:0,y:0},A.current={x:0,y:0},T()},[t,P,s,T,c,h,JSON.stringify(O),JSON.stringify(w),k,f,q,b,JSON.stringify(S)])}const OE={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function zE(e){let{delta:t,disabled:n}=e;const s=Ip(t);return Rc(l=>{if(n||!s||!l)return OE;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[ji.Backward]:l.x[ji.Backward]||c.x===-1,[ji.Forward]:l.x[ji.Forward]||c.x===1},y:{[ji.Backward]:l.y[ji.Backward]||c.y===-1,[ji.Forward]:l.y[ji.Forward]||c.y===1}}},[n,t,s])}function jE(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return Rc(l=>{var c;return t==null?null:(c=s??l)!=null?c:null},[s,t])}function PE(e,t){return v.useMemo(()=>e.reduce((n,s)=>{const{sensor:l}=s,c=l.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,s)}));return[...n,...c]},[]),[e,t])}var gc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(gc||(gc={}));var qp;(function(e){e.Optimized="optimized"})(qp||(qp={}));const sS=new Map;function HE(e,t){let{dragging:n,dependencies:s,config:l}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=l,b=v.useRef(e),y=L(),S=mc(y),w=v.useCallback(function(A){A===void 0&&(A=[]),!S.current&&h(O=>O===null?A:O.concat(A.filter(Y=>!O.includes(Y))))},[S]),k=v.useRef(null),T=Rc(A=>{if(y&&!n)return sS;if(!A||A===sS||b.current!==e||c!=null){const O=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){O.set(Y.id,Y.rect.current);continue}const P=Y.node.current,q=P?new Dg(g(P),P):null;Y.rect.current=q,q&&O.set(Y.id,q)}return O}return A},[e,c,n,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||w()},[n,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof p!="number"||k.current!==null||(k.current=setTimeout(()=>{w(),k.current=null},p))},[p,y,w,...s]),{droppableRects:T,measureDroppableContainers:w,measuringScheduled:c!=null};function L(){switch(f){case gc.Always:return!1;case gc.BeforeDragging:return n;default:return!n}}}function Cw(e,t){return Rc(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function IE(e,t){return Cw(e,t)}function UE(e){let{callback:t,disabled:n}=e;const s=Eg(t),l=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,n]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function Wh(e){let{callback:t,disabled:n}=e;const s=Eg(t),l=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[n]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function KE(e){return new Dg(Mc(e),e)}function aS(e,t,n){t===void 0&&(t=KE);const[s,l]=v.useState(null);function c(){l(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??n)!=null?f:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=UE({callback(g){if(e)for(const f of g){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Wh({callback:c});return Qs(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),s}function WE(e){const t=Cw(e);return hw(e,t)}const lS=[];function FE(e){const t=v.useRef(e),n=Rc(s=>e?s&&s!==lS&&e&&t.current&&e.parentNode===t.current.parentNode?s:Tg(e):lS,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function qE(e){const[t,n]=v.useState(null),s=v.useRef(e),l=v.useCallback(c=>{const h=cp(c.target);h&&n(p=>p?(p.set(h,Wp(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){h(c);const p=e.map(g=>{const f=cp(g);return f?(f.addEventListener("scroll",l,{passive:!0}),[f,Wp(f)]):null}).filter(g=>g!=null);n(p.length?new Map(p):null),s.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=cp(g);f?.removeEventListener("scroll",l)})}},[l,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>jl(c,h),dr):_w(e):dr,[e,t])}function oS(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const s=e!==dr;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?yh(e,n.current):dr}function $E(e){v.useEffect(()=>{if(!Uh)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function VE(e,t){return v.useMemo(()=>e.reduce((n,s)=>{let{eventName:l,handler:c}=s;return n[l]=h=>{c(h,t)},n},{}),[e,t])}function xw(e){return v.useMemo(()=>e?yE(e):null,[e])}const cS=[];function YE(e,t){t===void 0&&(t=Mc);const[n]=e,s=xw(n?Sn(n):null),[l,c]=v.useState(cS);function h(){c(()=>e.length?e.map(g=>mw(g)?s:new Dg(t(g),g)):cS)}const p=Wh({callback:h});return Qs(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),l}function XE(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Dc(t)?t:e}function GE(e){let{measure:t}=e;const[n,s]=v.useState(null),l=v.useCallback(f=>{for(const{target:b}of f)if(Dc(b)){s(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=Wh({callback:l}),h=v.useCallback(f=>{const b=XE(f);c?.disconnect(),b&&c?.observe(b),s(b?t(b):null)},[t,c]),[p,g]=vh(h);return v.useMemo(()=>({nodeRef:p,rect:n,setRef:g}),[n,p,g])}const ZE=[{sensor:bw,options:{}},{sensor:yw,options:{}}],QE={current:{}},rh={draggable:{measure:tS},droppable:{measure:tS,strategy:gc.WhileDragging,frequency:qp.Optimized},dragOverlay:{measure:Mc}};class cc 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,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const JE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new cc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:bh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:rh,measureDroppableContainers:bh,windowRect:null,measuringScheduled:!1},e2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:bh,draggableNodes:new Map,over:null,measureDroppableContainers:bh},Fh=v.createContext(e2),t2=v.createContext(JE);function i2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new cc}}}function n2(e,t){switch(t.type){case Ri.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ri.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 Ri.DragEnd:case Ri.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ri.RegisterDroppable:{const{element:n}=t,{id:s}=n,l=new cc(e.droppable.containers);return l.set(s,n),{...e,droppable:{...e.droppable,containers:l}}}case Ri.SetDroppableDisabled:{const{id:n,key:s,disabled:l}=t,c=e.droppable.containers.get(n);if(!c||s!==c.key)return e;const h=new cc(e.droppable.containers);return h.set(n,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:h}}}case Ri.UnregisterDroppable:{const{id:n,key:s}=t,l=e.droppable.containers.get(n);if(!l||s!==l.key)return e;const c=new cc(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function r2(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:l}=v.useContext(Fh),c=Ip(s),h=Ip(n?.id);return v.useEffect(()=>{if(!t&&!s&&c&&h!=null){if(!cw(c)||document.activeElement===c.target)return;const p=l.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[g.current,f.current]){if(!b)continue;const y=Qk(b);if(y){y.focus();break}}})}},[s,t,l,h,c]),null}function s2(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...s}),n):n}function a2(e){return v.useMemo(()=>({draggable:{...rh.draggable,...e?.draggable},droppable:{...rh.droppable,...e?.droppable},dragOverlay:{...rh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function l2(e){let{activeNode:t,measure:n,initialRect:s,config:l=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof l=="boolean"?{x:l,y:l}:l;Qs(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=n(f),y=hw(b,s);if(h||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=dw(f);S&&S.scrollBy({top:y.y,left:y.x})}},[t,h,p,s,n])}const kw=v.createContext({...dr,scaleX:1,scaleY:1});var $s;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})($s||($s={}));const o2=v.memo(function(t){var n,s,l,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:b=ZE,collisionDetection:y=dE,measuring:S,modifiers:w,...k}=t;const T=v.useReducer(n2,void 0,i2),[L,A]=T,[O,Y]=rE(),[P,q]=v.useState($s.Uninitialized),re=P===$s.Initialized,{draggable:{active:ne,nodes:ue,translate:ye},droppable:{containers:U}}=L,K=ne!=null?ue.get(ne):null,W=v.useRef({initial:null,translated:null}),H=v.useMemo(()=>{var Ct;return ne!=null?{id:ne,data:(Ct=K?.data)!=null?Ct:QE,rect:W}:null},[ne,K]),j=v.useRef(null),[ae,R]=v.useState(null),[X,Z]=v.useState(null),Ce=mc(k,Object.values(k)),Te=Kh("DndDescribedBy",h),M=v.useMemo(()=>U.getEnabled(),[U]),Q=a2(S),{droppableRects:he,measureDroppableContainers:ge,measuringScheduled:_e}=HE(M,{dragging:re,dependencies:[ye.x,ye.y],config:Q.droppable}),Se=jE(ue,ne),Ee=v.useMemo(()=>X?Up(X):null,[X]),De=Zi(),Ie=IE(Se,Q.draggable.measure);l2({activeNode:ne!=null?ue.get(ne):null,config:De.layoutShiftCompensation,initialRect:Ie,measure:Q.draggable.measure});const se=aS(Se,Q.draggable.measure,Ie),me=aS(Se?Se.parentElement:null),Le=v.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:he,draggableNodes:ue,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=U.getNodeFor((n=Le.current.over)==null?void 0:n.id),Me=GE({measure:Q.dragOverlay.measure}),Pe=(s=Me.nodeRef.current)!=null?s:Se,je=re?(l=Me.rect)!=null?l:se:null,ie=!!(Me.nodeRef.current&&Me.rect),xe=WE(ie?null:se),Re=xw(Pe?Sn(Pe):null),Be=FE(re?be??Se:null),Oe=YE(Be),rt=s2(w,{transform:{x:ye.x-xe.x,y:ye.y-xe.y,scaleX:1,scaleY:1},activatorEvent:X,active:H,activeNodeRect:se,containerNodeRect:me,draggingNodeRect:je,over:Le.current.over,overlayNodeRect:Me.rect,scrollableAncestors:Be,scrollableAncestorRects:Oe,windowRect:Re}),qt=Ee?jl(Ee,ye):null,wt=qE(Be),Ki=oS(wt),nt=oS(wt,[se]),pt=jl(rt,Ki),fe=je?mE(je,rt):null,Ue=H&&fe?y({active:H,collisionRect:fe,droppableRects:he,droppableContainers:M,pointerCoordinates:qt}):null,st=uE(Ue,"id"),[at,Et]=v.useState(null),Tt=ie?rt:jl(rt,nt),Dt=fE(Tt,(c=at?.rect)!=null?c:null,se),Rt=v.useRef(null),F=v.useCallback((Ct,_t)=>{let{sensor:Pt,options:li}=_t;if(j.current==null)return;const wi=ue.get(j.current);if(!wi)return;const jt=Ct.nativeEvent,Li=new Pt({active:j.current,activeNode:wi,event:jt,options:li,context:Le,onAbort(Ht){if(!ue.get(Ht))return;const{onDragAbort:bt}=Ce.current,oi={id:Ht};bt?.(oi),O({type:"onDragAbort",event:oi})},onPending(Ht,Wi,bt,oi){if(!ue.get(Ht))return;const{onDragPending:Ci}=Ce.current,sn={id:Ht,constraint:Wi,initialCoordinates:bt,offset:oi};Ci?.(sn),O({type:"onDragPending",event:sn})},onStart(Ht){const Wi=j.current;if(Wi==null)return;const bt=ue.get(Wi);if(!bt)return;const{onDragStart:oi}=Ce.current,Fi={activatorEvent:jt,active:{id:Wi,data:bt.data,rect:W}};Go.unstable_batchedUpdates(()=>{oi?.(Fi),q($s.Initializing),A({type:Ri.DragStart,initialCoordinates:Ht,active:Wi}),O({type:"onDragStart",event:Fi}),R(Rt.current),Z(jt)})},onMove(Ht){A({type:Ri.DragMove,coordinates:Ht})},onEnd:Gt(Ri.DragEnd),onCancel:Gt(Ri.DragCancel)});Rt.current=Li;function Gt(Ht){return async function(){const{active:bt,collisions:oi,over:Fi,scrollAdjustedTranslate:Ci}=Le.current;let sn=null;if(bt&&Ci){const{cancelDrop:dn}=Ce.current;sn={activatorEvent:jt,active:bt,collisions:oi,delta:Ci,over:Fi},Ht===Ri.DragEnd&&typeof dn=="function"&&await Promise.resolve(dn(sn))&&(Ht=Ri.DragCancel)}j.current=null,Go.unstable_batchedUpdates(()=>{A({type:Ht}),q($s.Uninitialized),Et(null),R(null),Z(null),Rt.current=null;const dn=Ht===Ri.DragEnd?"onDragEnd":"onDragCancel";if(sn){const Bi=Ce.current[dn];Bi?.(sn),O({type:dn,event:sn})}})}}},[ue]),qe=v.useCallback((Ct,_t)=>(Pt,li)=>{const wi=Pt.nativeEvent,jt=ue.get(li);if(j.current!==null||!jt||wi.dndKit||wi.defaultPrevented)return;const Li={active:jt};Ct(Pt,_t.options,Li)===!0&&(wi.dndKit={capturedBy:_t.sensor},j.current=li,F(Pt,_t))},[ue,F]),mt=PE(b,qe);$E(b),Qs(()=>{se&&P===$s.Initializing&&q($s.Initialized)},[se,P]),v.useEffect(()=>{const{onDragMove:Ct}=Ce.current,{active:_t,activatorEvent:Pt,collisions:li,over:wi}=Le.current;if(!_t||!Pt)return;const jt={active:_t,activatorEvent:Pt,collisions:li,delta:{x:pt.x,y:pt.y},over:wi};Go.unstable_batchedUpdates(()=>{Ct?.(jt),O({type:"onDragMove",event:jt})})},[pt.x,pt.y]),v.useEffect(()=>{const{active:Ct,activatorEvent:_t,collisions:Pt,droppableContainers:li,scrollAdjustedTranslate:wi}=Le.current;if(!Ct||j.current==null||!_t||!wi)return;const{onDragOver:jt}=Ce.current,Li=li.get(st),Gt=Li&&Li.rect.current?{id:Li.id,rect:Li.rect.current,data:Li.data,disabled:Li.disabled}:null,Ht={active:Ct,activatorEvent:_t,collisions:Pt,delta:{x:wi.x,y:wi.y},over:Gt};Go.unstable_batchedUpdates(()=>{Et(Gt),jt?.(Ht),O({type:"onDragOver",event:Ht})})},[st]),Qs(()=>{Le.current={activatorEvent:X,active:H,activeNode:Se,collisionRect:fe,collisions:Ue,droppableRects:he,draggableNodes:ue,draggingNode:Pe,draggingNodeRect:je,droppableContainers:U,over:at,scrollableAncestors:Be,scrollAdjustedTranslate:pt},W.current={initial:je,translated:fe}},[H,Se,Ue,fe,ue,Pe,je,he,U,at,Be,pt]),BE({...De,delta:ye,draggingRect:fe,pointerCoordinates:qt,scrollableAncestors:Be,scrollableAncestorRects:Oe});const $t=v.useMemo(()=>({active:H,activeNode:Se,activeNodeRect:se,activatorEvent:X,collisions:Ue,containerNodeRect:me,dragOverlay:Me,draggableNodes:ue,droppableContainers:U,droppableRects:he,over:at,measureDroppableContainers:ge,scrollableAncestors:Be,scrollableAncestorRects:Oe,measuringConfiguration:Q,measuringScheduled:_e,windowRect:Re}),[H,Se,se,X,Ue,me,Me,ue,U,he,at,ge,Be,Oe,Q,_e,Re]),Si=v.useMemo(()=>({activatorEvent:X,activators:mt,active:H,activeNodeRect:se,ariaDescribedById:{draggable:Te},dispatch:A,draggableNodes:ue,over:at,measureDroppableContainers:ge}),[X,mt,H,se,A,Te,ue,at,ge]);return Mi.createElement(uw.Provider,{value:Y},Mi.createElement(Fh.Provider,{value:Si},Mi.createElement(t2.Provider,{value:$t},Mi.createElement(kw.Provider,{value:Dt},f)),Mi.createElement(r2,{disabled:p?.restoreFocus===!1})),Mi.createElement(lE,{...p,hiddenTextDescribedById:Te}));function Zi(){const Ct=ae?.autoScrollEnabled===!1,_t=typeof g=="object"?g.enabled===!1:g===!1,Pt=re&&!Ct&&!_t;return typeof g=="object"?{...g,enabled:Pt}:{enabled:Pt}}}),c2=v.createContext(null),uS="button",u2="Draggable";function Ew(e){let{id:t,data:n,disabled:s=!1,attributes:l}=e;const c=Kh(u2),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:S}=v.useContext(Fh),{role:w=uS,roleDescription:k="draggable",tabIndex:T=0}=l??{},L=g?.id===t,A=v.useContext(L?kw:c2),[O,Y]=vh(),[P,q]=vh(),re=VE(h,t),ne=mc(n);Qs(()=>(y.set(t,{id:t,key:c,node:O,activatorNode:P,data:ne}),()=>{const ye=y.get(t);ye&&ye.key===c&&y.delete(t)}),[y,t]);const ue=v.useMemo(()=>({role:w,tabIndex:T,"aria-disabled":s,"aria-pressed":L&&w===uS?!0:void 0,"aria-roledescription":k,"aria-describedby":b.draggable}),[s,w,T,L,k,b.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:ue,isDragging:L,listeners:s?void 0:re,node:O,over:S,setNodeRef:Y,setActivatorNodeRef:q,transform:A}}const h2="Droppable",d2={timeout:25};function Mg(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:l}=e;const c=Kh(h2),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(Fh),b=v.useRef({disabled:n}),y=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:k,updateMeasurementsFor:T,timeout:L}={...d2,...l},A=mc(T??s),O=v.useCallback(()=>{if(!y.current){y.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),w.current=null},L)},[L]),Y=Wh({callback:O,disabled:k||!h}),P=v.useCallback((ue,ye)=>{Y&&(ye&&(Y.unobserve(ye),y.current=!1),ue&&Y.observe(ue))},[Y]),[q,re]=vh(P),ne=mc(t);return v.useEffect(()=>{!Y||!q.current||(Y.disconnect(),y.current=!1,Y.observe(q.current))},[q,Y]),v.useEffect(()=>(p({type:Ri.RegisterDroppable,element:{id:s,key:c,disabled:n,node:q,rect:S,data:ne}}),()=>p({type:Ri.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{n!==b.current.disabled&&(p({type:Ri.SetDroppableDisabled,id:s,key:c,disabled:n}),b.current.disabled=n)},[s,c,n,p]),{active:h,rect:S,isOver:g?.id===s,node:q,over:g,setNodeRef:re}}const f2=128,p2=512,Vl=100,m2="too_many_detached_terminals",g2=64,_2=4096;function Tw(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>f2)return null;const n=t.workspaces.map(v2);return n.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function Dw(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 s=n.detachedTerminalIds;return Array.isArray(s)&&s.length>Vl}):!1}function v2(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>p2)return null;const n=t.tabs.map(y2);if(n.some(l=>l===null))return null;const s=C2(t.detachedTerminalIds,Vl);return s===null?null:{id:t.id,title:t.title,defaultCwd:w2(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:n}}function y2(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=b2(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function b2(e){if(!e||typeof e!="object")return null;let t=0;return $p(e,1,()=>(t+=1,t<=_2))}function $p(e,t,n){if(!e||typeof e!="object"||t>g2||!n())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const l=$p(s.first,t+1,n),c=$p(s.second,t+1,n);return!l||!c?null:{type:"split",direction:s.direction,ratio:S2(s.ratio),first:l,second:c}}function S2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function w2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function C2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,s=[];for(const l of e)typeof l!="string"||!l||n.has(l)||(n.add(l),s.push(l));return s}const Rw=[{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"}],x2="nterminal-focus",k2=/^[A-Za-z0-9_.:-]{1,128}$/;function E2(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(x2)!=="terminal"?null:qh({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function qh(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!hS(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!hS(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function hS(e){return typeof e=="string"&&k2.test(e)}const Mw="nterminal.notifications.completionEnabled",Ng="nterminal.notifications.completionToastEnabled",Ag="nterminal.notifications.completionToastDurationSeconds",Lg="nterminal.notifications.completionToastPersistent",Vp="nterminal:completion-toast-display",Yp="nterminal:notification-focus",uc=6.5,Xp=2,Gp=60;function $h(){return typeof window<"u"&&"Notification"in window}function Bg(){try{return window.localStorage.getItem(Mw)==="true"}catch{return!1}}function dS(e){try{window.localStorage.setItem(Mw,e?"true":"false")}catch{}}function Ia(){return{enabled:M2(),durationSeconds:R2(),persistUntilDismissed:N2()}}function T2(e){if(typeof window<"u"){try{window.localStorage.setItem(Ng,e?"true":"false")}catch{}Og()}return Ia()}function fS(e){const t=Aw(e);if(typeof window<"u"){try{window.localStorage.setItem(Ag,String(t))}catch{}Og()}return Ia()}function D2(e){if(typeof window<"u"){try{window.localStorage.setItem(Lg,e?"true":"false")}catch{}Og()}return Ia()}function Nw(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Ng||n.key===Ag||n.key===Lg)&&e()};return window.addEventListener(Vp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Vp,e),window.removeEventListener("storage",t)}}function Nc(){return $h()?window.Notification.permission:"unsupported"}function R2(){if(typeof window>"u")return uc;try{const e=window.localStorage.getItem(Ag);return e===null?uc:Aw(Number(e))}catch{return uc}}function M2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ng)!=="false"}catch{return!0}}function N2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Lg)==="true"}catch{return!1}}function Aw(e){if(!Number.isFinite(e))return uc;const t=Math.round(e*2)/2;return Math.max(Xp,Math.min(Gp,t))}function Og(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Vp))}async function Lw(){if(!$h())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Nc()}}function A2(e){if(!$h()||Nc()!=="granted"||!Bg()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished",n=qh({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const s=new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:n?{focus:n}:void 0,silent:!0});n&&(s.onclick=()=>{window.focus(),L2(n)})}catch{}}function L2(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(Yp,{detail:e}))}const pS="nterminal.push.clientId",B2=2e4;function Oa(){try{const e=window.localStorage.getItem(pS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Zp()}`;return window.localStorage.setItem(pS,t),t}catch{return`client-${Zp()}`}}function O2(){return`page-${Zp()}`}function zg(){const e=typeof window<"u"&&window.isSecureContext===!0,t=I2(),n=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone";return{supported:n,secure:e,displayMode:t,deviceKind:U2(),reason:e?t!=="standalone"?"not_standalone":n?"supported":"unsupported":"insecure"}}async function z2(e,t){const n=zg();if(!n.supported)throw new Error(n.reason);if((Nc()==="granted"?"granted":await Lw())!=="granted")throw new Error("permission_denied");const l=Oa(),c=await navigator.serviceWorker.register("/sw.js"),h=await e.preparePushNotifications(l),g=await q2(c,h.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V2(h.publicKey)});await e.subscribePushNotifications({clientId:l,subscription:F2(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:K2(n.deviceKind),alwaysNotify:t})}async function j2(e){const t=Oa();let n;try{const l=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=l?.endpoint,await l?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function P2(e,t){await e.updatePushNotificationDevice({clientId:Oa(),alwaysNotify:t})}function H2(e){if(typeof window>"u")return()=>{};const t=Oa(),n=O2();let s=null,l=!1;const c=(f=!0)=>{const b=zg();e.updatePushPresence({clientId:t,pageId:n,visibilityState:W2(),focused:document.hasFocus(),deviceKind:b.deviceKind,displayMode:b.displayMode,browserNotificationsEnabled:Bg()&&Nc()==="granted",active:f}).catch(()=>{})},h=()=>{l||s!==null||(s=window.setInterval(()=>c(!0),B2))},p=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",p),window.addEventListener("blur",p),document.addEventListener("visibilitychange",p),window.addEventListener("pagehide",g),c(!0),h(),()=>{l=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",p),window.removeEventListener("blur",p),document.removeEventListener("visibilitychange",p),window.removeEventListener("pagehide",g),c(!1)}}function I2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function U2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function K2(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function W2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function F2(e){const t=e.toJSON(),n=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!n||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:s}}}async function q2(e,t){const n=await e.pushManager.getSubscription();return n?$2(n,t)?n:(await n.unsubscribe(),null):null}function $2(e,t){const n=e.options.applicationServerKey;return n?Y2(n)===t:!0}function V2(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(n),l=new ArrayBuffer(s.length),c=new Uint8Array(l);for(let h=0;h<s.length;h+=1)c[h]=s.charCodeAt(h);return l}function Y2(e){const t=new Uint8Array(e);let n="";for(const s of t)n+=String.fromCharCode(s);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Zp(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const La="__main__";function X2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function G2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const mS="Local",Z2=3e4,Q2=2,J2=6,Bw="nterminal.serverList.viewMode.v1";function eT(){try{return window.localStorage.getItem(Bw)==="list"?"list":"stats"}catch{return"stats"}}function tT(e){try{window.localStorage.setItem(Bw,e)}catch{}}function Ra(e,t){const n=[La,...t.map(h=>h.id)],s=new Set(n),l=new Set,c=[];for(const h of e??[])!s.has(h)||l.has(h)||(l.add(h),c.push(h));for(const h of n)l.has(h)||c.push(h);return c}function iT(e,t){const n=new Map(e.map(s=>[s.id,s]));return Ra(t,e).flatMap(s=>{if(s===La)return[{kind:"main",id:La}];const l=n.get(s);return l?[{kind:"agent",id:s,agent:l}]:[]})}function gS(e,t){return e.length===t.length&&e.every((n,s)=>n===t[s])}function Ow(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Jn(e.cpuPercent)} ${jg(e)}`,`MEM ${Jn(e.memoryPercent)} ${ns(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Jn(e.diskPercent)} ${ns(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Jn(e.swapPercent)} ${ns(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function nT(e){if(!(e===void 0||e==="error"))return[`CPU ${Jn(e.cpuPercent)} (${jg(e)})`,`RAM ${Jn(e.memoryPercent)} (${ns(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Jn(e.diskPercent)} (${ns(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Jn(e.swapPercent)} (${ns(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function rT(e,t){const n=Ow(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function Jn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function jg(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`:`${Qp(e.cpuPercent/100*t)}/${t} cores`}function ns(e,t){return!_S(e)||!_S(t)?"–/–":sT(e,t)}function sT(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Qp(e/s)}/${Qp(t/s)} ${n}`}function Qp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function _S(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Fu(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function aT(e){return[{label:"CPU",percent:Jn(e.cpuPercent),detail:jg(e),tone:Fu(e.cpuPercent)},{label:"MEM",percent:Jn(e.memoryPercent),detail:ns(e.memoryUsedBytes,e.memoryTotalBytes),tone:Fu(e.memoryPercent)},{label:"DISK",percent:Jn(e.diskPercent),detail:ns(e.diskUsedBytes,e.diskTotalBytes),tone:Fu(e.diskPercent)},{label:"SWAP",percent:Jn(e.swapPercent),detail:ns(e.swapUsedBytes,e.swapTotalBytes),tone:Fu(e.swapPercent)}]}function lT({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:nT(e),children:aT(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function vS({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:s,refreshToken:l=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,b]=v.useState([La]),[y,S]=v.useState(null),[w,k]=v.useState(null),[T,L]=v.useState(""),A=v.useRef(null),[O,Y]=v.useState(()=>eT()),[P,q]=v.useState(null),[re,ne]=v.useState(null),[ue,ye]=v.useState({}),U=v.useRef({}),K=v.useRef(0),W=v.useRef([]),H=v.useRef([La]),j=v.useRef(null);v.useEffect(()=>{W.current=p},[p]),v.useEffect(()=>{const se=Ra(f,p);H.current=se,gS(se,f)||b(se)},[p,f]),v.useEffect(()=>{let se=!1;return e.listAgents().then(me=>{se||(g(me.agents),b(Ra(me.serverOrder,me.agents)))}).catch(()=>{}),e.getMainInfo().then(me=>{se||S(me.name)}).catch(()=>{}),()=>{se=!0}},[e,l]),v.useEffect(()=>{w&&(A.current?.focus(),A.current?.select())},[w]),v.useEffect(()=>{let se=!1;function me(){const be=[{key:"__main__",load:()=>e.getMainStats()},...p.map(Pe=>({key:Pe.id,load:()=>e.getAgentStats(Pe.id)}))],Me=new Set(be.map(Pe=>Pe.key));for(const Pe of Object.keys(U.current))Me.has(Pe)||delete U.current[Pe];ye(Pe=>{const je={};for(const ie of Me)ie in Pe&&(je[ie]=Pe[ie]);return je});for(const Pe of be)Pe.load().then(je=>{se||(U.current[Pe.key]=0,ye(ie=>Me.has(Pe.key)?{...ie,[Pe.key]:je}:ie))}).catch(je=>{if(se)return;if(je instanceof hr&&je.status===401&&Pe.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const ie=(U.current[Pe.key]??0)+1;U.current[Pe.key]=ie,ie>=Q2&&ye(xe=>Me.has(Pe.key)?{...xe,[Pe.key]:"error"}:xe)})}me();const Le=window.setInterval(me,Z2);return()=>{se=!0,window.clearInterval(Le)}},[e,p,s]);function ae(se){se==="main"?(L(y??""),k({kind:"main"})):(L(se.name),k({kind:"agent",id:se.id}))}async function R(){if(!w)return;const se=T.trim(),me=w;if(k(null),me.kind==="main"){const Le=se||"";try{const be=await e.renameMain(Le);S(be.name)}catch{}}else{if(!se)return;const Le=p.find(be=>be.id===me.id)?.name;g(be=>be.map(Me=>Me.id===me.id?{...Me,name:se}:Me));try{await e.renameAgent(me.id,se)}catch{Le!==void 0&&g(be=>be.map(Me=>Me.id===me.id?{...Me,name:Le}:Me))}}}function X(){k(null)}function Z(se){Y(se),tT(se)}function Ce(se,me,Le){if(se===me)return;const be=Ra(H.current,W.current),Me=be.findIndex(Oe=>Oe===se),Pe=be.findIndex(Oe=>Oe===me);if(Me<0||Pe<0)return;const je=[...be],[ie]=je.splice(Me,1);if(!ie)return;const xe=je.findIndex(Oe=>Oe===me);if(xe<0)return;const Re=Le==="before"?xe:xe+1;if(je.splice(Re,0,ie),gS(je,be))return;const Be=K.current+1;K.current=Be,H.current=je,b(je),e.reorderAgents(je).then(Oe=>{if(K.current===Be){W.current=Oe.agents;const rt=Ra(Oe.serverOrder,Oe.agents);H.current=rt,g(Oe.agents),b(rt)}}).catch(async()=>{if(K.current===Be)try{const Oe=await e.listAgents();if(K.current===Be){W.current=Oe.agents;const rt=Ra(Oe.serverOrder,Oe.agents);H.current=rt,g(Oe.agents),b(rt)}}catch{K.current===Be&&(H.current=be,b(be))}})}function Te(se,me){const Le=Ra(H.current,W.current),be=Le.findIndex(Pe=>Pe===se),Me=Le[be+me];be<0||!Me||Ce(se,Me,me<0?"before":"after")}function M(se,me){me.pointerType==="mouse"&&me.button!==0||(me.stopPropagation(),j.current={sourceId:se,pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,active:!1,targetId:null,placement:"after"},me.currentTarget.setPointerCapture?.(me.pointerId))}function Q(se){const me=j.current;if(!me||me.pointerId!==se.pointerId)return;const Le=Math.hypot(se.clientX-me.startX,se.clientY-me.startY);if(!me.active){if(Le<J2)return;me.active=!0,q(me.sourceId)}const Me=document.elementFromPoint(se.clientX,se.clientY)?.closest("[data-server-id]"),Pe=Me?.dataset.serverId??null;if(!Me||!Pe||Pe===me.sourceId){me.targetId=null,ne(null);return}const je=Me.getBoundingClientRect(),ie=se.clientY<je.top+je.height/2?"before":"after";me.targetId=Pe,me.placement=ie,ne({serverId:Pe,placement:ie})}function he(se){const me=j.current;!me||me.pointerId!==se.pointerId||(se.stopPropagation(),se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ne(null),me.active&&me.targetId&&Ce(me.sourceId,me.targetId,me.placement))}function ge(se){const me=j.current;me&&me.pointerId===se.pointerId&&se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ne(null)}const _e=y?.trim()||mS,Se=w?.kind==="main",Ee=O==="stats",De=iT(p,f),Ie=De.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:De.map(se=>{const me=se.kind==="main",Le=me?_e:se.agent.name,be=me?La:se.id,Me=ue[be],Pe=Ow(Me);return m.jsxs("button",{type:"button",className:`server-list-chip${(me?t===null:t===se.id)?" server-list-chip--active":""}`,onClick:()=>n(me?null:se.id),"aria-label":Le,title:`${Le}${Pe?` — ${Pe}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:G2(Le)}),m.jsx("span",{className:"server-list-chip-pip","data-status":X2(Me)})]},se.id)})}):m.jsxs("div",{className:`server-list server-list--${O}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":O==="list",onClick:()=>Z("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":O==="stats",onClick:()=>Z("stats"),title:"Show resource usage",children:"Stats"})]}),De.map(se=>{const me=se.kind==="main",Le=me?_e:se.agent.name,be=me?La:se.id,Me=me?t===null:t===se.id,Pe=me?Se:w?.kind==="agent"&&w.id===se.id,je=c?.({agentId:me?null:se.id,serverId:se.id,label:Le,active:Me}),ie=re?.serverId===se.id&&P!==se.id?` server-list-section--drop-target server-list-section--drop-${re.placement}`:"";return m.jsxs("section",{className:`server-list-section${ie}`,"aria-label":`${Le} server`,children:[m.jsx("div",{className:["server-list-row",P===se.id?"server-list-row--dragging":"",re?.serverId===se.id&&P!==se.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":se.id,children:Pe?m.jsxs(m.Fragment,{children:[Ie?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:xe=>{xe.preventDefault(),R()},children:m.jsx("input",{ref:A,"aria-label":me?"Rename main server":`Rename ${Le}`,value:T,onChange:xe=>L(xe.target.value),onBlur:()=>{R()},onKeyDown:xe=>{xe.key==="Escape"&&(xe.preventDefault(),X())},placeholder:me?mS:void 0})})]}):m.jsxs(m.Fragment,{children:[Ie?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":se.id,title:"Drag to reorder","aria-label":`Reorder ${Le}`,"aria-grabbed":P===se.id,onPointerDown:xe=>M(se.id,xe),onPointerMove:Q,onPointerUp:he,onPointerCancel:ge,onKeyDown:xe=>{(xe.key==="ArrowUp"||xe.key==="ArrowDown")&&(xe.preventDefault(),xe.stopPropagation(),Te(se.id,xe.key==="ArrowUp"?-1:1))},onClick:xe=>xe.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Me?" server-list-item--active":""}`,onClick:()=>n(me?null:se.id),onDoubleClick:xe=>{xe.preventDefault(),ae(me?"main":{id:se.id,name:Le})},title:rT(Le,ue[be]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:me?void 0:se.agent.url,children:Le})]}),Ee?m.jsx(lT,{entry:ue[be]}):null]})]})}),je?m.jsx("div",{className:"server-list-children",children:je}):null]},se.id)})]})}function oT({api:e}){const[t,n]=v.useState([]),[s,l]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,b]=v.useState(""),[y,S]=v.useState("");async function w(){try{const[A,O,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),l(O.networks),h(Y.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function k(A){await e.revokeDevice(A),await w()}async function T(A){await e.removeNetwork(A),await w()}async function L(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),S(""),await w()}catch(O){g(O instanceof Error?O.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[p?m.jsx("p",{className:"form-error",children:p}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[A.label,A.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(A.id)},children:"revoke"})]},A.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:s.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?m.jsx("span",{className:"security-item-meta",children:A.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(A.id)},children:"remove"})]},A.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:L,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:A=>b(A.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:A=>S(A.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.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."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const cT=1500,Pg="nterminal.terminal.fontSize",Hg="nterminal.terminal.fontFamily",Jp="nterminal:terminal-font-size",em="nterminal:terminal-font-family",tm=11,im=20,za=14,wh=[{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:[]}],Il="meslo";nm(Il);async function dp(e=za,t=Il){if(typeof document>"u"||!document.fonts)return;const n=Pw(t).webFontFamilies;if(n.length===0)return;const s=Promise.all(n.map(l=>document.fonts.load(`${e}px ${l}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(l=>{globalThis.setTimeout(l,cT)})])}function zw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return za;const n=Math.round(t);return Math.max(tm,Math.min(im,n))}function jw(e){return wh.some(t=>t.id===e)?e:Il}function nm(e){return Pw(e).cssFamily}function Pw(e){return wh.find(t=>t.id===e)??wh[0]}function rm(){if(typeof window>"u")return za;try{const e=window.localStorage.getItem(Pg);return e?zw(e):za}catch{return za}}function sm(){if(typeof window>"u")return Il;try{return jw(window.localStorage.getItem(Hg))}catch{return Il}}function qu(e){const t=zw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Pg,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Jp,{detail:t})),t}function uT(e){const t=jw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Hg,t)}catch{}return window.dispatchEvent(new CustomEvent(em,{detail:t})),t}function Hw(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Pg&&e()};return window.addEventListener(Jp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Jp,e),window.removeEventListener("storage",t)}}function Iw(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Hg&&e()};return window.addEventListener(em,e),window.addEventListener("storage",t),()=>{window.removeEventListener(em,e),window.removeEventListener("storage",t)}}const Ig="nterminal.terminal.showScrollProgress",am="nterminal:terminal-scroll-progress",Ug="nterminal.terminal.tmuxScrollback.shell",Kg="nterminal.terminal.tmuxScrollback.agent",Wg="nterminal.terminal.tmuxScrollback.overrides",_c="nterminal:terminal-tmux-scrollback",hT=200;function lm(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ig)!=="false"}catch{return!0}}function dT(e){if(typeof window<"u"){try{window.localStorage.setItem(Ig,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(am,{detail:e}))}return e}function Uw(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Ig&&e()};return window.addEventListener(am,e),window.addEventListener("storage",t),()=>{window.removeEventListener(am,e),window.removeEventListener("storage",t)}}function om(){return Kw(Ug,!0)}function fT(e){return Ww(Ug,e,_c)}function cm(){return Kw(Kg,!0)}function pT(e){return Ww(Kg,e,_c)}function sh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===Ug||n.key===Kg||n.key===Wg)&&e()};return window.addEventListener(_c,e),window.addEventListener("storage",t),()=>{window.removeEventListener(_c,e),window.removeEventListener("storage",t)}}function fp(e){const n=Fw()[e];return typeof n=="boolean"?n:null}function mT(e,t){if(typeof window<"u"){try{const n=Fw(),s=Object.entries(n).filter(([c])=>c!==e);s.push([e,t]);const l=s.slice(-hT);window.localStorage.setItem(Wg,JSON.stringify(Object.fromEntries(l)))}catch{}window.dispatchEvent(new CustomEvent(_c,{detail:{terminalId:e,enabled:t}}))}return t}function Kw(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 Ww(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 Fw(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(Wg);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,l]of Object.entries(t))typeof l=="boolean"&&(n[s]=l);return n}catch{return{}}}const Fg="nterminal.shortcuts.workspace.v1",um="nterminal:workspace-shortcuts",vc=[{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:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],Vh={"server.previous":yi("ArrowUp",{ctrlKey:!0}),"server.next":yi("ArrowDown",{ctrlKey:!0}),"tab.previous":yi("ArrowLeft",{ctrlKey:!0}),"tab.next":yi("ArrowRight",{ctrlKey:!0}),"tab.index":yi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":yi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":yi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":yi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":yi("KeyH",{altKey:!0}),"scrollback.toggle":yi("KeyS",{altKey:!0})},gT={"server.previous":yi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":yi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":yi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":yi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":yi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":yi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":yi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":yi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":yi("KeyH",{altKey:!0}),"scrollback.toggle":yi("KeyS",{altKey:!0})};function Ua(){const e=Vw(Vh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Fg);if(!t)return e;const n=JSON.parse(t);for(const s of vc){const l=n[s.id];if(xT(l)){const c=Yw(l,s);CT(c,gT[s.id])||(e[s.id]=c)}}}catch{return e}return e}function yS(){return JSON.stringify(Ua())}function _T(e,t){const n=Ua(),s=vc.find(l=>l.id===e);return s&&(n[e]=Yw(t,s),qg(n)),n}function vT(e){const t=Ua();return t[e]={...Vh[e]},qg(t),t}function yT(){const e=Vw(Vh);return qg(e),e}function Ch(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===Fg&&e()};return window.addEventListener(um,e),window.addEventListener("storage",t),()=>{window.removeEventListener(um,e),window.removeEventListener("storage",t)}}function bT(e,t){const n=Zw(e);return!n||ET(n)||t.indexed&&Gw(e)===null||t.requiresPrimaryModifier&&!Xw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function qw(e){const t=Ua();for(const n of vc){const s=t[n.id];if(!(!s||!kT(e,s))){if(n.indexed){if(s.code!=="Digit")continue;const l=Gw(e);if(l!==null)return{id:n.id,index:l};continue}if(Zw(e)===s.code)return{id:n.id,index:null}}}return null}function xh(e){return $w(Ua()[e])}function $w(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(TT(e.code)),t.join("+")}const ST=()=>xh("split.right"),wT=()=>xh("split.down");function yi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Vw(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function CT(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function qg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Fg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(um))}}function Yw(e,t){return t.requiresPrimaryModifier&&!Xw(e)?{...Vh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Xw(e){return e.ctrlKey||e.altKey||e.metaKey}function xT(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 kT(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Gw(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 Zw(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 ET(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function TT(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 DT="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 RT(e="nterminal",t=new Date){return{reason:"permission",message:DT,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function MT(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 Qw=3600*1e3,NT="local",hm=new Set,Xs=new Map;let Js={checking:!1,hasUpdates:!1,lastCheckedAt:null},$g=null,hc=null,kh=0,qs=null;function AT(e){return hm.add(e),()=>{hm.delete(e)}}function bS(){return Js}function LT(e){const t=PT();$g=e,Vg(),dm(e,t);const n=()=>{if(document.visibilityState!=="visible"||!ea(e,t))return;const s=Js.lastCheckedAt;(s===null||Date.now()-s>=Qw)&&dm(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),ea(e,t)&&jT()}}function BT(e,t){Xs.set(e,Jw(t)),Ul({...Js,hasUpdates:Yg(),lastCheckedAt:Date.now()})}function pp(e){e===void 0?Xs.clear():Xs.set(e,!1),Ul({...Js,hasUpdates:Yg()})}async function dm(e,t){if(!ea(e,t))return;if(qs&&qs.api===e&&qs.runId===t)return qs.promise;Ul({...Js,checking:!0});const n=OT(e,t).finally(()=>{qs?.promise===n&&(qs=null),ea(e,t)&&(Ul({...Js,checking:!1,lastCheckedAt:Date.now()}),zT(e,t))});return qs={api:e,runId:t,promise:n},n}async function OT(e,t){try{const n=await e.listAgents();if(!ea(e,t))return;const s=[{key:NT,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],l=new Map;if(await Promise.all(s.map(async c=>{try{const h=await c.check();l.set(c.key,Jw(h))}catch{l.set(c.key,Xs.get(c.key)??!1)}})),!ea(e,t))return;Xs.clear();for(const[c,h]of l)Xs.set(c,h);Ul({...Js,hasUpdates:Yg()})}catch{}}function zT(e,t){ea(e,t)&&(Vg(),hc=window.setTimeout(()=>{hc=null,ea(e,t)&&dm(e,t)},Qw))}function jT(){kh+=1,Vg(),$g=null,qs=null,Xs.clear(),Ul({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Vg(){hc!==null&&(window.clearTimeout(hc),hc=null)}function PT(){return kh+=1,kh}function ea(e,t){return $g===e&&kh===t}function Jw(e){return e.updateAvailable===!0}function Yg(){return Array.from(Xs.values()).some(Boolean)}function Ul(e){Js=e;for(const t of Array.from(hm))t()}const HT=e=>new Promise(t=>setTimeout(t,e));function IT({api:e,onAgentRemoved:t}){const[n,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[l,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[b,y]=v.useState(!1);function S(U,K){c(W=>({...W,[U]:{...W[U],...K}}))}const w=U=>U.id===null?e.getVersion():e.getAgentVersion(U.id),k=U=>U.id===null?e.checkUpdate():e.checkAgentUpdate(U.id),T=U=>U.id===null?e.runUpdate():e.runAgentUpdate(U.id);v.useEffect(()=>{let U=!1;return e.listAgents().then(K=>{if(U)return;const W=[{key:"local",id:null,name:"Local (main)"},...K.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];s(W);for(const H of W)w(H).then(j=>S(H.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(H.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{U=!0}},[]);async function L(U){S(U.key,{busy:!0,status:"checking…",error:void 0});try{const K=await k(U);BT(U.key,K),S(U.key,{latestVersion:K.latestVersion,updateAvailable:K.updateAvailable,status:ne(K),...K.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(K){S(U.key,{busy:!1,error:K instanceof Error?K.message:"check failed"})}}async function A(){p(!0),await Promise.all(n.map(U=>L(U))),p(!1)}async function O(U,K){const W=Date.now()+18e4;for(;Date.now()<W;){await HT(3e3);try{const H=await w(U);if(K&&H.runningVersion!==K.runningVersion)return H}catch{}}return null}async function Y(U){let K=l[U.key]?.version;if(!K)try{K=await w(U),S(U.key,{version:K,manualUpdate:K.manualUpdate??null})}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(U.key,{busy:!0,status:"updating…",error:void 0});let W;try{W=await T(U)}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!W.ok){const j=W.manualUpdate??(MT(W.message)?RT():null);return j?(S(U.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(U.key,{busy:!1,status:void 0,error:W.message}),"failed")}if(!W.changed)return S(U.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),pp(U.key),"unchanged";S(U.key,{status:"restarting…"});const H=await O(U,K);return H?(S(U.key,{busy:!1,version:H,updateAvailable:!1,status:"updated",manualUpdate:H.manualUpdate??null}),pp(U.key),U.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(U.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function P(U){if(!(U.id===null||!window.confirm([`Delete secondary server "${U.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
+ `)))){S(U.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const W=await e.uninstallAgent(U.id);s(H=>H.filter(j=>j.key!==U.key)),c(H=>{const j={...H};return delete j[U.key],j}),pp(U.key),t?.(U.id),f(W.message)}catch(W){S(U.key,{busy:!1,status:void 0,error:W instanceof Error?W.message:"delete failed"})}}}async function q(){p(!0),f(null);const U=n.filter(R=>R.id!==null),K=n.find(R=>R.id===null),W=await Promise.all(U.map(R=>Y(R))),H=W.filter(R=>R==="failed").length;let j=W.filter(R=>R==="manual").length,ae=null;if(K&&(ae=await Y(K),ae==="manual"&&(j+=1),ae==="updated")){H>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}H>0&&j>0?f("Some servers failed and some need manual update. Check each marked row."):H>0?f("Some secondary servers failed to update. Check their rows and retry."):j>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function re(U){return U?U.error?U.error:U.status?U.status:U.manualUpdate?"manual update required":U.version?`v${U.version.version}`:"…":"…"}function ne(U){return U.error?U.error:typeof U.updateAvailable=="boolean"?U.updateAvailable?`latest v${U.latestVersion??"available"}`:"up to date":"unknown"}function ue(U){const K=U?.version;return K?`npm package v${K.runningVersion}`:""}async function ye(U,K){try{await UT(K),S(U,{copiedCommand:!0}),window.setTimeout(()=>S(U,{copiedCommand:!1}),1800)}catch(W){S(U,{error:W instanceof Error?W.message:"copy failed"})}}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{A()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{q()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsx("ul",{className:"security-list",children:n.map(U=>{const K=l[U.key],W=ue(K),H=K?.manualUpdate??null,j=K?.version!==void 0&&K?.updateAvailable!==!1&&!K?.busy&&!h,ae=U.id!==null&&!K?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:U.name}),m.jsxs("span",{className:"security-item-meta",children:[W?`${W} — `:"",re(K)]})]}),H?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:H.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:H.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ye(U.key,H.command)},children:K?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Y(U)},disabled:!j,children:K?.busy?"…":"Update"}),U.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{P(U)},disabled:!ae,children:"Delete"}):null]})]},U.key)})})]})}async function UT(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 $u=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function KT({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:s,onAgentRemoved:l}){const c=v.useMemo(()=>t??Hh(),[t]),[h,p]=v.useState(()=>rm()),[g,f]=v.useState(()=>sm()),[b,y]=v.useState(()=>lm()),[S,w]=v.useState(()=>om()),[k,T]=v.useState(()=>cm()),[L,A]=v.useState(()=>Zs()),[O,Y]=v.useState(()=>Ua()),[P,q]=v.useState(null),[re,ne]=v.useState(null),[ue,ye]=v.useState("appearance"),[U,K]=v.useState(()=>Bg()),[W,H]=v.useState(()=>Ia()),[j,ae]=v.useState(()=>Nc()),[R,X]=v.useState([]),[Z,Ce]=v.useState([]),[Te,M]=v.useState([]),[Q,he]=v.useState(5*1024*1024),[ge,_e]=v.useState(!1),[Se,Ee]=v.useState(null),[De,Ie]=v.useState(null),[se,me]=v.useState(!1),[Le,be]=v.useState(null),Me=v.useRef(null),Pe=v.useRef(null),je=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),ie=v.useMemo(()=>new Set(Z),[Z]),xe=!FT(Z,Te),Re=v.useMemo(()=>zg(),[]),Be=De?.displayMode==="standalone"&&(De.deviceKind==="mobile"||De.deviceKind==="tablet");v.useEffect(()=>Hw(()=>p(rm())),[]),v.useEffect(()=>Iw(()=>f(sm())),[]),v.useEffect(()=>Uw(()=>y(lm())),[]),v.useEffect(()=>sh(()=>{w(om()),T(cm())}),[]),v.useEffect(()=>Cg(()=>A(Zs())),[]),v.useEffect(()=>Ch(()=>Y(Ua())),[]),v.useEffect(()=>Nw(()=>H(Ia())),[]),v.useEffect(()=>{if(!P)return;const F=vc.find(mt=>mt.id===P);if(!F)return;const qe=mt=>{if(mt.preventDefault(),mt.stopPropagation(),mt.key==="Escape"){q(null),ne(null);return}const $t=bT(mt,F);if(!$t){ne(WT(F));return}Y(_T(P,$t)),q(null),ne(null)};return window.addEventListener("keydown",qe,!0),()=>window.removeEventListener("keydown",qe,!0)},[P]),v.useEffect(()=>{let F=!1;return c.listNotificationAssets().then(qe=>{F||pt(qe)}).catch(qe=>{F||Ee(Nl(qe))}),()=>{F=!0}},[c]),v.useEffect(()=>{let F=!1;return c.getPushNotificationStatus(Oa()).then(qe=>{F||(Ie(qe.currentDevice),be(null))}).catch(qe=>{F||be(Nl(qe))}),()=>{F=!0}},[c]);function Oe(F){p(qu(Number(F)))}function rt(F){H(fS(Number(F)))}function qt(F){ye(F);const qe=Pe.current,mt=je.current[F];if(!qe||!mt)return;const $t=Math.max(0,SS(mt,qe)-12);typeof qe.scrollTo=="function"?qe.scrollTo({top:$t,behavior:"smooth"}):qe.scrollTop=$t}function wt(){const F=Pe.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){ye($u[$u.length-1].id);return}let qe="appearance";const mt=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const $t of $u){const Si=je.current[$t.id];Si&&SS(Si,F)<=mt&&(qe=$t.id)}ye(qe)}function Ki(F){Y(vT(F)),q(null),ne(null)}function nt(){Y(yT()),q(null),ne(null)}function pt(F){const qe=F.assets.filter(mt=>mt.enabled).map(mt=>mt.id);X(F.assets),Ce(qe),M(qe),he(F.maxFileBytes),Ee(null)}async function fe(){if(U){dS(!1),K(!1);return}let F=j;F==="default"&&(F=await Lw(),ae(F)),F==="granted"&&(dS(!0),K(!0))}async function Ue(){me(!0),be(null);try{if(De)await j2(c),Ie(null);else{await z2(c,!1);const F=await c.getPushNotificationStatus(Oa());Ie(F.currentDevice)}}catch(F){be(wS(F))}finally{me(!1)}}async function st(F){me(!0),be(null);try{await P2(c,F);const qe=await c.getPushNotificationStatus(Oa());Ie(qe.currentDevice)}catch(qe){be(wS(qe))}finally{me(!1)}}async function at(F){const qe=F?.[0];if(qe){if(qe.size>Q){Ee(`File must be ${mp(Q)} or smaller.`),Tt();return}if(qe.type!=="video/mp4"&&qe.type!=="video/webm"){Ee("Upload an MP4 or WebM video."),Tt();return}_e(!0),Ee(null);try{await c.uploadNotificationAsset(qe),pt(await c.listNotificationAssets()),s?.()}catch(mt){Ee(Nl(mt))}finally{_e(!1),Tt()}}}async function Et(F){_e(!0),Ee(null);try{await c.deleteNotificationAsset(F),pt(await c.listNotificationAssets()),s?.()}catch(qe){Ee(Nl(qe))}finally{_e(!1)}}function Tt(){Me.current&&(Me.current.value="")}function Dt(F,qe){const mt=new Set(Z);if(qe?mt.add(F):mt.delete(F),mt.size===0){Ee("Keep at least one toast video selected.");return}Ee(null),Ce(Array.from(mt))}async function Rt(){if(Z.length===0){Ee("Keep at least one toast video selected.");return}_e(!0),Ee(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:Z});pt(F),s?.()}catch(F){Ee(Nl(F))}finally{_e(!1)}}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:F=>F.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:$u.map(F=>m.jsxs("button",{type:"button","data-active":ue===F.id?"true":"false","aria-current":ue===F.id?"true":void 0,onClick:()=>qt(F.id),children:[F.label,F.id==="servers"&&n?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),m.jsxs("div",{ref:Pe,className:"settings-content",onScroll:wt,children:[m.jsxs("section",{id:"settings-appearance",ref:F=>{je.current.appearance=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:_h.map(F=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===F.id,"data-active":L===F.id?"true":"false",onClick:()=>A(Fk(F.id)),style:{"--settings-theme-bg":F.tokens.bg,"--settings-theme-bg-2":F.tokens.bg2,"--settings-theme-sidebar":F.tokens.bgSidebar,"--settings-theme-line":F.tokens.line,"--settings-theme-fg":F.tokens.fg,"--settings-theme-fg-2":F.tokens.fg2,"--settings-theme-accent":F.tokens.accent,"--settings-theme-xterm-bg":F.xterm.background,"--settings-theme-xterm-fg":F.xterm.foreground,"--settings-theme-xterm-selection":F.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:F.label}),m.jsx("small",{children:F.description})]})]},F.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:tm,max:im,step:1,value:h,"aria-label":"Terminal font size",onChange:F=>Oe(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(qu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:tm,max:im,step:1,value:h,"aria-label":"Terminal font size value",onChange:F=>Oe(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(qu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(qu(za)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:F=>f(uT(F.currentTarget.value)),children:wh.map(F=>m.jsx("option",{value:F.id,children:F.label},F.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:F=>y(dT(F.currentTarget.checked))}),"Show scroll progress"]}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:S,onChange:F=>w(fT(F.currentTarget.checked))}),"Shell panes"]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:k,onChange:F=>T(pT(F.currentTarget.checked))}),"Codex/Claude panes"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:F=>{je.current.shortcuts=F},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:nt,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),re?m.jsx("p",{className:"settings-error",children:re}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:vc.map(F=>{const qe=P===F.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:F.label}),m.jsx("span",{className:"settings-shortcut-group",children:F.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":qe?"true":"false",onClick:()=>{q(F.id),ne(null)},children:qe?"Press keys…":$w(O[F.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Ki(F.id),children:"Reset"})]})]},F.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:F=>{je.current.notifications=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),$h()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:U&&j==="granted",onChange:()=>{fe()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="denied"?m.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."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("div",{className:"settings-subsection",children:[m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:!!De,onChange:()=>{Ue()},disabled:se||!Re.supported}),"Installed app push notifications"]}),m.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."}),Re.supported?null:m.jsx("p",{className:"muted",children:fm(Re.reason)}),De?m.jsxs("p",{className:"muted",children:["Registered as ",De.label,". Last active ",new Date(De.lastActiveAt).toLocaleString(),"."]}):null,Be?m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:De?.alwaysNotify===!0,onChange:F=>{st(F.currentTarget.checked)},disabled:se||!De}),"Always notify this mobile device"]}):null,Le?m.jsx("p",{className:"form-error",children:Le}):null]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.enabled,onChange:F=>H(T2(F.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:W.persistUntilDismissed?"Until closed":`${W.durationSeconds}s`}),m.jsx("input",{type:"range",min:Xp,max:Gp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>rt(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Xp,max:Gp,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>rt(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!W.enabled||W.persistUntilDismissed,onClick:()=>H(fS(uc)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.persistUntilDismissed,disabled:!W.enabled,onChange:F=>H(D2(F.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[mp(Q)," max"]})]}),m.jsx("input",{ref:Me,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{at(F.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ge,onClick:()=>Me.current?.click(),children:"Upload video"}),Se?m.jsx("p",{className:"settings-error",children:Se}):null,R.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:R.map(F=>m.jsxs("li",{"data-enabled":ie.has(F.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:ie.has(F.id),disabled:ge,"aria-label":`Use ${F.filename}`,onChange:qe=>Dt(F.id,qe.currentTarget.checked)}),m.jsx("video",{src:F.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:F.filename}),m.jsx("small",{children:F.source==="built-in"?"Built-in":mp(F.size)})]})]}),F.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ge,"aria-label":`Delete ${F.filename}`,onClick:()=>{Et(F.id)},children:"x"}):null]},F.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ge||R.length===0||!xe,onClick:()=>{Rt()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:F=>{je.current.security=F},className:"settings-section-group",children:m.jsx(oT,{api:c})}),m.jsx("div",{id:"settings-servers",ref:F=>{je.current.servers=F},className:"settings-section-group",children:m.jsx(IT,{api:c,...l?{onAgentRemoved:l}:{}})})]})]})]})})}function SS(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.top-s.top+t.scrollTop}function mp(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 Nl(e){return e instanceof Error?e.message:"Request failed."}function fm(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.":"This browser does not support installed app push notifications."}function wS(e){const t=Nl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?fm("not_standalone"):t==="insecure"?fm("insecure"):t}function WT(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 FT(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(s=>n.has(s))}class Ea extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function qT(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,s=e.files.map((l,c)=>({fieldName:`file${c}`,relativePath:l.relativePath,size:l.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[l,c]of e.files.entries())n.append(`file${l}`,c.file);return new Promise((l,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,p(),l(y))},f=y=>{h||(h=!0,p(),c(y))},b=()=>{t.abort(),f(new Ea(0,"Upload aborted."))};if(e.signal?.aborted){f(new Ea(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new Ea(t.status,"Invalid upload response."))}return}f(new Ea(t.status,$T(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Ea(0,"Upload failed.")),t.onabort=()=>f(new Ea(0,"Upload aborted.")),t.ontimeout=()=>f(new Ea(0,"Upload timed out.")),t.send(n)})}function $T(e,t){try{const n=JSON.parse(e),s=typeof n.error=="string"?n.error:n.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const VT="modulepreload",YT=function(e){return"/"+e},CS={},Xg=function(t,n,s){let l=Promise.resolve();if(n&&n.length>0){let g=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");l=g(n.map(f=>{if(f=YT(f),f in CS)return;CS[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":VT,b||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),b)return new Promise((w,k)=>{S.addEventListener("load",w),S.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return l.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},XT=v.lazy(()=>Xg(()=>import("./MarkdownPreview-CLmBLNLL.js"),__vite__mapDeps([0,1])));function GT({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:s=null,onOpenFile:l}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,b]=v.useState({}),[y,S]=v.useState(()=>new Set),[w,k]=v.useState(null),[T,L]=v.useState({type:"empty"}),[A,O]=v.useState("idle"),[Y,P]=v.useState(null),q=v.useRef(null),re=v.useRef(null),ne=v.useRef(!1),ue=v.useRef(0),ye=v.useRef(null);ye.current===null&&t&&(ye.current=t);const U=ye.current,K=s?QT(s):t?xS(t,n):null,W=c?[c.rootPath,p].filter(Boolean).join("/"):"",H=w?.path??null;v.useEffect(()=>(ne.current=!0,()=>{ne.current=!1,ue.current+=1,me()}),[]),v.useEffect(()=>{ye.current=t,re.current=null,j(K)},[e]),v.useEffect(()=>{s&&K!==re.current&&ae(s,K)},[s,K]),v.useEffect(()=>{if(s||!U||t!==U)return;const ie=xS(U,n);ie!==re.current&&R(U,ie)},[U,t,n,s]);async function j(ie=K){if(s){await ae(s,ie);return}await R(t,ie)}async function ae(ie,xe=K){const Re=Le();if(re.current=xe,me(),h(null),g(""),b({}),S(new Set),k(null),L({type:"empty"}),P(null),!ie){O("idle");return}O("loading");try{const Be=await e.createFileRoot({path:ie});if(!be(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const Oe=await e.listFiles({rootToken:Be.rootToken,path:""});if(!be(Re))return;Ce(Oe),O("idle")}catch(Be){be(Re)&&(P(Qr(Be)),O("idle"))}}async function R(ie,xe=K){const Re=Le();if(re.current=xe,me(),h(null),g(""),b({}),S(new Set),k(null),L({type:"empty"}),P(null),!ie){O("idle");return}O("loading");try{const Be=await e.createFileRoot({terminalId:ie});if(!be(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const Oe=await e.listFiles({rootToken:Be.rootToken,path:""});if(!be(Re))return;Ce(Oe),O("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Qr(Be)),O("idle"))}}async function X(ie=p,xe=c){if(!xe)return;const Re=Le();O("loading"),P(null);try{const Be=await e.listFiles({rootToken:xe.rootToken,path:ie});if(!be(Re))return;Ce(Be),O("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Qr(Be)),O("idle"))}}async function Z(){if(s){await ae(s,K);return}ye.current=t,await R(t,K)}function Ce(ie){b(xe=>({...xe,[ie.path]:JT(ie.entries)}))}async function Te(ie){if(!(!gp(ie)||!c)){if(k(ie),P(null),ie.kind==="directory"){g(ie.path),se(),await Q(ie);return}if(g(Ta(ie.path)),ie.editable){await ge(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function M(ie){if(!(!gp(ie)||!c)){if(k(ie),P(null),ie.kind==="directory"){g(ie.path),se(),await Q(ie);return}if(g(Ta(ie.path)),ie.editable){await _e(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function Q(ie){if(y.has(ie.path)){S(xe=>{const Re=new Set(xe);return Re.delete(ie.path),Re});return}S(xe=>new Set(xe).add(ie.path)),await X(ie.path)}function he(ie,xe){ie.key==="Enter"&&(ie.preventDefault(),M(xe))}async function ge(ie){if(!c)return;const xe=Le();O("loading"),me();try{const Re=await e.readFile({rootToken:c.rootToken,path:ie.path});if(!be(xe))return;L({type:"text-preview",file:ie,read:Re}),O("idle")}catch(Re){if(await Me(Re,xe))return;be(xe)&&(P(Qr(Re)),O("idle"))}}async function _e(ie){if(!c)return;const xe=Le();O("loading");try{await l({rootToken:c.rootToken,path:ie.path,...t?{terminalId:t}:{}}),be(xe)&&O("idle")}catch(Re){if(await Me(Re,xe))return;be(xe)&&(P(Qr(Re)),O("idle"))}}async function Se(ie,xe){if(!c)return;const Re=Le();O("loading"),me();try{const Be=await e.previewFile({rootToken:c.rootToken,path:ie.path});if(!be(Re))return;const Oe=URL.createObjectURL(Be);if(!be(Re)){URL.revokeObjectURL(Oe);return}q.current=Oe,L({type:"preview",file:ie,previewKind:xe,url:Oe}),O("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Qr(Be)),O("idle"))}}async function Ee(ie){if(!c)return;const xe=ie==="file"?"New file":"New folder",Re=window.prompt(xe,""),Be=w?w.kind==="directory"?w.path:Ta(w.path):p,Oe=kS(Re,Be);if(Oe){P(null);try{const rt=await e.createFileEntry({rootToken:c.rootToken,path:Oe,kind:ie});k(rt.entry),await X(Be)}catch(rt){if(await Me(rt))return;P(Qr(rt))}}}async function De(){if(!c||!w)return;const ie=window.prompt("Move selected entry",w.path),xe=kS(ie,"");if(!xe||xe===w.path)return;const Re=Ta(w.path),Be=Ta(xe);P(null);try{const Oe=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:xe});k(Oe.entry),g(Oe.entry.kind==="directory"?Oe.entry.path:Ta(Oe.entry.path)),se(),await X(Re),Be!==Re&&await X(Be)}catch(Oe){if(await Me(Oe))return;P(Qr(Oe))}}async function Ie(){if(!c||!w)return;const ie=w.path,xe=Ta(ie);P(null);try{const Re=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Be=Re.descendantCount>0?` and ${Re.descendantCount} nested item${Re.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Re.path}${Be}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:Re.previewToken}),k(null),g(xe),S(Oe=>{const rt=new Set(Oe);for(const qt of Oe)(qt===ie||qt.startsWith(`${ie}/`))&&rt.delete(qt);return rt}),se(),await X(xe)}catch(Re){if(await Me(Re))return;P(Qr(Re))}}function se(){ue.current+=1,me(),L({type:"empty"})}function me(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function Le(){return ue.current+=1,ue.current}function be(ie){return ne.current&&ie===ue.current}async function Me(ie,xe){return eD(ie)?(xe!==void 0&&!be(xe)||await j(K),!0):!1}function Pe(ie,xe){const Re=gp(ie),Be=ie.kind==="directory"&&y.has(ie.path),Oe=f[ie.path]??[],rt={"--file-tree-depth":xe};return m.jsxs(Mi.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ie.kind,"data-expanded":Be,"data-active":H===ie.path,disabled:!Re,style:rt,"aria-expanded":ie.kind==="directory"?Be:void 0,"aria-label":`${ie.kind==="directory"?"Open folder":"Open file"} ${ie.name}`,title:ie.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{Te(ie)},onDoubleClick:()=>{M(ie)},onKeyDown:qt=>he(qt,ie),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ie.kind==="directory"?Be?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:ie.name}),m.jsx("small",{children:ZT(ie)})]}),Be?m.jsx("div",{className:"file-tree-children",role:"group",children:Oe.map(qt=>Pe(qt,xe+1))}):null]},ie.path)}const je=f[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:W,children:W||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{Z()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ee("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ee("directory")},children:"▣"})]})]}),Y?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":W?`Files in ${W}`:"Files",children:je.map(ie=>Pe(ie,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{De()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ie()},children:"Delete"})]})]}),A==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&A!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?m.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?m.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(XT,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function gp(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function ZT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function xS(e,t){return`${e}\0${t??""}`}function QT(e){return`workspace\0${e}`}function JT(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 Ta(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function kS(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Qr(e){return e instanceof Error?e.message:"Request failed"}function eD(e){return e instanceof hr&&e.status===409&&e.message==="terminal_cwd_changed"}const tD=v.lazy(()=>Xg(()=>import("./MarkdownPreview-CLmBLNLL.js"),__vite__mapDeps([0,1])));function ES({api:e,editor:t,canClose:n,onClose:s}){const[l,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[b,y]=v.useState(null),[S,w]=v.useState(!1),[k,T]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),O=v.useRef(t.read.content),Y=v.useRef(!1),P=v.useRef(!1),q=v.useRef(0),re=h!==l.content&&g!=="saving"&&!S;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,Y.current=!1,L.current=t,A.current=t.read,O.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),w(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=l},[l]),v.useEffect(()=>{O.current=h},[h]),v.useEffect(()=>{if(h===l.content||S)return;const K=window.setInterval(()=>{!Y.current&&O.current!==A.current.content&&ne()},1e3);return()=>window.clearInterval(K)},[h===l.content,S,t.id]);async function ne(){if(Y.current)return;const K=O.current,W=A.current;if(K===W.content)return;const H=L.current,j=q.current;Y.current=!0,f("saving"),y(null),w(!1);try{const ae=await e.writeFile({rootToken:H.rootToken,path:H.path,content:K,expectedVersion:W.version});if(!P.current||j!==q.current)return;const R={...W,content:K,version:ae.version};A.current=R,c(R),f(O.current===K?"saved":"idle")}catch(ae){if(!P.current||j!==q.current)return;if(ae instanceof hr&&ae.status===409){w(!0),f("idle");return}y(iD(ae)),f("idle")}finally{j===q.current&&(Y.current=!1)}}const ue=g==="saving"?"saving":g==="saved"?"saved":l.language,ye=l.language==="markdown",U=ye&&k==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:ue}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!re,onClick:()=>{ne()},children:"Save"}),ye?m.jsx("button",{type:"button","aria-label":`${U?"Edit":"Preview"} ${t.title}`,onClick:()=>T(K=>K==="preview"?"edit":"preview"),children:U?"Edit":"Preview"}):null,n?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),b?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,U?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(tD,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:K=>{const W=K.target.value;O.current=W,p(W),f("idle"),y(null),w(!1)}})]})}function iD(e){return e instanceof Error?e.message:"Request failed"}var nD=2,rD=1,sD=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),s=parseInt(n.getPropertyValue("height")),l=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=h.top+h.bottom,g=h.right+h.left,f=s-p,b=l-g-t;return{cols:Math.max(nD,Math.floor(b/e.css.cell.width)),rows:Math.max(rD,Math.floor(f/e.css.cell.height))}}};var e1=Object.defineProperty,aD=Object.getOwnPropertyDescriptor,lD=(e,t)=>{for(var n in t)e1(e,n,{get:t[n],enumerable:!0})},ai=(e,t,n,s)=>{for(var l=s>1?void 0:s?aD(t,n):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(l=(s?h(t,n,l):h(l))||l);return s&&l&&e1(t,n,l),l},Ae=(e,t)=>(n,s)=>t(n,s,e),TS="Terminal input",pm={get:()=>TS,set:e=>TS=e},DS="Too much output to announce, navigate to rows manually to read",mm={get:()=>DS,set:e=>DS=e};function oD(e){return e.replace(/\r?\n/g,"\r")}function cD(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function uD(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function hD(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let l=e.clipboardData.getData("text/plain");t1(l,t,n,s)}}function t1(e,t,n,s){e=oD(e),e=cD(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function i1(e,t,n){let s=n.getBoundingClientRect(),l=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function RS(e,t,n,s,l){i1(e,t,n),l&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Vs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Yh(e,t=0,n=e.length){let s="";for(let l=t;l<n;++l){let c=e[l];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var dD=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=l;c<n;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=n)return this._interim=h,s;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[s++]=(h-55296)*1024+p-56320+65536:(t[s++]=h,t[s++]=p);continue}h!==65279&&(t[s++]=h)}return s}},fD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,l,c,h,p,g=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let k=0,T;for(;(T=this.interim[++k]&63)&&k<4;)w<<=6,w|=T;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-k;for(;f<A;){if(f>=n)return 0;if(T=e[f++],(T&192)!==128){f--,S=!0;break}else this.interim[k++]=T,w<<=6,w|=T&63}S||(L===2?w<128?f--:t[s++]=w:L===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let b=n-4,y=f;for(;y<n;){for(;y<b&&!((l=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((p=e[y+3])&128);)t[s++]=l,t[s++]=c,t[s++]=h,t[s++]=p,y+=4;if(l=e[y++],l<128)t[s++]=l;else if((l&224)===192){if(y>=n)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(g=(l&31)<<6|c&63,g<128){y--;continue}t[s++]=g}else if((l&240)===224){if(y>=n)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(g=(l&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((l&248)===240){if(y>=n)return this.interim[0]=l,s;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[y++],(h&192)!==128){y--;continue}if(y>=n)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=h,s;if(p=e[y++],(p&192)!==128){y--;continue}if(g=(l&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},n1="",Ys=" ",Ac=class r1{constructor(){this.fg=0,this.bg=0,this.extended=new Eh}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 r1;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}},Eh=class s1{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 s1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},er=class a1 extends Ac{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Eh,this.combinedData=""}static fromCharData(t){let n=new a1;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?Vs(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 s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let l=t[1].charCodeAt(1);56320<=l&&l<=57343?this.content=(s-55296)*1024+l-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()]}},MS="di$target",gm="di$dependencies",_p=new Map;function pD(e){return e[gm]||[]}function Ui(e){if(_p.has(e))return _p.get(e);let t=function(n,s,l){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");mD(t,n,l)};return t._id=e,_p.set(e,t),t}function mD(e,t,n){t[MS]===t?t[gm].push({id:e,index:n}):(t[gm]=[{id:e,index:n}],t[MS]=t)}var un=Ui("BufferService"),l1=Ui("CoreMouseService"),qa=Ui("CoreService"),gD=Ui("CharsetService"),Gg=Ui("InstantiationService"),o1=Ui("LogService"),hn=Ui("OptionsService"),c1=Ui("OscLinkService"),_D=Ui("UnicodeService"),Lc=Ui("DecorationService"),_m=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 s=[],l=this._optionsService.rawOptions.linkHandler,c=new er,h=n.getTrimmedLength(),p=-1,g=-1,f=!1;for(let b=0;b<h;b++)if(!(g===-1&&!n.hasContent(b))){if(n.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let S={start:{x:g+1,y:e},end:{x:b+(!f&&b===h-1?1:0),y:e}},w=!1;if(!l?.allowNonHttpProtocols)try{let k=new URL(y);["http:","https:"].includes(k.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:S,activate:(k,T)=>l?l.activate(k,T,S):vD(k,T),hover:(k,T)=>l?.hover?.(k,T,S),leave:(k,T)=>l?.leave?.(k,T,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,p=c.extended.urlId):(g=-1,p=-1)}}t(s)}};_m=ai([Ae(0,un),Ae(1,hn),Ae(2,c1)],_m);function vD(e,t){if(confirm(`Do you want to navigate to ${t}?
16
+
17
+ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Xh=Ui("CharSizeService"),rs=Ui("CoreBrowserService"),Zg=Ui("MouseService"),ss=Ui("RenderService"),yD=Ui("SelectionService"),u1=Ui("CharacterJoinerService"),Yl=Ui("ThemeService"),h1=Ui("LinkProviderService"),bD=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?NS.isErrorNoTelemetry(e)?new NS(e.message+`
18
+
19
+ `+e.stack):new Error(e.message+`
20
+
21
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},SD=new bD;function ah(e){wD(e)||SD.onUnexpectedError(e)}var vm="Canceled";function wD(e){return e instanceof CD?!0:e instanceof Error&&e.name===vm&&e.message===vm}var CD=class extends Error{constructor(){super(vm),this.name=this.message}};function xD(e){return new Error(`Illegal argument: ${e}`)}var NS=class ym extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ym)return t;let n=new ym;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},bm=class d1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,d1.prototype)}};function Nn(e,t=0){return e[e.length-(1+t)]}var kD;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function s(c){return c>0}e.isGreaterThan=s;function l(c){return c===0}e.isNeitherLessOrGreaterThan=l,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(kD||={});function ED(e,t){let n=this,s=!1,l;return function(){return s||(s=!0,t||(l=e.apply(n,arguments))),l}}var f1;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*l(P){yield P}e.single=l;function c(P){return t(P)?P:l(P)}e.wrap=c;function h(P){return P||n}e.from=h;function*p(P){for(let q=P.length-1;q>=0;q--)yield P[q]}e.reverse=p;function g(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(P){return P[Symbol.iterator]().next().value}e.first=f;function b(P,q){let re=0;for(let ne of P)if(q(ne,re++))return!0;return!1}e.some=b;function y(P,q){for(let re of P)if(q(re))return re}e.find=y;function*S(P,q){for(let re of P)q(re)&&(yield re)}e.filter=S;function*w(P,q){let re=0;for(let ne of P)yield q(ne,re++)}e.map=w;function*k(P,q){let re=0;for(let ne of P)yield*q(ne,re++)}e.flatMap=k;function*T(...P){for(let q of P)yield*q}e.concat=T;function L(P,q,re){let ne=re;for(let ue of P)ne=q(ne,ue);return ne}e.reduce=L;function*A(P,q,re=P.length){for(q<0&&(q+=P.length),re<0?re+=P.length:re>P.length&&(re=P.length);q<re;q++)yield P[q]}e.slice=A;function O(P,q=Number.POSITIVE_INFINITY){let re=[];if(q===0)return[re,P];let ne=P[Symbol.iterator]();for(let ue=0;ue<q;ue++){let ye=ne.next();if(ye.done)return[re,e.empty()];re.push(ye.value)}return[re,{[Symbol.iterator](){return ne}}]}e.consume=O;async function Y(P){let q=[];for await(let re of P)q.push(re);return Promise.resolve(q)}e.asyncToArray=Y})(f1||={});function Ka(e){if(f1.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}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 TD(...e){return Xt(()=>Ka(e))}function Xt(e){return{dispose:ED(()=>{e()})}}var p1=class m1{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{Ka(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?m1.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)}};p1.DISABLE_DISPOSED_WARNING=!1;var Gs=p1,ot=class{constructor(){this._store=new Gs,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)}};ot.None=Object.freeze({dispose(){}});var Kl=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}},is=typeof window=="object"?window:globalThis,Sm=class wm{constructor(t){this.element=t,this.next=wm.Undefined,this.prev=wm.Undefined}};Sm.Undefined=new Sm(void 0);var Qt=Sm,AS=class{constructor(){this._first=Qt.Undefined,this._last=Qt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Qt.Undefined}clear(){let e=this._first;for(;e!==Qt.Undefined;){let t=e.next;e.prev=Qt.Undefined,e.next=Qt.Undefined,e=t}this._first=Qt.Undefined,this._last=Qt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Qt(e);if(this._first===Qt.Undefined)this._first=n,this._last=n;else if(t){let l=this._last;this._last=n,n.prev=l,l.next=n}else{let l=this._first;this._first=n,n.next=l,l.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Qt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Qt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Qt.Undefined&&e.next!==Qt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Qt.Undefined&&e.next===Qt.Undefined?(this._first=Qt.Undefined,this._last=Qt.Undefined):e.next===Qt.Undefined?(this._last=this._last.prev,this._last.next=Qt.Undefined):e.prev===Qt.Undefined&&(this._first=this._first.next,this._first.prev=Qt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Qt.Undefined;)yield e.element,e=e.next}},DD=globalThis.performance&&typeof globalThis.performance.now=="function",RD=class g1{static create(t){return new g1(t)}constructor(t){this._now=DD&&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}},Gi;(e=>{e.None=()=>ot.None;function t(W,H){return y(W,()=>{},0,void 0,!0,void 0,H)}e.defer=t;function n(W){return(H,j=null,ae)=>{let R=!1,X;return X=W(Z=>{if(!R)return X?X.dispose():R=!0,H.call(j,Z)},null,ae),R&&X.dispose(),X}}e.once=n;function s(W,H,j){return f((ae,R=null,X)=>W(Z=>ae.call(R,H(Z)),null,X),j)}e.map=s;function l(W,H,j){return f((ae,R=null,X)=>W(Z=>{H(Z),ae.call(R,Z)},null,X),j)}e.forEach=l;function c(W,H,j){return f((ae,R=null,X)=>W(Z=>H(Z)&&ae.call(R,Z),null,X),j)}e.filter=c;function h(W){return W}e.signal=h;function p(...W){return(H,j=null,ae)=>{let R=TD(...W.map(X=>X(Z=>H.call(j,Z))));return b(R,ae)}}e.any=p;function g(W,H,j,ae){let R=j;return s(W,X=>(R=H(R,X),R),ae)}e.reduce=g;function f(W,H){let j,ae={onWillAddFirstListener(){j=W(R.fire,R)},onDidRemoveLastListener(){j?.dispose()}},R=new ke(ae);return H?.add(R),R.event}function b(W,H){return H instanceof Array?H.push(W):H&&H.add(W),W}function y(W,H,j=100,ae=!1,R=!1,X,Z){let Ce,Te,M,Q=0,he,ge={leakWarningThreshold:X,onWillAddFirstListener(){Ce=W(Se=>{Q++,Te=H(Te,Se),ae&&!M&&(_e.fire(Te),Te=void 0),he=()=>{let Ee=Te;Te=void 0,M=void 0,(!ae||Q>1)&&_e.fire(Ee),Q=0},typeof j=="number"?(clearTimeout(M),M=setTimeout(he,j)):M===void 0&&(M=0,queueMicrotask(he))})},onWillRemoveListener(){R&&Q>0&&he?.()},onDidRemoveLastListener(){he=void 0,Ce.dispose()}},_e=new ke(ge);return Z?.add(_e),_e.event}e.debounce=y;function S(W,H=0,j){return e.debounce(W,(ae,R)=>ae?(ae.push(R),ae):[R],H,void 0,!0,void 0,j)}e.accumulate=S;function w(W,H=(ae,R)=>ae===R,j){let ae=!0,R;return c(W,X=>{let Z=ae||!H(X,R);return ae=!1,R=X,Z},j)}e.latch=w;function k(W,H,j){return[e.filter(W,H,j),e.filter(W,ae=>!H(ae),j)]}e.split=k;function T(W,H=!1,j=[],ae){let R=j.slice(),X=W(Te=>{R?R.push(Te):Ce.fire(Te)});ae&&ae.add(X);let Z=()=>{R?.forEach(Te=>Ce.fire(Te)),R=null},Ce=new ke({onWillAddFirstListener(){X||(X=W(Te=>Ce.fire(Te)),ae&&ae.add(X))},onDidAddFirstListener(){R&&(H?setTimeout(Z):Z())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return ae&&ae.add(Ce),Ce.event}e.buffer=T;function L(W,H){return(j,ae,R)=>{let X=H(new O);return W(function(Z){let Ce=X.evaluate(Z);Ce!==A&&j.call(ae,Ce)},void 0,R)}}e.chain=L;let A=Symbol("HaltChainable");class O{constructor(){this.steps=[]}map(H){return this.steps.push(H),this}forEach(H){return this.steps.push(j=>(H(j),j)),this}filter(H){return this.steps.push(j=>H(j)?j:A),this}reduce(H,j){let ae=j;return this.steps.push(R=>(ae=H(ae,R),ae)),this}latch(H=(j,ae)=>j===ae){let j=!0,ae;return this.steps.push(R=>{let X=j||!H(R,ae);return j=!1,ae=R,X?R:A}),this}evaluate(H){for(let j of this.steps)if(H=j(H),H===A)break;return H}}function Y(W,H,j=ae=>ae){let ae=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.on(H,ae),X=()=>W.removeListener(H,ae),Z=new ke({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromNodeEventEmitter=Y;function P(W,H,j=ae=>ae){let ae=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.addEventListener(H,ae),X=()=>W.removeEventListener(H,ae),Z=new ke({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromDOMEventEmitter=P;function q(W){return new Promise(H=>n(W)(H))}e.toPromise=q;function re(W){let H=new ke;return W.then(j=>{H.fire(j)},()=>{H.fire(void 0)}).finally(()=>{H.dispose()}),H.event}e.fromPromise=re;function ne(W,H){return W(j=>H.fire(j))}e.forward=ne;function ue(W,H,j){return H(j),W(ae=>H(ae))}e.runAndSubscribe=ue;class ye{constructor(H,j){this._observable=H,this._counter=0,this._hasChanged=!1;let ae={onWillAddFirstListener:()=>{H.addObserver(this)},onDidRemoveLastListener:()=>{H.removeObserver(this)}};this.emitter=new ke(ae),j&&j.add(this.emitter)}beginUpdate(H){this._counter++}handlePossibleChange(H){}handleChange(H,j){this._hasChanged=!0}endUpdate(H){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(W,H){return new ye(W,H).emitter.event}e.fromObservable=U;function K(W){return(H,j,ae)=>{let R=0,X=!1,Z={beginUpdate(){R++},endUpdate(){R--,R===0&&(W.reportChanges(),X&&(X=!1,H.call(j)))},handlePossibleChange(){},handleChange(){X=!0}};W.addObserver(Z),W.reportChanges();let Ce={dispose(){W.removeObserver(Z)}};return ae instanceof Gs?ae.add(Ce):Array.isArray(ae)&&ae.push(Ce),Ce}}e.fromObservableLight=K})(Gi||={});var Cm=class xm{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xm._idPool++}`,xm.all.add(this)}start(t){this._stopWatch=new RD,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}}};Cm.all=new Set,Cm._idPool=0;var MD=Cm,ND=-1,_1=class v1{constructor(t,n,s=(v1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let l=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,l+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new BD(p,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[s,l]of this._stacks)(!t||n<l)&&(t=[s,l],n=l);return t}};_1._idPool=1;var AD=_1,LD=class y1{constructor(t){this.value=t}static create(){let t=new Error;return new y1(t.stack??"")}print(){console.warn(this.value.split(`
22
+ `).slice(2).join(`
23
+ `))}},BD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},OD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},zD=0,vp=class{constructor(e){this.value=e,this.id=zD++}},jD=2,PD,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new AD(e?.onListenerError??ah,this._options?.leakWarningThreshold??ND):void 0,this._perfMon=this._options?._profName?new MD(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 h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new OD(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||ah)(g),ot.None}if(this._disposed)return ot.None;t&&(e=e.bind(t));let s=new vp(e),l;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=LD.create(),l=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof vp?(this._deliveryQueue??=new HD,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Xt(()=>{l?.(),this._removeListener(s)});return n instanceof Gs?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 s=this._deliveryQueue.current===this;if(this._size*jD<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:s&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||ah;if(!n){e.value(t);return}try{e.value(t)}catch(s){n(s)}}_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 vp)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}},HD=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}},km=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,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 s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}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 s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};km.INSTANCE=new km;var Qg=km;function ID(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Qg.INSTANCE.onDidChangeZoomLevel;function UD(e){return Qg.INSTANCE.getZoomFactor(e)}Qg.INSTANCE.onDidChangeFullscreen;var Xl=typeof navigator=="object"?navigator.userAgent:"",Em=Xl.indexOf("Firefox")>=0,KD=Xl.indexOf("AppleWebKit")>=0,Jg=Xl.indexOf("Chrome")>=0,WD=!Jg&&Xl.indexOf("Safari")>=0;Xl.indexOf("Electron/")>=0;Xl.indexOf("Android")>=0;var yp=!1;if(typeof is.matchMedia=="function"){let e=is.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=is.matchMedia("(display-mode: fullscreen)");yp=e.matches,ID(is,e,({matches:n})=>{yp&&t.matches||(yp=n)})}var Ll="en",Tm=!1,Dm=!1,lh=!1,b1=!1,Vu,oh=Ll,LS=Ll,FD,es,ja=globalThis,Bn;typeof ja.vscode<"u"&&typeof ja.vscode.process<"u"?Bn=ja.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Bn=process);var qD=typeof Bn?.versions?.electron=="string",$D=qD&&Bn?.type==="renderer";if(typeof Bn=="object"){Tm=Bn.platform==="win32",Dm=Bn.platform==="darwin",lh=Bn.platform==="linux",lh&&Bn.env.SNAP&&Bn.env.SNAP_REVISION,Bn.env.CI||Bn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Vu=Ll,oh=Ll;let e=Bn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Vu=t.userLocale,LS=t.osLocale,oh=t.resolvedLanguage||Ll,FD=t.languagePack?.translationsConfigFile}catch{}b1=!0}else typeof navigator=="object"&&!$D?(es=navigator.userAgent,Tm=es.indexOf("Windows")>=0,Dm=es.indexOf("Macintosh")>=0,(es.indexOf("Macintosh")>=0||es.indexOf("iPad")>=0||es.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,lh=es.indexOf("Linux")>=0,es?.indexOf("Mobi")>=0,oh=globalThis._VSCODE_NLS_LANGUAGE||Ll,Vu=navigator.language.toLowerCase(),LS=Vu):console.error("Unable to resolve platform.");var S1=Tm,Rr=Dm,VD=lh,BS=b1,Mr=es,Is=oh,YD;(e=>{function t(){return Is}e.value=t;function n(){return Is.length===2?Is==="en":Is.length>=3?Is[0]==="e"&&Is[1]==="n"&&Is[2]==="-":!1}e.isDefaultVariant=n;function s(){return Is==="en"}e.isDefault=s})(YD||={});var XD=typeof ja.postMessage=="function"&&!ja.importScripts;(()=>{if(XD){let e=[];ja.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,l=e.length;s<l;s++){let c=e[s];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),ja.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var GD=!!(Mr&&Mr.indexOf("Chrome")>=0);Mr&&Mr.indexOf("Firefox")>=0;!GD&&Mr&&Mr.indexOf("Safari")>=0;Mr&&Mr.indexOf("Edg/")>=0;Mr&&Mr.indexOf("Android")>=0;var Tl=typeof navigator=="object"?navigator:{};BS||document.queryCommandSupported&&document.queryCommandSupported("copy")||Tl&&Tl.clipboard&&Tl.clipboard.writeText,BS||Tl&&Tl.clipboard&&Tl.clipboard.readText;var e_=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}},bp=new e_,OS=new e_,zS=new e_,ZD=new Array(230),w1;(e=>{function t(p){return bp.keyCodeToStr(p)}e.toString=t;function n(p){return bp.strToKeyCode(p)}e.fromString=n;function s(p){return OS.keyCodeToStr(p)}e.toUserSettingsUS=s;function l(p){return zS.keyCodeToStr(p)}e.toUserSettingsGeneral=l;function c(p){return OS.strToKeyCode(p)||zS.strToKeyCode(p)}e.fromUserSettings=c;function h(p){if(p>=98&&p<=113)return null;switch(p){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return bp.keyCodeToStr(p)}e.toElectronAccelerator=h})(w1||={});var QD=class C1{constructor(t,n,s,l,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=l,this.keyCode=c}equals(t){return t instanceof C1&&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",s=this.altKey?"1":"0",l=this.metaKey?"1":"0";return`K${t}${n}${s}${l}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new JD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},JD=class{constructor(e){if(e.length===0)throw xD("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 eR(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return w1.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Em)switch(t){case 59:return 85;case 60:if(VD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Rr)return 57;break}else if(KD&&(Rr&&t===93||!Rr&&t===92))return 57;return ZD[t]||0}var tR=Rr?256:2048,iR=512,nR=1024,rR=Rr?2048:256,jS=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=eR(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|=tR),this.altKey&&(t|=iR),this.shiftKey&&(t|=nR),this.metaKey&&(t|=rR),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new QD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},PS=new WeakMap;function sR(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 aR=class{static getSameOriginWindowChain(e){let t=PS.get(e);if(!t){t=[],PS.set(e,t);let n=e,s;do s=sR(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,l=this.getSameOriginWindowChain(e);for(let c of l){let h=c.window.deref();if(n+=h?.scrollY??0,s+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();n+=p.top,s+=p.left}return{top:n,left:s}}},Yu=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=aR.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},HS=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 s=!1;if(Jg){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*h):this.deltaY=l.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Em&&!Rr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")WD&&S1?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*h):this.deltaX=l.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 p=e;p.deltaMode===p.DOM_DELTA_LINE?Em&&!Rr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},x1=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),lR;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof oR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:x1})})(lR||={});var oR=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?x1:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},t_=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 bm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},cR=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 bm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Xt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},uR;(e=>{async function t(s){let l,c=await Promise.all(s.map(h=>h.then(p=>p,p=>{l||(l=p)})));if(typeof l<"u")throw l;return c}e.settled=t;function n(s){return new Promise(async(l,c)=>{try{await s(l,c)}catch(h){c(h)}})}e.withAsyncBody=n})(uR||={});var IS=class Gn{static fromArray(t){return new Gn(n=>{n.emitMany(t)})}static fromPromise(t){return new Gn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Gn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Gn(async n=>{await Promise.all(t.map(async s=>{for await(let l of s)n.emitOne(l)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new ke,queueMicrotask(async()=>{let s={emitOne:l=>this.emitOne(l),emitMany:l=>this.emitMany(l),reject:l=>this.reject(l)};try{await Promise.resolve(t(s)),this.resolve()}catch(l){this.reject(l)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Gi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new Gn(async s=>{for await(let l of t)s.emitOne(n(l))})}map(t){return Gn.map(this,t)}static filter(t,n){return new Gn(async s=>{for await(let l of t)n(l)&&s.emitOne(l)})}filter(t){return Gn.filter(this,t)}static coalesce(t){return Gn.filter(t,n=>!!n)}coalesce(){return Gn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Gn.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())}};IS.EMPTY=IS.fromArray([]);var{getWindow:Dr,getWindowId:hR,onDidRegisterWindow:dR}=(function(){let e=new Map,t={window:is,disposables:new Gs};e.set(is.vscodeWindowId,t);let n=new ke,s=new ke,l=new ke;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:l.event,onDidUnregisterWindow:s.event,registerWindow(h){if(e.has(h.vscodeWindowId))return ot.None;let p=new Gs,g={window:h,disposables:p.add(new Gs)};return e.set(h.vscodeWindowId,g),p.add(Xt(()=>{e.delete(h.vscodeWindowId),s.fire(h)})),p.add(Xe(h,zi.BEFORE_UNLOAD,()=>{l.fire(h)})),n.fire(g),p},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let p=h;if(p?.ownerDocument?.defaultView)return p.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:is},getDocument(h){return Dr(h).document}}})(),fR=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!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 Xe(e,t,n,s){return new fR(e,t,n,s)}var US=function(e,t,n,s){return Xe(e,t,n,s)},i_,pR=class extends cR{constructor(e){super(),this.defaultTarget=e&&Dr(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},KS=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){ah(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,l=c=>{n.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),s.set(c,!0);h.length>0;)h.sort(KS.sort),h.shift().execute();s.set(c,!1)};i_=(c,h,p=0)=>{let g=hR(c),f=new KS(h,p),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(f),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>l(g))),f}})();function mR(e){let t=e.getBoundingClientRect(),n=Dr(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var zi={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"},gR=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=bn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=bn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=bn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=bn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=bn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=bn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=bn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=bn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=bn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=bn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=bn(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=bn(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=bn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=bn(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 bn(e){return typeof e=="number"?`${e}px`:e}function dc(e){return new gR(e)}var k1=class{constructor(){this._hooks=new Gs,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,s,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=l;let c=e;try{e.setPointerCapture(t),this._hooks.add(Xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Dr(e)}this._hooks.add(Xe(c,zi.POINTER_MOVE,h=>{if(h.buttons!==n){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Xe(c,zi.POINTER_UP,h=>this.stopMonitoring(!0)))}};function _R(e,t,n){let s=null,l=null;if(typeof n.value=="function"?(s="value",l=n.value,l.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",l=n.get),!l)throw new Error("not supported");let c=`$memoize$${t}`;n[s]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:l.apply(this,h)}),this[c]}}var Tr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Tr||={});var Zo=class rn extends ot{constructor(){super(),this.dispatched=!1,this.targets=new AS,this.ignoreTargets=new AS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Gi.runAndSubscribe(dR,({window:t,disposables:n})=>{n.add(Xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:is,disposables:this._store}))}static addTarget(t){if(!rn.isTouchDevice())return ot.None;rn.INSTANCE||(rn.INSTANCE=new rn);let n=rn.INSTANCE.targets.push(t);return Xt(n)}static ignoreTarget(t){if(!rn.isTouchDevice())return ot.None;rn.INSTANCE||(rn.INSTANCE=new rn);let n=rn.INSTANCE.ignoreTargets.push(t);return Xt(n)}static isTouchDevice(){return"ontouchstart"in is||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 s=0,l=t.targetTouches.length;s<l;s++){let c=t.targetTouches.item(s);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 h=this.newGestureEvent(Tr.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),l=Object.keys(this.activeTouches).length;for(let c=0,h=n.changedTouches.length;c<h;c++){let p=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(p.identifier))){console.warn("move of an UNKNOWN touch",p);continue}let g=this.activeTouches[p.identifier],f=Date.now()-g.initialTimeStamp;if(f<rn.HOLD_DELAY&&Math.abs(g.initialPageX-Nn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Nn(g.rollingPageY))<30){let b=this.newGestureEvent(Tr.Tap,g.initialTarget);b.pageX=Nn(g.rollingPageX),b.pageY=Nn(g.rollingPageY),this.dispatchEvent(b)}else if(f>=rn.HOLD_DELAY&&Math.abs(g.initialPageX-Nn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Nn(g.rollingPageY))<30){let b=this.newGestureEvent(Tr.Contextmenu,g.initialTarget);b.pageX=Nn(g.rollingPageX),b.pageY=Nn(g.rollingPageY),this.dispatchEvent(b)}else if(l===1){let b=Nn(g.rollingPageX),y=Nn(g.rollingPageY),S=Nn(g.rollingTimestamps)-g.rollingTimestamps[0],w=b-g.rollingPageX[0],k=y-g.rollingPageY[0],T=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,T,s,Math.abs(w)/S,w>0?1:-1,b,Math.abs(k)/S,k>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Tr.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===Tr.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>rn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Tr.Change||t.type===Tr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let l=0,c=t.initialTarget;for(;c&&c!==s;)l++,c=c.parentElement;n.push([l,s])}n.sort((s,l)=>s[0]-l[0]);for(let[s,l]of n)l.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,l,c,h,p,g,f){this.handle=i_(t,()=>{let b=Date.now(),y=b-s,S=0,w=0,k=!0;l+=rn.SCROLL_FRICTION*y,p+=rn.SCROLL_FRICTION*y,l>0&&(k=!1,S=c*l*y),p>0&&(k=!1,w=g*p*y);let T=this.newGestureEvent(Tr.Change);T.translationX=S,T.translationY=w,n.forEach(L=>L.dispatchEvent(T)),k||this.inertia(t,n,b,l,c,h+S,p,g,f+w)})}onTouchMove(t){let n=Date.now();for(let s=0,l=t.changedTouches.length;s<l;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(Tr.Change,h.initialTarget);p.translationX=c.pageX-Nn(h.rollingPageX),p.translationY=c.pageY-Nn(h.rollingPageY),p.pageX=c.pageX,p.pageY=c.pageY,this.dispatchEvent(p),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Zo.SCROLL_FRICTION=-.005,Zo.HOLD_DELAY=700,Zo.CLEAR_TAP_COUNT_TIME=400,ai([_R],Zo,"isTouchDevice",1);var vR=Zo,n_=class extends ot{onclick(e,t){this._register(Xe(e,zi.CLICK,n=>t(new Yu(Dr(e),n))))}onmousedown(e,t){this._register(Xe(e,zi.MOUSE_DOWN,n=>t(new Yu(Dr(e),n))))}onmouseover(e,t){this._register(Xe(e,zi.MOUSE_OVER,n=>t(new Yu(Dr(e),n))))}onmouseleave(e,t){this._register(Xe(e,zi.MOUSE_LEAVE,n=>t(new Yu(Dr(e),n))))}onkeydown(e,t){this._register(Xe(e,zi.KEY_DOWN,n=>t(new jS(n))))}onkeyup(e,t){this._register(Xe(e,zi.KEY_UP,n=>t(new jS(n))))}oninput(e,t){this._register(Xe(e,zi.INPUT,t))}onblur(e,t){this._register(Xe(e,zi.BLUR,t))}onfocus(e,t){this._register(Xe(e,zi.FOCUS,t))}onchange(e,t){this._register(Xe(e,zi.CHANGE,t))}ignoreGesture(e){return vR.ignoreTarget(e)}},WS=11,yR=class extends n_{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=WS+"px",this.domNode.style.height=WS+"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 k1),this._register(US(this.bgDomNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(US(this.domNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new pR),this._pointerdownScheduleRepeatTimer=this._register(new t_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Dr(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()}},bR=class Rm{constructor(t,n,s,l,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,l=l|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=l,this.rawScrollTop=p,n<0&&(n=0),l+n>s&&(l=s-n),l<0&&(l=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=n,this.scrollWidth=s,this.scrollLeft=l,this.height=c,this.scrollHeight=h,this.scrollTop=p}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 Rm(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 Rm(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 s=this.width!==t.width,l=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,p=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:s,scrollWidthChanged:l,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},SR=class extends ot{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new bR(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 s;t?s=new qS(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=qS.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)))}},FS=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Sp(e,t){let n=t-e;return function(s){return e+n*xR(s)}}function wR(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var qS=class Mm{constructor(t,n,s,l){this.from=t,this.to=n,this.duration=l,this.startTime=s,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,s){if(Math.abs(t-n)>2.5*s){let l,c;return t<n?(l=t+.75*s,c=n-.75*s):(l=t-.75*s,c=n+.75*s),wR(Sp(t,l),Sp(c,n),.33)}return Sp(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 s=this.scrollLeft(n),l=this.scrollTop(n);return new FS(s,l,!1)}return new FS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return Mm.start(t,n,s)}static start(t,n,s){s=s+10;let l=Date.now()-10;return new Mm(t,n,l,s)}};function CR(e){return Math.pow(e,3)}function xR(e){return 1-CR(1-e)}var kR=class extends ot{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 t_)}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":"")))}},ER=140,E1=class extends n_{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 kR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new k1),this._shouldRender=!0,this.domNode=dc(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(Xe(this.domNode.domNode,zi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new yR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=dc(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 s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Xe(this.slider.domNode,zi.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.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(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);n<=l&&l<=s?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 l=mR(this.domNode.domNode);t=e.pageX-l.left,n=e.pageY-l.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),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),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),h=Math.abs(c-n);if(S1&&h>ER){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let p=this._sliderPointerPosition(l)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(p))},()=>{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()}},T1=class Nm{constructor(t,n,s,l,c,h){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=l,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Nm(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,s,l,c){let h=Math.max(0,s-t),p=Math.max(0,h-2*n),g=l>0&&l>s;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*p/l))),b=(p-f)/(l-s),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=Nm._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,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},TR=class extends E1{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new T1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,l.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}},DR=class extends E1{constructor(e,t,n){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new T1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,l.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}},RR=500,$S=50,MR=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Am=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,s=1,l=this._rear;do{let c=l===this._front?t:Math.pow(2,-s);if(t-=c,n+=this._memory[l].score*c,l===this._front)break;l=(this._capacity+l-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Jg){let n=Dr(t.browserEvent),s=UD(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let l=null,c=new MR(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(l=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,l)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let l=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(n.deltaX),p=Math.abs(n.deltaY),g=Math.max(Math.min(l,h),1),f=Math.max(Math.min(c,p),1),b=Math.max(l,h),y=Math.max(c,p);b%g===0&&y%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Am.INSTANCE=new Am;var NR=Am,AR=class extends n_{constructor(e,t,n){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=BR(t),this._scrollable=n,this._register(this._scrollable.onScroll(l=>{this._onWillScroll.fire(l),this._onDidScroll(l),this._onScroll.fire(l)}));let s={onMouseWheel:l=>this._onMouseWheel(l),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new DR(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new TR(this._scrollable,this._options,s)),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=dc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=dc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=dc(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,l=>this._onMouseOver(l)),this.onmouseleave(this._listenOnDomNode,l=>this._onMouseLeave(l)),this._hideTimeout=this._register(new t_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ka(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,Rr&&(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 HS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ka(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new HS(n))};this._mouseWheelToDispose.push(Xe(this._listenOnDomNode,zi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=NR.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let h=!Rr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(l){let f=$S*l,b=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let f=$S*c,b=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,s=n?" left":"",l=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${l}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${l}${s}`)}}_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(),RR)}},LR=class extends AR{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 BR(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,Rr&&(t.className+=" mac"),t}var Lm=class extends ot{constructor(e,t,n,s,l,c,h,p){super(),this._bufferService=n,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new SR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>i_(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new LR(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(l.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Gi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Xt(()=>this._styleElement.remove())),this._register(Gi.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
24
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}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}};Lm=ai([Ae(2,un),Ae(3,rs),Ae(4,l1),Ae(5,Yl),Ae(6,hn),Ae(7,ss)],Lm);var Bm=class extends ot{constructor(e,t,n,s,l){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=l,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(Xt(()=>{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()}};Bm=ai([Ae(1,un),Ae(2,rs),Ae(3,Lc),Ae(4,ss)],Bm);var OR=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)}},kr={full:0,left:0,center:0,right:0},Us={full:0,left:0,center:0,right:0},Io={full:0,left:0,center:0,right:0},Th=class extends ot{constructor(e,t,n,s,l,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=l,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,this._colorZoneStore=new OR,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(Xt(()=>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);Us.full=this._canvas.width,Us.left=e,Us.center=t,Us.right=e,this._refreshDrawHeightConstants(),Io.full=1,Io.left=1,Io.center=1+Us.left,Io.right=1+Us.left+Us.center}_refreshDrawHeightConstants(){kr.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);kr.left=t,kr.center=t,kr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*kr.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(Io[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-kr[e.position||"full"]/2),Us[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+kr[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}))}};Th=ai([Ae(2,un),Ae(3,Lc),Ae(4,ss),Ae(5,hn),Ae(6,Yl),Ae(7,rs)],Th);var de;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
25
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(de||={});var ch;(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="Ÿ"))(ch||={});var D1;(e=>e.ST=`${de.ESC}\\`)(D1||={});var Om=class{constructor(e,t,n,s,l,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=l,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(`${de.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,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"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=l+"px",this._textarea.style.top=s+"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)}}};Om=ai([Ae(2,un),Ae(3,hn),Ae(4,qa),Ae(5,ss)],Om);var Pi=0,Hi=0,Ii=0,si=0,VS={css:"#00000000",rgba:0},bi;(e=>{function t(l,c,h,p){return p!==void 0?`#${Da(l)}${Da(c)}${Da(h)}${Da(p)}`:`#${Da(l)}${Da(c)}${Da(h)}`}e.toCss=t;function n(l,c,h,p=255){return(l<<24|c<<16|h<<8|p)>>>0}e.toRgba=n;function s(l,c,h,p){return{css:e.toCss(l,c,h,p),rgba:e.toRgba(l,c,h,p)}}e.toColor=s})(bi||={});var Ft;(e=>{function t(g,f){if(si=(f.rgba&255)/255,si===1)return{css:f.css,rgba:f.rgba};let b=f.rgba>>24&255,y=f.rgba>>16&255,S=f.rgba>>8&255,w=g.rgba>>24&255,k=g.rgba>>16&255,T=g.rgba>>8&255;Pi=w+Math.round((b-w)*si),Hi=k+Math.round((y-k)*si),Ii=T+Math.round((S-T)*si);let L=bi.toCss(Pi,Hi,Ii),A=bi.toRgba(Pi,Hi,Ii);return{css:L,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function s(g,f,b){let y=uh.ensureContrastRatio(g.rgba,f.rgba,b);if(y)return bi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=s;function l(g){let f=(g.rgba|255)>>>0;return[Pi,Hi,Ii]=uh.toChannels(f),{css:bi.toCss(Pi,Hi,Ii),rgba:f}}e.opaque=l;function c(g,f){return si=Math.round(f*255),[Pi,Hi,Ii]=uh.toChannels(g.rgba),{css:bi.toCss(Pi,Hi,Ii,si),rgba:bi.toRgba(Pi,Hi,Ii,si)}}e.opacity=c;function h(g,f){return si=g.rgba&255,c(g,si*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Ft||={});var Jt;(e=>{let t,n;try{let l=document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(l){if(l.match(/#[\da-f]{3,8}/i))switch(l.length){case 4:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),bi.toColor(Pi,Hi,Ii);case 5:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),si=parseInt(l.slice(4,5).repeat(2),16),bi.toColor(Pi,Hi,Ii,si);case 7:return{css:l,rgba:(parseInt(l.slice(1),16)<<8|255)>>>0};case 9:return{css:l,rgba:parseInt(l.slice(1),16)>>>0}}let c=l.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 Pi=parseInt(c[1]),Hi=parseInt(c[2]),Ii=parseInt(c[3]),si=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),bi.toColor(Pi,Hi,Ii,si);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=l,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pi,Hi,Ii,si]=t.getImageData(0,0,1,1).data,si!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:bi.toRgba(Pi,Hi,Ii,si),css:l}}e.toColor=s})(Jt||={});var cn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,l,c){let h=s/255,p=l/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+b*.7152+y*.0722}e.relativeLuminance2=n})(cn||={});var uh;(e=>{function t(h,p){if(si=(p&255)/255,si===1)return p;let g=p>>24&255,f=p>>16&255,b=p>>8&255,y=h>>24&255,S=h>>16&255,w=h>>8&255;return Pi=y+Math.round((g-y)*si),Hi=S+Math.round((f-S)*si),Ii=w+Math.round((b-w)*si),bi.toRgba(Pi,Hi,Ii)}e.blend=t;function n(h,p,g){let f=cn.relativeLuminance(h>>8),b=cn.relativeLuminance(p>>8);if(Jr(f,b)<g){if(b<f){let w=s(h,p,g),k=Jr(f,cn.relativeLuminance(w>>8));if(k<g){let T=l(h,p,g),L=Jr(f,cn.relativeLuminance(T>>8));return k>L?w:T}return w}let y=l(h,p,g),S=Jr(f,cn.relativeLuminance(y>>8));if(S<g){let w=s(h,p,g),k=Jr(f,cn.relativeLuminance(w>>8));return S>k?y:w}return y}}e.ensureContrastRatio=n;function s(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,T=Jr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));for(;T<g&&(S>0||w>0||k>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),k-=Math.max(0,Math.ceil(k*.1)),T=Jr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.reduceLuminance=s;function l(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,S=p>>24&255,w=p>>16&255,k=p>>8&255,T=Jr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));for(;T<g&&(S<255||w<255||k<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),T=Jr(cn.relativeLuminance2(S,w,k),cn.relativeLuminance2(f,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.increaseLuminance=l;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(uh||={});function Da(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Jr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var zR=class extends Ac{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()]}},Dh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new er}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=[],s=t.translateToString(!0),l=0,c=0,h=0,p=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==p||this._workCell.bg!==g){if(f-l>1){let b=this._getJoinedRanges(s,h,c,t,l);for(let y=0;y<b.length;y++)n.push(b[y])}l=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ys.length}if(this._bufferService.cols-l>1){let f=this._getJoinedRanges(s,h,c,t,l);for(let b=0;b<f.length;b++)n.push(f[b])}return n}_getJoinedRanges(e,t,n,s,l){let c=e.substring(t,n),h=[];try{h=this._characterJoiners[0].handler(c)}catch(p){console.error(p)}for(let p=1;p<this._characterJoiners.length;p++)try{let g=this._characterJoiners[p].handler(c);for(let f=0;f<g.length;f++)Dh._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,s,l),h}_stringRangesToCellRanges(e,t,n){let s=0,l=!1,c=0,h=e[s];if(h){for(let p=n;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||Ys.length;if(g!==0){if(!l&&h[0]<=c&&(h[0]=p,l=!0),h[1]<=c){if(h[1]=p,h=e[++s],!h)break;h[0]<=c?(h[0]=p,l=!0):l=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let l=e[s];if(n){if(t[1]<=l[0])return e[s-1][1]=t[1],e;if(t[1]<=l[1])return e[s-1][1]=Math.max(t[1],l[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=l[0])return e.splice(s,0,t),e;if(t[1]<=l[1])return l[0]=Math.min(t[0],l[0]),e;t[0]<l[1]&&(l[0]=Math.min(t[0],l[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Dh=ai([Ae(0,un)],Dh);function jR(e){return 57508<=e&&e<=57558}function PR(e){return 9472<=e&&e<=9631}function HR(e){return jR(e)||PR(e)}function IR(){return{css:{canvas:Xu(),cell:Xu()},device:{canvas:Xu(),cell:Xu(),char:{width:0,height:0,left:0,top:0}}}}function Xu(){return{width:0,height:0}}var zm=class{constructor(e,t,n,s,l,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=l,this._decorationService=c,this._themeService=h,this._workCell=new er,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,l,c,h,p,g,f,b){let y=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,k=e.getNoBgTrimmedLength();n&&k<c+1&&(k=c+1);let T,L=0,A="",O=0,Y=0,P=0,q=0,re=!1,ne=0,ue=!1,ye=0,U=0,K=[],W=f!==-1&&b!==-1;for(let H=0;H<k;H++){e.loadCell(H,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let ae=!1,R=H>=U,X=H,Z=this._workCell;if(S.length>0&&H===S[0][0]&&R){let be=S.shift(),Me=this._isCellInSelection(be[0],t);for(O=be[0]+1;O<be[1];O++)R&&=Me===this._isCellInSelection(O,t);R&&=!n||c<be[0]||c>=be[1],R?(ae=!0,Z=new zR(this._workCell,e.translateToString(!0,be[0],be[1]),be[1]-be[0]),X=be[1]-1,j=Z.getWidth()):U=be[1]}let Ce=this._isCellInSelection(H,t),Te=n&&H===c,M=W&&H>=f&&H<=b,Q=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{Q=!0});let he=Z.getChars()||Ys;if(he===" "&&(Z.isUnderline()||Z.isOverline())&&(he=" "),ye=j*p-g.get(he,Z.isBold(),Z.isItalic()),!T)T=this._document.createElement("span");else if(L&&(Ce&&ue||!Ce&&!ue&&Z.bg===Y)&&(Ce&&ue&&w.selectionForeground||Z.fg===P)&&Z.extended.ext===q&&M===re&&ye===ne&&!Te&&!ae&&!Q&&R){Z.isInvisible()?A+=Ys:A+=he,L++;continue}else L&&(T.textContent=A),T=this._document.createElement("span"),L=0,A="";if(Y=Z.bg,P=Z.fg,q=Z.extended.ext,re=M,ne=ye,ue=Ce,ae&&c>=H&&c<=X&&(c=H),!this._coreService.isCursorHidden&&Te&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(Z.isBold()&&K.push("xterm-bold"),Z.isItalic()&&K.push("xterm-italic"),Z.isDim()&&K.push("xterm-dim"),Z.isInvisible()?A=Ys:A=Z.getChars()||Ys,Z.isUnderline()&&(K.push(`xterm-underline-${Z.extended.underlineStyle}`),A===" "&&(A=" "),!Z.isUnderlineColorDefault()))if(Z.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${Ac.toColorRGB(Z.getUnderlineColor()).join(",")})`;else{let be=Z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Z.isBold()&&be<8&&(be+=8),T.style.textDecorationColor=w.ansi[be].css}Z.isOverline()&&(K.push("xterm-overline"),A===" "&&(A=" ")),Z.isStrikethrough()&&K.push("xterm-strikethrough"),M&&(T.style.textDecoration="underline");let ge=Z.getFgColor(),_e=Z.getFgColorMode(),Se=Z.getBgColor(),Ee=Z.getBgColorMode(),De=!!Z.isInverse();if(De){let be=ge;ge=Se,Se=be;let Me=_e;_e=Ee,Ee=Me}let Ie,se,me=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{be.options.layer!=="top"&&me||(be.backgroundColorRGB&&(Ee=50331648,Se=be.backgroundColorRGB.rgba>>8&16777215,Ie=be.backgroundColorRGB),be.foregroundColorRGB&&(_e=50331648,ge=be.foregroundColorRGB.rgba>>8&16777215,se=be.foregroundColorRGB),me=be.options.layer==="top")}),!me&&Ce&&(Ie=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Se=Ie.rgba>>8&16777215,Ee=50331648,me=!0,w.selectionForeground&&(_e=50331648,ge=w.selectionForeground.rgba>>8&16777215,se=w.selectionForeground)),me&&K.push("xterm-decoration-top");let Le;switch(Ee){case 16777216:case 33554432:Le=w.ansi[Se],K.push(`xterm-bg-${Se}`);break;case 50331648:Le=bi.toColor(Se>>16,Se>>8&255,Se&255),this._addStyle(T,`background-color:#${YS((Se>>>0).toString(16),"0",6)}`);break;default:De?(Le=w.foreground,K.push("xterm-bg-257")):Le=w.background}switch(Ie||Z.isDim()&&(Ie=Ft.multiplyOpacity(Le,.5)),_e){case 16777216:case 33554432:Z.isBold()&&ge<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ge+=8),this._applyMinimumContrast(T,Le,w.ansi[ge],Z,Ie,void 0)||K.push(`xterm-fg-${ge}`);break;case 50331648:let be=bi.toColor(ge>>16&255,ge>>8&255,ge&255);this._applyMinimumContrast(T,Le,be,Z,Ie,se)||this._addStyle(T,`color:#${YS(ge.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Le,w.foreground,Z,Ie,se)||De&&K.push("xterm-fg-257")}K.length&&(T.className=K.join(" "),K.length=0),!Te&&!ae&&!Q&&R?L++:T.textContent=A,ye!==this.defaultSpacing&&(T.style.letterSpacing=`${ye}px`),y.push(T),H=X}return T&&L&&(T.textContent=A),y}_applyMinimumContrast(e,t,n,s,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||HR(s.getCode()))return!1;let h=this._getContrastCache(s),p;if(!l&&!c&&(p=h.getColor(t.rgba,n.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);p=Ft.ensureContrastRatio(l||t,c||n,g),h.setColor((l||t).rgba,(c||n).rgba,p??null)}return p?(this._addStyle(e,`color:${p.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,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};zm=ai([Ae(1,u1),Ae(2,hn),Ae(3,rs),Ae(4,qa),Ae(5,Lc),Ae(6,Yl)],zm);function YS(e,t,n){for(;e.length<n;)e=t+e;return e}var UR=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.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,s,l,c],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(l),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,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let h=this._measure(e,0);return h>0&&(this._flat[s]=h),h}let l=e;t&&(l+="B"),n&&(l+="I");let c=this._holey.get(l);if(c===void 0){let h=0;t&&(h|=1),n&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(l,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},KR=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,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let l=e.buffers.active.ydisp,c=t[1]-l,h=n[1]-l,p=Math.max(c,0),g=Math.min(h,e.rows-1);if(p>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,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 WR(){return new KR}var wp="xterm-dom-renderer-owner-",Xn="xterm-rows",Gu="xterm-fg-",XS="xterm-bg-",Uo="xterm-focus",Zu="xterm-selection",FR=1,jm=class extends ot{constructor(e,t,n,s,l,c,h,p,g,f,b,y,S,w){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=l,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=b,this._coreService=y,this._coreBrowserService=S,this._themeService=w,this._terminalClass=FR++,this._rowElements=[],this._selectionRenderModel=WR(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Xn),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(Zu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=IR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(zm,document),this._element.classList.add(wp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(Xt(()=>{this._element.classList.remove(wp+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new UR(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} .${Xn} 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} .${Xn} { 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} .${Xn} .xterm-dim { color: ${Ft.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}`,s=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Xn}.${Uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Xn}.${Uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Xn}.${Uo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Xn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Zu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Zu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Zu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Gu}${c} { color: ${h.css}; }${this._terminalSelector} .${Gu}${c}.xterm-dim { color: ${Ft.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${XS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Gu}257 { color: ${Ft.opaque(e.background).css}; }${this._terminalSelector} .${Gu}257.xterm-dim { color: ${Ft.multiplyOpacity(Ft.opaque(e.background),.5).css}; }${this._terminalSelector} .${XS}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 s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Uo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Uo),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 s=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];p.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=s===c?e[0]:0,f=c===l?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let b=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=l===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,n,s=1){let l=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(n-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),l.style.height=`${s*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${h}px`,l}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,s=n.ybase+n.y,l=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+n.ydisp,b=this._rowElements[g],y=n.lines.get(f);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,f,f===s,h,p,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${wp}${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,s,l,c){n<0&&(e=0),s<0&&(t=0);let h=this._bufferService.rows-1;n=Math.max(Math.min(n,h),0),s=Math.max(Math.min(s,h),0),l=Math.min(l,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,l-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=n;w<=s;++w){let k=w+p.ydisp,T=this._rowElements[w],L=p.lines.get(k);if(!T||!L)break;T.replaceChildren(...this._rowFactory.createRow(L,k,k===g,y,S,f,b,this.dimensions.css.cell.width,this._widthCache,c?w===n?e:0:-1,c?(w===s?t:l)-1:-1))}}};jm=ai([Ae(7,Gg),Ae(8,Xh),Ae(9,hn),Ae(10,un),Ae(11,qa),Ae(12,rs),Ae(13,Yl)],jm);var Pm=class extends ot{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new $R(this._optionsService))}catch{this._measureStrategy=this._register(new qR(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())}};Pm=ai([Ae(2,hn)],Pm);var R1=class extends ot{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)}},qR=class extends R1{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}},$R=class extends R1{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}},VR=class extends ot{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 YR(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Gi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(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}},YR=class extends ot{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Kl),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(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)}},XR=class extends ot{constructor(){super(),this.linkProviders=[],this._register(Xt(()=>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 r_(e,t,n){let s=n.getBoundingClientRect(),l=e.getComputedStyle(n),c=parseInt(l.getPropertyValue("padding-left")),h=parseInt(l.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-h]}function GR(e,t,n,s,l,c,h,p,g){if(!c)return;let f=r_(e,t,n);if(f)return f[0]=Math.ceil((f[0]+(g?h/2:0))/h),f[1]=Math.ceil(f[1]/p),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),l),f}var Hm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,l){return GR(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,t){let n=r_(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])}}};Hm=ai([Ae(0,ss),Ae(1,Xh)],Hm);var ZR=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=[]}},M1={};lD(M1,{getSafariVersion:()=>JR,isChromeOS:()=>B1,isFirefox:()=>N1,isIpad:()=>eM,isIphone:()=>tM,isLegacyEdge:()=>QR,isLinux:()=>s_,isMac:()=>Rh,isNode:()=>Gh,isSafari:()=>A1,isWindows:()=>L1});var Gh=typeof process<"u"&&"title"in process,Bc=Gh?"node":navigator.userAgent,Oc=Gh?"node":navigator.platform,N1=Bc.includes("Firefox"),QR=Bc.includes("Edge"),A1=/^((?!chrome|android).)*safari/i.test(Bc);function JR(){if(!A1)return 0;let e=Bc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Rh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Oc),eM=Oc==="iPad",tM=Oc==="iPhone",L1=["Windows","Win16","Win32","WinCE"].includes(Oc),s_=Oc.indexOf("Linux")>=0,B1=/\bCrOS\b/.test(Bc),O1=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,s=e.timeRemaining(),l=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),l=e.timeRemaining(),n*1.5>l){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=l}this.clear()}},iM=class extends O1{_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())}}},nM=class extends O1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Mh=!Gh&&"requestIdleCallback"in window?nM:iM,rM=class{constructor(){this._queue=new Mh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Im=class extends ot{constructor(e,t,n,s,l,c,h,p,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=l,this._coreBrowserService=p,this._renderer=this._register(new Kl),this._pausedResizeTask=new rM,this._observerDisposable=this._register(new Kl),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 ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ZR((f,b)=>this._renderRows(f,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new sM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.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(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Xt(()=>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 s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.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()}};Im=ai([Ae(2,hn),Ae(3,Xh),Ae(4,qa),Ae(5,Lc),Ae(6,un),Ae(7,rs),Ae(8,Yl)],Im);var sM=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 aM(e,t,n,s){let l=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return cM(l,c,e,t,n,s)+Zh(c,t,n,s)+uM(l,c,e,t,n,s);let h;if(c===t)return h=l>e?"D":"C",bc(Math.abs(l-e),yc(h,s));h=c>t?"D":"C";let p=Math.abs(c-t),g=oM(c>t?e:l,n)+(p-1)*n.cols+1+lM(c>t?l:e);return bc(g,yc(h,s))}function lM(e,t){return e-1}function oM(e,t){return t.cols-e}function cM(e,t,n,s,l,c){return Zh(t,s,l,c).length===0?"":bc(j1(e,t,e,t-Wa(t,l),!1,l).length,yc("D",c))}function Zh(e,t,n,s){let l=e-Wa(e,n),c=t-Wa(t,n),h=Math.abs(l-c)-hM(e,t,n);return bc(h,yc(z1(e,t),s))}function uM(e,t,n,s,l,c){let h;Zh(t,s,l,c).length>0?h=s-Wa(s,l):h=t;let p=s,g=dM(e,t,n,s,l,c);return bc(j1(e,h,n,p,g==="C",l).length,yc(g,c))}function hM(e,t,n){let s=0,l=e-Wa(e,n),c=t-Wa(t,n);for(let h=0;h<Math.abs(l-c);h++){let p=z1(e,t)==="A"?-1:1;n.buffer.lines.get(l+p*h)?.isWrapped&&s++}return s}function Wa(e,t){let n=0,s=t.buffer.lines.get(e),l=s?.isWrapped;for(;l&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),l=s?.isWrapped;return n}function dM(e,t,n,s,l,c){let h;return Zh(n,s,l,c).length>0?h=s-Wa(s,l):h=t,e<n&&h<=s||e>=n&&h<s?"C":"D"}function z1(e,t){return e>t?"A":"B"}function j1(e,t,n,s,l,c){let h=e,p=t,g="";for(;(h!==n||p!==s)&&p>=0&&p<c.buffer.lines.length;)h+=l?1:-1,l&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!l&&h<0&&(g+=c.buffer.translateBufferLineToString(p,!1,0,e+1),h=c.cols-1,e=h,p--);return g+c.buffer.translateBufferLineToString(p,!1,e,h)}function yc(e,t){let n=t?"O":"[";return de.ESC+n+e}function bc(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var fM=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 GS(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 Cp=50,pM=15,mM=50,gM=500,_M=" ",vM=new RegExp(_M,"g"),Um=class extends ot{constructor(e,t,n,s,l,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=l,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new er,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new fM(this._bufferService),this._activeSelectionMode=0,this._register(Xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.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,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let l=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let p=n.translateBufferLineToString(h,!0,l,c);s.push(p)}}else{let l=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=t[1]-1;c++){let h=n.lines.get(c),p=n.translateBufferLineToString(c,!0);h?.isWrapped?s[s.length-1]+=p:s.push(p)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),h=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=h:s.push(h)}}return s.map(l=>l.replace(vM," ")).join(L1?`\r
26
+ `:`
27
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),s_&&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,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_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=GS(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=r_(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,-Cp),Cp),t/=Cp,t/Math.abs(t)+Math.round(t*(pM-1)))}shouldForceSelection(e){return Rh?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(),mM)}_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&&!(Rh&&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 s=n.lines.get(this._model.selectionEnd[1]);s&&s.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<gM&&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 s=aM(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!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 s=0;t>=s;s++){let l=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:l>1&&t!==s&&(n+=l-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,s=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let h=l.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,b=0,y=0,S=0,w=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let L=e[0],A=e[0];c.getWidth(L)===0&&(b++,L--),c.getWidth(A)===2&&(y++,A++);let O=c.getString(A).length;for(O>1&&(w+=O-1,g+=O-1);L>0&&p>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,L--):Y>1&&(S+=Y-1,p-=Y-1),p--,L--}for(;A<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,A++):Y>1&&(w+=Y-1,g+=Y-1),g++,A++}}g++;let k=p+f-b+S,T=Math.min(this._bufferService.cols,g-p+b+y-S-w);if(!(!t&&h.slice(p,g).trim()==="")){if(n&&k===0&&c.getCodePoint(0)!==32){let L=l.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let O=this._bufferService.cols-A.start;k-=O,T+=O}}}if(s&&k+T===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=l.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(T+=A.length)}}return{start:k,length:T}}}_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=GS(n,this._bufferService.cols)}};Um=ai([Ae(3,un),Ae(4,qa),Ae(5,Zg),Ae(6,hn),Ae(7,ss),Ae(8,rs)],Um);var ZS=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={}}},QS=class{constructor(){this._color=new ZS,this._css=new ZS}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()}},Ti=Object.freeze((()=>{let e=[Jt.toColor("#2e3436"),Jt.toColor("#cc0000"),Jt.toColor("#4e9a06"),Jt.toColor("#c4a000"),Jt.toColor("#3465a4"),Jt.toColor("#75507b"),Jt.toColor("#06989a"),Jt.toColor("#d3d7cf"),Jt.toColor("#555753"),Jt.toColor("#ef2929"),Jt.toColor("#8ae234"),Jt.toColor("#fce94f"),Jt.toColor("#729fcf"),Jt.toColor("#ad7fa8"),Jt.toColor("#34e2e2"),Jt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],l=t[n/6%6|0],c=t[n%6];e.push({css:bi.toCss(s,l,c),rgba:bi.toRgba(s,l,c)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:bi.toCss(s,s,s),rgba:bi.toRgba(s,s,s)})}return e})()),Ma=Jt.toColor("#ffffff"),Qo=Jt.toColor("#000000"),JS=Jt.toColor("#ffffff"),e0=Qo,Ko={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},yM=Ma,Km=class extends ot{constructor(e){super(),this._optionsService=e,this._contrastCache=new QS,this._halfContrastCache=new QS,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ma,background:Qo,cursor:JS,cursorAccent:e0,selectionForeground:void 0,selectionBackgroundTransparent:Ko,selectionBackgroundOpaque:Ft.blend(Qo,Ko),selectionInactiveBackgroundTransparent:Ko,selectionInactiveBackgroundOpaque:Ft.blend(Qo,Ko),scrollbarSliderBackground:Ft.opacity(Ma,.2),scrollbarSliderHoverBackground:Ft.opacity(Ma,.4),scrollbarSliderActiveBackground:Ft.opacity(Ma,.5),overviewRulerBorder:Ma,ansi:Ti.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=Lt(e.foreground,Ma),t.background=Lt(e.background,Qo),t.cursor=Ft.blend(t.background,Lt(e.cursor,JS)),t.cursorAccent=Ft.blend(t.background,Lt(e.cursorAccent,e0)),t.selectionBackgroundTransparent=Lt(e.selectionBackground,Ko),t.selectionBackgroundOpaque=Ft.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Lt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ft.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Lt(e.selectionForeground,VS):void 0,t.selectionForeground===VS&&(t.selectionForeground=void 0),Ft.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ft.opacity(t.selectionBackgroundTransparent,.3)),Ft.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ft.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Lt(e.scrollbarSliderBackground,Ft.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Lt(e.scrollbarSliderHoverBackground,Ft.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Lt(e.scrollbarSliderActiveBackground,Ft.opacity(t.foreground,.5)),t.overviewRulerBorder=Lt(e.overviewRulerBorder,yM),t.ansi=Ti.slice(),t.ansi[0]=Lt(e.black,Ti[0]),t.ansi[1]=Lt(e.red,Ti[1]),t.ansi[2]=Lt(e.green,Ti[2]),t.ansi[3]=Lt(e.yellow,Ti[3]),t.ansi[4]=Lt(e.blue,Ti[4]),t.ansi[5]=Lt(e.magenta,Ti[5]),t.ansi[6]=Lt(e.cyan,Ti[6]),t.ansi[7]=Lt(e.white,Ti[7]),t.ansi[8]=Lt(e.brightBlack,Ti[8]),t.ansi[9]=Lt(e.brightRed,Ti[9]),t.ansi[10]=Lt(e.brightGreen,Ti[10]),t.ansi[11]=Lt(e.brightYellow,Ti[11]),t.ansi[12]=Lt(e.brightBlue,Ti[12]),t.ansi[13]=Lt(e.brightMagenta,Ti[13]),t.ansi[14]=Lt(e.brightCyan,Ti[14]),t.ansi[15]=Lt(e.brightWhite,Ti[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=Lt(e.extendedAnsi[s],Ti[s+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()}}};Km=ai([Ae(0,hn)],Km);function Lt(e,t){if(e!==void 0)try{return Jt.toColor(e)}catch{}return t}var bM=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)}},SM=class{constructor(){this._services=new bM,this._services.set(Gg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=pD(e).sort((c,h)=>c.index-h.index),s=[];for(let c of n){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(h)}let l=n.length>0?n[0].index:t.length;if(t.length!==l)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${l+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},wM={trace:0,debug:1,info:2,warn:3,error:4,off:5},CM="xterm.js: ",Wm=class extends ot{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=wM[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?"":CM)+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)}};Wm=ai([Ae(0,hn)],Wm);var t0=class extends ot{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),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 s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}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 l=t-1;l>=0;l--)this.set(e+l+n,this.get(e+l));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},lt=3,vi=Object.freeze(new Ac),Qu=0,xp=2,Jo=class P1{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*lt);let l=n||er.fromCharData([0,n1,1,0]);for(let c=0;c<t;++c)this.setCell(c,l);this.length=t}get(t){let n=this._data[t*lt+0],s=n&2097151;return[this._data[t*lt+1],n&2097152?this._combined[t]:s?Vs(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*lt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*lt+0]=t|2097152|n[2]<<22):this._data[t*lt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*lt+0]>>22}hasWidth(t){return this._data[t*lt+0]&12582912}getFg(t){return this._data[t*lt+1]}getBg(t){return this._data[t*lt+2]}hasContent(t){return this._data[t*lt+0]&4194303}getCodePoint(t){let n=this._data[t*lt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*lt+0]&2097152}getString(t){let n=this._data[t*lt+0];return n&2097152?this._combined[t]:n&2097151?Vs(n&2097151):""}isProtected(t){return this._data[t*lt+2]&536870912}loadCell(t,n){return Qu=t*lt,n.content=this._data[Qu+0],n.fg=this._data[Qu+1],n.bg=this._data[Qu+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*lt+0]=n.content,this._data[t*lt+1]=n.fg,this._data[t*lt+2]=n.bg}setCellFromCodepoint(t,n,s,l){l.bg&268435456&&(this._extendedAttrs[t]=l.extended),this._data[t*lt+0]=n|s<<22,this._data[t*lt+1]=l.fg,this._data[t*lt+2]=l.bg}addCodepointToCell(t,n,s){let l=this._data[t*lt+0];l&2097152?this._combined[t]+=Vs(n):l&2097151?(this._combined[t]=Vs(l&2097151)+Vs(n),l&=-2097152,l|=2097152):l=n|1<<22,s&&(l&=-12582913,l|=s<<22),this._data[t*lt+0]=l}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let l=new er;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,l));for(let c=0;c<n;++c)this.setCell(t+c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let l=new er;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,l));for(let c=this.length-n;c<this.length;++c)this.setCell(c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,l=!1){if(l){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*xp<this._data.buffer.byteLength;let s=t*lt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<t;++l)this.setCell(l,n)}else{this._data=this._data.subarray(0,s);let l=Object.keys(this._combined);for(let h=0;h<l.length;h++){let p=parseInt(l[h],10);p>=t&&delete this._combined[p]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let p=parseInt(c[h],10);p>=t&&delete this._extendedAttrs[p]}}return this.length=t,s*4*xp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*xp<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 s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 P1(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*lt+0]&4194303)return t+(this._data[t*lt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303||this._data[t*lt+2]&50331648)return t+(this._data[t*lt+0]>>22);return 0}copyCellsFrom(t,n,s,l,c){let h=t._data;if(c)for(let g=l-1;g>=0;g--){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(n+g)*lt+f];h[(n+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}else for(let g=0;g<l;g++){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(n+g)*lt+f];h[(n+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[n+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=n&&(this._combined[f-n+s]=t._combined[f])}}translateToString(t,n,s,l){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let c="";for(;n<s;){let h=this._data[n*lt+0],p=h&2097151,g=h&2097152?this._combined[n]:p?Vs(p):Ys;if(c+=g,l)for(let f=0;f<g.length;++f)l.push(n);n+=h>>22||1}return l&&l.push(n),c}};function xM(e,t,n,s,l,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let b=[e.get(p)];for(;g<e.length&&f.isWrapped;)b.push(f),f=e.get(++g);if(!c&&s>=p&&s<g){p+=b.length-1;continue}let y=0,S=Sc(b,y,t),w=1,k=0;for(;w<b.length;){let L=Sc(b,w,t),A=L-k,O=n-S,Y=Math.min(A,O);b[y].copyCellsFrom(b[w],k,S,Y,!1),S+=Y,S===n&&(y++,S=0),k+=Y,k===L&&(w++,k=0),S===0&&y!==0&&b[y-1].getWidth(n-1)===2&&(b[y].copyCellsFrom(b[y-1],n-1,S++,1,!1),b[y-1].setCell(n-1,l))}b[y].replaceCells(S,n,l);let T=0;for(let L=b.length-1;L>0&&(L>y||b[L].getTrimmedLength()===0);L--)T++;T>0&&(h.push(p+b.length-T),h.push(T)),p+=b.length-1}return h}function kM(e,t){let n=[],s=0,l=t[s],c=0;for(let h=0;h<e.length;h++)if(l===h){let p=t[++s];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,l=t[++s]}else n.push(h);return{layout:n,countRemoved:c}}function EM(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function TM(e,t,n){let s=[],l=e.map((g,f)=>Sc(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<l;){if(l-p<n){s.push(l-p);break}c+=n;let g=Sc(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let b=f?n-1:n;s.push(b),p+=b}return s}function Sc(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,l=e[t+1].getWidth(0)===2;return s&&l?n-1:n}var H1=class I1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=I1._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ka(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};H1._nextId=1;var DM=H1,Ai={},Na=Ai.B;Ai[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ai.A={"#":"£"};Ai.B=void 0;Ai[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ai.C=Ai[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ai.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ai.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ai.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ai.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ai.E=Ai[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ai.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ai.H=Ai[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ai["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var i0=4294967295,n0=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=vi.clone(),this.savedCharset=Na,this.markers=[],this._nullCell=er.fromCharData([0,n1,1,0]),this._whitespaceCell=er.fromCharData([0,Ys,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Mh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new t0(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 Eh),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 Eh),this._whitespaceCell}getBlankLine(e,t){return new Jo(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>i0?i0:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=vi);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 t0(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(vi),s=0,l=this._getCorrectBufferLength(t);if(l>this.lines.maxLength&&(this.lines.maxLength=l),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)s+=+this.lines.get(h).resize(e,n);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)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 Jo(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 Jo(e,n)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(l<this.lines.maxLength){let h=this.lines.length-l;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=l}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++)s+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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,s=xM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(vi),n);if(s.length>0){let l=kM(this.lines,s);EM(this.lines,l.layout),this._reflowLargerAdjustViewport(e,t,l.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(vi),l=n;for(;l-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Jo(e,s))):(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,s=this.getNullCell(vi),l=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let p=this.lines.get(h);if(!p||!p.isWrapped&&p.getTrimmedLength()<=e)continue;let g=[p];for(;p.isWrapped&&h>0;)p=this.lines.get(--h),g.unshift(p);if(!n){let Y=this.ybase+this.y;if(Y>=h&&Y<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),b=TM(g,this._cols,e),y=b.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+y):S=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let Y=0;Y<y;Y++){let P=this.getBlankLine(vi,!0);w.push(P)}w.length>0&&(l.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let k=b.length-1,T=b[k];T===0&&(k--,T=b[k]);let L=g.length-y-1,A=f;for(;L>=0;){let Y=Math.min(A,T);if(g[k]===void 0)break;if(g[k].copyCellsFrom(g[L],A-Y,T-Y,Y,!0),T-=Y,T===0&&(k--,T=b[k]),A-=Y,A===0){L--;let P=Math.max(L,0);A=Sc(g,P,this._cols)}}for(let Y=0;Y<g.length;Y++)b[Y]<e&&g[Y].setCell(b[Y],s);let O=y-S;for(;O-- >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+y,this.ybase+t-1)}if(l.length>0){let h=[],p=[];for(let T=0;T<this.lines.length;T++)p.push(this.lines.get(T));let g=this.lines.length,f=g-1,b=0,y=l[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(y&&y.start>f+S){for(let L=y.newLines.length-1;L>=0;L--)this.lines.set(T--,y.newLines[L]);T++,h.push({index:f+1,amount:y.newLines.length}),S+=y.newLines.length,y=l[++b]}else this.lines.set(T,p[f--]);let w=0;for(let T=h.length-1;T>=0;T--)h[T].index+=w,this.lines.onInsertEmitter.fire(h[T]),w+=h[T].amount;let k=Math.max(0,g+c-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,n=0,s){let l=this.lines.get(e);return l?l.translateToString(t,n,s):""}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 DM(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)}},RM=class extends ot{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),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 n0(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new n0(!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)}},U1=2,K1=1,Fm=class extends ot{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,U1),this.rows=Math.max(e.rawOptions.rows||0,K1),this.buffers=this._register(new RM(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,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let l=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let h=n.lines.isFull;c===n.lines.length-1?h?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(c+1,0,s.clone()),h?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let h=c-l+1;n.lines.shiftElements(l+1,h-1,-1),n.lines.set(c,s.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 s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Fm=ai([Ae(0,hn)],Fm);var Dl={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:Rh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},MM=["normal","bold","100","200","300","400","500","600","700","800","900"],NM=class extends ot{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...Dl};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Xt(()=>{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 Dl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Dl))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Dl[e]),!AM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Dl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=MM.includes(t)?t:Dl[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 AM(e){return e==="block"||e==="underline"||e==="bar"}function ec(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&ec(e[s],t-1);return n}var r0=Object.freeze({insertMode:!1}),s0=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),qm=class extends ot{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 ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ec(r0),this.decPrivateModes=ec(s0)}reset(){this.modes=ec(r0),this.decPrivateModes=ec(s0)}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(s=>s.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))}};qm=ai([Ae(0,un),Ae(1,o1),Ae(2,hn)],qm);var a0={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 kp(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 Ep=String.fromCharCode,l0={DEFAULT:e=>{let t=[kp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ep(t[0])}${Ep(t[1])}${Ep(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${kp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${kp(e,!0)};${e.x};${e.y}${t}`}},$m=class extends ot{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 ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(a0))this.addProtocol(s,a0[s]);for(let s of Object.keys(l0))this.addEncoding(s,l0[s]);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 s=t/n,l=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=s+0,Math.abs(e.deltaY)<50&&(l*=.3),this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_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)}};$m=ai([Ae(0,un),Ae(1,qa),Ae(2,hn)],$m);var Tp=[[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]],LM=[[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]],Di;function BM(e,t){let n=0,s=t.length-1,l;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(l=n+s>>1,e>t[l][1])n=l+1;else if(e<t[l][0])s=l-1;else return!0;return!1}var OM=class{constructor(){if(this.version="6",!Di){Di=new Uint8Array(65536),Di.fill(1),Di[0]=0,Di.fill(0,1,32),Di.fill(0,127,160),Di.fill(2,4352,4448),Di[9001]=2,Di[9002]=2,Di.fill(2,11904,42192),Di[12351]=1,Di.fill(2,44032,55204),Di.fill(2,63744,64256),Di.fill(2,65040,65050),Di.fill(2,65072,65136),Di.fill(2,65280,65377),Di.fill(2,65504,65511);for(let e=0;e<Tp.length;++e)Di.fill(0,Tp[e][0],Tp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Di[e]:BM(e,LM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let l=Ba.extractWidth(t);l===0?s=!1:l>n&&(n=l)}return Ba.createPropertyValue(0,n,s)}},Ba=class hh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new OM;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,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?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,s=0,l=t.length;for(let c=0;c<l;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=l)return n+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let p=this.charProperties(h,s),g=hh.extractWidth(p);hh.extractShouldJoin(p)&&(g-=hh.extractWidth(s)),n+=g,s=p}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},zM=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 o0(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 Wo=2147483647,jM=256,W1=class Vm{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>jM)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 Vm;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let l=t[s];if(Array.isArray(l))for(let c=0;c<l.length;++c)n.addSubParam(l[c]);else n.addParam(l)}return n}clone(){let t=new Vm(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 s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,l))}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>Wo?Wo: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>Wo?Wo: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,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,l=this._subParamsIdx[n]&255;l-s>0&&(t[n]=this._subParams.slice(s,l))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,l=s[n-1];s[n-1]=~l?Math.min(l*10+t,Wo):t}},Fo=[],PM=class{constructor(){this._state=0,this._active=Fo,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 s=n.indexOf(t);s!==-1&&n.splice(s,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=Fo}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=Fo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fo,!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",Yh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].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 s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-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,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Fo,this._id=-1,this._state=0}}},An=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+=Yh(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}},qo=[],HM=class{constructor(){this._handlers=Object.create(null),this._active=qo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,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=qo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||qo,!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",Yh(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=qo,this._ident=0}},tc=new W1;tc.addParam(0);var c0=class{constructor(e){this._handler=e,this._data="",this._params=tc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():tc,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Yh(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=tc,this._data="",this._hitLimit=!1,n));return this._params=tc,this._data="",this._hitLimit=!1,t}},IM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let l=0;l<e.length;l++)this.table[t<<8|e[l]]=n<<4|s}},Qn=160,UM=(function(){let e=new IM(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),n=(p,g)=>t.slice(p,g),s=n(32,127),l=n(0,24);l.push(25),l.push.apply(l,n(28,32));let c=n(0,14),h;e.setDefault(1,0),e.addMany(s,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(n(128,144),h,3,0),e.addMany(n(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(l,0,3,0),e.addMany(l,1,3,1),e.add(127,1,0,1),e.addMany(l,8,0,8),e.addMany(l,3,3,3),e.add(127,3,0,3),e.addMany(l,4,3,4),e.add(127,4,0,4),e.addMany(l,6,3,6),e.addMany(l,5,3,5),e.add(127,5,0,5),e.addMany(l,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,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(s,7,0,7),e.addMany(l,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(l,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(l,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(l,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(l,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(l,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Qn,0,2,0),e.add(Qn,8,5,8),e.add(Qn,6,0,6),e.add(Qn,11,0,11),e.add(Qn,13,13,13),e})(),KM=class extends ot{constructor(e=UM){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 W1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},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(Xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new PM),this._dcsParser=this._register(new HM),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 l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);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 s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,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 s=this._escHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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 s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,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,s,l){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=l}parse(e,t,n){let s=0,l=0,c=0,h;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 p=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(h=p[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(h=p[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(s!==24&&s!==26,n),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],h=this._oscParser.end(s!==24&&s!==26,n),h)return h;s===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 p=c;p<t;++p){switch(s=e[p],l=this._transitions.table[this.currentState<<8|(s<160?s:Qn)],l>>4){case 2:for(let S=p+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Qn){this._printHandler(e,p,S),p=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(h=g[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._preserveStack(3,g,f,l,p),h;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++p<t&&(s=e[p])>47&&s<60);p--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let b=this._escHandlers[this._collect<<8|s],y=b?b.length-1:-1;for(;y>=0&&(h=b[y](),h!==!0);y--)if(h instanceof Promise)return this._preserveStack(4,b,y,l,p),h;y<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let S=p+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Qn){this._dcsParser.put(e,p,S),p=S-1;break}break;case 14:if(h=this._dcsParser.unhook(s!==24&&s!==26),h)return this._preserveStack(6,[],0,l,p),h;s===27&&(l|=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=p+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Qn){this._oscParser.put(e,p,S),p=S-1;break}break;case 6:if(h=this._oscParser.end(s!==24&&s!==26),h)return this._preserveStack(5,[],0,l,p),h;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},WM=/^([\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})$/,FM=/^[\da-f]+$/;function u0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=WM.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),FM.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let l=0;l<3;++l){let c=parseInt(t.slice(n*l,n*l+n),16);s[l]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return s}}function Dp(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function qM(e,t=16){let[n,s,l]=e;return`rgb:${Dp(n,t)}/${Dp(s,t)}/${Dp(l,t)}`}var $M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ks=131072,h0=10;function d0(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 f0=5e3,p0=0,VM=class extends ot{constructor(e,t,n,s,l,c,h,p,g=new KM){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=l,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new dD,this._utf8Decoder=new fD,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=vi.clone(),this._eraseAttrDataInternal=vi.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),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 Ym(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:b.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:b,data:y})}),this._parser.setDcsHandlerFallback((f,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:b,payload:y})}),this._parser.setPrintHandler((f,b,y)=>this.print(f,b,y)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(de.BEL,()=>this.bell()),this._parser.setExecuteHandler(de.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(de.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(de.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(de.BS,()=>this.backspace()),this._parser.setExecuteHandler(de.HT,()=>this.tab()),this._parser.setExecuteHandler(de.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(de.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ch.IND,()=>this.index()),this._parser.setExecuteHandler(ch.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ch.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new An(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new An(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new An(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new An(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new An(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new An(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new An(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new An(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new An(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new An(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new An(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new An(f=>this.restoreCursorColor(f))),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 f in Ai)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new c0((f,b)=>this.requestStatusString(f,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),f0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${f0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,l=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,l=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ks&&(c=this._parseStack.position+Ks)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ks&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ks))),h||this._dirtyRowTracker.clearRange(),e.length>Ks)for(let f=c;f<e.length;f+=Ks){let b=f+Ks<e.length?f+Ks:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(f,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,b),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,y))return this._preserveStack(s,l,y,f),this._logSlowResolvingAsync(n),n}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,l,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==l)&&this._onCursorMove.fire();let p=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(p,this._bufferService.rows-1)})}print(e,t,n){let s,l,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,b=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let S=this._parser.precedingJoinState;for(let w=t;w<n;++w){if(s=e[w],s<127&&c){let A=c[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let k=this._unicodeService.charProperties(s,S);l=Ba.extractWidth(k);let T=Ba.extractShouldJoin(k),L=T?Ba.extractWidth(S):0;if(S=k,h&&this._onA11yChar.fire(Vs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+l-L>p){if(g){let A=y,O=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&y instanceof Jo&&y.copyCellsFrom(A,O,0,L,!1);O<p;)A.setCellFromCodepoint(O++,0,1,b)}else if(this._activeBuffer.x=p-1,l===2)continue}if(T&&this._activeBuffer.x){let A=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-A,s,l);for(let O=l-L;--O>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(f&&(y.insertCells(this._activeBuffer.x,l-L,this._activeBuffer.getNullCell(b)),y.getWidth(p-1)===2&&y.setCellFromCodepoint(p-1,0,1,b)),y.setCellFromCodepoint(this._activeBuffer.x++,s,l,b),l>0)for(;--l;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=S,this._activeBuffer.x<p&&n-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>d0(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new c0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new An(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,s=!1,l=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),l),s&&(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 s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,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,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,l=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(l-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,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,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(vi));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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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,s=Ba.extractWidth(t),l=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(l),h=new Uint32Array(c.length*n),p=0;for(let f=0;f<c.length;){let b=c.codePointAt(f)||0;h[p++]=b,f+=b>65535?2:1}let g=p;for(let f=1;f<n;++f)h.copyWithin(g,0,p),g+=p;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(de.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(de.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(de.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(de.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(de.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,Na),this._charsetService.setgCharset(1,Na),this._charsetService.setgCharset(2,Na),this._charsetService.setgCharset(3,Na);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;(T=>(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let s=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:b}=p,y=this._optionsService.rawOptions,S=(T,L)=>(h.triggerDataEvent(`${de.ESC}[${t?"":"?"}${T};${L}$y`),!0),w=T=>T?1:2,k=e.params[0];return t?k===2?S(k,4):k===4?S(k,w(h.modes.insertMode)):k===12?S(k,3):k===20?S(k,w(y.convertEol)):S(k,0):k===1?S(k,w(s.applicationCursorKeys)):k===3?S(k,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):k===6?S(k,w(s.origin)):k===7?S(k,w(s.wraparound)):k===8?S(k,3):k===9?S(k,w(l==="X10")):k===12?S(k,w(y.cursorBlink)):k===25?S(k,w(!h.isCursorHidden)):k===45?S(k,w(s.reverseWraparound)):k===66?S(k,w(s.applicationKeypad)):k===67?S(k,4):k===1e3?S(k,w(l==="VT200")):k===1002?S(k,w(l==="DRAG")):k===1003?S(k,w(l==="ANY")):k===1004?S(k,w(s.sendFocus)):k===1005?S(k,4):k===1006?S(k,w(c==="SGR")):k===1015?S(k,4):k===1016?S(k,w(c==="SGR_PIXELS")):k===1048?S(k,1):k===47||k===1047||k===1049?S(k,w(f===b)):k===2004?S(k,w(s.bracketedPasteMode)):k===2026?S(k,w(s.synchronizedOutput)):S(k,0)}_updateAttrColor(e,t,n,s,l){return t===2?(e|=50331648,e&=-16777216,e|=Ac.fromColorRGB([n,s,l])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],l=0,c=0;do{if(s[c+l]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do s[1]===5&&(l=1),s[c+p+1+l]=h[p];while(++p<h.length&&p+c+1+l<s.length);break}if(s[1]===5&&c+l>=2||s[1]===2&&c+l>=5)break;s[1]&&(l=1)}while(++c+t<e.length&&c+l<s.length);for(let h=2;h<s.length;++h)s[h]===-1&&(s[h]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[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=vi.fg,e.bg=vi.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,s=this._curAttrData;for(let l=0;l<t;l++)n=e.params[l],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(l)?e.getSubParams(l)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=vi.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=vi.bg&16777215):n===38||n===48||n===58?l+=this._extractColor(e,l,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=vi.fg&16777215,s.bg&=-67108864,s.bg|=vi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${de.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${de.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(`${de.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=vi.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(!d0(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(`${de.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>h0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>h0&&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 s=n.shift(),l=n.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(m0(c))if(l==="?")t.push({type:0,index:c});else{let h=u0(l);h&&t.push({type:1,index:c,color:h})}}}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(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,l=n.findIndex(c=>c.startsWith("id="));return l!==-1&&(s=n[l].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let l=u0(n[s]);l&&this._onColor.fire([{type:1,index:this._specialColors[t],color:l}])}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 s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let l=parseInt(n[s]);m0(l)&&t.push({type:2,index:l})}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,Na),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset($M[e[0]],Ai[e[1]]||Na),!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=vi.clone(),this._eraseAttrDataInternal=vi.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 er;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,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=h=>(this._coreService.triggerDataEvent(`${de.ESC}${h}${de.ESC}\\`),!0),s=this._bufferService.buffer,l=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${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[l.cursorStyle]-(l.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ym=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&&(p0=e,e=t,t=p0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ym=ai([Ae(0,un)],Ym);function m0(e){return 0<=e&&e<256}var YM=5e7,g0=12,XM=50,GM=class extends ot{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 ke),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 s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>YM)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 s=this._writeBuffer[this._bufferOffset],l=this._action(s,t);if(l){let h=p=>performance.now()-n>=g0?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(n,p);l.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=g0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>XM&&(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()}},Xm=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 p=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(g,p)),this._dataByLinkId.set(g.id,g),g.id}let n=e,s=this._getEntryIdKey(n),l=this._entriesWithId.get(s);if(l)return this.addLineToLink(l.id,t.ybase+t.y),l.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}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)))}};Xm=ai([Ae(0,un)],Xm);var _0=!1,ZM=class extends ot{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Kl),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new SM,this.optionsService=this._register(new NM(e)),this._instantiationService.setService(hn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Fm)),this._instantiationService.setService(un,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Wm)),this._instantiationService.setService(o1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(qm)),this._instantiationService.setService(qa,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance($m)),this._instantiationService.setService(l1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ba)),this._instantiationService.setService(_D,this.unicodeService),this._charsetService=this._instantiationService.createInstance(zM),this._instantiationService.setService(gD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Xm),this._instantiationService.setService(c1,this._oscLinkService),this._inputHandler=this._register(new VM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Gi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Gi.forward(this._bufferService.onResize,this._onResize)),this._register(Gi.forward(this.coreService.onData,this._onData)),this._register(Gi.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 GM((t,n)=>this._inputHandler.parse(t,n))),this._register(Gi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),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&&!_0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),_0=!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,U1),t=Math.max(t,K1),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(o0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(o0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Xt(()=>{for(let t of e)t.dispose()})}}},QM={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 JM(e,t,n,s){let l={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?l.key=de.ESC+"OA":l.key=de.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?l.key=de.ESC+"OD":l.key=de.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?l.key=de.ESC+"OC":l.key=de.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?l.key=de.ESC+"OB":l.key=de.ESC+"[B");break;case 8:l.key=e.ctrlKey?"\b":de.DEL,e.altKey&&(l.key=de.ESC+l.key);break;case 9:if(e.shiftKey){l.key=de.ESC+"[Z";break}l.key=de.HT,l.cancel=!0;break;case 13:l.key=e.altKey?de.ESC+de.CR:de.CR,l.cancel=!0;break;case 27:l.key=de.ESC,e.altKey&&(l.key=de.ESC+de.ESC),l.cancel=!0;break;case 37:if(e.metaKey)break;c?l.key=de.ESC+"[1;"+(c+1)+"D":t?l.key=de.ESC+"OD":l.key=de.ESC+"[D";break;case 39:if(e.metaKey)break;c?l.key=de.ESC+"[1;"+(c+1)+"C":t?l.key=de.ESC+"OC":l.key=de.ESC+"[C";break;case 38:if(e.metaKey)break;c?l.key=de.ESC+"[1;"+(c+1)+"A":t?l.key=de.ESC+"OA":l.key=de.ESC+"[A";break;case 40:if(e.metaKey)break;c?l.key=de.ESC+"[1;"+(c+1)+"B":t?l.key=de.ESC+"OB":l.key=de.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(l.key=de.ESC+"[2~");break;case 46:c?l.key=de.ESC+"[3;"+(c+1)+"~":l.key=de.ESC+"[3~";break;case 36:c?l.key=de.ESC+"[1;"+(c+1)+"H":t?l.key=de.ESC+"OH":l.key=de.ESC+"[H";break;case 35:c?l.key=de.ESC+"[1;"+(c+1)+"F":t?l.key=de.ESC+"OF":l.key=de.ESC+"[F";break;case 33:e.shiftKey?l.type=2:e.ctrlKey?l.key=de.ESC+"[5;"+(c+1)+"~":l.key=de.ESC+"[5~";break;case 34:e.shiftKey?l.type=3:e.ctrlKey?l.key=de.ESC+"[6;"+(c+1)+"~":l.key=de.ESC+"[6~";break;case 112:c?l.key=de.ESC+"[1;"+(c+1)+"P":l.key=de.ESC+"OP";break;case 113:c?l.key=de.ESC+"[1;"+(c+1)+"Q":l.key=de.ESC+"OQ";break;case 114:c?l.key=de.ESC+"[1;"+(c+1)+"R":l.key=de.ESC+"OR";break;case 115:c?l.key=de.ESC+"[1;"+(c+1)+"S":l.key=de.ESC+"OS";break;case 116:c?l.key=de.ESC+"[15;"+(c+1)+"~":l.key=de.ESC+"[15~";break;case 117:c?l.key=de.ESC+"[17;"+(c+1)+"~":l.key=de.ESC+"[17~";break;case 118:c?l.key=de.ESC+"[18;"+(c+1)+"~":l.key=de.ESC+"[18~";break;case 119:c?l.key=de.ESC+"[19;"+(c+1)+"~":l.key=de.ESC+"[19~";break;case 120:c?l.key=de.ESC+"[20;"+(c+1)+"~":l.key=de.ESC+"[20~";break;case 121:c?l.key=de.ESC+"[21;"+(c+1)+"~":l.key=de.ESC+"[21~";break;case 122:c?l.key=de.ESC+"[23;"+(c+1)+"~":l.key=de.ESC+"[23~";break;case 123:c?l.key=de.ESC+"[24;"+(c+1)+"~":l.key=de.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?l.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?l.key=de.NUL:e.keyCode>=51&&e.keyCode<=55?l.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?l.key=de.DEL:e.keyCode===219?l.key=de.ESC:e.keyCode===220?l.key=de.FS:e.keyCode===221&&(l.key=de.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=QM[e.keyCode]?.[e.shiftKey?1:0];if(h)l.key=de.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(p);e.shiftKey&&(g=g.toUpperCase()),l.key=de.ESC+g}else if(e.keyCode===32)l.key=de.ESC+(e.ctrlKey?de.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),l.key=de.ESC+p,l.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(l.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?l.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(l.key=de.US),e.key==="@"&&(l.key=de.NUL));break}return l}var hi=0,eN=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Mh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Mh,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((l,c)=>this._getKey(l)-this._getKey(c)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<s.length;l++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[l]=e[t],t++):s[l]=this._array[n++];this._array=s,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||(hi=this._search(t),hi===-1)||this._getKey(this._array[hi])!==t)return!1;do if(this._array[hi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(hi),!0;while(++hi<this._array.length&&this._getKey(this._array[hi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),t=0,n=new Array(this._array.length-e.length),s=0;for(let l=0;l<this._array.length;l++)e[t]===l?t++:n[s++]=this._array[l];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&&(hi=this._search(e),!(hi<0||hi>=this._array.length)&&this._getKey(this._array[hi])===e))do yield this._array[hi];while(++hi<this._array.length&&this._getKey(this._array[hi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(hi=this._search(e),!(hi<0||hi>=this._array.length)&&this._getKey(this._array[hi])===e))do t(this._array[hi]);while(++hi<this._array.length&&this._getKey(this._array[hi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,l=this._getKey(this._array[s]);if(l>e)n=s-1;else if(l<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Rp=0,v0=0,tN=class extends ot{constructor(){super(),this._decorations=new eN(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new iN(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.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 s=0,l=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,l=s+(c.options.width??1),e>=s&&e<l&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,l=>{Rp=l.options.x??0,v0=Rp+(l.options.width??1),e>=Rp&&e<v0&&(!n||(l.options.layer??"bottom")===n)&&s(l)})}},iN=class extends Gs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),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=Jt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Jt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},nN=1e3,rN=class{constructor(e,t=nN){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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let l=s-this._lastRefreshMs,c=this._debounceThresholdMS-l;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)}},y0=20,Nh=class extends ot{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let l=this._coreBrowserService.mainDocument;this._accessibilityContainer=l.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=l.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=l.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new rN(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
28
+ `))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Xe(l,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Xt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<y0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
29
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===y0+1&&(this._liveRegion.textContent+=mm.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,s=n.lines.length.toString();for(let l=e;l<=t;l++){let c=n.lines.get(n.ydisp+l),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(n.ydisp+l+1).toString(),f=this._rowElements[l];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,h)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],l=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(l===c||e.relatedTarget!==s)return;let h,p;if(t===0?(h=n,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=n,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),p.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 s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let l=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let S=g<y.length?y[g]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=l(t),h=l(n);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.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 s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Nh=ai([Ae(1,Gg),Ae(2,rs),Ae(3,ss)],Nh);var Gm=class extends ot{constructor(e,t,n,s,l){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=l,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Xt(()=>{Ka(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(Xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Xe(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 s=0;s<n.length;s++){let l=n[s];if(l.classList.contains("xterm"))break;if(l.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(s=>{s?.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[s,l]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(n=this._checkLinkProviderResult(s,e,n)):l.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(s,h),n=this._checkLinkProviderResult(s,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let l=t.get(s);if(l)for(let c=0;c<l.length;c++){let h=l[c],p=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let f=p;f<=g;f++){if(n.has(f)){l.splice(c--,1);break}n.add(f)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),l=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(l=!0);if(!l&&s){let c=s.find(h=>this._linkAtPosition(h.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 h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){n=!0,this._handleNewLink(h);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&&sN(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,Ka(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 s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,l=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=l&&(this._clearCurrentLink(s,l),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,s=this._bufferService.buffer.ydisp,l=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(l)}_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,s=e.range.end.y*this._bufferService.cols+e.range.end.x,l=t.y*this._bufferService.cols+t.x;return n<=l&&l<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,l){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:l}}};Gm=ai([Ae(1,Zg),Ae(2,ss),Ae(3,un),Ae(4,h1)],Gm);function sN(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 aN=class extends ZM{constructor(e={}){super(e),this._linkifier=this._register(new Kl),this.browser=M1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Kl),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(tN),this._instantiationService.setService(Lc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(XR),this._instantiationService.setService(h1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(_m)),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(Gi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Gi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Gi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Gi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Xt(()=>{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,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let l=Ft.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${de.ESC}]${s};${qM(l)}${D1.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=bi.toColor(...t.color));else{let c=n;this._themeService.modifyColors(h=>h[c]=bi.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(Nh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(de.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(de.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),s=this._renderService.dimensions.css.cell.height,l=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*l,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Xe(this.element,"copy",t=>{this.hasSelection()&&uD(t,this._selectionService)}));let e=t=>hD(t,this.textarea,this.coreService,this.optionsService);this._register(Xe(this.textarea,"paste",e)),this._register(Xe(this.element,"paste",e)),N1?this._register(Xe(this.element,"mousedown",t=>{t.button===2&&RS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Xe(this.element,"contextmenu",t=>{RS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s_&&this._register(Xe(this.element,"auxclick",t=>{t.button===1&&i1(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Xe(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(Xe(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),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",pm.get()),B1||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(VR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(rs,this._coreBrowserService),this._register(Xe(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Pm,this._document,this._helperContainer),this._instantiationService.setService(Xh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Km),this._instantiationService.setService(Yl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Dh),this._instantiationService.setService(u1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Im,this.rows,this.screenElement)),this._instantiationService.setService(ss,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Om,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hm),this._instantiationService.setService(Zg,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Gm,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(Lm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Um,this.element,this.screenElement,s)),this._instantiationService.setService(yD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Gi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Bm,this.screenElement)),this._register(Xe(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),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(Nh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Th,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Th,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(jm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let p,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,p=c.button<3?c.button:3;break;case"mousedown":g=1,p=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,p=4;break;default:return!1}return g===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:p,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.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?s.mousemove||(t.addEventListener("mousemove",l.mousemove),s.mousemove=l.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",l.wheel,{passive:!1}),s.wheel=l.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Xe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Xe(t,"wheel",c=>{if(!s.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 h=de.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!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){t1(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=JM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),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===de.ETX||n.key===de.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)&&(lN(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(vi));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(de.ESC+"[I"):this.coreService.triggerDataEvent(de.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(`${de.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${de.ESC}[6;${l};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function lN(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var oN=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)}},cN=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 er)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},b0=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 cN(t)}getNullCell(){return new er}},uN=class extends ot{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new b0(this._core.buffers.normal,"normal"),this._alternate=new b0(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)}},hN=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,s)=>t(n,s.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)}},dN=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}},fN=["cols","rows"],Er=0,pN=class extends ot{constructor(e){super(),this._core=this._register(new aN(e)),this._addonManager=this._register(new oN),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,l)=>{this._checkReadonlyOptions(s),this._core.options[s]=l};for(let s in this._core.options){let l={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,l)}}_checkReadonlyOptions(e){if(fN.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 hN(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new dN(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 uN(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
30
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return pm.get()},set promptLabel(e){pm.set(e)},get tooMuchOutput(){return mm.get()},set tooMuchOutput(e){mm.set(e)}}}_verifyIntegers(...e){for(Er of e)if(Er===1/0||isNaN(Er)||Er%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Er of e)if(Er&&(Er===1/0||isNaN(Er)||Er%1!==0||Er<0))throw new Error("This API only accepts positive integers")}};class mN{pending=null;accept(t){let n="";for(const s of t)n+=this.acceptChar(s);return n}acceptChar(t){return t===""?this.acceptBackspace():V1.has(t)?this.acceptConsonant(t):Y1.has(t)?this.acceptVowel(t):yN(t)&&this.canReplacePendingWith(t)?(this.pending=w0(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const l=this.flushPending();return this.pending={initial:t},l}if(!this.pending.final){if(X1.has(t))return this.pending.final=t,"";const l=this.flushPending();return this.pending={initial:t},l}const n=vN.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=_N.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=S0.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 s=this.pending.final,l=C0({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},l}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=S0.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=w0(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=C0(this.pending);return this.pending=null,t}}const Ah=44032,Lh=21,Bl=28,gN=19*Lh*Bl,F1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],q1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],$1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],V1=a_(F1),Y1=a_(q1),X1=a_($1),_N=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),G1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],vN=new Map(G1),S0=new Map(G1.map(([e,t])=>[t,[e[0],e[1]]]));function a_(e){return new Map(e.map((t,n)=>[t,n]))}function yN(e){const t=e.codePointAt(0);return t!==void 0&&t>=Ah&&t<Ah+gN}function w0(e){const t=e.codePointAt(0)-Ah,n=Math.floor(t/(Lh*Bl)),s=Math.floor(t%(Lh*Bl)/Bl),l=t%Bl,c={initial:F1[n],vowel:q1[s]};return l===0?c:{...c,final:$1[l]}}function C0(e){if(!e.vowel)return e.initial;const t=V1.get(e.initial),n=Y1.get(e.vowel),s=e.final?X1.get(e.final):0;return t===void 0||n===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Ah+(t*Lh+n)*Bl+s)}const bN=[{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 SN({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:s,onHide:l}){function c(h){h.preventDefault(),h.stopPropagation(),s()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.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"}),bN.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>n(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:l,children:"×"})]})}const wN={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function CN(e){return wN[e]}function xN(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const Z1="--nterminal-viewport-height",Q1="--nterminal-keyboard-inset-bottom",J1="data-nterminal-keyboard-visible",Qh="data-nterminal-compose-open",Bh="nterminal:viewport-refresh",kN=120;function EN(e=window){const t=e.document.documentElement,n=e.visualViewport,s=AN(e);function l(){l_(e)}return l(),n?.addEventListener("resize",l),n?.addEventListener("scroll",l),s?.addEventListener("geometrychange",l),e.addEventListener("resize",l),e.addEventListener(Bh,l),e.addEventListener("orientationchange",l),e.addEventListener("pageshow",l),e.document.addEventListener("visibilitychange",l),()=>{n?.removeEventListener("resize",l),n?.removeEventListener("scroll",l),s?.removeEventListener("geometrychange",l),e.removeEventListener("resize",l),e.removeEventListener(Bh,l),e.removeEventListener("orientationchange",l),e.removeEventListener("pageshow",l),e.document.removeEventListener("visibilitychange",l),t.style.removeProperty(Z1),t.style.removeProperty(Q1),t.removeAttribute(J1)}}function l_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:s}=Zm(e),l=TN(e,s);return l!==null&&x0(t,Z1,`${l}px`),x0(t,Q1,`${n}px`),DN(t,J1,String(s)),{viewportHeight:l,keyboardInsetBottom:n,keyboardVisible:s}}function Zm(e=window){const t=RN(e);return{keyboardInsetBottom:t,keyboardVisible:t>kN}}function TN(e,t){if((e.document.documentElement.hasAttribute(Qh)||t)&&Pa(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Pa(n)?n:Pa(e.innerHeight)?e.innerHeight:null}function Pa(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function x0(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function DN(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function RN(e){return Math.max(MN(e),NN(e))}function MN(e){const t=e.visualViewport?.height;if(!Pa(t)||!Pa(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 NN(e){if(!Pa(e.innerHeight))return 0;const n=eC(e)?.boundingRect?.height;return!Pa(n)||n>=e.innerHeight*.8?0:Math.round(n)}function eC(e){return e.navigator.virtualKeyboard}function AN(e){const t=eC(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const zc=new Map,wc=new Map,LN=Object.freeze({open:!1,text:""});function BN(e){let t=wc.get(e);return t||(t=new Set,wc.set(e,t)),t}function tC(e){const t=wc.get(e);if(t)for(const n of Array.from(t))n()}function o_(e){return zc.get(e)??LN}function ON(e,t){const n=BN(e);return n.add(t),()=>{n.delete(t)}}function zN(e,t){const n=o_(e);n.open!==t&&(zc.set(e,{...n,open:t}),tC(e))}function jN(e,t){const n=o_(e);n.text!==t&&(zc.set(e,{...n,text:t}),tC(e))}function Ju(e){zc.delete(e),wc.delete(e)}function k0(){zc.clear(),wc.clear()}const iC=120,PN="\x1B[200~",HN="\x1B[201~";function E0(e,t){const n=t.stripTrailingLineBreaks===!1?e:c_(e),s=UN(n);return s?t.bracketedPasteMode?`${PN}${s}${HN}`:s:""}function IN(e){return e==="queue"?" ":"\r"}function c_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function UN(e){return e.replace(/\r\n/g,`
31
+ `).replace(/\r/g,`
32
+ `).replace(/\n/g,"\r")}const KN=420,WN=3e3,T0=650,FN=80,qN=3,dh=new Set;let Pl=null;function $N({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:s=!1}){const l=v.useMemo(()=>O=>ON(e,O),[e]),c=v.useMemo(()=>()=>o_(e),[e]),h=v.useSyncExternalStore(l,c,c),{open:p,text:g}=h,f=v.useRef(null),b=v.useRef(null),y=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!p||!fh()))return YN(e),()=>XN(e)},[p,e]),v.useLayoutEffect(()=>{const O=f.current?.closest(".terminal-pane");if(!O)return;function Y(){O?.removeAttribute("data-compose-open"),O?.style.removeProperty("--compose-drawer-panel-height")}if(!p){Y();return}const P=b.current;O.setAttribute("data-compose-open","true");function q(){const ye=P?.getBoundingClientRect().height??0;ye>0&&O?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ye)}px`)}q();const re=[window.setTimeout(q,0),window.setTimeout(q,180),window.setTimeout(q,260)],ne=window.requestAnimationFrame?.(q)??null,ue=typeof ResizeObserver=="function"&&P?new ResizeObserver(q):null;return ue&&P&&ue.observe(P),()=>{for(const ye of re)window.clearTimeout(ye);ne!==null&&window.cancelAnimationFrame?.(ne),ue?.disconnect(),Y()}},[p]),v.useEffect(()=>{if(!p){S.current?.(),S.current=null;return}D0(y.current),A()},[p]);function w(O){zN(e,O)}function k(O){jN(e,O)}function T(){VN(f.current),w(!1),R0()}function L(O="send"){if(!(s||!g)){if(t(g,O),k(""),fh()){y.current?.blur(),R0();return}window.setTimeout(()=>y.current?.focus(),iC+20)}}function A(){fh()&&(S.current?.(),S.current=GN())}return m.jsxs("div",{ref:f,className:"compose-drawer","data-open":p?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":p?"true":void 0,tabIndex:p?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:b,className:"compose-drawer-panel","aria-hidden":p?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:p?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:T,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.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"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:y,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:p?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:O=>k(O.target.value),onFocus:A,onKeyDown:O=>{if(O.key==="Enter"&&(O.metaKey||O.ctrlKey)){if(O.preventDefault(),O.shiftKey){n&&L("queue");return}L("send");return}O.key==="Escape"&&(O.preventDefault(),T())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:p?0:-1,onClick:()=>{k(""),D0(y.current),A()},disabled:!g,children:"Clear"}),n?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:p?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>L("queue"),disabled:s||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:p?0:-1,onClick:()=>L("send"),disabled:s||!g,children:"Send"})]})]})]})}function VN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function D0(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function fh(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function R0(){if(!fh())return;const e=Ol;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function YN(e){Pl!==null&&(window.clearTimeout(Pl),Pl=null),dh.add(e),document.documentElement.setAttribute(Qh,"true"),Ol()}function XN(e){if(dh.delete(e),dh.size>0||Pl!==null){Ol();return}Pl=window.setTimeout(()=>{if(Pl=null,dh.size>0){Ol();return}document.documentElement.removeAttribute(Qh),Ol()},KN),Ol()}function GN(){let e=!1,t=null,n=null,s=null,l=0;const c=Date.now(),h=window.visualViewport,p=ZN();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function f(){e||(e=!0,g(),h?.removeEventListener("resize",y),h?.removeEventListener("scroll",y),p?.removeEventListener("geometrychange",y))}function b(S){if(!e){if(S<T0&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(y);return}t=window.setTimeout(y,FN)}}function y(){if(e)return;g();const S=l_(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?l+=1:(l=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=WN||w>=T0&&l>=qN){f();return}b(w)}return h?.addEventListener("resize",y),h?.addEventListener("scroll",y),p?.addEventListener("geometrychange",y),y(),f}function Ol(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,l_()}function ZN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function QN(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(h=>{if(tA(h))return h.preventDefault(),h.stopPropagation(),JN(e),!1;if(eA(h)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return h.preventDefault(),h.stopPropagation(),n.onInterrupt(),!1;if(iA(h)){const p=Qm(e);return p?(h.preventDefault(),h.stopPropagation(),Jm(p),!1):!0}return nA(h)?(h.preventDefault(),h.stopPropagation(),rA(e,n.onPasteText),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const l=h=>{const p=Qm(e);if(p){if(h.clipboardData){h.clipboardData.setData("text/plain",p),h.preventDefault();return}h.preventDefault(),Jm(p)}},c=h=>{const p=h.clipboardData?.getData("text/plain");if(!p)return;const g=c_(p);h.preventDefault(),h.stopImmediatePropagation(),nC(e,g,n.onPasteText)};return s.addEventListener("copy",l,!0),s.addEventListener("paste",c,!0),{dispose(){s.removeEventListener("copy",l,!0),s.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function JN(e){const t=Qm(e);t&&await Jm(t)}function eA(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function tA(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 iA(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function nA(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 rA(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;nC(e,c_(n),t)}catch{}}function nC(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function Qm(e){return e.hasSelection()?e.getSelection():sA(e.element??null)}function sA(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 s=0;s<t.rangeCount;s+=1){const l=t.getRangeAt(s);if(e.contains(l.commonAncestorContainer))return n}return""}async function Jm(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}aA(e)}function aA(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 lA=[4,10,11,12];function oA(e,t){const n=[e.parser.registerCsiHandler({final:"c"},s=>M0(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>M0(s)),e.parser.registerCsiHandler({final:"n"},s=>cA(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>uA(s)),e.parser.registerCsiHandler({final:"t"},s=>hA(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...lA.map(s=>e.parser.registerOscHandler(s,l=>dA(l)))];return{dispose(){for(const s of n)s.dispose()}}}function M0(e){return Jh(e)===0}function cA(e){const t=Jh(e);return t===5||t===6}function uA(e){return Jh(e)===6}function hA(e){const t=Jh(e);return t===14||t===16||t===18}function dA(e){return e.split(";").some(t=>t==="?")}function Jh(e){const t=e[0];return typeof t=="number"?t:0}const Fa=new Map,fA=2*1024*1024,pA=1500,mA=25e3;function gA(e,t){let n=Fa.get(e);n||(n=yA(e),Fa.set(e,n),ed(n)),n.listeners.add(t);const s=c=>kA(n,c),l=()=>{n.listeners.delete(t)};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:s,detach:l}}function ic(e){const t=Fa.get(e);t&&(EA(t),Fa.delete(e))}function _A(e,t={}){const n=Fa.get(e);if(!n)return!1;n.exited=!1,n.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(n.preserveCachedOutputOnNextSnapshot=!0),n.reconnectTimer!==null&&(window.clearTimeout(n.reconnectTimer),n.reconnectTimer=null),jc(n);const s=n.socket;return n.socket=null,Aa(n,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),ed(n),!0}function vA(){for(const e of Fa.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),jc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Aa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),ed(e)}}function Mp(){for(const e of Array.from(Fa.keys()))ic(e)}function yA(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function ed(e){if(!e.reconnectEnabled)return;Aa(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){Aa(e,"connected");for(const n of e.pendingOut)t.send(JSON.stringify(n));e.pendingOut.length=0,e.isAlive=!0,bA(e)}}),t.addEventListener("message",n=>{if(e.socket!==t)return;const s=typeof n.data=="string"?n.data:"";if(!s)return;let l=null;try{l=JSON.parse(s)}catch{return}if(!l||typeof l.type!="string")return;if(l.type==="pong"){e.isAlive=!0;return}const c=wA(e,l);rC(e,{type:"message",message:c})}),t.addEventListener("close",n=>{if(e.socket===t){if(e.socket=null,jc(e),n.code===1008){e.reconnectEnabled=!1,Aa(e,SA(n.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){Aa(e,"closed");return}Aa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,ed(e)},pA)}}),t.addEventListener("error",()=>{})}function bA(e){jc(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},mA)}function jc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function SA(e){return e.trim().toLowerCase()==="unauthorized"}function wA(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,CA(e,t.output),Np(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,s)=>n+s.length,0),Np(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,Np(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function CA(e,t){const n=xA(e.output,t);if(n===0)return;const s=t.slice(n);for(const l of s)e.output.push(l),e.outputBytes+=l.length}function xA(e,t){const n=Math.min(e.length,t.length);for(let s=n;s>0;s-=1){let l=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){l=!1;break}if(l)return s}return 0}function Np(e){for(;e.outputBytes>fA&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Aa(e,t){e.status!==t&&(e.status=t,rC(e,{type:"status",status:t}))}function rC(e,t){for(const n of Array.from(e.listeners))n(t)}function kA(e,t){const n=e.socket;return n&&n.readyState===WebSocket.OPEN?(n.send(JSON.stringify(t)),!0):((t.type==="input"||t.type==="cancel_scrollback")&&e.pendingOut.push(t),!1)}function EA(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),jc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const TA=[0,50,150,350],DA=2,RA=[300,1200,2500],MA=1e3,NA=1e5,AA="",eg="\x1B[?1049l\x1B[?1047l\x1B[?47l",LA=new Set(["47","1047","1049"]),BA=400,OA=3,zA=3,jA=32,PA=1.42,HA=2,IA=24,UA=240,KA=60,WA=420,FA=6,qA=2,N0=[500,1500,3e3,5e3,8e3],A0=15e3,$A=40,eh=240,VA=Mi.lazy(()=>Xg(()=>import("./TranscriptMarkdownBody-D39ylGl_.js"),__vite__mapDeps([2,1])));function L0({terminal:e,serverApi:t,active:n,visible:s=!0,canClose:l,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:b,onAuthClose:y}){const S=v.useSyncExternalStore(Hw,rm,()=>za),w=v.useSyncExternalStore(Iw,sm,()=>Il),k=v.useSyncExternalStore(Uw,lm,()=>!0),T=v.useSyncExternalStore(sh,om,()=>!0),L=v.useSyncExternalStore(sh,cm,()=>!0),A=v.useSyncExternalStore(Cg,Zs,()=>Hl),O=v.useSyncExternalStore(Ch,()=>xh("history.toggle"),()=>"Alt+H"),Y=v.useSyncExternalStore(Ch,()=>xh("scrollback.toggle"),()=>"Alt+S"),P=v.useRef(null),q=v.useRef(null),re=v.useRef(null),ne=v.useRef(null),ue=v.useRef({onExit:f,onSnapshot:b}),ye=v.useRef(t.createWebSocketUrl),U=v.useRef(y),K=v.useRef(null),W=v.useRef(null),H=v.useRef(null),j=v.useRef(!1),ae=v.useRef(new Map),R=v.useRef([]),X=v.useRef(null),Z=v.useRef(0),Ce=v.useRef(!1),Te=v.useRef(!1),M=v.useRef(!1),Q=v.useRef({terminalId:e.id,enabled:!1}),he=v.useRef([]),ge=v.useRef([]),_e=v.useRef(0),Se=v.useRef(!1),Ee=v.useRef(null),De=v.useRef(0),Ie=v.useRef(null),se=v.useRef(null),me=v.useRef(!1),Le=v.useRef(!1),be=v.useRef(!1),Me=v.useRef(!1),Pe=v.useRef(null),je=v.useRef(null),ie=v.useRef(!1),xe=v.useRef(!1),Re=v.useRef(!1),Be=v.useRef(!1),Oe=v.useRef(!1),rt=v.useRef(!1),qt=v.useRef(!1),wt=v.useRef(n),Ki=v.useRef(s),nt=v.useRef(c),pt=v.useRef(S),fe=v.useRef(w),Ue=v.useRef(!1),st=v.useRef(null),at=v.useRef(null),Et=v.useRef(!1),Tt=v.useRef(!1),Dt=v.useRef(null),[,Rt]=v.useState("connecting"),[F,qe]=v.useState(!1),[mt,$t]=v.useState(null),[Si,Zi]=v.useState(!1),[Ct,_t]=v.useState(null),[Pt,li]=v.useState(!1),[wi,jt]=v.useState(!1),[Li,Gt]=v.useState(!1),[Ht,Wi]=v.useState(!1),[bt,oi]=v.useState(null),[Fi,Ci]=v.useState(!1),[sn,dn]=v.useState(()=>fp(e.id)),Bi=!!bt||nc(e.currentCommand),ei=bt?.provider==="claude"||lC(e.currentCommand),xi=!!bt||nc(e.currentCommand),wn=e.capabilities?.tmuxScrollback===!0,Qi=wn&&(sn??(xi?L:T)),[na,ra]=v.useState(!1);v.useLayoutEffect(()=>{wt.current=n},[n]),v.useLayoutEffect(()=>{Ki.current=s},[s]),v.useLayoutEffect(()=>{nt.current=c},[c]),v.useLayoutEffect(()=>{pt.current=S},[S]),v.useLayoutEffect(()=>{fe.current=w},[w]),v.useLayoutEffect(()=>{Ue.current=Fi},[Fi]),v.useLayoutEffect(()=>{st.current=bt},[bt]),v.useLayoutEffect(()=>{Et.current=Bi},[Bi]),v.useLayoutEffect(()=>{Tt.current=ei},[ei]),v.useLayoutEffect(()=>{const D=Q.current;Te.current=Qi,M.current=wn,Q.current={terminalId:e.id,enabled:Qi},H0(P.current,Qi),D.terminalId===e.id&&D.enabled&&!Qi&&_s(),Qi||Gt(!1)},[e.id,Qi,wn]),v.useEffect(()=>{dn(fp(e.id)),Z.current=0,Ce.current=!1,Gt(!1),Hn()},[e.id]),v.useEffect(()=>sh(()=>{dn(fp(e.id))}),[e.id]),v.useEffect(()=>{s&&n&&e.status==="running"&&(We(),we("auto"))},[n,s,e.status]),v.useEffect(()=>{ue.current={onExit:f,onSnapshot:b}},[f,b]),v.useEffect(()=>{ye.current=t.createWebSocketUrl,U.current=y},[t,y]),v.useEffect(()=>{let D=!1,J=null,Ke=0;const Ye=p3(e.currentCommand),Ge=nc(e.currentCommand);function ht(){J!==null&&(window.clearTimeout(J),J=null)}function di(Zt){if(D)return;let fi;if(Zt){if(!Ge)return;fi=A0}else if(Ke<N0.length){if(!Ye)return;fi=N0[Ke++]}else{if(!Ge)return;fi=A0}J=window.setTimeout(()=>{J=null,en()},fi)}async function en(){try{const Zt=await t.getTerminalTranscriptSource(e.id);if(D)return;oi(fi=>fi&&Zt.source&&fi.provider===Zt.source.provider&&fi.sessionId===Zt.source.sessionId?fi:Zt.source),di(!!Zt.source)}catch(Zt){if(D)return;Ap(Zt)&&oi(null),di(!1)}}return oi(null),e.status!=="running"?()=>{D=!0,ht()}:(en(),()=>{D=!0,ht()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const D=bt?`${e.id}:${bt.provider}:${bt.sessionId}`:null,J=at.current;J!==null&&D!==null&&J!==D&&Ue.current&&Ci(!1),at.current=D},[e.id,bt?.provider,bt?.sessionId]),v.useEffect(()=>{function D(J){if(!wt.current||!Ki.current||J.isComposing||J.key==="Process"||GA(J.target))return;const Ke=qw(J);if(Ke?.id==="history.toggle"&&st.current){J.preventDefault(),J.stopPropagation(),Ci(Ye=>!Ye);return}if(Ke?.id==="scrollback.toggle"&&M.current){J.preventDefault(),J.stopPropagation(),zr();return}}return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[]),v.useEffect(()=>{const D=q.current;D&&(D.options.disableStdin=e.status==="exited"),e.status==="exited"&&Rt("closed")},[e.status]),v.useEffect(()=>{const D=q.current;D&&(D.options.fontSize=S,dp(S,fe.current).then(()=>{pt.current===S&&We()}))},[S]),v.useEffect(()=>{const D=q.current;D&&(D.options.fontFamily=nm(w),dp(pt.current,w).then(()=>{fe.current===w&&We()}))},[w]),v.useEffect(()=>{const D=q.current;D&&(D.options.theme=B0(A))},[A]),v.useEffect(()=>{const D=P.current;if(!D)return;let J=!1,Ke=null,Ye=null,Ge=null,ht=null,di=null,en=null,Zt=null;K.current=null,Oe.current=!1,rt.current=!1,Me.current=!1,hs(),Ar();const fi=pt.current,ua=fe.current,Cn=new pN({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:nm(ua),fontSize:fi,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:NA,theme:{...B0(Zs())}}),Pc=new sD;return Cn.loadAddon(Pc),ht=oA(Cn),q.current=Cn,re.current=Pc,dp(fi,ua).then(()=>{if(J)return;Cn.open(D),H0(D,Te.current),Oe.current=!0,Ke=QN(Cn,{onPasteText:te,onInterrupt:B,shouldInterruptPlainCtrlC:()=>Tt.current}),Ki.current&&wt.current&&e.status==="running"&&we("auto"),We(),di=C3(D,Cn,()=>pt.current*1.2,zn,In=>{It(In)},ii,Pn,()=>Te.current,gs),en=b3(D,Cn,zn,In=>{It(In)},ii,Pn,()=>Te.current,gs);const sd=new mN;Ye=Cn.onData(In=>{if(qt.current){const Ic=xN(In);if(Ic){Ut(!1),E(Ic);return}}const Hc=sd.accept(In);Hc&&E(Hc)}),Ge=Cn.onScroll(In=>{if(xe.current||Be.current||Re.current){ti();return}ds(),ur(Cn)&&jn({scrollToBottom:!0}),zn(),!Te.current&&In<=3&&It()}),Zt=new ResizeObserver(()=>{as()}),Zt.observe(D),rt.current&&(mr(),rt.current=!1,We()),Br()}),()=>{pn(ne.current,{updateUi:!1}),J=!0,Oe.current=!1,rt.current=!1,hs(),W.current=null,H.current=null,j.current=!1,ki(),nr(),Re.current=!1,di?.(),en?.(),Zt?.disconnect(),Ke?.dispose(),Ye?.dispose(),Ge?.dispose(),ht?.dispose(),Cn.dispose(),q.current=null,re.current=null}},[e.id]),v.useEffect(()=>{const D=ye.current(e.id),J=gA(D,Nr);return ne.current=J.send,Rt(J.status),J.status==="connected"&&We(),J.snapshot&&(ue.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),q.current&&(We(),On(J.output,J.history),We())),()=>{pn(J.send,{updateUi:!1}),J.detach(),ne.current=null}},[e.id,e.status]);function Nr(D){if(D.type==="status"){Rt(D.status),D.status==="unauthorized"&&U.current?.({source:"terminal-ws-1008",terminalId:e.id}),D.status==="connected"&&We();return}gr(D.message)}function Ar(D=[],J=null){he.current=[],ge.current=th(D),_e.current=0,Se.current=!1,Ee.current=null,Re.current=!1,De.current+=1,Ie.current=J,se.current=null,me.current=!1,Le.current=!1,be.current=!1,rt.current=!1,Dt.current=null,Pe.current=null,ie.current=!1,qe(!1),$t(null),Zi(!1),_t(null),li(!1),jt(!1)}function On(D=[],J=null){Ar(D,J),pr()}function pr(){if(!q.current||!Oe.current){rt.current=!0;return}rt.current=!1,mr()}async function mr(){const D=q.current;if(!D)return;const J=ih(D,ie.current),Ke=J?ge.current.length:_e.current;await tr(D,{liveOutputLimit:Ke,scrollToBottom:J}),q.current===D&&ti()}function tr(D,J={}){return new Promise(Ke=>{Re.current=!0,Se.current=!1;const Ye=De.current+1;De.current=Ye;const Ge=Math.max(0,Math.min(J.liveOutputLimit??ge.current.length,ge.current.length)),ht=J.historyPages??he.current,di=()=>{if(q.current!==D||De.current!==Ye){Ke(!1);return}try{_e.current=Ge,J.scrollToBottom&&rr(D)}finally{Re.current=!1;const Zt=Ya();Zt?jn(Zt):J.applyDeferredSnapshot!==!1&&vr(),Ke(!0)}},en=()=>{if(q.current!==D||De.current!==Ye){Ke(!1);return}D.clear();const Zt=th([...ht,...ge.current.slice(0,Ge)]);if(Zt.length===0){di();return}for(let fi=0;fi<Zt.length;fi+=1){const ua=Zt[fi];fi===Zt.length-1?D.write(ua,di):D.write(ua)}};if(D.buffer.active.type==="alternate"){D.write(eg,en);return}en()})}async function It(D=0){const J=q.current;if(be.current||!J)return;if(fs(J)){ti();return}const Ke=Ie.current;be.current=!0,qe(!0);const Ye=J.buffer.active.viewportY;try{let Ge=!!(Ke&&!Ke.hasMore);if(!Ge)try{const ht=await t.getTerminalHistory(e.id,{beforeLine:Ke?.startLine??0,limit:MA}),di={startLine:ht.startLine,endLine:ht.endLine,hasMore:ht.hasMore};if(ht.output.length>0){await Lr(J,ht.output,Ye,D)&&(Ie.current=di);return}Ie.current=di,Ge=!ht.hasMore}catch(ht){Ge=Ap(ht)}if(Ge){if(fs(J)){ti();return}await sa(J,Ye,D)}}catch{}finally{be.current=!1,qe(!1)}}async function sa(D,J,Ke){if(!(me.current||Le.current))try{const Ye=se.current,Ge=await t.getTerminalTranscriptHistory(e.id,{...Ye?{cursor:Ye}:{},limit:BA}),ht=Ge.output.map(oC);if(!Ge.source)return;if(ht.length===0){oi(Ge.source),se.current=Ge.cursor,Le.current=!Ge.hasMore||!Ge.cursor;return}await Lr(D,ht,J,Ke)&&(oi(Ge.source),se.current=Ge.cursor,Le.current=!Ge.hasMore||!Ge.cursor)}catch(Ye){Ap(Ye)&&(me.current=!0)}}async function Lr(D,J,Ke,Ye){if(fs(D))return ti(),!1;const Ge=[...J,...he.current],ht=v3(J);return!await tr(D,{liveOutputLimit:_e.current,scrollToBottom:!1,historyPages:Ge,applyDeferredSnapshot:!1})||q.current!==D?!1:(he.current=Ge,yr(D,Math.max(0,Ke+ht+Math.min(0,Ye))),ie.current=!ur(D),zn(),!0)}v.useEffect(()=>{const D=window.visualViewport;function J(){document.visibilityState==="visible"&&We()}function Ke(){We()}function Ye(){as()}function Ge(){Jl()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",Ke),window.addEventListener("resize",Ye),window.addEventListener(Bh,Ge),D?.addEventListener("resize",Ye),D?.addEventListener("scroll",Ye),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",Ke),window.removeEventListener("resize",Ye),window.removeEventListener(Bh,Ge),D?.removeEventListener("resize",Ye),D?.removeEventListener("scroll",Ye)}},[e.id]);function ir(){const D=ye.current(e.id);Me.current=!0,Dt.current=null,Rt("reconnecting"),We(),_A(D,{preserveCachedOutputOnNextSnapshot:!0})}function gr(D){if(D.type==="snapshot"&&D.terminal.id===e.id){ue.current.onSnapshot(D.terminal,{notifyCompletion:!1});const Ke=q.current;if(!Ke)return;We();const Ye=Me.current;if(Me.current=!1,Ye){Ie.current=D.history??Ie.current,ti(),We();return}if(ca(Ke,D.terminal)){ps(D.output,D.history??null),ti(),We();return}On(D.output,D.history??null),We();return}if(D.type==="terminal_updated"&&D.terminal.id===e.id){ue.current.onSnapshot(D.terminal,{notifyCompletion:!0});return}if(D.type==="output"&&D.terminalId===e.id){const Ke=hC(D.data);if(!Ke)return;ge.current.push(Ke),q.current&&Oe.current?jn({scrollToBottom:!0}):rt.current=!0;return}const J=q.current;if(J){if(D.type==="exit"&&D.terminalId===e.id){ue.current.onExit(D.exitCode),Rt("closed");return}D.type==="error"&&J.writeln(`\r
33
+ [nterminal] ${D.message}`)}}function Ql(D=25){if(document.visibilityState==="hidden"||!Ki.current||ae.current.has(D))return;const J=window.setTimeout(()=>{ae.current.delete(D),!aa()&&fn()},D);ae.current.set(D,J)}function as(){aa()||Br()}function aa(){const D=an();return D&&ls(D)?(j.current=!0,H.current=D,!0):D&&os(D)?(j.current=!1,H.current=null,!0):((!D||!D.composeOpen&&!D.keyboardVisible)&&(j.current=!1,H.current=null),!1)}function Jl(){if(!j.current)return;const D=an();D&&(D.composeOpen||D.keyboardVisible)||(j.current=!1,H.current=null)}function ls(D){if(!D.mobileLike||!D.composeOpen&&!D.keyboardVisible)return!1;const J=W.current;return J?qi(D.windowWidth,J.windowWidth)&&qi(D.visualViewportWidth,J.visualViewportWidth)&&qi(D.containerWidth,J.containerWidth):!1}function os(D){if(!D.mobileLike||D.composeOpen||D.keyboardVisible)return!1;const J=H.current;return!J||!J.composeOpen&&!J.keyboardVisible?!1:qi(D.windowWidth,J.windowWidth)&&qi(D.visualViewportWidth,J.visualViewportWidth)&&qi(D.containerWidth,J.containerWidth)}function an(){const D=P.current;if(!D||D.isConnected===!1)return null;const J=D.getBoundingClientRect(),Ke=us(window.innerWidth)??0,Ye=us(window.visualViewport?.width)??Ke,Ge=us(J.width)??us(D.clientWidth)??Ke;if(Ke<=0||Ye<=0||Ge<=0)return null;const{keyboardVisible:ht}=Zm(),di=document.documentElement.hasAttribute(Qh),en=Ji()||ht;return{windowWidth:Ke,visualViewportWidth:Ye,containerWidth:Ge,composeOpen:di,keyboardVisible:ht,mobileLike:en}}function Ji(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function cs(){return Zm().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function us(D){return typeof D=="number"&&Number.isFinite(D)&&D>0?D:null}function qi(D,J){return Math.abs(D-J)<=DA}function Br(){for(const D of TA)Ql(D)}function We(){K.current=null,Br()}function hs(){for(const D of ae.current.values())window.clearTimeout(D);ae.current.clear()}function ki(){for(const D of R.current)window.clearTimeout(D);R.current=[]}function zn(){if(ti(),!Pe.current){Zi(!1);return}Zi(!0),nr(),je.current=window.setTimeout(()=>{je.current=null,Zi(!1)},1200)}function ti(){const D=q.current,J=D?y3(D):null;if(Pe.current=J,$t(J),jt(!!(D&&J)),li(!!(D&&J&&!ur(D))),J||!D||!la()){_t(null);return}_t({alternate:D.buffer.active.type==="alternate"})}function la(){const D=Ie.current;return he.current.length>0||!!D?.hasMore}function nr(){je.current!==null&&(window.clearTimeout(je.current),je.current=null)}function ds(){const D=q.current;D&&(ie.current=!ur(D),ti())}function oa(D){Ee.current=Lp(Ee.current,D)}function _r(D){const J=Ee.current;return Ee.current=null,Lp(J,D)}function Ya(){const D=Ee.current;return Ee.current=null,D}function jn(D={}){const J=q.current;if(!J||!Oe.current){rt.current=!0;return}if(Re.current){oa(D);return}if(Se.current){oa(D);return}const Ke=_r(D);if(!Ke.force&&!ih(J,ie.current)){ti();return}Se.current=!0;const Ye=De.current,Ge=()=>{if(q.current!==J||De.current!==Ye){Se.current=!1;return}if(!Ke.force&&!ih(J,ie.current)){Se.current=!1,ti();return}const ht=_e.current,di=ge.current[ht];if(di===void 0){Se.current=!1,Ke.scrollToBottom&&rr(J),ti();const en=Ya();en?jn(Lp(Ke,en)):vr();return}J.write(di,()=>{if(q.current!==J||De.current!==Ye){Se.current=!1;return}_e.current=ht+1,Ge()})};Ge()}function fs(D){return!ur(D)&&(Xa()||Se.current||Re.current)}function ca(D,J){return(Et.current||nc(J?.currentCommand))&&!ur(D)}function Xa(){return _e.current<ge.current.length}function ps(D,J){Dt.current={output:D,history:J,appendFromLiveOutputIndex:_e.current}}function vr(){const D=q.current,J=Dt.current;if(!D||!J||!ur(D)||Xa()||Se.current||Re.current)return;const Ke=th(J.output),Ye=th(ge.current.slice(J.appendFromLiveOutputIndex));Dt.current=null,On(_3(Ke,Ye),J.history),We()}function ii(){Be.current=!0}function Pn(){ds(),Be.current=!1;const D=q.current;D&&ur(D)&&jn({scrollToBottom:!0})}function rr(D){sr(()=>I0(D))&&(ie.current=!1)}function yr(D,J){sr(()=>(D.scrollToLine(J),!0))}function sr(D){xe.current=!0;try{return D()}finally{xe.current=!1}}function Ga(){const D=q.current;if(!D)return;const J=()=>{Te.current&&(ar(ne.current),Gt(!1)),I0(D),ie.current=!1,ti(),jn({force:!0,scrollToBottom:!0}),we("scroll-action")};if(D.buffer.active.type==="alternate"){D.write(eg,J);return}J()}function ms(D){const J=q.current,Ke=P.current;if(!J||!Ke)return;const Ye=Ke.getBoundingClientRect();if(Ye.height<=0)return;const Ge=Math.max(0,Math.min(1,(D-Ye.top)/Ye.height)),ht=Math.round(J.buffer.active.baseY*Ge);ii();try{J.scrollToLine(ht)}finally{Pn()}ie.current=!ur(J),ti(),zn(),ht<=3&&It()}function Za(D){D.preventDefault(),D.stopPropagation(),D.currentTarget.setPointerCapture?.(D.pointerId),ms(D.clientY)}function Or(D){(D.buttons&1)!==0&&(D.preventDefault(),D.stopPropagation(),ms(D.clientY))}function fn(){const D=q.current,J=re.current;if(!(!D||!J)&&!(document.visibilityState==="hidden"||!Ki.current||P.current?.isConnected===!1))try{const Ke=ih(D,ie.current),Ye=an();J.fit(),Ye&&(W.current=Ye),Ke&&rr(D),D.refresh(0,Math.max(0,D.rows-1)),ti();const Ge={cols:D.cols,rows:D.rows},ht=K.current;if(ht&&ht.cols===Ge.cols&&ht.rows===Ge.rows)return;br({type:"resize",terminalId:e.id,cols:Ge.cols,rows:Ge.rows})&&(K.current=Ge)}catch{}}function br(D){const J=ne.current;return J?J(D):!1}function Hn(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function ln(){Hn();const D=Math.max(-eh,Math.min(eh,Z.current));if(Z.current=0,D===0)return!1;const J=br({type:"scrollback_scroll",terminalId:e.id,lines:D});return J&&(Ce.current=!0,D<0&&Gt(!0)),J}function gs(D){if(!Te.current||D===0)return;const J=Z.current+D;Z.current=Math.max(-eh,Math.min(eh,J)),X.current===null&&(X.current=window.setTimeout(()=>{X.current=null,ln()},$A))}function _s(){ar(ne.current)}function pn(D=ne.current,J={}){const Ke=Ce.current;Hn(),Z.current=0,Ce.current=!1,J.updateUi!==!1&&Gt(!1),Ke&&D?.({type:"cancel_scrollback",terminalId:e.id})}function ar(D){Hn(),Z.current=0,Ce.current=!1,Gt(!1),D?.({type:"cancel_scrollback",terminalId:e.id})}function zr(){if(!M.current)return;const D=!Te.current;dn(mT(e.id,D)),C()}function C(){const D=q.current;D&&(rr(D),ti())}function E(D){ln();const J=Ce.current;Ce.current=!1,J&&Gt(!1),jn({force:!0,scrollToBottom:!0}),br({type:"input",terminalId:e.id,data:D,...J?{cancelScrollbackMode:!0}:{}})&&f3(D)&&pe()}function B(){qt.current&&Ut(!1),E(AA)}function te(D){const J=E0(D,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&E(J)}function ve(D,J){const Ke=E0(D,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Ke&&E(Ke),window.setTimeout(()=>E(IN(J)),iC)}function pe(){!nt.current||!wt.current||(ki(),R.current=RA.map(D=>{const J=window.setTimeout(()=>{R.current=R.current.filter(Ke=>Ke!==J),nt.current&&wt.current&&br({type:"refresh_cwd",terminalId:e.id})},D);return J}))}function we(D="terminal-interaction"){Ue.current||cs()&&(D==="auto"||D==="scroll-action")||q.current?.focus()}const $e=v.useCallback(()=>{Ci(!1)},[]);function et(){Wi(D=>{const J=!D;return qt.current=J,J}),we("input-action")}function Ut(D){qt.current=D,Wi(D)}function Vt(D){qt.current&&Ut(!1),E(CN(D)),we("input-action")}return m.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":Qi?"true":"false",onMouseDown:()=>{n||p()},children:[m.jsx(ZA,{terminal:e,canClose:l,tabId:h,transcriptSource:bt,transcriptShortcutLabel:O,scrollbackShortcutLabel:Y,tmuxScrollbackSupported:wn,tmuxScrollbackEnabled:Qi,onToggleTmuxScrollback:zr,onOpenTranscript:()=>Ci(!0),onInterrupt:B,onReload:ir,onClose:g}),m.jsx("div",{className:"xterm-container",ref:P}),F?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,k&&!Qi&&mt?m.jsxs("div",{className:"terminal-scroll-progress","data-active":Si,"aria-hidden":"true",children:[mt.current,"/",mt.total]}):k&&!Qi&&Ct?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ct.alternate?"alternate":"normal","aria-hidden":"true",children:[Ct.alternate?"alt ":"","0/?"]}):null,Pt||Qi&&Li?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),Ga()},children:"↓"}):null,wi&&!Qi?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Za,onPointerMove:Or,children:m.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?na?m.jsx(SN,{ctrlActive:Ht,onCtrl:et,onStandaloneKey:Vt,onPreserveFocus:()=>we("input-action"),onHide:()=>ra(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:D=>{D.stopPropagation(),we("input-action")},onPointerDown:D=>{D.stopPropagation(),we("input-action")},onClick:()=>ra(!0),children:"⌨"}):null,m.jsx($N,{terminalId:e.id,onSubmit:ve,queueAvailable:bt?.provider==="codex"||aC(e.currentCommand),disabled:e.status!=="running"}),Fi&&bt?m.jsx(QA,{terminalId:e.id,serverApi:t,source:bt,fontSize:S,onClose:$e}):null]})}function B0(e){return qk(e)}function YA(e,t,n){const s=XA(e,t),l=O0(s*Math.max(1,n),KA,WA);return{limit:O0(Math.ceil(l/HA),IA,UA),maxLines:l}}function XA(e,t){const n=e?.clientHeight??0;if(n<=0)return jA;const s=Math.max(10,t*PA);return Math.max(1,Math.floor(n/s))}function O0(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function GA(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function ZA({terminal:e,canClose:t,tabId:n,transcriptSource:s,transcriptShortcutLabel:l,scrollbackShortcutLabel:c,tmuxScrollbackSupported:h,tmuxScrollbackEnabled:p,onToggleTmuxScrollback:g,onOpenTranscript:f,onInterrupt:b,onReload:y,onClose:S}){const w=Ew({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),k={cursor:n?"grab":"default",opacity:w.isDragging?.5:void 0};return m.jsxs("header",{ref:w.setNodeRef,className:"terminal-pane-header",style:k,"data-dragging":w.isDragging,...w.attributes,...w.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),s?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Oh(s.provider)} transcript history`,"aria-label":`View ${Oh(s.provider)} transcript history`,onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),f()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:l})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),h&&e.status==="running"?m.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":p?"true":"false","aria-pressed":p,"aria-label":`Toggle tmux scrollback (${c})`,title:p?`Scroll input uses tmux scrollback (${c}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${c}).`,onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),g()},children:[p?m.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.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"}),m.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"})]}):m.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.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"}),m.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),m.jsx("kbd",{children:c})]}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-interrupt","aria-label":`Send interrupt to ${e.title}`,title:"Send interrupt (^C)",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),b()},children:"^C"}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),y()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),S()},children:"x"}):null]})}const QA=Mi.memo(function({terminalId:t,serverApi:n,source:s,fontSize:l,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),S=v.useRef(null),w=v.useRef(null),[k,T]=v.useState([]),[L,A]=v.useState(!1),[O,Y]=v.useState(""),[P,q]=v.useState(-1),[re,ne]=v.useState(!1),[ue,ye]=v.useState(-1),[U,K]=v.useState(null),[W,H]=v.useState(null),[j,ae]=v.useState(!1),[R,X]=v.useState(!0),[Z,Ce]=v.useState(!1),[Te,M]=v.useState(null);v.useEffect(()=>{function fe(Ue){Ue.key==="Escape"&&(Ue.preventDefault(),Ue.stopPropagation(),c())}return document.addEventListener("keydown",fe,!0),()=>document.removeEventListener("keydown",fe,!0)},[c]),v.useEffect(()=>{p.current+=1;const fe=p.current;return g.current=!1,f.current=!0,b.current=null,S.current=null,w.current=null,T([]),H(null),ae(!1),M(null),q(-1),ye(-1),K(null),Be(null,"initial",fe),()=>{p.current===fe&&(p.current+=1)}},[n,L,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const fe=h.current;if(!fe)return;if(f.current){if(R||k.length===0)return;f.current=!1;const st=()=>{fe.scrollTop=fe.scrollHeight};st(),window.requestAnimationFrame?.(st);return}const Ue=b.current;Ue!==null&&(b.current=null,fe.scrollTop+=fe.scrollHeight-Ue)},[k,R,L]);const Q=Oh(s.provider),he=P0(k,L),ge=t3(he),_e=s3(ge),Se=_e.map(fe=>fe.key).join(""),Ee=U?_e.find(fe=>fe.key===U)?.entryIndex??null:null,De=O.trim().length>0,Ie=r3(ge,O),se=Ie.length,me=se>0?P>=0&&P<se?P:0:-1,Le=me>=0?Ie[me]?.entryIndex??null:null,be=me>=0?Ie[me]??null:null,Me=De?Le:Ee,Pe=De?Le===null?null:"search":Ee===null?null:"prompt",je=he?he.split(`
34
+ `).length-1:0,ie=_e.length>0&&ue>=0&&ue<_e.length?ue:_e.length-1,xe=U??(ie>=0?_e[ie]?.key??null:null),Re=De?se>0?`${me+1}/${se} ${se===1?"match":"matches"} · ${je} ${je===1?"line":"lines"}`:`0 matches · ${je} ${je===1?"line":"lines"}`:_e.length>0?`${ie+1}/${_e.length} prompts · ${je} ${je===1?"line":"lines"}`:`0 prompts · ${je} ${je===1?"line":"lines"}`;v.useEffect(()=>{const fe=O.trim().toLowerCase();q(Ue=>!fe||se===0?-1:y.current!==fe?0:Ue>=0&&Ue<se?Ue:0),y.current=fe},[O,se]),v.useEffect(()=>{if(De){K(null);return}U&&!_e.some(fe=>fe.key===U)&&K(null),ye(fe=>{if(_e.length===0)return w.current=null,-1;const Ue=w.current?_e.findIndex(at=>at.key===w.current):-1,st=Ue>=0?Ue:fe>=0&&fe<_e.length?fe:_e.length-1;return w.current=_e[st]?.key??null,st})},[U,De,Se]),v.useEffect(()=>{const fe=S.current;if(!fe||_e.length===0)return;S.current=null;const Ue=fe.anchorKey?_e.findIndex(at=>at.key===fe.anchorKey):-1,st=Ue>0?Ue-1:0;Ki(st)},[Se]);async function Be(fe,Ue,st=p.current){if(!g.current){g.current=!0,Ue==="initial"?X(!0):(Ce(!0),b.current=h.current?.scrollHeight??null),M(null);try{await Oe(fe,Ue,st)}catch(at){if(p.current!==st)return;M(at instanceof Error?at.message:"Failed to load transcript history.")}finally{p.current===st&&(g.current=!1,X(!1),Ce(!1))}}}async function Oe(fe,Ue,st){let at=fe,Et=0,Tt=[];const Dt=Ue==="initial"&&s.provider!=="claude"?qA:FA;for(;p.current===st;){const Rt=await n.getTerminalTranscriptHistory(t,{...at?{cursor:at}:{},...YA(h.current,l,Ue==="initial"?OA:zA),includeTools:L});if(p.current!==st)return;const F=j0(Rt.output,s.provider,{includeTools:L}),qe=rt(Rt,Ue,Tt,F);if(F&&(Tt=[F,...Tt],qe))return;if(!Rt.hasMore||!Rt.cursor||Et>=Dt){Tt.length>0&&T(mt=>Ue==="older"?[...Tt,...mt]:Tt);return}at=Rt.cursor,Et+=1}}function rt(fe,Ue,st,at=j0(fe.output,s.provider,{includeTools:L})){if(H(fe.cursor),ae(!!(fe.hasMore&&fe.cursor)),!at)return!1;const Et=[at,...st];return P0(Et,L)?(T(Tt=>Ue==="older"?[...Et,...Tt]:Et),!0):!1}function qt(){const fe=h.current;fe&&(pt(),!(fe.scrollTop>72||!j||!W||g.current)&&Be(W,"older"))}function wt(fe){se!==0&&q(Ue=>{const st=me>=0?me:fe>0?-1:0;return((Ue>=0&&Ue<se?Ue:st)+fe+se)%se})}function Ki(fe){const Ue=_e[fe];Ue&&(w.current=Ue.key,ye(fe),K(Ue.key))}async function nt(fe){if(_e.length===0){fe<0&&j&&W&&!g.current&&(S.current={anchorKey:null},await Be(W,"older"));return}const st=(ue>=0&&ue<_e.length?ue:fe<0?_e.length-1:-1)+fe;if(st>=0&&st<_e.length){Ki(st);return}fe<0&&st<0&&j&&W&&!g.current&&(S.current={anchorKey:_e[0]?.key??null},await Be(W,"older"))}function pt(){if(De)return;const fe=h.current;if(!fe)return;const st=fe.getBoundingClientRect().top+Math.min(140,Math.max(48,fe.clientHeight*.28));let at=null;for(const Et of u3(fe)){const Tt=h3(Et);if(Tt!==null)if(Et.getBoundingClientRect().top<=st)at=Tt;else break}if(at!==null){const Et=_e[at]?.key??null;w.current=Et,ye(at),U&&U!==Et&&K(null)}}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:fe=>fe.stopPropagation(),onMouseDown:fe=>fe.stopPropagation(),onClick:fe=>{fe.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:fe=>fe.stopPropagation(),onMouseDown:fe=>fe.stopPropagation(),onClick:fe=>fe.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[Q," JSONL"]}),m.jsx("span",{title:s.sessionId,children:s.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:L,onChange:fe=>A(fe.currentTarget.checked)}),"Show tool output"]}),m.jsx("label",{className:"transcript-search",children:m.jsx("input",{type:"search",value:O,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:fe=>Y(fe.currentTarget.value),onKeyDown:fe=>{fe.key==="Enter"&&(fe.preventDefault(),De?wt(fe.shiftKey?-1:1):nt(fe.shiftKey?-1:1))}})}),m.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":re,"aria-label":"Toggle prompt list",onClick:()=>ne(fe=>!fe),disabled:_e.length===0,children:"List"}),m.jsxs("div",{className:"transcript-search-actions","aria-label":De?"Search result navigation":"Prompt navigation",children:[m.jsx("button",{type:"button",onClick:()=>De?wt(-1):void nt(-1),disabled:De?se===0:_e.length===0&&!j,"aria-label":De?"Previous search match":"Previous user prompt",title:De?"Previous search match":"Previous user prompt",children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>De?wt(1):void nt(1),disabled:De?se===0:_e.length===0,"aria-label":De?"Next search match":"Next user prompt",title:De?"Next search match":"Next user prompt",children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:Re})]}),re?m.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:_e.length>0?_e.map((fe,Ue)=>m.jsxs("button",{type:"button",className:xe===fe.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>Ki(Ue),children:[m.jsx("span",{children:fe.timestampLabel}),m.jsx("strong",{children:fe.snippet})]},`${fe.key}:${Ue}`)):m.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:qt,children:[Z?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&j?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,he?m.jsx(JA,{entries:ge,searchQuery:O,activeEntryIndex:Me,activeEntryMode:Pe,activeSearchMatch:be,fontSize:l}):null,R?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!R&&!he&&!Te?j&&W?m.jsxs("div",{className:"transcript-dialog-status",children:[L?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{Be(W,"older")},disabled:Z,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,Te?m.jsx("div",{className:"transcript-dialog-error",children:Te}):null]})]})})});function JA({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:s,activeSearchMatch:l,fontSize:c}){const h=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=h.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((l?.entryIndex===n?f[l.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,s,l,t]);let p=-1;return m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const b=g.kind==="user"?++p:null,y=n===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return m.jsxs("section",{ref:S=>{S?h.current.set(f,S):h.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${y}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...b!==null?{"data-transcript-prompt-position":b}:{},children:[g.header?m.jsx("div",{className:"transcript-entry-header",children:sC(g.header,t)}):null,g.body?m.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?m.jsx(z0,{text:g.body,searchQuery:t}):m.jsx(Mi.Suspense,{fallback:m.jsx(z0,{text:g.body,searchQuery:t}),children:m.jsx(VA,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function z0({text:e,searchQuery:t}){const n=e.endsWith(`
35
+ `)?e.slice(0,-1).split(`
36
+ `):e.split(`
37
+ `);return m.jsx("pre",{className:"transcript-entry-pre",children:n.map((s,l)=>m.jsx("span",{className:`transcript-line transcript-line-${d3(s,l===0||n[l-1]?.trim()==="")}`,children:sC(s,t)},l))})}function sC(e,t){const n=t.trim();if(!n)return e||" ";const s=e.toLowerCase(),l=n.toLowerCase(),c=[];let h=0,p=s.indexOf(l);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+n.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=s.indexOf(l,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function e3(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const s=e.toLowerCase();let l=0,c=s.indexOf(n);for(;c!==-1;)l+=1,c=s.indexOf(n,c+n.length);return l}function t3(e){const t=e.endsWith(`
38
+ `)?e.slice(0,-1):e;if(!t)return[];const n=[];let s=null,l="plain",c=[];function h(){const p=i3(c).join(`
39
+ `);(s||p)&&n.push({header:s,body:p,kind:l}),s=null,l="plain",c=[]}for(const p of t.split(`
40
+ `)){const g=n3(p);g?(h(),s=p,l=g):c.push(p)}return h(),n}function i3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function n3(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 r3(e,t){const n=[];for(let s=0;s<e.length;s+=1){const l=e[s];if(!l)continue;const c=l.header?`${l.header}
41
+ ${l.body}`:l.body,h=e3(c,t);for(let p=0;p<h;p+=1)n.push({entryIndex:s,matchIndexInEntry:p})}return n}function s3(e){const t=[];for(let l=0;l<e.length;l+=1){const c=e[l];!c||c.kind!=="user"||t.push({contentKey:a3(c),entry:c,entryIndex:l})}const n=new Map,s=new Map;for(let l=t.length-1;l>=0;l-=1){const c=t[l];if(!c)continue;const h=n.get(c.contentKey)??0;n.set(c.contentKey,h+1),s.set(l,JSON.stringify([c.contentKey,h]))}return t.map((l,c)=>({entryIndex:l.entryIndex,key:s.get(c)??JSON.stringify([l.contentKey,0]),snippet:o3(l.entry.body),timestampLabel:c3(l.entry.header)}))}function a3(e){return JSON.stringify([e.header??"",e.body.length,l3(e.body)])}function l3(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 o3(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function c3(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function u3(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function h3(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 d3(e,t){const n=e.trim();if(!n)return"blank";const s=n.replace(/^\[[^\]]+\]\s+/,""),l=/^\[[^\]]+\]\s+/.test(n);return(l||t)&&/^User$/.test(s)?"user":(l||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(l||t)&&/^System$/.test(s)?"system":(l||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||uC(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 f3(e){return e.includes("\r")||e.includes(`
42
+ `)}function Ap(e){return e instanceof hr&&e.status===404}function nc(e){return aC(e)||lC(e)}function aC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function lC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function p3(e){if(nc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Oh(e){return e==="codex"?"Codex":"Claude"}function j0(e,t,n={}){const s=`[nterminal] ${Oh(t)} transcript archive ends here. Live terminal screen continues below.`,l=e.join("").replace(/\r\n/g,`
43
+ `).replace(/\r/g,`
44
+ `).replace(s,"").replace(/\n{3,}/g,`
45
+
46
+ `).trimEnd(),c=oC(l),h=n.includeTools?c:cC(c);return h?`${h}
47
+ `:""}function oC(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 s=m3(n);return s?`[${s}]`:t})}function m3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),s=$o(t.getMonth()+1),l=$o(t.getDate()),c=$o(t.getHours()),h=$o(t.getMinutes()),p=$o(t.getSeconds());return`${n}-${s}-${l} ${c}:${h}:${p}`}function $o(e){return e.toString().padStart(2,"0")}function P0(e,t){return e.map(n=>t?n:cC(n)).filter(Boolean).map(n=>n.endsWith(`
48
+ `)?n:`${n}
49
+ `).join("")}function cC(e){if(!e)return"";const t=e.split(`
50
+ `),n=[];let s=!1,l=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?g3(h):null;if(g&&(s=g==="tool",l=!1),uC(h)){l=!0,c=!1;continue}if(l){p?(l=!1,s||n.push(h),c=!0):c=!1;continue}s||n.push(h),c=p}return n.join(`
51
+ `).replace(/\n{3,}/g,`
52
+
53
+ `).trimEnd()}function g3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function uC(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function _3(e,t){if(t.length===0)return e;let n=0;const s=Math.min(e.length,t.length);for(let l=s;l>0;l-=1){let c=!0;for(let h=0;h<l;h+=1)if(e[e.length-l+h]!==t[h]){c=!1;break}if(c){n=l;break}}return[...e,...t.slice(n)]}function v3(e){let t=0;for(const n of e){if(!n)continue;const s=n.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function th(e){const t=[];for(const n of e){const s=hC(n);s&&t.push(s)}return t}function hC(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,s)=>{const l=n.split(";").filter(Boolean).filter(c=>!LA.has(c.split(":")[0]??""));return l.length>0?`\x1B[?${l.join(";")}${s}`:""})}function Lp(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function y3(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 H0(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 ur(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function ih(e,t){return!t||ur(e)}function I0(e){return ur(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function b3(e,t,n,s,l,c,h,p){const g=f=>{const b=w3(f);if(b!==0){if(h()){if(k3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),p(b);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),S3(t,b,n,s,l,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function S3(e,t,n,s,l,c){const h=()=>{l();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(eg,h);return}h()}function w3(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 s=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,s))}function C3(e,t,n,s,l,c,h,p,g){let f=null,b=0;const y={passive:!1};function S(T){f=Bp(T),b=0}function w(T){const L=Bp(T);if(L===null){f=null,b=0;return}if(f===null){f=L;return}const A=L.clientY-f.clientY;if(f=L,T.cancelable&&T.preventDefault(),A===0)return;if(x3(t)&&E3(t,L,-A)){b=0;return}b-=A/n();const O=b<0?Math.ceil(b):Math.floor(b);if(O!==0){if(b-=O,p()){g(O);return}c();try{t.scrollLines(O)}finally{h()}s(),O<0&&t.buffer.active.viewportY<=3&&l(O)}}function k(T){if(T.touches.length>0){f=Bp(T);return}f=null,b=0}return e.addEventListener("touchstart",S,y),e.addEventListener("touchmove",w,y),e.addEventListener("touchend",k),e.addEventListener("touchcancel",k),()=>{e.removeEventListener("touchstart",S,y),e.removeEventListener("touchmove",w,y),e.removeEventListener("touchend",k),e.removeEventListener("touchcancel",k)}}function Bp(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function x3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function k3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function E3(e,t,n){const s=e.element;return s?(s.dispatchEvent(T3(t,n)),!0):!1}function T3(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const l=new Event("wheel",s);return Object.defineProperties(l,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),l}function tg({node:e,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:S,onSelect:w,onClose:k,onResize:T,onExit:L,onSnapshot:A,onCloseEditor:O,onAuthClose:Y}){const P=S??ig(e);if(y.length===0&&b){const ue=ng(e),ye=ue.some(U=>U.key===b)?b:ue[0]?.key;if(ue.length>1&&ye)return m.jsx("div",{className:"mobile-focused-split",children:ue.map(U=>{const K=U.key===ye;if(U.type==="editor"){const H=n[U.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:H?m.jsx(ES,{api:s,editor:H,canClose:P>1,onClose:()=>O(U.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},U.key)}const W=t[U.terminalId];return W?m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx(L0,{terminal:W,serverApi:s,active:K,visible:c&&K,canClose:P>1,refreshCwdOnEnter:h&&K,tabId:p,onSelect:()=>w(U.terminalId),onClose:()=>k(U.terminalId),onExit:H=>L(U.terminalId,H),onSnapshot:A,...Y?{onAuthClose:Y}:{}})},U.key):m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},U.key)})})}if(e.type==="pane"){const ue=t[e.terminalId];if(!ue)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ye=m.jsx(L0,{terminal:ue,serverApi:s,active:e.terminalId===l,visible:c,canClose:P>1,refreshCwdOnEnter:h&&e.terminalId===l,tabId:p,onSelect:()=>w(e.terminalId),onClose:()=>k(e.terminalId),onExit:K=>L(e.terminalId,K),onSnapshot:A,...Y?{onAuthClose:Y}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ye,m.jsx(nh,{terminalId:e.terminalId,side:"top"}),m.jsx(nh,{terminalId:e.terminalId,side:"right"}),m.jsx(nh,{terminalId:e.terminalId,side:"bottom"}),m.jsx(nh,{terminalId:e.terminalId,side:"left"})]}):ye}if(e.type==="editor"){const ue=n[e.editorId];return ue?m.jsx(ES,{api:s,editor:ue,canClose:P>1,onClose:()=>O(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const q=Math.max(.1,Math.min(.9,e.ratio)),re=1-q,ne=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`}:{gridTemplateRows:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ne,children:[m.jsx("div",{className:"split-cell",children:m.jsx(tg,{node:e.first,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,0],totalPanes:P,onSelect:w,onClose:k,onResize:T,onExit:L,onSnapshot:A,onCloseEditor:O,...Y?{onAuthClose:Y}:{}})}),m.jsx(D3,{direction:e.direction,path:y,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(tg,{node:e.second,terminals:t,editors:n,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,1],totalPanes:P,onSelect:w,onClose:k,onResize:T,onExit:L,onSnapshot:A,onCloseEditor:O,...Y?{onAuthClose:Y}:{}})})]})}function nh({terminalId:e,side:t}){const{setNodeRef:n,isOver:s}=Mg({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function D3({direction:e,path:t,onResize:n}){function s(l){l.preventDefault(),l.stopPropagation();const c=l.currentTarget;c.setPointerCapture?.(l.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-p.left)/p.width:(b.clientY-p.top)/p.height;n(t,Math.min(.9,Math.max(.1,y)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function ig(e){return e.type==="pane"||e.type==="editor"?1:ig(e.first)+ig(e.second)}function ng(e){return e.type==="pane"?[{key:R3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:M3(e.editorId),type:"editor",editorId:e.editorId}]:[...ng(e.first),...ng(e.second)]}function R3(e){return`terminal:${e}`}function M3(e){return`editor:${e}`}const td="workspace-default",N3="NTerminal";function A3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function L3(e,t){switch(t.type){case"workspace.hydrated":return rg(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return B3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return P3(e,t.workspaceId);case"workspace.selected":return dC(e,t.workspaceId);case"workspace.renamed":return O3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return z3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return j3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return fC(e,t.terminal);case"terminal.split":return H3(e,t.terminal,t.direction);case"terminal.updated":return G3(e,t.terminal);case"terminal.exited":return Z3(e,t.terminalId,t.exitCode);case"terminal.closed":return gC(e,t.terminalId);case"terminal.detached":return Q3(e,t.terminalId,t.workspaceId);case"editor.split":return I3(e,t.editorId,t.title,t.direction);case"editor.closed":return J3(e,t.editorId);case"pane.selected":return Y3(e,t.terminalId);case"pane.resized":return X3(e,t.path,t.ratio);case"tab.selected":return K3(e,t.tabId);case"tab.renamed":return V3(e,t.tabId,t.title);case"tab.reordered":return u_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return W3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return pC(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return mC(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return F3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return U3(e);default:return e}}function B3(e,t){if(e.workspaces.some(s=>s.id===t.id))return dC(e,t.id);const n={id:t.id,title:t.title,defaultCwd:fr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function dC(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function O3(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===s?h:(l=!0,{...h,title:s}));return l?{...e,workspaces:c}:e}function z3(e,t,n){const s=fr(n);let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===s?h:(l=!0,{...h,defaultCwd:s}));return l?{...e,workspaces:c}:e}function j3(e,t,n,s){if(t===n)return e;const l=e.workspaces.findIndex(y=>y.id===t),c=e.workspaces.findIndex(y=>y.id===n);if(l<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(l,1);if(!p)return e;const g=h.findIndex(y=>y.id===n);if(g<0)return e;const f=s==="before"?g:g+1,b=h.slice();return b.splice(f,0,p),$3(e.workspaces,b)?e:{...e,workspaces:b}}function P3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const n=e.workspaces.find(p=>p.id===t),s=new Set(n?zh(n):[]),l={...e.terminals};for(const p of s)delete l[p];const c=e.workspaces.filter(p=>p.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:l}}function fC(e,t){const n=vC(e),s=$a(n)??nd(),l=CC(t);return{...n,activeWorkspaceId:s.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??fr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,l],activeTabId:l.id}:wC(c,t.id))}}function H3(e,t,n){const s=$a(e),l=s?id(s):void 0;if(!s||!l)return fC(e,t);const c=l.activeTerminalId,h=xc(l.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(p=>p.id===s.id?{...p,defaultCwd:p.defaultCwd??fr(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===l.id?{...g,root:h,activeTerminalId:t.id}:g)}:wC(p,t.id))}}function I3(e,t,n,s){const l=$a(e),c=l?id(l):void 0;if(!l||!c)return e;const h=c.activeTerminalId,p=xc(c.root,h,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===l.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function U3(e){const t=$a(e),n=t?id(t):void 0;return n?gC(e,n.activeTerminalId):e}function K3(e,t){const n=$a(e);return!n||!n.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===n.id?{...s,activeTabId:t}:s)}}function u_(e,t,n){const s=e.workspaces.map(l=>{const c=l.tabs.findIndex(b=>b.id===t);if(c<0)return l;const h=l.tabs.slice(),[p]=h.splice(c,1);if(!p)return l;const g=Math.max(0,Math.min(h.length,n)),f=h.slice();return f.splice(g,0,p),q3(l.tabs,f)?l:{...l,tabs:f}});return s.every((l,c)=>l===e.workspaces[c])?e:{...e,workspaces:s}}function W3(e,t,n,s,l){if(n===s||!e.terminals[n]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(k=>k.id===t);if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y=Wl(b.root,n);if(!y){const k=g.tabs.filter((T,L)=>L!==f);return{...g,tabs:k}}const S={...b,root:y,activeTerminalId:Ni(y)[0]??b.activeTerminalId},w=g.tabs.slice();return w[f]=S,{...g,tabs:w}});const h=l==="left"||l==="right"?"vertical":"horizontal",p=l==="left"||l==="top";return c=c.map(g=>{const f=g.tabs.findIndex(T=>Ni(T.root).includes(s));if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y={type:"pane",terminalId:n},S={type:"split",direction:h,ratio:.5,first:p?y:{type:"pane",terminalId:s},second:p?{type:"pane",terminalId:s}:y},w=xc(b.root,s,S),k=g.tabs.slice();return k[f]={...b,root:w,activeTerminalId:n},{...g,tabs:k,activeTabId:b.id}}),vC({...e,workspaces:c})}function pC(e,t,n,s){let l=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(O=>O.id===t);if(A>=0){l=L,c=A;break}}if(l<0)return e;const h=e.workspaces[l],p=h.tabs[c],g=Ni(p.root);if(!g.includes(n))return e;if(g.length===1)return u_(e,t,s);const f=Wl(p.root,n);if(!f)return e;const b={...p,root:f,activeTerminalId:Ni(f)[0]??p.activeTerminalId},y=e.terminals[n],S={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},w=h.tabs.slice();w[c]=b;const k=Math.max(0,Math.min(w.length,s));w.splice(k,0,S);const T=e.workspaces.slice();return T[l]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:T}}function mC(e,t,n,s=Number.MAX_SAFE_INTEGER){const l=yC(e.workspaces,t),c=e.workspaces.find(f=>f.id===n);if(!l||!c)return e;if(l.workspace.id===n)return s===Number.MAX_SAFE_INTEGER?e:u_(e,t,s);const h=Ni(l.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===l.workspace.id)return Va({...f,tabs:f.tabs.filter(b=>b.id!==t)});if(f.id===n){const b=f.tabs.slice(),y=Math.max(0,Math.min(b.length,s));return b.splice(y,0,l.tab),{...f,defaultCwd:f.defaultCwd??fr(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:b,activeTabId:l.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:n}}function F3(e,t,n,s,l=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),h=yC(e.workspaces,t);if(!c||!h||!e.terminals[n]||!Ni(h.tab.root).includes(n))return e;if(h.workspace.id===s)return pC(e,t,n,l);if(Ni(h.tab.root).length===1)return mC(e,t,s,l);const g=Wl(h.tab.root,n);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Ni(g)[0]??h.tab.activeTerminalId},b=e.terminals[n],y={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return Va({...w,tabs:w.tabs.map(k=>k.id===t?f:k)});if(w.id===s){const k=w.tabs.slice(),T=Math.max(0,Math.min(k.length,l));return k.splice(T,0,y),{...w,defaultCwd:w.defaultCwd??fr(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(L=>L!==n),tabs:k,activeTabId:y.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function q3(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 $3(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 V3(e,t,n){const s=n.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===s?f:(l=!0,p=!0,{...f,title:s}));return p?{...h,tabs:g}:h});return l?{...e,workspaces:c}:e}function Y3(e,t){const n=e.workspaces.find(l=>l.tabs.some(c=>Fl(c.root,t))),s=n?.tabs.find(l=>Fl(l.root,t));return!n||!s?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(l=>l.id===n.id?{...l,activeTabId:s.id,tabs:l.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:l)}}function X3(e,t,n){const s=$a(e),l=s?id(s):void 0;if(!s||!l)return e;const c=ug(l.root,t,EC(n));return c===l.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===s.id?{...h,tabs:h.tabs.map(p=>p.id===l.id?{...p,root:c}:p)}:h)}}function rg(e,t,n,s){const l=Object.fromEntries(e.map(y=>[y.id,y])),c=new Set(e.map(y=>y.id)),h=new Set,p=!!(n&&n.some(y=>xC(y))||t&&t.some(y=>kC(y)));let g=e5(t,n,c,h);g.length===0&&(g=[nd()]);const f=typeof s=="string"&&g.some(y=>y.id===s)?s:g[0]?.id??null,b=f??g[0]?.id??td;for(const y of e)if(!h.has(y.id)){if(p)g=n5(g,b,y.id,y);else{const S=CC(y);g=s5(g,b,S,y)}h.add(y.id)}return{workspaces:g.map(y=>Va(r5(y,l))),activeWorkspaceId:f,terminals:l}}function Cc(e){return Ni(e.root)}function sg(e){return hg(e.root)}function zh(e){return h_([...e.tabs.flatMap(t=>Ni(t.root)),...e.detachedTerminalIds])}function Op(e){const t=e.workspaces.map(n=>{const s=n.tabs.flatMap(l=>{const c=og(l.root);return c?[{...l,root:c}]:[]});return Va({...n,tabs:s})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function G3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(s=>Fl(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function Z3(e,t,n){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:n}}}:e}function gC(e,t){const n={...e.terminals};return delete n[t],_C(e,t,n)}function Q3(e,t,n){if(!e.terminals[t])return e;const s=(n&&e.workspaces.some(c=>c.id===n)?n:null)??t5(e,t)?.id??i5(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??td,l=e.workspaces.find(c=>c.id===s);return!l||!SC(l,t)?e:_C(e,t,{...e.terminals},{detachToWorkspaceId:s})}function _C(e,t,n,s={}){let l=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=Wl(g.root,t);if(!f)continue;const b=Ni(f),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&p.push({...g,root:f,activeTerminalId:y})}return Va({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});s.detachToWorkspaceId&&n[t]&&(l=l.map(h=>h.id===s.detachToWorkspaceId?bC(h,t,n[t]):h));const c=l.some(h=>h.id===e.activeWorkspaceId);return{workspaces:l,activeWorkspaceId:c?e.activeWorkspaceId:l[0]?.id??null,terminals:n}}function J3(e,t){const n=e.workspaces.map(l=>{const c=[];for(const h of l.tabs){const p=ag(h.root,t);if(!p)continue;const g=Ni(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return Va({...l,tabs:c})}),s=n.some(l=>l.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:s?e.activeWorkspaceId:n[0]?.id??null}}function e5(e,t,n,s){if(t&&t.length>0){const l=[];for(const c of t)xC(c)&&l.push(U0(c,n,s));if(l.length>0)return l}return[U0({...nd(),tabs:e??[]},n,s)]}function U0(e,t,n){const s=[];for(const c of e.tabs){if(!kC(c))continue;const h=lg(c.root,t);if(!h)continue;const p=Ni(h);for(const f of p)n.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&s.push({...c,root:h,activeTerminalId:g})}const l=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),l.push(c));return Va({...e,defaultCwd:fr(e.defaultCwd),detachedTerminalIds:l,tabs:s})}function vC(e){return $a(e)?e:{...e,workspaces:[nd()],activeWorkspaceId:td}}function $a(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function id(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function yC(e,t){for(const n of e){const s=n.tabs.findIndex(l=>l.id===t);if(s>=0)return{workspace:n,tab:n.tabs[s],tabIndex:s}}return null}function t5(e,t){return e.workspaces.find(n=>n.tabs.some(s=>Fl(s.root,t)))}function i5(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function n5(e,t,n,s){return e.map(l=>l.id===t?bC(l,n,s):l)}function bC(e,t,n){return SC(e,t)?{...e,defaultCwd:e.defaultCwd??fr(n?.cwd),detachedTerminalIds:h_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function SC(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Vl}function wC(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function r5(e,t){if(e.defaultCwd)return e;const n=zh(e).find(l=>!!t[l]),s=n?fr(t[n]?.cwd):null;return s?{...e,defaultCwd:s}:e}function nd(){return{id:td,title:N3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Va(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:fr(e.defaultCwd),detachedTerminalIds:h_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function s5(e,t,n,s){const l=Ni(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??fr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!l.includes(h)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function CC(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function xc(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:xc(e.first,t,n),second:xc(e.second,t,n)}}function Wl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Wl(e.first,t),s=Wl(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function ag(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=ag(e.first,t),s=ag(e.second,t);return n&&s?{...e,first:n,second:s}:n??s}function lg(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=lg(e.first,t),s=lg(e.second,t);return n&&s?{...e,ratio:EC(e.ratio),first:n,second:s}:n??s}function og(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=og(e.first),n=og(e.second);return t&&n?{...e,first:t,second:n}:t??n}function xC(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 kC(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&cg(t.root)}function cg(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")&&cg(t.first)&&cg(t.second):!1}function ug(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[s,...l]=t;if(s===0){const c=ug(e.first,l,n);return c===e.first?e:{...e,first:c}}if(s===1){const c=ug(e.second,l,n);return c===e.second?e:{...e,second:c}}return e}function EC(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function fr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function h_(e){const t=new Set,n=[];for(const s of e)!s||t.has(s)||(t.add(s),n.push(s));return n}function Fl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Fl(e.first,t)||Fl(e.second,t)}function Ni(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ni(e.first),...Ni(e.second)]}function hg(e){return e.type==="pane"||e.type==="editor"?1:hg(e.first)+hg(e.second)}const ta=new Map,kc=new Map,Ec=new Map,Tc=new Map;function Gl(e){return e??"__local__"}function a5(e){return{agentId:e,state:A3(),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 Bt(e){const t=Gl(e);let n=ta.get(t);return n||(n=a5(e),ta.set(t,n)),n}function TC(e,t){const n=Gl(e);let s=kc.get(n);return s||(s=new Set,kc.set(n,s)),s.add(t),()=>{s.delete(t)}}function l5(e){const t=Gl(e),n=kc.get(t);if(n)for(const s of Array.from(n))s()}function Zl(e,t){ta.set(Gl(e),t),l5(e)}const dg=new Set;function o5(e){return dg.add(e),()=>{dg.delete(e)}}function Rl(e,t){const n=Bt(e),s=Gl(e);t.type==="workspace.hydrated"&&(Ec.delete(s),Tc.delete(s));const l=L3(n.state,t);let c=n.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],b=p5(s),y=m5(s);if(t.notifyCompletion===!0&&t.terminal.agentStatus)t.terminal.agentStatus.state==="working"&&y.add(t.terminal.id),t.terminal.agentStatus.state==="done"&&y.has(t.terminal.id)&&(h=F0(l,t.terminal.id,f?.currentCommand??null),y.delete(t.terminal.id)),t.terminal.agentStatus.state==="idle"&&y.delete(t.terminal.id),b.delete(t.terminal.id);else{const S=f?.activity==="busy",w=t.terminal.activity==="busy",k=t.terminal.activity==="idle";t.notifyCompletion===!0&&w&&b.add(t.terminal.id),t.notifyCompletion===!0&&S&&k&&b.has(t.terminal.id)&&(h=F0(l,t.terminal.id,f?.currentCommand??null)),(k||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(h){const S=DC(l,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==l.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),y.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=c5(l,t.tabId)?.tab??null;else{const y=l.workspaces.find(S=>S.id===t.workspaceId);f=y?.tabs.find(S=>S.id===y.activeTabId)??null}const b=f?Ni(f.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const S of b)y.delete(S);c=y}}const p=l!==n.state,g=c!==n.unreadCompletions;if((p||g)&&Zl(e,{...n,state:l,unreadCompletions:c}),g&&d_(),h)for(const f of Array.from(dg))f({agentId:e,...h})}function DC(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Ni(s.root).includes(t))return{workspace:n,tab:s};return null}function c5(e,t){for(const n of e.workspaces){const s=n.tabs.find(l=>l.id===t);if(s)return{workspace:n,tab:s}}return null}const fg=new Set;function u5(e){return fg.add(e),()=>{fg.delete(e)}}function h5(){let e=0;for(const t of ta.values())e+=t.unreadCompletions.size;return e}function d_(){for(const e of Array.from(fg))e()}function K0(e,t){const n=Bt(e);if(!n.unreadCompletions.has(t))return;const s=new Set(n.unreadCompletions);s.delete(t),Zl(e,{...n,unreadCompletions:s}),d_()}function W0(e,t){const n=Bt(e);t!==n.state&&Zl(e,{...n,state:t})}function zp(e,t){const n=Bt(e),s=t(n.editors);s!==n.editors&&Zl(e,{...n,editors:s})}function Ws(e,t,n){const s=Bt(e);s.loaded===t&&s.error===n||Zl(e,{...s,loaded:t,error:n})}function Vo(e,t,n){const s=Bt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===n||Zl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:n})}function d5(e){const t=Bt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function f5(e){const t=Gl(e),n=ta.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const s=n?n.unreadCompletions.size>0:!1;ta.delete(t),kc.delete(t),Ec.delete(t),Tc.delete(t),s&&d_()}function jp(){for(const e of ta.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}ta.clear(),kc.clear(),Ec.clear(),Tc.clear()}function p5(e){let t=Ec.get(e);return t||(t=new Set,Ec.set(e,t)),t}function m5(e){let t=Tc.get(e);return t||(t=new Set,Tc.set(e,t)),t}function F0(e,t,n){const s=DC(e,t);return s?{terminalId:t,tabId:s.tab.id,commandName:n}:null}function pg(e,t){let n=!1,s=!1,l=null,c=!1;for(const h of Cc(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,n=!0;continue}p.activity==="busy"?(s=!0,n=!0,!l&&p.currentCommand&&(l=p.currentCommand)):p.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:l}:{state:"idle",commandName:null}:null}function f_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function mg(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function g5(e,t,n,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function _5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:k}){const[T,L]=v.useState(null),[A,O]=v.useState(!1),[Y,P]=v.useState(null),q=v.useRef(null),re=e.findIndex(j=>j.id===t),ne=re>=0?e[re]:e[0]??null,ue=ne?pg(ne,n):null,ye=ne?sg(ne):0,U=ne?mg(ne,n):"No tab";v.useEffect(()=>{q.current?.focus(),q.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!A)return;const j=ae=>{ae.key==="Escape"&&O(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[A]),v.useEffect(()=>{A&&e.length===0&&O(!1)},[A,e.length]);function K(j,ae){L({tabId:j,title:ae})}function W(){if(!T)return;const j=T.title.trim();j&&w(T.tabId,j),L(null)}function H(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${ST()}`,onClick:y,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${wT()}`,onClick:S,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:p,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:U,onClick:()=>O(!0),disabled:e.length===0,children:[ue?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ue.state,"aria-hidden":"true",title:f_(ue)}):null,m.jsx("span",{children:U}),m.jsxs("small",{children:[re>=0?re+1:0,"/",e.length||0,ye>1?` / ${ye}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,ae)=>{const R=Cc(j),X=sg(j),Z=mg(j,n),Ce=j.id===t,Te=T?.tabId===j.id,M=pg(j,n),Q=s?.has(j.id)??!1;return m.jsxs(Mi.Fragment,{children:[m.jsx(q0,{index:ae}),m.jsx(v5,{tab:j,active:Ce,editing:Te,title:Z,paneCount:X,terminalIds:R,canClose:e.length>1,editValue:Te?T.title:null,editInputRef:Te?q:null,activity:M,unread:Q,onSelect:()=>c(j.id),onBeginRename:()=>K(j.id,Z),onCloseAll:()=>g(R),onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:he=>L({tabId:j.id,title:he})})]},j.id)}),m.jsx(q0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(l?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(j=>m.jsx(b5,{terminal:j,onReattach:()=>f?.(j.id),onDelete:()=>P(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),k?H():null]}),A?m.jsx(y5,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:T,editInputRef:q,onClose:()=>O(!1),onSelectTab:j=>{c(j),O(!1)},onCreateTab:()=>{h(),O(!1)},onBeginRename:K,onCloseTerminals:j=>{g(j),O(!1)},onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:(j,ae)=>L({tabId:j,title:ae}),onReattachTerminal:j=>{f?.(j),O(!1)},onDeleteTerminal:j=>{P(j),O(!1)}}):null,Y?m.jsx(S5,{terminal:Y,onCancel:()=>P(null),onConfirm:()=>{b?.(Y.id),P(null)}}):null]})}function v5({tab:e,active:t,editing:n,title:s,paneCount:l,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:b,onBeginRename:y,onCloseAll:S,onCommitRename:w,onCancelRename:k,onRenameChange:T}){const{attributes:L,listeners:A,setNodeRef:O,transform:Y,isDragging:P}=Ew({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),q={transform:Kp.Translate.toString(Y),opacity:P?.4:void 0,zIndex:P?2:void 0};return m.jsxs("div",{ref:O,className:"terminal-tab","data-active":t,"data-dragging":P,"data-unread":f?"true":void 0,style:q,...L,...A,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:f_(g)}):null,n&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:re=>{re.preventDefault(),w()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${s}`,value:h,onBlur:w,onChange:re=>T(re.target.value),onKeyDown:re=>{if(re.key==="Enter"){re.preventDefault(),w();return}re.key==="Escape"&&(re.preventDefault(),k())}}),m.jsx("small",{children:l})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:b,onDoubleClick:re=>{re.preventDefault(),y()},children:[m.jsx("span",{children:s}),m.jsxs("small",{children:[l," pane",l===1?"":"s"]})]}),c&&!n?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),S()},children:"x"}):null]})}function y5({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:b,onCloseTerminals:y,onCommitRename:S,onCancelRename:w,onRenameChange:k,onReattachTerminal:T,onDeleteTerminal:L}){const A=v.useRef(null);return v.useEffect(()=>{A.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:p,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:O=>O.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:p,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((O,Y)=>{const P=Cc(O),q=sg(O),re=mg(O,n),ne=O.id===t,ue=c?.tabId===O.id,ye=pg(O,n),U=s?.has(O.id)??!1;return m.jsxs("div",{ref:ne?A:null,className:"mobile-tab-sheet-row","data-active":ne,"data-unread":U?"true":void 0,children:[ue&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:K=>{K.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${re}`,value:c.title,onBlur:S,onChange:K=>k(O.id,K.target.value),onKeyDown:K=>{if(K.key==="Enter"){K.preventDefault(),S();return}K.key==="Escape"&&(K.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${re}`,onClick:()=>g(O.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:re}),m.jsx("small",{children:g5(O,n,q,ye)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ye?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ye.state,"aria-hidden":"true",title:f_(ye)}):null,m.jsx("span",{children:q})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ue?m.jsx("button",{type:"button","aria-label":`Done renaming ${re}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${re}`,onClick:()=>b(O.id,re),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${re}`,onClick:()=>y(P),children:"×"}):null]})]},O.id)}),(l?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(l??[]).map(O=>{const Y=O.title||O.cwd||O.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>T(O.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:Y}),m.jsx("small",{children:O.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>L(O),children:"×"})})]},O.id)})]}):null]})]})})}function q0({index:e}){const{setNodeRef:t,isOver:n}=Mg({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function b5({terminal:e,onReattach:t,onDelete:n}){const s=e.title||e.cwd||e.id.slice(0,8),l=`${e.title||"Terminal"}
54
+ ${e.cwd}
55
+ (detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:l,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function S5({terminal:e,onCancel:t,onConfirm:n}){const s=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:l=>l.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:s}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function w5({uploads:e,onDismiss:t,onDismissAll:n,onRetry:s,onCancel:l}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",p=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${T5(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?ph(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(C5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>l(g.id)},g.id))})]})}function C5({upload:e,compact:t,onDismiss:n,onRetry:s,onCancel:l}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":ph(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:ph(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:l,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${ph(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(x5,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(k5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function x5({toast:e}){const t=e.percent===null?D5(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function k5({response:e,compact:t}){const n=e.results.filter(h=>h.status==="failed"),s=e.results.filter(h=>h.status==="uploaded"),l=t?3:6,c=[...n,...s].slice(0,l);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,p)=>m.jsx(E5,{result:h},`${h.relativePath}-${p}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function E5({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),n?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function ph(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 T5(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 D5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function R5({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const s=e,l=s.commandName?`${s.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),n()}function h(p){p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(s)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:s.tabTitle}),m.jsx("span",{children:l})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:p=>p.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const M5=sc(0,0,1,1),ts=1e-6;function N5(e){return RC(e).map(t=>t.terminalId)}function RC(e){return rc(e,M5).sort(O5).map((t,n)=>({...t,index:n+1}))}function A5(e,t,n){const s=RC(e),l=s.find(h=>h.terminalId===t);return l?s.filter(h=>h.terminalId!==t).map(h=>B5(l,h,n)).filter(h=>h!==null).sort(z5)[0]?.entry.terminalId??null:null}function L5(e,t){return!Number.isInteger(t)||t<1?null:N5(e)[t-1]??null}function rc(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=j5(e.ratio);if(e.direction==="vertical"){const l=t.left+(t.right-t.left)*n;return[...rc(e.first,sc(t.left,t.top,l,t.bottom)),...rc(e.second,sc(l,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*n;return[...rc(e.first,sc(t.left,t.top,t.right,s)),...rc(e.second,sc(t.left,s,t.right,t.bottom))]}function B5(e,t,n){const s=e.bounds,l=t.bounds,c=$0(s.left,s.right,l.left,l.right),h=$0(s.top,s.bottom,l.top,l.bottom);switch(n){case"left":return l.centerX>=s.centerX-ts||h<=ts?null:{entry:t,primaryDistance:Math.max(0,s.left-l.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"right":return l.centerX<=s.centerX+ts||h<=ts?null:{entry:t,primaryDistance:Math.max(0,l.left-s.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"up":return l.centerY>=s.centerY-ts||c<=ts?null:{entry:t,primaryDistance:Math.max(0,s.top-l.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};case"down":return l.centerY<=s.centerY+ts||c<=ts?null:{entry:t,primaryDistance:Math.max(0,l.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};default:return null}}function O5(e,t){return zl(e.bounds.top,t.bounds.top)||zl(e.bounds.left,t.bounds.left)}function z5(e,t){return zl(e.primaryDistance,t.primaryDistance)||zl(e.perpendicularDistance,t.perpendicularDistance)||zl(t.overlap,e.overlap)||zl(e.entry.index,t.entry.index)}function zl(e,t){const n=e-t;return Math.abs(n)<=ts?0:n}function $0(e,t,n,s){return Math.max(0,Math.min(t,s)-Math.max(e,n))}function sc(e,t,n,s){return{left:e,top:t,right:n,bottom:s,centerX:e+(n-e)/2,centerY:t+(s-t)/2}}function j5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class P5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function V0(e){return e?Array.from(e.types??[]).includes("Files")||LC(e.items).some(n=>n.kind==="file")?!0:BC(e.files).length>0:!1}async function H5(e){const t=LC(e.items).filter(n=>n.kind==="file");return t.length>0?I5(t):U5(e.files)}async function I5(e){const t=[];for(const n of e){const s=q5(n);if(s){await MC(s,"",t);continue}const l=n.getAsFile();if(l){t.push({relativePath:NC(l),file:l});continue}throw new P5("Folder upload is not supported by this browser.")}return t}function U5(e){return BC(e).map(t=>({relativePath:NC(t),file:t}))}async function MC(e,t,n){const s=V5(t,e.name);if(e.isFile){const h=await K5(e);n.push({relativePath:s,file:h});return}if(!e.isDirectory)return;const l=e.createReader(),c=await W5(l);for(const h of c)await MC(h,s,n)}function K5(e){return new Promise((t,n)=>{e.file(t,s=>n(s))})}async function W5(e){const t=[];for(;;){const n=await F5(e);if(n.length===0)return t;t.push(...n)}}function F5(e){return new Promise((t,n)=>{e.readEntries(t,s=>n(s))})}function NC(e){const t=e.webkitRelativePath;return AC(typeof t=="string"&&t?t:e.name)}function q5(e){const t=e.webkitGetAsEntry?.();return $5(t)?t:null}function $5(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 V5(e,t){return AC(e?`${e}/${t}`:t)}function AC(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function LC(e){return e?Array.from(e):[]}function BC(e){return e?Array.from(e):[]}const Y0="nterminal.terminalWorkspaces.v2",OC="nterminal.sidebarCollapsed.v1",Y5=75,X0=Rw.map(e=>e.url),X5=Rw[0].url,G5=6;function Z5({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s,sessionExpiresAt:l=null,previewMode:c=!1,onLogout:h=async()=>{},onSessionInvalid:p}){const g=v.useMemo(()=>e??Hh(),[e]),f=v.useMemo(()=>t??pc(null),[t]),b=v.useMemo(()=>vL(n),[n]),y=v.useMemo(()=>C=>TC(n,C),[n]),S=v.useMemo(()=>()=>Bt(n),[n]),w=v.useSyncExternalStore(y,S,S),k=w.state,T=w.editors,L=!w.loaded,A=w.error,[O,Y]=v.useState(!1),[P,q]=v.useState(()=>kL()),[re,ne]=v.useState("servers"),[ue,ye]=v.useState(!1),U=v.useSyncExternalStore(AT,bS,bS);v.useSyncExternalStore(Ch,yS,yS);const[K,W]=v.useState(0),[H,j]=v.useState(null),[ae,R]=v.useState(()=>[null]),[X,Z]=v.useState(0),[Ce,Te]=v.useState(()=>[n]),[M,Q]=v.useState(()=>new Set),[he,ge]=v.useState({}),[_e,Se]=v.useState(null),Ee=v.useRef(0),De=v.useRef(0),[Ie,se]=v.useState(null),[me,Le]=v.useState(null),be=v.useRef(null),Me=v.useRef(0),Pe=v.useRef(null),je=v.useRef(null),ie=v.useRef(null),xe=v.useRef(null),Re=v.useRef(()=>{}),[Be,Oe]=v.useState(null),rt=oE(eS(Sw,{activationConstraint:{distance:8}}),eS(ww,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>LT(g),[g]);function qt(C){const E=C.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Oe({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Oe({tabId:E.sourceTabId,terminalId:E.terminalId})}}function wt(C){Oe(null);const E=C.active.data.current,B=C.over?.data.current;if(!(!E||!B||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){We({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){We({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&We({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:B.terminalId,side:B.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(B.kind==="tab-position"&&typeof B.index=="number"){We({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:B.index});return}if(B.kind==="workspace"&&typeof B.workspaceId=="string"){We({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:B.workspaceId});return}B.kind==="pane-zone"&&typeof B.terminalId=="string"&&(B.side==="top"||B.side==="right"||B.side==="bottom"||B.side==="left")&&We({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:B.terminalId,side:B.side})}}}function Ki(){Oe(null)}const nt=k.workspaces.find(C=>C.id===k.activeWorkspaceId)??k.workspaces[0],pt=nt?.tabs.find(C=>C.id===nt.activeTabId)??nt?.tabs[0],fe=pt?.activeTerminalId??null,Ue=fe?k.terminals[fe]:void 0,st=dL("(max-width: 760px)"),at=v.useMemo(()=>pt?jh(pt.root):[],[pt]),Et=nt&&pt?ac(n,nt.id,pt.id):null,Tt=pt?zC(at,pt.activeTerminalId,Et?he[Et]:void 0):null,Dt=st&&at.length>1,Rt=v.useMemo(()=>(nt?.detachedTerminalIds??[]).flatMap(C=>{const E=k.terminals[C];return E?[E]:[]}),[nt?.detachedTerminalIds,k.terminals]),F=v.useMemo(()=>{const C=new Set;for(const E of nt?.tabs??[])Cc(E).some(B=>w.unreadCompletions.has(B))&&C.add(E.id);return C},[nt?.tabs,w.unreadCompletions]),[qe,mt]=v.useState([]),$t=v.useRef([]),Si=v.useRef(null),[Zi,Ct]=v.useState(null),[_t,Pt]=v.useState(null),[li,wi]=v.useState([]),[jt,Li]=v.useState(()=>Ia()),Gt=v.useRef(0),Ht=v.useRef(n),Wi=v.useRef(X0),bt=v.useRef(jt),oi=v.useRef(()=>{});oi.current=nr,Re.current=Or;const Fi=v.useCallback(async()=>{try{const C=await g.listNotificationAssets();wi(C.assets.filter(E=>E.enabled).map(E=>E.url))}catch{wi([])}},[g]);v.useEffect(()=>{Te(C=>C.some(E=>nn(E,n))?C:[...C,n])},[n]);const Ci=v.useCallback(C=>{const E=Bt(C),B=pc(C);for(const te of Object.keys(E.state.terminals))ic(B.createWebSocketUrl(te)),Ju(te);f5(C),Te(te=>te.filter(ve=>!nn(ve,C))),Q(te=>{const ve=`${gh(C)}:`;let pe=!1;const we=new Set;for(const $e of te){if($e.startsWith(ve)){pe=!0;continue}we.add($e)}return pe?we:te}),ge(te=>{const ve=`${gh(C)}:`;let pe=!1;const we={};for(const[$e,et]of Object.entries(te)){if($e.startsWith(ve)){pe=!0;continue}we[$e]=et}return pe?we:te})},[]);v.useEffect(()=>{let C=!1;return g.listAgents().then(E=>{if(!C){const B=E.agents.map(ve=>ve.id),te=[null,...B];n!==null&&!B.includes(n)&&(Ci(n),s?.(null)),R(te)}}).catch(()=>{}),()=>{C=!0}},[n,g,Ci,s,X]);const sn=v.useCallback(C=>{Ci(C),Z(E=>E+1),nn(C,Ht.current)&&s?.(null)},[Ci,s]);v.useEffect(()=>{R(C=>C.some(E=>nn(E,n))?C:[...C,n])},[n]),v.useEffect(()=>{Ht.current=n},[n]),v.useEffect(()=>{j(null)},[n]),v.useEffect(()=>{const C=Pe.current;if(!C)return;if(!nn(C.agentId,n)){Pe.current=null;return}if(!w.loaded||k.workspaces.length===0)return;Pe.current=null;const E=C.edge==="first"?k.workspaces[0]:k.workspaces[k.workspaces.length-1];E&&E.id!==k.activeWorkspaceId&&We({type:"workspace.selected",workspaceId:E.id})},[n,w.loaded,k.activeWorkspaceId,k.workspaces]),v.useEffect(()=>{const C=je.current;if(C){if(!nn(C.agentId,n)){je.current=null;return}w.loaded&&(je.current=null,k.workspaces.some(E=>E.id===C.workspaceId)&&We({type:"workspace.selected",workspaceId:C.workspaceId}))}},[n,w.loaded,k.workspaces]),v.useEffect(()=>{const C=ie.current;if(C){if(!nn(C.agentId,n)){ie.current=null;return}w.loaded&&(ie.current=null,w.error||xi())}},[n,w.error,w.loaded]),v.useEffect(()=>{fn()},[n,w.loaded,k]),v.useEffect(()=>{const C=()=>{const te=pL();te&&Re.current(te)},E=te=>{const ve=mL(te.data);ve&&Re.current(ve)},B=te=>{const ve=qh(te.detail);ve&&Re.current(ve)};return C(),window.addEventListener("hashchange",C),window.addEventListener(Yp,B),navigator.serviceWorker?.addEventListener?.("message",E),()=>{window.removeEventListener("hashchange",C),window.removeEventListener(Yp,B),navigator.serviceWorker?.removeEventListener?.("message",E)}},[]),v.useEffect(()=>{Fi()},[Fi]),v.useEffect(()=>Nw(()=>Li(Ia())),[]),v.useEffect(()=>{const C=E=>{oi.current(E)};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[]),v.useEffect(()=>{Wi.current=li.length>0?li:X0},[li]),v.useEffect(()=>{bt.current=jt},[jt]),v.useEffect(()=>{if(!w.loaded||!nt||!pt)return;const C=ac(n,nt.id,pt.id);Q(E=>{if(E.has(C))return E;const B=new Set(E);return B.add(C),B})},[n,w.loaded,nt?.id,pt?.id]),v.useEffect(()=>()=>{Hn()},[]),v.useEffect(()=>H2(g),[g]),v.useEffect(()=>o5(C=>{const E=Bt(C.agentId).state,B=E.workspaces.flatMap(we=>we.tabs).find(we=>we.id===C.tabId),te=E.terminals[C.terminalId],ve=B?.title?.trim()||te?.title||C.commandName||"terminal",pe=document.visibilityState==="visible"&&nn(C.agentId,Ht.current)&&C.tabId===_L(E);if(pe||A2({agentId:C.agentId,tabTitle:ve,commandName:C.commandName,terminalId:C.terminalId}),!pe&&document.visibilityState==="visible"&&bt.current.enabled){const we=Gt.current+1;Gt.current=we;const $e=Wi.current;Ct({id:we,agentId:C.agentId,terminalId:C.terminalId,tabId:C.tabId,tabTitle:ve,commandName:C.commandName,assetSrc:$e[Math.floor(Math.random()*$e.length)]??X5})}}),[]),v.useEffect(()=>{if(!Zi||jt.persistUntilDismissed)return;const C=window.setTimeout(()=>{Ct(E=>E?.id===Zi.id?null:E)},jt.durationSeconds*1e3);return()=>window.clearTimeout(C)},[Zi,jt]),v.useEffect(()=>{EL(P),P&&Bi()},[P]),v.useEffect(()=>{let C=!1;async function E(){if(!Bt(n).loaded){Ws(n,!1,null);try{let te=null,ve=null;try{te=yL(b)}catch(et){if(!(et instanceof Ph))throw et;ve=et}const[pe,we]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),$e=pe.terminals.length>0?pe.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!C){const et=we.layout?PC(we.layout):null;if(!et&&ve)throw ve;const Ut=et??te??{},Vt=rg($e,void 0,Ut.savedWorkspaces,Ut.savedActiveWorkspaceId),D=Op(Vt);W0(n,Vt),Vo(n,we.revision,JSON.stringify(D)),Ws(n,!0,null),!et&&te&&ln(D,{baseRevision:we.revision})}}catch(te){!C&&!Br(te)&&Ws(n,!0,Fs(te))}}}return E(),()=>{C=!0}},[n,f,K]);function dn(){Ws(n,!1,null),W(C=>C+1)}function Bi(){Ee.current+=1,De.current+=1,Se(null)}function ei(C){Ee.current+=1,De.current+=1,Se(E=>E&&{...E,cwd:C,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function xi(){Ee.current+=1,De.current+=1;const C=k.workspaces.length+1,E=Qi();Se({mode:"create",workspaceId:null,title:`Workspace ${C}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&na(E)}function wn(C){if(nn(C,n)){xi();return}ie.current={agentId:C},s?.(C)}function ia(C){if(P&&!O)return;const E=k.workspaces.find(te=>te.id===C);if(!E)return;Ee.current+=1,De.current+=1;const B=E.defaultCwd??Ue?.cwd??"";Se({mode:"edit",workspaceId:C,title:E.title,cwd:B,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),B&&na(B)}function Qi(){return nt?.defaultCwd??Ue?.cwd??""}async function na(C){const E=Ee.current+1;Ee.current=E;const B=C.trim();if(Se(te=>te&&{...te,cwd:C,browseStatus:B?"loading":"idle",browseRoot:null,browseEntries:[],error:B?null:"Choose a default working directory."}),!!B)try{const te=await f.createFileRoot({path:B}),ve=await f.listFiles({rootToken:te.rootToken,path:""});if(Ee.current!==E)return;Se(pe=>pe&&{...pe,cwd:te.rootPath,browseRoot:{rootToken:te.rootToken,rootPath:te.rootPath},browseEntries:ve.entries.filter(we=>we.kind==="directory"),browseStatus:"idle",error:null})}catch(te){if(Ee.current!==E)return;Se(ve=>ve&&{...ve,browseStatus:"idle",error:Fs(te)})}}async function ra(){const C=_e;if(!C)return;const E=C.title.trim(),B=C.cwd.trim();if(!E||!B){Se({...C,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const te=De.current+1;De.current=te,Se({...C,submitStatus:"submitting",error:null});try{const ve=await f.createFileRoot({path:B});if(De.current!==te)return;if(C.mode==="create"){const pe=k.workspaces.length+1;We({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${pe}`,title:E,defaultCwd:ve.rootPath})}else C.workspaceId&&(We({type:"workspace.renamed",workspaceId:C.workspaceId,title:E}),We({type:"workspace.defaultCwdChanged",workspaceId:C.workspaceId,defaultCwd:ve.rootPath}));Se(null)}catch(ve){if(De.current!==te)return;Se(pe=>pe&&{...pe,submitStatus:"idle",error:Fs(ve)})}}function Nr(C){De.current+=1,Se(C)}function Ar(C,E,B){if(C===E)return;const te=k.workspaces.some(pe=>pe.id===C),ve=k.workspaces.some(pe=>pe.id===E);!te||!ve||We({type:"workspace.reordered",sourceWorkspaceId:C,targetWorkspaceId:E,placement:B})}function On(C,E){const B=k.workspaces.findIndex(ve=>ve.id===C),te=k.workspaces[B+E];B<0||!te||Ar(C,te.id,E<0?"before":"after")}function pr(C,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),be.current={sourceId:C,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function mr(C){const E=be.current;if(!E||E.pointerId!==C.pointerId)return;const B=Math.hypot(C.clientX-E.startX,C.clientY-E.startY);if(!E.active){if(B<G5)return;E.active=!0,se(E.sourceId)}const ve=document.elementFromPoint(C.clientX,C.clientY)?.closest("[data-workspace-id]"),pe=ve?.dataset.workspaceId??null;if(!ve||!pe||pe===E.sourceId||!k.workspaces.some(et=>et.id===pe)){E.targetId=null,Le(null);return}const we=ve.getBoundingClientRect(),$e=C.clientY<we.top+we.height/2?"before":"after";E.targetId=pe,E.placement=$e,Le({workspaceId:pe,placement:$e})}function tr(C){const E=be.current;!E||E.pointerId!==C.pointerId||(C.preventDefault(),C.stopPropagation(),C.currentTarget.releasePointerCapture?.(C.pointerId),be.current=null,se(null),Le(null),E.active&&E.targetId&&Ar(E.sourceId,E.targetId,E.placement))}function It(C){const E=be.current;E&&E.pointerId===C.pointerId&&C.currentTarget.releasePointerCapture?.(C.pointerId),be.current=null,se(null),Le(null)}async function sa(){await qi(async()=>{const C=nt?.defaultCwd?{cols:80,rows:24,cwd:nt.defaultCwd}:{cols:80,rows:24},E=await f.createTerminal(C);We({type:"terminal.created",terminal:E.terminal})})}async function Lr(C){await qi(async()=>{const E=fe?{parentTerminalId:fe,cols:80,rows:24}:nt?.defaultCwd?{cols:80,rows:24,cwd:nt.defaultCwd}:{cols:80,rows:24},B=await f.createTerminal(E);We({type:"terminal.split",terminal:B.terminal,direction:C})})}async function ir(C){let E=fe,B=Et;const te=nt?.defaultCwd?.trim();if(!E&&!te)throw new Error("No active pane is available.");const ve=await f.readFile(C);if(!E&&te){const $e=await f.createTerminal({cols:80,rows:24,cwd:te});E=$e.terminal.id,We({type:"terminal.created",terminal:$e.terminal})}if(E){We({type:"pane.selected",terminalId:E});const $e=Bt(n).state,et=$e.workspaces.find(Vt=>Vt.id===$e.activeWorkspaceId)??$e.workspaces[0],Ut=et?.tabs.find(Vt=>Vt.id===et.activeTabId)??et?.tabs[0];B=et&&Ut?ac(n,et.id,Ut.id):null}const pe=`editor-${Date.now().toString(36)}-${d5(n)}`,we=xL(ve.path);zp(n,$e=>({...$e,[pe]:{id:pe,title:we,rootToken:C.rootToken,path:ve.path,read:ve}})),B&&ge($e=>({...$e,[B]:jC(pe)})),We({type:"editor.split",editorId:pe,title:we,direction:"vertical"})}function gr(C){zp(n,E=>{const B={...E};return delete B[C],B}),We({type:"editor.closed",editorId:C})}function Ql(C){as([C])}function as(C){const E=[...new Set(C)].filter(te=>k.terminals[te]);if(E.length===0)return;const B=E.length===1?k.terminals[E[0]]?.title||k.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;j(null),Pt({terminalIds:E,label:B,workspaceId:nt?.id??k.activeWorkspaceId??null})}function aa(C,E){const B=Ya(C,E);if(!B)return!1;const te=C.filter(ve=>!B.detachedTerminalIds.includes(ve));if(B.detachedTerminalIds.length+te.length>Vl)return j(SL(B.detachedTerminalIds.length)),!1;j(null);for(const ve of C)We(B.id?{type:"terminal.detached",terminalId:ve,workspaceId:B.id}:{type:"terminal.detached",terminalId:ve});return!0}async function Jl(C){await qi(async()=>{for(const E of C)await cs(E),ic(f.createWebSocketUrl(E)),Ju(E),We({type:"terminal.closed",terminalId:E})})}async function ls(C){const E=k.workspaces.find(B=>B.id===C);!E||k.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await qi(async()=>{const B=zh(E),te=[];let ve=null;for(const we of B)try{await cs(we)}catch($e){te.push(Fs($e)),$e instanceof hr&&$e.status===401&&!f.isAgent&&(ve=$e)}finally{ic(f.createWebSocketUrl(we)),Ju(we)}const pe=E.tabs.flatMap(we=>gg(we.root));if(pe.length>0){const we=new Set(pe);zp(n,$e=>{const et={...$e};for(const Ut of we)delete et[Ut];return et})}if(We({type:"workspace.closed",workspaceId:C}),ve)throw ve;if(te.length>0)throw new Error(`Workspace was removed, but ${te.length} terminal session${te.length===1?"":"s"} may still be running. ${te[0]}`)})}async function os(C){await qi(async()=>{await cs(C),ic(f.createWebSocketUrl(C)),Ju(C),We({type:"terminal.closed",terminalId:C})})}async function an(C,E){const B=E.trim();if(!B)return;let te=null;for(const ve of k.workspaces){const pe=ve.tabs.find(we=>we.id===C);if(pe){te=pe.activeTerminalId;break}}if(We({type:"tab.renamed",tabId:C,title:B}),!!te)try{const ve=await f.renameTerminal(te,B);hs({type:"terminal.updated",terminal:ve.terminal})}catch(ve){Ws(n,!0,Fs(ve))}}function Ji(C){const E=k.terminals[C];E&&We({type:"terminal.created",terminal:E})}async function cs(C){try{await f.closeTerminal(C)}catch(E){if(E instanceof hr&&E.status===404)return;throw E}}async function us(){await qi(async()=>{await h()})}async function qi(C){Ws(n,!0,null);try{await C()}catch(E){if(Br(E))return;Ws(n,!0,Fs(E))}}function Br(C){return C instanceof hr&&C.status===401&&!f.isAgent&&p?(p({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function We(C){Rl(n,C);const E=Bt(n),B=E.state;if(!E.loaded||B.workspaces.length===0)return;const te=Op(B);JSON.stringify(te)!==E.lastPersistedLayoutJson&&br(te)}function hs(C){Rl(n,C)}function ki(C,E,B,te){const ve=ac(C,E,B);ge(pe=>({...pe,[ve]:te}))}function zn(C){Et&&ge(E=>({...E,[Et]:C}))}function ti(C,E){const B=fc(C);E?ki(n,E.workspaceId,E.tabId,B):zn(B),We({type:"pane.selected",terminalId:C})}function la(C){zn(C.key),C.type==="terminal"&&We({type:"pane.selected",terminalId:C.terminalId})}function nr(C){if(ue||_t||C.isComposing||C.key==="Process"||nL(C.target))return;const E=J5(C);if(!E)return;if(C.preventDefault(),C.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){oa(E.type==="server.next"?1:-1);return}const B=Bt(n).state,te=B.workspaces.find(we=>we.id===B.activeWorkspaceId)??B.workspaces[0],ve=te?.tabs.find(we=>we.id===te.activeTabId)??te?.tabs[0];if(E.type==="split"){if(!ve)return;Lr(E.direction);return}if(!te||!ve)return;if(E.type==="tab.previous"||E.type==="tab.next"){const we=iL(te.tabs,ve.id,E.type==="tab.next"?1:-1);we&&We({type:"tab.selected",tabId:we.id});return}if(E.type==="tab.index"){const we=te.tabs[E.index-1];we&&We({type:"tab.selected",tabId:we.id});return}const pe=eL(ve.root,ve.activeTerminalId,E);pe&&ti(pe,{workspaceId:te.id,tabId:ve.id})}function ds(C,E){if(!s||ae.length===0)return;const B=ae.findIndex(we=>nn(we,n)),ve=((B===-1?0:B)+C+ae.length)%ae.length,pe=ae[ve]??null;nn(pe,n)||(E&&(Pe.current={agentId:pe,edge:E}),s(pe))}function oa(C){const E=Bt(n).state,B=E.workspaces;if(B.length===0){ds(C,C===1?"first":"last");return}const te=B.findIndex(we=>we.id===E.activeWorkspaceId),pe=(te===-1?0:te)+C;if(pe>=0&&pe<B.length){We({type:"workspace.selected",workspaceId:B[pe].id});return}ds(C,C===1?"first":"last")}function _r(C,E){if(nn(C,n)){We({type:"workspace.selected",workspaceId:E});return}je.current={agentId:C,workspaceId:E},s?.(C)}function Ya(C,E){if(E)return k.workspaces.find(B=>B.id===E)??null;for(const B of C){const te=k.workspaces.find(pe=>pe.tabs.some(we=>Cc(we).includes(B)));if(te)return te;const ve=k.workspaces.find(pe=>pe.detachedTerminalIds.includes(B));if(ve)return ve}return k.workspaces.find(B=>B.id===k.activeWorkspaceId)??k.workspaces[0]??null}function jn(C){V0(C.dataTransfer)&&(C.preventDefault(),C.dataTransfer.dropEffect="copy")}function fs(C){if(!V0(C.dataTransfer))return;C.preventDefault();const E=wL(Bt(n).state),B=Me.current+1;if(Me.current=B,!E){vr({id:B,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}vr({id:B,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),ca(B,E.id,C.dataTransfer)}async function ca(C,E,B){try{const te=await H5(B);if(te.length===0)throw new Error("No files were found in the drop.");ii(C,{id:C,status:"queued",fileCount:te.length,message:"Queued"},{terminalId:E,files:te})}catch(te){ii(C,{id:C,status:"failed",fileCount:0,message:Fs(te)},{terminalId:E})}finally{ps()}}async function Xa(C){const E=$t.current.find(pe=>pe.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const B=E.terminalId,te=E.files,ve=new AbortController;Si.current=C,ii(C,{id:C,status:"uploading",fileCount:te.length,loaded:0,total:null,percent:null},{terminalId:B,files:te,abortController:ve});try{const pe=await qT({terminalId:B,files:te,signal:ve.signal,onProgress:Ut=>{ii(C,{id:C,status:"uploading",fileCount:te.length,loaded:Ut.loaded,total:Ut.total,percent:Ut.percent},{terminalId:B,files:te,abortController:ve})}}),we=pe.failed>0?pe.uploaded>0?"partial":"failed":"success",$e=pe.failed>0?CL(pe):void 0,et={id:C,status:we,fileCount:te.length,response:pe};$e&&(et.message=$e),ii(C,et,{terminalId:B,files:te})}catch(pe){ii(C,{id:C,status:"failed",fileCount:te.length,message:ve.signal.aborted?"Upload canceled.":Fs(pe)},{terminalId:B,files:te})}finally{Si.current===C&&(Si.current=null),ps()}}function ps(){if(Si.current!==null)return;const C=$t.current.find(E=>E.status==="queued");C?.terminalId&&C.files&&C.files.length>0&&Xa(C.id)}function vr(C){Pn(E=>[...E,C])}function ii(C,E,B={}){Pn(te=>te.map(ve=>{if(ve.id!==C)return ve;const pe={...E},we=B.terminalId??ve.terminalId,$e=B.files??ve.files;return we!==void 0&&(pe.terminalId=we),$e!==void 0&&(pe.files=$e),B.abortController!==void 0&&(pe.abortController=B.abortController),pe}))}function Pn(C){const E=C($t.current);$t.current=E,mt(E)}function rr(C){$t.current.find(B=>B.id===C)?.abortController?.abort(),Si.current===C&&(Si.current=null),Pn(B=>B.filter(te=>te.id!==C)),ps()}function yr(){for(const C of $t.current)C.abortController?.abort();Si.current=null,Pn(()=>[])}function sr(C){const E=$t.current.find(B=>B.id===C);if(E){if(E.status==="queued"){rr(C);return}E.abortController?.abort()}}function Ga(C){const E=$t.current.find(te=>te.id===C);if(!E?.terminalId||!E.files||E.files.length===0)return;const B=ms(E);if(B.length===0){ii(C,{id:C,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}ii(C,{id:C,status:"queued",fileCount:B.length,message:"Queued"},{terminalId:E.terminalId,files:B}),ps()}function ms(C){const E=C.files??[],B="response"in C?C.response:void 0;if(!B)return E;const te=B.results.filter(we=>we.status==="failed").map(we=>we.relativePath);if(te.length===0)return[];const ve=new Map;for(const we of E){const $e=ve.get(we.relativePath)??[];$e.push(we),ve.set(we.relativePath,$e)}const pe=[];for(const we of te){const et=ve.get(we)?.shift();et&&pe.push(et)}return pe}function Za(C){const B=Bt(C.agentId).state.workspaces.find(te=>te.tabs.some(ve=>ve.id===C.tabId));B&&ki(C.agentId,B.id,C.tabId,fc(C.terminalId)),Rl(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),K0(C.agentId,C.terminalId),nn(C.agentId,n)||s?.(C.agentId),Ct(null)}function Or(C){if(xe.current=C,!nn(C.agentId,n)){s?s(C.agentId):xe.current=null;return}fn()}function fn(){const C=xe.current;if(!C||!nn(C.agentId,n)||!w.loaded)return;const E=Bt(C.agentId),B=gL(E.state,C.terminalId);xe.current=null,B&&(ki(C.agentId,B.workspaceId,B.tabId,fc(C.terminalId)),Rl(C.agentId,{type:"pane.selected",terminalId:C.terminalId}),K0(C.agentId,C.terminalId))}function br(C){const E=Bt(n).mutable.saveCoord;E.pendingLayoutSave=C,Yo(C,b),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const B=E.pendingLayoutSave;E.pendingLayoutSave=null,B&&ln(B)},Y5)}function Hn(){const C=Bt(n).mutable.saveCoord;C.saveTimer!==null&&(window.clearTimeout(C.saveTimer),C.saveTimer=null);const E=C.pendingLayoutSave;C.pendingLayoutSave=null,E&&(Yo(E,b),ln(E))}function ln(C,E={}){const B=Bt(n).mutable.saveCoord;B.nextPersistLayout=C,E.baseRevision!==void 0&&(B.queuedBaseRevision=E.baseRevision),!B.nextPersistQueued&&(B.nextPersistQueued=!0,B.persistChain=B.persistChain.then(async()=>{B.nextPersistQueued=!1;const te=B.nextPersistLayout,ve=B.queuedBaseRevision;B.nextPersistLayout=null,B.queuedBaseRevision=void 0,te&&await gs(te,ve!==void 0?{baseRevision:ve}:{})}))}async function gs(C,E={}){const B=Bt(n),te=E.baseRevision??B.layoutRevision,ve={layout:C,...typeof te=="number"?{baseRevision:te}:{}};try{const pe=await f.saveTerminalLayout(ve),we=pe.layout??C;Vo(n,pe.revision,JSON.stringify(we)),Yo(we,b);return}catch(pe){if(pe instanceof hr&&pe.status===400&&pe.message===m2){bL(n,b),Ws(n,!0,HC());return}if(pe instanceof hr&&pe.status===409)try{const we=await f.getTerminalLayout(),$e=Bt(n).mutable.saveCoord;if($e.nextPersistLayout||$e.pendingLayoutSave){const et=we.layout?JSON.stringify(we.layout):Bt(n).lastPersistedLayoutJson;Vo(n,we.revision,et);return}if(we.layout){const et=Bt(n).state,Ut=rg(Object.values(et.terminals),void 0,we.layout.workspaces,we.layout.activeWorkspaceId),Vt=Op(Ut);W0(n,Ut),Vo(n,we.revision,JSON.stringify(Vt)),Yo(Vt,b)}else Vo(n,we.revision,B.lastPersistedLayoutJson);return}catch{}Yo(C,b)}}const _s=TL(l),pn=!P||O,ar=pn?re:"servers";function zr(C){const E=C.active?w:Bt(C.agentId),B=C.active?k:E.state,te=C.active?w.loaded:E.loaded,ve=C.active?A:E.error;return m.jsxs("div",{className:`workspace-list-panel${C.active?" workspace-list-panel--active-server":""}`,"aria-label":`${C.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${C.label}`,title:"New workspace",onClick:()=>wn(C.agentId),children:"+"})]}),te?ve?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(C.agentId),children:ve}):m.jsx("div",{className:"workspace-list-items",children:B.workspaces.map(pe=>{const we=C.active&&pe.id===nt?.id,$e=zh(pe).length,et=C.active&&B.workspaces.length>1,Ut=me?.workspaceId===pe.id&&Ie!==pe.id?me.placement:null;return m.jsxs(oL,{workspaceId:pe.id,active:we,disabled:!C.active,reorderable:et,dragging:Ie===pe.id,dropPlacement:Ut,children:[et?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":pe.id,title:"Drag to reorder","aria-label":`Reorder ${pe.title}`,"aria-grabbed":Ie===pe.id,onPointerDown:Vt=>pr(pe.id,Vt),onPointerMove:mr,onPointerUp:tr,onPointerCancel:It,onKeyDown:Vt=>{(Vt.key==="ArrowUp"||Vt.key==="ArrowDown")&&(Vt.preventDefault(),Vt.stopPropagation(),On(pe.id,Vt.key==="ArrowUp"?-1:1))},onClick:Vt=>Vt.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":we?"page":void 0,title:pe.defaultCwd??void 0,onClick:()=>_r(C.agentId,pe.id),onDoubleClick:()=>{C.active&&ia(pe.id)},children:[m.jsx("span",{className:"workspace-list-name",children:pe.title}),m.jsxs("small",{children:[pe.defaultCwd??"No folder"," · ",$e," ",$e===1?"session":"sessions"]})]}),C.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${pe.title}`,title:"Edit workspace",onClick:()=>ia(pe.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${pe.title}`,title:"Delete workspace",disabled:B.workspaces.length<=1,onClick:()=>{ls(pe.id)},children:"x"})]}):null]},pe.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(C.agentId),children:"Open server to load workspaces"})]})}return m.jsx(o2,{sensors:rt,onDragStart:qt,onDragEnd:wt,onDragCancel:Ki,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":P,"data-sidebar-open":O,onDragOver:jn,onDrop:fs,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[m.jsxs("div",{className:"workspace-brand-lockup",children:[pn?m.jsx(aw,{height:20}):m.jsx(sw,{size:24}),c&&pn?m.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":P?"Expand sidebar":"Collapse sidebar",title:P?"Expand sidebar":"Collapse sidebar",onClick:()=>q(C=>!C),children:P?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${ar==="files"?"files":"servers"}`,children:[pn?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":re==="servers",onClick:()=>{ne("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":re==="files",onClick:()=>{ne("files")},children:"Files"})]}):null,ar==="servers"&&pn?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(vS,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,renderServerChildren:zr})}):null,pn?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(vS,{api:g,activeAgentId:n,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,compact:!0})}),ar==="files"?m.jsx(GT,{api:f,activeTerminalId:fe,activeTerminalCwd:Ue?.cwd??null,workspaceRootPath:fe?null:nt?.defaultCwd??null,onOpenFile:ir},`${n??"local"}:${nt?.id??"no-workspace"}`):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[pn?m.jsx("span",{children:_s}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ye(!0),children:[m.jsx(Z0,{name:"settings"}),U.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),pn?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{us()},children:m.jsx(Z0,{name:"logout"})}):null]})]})]}),ue?m.jsx(KT,{api:g,onClose:()=>ye(!1),updateAvailable:U.hasUpdates,onNotificationAssetsChanged:()=>{Fi()},onAgentRemoved:sn}):null,_e?m.jsx(rL,{dialog:_e,activePaneCwd:Ue?.cwd??null,activeWorkspaceCwd:nt?.defaultCwd??null,onChange:Nr,onManualCwdChange:ei,onBrowse:na,onCancel:Bi,onSubmit:()=>{ra()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":Dt?"true":void 0,children:[m.jsx(_5,{tabs:nt?.tabs??[],activeTabId:nt?.activeTabId??null,terminals:k.terminals,unreadCompletionTabIds:F,detachedTerminals:Rt,onSelectTab:C=>We({type:"tab.selected",tabId:C}),onCreateTab:()=>{sa()},onToggleWorkspaces:()=>Y(C=>!C),onCloseTerminals:C=>as(C),onReattachTerminal:C=>Ji(C),onDeleteTerminal:C=>{os(C)},onSplitVertical:()=>{Lr("vertical")},onSplitHorizontal:()=>{Lr("horizontal")},onRenameTab:(C,E)=>{an(C,E)},activePaneAvailable:!!fe}),Dt?m.jsx(uL,{targets:at,activeLeafKey:Tt,terminals:k.terminals,editors:T,onSelect:la}):null,A?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:A}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:dn,children:"Retry"}),n!==null&&s?m.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!pt?m.jsx(lL,{onCreate:()=>{sa()}}):null,Ce.map(C=>{const E=nn(C,n);return m.jsx(Q5,{agentId:C,active:E,activeServerApi:E?f:void 0,visitedTabKeys:M,refreshCwdOnEnter:E,draggingTab:E?Be:null,mobileSplitFocus:st,mobileFocusedLeafByTabKey:he,onSelect:B=>{E&&ti(B)},onClose:B=>{E&&Ql(B)},onCloseEditor:B=>{E&&gr(B)},onResize:(B,te)=>{E&&We({type:"pane.resized",path:B,ratio:te})},onExit:(B,te)=>{E?hs({type:"terminal.exited",terminalId:B,exitCode:te}):Rl(C,{type:"terminal.exited",terminalId:B,exitCode:te})},onSnapshot:(B,te)=>{const ve={type:"terminal.updated",terminal:B,notifyCompletion:te?.notifyCompletion===!0};E?hs(ve):Rl(C,ve)},...C===null&&p?{onAuthClose:B=>p({...B,source:B?.source??"terminal-ws-1008",activeAgentId:C})}:{}},gh(C))})]}),_t?m.jsx(cL,{label:_t.label,count:_t.terminalIds.length,warning:H,onCancel:()=>{j(null),Pt(null)},onHide:()=>{aa(_t.terminalIds,_t.workspaceId)&&Pt(null)},onDelete:()=>{const C=_t.terminalIds;j(null),Pt(null),Jl(C)}}):null,m.jsx(R5,{toast:Zi,onActivate:Za,onDismiss:()=>Ct(null)}),m.jsx(w5,{uploads:qe,onDismiss:rr,onDismissAll:yr,onRetry:Ga,onCancel:sr})]})]})})}function Q5({agentId:e,active:t,activeServerApi:n,visitedTabKeys:s,refreshCwdOnEnter:l,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,onAuthClose:k}){const T=v.useMemo(()=>ye=>TC(e,ye),[e]),L=v.useMemo(()=>()=>Bt(e),[e]),A=v.useSyncExternalStore(T,L,L),O=v.useMemo(()=>pc(e),[e]),Y=n??O,P=A.state,q=P.workspaces.find(ye=>ye.id===P.activeWorkspaceId)??P.workspaces[0],re=q?.id??null,ue=(q?.tabs.find(ye=>ye.id===q.activeTabId)??q?.tabs[0])?.id??null;return!A.loaded||P.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:P.workspaces.flatMap(ye=>ye.tabs.map(U=>{const K=t&&ye.id===re&&U.id===ue,W=ac(e,ye.id,U.id),H=jh(U.root),j=h&&H.length>1?zC(H,U.activeTerminalId,p[W]):null;return!K&&!s.has(W)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":K,"aria-hidden":!K,children:m.jsx(tg,{node:U.root,terminals:P.terminals,editors:A.editors,api:Y,activeTerminalId:U.activeTerminalId,visible:K,refreshCwdOnEnter:K&&l,tabId:U.id,dropZoneActive:K&&c!==null,draggingTerminalId:K?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,...k?{onAuthClose:k}:{}})},`${ye.id}:${U.id}`)}))})}function J5(e){const t=qw(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=tL(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function eL(e,t,n){switch(n.type){case"pane.direction":return A5(e,t,n.direction);case"pane.index":return L5(e,n.index);default:return null}}function tL(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function iL(e,t,n){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+n+e.length)%e.length]??null}function jh(e){return e.type==="pane"?[{key:fc(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:jC(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...jh(e.first),...jh(e.second)]}function gg(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...gg(e.first),...gg(e.second)]}function zC(e,t,n){if(n&&e.some(l=>l.key===n))return n;const s=t?fc(t):null;return s&&e.some(l=>l.key===s)?s:e[0]?.key??null}function fc(e){return`terminal:${e}`}function jC(e){return`editor:${e}`}function nL(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 rL({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:s,onManualCwdChange:l,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function y(w){s(k=>k&&{...k,...w})}function S(w){w&&(y({cwd:w,error:null}),c(w))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||p()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:w=>y({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:b,onChange:w=>l(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(n),disabled:b||!n,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(aL(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{c(sL(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function sL(e,t){return t?t.startsWith("/")?mh(t):mh(`${e||"/"}/${t}`):mh(e)}function aL(e){const t=mh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function mh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function lL({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function oL({workspaceId:e,active:t,disabled:n=!1,reorderable:s=!1,dragging:l=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=Mg({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",l?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function cL({label:e,count:t,warning:n,onCancel:s,onHide:l,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:l,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function uL({targets:e,activeLeafKey:t,terminals:n,editors:s,onSelect:l}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(S=>S.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],b=G0(f,n,s);function y(S){const w=(g+S+e.length)%e.length,k=e[w];k&&l(k)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const k=G0(S,n,s),T=hL(S,n,s),L=S.key===f.key;return m.jsxs("button",{type:"button","data-active":L,onClick:()=>{l(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:k}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function G0(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function hL(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function dL(e){const[t,n]=v.useState(()=>fL(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const s=window.matchMedia(e),l=()=>n(s.matches);return l(),typeof s.addEventListener=="function"?(s.addEventListener("change",l),()=>s.removeEventListener("change",l)):(s.addListener(l),()=>s.removeListener(l))},[e]),t}function fL(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function pL(){if(typeof window>"u")return null;const e=E2(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 mL(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:qh(t.focus)}function gL(e,t){for(const n of e.workspaces)for(const s of n.tabs)if(Ni(s.root).includes(t))return{workspaceId:n.id,tabId:s.id};return null}function nn(e,t){return e===t}function _L(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function gh(e){return e??"__local__"}function ac(e,t,n){return`${gh(e)}:${t}:${n}`}class Ph extends Error{constructor(){super(HC())}}function vL(e){return e?{workspaceKey:`${Y0}:${e}`}:{workspaceKey:Y0}}function yL(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(Dw(n))throw new Ph;const s=Tw(n);return s?PC(s):null}catch(n){if(n instanceof Ph)throw n;return null}}function PC(e){if(Dw(e))throw new Ph;const t=Tw(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Yo(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function bL(e,t){const n=Bt(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function SL(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Vl}. Re-open or delete hidden sessions before hiding more.`}function HC(){return`A saved terminal layout has more than ${Vl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function wL(e){const t=e.workspaces.find(l=>l.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(l=>l.id===t.activeTabId)??t?.tabs[0],s=n?e.terminals[n.activeTerminalId]:void 0;return s?.status==="running"?s:null}function CL(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function xL(e){return e.split("/").filter(Boolean).pop()??e}function kL(){try{return localStorage.getItem(OC)==="true"}catch{return!1}}function EL(e){try{localStorage.setItem(OC,e?"true":"false")}catch{}}function TL(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 s=Math.max(1,Math.floor(n/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function Z0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function Fs(e){return e instanceof Error?e.message:"Request failed"}function DL({api:e,onDone:t}){const[n,s]=v.useState(null),[l,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(L=>{T||(s(L.qrDataUrl),c(L.secret))}).catch(L=>{T||w(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function k(T){if(T.preventDefault(),!!l){f(!0),y(null);try{await e.activateTotp({secret:l,otp:h}),t()}catch(L){y(L instanceof Error?L.message:"Verification failed")}finally{f(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!n||!l?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.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."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:l})]}),m.jsxs("form",{className:"auth-form",onSubmit:k,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>p(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?m.jsx("p",{className:"form-error",children:b}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}const IC="nterminal.clientDiagnostics.v1",UC=150,RL=24,ML=160;let Q0=!1,Xo=null;function NL(){Q0||typeof window>"u"||(Q0=!0,Ln("page.load",{navigation:UL(),visibility:document.visibilityState,online:navigator.onLine,viewport:FC(),standalone:IL()}),document.addEventListener("visibilitychange",()=>{Ln("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Ln("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Ln("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Ln("network.online")),window.addEventListener("offline",()=>Ln("network.offline")),window.addEventListener("focus",()=>Ln("window.focus")),window.addEventListener("blur",()=>Ln("window.blur")),window.addEventListener("error",e=>{Ln("runtime.error",{message:e.message,source:KL(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Ln("runtime.unhandledrejection",{reason:WL(e.reason)})}))}function Ln(e,t={}){const n={at:new Date().toISOString(),event:rd(e,80),data:WC({...t,visibility:t.visibility??PL(),online:t.online??HL(),viewport:t.viewport??FC()})},s=KC();return s.push(n),AL(s.slice(-UC)),n}function KC(){try{const e=window.localStorage.getItem(IC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(LL).filter(n=>n!==null).slice(-UC):[]}catch{return[]}}async function p_(e,t=fetch){if(Xo)return Xo;const n=KC(),s={reason:rd(e,80),events:n},l=JSON.stringify(s);Xo=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:l.length<48e3,body:l});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Xo}finally{Xo=null}}function AL(e){try{window.localStorage.setItem(IC,JSON.stringify(e))}catch{}}function LL(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:rd(t.event,80),...t.data&&typeof t.data=="object"?{data:WC(t.data)}:{}}}function WC(e){const t={};for(const[n,s]of Object.entries(e).slice(0,RL)){const l=rd(n,64);if(!l||BL(l))continue;const c=OL(s);c!==void 0&&(t[l]=c)}return t}function BL(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function OL(e){if(typeof e=="string")return zL(e,ML);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function rd(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function zL(e,t){return jL(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function jL(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 PL(){return typeof document>"u"?void 0:document.visibilityState}function HL(){return typeof navigator>"u"?void 0:navigator.onLine}function FC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function IL(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function UL(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function KL(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 WL(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function FL(e){return{source:Pp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Pp(e.terminalId)}:{},...e?.detail?{detail:Pp(e.detail)}:{}}}function qL(e){return{invalidationSource:e.source}}function $L(e){Ln("auth.session_invalid.request",qC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),p_("session-invalid-request").catch(()=>{}))}function VL(e,t){Ln("auth.session_invalid.result",{...qC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),p_("session-invalid-result").catch(()=>{}))}function qC(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 Pp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function YL({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:s}){const l=v.useMemo(()=>e??Hh(),[e]),c=v.useMemo(()=>t??pc(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let A=!1;return l.getSession().then(O=>{A||(p(O),f(null))}).catch(O=>{A||(f(Ha(O)),p(null))}),()=>{A=!0}},[l]);const S=QL(h);v.useEffect(()=>{const A=y.current;Ln("auth.view",{view:S,previousView:A,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),A==="workspace"&&S!=="workspace"&&p_(`auth-left-workspace-${S}`).catch(()=>{}),y.current=S},[h,S]);async function w(){const A=await l.getSession();p(A),f(null)}async function k(){Mp(),jp(),k0(),f(null),p(null);try{await w()}catch(A){f(Ha(A))}}function T(A){const O=FL(A);if($L(O),b.current)return b.current;const Y=(async()=>{f(null);try{const P=await l.getSession(qL(O));if(VL(O,P.authenticated),p(P),P.authenticated){vA();return}Mp(),jp(),k0()}catch(P){f(Ha(P))}finally{b.current=null}})();return b.current=Y,Y}if(S==="workspace")return m.jsx(Z5,{api:l,serverApi:c,activeAgentId:n,onSelectServer:s,sessionExpiresAt:h?.expiresAt??null,previewMode:h?.previewMode===!0,onSessionInvalid:A=>{T(A)},onLogout:async()=>{Mp(),jp();const A=await l.logout();p(A)}});const L={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(sw,{size:26}),m.jsxs("div",{children:[m.jsx(aw,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:L[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},children:"Retry"}):null,S==="setup_password"?m.jsx(XL,{api:l,onSession:A=>{p(A)}}):null,S==="setup_totp"?m.jsx(DL,{api:l,onDone:()=>{w()}}):null,S==="login"?m.jsx(GL,{api:l,session:h,onSession:p,onRefresh:w}):null,S==="reauth"?m.jsx(ZL,{api:l,session:h,onSession:p,onFullLogin:()=>p(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function XL({api:e,onSession:t}){const[n,s]=v.useState(""),[l,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function b(y){y.preventDefault(),p(!0),f(null);try{if(n!==l){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(S){f(Ha(S))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:b,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:n,onChange:y=>s(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:l,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||n.length<8||l.length<8,children:"Set password"})]})}function GL({api:e,session:t,onSession:n,onRefresh:s}){const[l,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(!1),[S,w]=v.useState(null),k=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),y(!0),w(null);try{n(await e.login({password:l,...k?{otp:h}:{},rememberNetwork:g}))}catch(O){w(Ha(O))}finally{y(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:L,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:l,onChange:A=>c(A.currentTarget.value),required:!0})]}),k?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:A=>p(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||l.length===0||k&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:b,children:"Refresh"})]})]})}function ZL({api:e,session:t,onSession:n,onFullLogin:s}){const l=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,b]=v.useState(!1),[y,S]=v.useState(!1),[w,k]=v.useState(!1),[T,L]=v.useState(null),A=Mi.useCallback(async(Y,P)=>{b(!0),L(null);try{n(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:P}))}catch(q){L(Ha(q))}finally{b(!1)}},[e,n]);v.useEffect(()=>{if(l){let Y=!1;S(!0),k(!1),L(null);const P=window.setTimeout(()=>{Y||k(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{Y||n(q)}).catch(q=>{Y||(L(Ha(q)),k(!0))}).finally(()=>{window.clearTimeout(P),Y||S(!1)}),()=>{Y=!0,window.clearTimeout(P)}}},[e,l,n]);async function O(Y){Y.preventDefault(),await A(c,p)}return l&&y&&!w&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:O,children:[l&&w&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>h(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?m.jsx("p",{className:"form-error",children:T}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function QL(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Ha(e){return e instanceof Error?e.message:"Request failed"}const J0="NTerminal",_g="nterminal.activeAgentId";function JL(){const[e,t]=v.useState(()=>eB()),n=v.useMemo(()=>Hh(),[]),s=v.useMemo(()=>pc(e),[e]);v.useEffect(()=>{const c=()=>{const h=h5();document.title=h>0?`(${h}) ${J0}`:J0};return c(),u5(c)},[]);function l(c){tB(c),t(c)}return m.jsx(YL,{api:n,activeAgentId:e,serverApi:s,onSelectServer:l})}function eB(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(_g);return e&&e.trim()?e:null}catch{return null}}function tB(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(_g,e);return}window.localStorage.removeItem(_g)}catch{}}const ew=["gesturestart","gesturechange","gestureend"],iB=[".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 nB(e=window){if(!sB(e))return()=>{};const t={passive:!1},n=e.document;function s(c){c.cancelable&&c.preventDefault()}function l(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!rB(c.target))&&s(c)}for(const c of ew)n.addEventListener(c,s,t);return n.addEventListener("touchmove",l,t),n.addEventListener("dblclick",s,t),()=>{for(const c of ew)n.removeEventListener(c,s,t);n.removeEventListener("touchmove",l,t),n.removeEventListener("dblclick",s,t)}}function rB(e){return e instanceof Element&&e.closest(iB)!==null}function sB(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}NL();EN();nB();wg();Kk.createRoot(document.getElementById("root")).render(m.jsx(Mi.StrictMode,{children:m.jsx(JL,{})}));export{Mi as R,Lk as g,m as j};