nterminal 1.2.90 → 1.2.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/brand/claude.webp +0 -0
- package/assets/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-DeuMEC4W.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-Bkq8AHtC.js → TranscriptMarkdownBody-Ba-PCW9y.js} +1 -1
- package/dist/client/assets/{index-BI8o0HfA.js → index-AlID8r7Q.js} +1 -1
- package/dist/client/assets/index-B8YltmYF.js +57 -0
- package/dist/client/assets/index-BZjaqOfH.css +1 -0
- package/dist/client/brand/claude.webp +0 -0
- package/dist/client/brand/codex.webp +0 -0
- package/dist/client/index.html +2 -2
- package/dist/server/accounts/accountService.d.ts +70 -0
- package/dist/server/accounts/accountService.js +765 -0
- package/dist/server/accounts/accountService.js.map +1 -0
- package/dist/server/agent/agentRoutes.d.ts +2 -0
- package/dist/server/agent/agentRoutes.js +61 -0
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/http.d.ts +2 -1
- package/dist/server/http.js +6 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/accountRoutes.d.ts +9 -0
- package/dist/server/routes/accountRoutes.js +84 -0
- package/dist/server/routes/accountRoutes.js.map +1 -0
- package/dist/server/routes/agentManagementRoutes.js +35 -0
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/shared/protocol.d.ts +30 -0
- package/dist/shared/protocol.js.map +1 -1
- package/package.json +1 -1
- package/public/brand/claude.webp +0 -0
- package/public/brand/codex.webp +0 -0
- package/dist/client/assets/MarkdownPreview-4fzY6p-f.js +0 -1
- package/dist/client/assets/index-CiLqZsSA.css +0 -1
- package/dist/client/assets/index-Cr6EN3hl.js +0 -57
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-4fzY6p-f.js","assets/index-BI8o0HfA.js","assets/TranscriptMarkdownBody-Bkq8AHtC.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function s2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vm={exports:{}},Kc={};var F0;function r2(){if(F0)return Kc;F0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var m in o)m!=="key"&&(c[m]=o[m])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:c}}return Kc.Fragment=t,Kc.jsx=n,Kc.jsxs=n,Kc}var W0;function a2(){return W0||(W0=1,Vm.exports=r2()),Vm.exports}var f=a2(),Ym={exports:{}},at={};var $0;function o2(){if($0)return at;$0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),C=Symbol.iterator;function k(N){return N===null||typeof N!="object"?null:(N=C&&N[C]||N["@@iterator"],typeof N=="function"?N:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,B={};function A(N,U,ue){this.props=N,this.context=U,this.refs=B,this.updater=ue||S}A.prototype.isReactComponent={},A.prototype.setState=function(N,U){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,U,"setState")},A.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function H(){}H.prototype=A.prototype;function Y(N,U,ue){this.props=N,this.context=U,this.refs=B,this.updater=ue||S}var $=Y.prototype=new H;$.constructor=Y,D($,A.prototype),$.isPureReactComponent=!0;var se=Array.isArray;function J(){}var W={H:null,A:null,T:null,S:null},xe=Object.prototype.hasOwnProperty;function re(N,U,ue){var Ce=ue.ref;return{$$typeof:e,type:N,key:U,ref:Ce!==void 0?Ce:null,props:ue}}function Ee(N,U){return re(N.type,U,N.props)}function ie(N){return typeof N=="object"&&N!==null&&N.$$typeof===e}function V(N){var U={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(ue){return U[ue]})}var X=/\/+/g;function F(N,U){return typeof N=="object"&&N!==null&&N.key!=null?V(""+N.key):U.toString(36)}function le(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(J,J):(N.status="pending",N.then(function(U){N.status==="pending"&&(N.status="fulfilled",N.value=U)},function(U){N.status==="pending"&&(N.status="rejected",N.reason=U)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function O(N,U,ue,Ce,Oe){var De=typeof N;(De==="undefined"||De==="boolean")&&(N=null);var Be=!1;if(N===null)Be=!0;else switch(De){case"bigint":case"string":case"number":Be=!0;break;case"object":switch(N.$$typeof){case e:case t:Be=!0;break;case y:return Be=N._init,O(Be(N._payload),U,ue,Ce,Oe)}}if(Be)return Oe=Oe(N),Be=Ce===""?"."+F(N,0):Ce,se(Oe)?(ue="",Be!=null&&(ue=Be.replace(X,"$&/")+"/"),O(Oe,U,ue,"",function(Fe){return Fe})):Oe!=null&&(ie(Oe)&&(Oe=Ee(Oe,ue+(Oe.key==null||N&&N.key===Oe.key?"":(""+Oe.key).replace(X,"$&/")+"/")+Be)),U.push(Oe)),1;Be=0;var Ne=Ce===""?".":Ce+":";if(se(N))for(var Ue=0;Ue<N.length;Ue++)Ce=N[Ue],De=Ne+F(Ce,Ue),Be+=O(Ce,U,ue,De,Oe);else if(Ue=k(N),typeof Ue=="function")for(N=Ue.call(N),Ue=0;!(Ce=N.next()).done;)Ce=Ce.value,De=Ne+F(Ce,Ue++),Be+=O(Ce,U,ue,De,Oe);else if(De==="object"){if(typeof N.then=="function")return O(le(N),U,ue,Ce,Oe);throw U=String(N),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Be}function M(N,U,ue){if(N==null)return N;var Ce=[],Oe=0;return O(N,Ce,"","",function(De){return U.call(ue,De,Oe++)}),Ce}function j(N){if(N._status===-1){var U=N._result;U=U(),U.then(function(ue){(N._status===0||N._status===-1)&&(N._status=1,N._result=ue)},function(ue){(N._status===0||N._status===-1)&&(N._status=2,N._result=ue)}),N._status===-1&&(N._status=0,N._result=U)}if(N._status===1)return N._result.default;throw N._result}var ae=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)},we={map:M,forEach:function(N,U,ue){M(N,function(){U.apply(this,arguments)},ue)},count:function(N){var U=0;return M(N,function(){U++}),U},toArray:function(N){return M(N,function(U){return U})||[]},only:function(N){if(!ie(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return at.Activity=b,at.Children=we,at.Component=A,at.Fragment=n,at.Profiler=o,at.PureComponent=Y,at.StrictMode=r,at.Suspense=g,at.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=W,at.__COMPILER_RUNTIME={__proto__:null,c:function(N){return W.H.useMemoCache(N)}},at.cache=function(N){return function(){return N.apply(null,arguments)}},at.cacheSignal=function(){return null},at.cloneElement=function(N,U,ue){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var Ce=D({},N.props),Oe=N.key;if(U!=null)for(De in U.key!==void 0&&(Oe=""+U.key),U)!xe.call(U,De)||De==="key"||De==="__self"||De==="__source"||De==="ref"&&U.ref===void 0||(Ce[De]=U[De]);var De=arguments.length-2;if(De===1)Ce.children=ue;else if(1<De){for(var Be=Array(De),Ne=0;Ne<De;Ne++)Be[Ne]=arguments[Ne+2];Ce.children=Be}return re(N.type,Oe,Ce)},at.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:c,_context:N},N},at.createElement=function(N,U,ue){var Ce,Oe={},De=null;if(U!=null)for(Ce in U.key!==void 0&&(De=""+U.key),U)xe.call(U,Ce)&&Ce!=="key"&&Ce!=="__self"&&Ce!=="__source"&&(Oe[Ce]=U[Ce]);var Be=arguments.length-2;if(Be===1)Oe.children=ue;else if(1<Be){for(var Ne=Array(Be),Ue=0;Ue<Be;Ue++)Ne[Ue]=arguments[Ue+2];Oe.children=Ne}if(N&&N.defaultProps)for(Ce in Be=N.defaultProps,Be)Oe[Ce]===void 0&&(Oe[Ce]=Be[Ce]);return re(N,De,Oe)},at.createRef=function(){return{current:null}},at.forwardRef=function(N){return{$$typeof:m,render:N}},at.isValidElement=ie,at.lazy=function(N){return{$$typeof:y,_payload:{_status:-1,_result:N},_init:j}},at.memo=function(N,U){return{$$typeof:p,type:N,compare:U===void 0?null:U}},at.startTransition=function(N){var U=W.T,ue={};W.T=ue;try{var Ce=N(),Oe=W.S;Oe!==null&&Oe(ue,Ce),typeof Ce=="object"&&Ce!==null&&typeof Ce.then=="function"&&Ce.then(J,ae)}catch(De){ae(De)}finally{U!==null&&ue.types!==null&&(U.types=ue.types),W.T=U}},at.unstable_useCacheRefresh=function(){return W.H.useCacheRefresh()},at.use=function(N){return W.H.use(N)},at.useActionState=function(N,U,ue){return W.H.useActionState(N,U,ue)},at.useCallback=function(N,U){return W.H.useCallback(N,U)},at.useContext=function(N){return W.H.useContext(N)},at.useDebugValue=function(){},at.useDeferredValue=function(N,U){return W.H.useDeferredValue(N,U)},at.useEffect=function(N,U){return W.H.useEffect(N,U)},at.useEffectEvent=function(N){return W.H.useEffectEvent(N)},at.useId=function(){return W.H.useId()},at.useImperativeHandle=function(N,U,ue){return W.H.useImperativeHandle(N,U,ue)},at.useInsertionEffect=function(N,U){return W.H.useInsertionEffect(N,U)},at.useLayoutEffect=function(N,U){return W.H.useLayoutEffect(N,U)},at.useMemo=function(N,U){return W.H.useMemo(N,U)},at.useOptimistic=function(N,U){return W.H.useOptimistic(N,U)},at.useReducer=function(N,U,ue){return W.H.useReducer(N,U,ue)},at.useRef=function(N){return W.H.useRef(N)},at.useState=function(N){return W.H.useState(N)},at.useSyncExternalStore=function(N,U,ue){return W.H.useSyncExternalStore(N,U,ue)},at.useTransition=function(){return W.H.useTransition()},at.version="19.2.6",at}var q0;function H_(){return q0||(q0=1,Ym.exports=o2()),Ym.exports}var v=H_();const Ni=s2(v);var Xm={exports:{}},Fc={},Gm={exports:{}},Zm={};var V0;function l2(){return V0||(V0=1,(function(e){function t(O,M){var j=O.length;O.push(M);e:for(;0<j;){var ae=j-1>>>1,we=O[ae];if(0<o(we,M))O[ae]=M,O[j]=we,j=ae;else break e}}function n(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var M=O[0],j=O.pop();if(j!==M){O[0]=j;e:for(var ae=0,we=O.length,N=we>>>1;ae<N;){var U=2*(ae+1)-1,ue=O[U],Ce=U+1,Oe=O[Ce];if(0>o(ue,j))Ce<we&&0>o(Oe,ue)?(O[ae]=Oe,O[Ce]=j,ae=Ce):(O[ae]=ue,O[U]=j,ae=U);else if(Ce<we&&0>o(Oe,j))O[ae]=Oe,O[Ce]=j,ae=Ce;else break e}}return M}function o(O,M){var j=O.sortIndex-M.sortIndex;return j!==0?j:O.id-M.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,m=u.now();e.unstable_now=function(){return u.now()-m}}var g=[],p=[],y=1,b=null,C=3,k=!1,S=!1,D=!1,B=!1,A=typeof setTimeout=="function"?setTimeout:null,H=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function $(O){for(var M=n(p);M!==null;){if(M.callback===null)r(p);else if(M.startTime<=O)r(p),M.sortIndex=M.expirationTime,t(g,M);else break;M=n(p)}}function se(O){if(D=!1,$(O),!S)if(n(g)!==null)S=!0,J||(J=!0,V());else{var M=n(p);M!==null&&le(se,M.startTime-O)}}var J=!1,W=-1,xe=5,re=-1;function Ee(){return B?!0:!(e.unstable_now()-re<xe)}function ie(){if(B=!1,J){var O=e.unstable_now();re=O;var M=!0;try{e:{S=!1,D&&(D=!1,H(W),W=-1),k=!0;var j=C;try{t:{for($(O),b=n(g);b!==null&&!(b.expirationTime>O&&Ee());){var ae=b.callback;if(typeof ae=="function"){b.callback=null,C=b.priorityLevel;var we=ae(b.expirationTime<=O);if(O=e.unstable_now(),typeof we=="function"){b.callback=we,$(O),M=!0;break t}b===n(g)&&r(g),$(O)}else r(g);b=n(g)}if(b!==null)M=!0;else{var N=n(p);N!==null&&le(se,N.startTime-O),M=!1}}break e}finally{b=null,C=j,k=!1}M=void 0}}finally{M?V():J=!1}}}var V;if(typeof Y=="function")V=function(){Y(ie)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,F=X.port2;X.port1.onmessage=ie,V=function(){F.postMessage(null)}}else V=function(){A(ie,0)};function le(O,M){W=A(function(){O(e.unstable_now())},M)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):xe=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return C},e.unstable_next=function(O){switch(C){case 1:case 2:case 3:var M=3;break;default:M=C}var j=C;C=M;try{return O()}finally{C=j}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(O,M){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var j=C;C=O;try{return M()}finally{C=j}},e.unstable_scheduleCallback=function(O,M,j){var ae=e.unstable_now();switch(typeof j=="object"&&j!==null?(j=j.delay,j=typeof j=="number"&&0<j?ae+j:ae):j=ae,O){case 1:var we=-1;break;case 2:we=250;break;case 5:we=1073741823;break;case 4:we=1e4;break;default:we=5e3}return we=j+we,O={id:y++,callback:M,priorityLevel:O,startTime:j,expirationTime:we,sortIndex:-1},j>ae?(O.sortIndex=j,t(p,O),n(g)===null&&O===n(p)&&(D?(H(W),W=-1):D=!0,le(se,j-ae))):(O.sortIndex=we,t(g,O),S||k||(S=!0,J||(J=!0,V()))),O},e.unstable_shouldYield=Ee,e.unstable_wrapCallback=function(O){var M=C;return function(){var j=C;C=M;try{return O.apply(this,arguments)}finally{C=j}}}})(Zm)),Zm}var Y0;function c2(){return Y0||(Y0=1,Gm.exports=l2()),Gm.exports}var Qm={exports:{}},fn={};var X0;function u2(){if(X0)return fn;X0=1;var e=H_();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:y}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return fn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,fn.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return c(g,p,null,y)},fn.flushSync=function(g){var p=u.T,y=r.p;try{if(u.T=null,r.p=2,g)return g()}finally{u.T=p,r.p=y,r.d.f()}},fn.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},fn.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},fn.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin),C=typeof p.integrity=="string"?p.integrity:void 0,k=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:C,fetchPriority:k}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:C,fetchPriority:k,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},fn.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=m(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},fn.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=m(y,p.crossOrigin);r.d.L(g,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},fn.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=m(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},fn.requestFormReset=function(g){r.d.r(g)},fn.unstable_batchedUpdates=function(g,p){return g(p)},fn.useFormState=function(g,p,y){return u.H.useFormState(g,p,y)},fn.useFormStatus=function(){return u.H.useHostTransitionStatus()},fn.version="19.2.6",fn}var G0;function _C(){if(G0)return Qm.exports;G0=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(),Qm.exports=u2(),Qm.exports}var Z0;function d2(){if(Z0)return Fc;Z0=1;var e=c2(),t=H_(),n=_C();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)s+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var s=i,a=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(a=s.return),i=s.return;while(i)}return s.tag===3?a:null}function u(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function m(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var s=i.alternate;if(!s){if(s=c(i),s===null)throw Error(r(188));return s!==i?null:i}for(var a=i,l=s;;){var d=a.return;if(d===null)break;var h=d.alternate;if(h===null){if(l=d.return,l!==null){a=l;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===a)return g(d),i;if(h===l)return g(d),s;h=h.sibling}throw Error(r(188))}if(a.return!==l.return)a=d,l=h;else{for(var _=!1,T=d.child;T;){if(T===a){_=!0,a=d,l=h;break}if(T===l){_=!0,l=d,a=h;break}T=T.sibling}if(!_){for(T=h.child;T;){if(T===a){_=!0,a=h,l=d;break}if(T===l){_=!0,l=h,a=d;break}T=T.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var b=Object.assign,C=Symbol.for("react.element"),k=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),Ee=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function V(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var X=Symbol.for("react.client.reference");function F(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===X?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case A:return"Profiler";case B:return"StrictMode";case se:return"Suspense";case J:return"SuspenseList";case re:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case S:return"Portal";case Y:return i.displayName||"Context";case H:return(i._context.displayName||"Context")+".Consumer";case $:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case W:return s=i.displayName||null,s!==null?s:F(i.type)||"Memo";case xe:s=i._payload,i=i._init;try{return F(i(s))}catch{}}return null}var le=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j={pending:!1,data:null,method:null,action:null},ae=[],we=-1;function N(i){return{current:i}}function U(i){0>we||(i.current=ae[we],ae[we]=null,we--)}function ue(i,s){we++,ae[we]=i.current,i.current=s}var Ce=N(null),Oe=N(null),De=N(null),Be=N(null);function Ne(i,s){switch(ue(De,s),ue(Oe,i),ue(Ce,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?h0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=h0(s),i=f0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(Ce),ue(Ce,i)}function Ue(){U(Ce),U(Oe),U(De)}function Fe(i){i.memoizedState!==null&&ue(Be,i);var s=Ce.current,a=f0(s,i.type);s!==a&&(ue(Oe,i),ue(Ce,a))}function ne(i){Oe.current===i&&(U(Ce),U(Oe)),Be.current===i&&(U(Be),zc._currentValue=j)}var me,R;function q(i){if(me===void 0)try{throw Error()}catch(a){var s=a.stack.trim().match(/\n( *(at )?)/);me=s&&s[1]||"",R=-1<a.stack.indexOf(`
|
|
3
|
-
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
-
`+me+i+R}var fe=!1;function ge(i,s){if(!i||fe)return"";fe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(ce){var te=ce}Reflect.construct(i,[],_e)}else{try{_e.call()}catch(ce){te=ce}i.call(_e.prototype)}}else{try{throw Error()}catch(ce){te=ce}(_e=i())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(ce){if(ce&&te&&typeof ce.stack=="string")return[ce.stack,te.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=l.DetermineComponentFrameRoot(),_=h[0],T=h[1];if(_&&T){var L=_.split(`
|
|
5
|
-
`),Z=T.split(`
|
|
6
|
-
`);for(d=l=0;l<L.length&&!L[l].includes("DetermineComponentFrameRoot");)l++;for(;d<Z.length&&!Z[d].includes("DetermineComponentFrameRoot");)d++;if(l===L.length||d===Z.length)for(l=L.length-1,d=Z.length-1;1<=l&&0<=d&&L[l]!==Z[d];)d--;for(;1<=l&&0<=d;l--,d--)if(L[l]!==Z[d]){if(l!==1||d!==1)do if(l--,d--,0>d||L[l]!==Z[d]){var he=`
|
|
7
|
-
`+L[l].replace(" at new "," at ");return i.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",i.displayName)),he}while(1<=l&&0<=d);break}}}finally{fe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?q(a):""}function Q(i,s){switch(i.tag){case 26:case 27:case 5:return q(i.type);case 16:return q("Lazy");case 13:return i.child!==s&&s!==null?q("Suspense Fallback"):q("Suspense");case 19:return q("SuspenseList");case 0:case 15:return ge(i.type,!1);case 11:return ge(i.type.render,!1);case 1:return ge(i.type,!0);case 31:return q("Activity");default:return""}}function ke(i){try{var s="",a=null;do s+=Q(i,a),a=i,i=i.return;while(i);return s}catch(l){return`
|
|
8
|
-
Error generating stack: `+l.message+`
|
|
9
|
-
`+l.stack}}var de=Object.prototype.hasOwnProperty,Re=e.unstable_scheduleCallback,Ie=e.unstable_cancelCallback,je=e.unstable_shouldYield,Ye=e.unstable_requestPaint,ct=e.unstable_now,Nt=e.unstable_getCurrentPriorityLevel,yt=e.unstable_ImmediatePriority,Tt=e.unstable_UserBlockingPriority,$e=e.unstable_NormalPriority,St=e.unstable_LowPriority,Lt=e.unstable_IdlePriority,ye=e.log,Xe=e.unstable_setDisableYieldValue,rt=null,Ze=null;function Et(i){if(typeof ye=="function"&&Xe(i),Ze&&typeof Ze.setStrictMode=="function")try{Ze.setStrictMode(rt,i)}catch{}}var ut=Math.clz32?Math.clz32:ee,Tn=Math.log,gi=Math.LN2;function ee(i){return i>>>=0,i===0?32:31-(Tn(i)/gi|0)|0}var Pe=256,st=262144,tt=4194304;function kt(i){var s=i&42;if(s!==0)return s;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Xt(i,s,a){var l=i.pendingLanes;if(l===0)return 0;var d=0,h=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var T=l&134217727;return T!==0?(l=T&~h,l!==0?d=kt(l):(_&=T,_!==0?d=kt(_):a||(a=T&~i,a!==0&&(d=kt(a))))):(T=l&~h,T!==0?d=kt(T):_!==0?d=kt(_):a||(a=l&~i,a!==0&&(d=kt(a)))),d===0?0:s!==0&&s!==d&&(s&h)===0&&(h=d&-d,a=s&-s,h>=a||h===32&&(a&4194048)!==0)?s:d}function Ft(i,s){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&s)===0}function ci(i,s){switch(i){case 1:case 2:case 4:case 8:case 64:return s+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gt(){var i=tt;return tt<<=1,(tt&62914560)===0&&(tt=4194304),i}function si(i){for(var s=[],a=0;31>a;a++)s.push(i);return s}function ui(i,s){i.pendingLanes|=s,s!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Wt(i,s,a,l,d,h){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var T=i.entanglements,L=i.expirationTimes,Z=i.hiddenUpdates;for(a=_&~a;0<a;){var he=31-ut(a),_e=1<<he;T[he]=0,L[he]=-1;var te=Z[he];if(te!==null)for(Z[he]=null,he=0;he<te.length;he++){var ce=te[he];ce!==null&&(ce.lane&=-536870913)}a&=~_e}l!==0&&cn(i,l,0),h!==0&&d===0&&i.tag!==0&&(i.suspendedLanes|=h&~(_&~s))}function cn(i,s,a){i.pendingLanes|=s,i.suspendedLanes&=~s;var l=31-ut(s);i.entangledLanes|=s,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ei(i,s){var a=i.entangledLanes|=s;for(i=i.entanglements;a;){var l=31-ut(a),d=1<<l;d&s|i[l]&s&&(i[l]|=s),a&=~d}}function Hi(i,s){var a=s&-s;return a=(a&42)!==0?1:vn(a),(a&(i.suspendedLanes|s))!==0?0:a}function vn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function _n(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function ti(){var i=M.p;return i!==0?i:(i=window.event,i===void 0?32:j0(i.type))}function Ji(i,s){var a=M.p;try{return M.p=i,s()}finally{M.p=a}}var ri=Math.random().toString(36).slice(2),vi="__reactFiber$"+ri,_i="__reactProps$"+ri,Bn="__reactContainer$"+ri,Hr="__reactEvents$"+ri,jo="__reactListeners$"+ri,Ur="__reactHandles$"+ri,er="__reactResources$"+ri,hs="__reactMarker$"+ri;function tr(i){delete i[vi],delete i[_i],delete i[Hr],delete i[jo],delete i[Ur]}function fs(i){var s=i[vi];if(s)return s;for(var a=i.parentNode;a;){if(s=a[Bn]||a[vi]){if(a=s.alternate,s.child!==null||a!==null&&a.child!==null)for(i=y0(i);i!==null;){if(a=i[vi])return a;i=y0(i)}return s}i=a,a=i.parentNode}return null}function Rs(i){if(i=i[vi]||i[Bn]){var s=i.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return i}return null}function ps(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i.stateNode;throw Error(r(33))}function Ms(i){var s=i[er];return s||(s=i[er]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function zt(i){i[hs]=!0}var Io=new Set,Kr={};function $t(i,s){jn(i,s),jn(i+"Capture",s)}function jn(i,s){for(Kr[i]=s,i=0;i<s.length;i++)Io.add(s[i])}var en=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]*$"),Fr={},zo={};function ir(i){return de.call(zo,i)?!0:de.call(Fr,i)?!1:en.test(i)?zo[i]=!0:(Fr[i]=!0,!1)}function ms(i,s,a){if(ir(s))if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(s);return;case"boolean":var l=s.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(s);return}}i.setAttribute(s,""+a)}}function Wr(i,s,a){if(a===null)i.removeAttribute(s);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(s);return}i.setAttribute(s,""+a)}}function bn(i,s,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(s,a,""+l)}}function Ui(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Ns(i){var s=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Va(i,s,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,s);if(!i.hasOwnProperty(s)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var d=l.get,h=l.set;return Object.defineProperty(i,s,{configurable:!0,get:function(){return d.call(this)},set:function(_){a=""+_,h.call(this,_)}}),Object.defineProperty(i,s,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[s]}}}}function gs(i){if(!i._valueTracker){var s=Ns(i)?"checked":"value";i._valueTracker=Va(i,s,""+i[s])}}function Ki(i){if(!i)return!1;var s=i._valueTracker;if(!s)return!0;var a=s.getValue(),l="";return i&&(l=Ns(i)?i.checked?"true":"false":i.value),i=l,i!==a?(s.setValue(i),!0):!1}function vs(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 As=/[\n"\\]/g;function Oi(i){return i.replace(As,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function mt(i,s,a,l,d,h,_,T){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),s!=null?_==="number"?(s===0&&i.value===""||i.value!=s)&&(i.value=""+Ui(s)):i.value!==""+Ui(s)&&(i.value=""+Ui(s)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),s!=null?nr(i,_,Ui(s)):a!=null?nr(i,_,Ui(a)):l!=null&&i.removeAttribute("value"),d==null&&h!=null&&(i.defaultChecked=!!h),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?i.name=""+Ui(T):i.removeAttribute("name")}function _s(i,s,a,l,d,h,_,T){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(i.type=h),s!=null||a!=null){if(!(h!=="submit"&&h!=="reset"||s!=null)){gs(i);return}a=a!=null?""+Ui(a):"",s=s!=null?""+Ui(s):a,T||s===i.value||(i.value=s),i.defaultValue=s}l=l??d,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=T?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),gs(i)}function nr(i,s,a){s==="number"&&vs(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function un(i,s,a,l){if(i=i.options,s){s={};for(var d=0;d<a.length;d++)s["$"+a[d]]=!0;for(a=0;a<i.length;a++)d=s.hasOwnProperty("$"+i[a].value),i[a].selected!==d&&(i[a].selected=d),d&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Ui(a),s=null,d=0;d<i.length;d++){if(i[d].value===a){i[d].selected=!0,l&&(i[d].defaultSelected=!0);return}s!==null||i[d].disabled||(s=i[d])}s!==null&&(s.selected=!0)}}function $r(i,s,a){if(s!=null&&(s=""+Ui(s),s!==i.value&&(i.value=s),a==null)){i.defaultValue!==s&&(i.defaultValue=s);return}i.defaultValue=a!=null?""+Ui(a):""}function Ya(i,s,a,l){if(s==null){if(l!=null){if(a!=null)throw Error(r(92));if(le(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),s=a}a=Ui(s),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),gs(i)}function dn(i,s){if(s){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=s;return}}i.textContent=s}var Po=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 qr(i,s,a){var l=s.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(s,""):s==="float"?i.cssFloat="":i[s]="":l?i.setProperty(s,a):typeof a!="number"||a===0||Po.has(s)?s==="float"?i.cssFloat=a:i[s]=(""+a).trim():i[s]=a+"px"}function bs(i,s,a){if(s!=null&&typeof s!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||s!=null&&s.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var d in s)l=s[d],s.hasOwnProperty(d)&&a[d]!==l&&qr(i,d,l)}else for(var h in s)s.hasOwnProperty(h)&&qr(i,h,s[h])}function Vr(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 Ho=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"]]),Gl=/^[\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 ys(i){return Gl.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Xn(){}var bi=null;function Yr(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Fi=null,ai=null;function Ls(i){var s=Rs(i);if(s&&(i=s.stateNode)){var a=i[_i]||null;e:switch(i=s.stateNode,s.type){case"input":if(mt(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),s=a.name,a.type==="radio"&&s!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Oi(""+s)+'"][type="radio"]'),s=0;s<a.length;s++){var l=a[s];if(l!==i&&l.form===i.form){var d=l[_i]||null;if(!d)throw Error(r(90));mt(l,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(s=0;s<a.length;s++)l=a[s],l.form===i.form&&Ki(l)}break e;case"textarea":$r(i,a.value,a.defaultValue);break e;case"select":s=a.value,s!=null&&un(i,!!a.multiple,s,!1)}}}var sr=!1;function Xa(i,s,a){if(sr)return i(s,a);sr=!0;try{var l=i(s);return l}finally{if(sr=!1,(Fi!==null||ai!==null)&&(Xd(),Fi&&(s=Fi,i=ai,ai=Fi=null,Ls(s),i)))for(s=0;s<i.length;s++)Ls(i[s])}}function In(i,s){var a=i.stateNode;if(a===null)return null;var l=a[_i]||null;if(l===null)return null;a=l[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,s,typeof a));return a}var yi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xr=!1;if(yi)try{var rr={};Object.defineProperty(rr,"passive",{get:function(){Xr=!0}}),window.addEventListener("test",rr,rr),window.removeEventListener("test",rr,rr)}catch{Xr=!1}var yn=null,Os=null,Bs=null;function ar(){if(Bs)return Bs;var i,s=Os,a=s.length,l,d="value"in yn?yn.value:yn.textContent,h=d.length;for(i=0;i<a&&s[i]===d[i];i++);var _=a-i;for(l=1;l<=_&&s[a-l]===d[h-l];l++);return Bs=d.slice(i,1<l?1-l:void 0)}function or(i){var s=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&s===13&&(i=13)):i=s,i===10&&(i=13),32<=i||i===13?i:0}function js(){return!0}function hn(){return!1}function ki(i){function s(a,l,d,h,_){this._reactName=a,this._targetInst=d,this.type=l,this.nativeEvent=h,this.target=_,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(h):h[T]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?js:hn,this.isPropagationStopped=hn,this}return b(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=js)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=js)},persist:function(){},isPersistent:js}),s}var Gn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},w=ki(Gn),E=b({},Gn,{view:0,detail:0}),z=ki(E),oe,Se,pe,Me=b({},E,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zs,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!==pe&&(pe&&i.type==="mousemove"?(oe=i.screenX-pe.screenX,Se=i.screenY-pe.screenY):Se=oe=0,pe=i),oe)},movementY:function(i){return"movementY"in i?i.movementY:Se}}),Qe=ki(Me),ot=b({},Me,{dataTransfer:0}),Si=ki(ot),Wi=b({},E,{relatedTarget:0}),Is=ki(Wi),zn=b({},Gn,{animationName:0,elapsedTime:0,pseudoElement:0}),Uo=ki(zn),Gr=b({},Gn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Zl=ki(Gr),tn=b({},Gn,{data:0}),Ko=ki(tn),Fo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ju={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"},ed={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function td(i){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(i):(i=ed[i])?!!s[i]:!1}function zs(){return td}var nn=b({},E,{key:function(i){if(i.key){var s=Fo[i.key]||i.key;if(s!=="Unidentified")return s}return i.type==="keypress"?(i=or(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?Ju[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zs,charCode:function(i){return i.type==="keypress"?or(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?or(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Xf=ki(nn),id=b({},Me,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ql=ki(id),nd=b({},E,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zs}),Gf=ki(nd),sd=b({},Gn,{propertyName:0,elapsedTime:0,pseudoElement:0}),lr=ki(sd),Jl=b({},Me,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Zf=ki(Jl),Qf=b({},Gn,{newState:0,oldState:0}),Jf=ki(Qf),ec=[9,13,27,32],Ga=yi&&"CompositionEvent"in window,cr=null;yi&&"documentMode"in document&&(cr=document.documentMode);var Wo=yi&&"TextEvent"in window&&!cr,tc=yi&&(!Ga||cr&&8<cr&&11>=cr),ic=" ",rd=!1;function nc(i,s){switch(i){case"keyup":return ec.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ad(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Zr=!1;function ep(i,s){switch(i){case"compositionend":return ad(s);case"keypress":return s.which!==32?null:(rd=!0,ic);case"textInput":return i=s.data,i===ic&&rd?null:i;default:return null}}function od(i,s){if(Zr)return i==="compositionend"||!Ga&&nc(i,s)?(i=ar(),Bs=Os=yn=null,Zr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return tc&&s.locale!=="ko"?null:s.data;default:return null}}var sc={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 Za(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s==="input"?!!sc[i.type]:s==="textarea"}function rc(i,s,a,l){Fi?ai?ai.push(l):ai=[l]:Fi=l,s=ih(s,"onChange"),0<s.length&&(a=new w("onChange","change",null,a,l),i.push({event:a,listeners:s}))}var Qr=null,Qa=null;function ld(i){a0(i,0)}function Ja(i){var s=ps(i);if(Ki(s))return i}function ac(i,s){if(i==="change")return s}var cd=!1;if(yi){var $o;if(yi){var Zn="oninput"in document;if(!Zn){var ud=document.createElement("div");ud.setAttribute("oninput","return;"),Zn=typeof ud.oninput=="function"}$o=Zn}else $o=!1;cd=$o&&(!document.documentMode||9<document.documentMode)}function dd(){Qr&&(Qr.detachEvent("onpropertychange",oc),Qa=Qr=null)}function oc(i){if(i.propertyName==="value"&&Ja(Qa)){var s=[];rc(s,Qa,i,Yr(i)),Xa(ld,s)}}function tp(i,s,a){i==="focusin"?(dd(),Qr=s,Qa=a,Qr.attachEvent("onpropertychange",oc)):i==="focusout"&&dd()}function ip(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ja(Qa)}function ur(i,s){if(i==="click")return Ja(s)}function np(i,s){if(i==="input"||i==="change")return Ja(s)}function sp(i,s){return i===s&&(i!==0||1/i===1/s)||i!==i&&s!==s}var Sn=typeof Object.is=="function"?Object.is:sp;function Jr(i,s){if(Sn(i,s))return!0;if(typeof i!="object"||i===null||typeof s!="object"||s===null)return!1;var a=Object.keys(i),l=Object.keys(s);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var d=a[l];if(!de.call(s,d)||!Sn(i[d],s[d]))return!1}return!0}function Ss(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function hd(i,s){var a=Ss(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=s&&l>=s)return{node:a,offset:s-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ss(a)}}function fd(i,s){return i&&s?i===s?!0:i&&i.nodeType===3?!1:s&&s.nodeType===3?fd(i,s.parentNode):"contains"in i?i.contains(s):i.compareDocumentPosition?!!(i.compareDocumentPosition(s)&16):!1:!1}function pd(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var s=vs(i.document);s instanceof i.HTMLIFrameElement;){try{var a=typeof s.contentWindow.location.href=="string"}catch{a=!1}if(a)i=s.contentWindow;else break;s=vs(i.document)}return s}function eo(i){var s=i&&i.nodeName&&i.nodeName.toLowerCase();return s&&(s==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||s==="textarea"||i.contentEditable==="true")}var rp=yi&&"documentMode"in document&&11>=document.documentMode,dr=null,x=null,I=null,Te=!1;function qe(i,s,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Te||dr==null||dr!==vs(l)||(l=dr,"selectionStart"in l&&eo(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),I&&Jr(I,l)||(I=l,l=ih(x,"onSelect"),0<l.length&&(s=new w("onSelect","select",null,s,a),i.push({event:s,listeners:l}),s.target=dr)))}function Ke(i,s){var a={};return a[i.toLowerCase()]=s.toLowerCase(),a["Webkit"+i]="webkit"+s,a["Moz"+i]="moz"+s,a}var et={animationend:Ke("Animation","AnimationEnd"),animationiteration:Ke("Animation","AnimationIteration"),animationstart:Ke("Animation","AnimationStart"),transitionrun:Ke("Transition","TransitionRun"),transitionstart:Ke("Transition","TransitionStart"),transitioncancel:Ke("Transition","TransitionCancel"),transitionend:Ke("Transition","TransitionEnd")},dt={},pt={};yi&&(pt=document.createElement("div").style,"AnimationEvent"in window||(delete et.animationend.animation,delete et.animationiteration.animation,delete et.animationstart.animation),"TransitionEvent"in window||delete et.transitionend.transition);function Ve(i){if(dt[i])return dt[i];if(!et[i])return i;var s=et[i],a;for(a in s)if(s.hasOwnProperty(a)&&a in pt)return dt[i]=s[a];return i}var qt=Ve("animationend"),Ot=Ve("animationiteration"),At=Ve("animationstart"),Ps=Ve("transitionrun"),qo=Ve("transitionstart"),Hs=Ve("transitioncancel"),lc=Ve("transitionend"),cc=new Map,ap="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(" ");ap.push("scrollEnd");function ws(i,s){cc.set(i,s),$t(s,[i])}var md=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Qn=[],Vo=0,op=0;function gd(){for(var i=Vo,s=op=Vo=0;s<i;){var a=Qn[s];Qn[s++]=null;var l=Qn[s];Qn[s++]=null;var d=Qn[s];Qn[s++]=null;var h=Qn[s];if(Qn[s++]=null,l!==null&&d!==null){var _=l.pending;_===null?d.next=d:(d.next=_.next,_.next=d),l.pending=d}h!==0&&Ub(a,d,h)}}function vd(i,s,a,l){Qn[Vo++]=i,Qn[Vo++]=s,Qn[Vo++]=a,Qn[Vo++]=l,op|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function lp(i,s,a,l){return vd(i,s,a,l),_d(i)}function to(i,s){return vd(i,null,null,s),_d(i)}function Ub(i,s,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var d=!1,h=i.return;h!==null;)h.childLanes|=a,l=h.alternate,l!==null&&(l.childLanes|=a),h.tag===22&&(i=h.stateNode,i===null||i._visibility&1||(d=!0)),i=h,h=h.return;return i.tag===3?(h=i.stateNode,d&&s!==null&&(d=31-ut(a),i=h.hiddenUpdates,l=i[d],l===null?i[d]=[s]:l.push(s),s.lane=a|536870912),h):null}function _d(i){if(50<Nc)throw Nc=0,vm=null,Error(r(185));for(var s=i.return;s!==null;)i=s,s=i.return;return i.tag===3?i.stateNode:null}var Yo={};function UT(i,s,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pn(i,s,a,l){return new UT(i,s,a,l)}function cp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function hr(i,s){var a=i.alternate;return a===null?(a=Pn(i.tag,s,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=s,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,s=i.dependencies,a.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function Kb(i,s){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=s,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,s=a.dependencies,i.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),i}function bd(i,s,a,l,d,h){var _=0;if(l=i,typeof i=="function")cp(i)&&(_=1);else if(typeof i=="string")_=qE(i,a,Ce.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case re:return i=Pn(31,a,s,d),i.elementType=re,i.lanes=h,i;case D:return io(a.children,d,h,s);case B:_=8,d|=24;break;case A:return i=Pn(12,a,s,d|2),i.elementType=A,i.lanes=h,i;case se:return i=Pn(13,a,s,d),i.elementType=se,i.lanes=h,i;case J:return i=Pn(19,a,s,d),i.elementType=J,i.lanes=h,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case H:_=9;break e;case $:_=11;break e;case W:_=14;break e;case xe:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return s=Pn(_,a,s,d),s.elementType=i,s.type=l,s.lanes=h,s}function io(i,s,a,l){return i=Pn(7,i,l,s),i.lanes=a,i}function up(i,s,a){return i=Pn(6,i,null,s),i.lanes=a,i}function Fb(i){var s=Pn(18,null,null,0);return s.stateNode=i,s}function dp(i,s,a){return s=Pn(4,i.children!==null?i.children:[],i.key,s),s.lanes=a,s.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},s}var Wb=new WeakMap;function Jn(i,s){if(typeof i=="object"&&i!==null){var a=Wb.get(i);return a!==void 0?a:(s={value:i,source:s,stack:ke(s)},Wb.set(i,s),s)}return{value:i,source:s,stack:ke(s)}}var Xo=[],Go=0,yd=null,uc=0,es=[],ts=0,ea=null,Us=1,Ks="";function fr(i,s){Xo[Go++]=uc,Xo[Go++]=yd,yd=i,uc=s}function $b(i,s,a){es[ts++]=Us,es[ts++]=Ks,es[ts++]=ea,ea=i;var l=Us;i=Ks;var d=32-ut(l)-1;l&=~(1<<d),a+=1;var h=32-ut(s)+d;if(30<h){var _=d-d%5;h=(l&(1<<_)-1).toString(32),l>>=_,d-=_,Us=1<<32-ut(s)+d|a<<d|l,Ks=h+i}else Us=1<<h|a<<d|l,Ks=i}function hp(i){i.return!==null&&(fr(i,1),$b(i,1,0))}function fp(i){for(;i===yd;)yd=Xo[--Go],Xo[Go]=null,uc=Xo[--Go],Xo[Go]=null;for(;i===ea;)ea=es[--ts],es[ts]=null,Ks=es[--ts],es[ts]=null,Us=es[--ts],es[ts]=null}function qb(i,s){es[ts++]=Us,es[ts++]=Ks,es[ts++]=ea,Us=s.id,Ks=s.overflow,ea=i}var sn=null,Zt=null,xt=!1,ta=null,is=!1,pp=Error(r(519));function ia(i){var s=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw dc(Jn(s,i)),pp}function Vb(i){var s=i.stateNode,a=i.type,l=i.memoizedProps;switch(s[vi]=i,s[_i]=l,a){case"dialog":bt("cancel",s),bt("close",s);break;case"iframe":case"object":case"embed":bt("load",s);break;case"video":case"audio":for(a=0;a<Lc.length;a++)bt(Lc[a],s);break;case"source":bt("error",s);break;case"img":case"image":case"link":bt("error",s),bt("load",s);break;case"details":bt("toggle",s);break;case"input":bt("invalid",s),_s(s,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":bt("invalid",s);break;case"textarea":bt("invalid",s),Ya(s,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||s.textContent===""+a||l.suppressHydrationWarning===!0||u0(s.textContent,a)?(l.popover!=null&&(bt("beforetoggle",s),bt("toggle",s)),l.onScroll!=null&&bt("scroll",s),l.onScrollEnd!=null&&bt("scrollend",s),l.onClick!=null&&(s.onclick=Xn),s=!0):s=!1,s||ia(i,!0)}function Yb(i){for(sn=i.return;sn;)switch(sn.tag){case 5:case 31:case 13:is=!1;return;case 27:case 3:is=!0;return;default:sn=sn.return}}function Zo(i){if(i!==sn)return!1;if(!xt)return Yb(i),xt=!0,!1;var s=i.tag,a;if((a=s!==3&&s!==27)&&((a=s===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||Am(i.type,i.memoizedProps)),a=!a),a&&Zt&&ia(i),Yb(i),s===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Zt=b0(i)}else if(s===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Zt=b0(i)}else s===27?(s=Zt,ga(i.type)?(i=Im,Im=null,Zt=i):Zt=s):Zt=sn?ss(i.stateNode.nextSibling):null;return!0}function no(){Zt=sn=null,xt=!1}function mp(){var i=ta;return i!==null&&(Mn===null?Mn=i:Mn.push.apply(Mn,i),ta=null),i}function dc(i){ta===null?ta=[i]:ta.push(i)}var gp=N(null),so=null,pr=null;function na(i,s,a){ue(gp,s._currentValue),s._currentValue=a}function mr(i){i._currentValue=gp.current,U(gp)}function vp(i,s,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&s)!==s?(i.childLanes|=s,l!==null&&(l.childLanes|=s)):l!==null&&(l.childLanes&s)!==s&&(l.childLanes|=s),i===a)break;i=i.return}}function _p(i,s,a,l){var d=i.child;for(d!==null&&(d.return=i);d!==null;){var h=d.dependencies;if(h!==null){var _=d.child;h=h.firstContext;e:for(;h!==null;){var T=h;h=d;for(var L=0;L<s.length;L++)if(T.context===s[L]){h.lanes|=a,T=h.alternate,T!==null&&(T.lanes|=a),vp(h.return,a,i),l||(_=null);break e}h=T.next}}else if(d.tag===18){if(_=d.return,_===null)throw Error(r(341));_.lanes|=a,h=_.alternate,h!==null&&(h.lanes|=a),vp(_,a,i),_=null}else _=d.child;if(_!==null)_.return=d;else for(_=d;_!==null;){if(_===i){_=null;break}if(d=_.sibling,d!==null){d.return=_.return,_=d;break}_=_.return}d=_}}function Qo(i,s,a,l){i=null;for(var d=s,h=!1;d!==null;){if(!h){if((d.flags&524288)!==0)h=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var _=d.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var T=d.type;Sn(d.pendingProps.value,_.value)||(i!==null?i.push(T):i=[T])}}else if(d===Be.current){if(_=d.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(i!==null?i.push(zc):i=[zc])}d=d.return}i!==null&&_p(s,i,a,l),s.flags|=262144}function Sd(i){for(i=i.firstContext;i!==null;){if(!Sn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ro(i){so=i,pr=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function rn(i){return Xb(so,i)}function wd(i,s){return so===null&&ro(i),Xb(i,s)}function Xb(i,s){var a=s._currentValue;if(s={context:s,memoizedValue:a,next:null},pr===null){if(i===null)throw Error(r(308));pr=s,i.dependencies={lanes:0,firstContext:s},i.flags|=524288}else pr=pr.next=s;return a}var KT=typeof AbortController<"u"?AbortController:function(){var i=[],s=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){s.aborted=!0,i.forEach(function(a){return a()})}},FT=e.unstable_scheduleCallback,WT=e.unstable_NormalPriority,Ti={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function bp(){return{controller:new KT,data:new Map,refCount:0}}function hc(i){i.refCount--,i.refCount===0&&FT(WT,function(){i.controller.abort()})}var fc=null,yp=0,Jo=0,el=null;function $T(i,s){if(fc===null){var a=fc=[];yp=0,Jo=Cm(),el={status:"pending",value:void 0,then:function(l){a.push(l)}}}return yp++,s.then(Gb,Gb),s}function Gb(){if(--yp===0&&fc!==null){el!==null&&(el.status="fulfilled");var i=fc;fc=null,Jo=0,el=null;for(var s=0;s<i.length;s++)(0,i[s])()}}function qT(i,s){var a=[],l={status:"pending",value:null,reason:null,then:function(d){a.push(d)}};return i.then(function(){l.status="fulfilled",l.value=s;for(var d=0;d<a.length;d++)(0,a[d])(s)},function(d){for(l.status="rejected",l.reason=d,d=0;d<a.length;d++)(0,a[d])(void 0)}),l}var Zb=O.S;O.S=function(i,s){OS=ct(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&$T(i,s),Zb!==null&&Zb(i,s)};var ao=N(null);function Sp(){var i=ao.current;return i!==null?i:Vt.pooledCache}function Cd(i,s){s===null?ue(ao,ao.current):ue(ao,s.pool)}function Qb(){var i=Sp();return i===null?null:{parent:Ti._currentValue,pool:i}}var tl=Error(r(460)),wp=Error(r(474)),xd=Error(r(542)),kd={then:function(){}};function Jb(i){return i=i.status,i==="fulfilled"||i==="rejected"}function ey(i,s,a){switch(a=i[a],a===void 0?i.push(s):a!==s&&(s.then(Xn,Xn),s=a),s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,iy(i),i;default:if(typeof s.status=="string")s.then(Xn,Xn);else{if(i=Vt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=s,i.status="pending",i.then(function(l){if(s.status==="pending"){var d=s;d.status="fulfilled",d.value=l}},function(l){if(s.status==="pending"){var d=s;d.status="rejected",d.reason=l}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw i=s.reason,iy(i),i}throw lo=s,tl}}function oo(i){try{var s=i._init;return s(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(lo=a,tl):a}}var lo=null;function ty(){if(lo===null)throw Error(r(459));var i=lo;return lo=null,i}function iy(i){if(i===tl||i===xd)throw Error(r(483))}var il=null,pc=0;function Td(i){var s=pc;return pc+=1,il===null&&(il=[]),ey(il,i,s)}function mc(i,s){s=s.props.ref,i.ref=s!==void 0?s:null}function Ed(i,s){throw s.$$typeof===C?Error(r(525)):(i=Object.prototype.toString.call(s),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":i)))}function ny(i){function s(K,P){if(i){var G=K.deletions;G===null?(K.deletions=[P],K.flags|=16):G.push(P)}}function a(K,P){if(!i)return null;for(;P!==null;)s(K,P),P=P.sibling;return null}function l(K){for(var P=new Map;K!==null;)K.key!==null?P.set(K.key,K):P.set(K.index,K),K=K.sibling;return P}function d(K,P){return K=hr(K,P),K.index=0,K.sibling=null,K}function h(K,P,G){return K.index=G,i?(G=K.alternate,G!==null?(G=G.index,G<P?(K.flags|=67108866,P):G):(K.flags|=67108866,P)):(K.flags|=1048576,P)}function _(K){return i&&K.alternate===null&&(K.flags|=67108866),K}function T(K,P,G,ve){return P===null||P.tag!==6?(P=up(G,K.mode,ve),P.return=K,P):(P=d(P,G),P.return=K,P)}function L(K,P,G,ve){var Ge=G.type;return Ge===D?he(K,P,G.props.children,ve,G.key):P!==null&&(P.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===xe&&oo(Ge)===P.type)?(P=d(P,G.props),mc(P,G),P.return=K,P):(P=bd(G.type,G.key,G.props,null,K.mode,ve),mc(P,G),P.return=K,P)}function Z(K,P,G,ve){return P===null||P.tag!==4||P.stateNode.containerInfo!==G.containerInfo||P.stateNode.implementation!==G.implementation?(P=dp(G,K.mode,ve),P.return=K,P):(P=d(P,G.children||[]),P.return=K,P)}function he(K,P,G,ve,Ge){return P===null||P.tag!==7?(P=io(G,K.mode,ve,Ge),P.return=K,P):(P=d(P,G),P.return=K,P)}function _e(K,P,G){if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return P=up(""+P,K.mode,G),P.return=K,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case k:return G=bd(P.type,P.key,P.props,null,K.mode,G),mc(G,P),G.return=K,G;case S:return P=dp(P,K.mode,G),P.return=K,P;case xe:return P=oo(P),_e(K,P,G)}if(le(P)||V(P))return P=io(P,K.mode,G,null),P.return=K,P;if(typeof P.then=="function")return _e(K,Td(P),G);if(P.$$typeof===Y)return _e(K,wd(K,P),G);Ed(K,P)}return null}function te(K,P,G,ve){var Ge=P!==null?P.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Ge!==null?null:T(K,P,""+G,ve);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case k:return G.key===Ge?L(K,P,G,ve):null;case S:return G.key===Ge?Z(K,P,G,ve):null;case xe:return G=oo(G),te(K,P,G,ve)}if(le(G)||V(G))return Ge!==null?null:he(K,P,G,ve,null);if(typeof G.then=="function")return te(K,P,Td(G),ve);if(G.$$typeof===Y)return te(K,P,wd(K,G),ve);Ed(K,G)}return null}function ce(K,P,G,ve,Ge){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return K=K.get(G)||null,T(P,K,""+ve,Ge);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case k:return K=K.get(ve.key===null?G:ve.key)||null,L(P,K,ve,Ge);case S:return K=K.get(ve.key===null?G:ve.key)||null,Z(P,K,ve,Ge);case xe:return ve=oo(ve),ce(K,P,G,ve,Ge)}if(le(ve)||V(ve))return K=K.get(G)||null,he(P,K,ve,Ge,null);if(typeof ve.then=="function")return ce(K,P,G,Td(ve),Ge);if(ve.$$typeof===Y)return ce(K,P,G,wd(P,ve),Ge);Ed(P,ve)}return null}function He(K,P,G,ve){for(var Ge=null,Dt=null,We=P,ht=P=0,Ct=null;We!==null&&ht<G.length;ht++){We.index>ht?(Ct=We,We=null):Ct=We.sibling;var Rt=te(K,We,G[ht],ve);if(Rt===null){We===null&&(We=Ct);break}i&&We&&Rt.alternate===null&&s(K,We),P=h(Rt,P,ht),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt,We=Ct}if(ht===G.length)return a(K,We),xt&&fr(K,ht),Ge;if(We===null){for(;ht<G.length;ht++)We=_e(K,G[ht],ve),We!==null&&(P=h(We,P,ht),Dt===null?Ge=We:Dt.sibling=We,Dt=We);return xt&&fr(K,ht),Ge}for(We=l(We);ht<G.length;ht++)Ct=ce(We,K,ht,G[ht],ve),Ct!==null&&(i&&Ct.alternate!==null&&We.delete(Ct.key===null?ht:Ct.key),P=h(Ct,P,ht),Dt===null?Ge=Ct:Dt.sibling=Ct,Dt=Ct);return i&&We.forEach(function(Sa){return s(K,Sa)}),xt&&fr(K,ht),Ge}function Je(K,P,G,ve){if(G==null)throw Error(r(151));for(var Ge=null,Dt=null,We=P,ht=P=0,Ct=null,Rt=G.next();We!==null&&!Rt.done;ht++,Rt=G.next()){We.index>ht?(Ct=We,We=null):Ct=We.sibling;var Sa=te(K,We,Rt.value,ve);if(Sa===null){We===null&&(We=Ct);break}i&&We&&Sa.alternate===null&&s(K,We),P=h(Sa,P,ht),Dt===null?Ge=Sa:Dt.sibling=Sa,Dt=Sa,We=Ct}if(Rt.done)return a(K,We),xt&&fr(K,ht),Ge;if(We===null){for(;!Rt.done;ht++,Rt=G.next())Rt=_e(K,Rt.value,ve),Rt!==null&&(P=h(Rt,P,ht),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt);return xt&&fr(K,ht),Ge}for(We=l(We);!Rt.done;ht++,Rt=G.next())Rt=ce(We,K,ht,Rt.value,ve),Rt!==null&&(i&&Rt.alternate!==null&&We.delete(Rt.key===null?ht:Rt.key),P=h(Rt,P,ht),Dt===null?Ge=Rt:Dt.sibling=Rt,Dt=Rt);return i&&We.forEach(function(n2){return s(K,n2)}),xt&&fr(K,ht),Ge}function Ut(K,P,G,ve){if(typeof G=="object"&&G!==null&&G.type===D&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case k:e:{for(var Ge=G.key;P!==null;){if(P.key===Ge){if(Ge=G.type,Ge===D){if(P.tag===7){a(K,P.sibling),ve=d(P,G.props.children),ve.return=K,K=ve;break e}}else if(P.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===xe&&oo(Ge)===P.type){a(K,P.sibling),ve=d(P,G.props),mc(ve,G),ve.return=K,K=ve;break e}a(K,P);break}else s(K,P);P=P.sibling}G.type===D?(ve=io(G.props.children,K.mode,ve,G.key),ve.return=K,K=ve):(ve=bd(G.type,G.key,G.props,null,K.mode,ve),mc(ve,G),ve.return=K,K=ve)}return _(K);case S:e:{for(Ge=G.key;P!==null;){if(P.key===Ge)if(P.tag===4&&P.stateNode.containerInfo===G.containerInfo&&P.stateNode.implementation===G.implementation){a(K,P.sibling),ve=d(P,G.children||[]),ve.return=K,K=ve;break e}else{a(K,P);break}else s(K,P);P=P.sibling}ve=dp(G,K.mode,ve),ve.return=K,K=ve}return _(K);case xe:return G=oo(G),Ut(K,P,G,ve)}if(le(G))return He(K,P,G,ve);if(V(G)){if(Ge=V(G),typeof Ge!="function")throw Error(r(150));return G=Ge.call(G),Je(K,P,G,ve)}if(typeof G.then=="function")return Ut(K,P,Td(G),ve);if(G.$$typeof===Y)return Ut(K,P,wd(K,G),ve);Ed(K,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,P!==null&&P.tag===6?(a(K,P.sibling),ve=d(P,G),ve.return=K,K=ve):(a(K,P),ve=up(G,K.mode,ve),ve.return=K,K=ve),_(K)):a(K,P)}return function(K,P,G,ve){try{pc=0;var Ge=Ut(K,P,G,ve);return il=null,Ge}catch(We){if(We===tl||We===xd)throw We;var Dt=Pn(29,We,null,K.mode);return Dt.lanes=ve,Dt.return=K,Dt}}}var co=ny(!0),sy=ny(!1),sa=!1;function Cp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xp(i,s){i=i.updateQueue,s.updateQueue===i&&(s.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ra(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function aa(i,s,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(Mt&2)!==0){var d=l.pending;return d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s,s=_d(i),Ub(i,null,a),s}return vd(i,l,s,a),_d(i)}function gc(i,s,a){if(s=s.updateQueue,s!==null&&(s=s.shared,(a&4194048)!==0)){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,ei(i,a)}}function kp(i,s){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var d=null,h=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};h===null?d=h=_:h=h.next=_,a=a.next}while(a!==null);h===null?d=h=s:h=h.next=s}else d=h=s;a={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=s:i.next=s,a.lastBaseUpdate=s}var Tp=!1;function vc(){if(Tp){var i=el;if(i!==null)throw i}}function _c(i,s,a,l){Tp=!1;var d=i.updateQueue;sa=!1;var h=d.firstBaseUpdate,_=d.lastBaseUpdate,T=d.shared.pending;if(T!==null){d.shared.pending=null;var L=T,Z=L.next;L.next=null,_===null?h=Z:_.next=Z,_=L;var he=i.alternate;he!==null&&(he=he.updateQueue,T=he.lastBaseUpdate,T!==_&&(T===null?he.firstBaseUpdate=Z:T.next=Z,he.lastBaseUpdate=L))}if(h!==null){var _e=d.baseState;_=0,he=Z=L=null,T=h;do{var te=T.lane&-536870913,ce=te!==T.lane;if(ce?(wt&te)===te:(l&te)===te){te!==0&&te===Jo&&(Tp=!0),he!==null&&(he=he.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var He=i,Je=T;te=s;var Ut=a;switch(Je.tag){case 1:if(He=Je.payload,typeof He=="function"){_e=He.call(Ut,_e,te);break e}_e=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=Je.payload,te=typeof He=="function"?He.call(Ut,_e,te):He,te==null)break e;_e=b({},_e,te);break e;case 2:sa=!0}}te=T.callback,te!==null&&(i.flags|=64,ce&&(i.flags|=8192),ce=d.callbacks,ce===null?d.callbacks=[te]:ce.push(te))}else ce={lane:te,tag:T.tag,payload:T.payload,callback:T.callback,next:null},he===null?(Z=he=ce,L=_e):he=he.next=ce,_|=te;if(T=T.next,T===null){if(T=d.shared.pending,T===null)break;ce=T,T=ce.next,ce.next=null,d.lastBaseUpdate=ce,d.shared.pending=null}}while(!0);he===null&&(L=_e),d.baseState=L,d.firstBaseUpdate=Z,d.lastBaseUpdate=he,h===null&&(d.shared.lanes=0),da|=_,i.lanes=_,i.memoizedState=_e}}function ry(i,s){if(typeof i!="function")throw Error(r(191,i));i.call(s)}function ay(i,s){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)ry(a[i],s)}var nl=N(null),Dd=N(0);function oy(i,s){i=xr,ue(Dd,i),ue(nl,s),xr=i|s.baseLanes}function Ep(){ue(Dd,xr),ue(nl,nl.current)}function Dp(){xr=Dd.current,U(nl),U(Dd)}var Hn=N(null),ns=null;function oa(i){var s=i.alternate;ue(wi,wi.current&1),ue(Hn,i),ns===null&&(s===null||nl.current!==null||s.memoizedState!==null)&&(ns=i)}function Rp(i){ue(wi,wi.current),ue(Hn,i),ns===null&&(ns=i)}function ly(i){i.tag===22?(ue(wi,wi.current),ue(Hn,i),ns===null&&(ns=i)):la()}function la(){ue(wi,wi.current),ue(Hn,Hn.current)}function Un(i){U(Hn),ns===i&&(ns=null),U(wi)}var wi=N(0);function Rd(i){for(var s=i;s!==null;){if(s.tag===13){var a=s.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Bm(a)||jm(a)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var gr=0,lt=null,Pt=null,Ei=null,Md=!1,sl=!1,uo=!1,Nd=0,bc=0,rl=null,VT=0;function di(){throw Error(r(321))}function Mp(i,s){if(s===null)return!1;for(var a=0;a<s.length&&a<i.length;a++)if(!Sn(i[a],s[a]))return!1;return!0}function Np(i,s,a,l,d,h){return gr=h,lt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,O.H=i===null||i.memoizedState===null?$y:qp,uo=!1,h=a(l,d),uo=!1,sl&&(h=uy(s,a,l,d)),cy(i),h}function cy(i){O.H=wc;var s=Pt!==null&&Pt.next!==null;if(gr=0,Ei=Pt=lt=null,Md=!1,bc=0,rl=null,s)throw Error(r(300));i===null||Di||(i=i.dependencies,i!==null&&Sd(i)&&(Di=!0))}function uy(i,s,a,l){lt=i;var d=0;do{if(sl&&(rl=null),bc=0,sl=!1,25<=d)throw Error(r(301));if(d+=1,Ei=Pt=null,i.updateQueue!=null){var h=i.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}O.H=qy,h=s(a,l)}while(sl);return h}function YT(){var i=O.H,s=i.useState()[0];return s=typeof s.then=="function"?yc(s):s,i=i.useState()[0],(Pt!==null?Pt.memoizedState:null)!==i&&(lt.flags|=1024),s}function Ap(){var i=Nd!==0;return Nd=0,i}function Lp(i,s,a){s.updateQueue=i.updateQueue,s.flags&=-2053,i.lanes&=~a}function Op(i){if(Md){for(i=i.memoizedState;i!==null;){var s=i.queue;s!==null&&(s.pending=null),i=i.next}Md=!1}gr=0,Ei=Pt=lt=null,sl=!1,bc=Nd=0,rl=null}function wn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ei===null?lt.memoizedState=Ei=i:Ei=Ei.next=i,Ei}function Ci(){if(Pt===null){var i=lt.alternate;i=i!==null?i.memoizedState:null}else i=Pt.next;var s=Ei===null?lt.memoizedState:Ei.next;if(s!==null)Ei=s,Pt=i;else{if(i===null)throw lt.alternate===null?Error(r(467)):Error(r(310));Pt=i,i={memoizedState:Pt.memoizedState,baseState:Pt.baseState,baseQueue:Pt.baseQueue,queue:Pt.queue,next:null},Ei===null?lt.memoizedState=Ei=i:Ei=Ei.next=i}return Ei}function Ad(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function yc(i){var s=bc;return bc+=1,rl===null&&(rl=[]),i=ey(rl,i,s),s=lt,(Ei===null?s.memoizedState:Ei.next)===null&&(s=s.alternate,O.H=s===null||s.memoizedState===null?$y:qp),i}function Ld(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return yc(i);if(i.$$typeof===Y)return rn(i)}throw Error(r(438,String(i)))}function Bp(i){var s=null,a=lt.updateQueue;if(a!==null&&(s=a.memoCache),s==null){var l=lt.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(s={data:l.data.map(function(d){return d.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),a===null&&(a=Ad(),lt.updateQueue=a),a.memoCache=s,a=s.data[s.index],a===void 0)for(a=s.data[s.index]=Array(i),l=0;l<i;l++)a[l]=Ee;return s.index++,a}function vr(i,s){return typeof s=="function"?s(i):s}function Od(i){var s=Ci();return jp(s,Pt,i)}function jp(i,s,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var d=i.baseQueue,h=l.pending;if(h!==null){if(d!==null){var _=d.next;d.next=h.next,h.next=_}s.baseQueue=d=h,l.pending=null}if(h=i.baseState,d===null)i.memoizedState=h;else{s=d.next;var T=_=null,L=null,Z=s,he=!1;do{var _e=Z.lane&-536870913;if(_e!==Z.lane?(wt&_e)===_e:(gr&_e)===_e){var te=Z.revertLane;if(te===0)L!==null&&(L=L.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),_e===Jo&&(he=!0);else if((gr&te)===te){Z=Z.next,te===Jo&&(he=!0);continue}else _e={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},L===null?(T=L=_e,_=h):L=L.next=_e,lt.lanes|=te,da|=te;_e=Z.action,uo&&a(h,_e),h=Z.hasEagerState?Z.eagerState:a(h,_e)}else te={lane:_e,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},L===null?(T=L=te,_=h):L=L.next=te,lt.lanes|=_e,da|=_e;Z=Z.next}while(Z!==null&&Z!==s);if(L===null?_=h:L.next=T,!Sn(h,i.memoizedState)&&(Di=!0,he&&(a=el,a!==null)))throw a;i.memoizedState=h,i.baseState=_,i.baseQueue=L,l.lastRenderedState=h}return d===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Ip(i){var s=Ci(),a=s.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,d=a.pending,h=s.memoizedState;if(d!==null){a.pending=null;var _=d=d.next;do h=i(h,_.action),_=_.next;while(_!==d);Sn(h,s.memoizedState)||(Di=!0),s.memoizedState=h,s.baseQueue===null&&(s.baseState=h),a.lastRenderedState=h}return[h,l]}function dy(i,s,a){var l=lt,d=Ci(),h=xt;if(h){if(a===void 0)throw Error(r(407));a=a()}else a=s();var _=!Sn((Pt||d).memoizedState,a);if(_&&(d.memoizedState=a,Di=!0),d=d.queue,Hp(py.bind(null,l,d,i),[i]),d.getSnapshot!==s||_||Ei!==null&&Ei.memoizedState.tag&1){if(l.flags|=2048,al(9,{destroy:void 0},fy.bind(null,l,d,a,s),null),Vt===null)throw Error(r(349));h||(gr&127)!==0||hy(l,s,a)}return a}function hy(i,s,a){i.flags|=16384,i={getSnapshot:s,value:a},s=lt.updateQueue,s===null?(s=Ad(),lt.updateQueue=s,s.stores=[i]):(a=s.stores,a===null?s.stores=[i]:a.push(i))}function fy(i,s,a,l){s.value=a,s.getSnapshot=l,my(s)&&gy(i)}function py(i,s,a){return a(function(){my(s)&&gy(i)})}function my(i){var s=i.getSnapshot;i=i.value;try{var a=s();return!Sn(i,a)}catch{return!0}}function gy(i){var s=to(i,2);s!==null&&Nn(s,i,2)}function zp(i){var s=wn();if(typeof i=="function"){var a=i;if(i=a(),uo){Et(!0);try{a()}finally{Et(!1)}}}return s.memoizedState=s.baseState=i,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:i},s}function vy(i,s,a,l){return i.baseState=a,jp(i,Pt,typeof l=="function"?l:vr)}function XT(i,s,a,l,d){if(Id(i))throw Error(r(485));if(i=s.action,i!==null){var h={payload:d,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){h.listeners.push(_)}};O.T!==null?a(!0):h.isTransition=!1,l(h),a=s.pending,a===null?(h.next=s.pending=h,_y(s,h)):(h.next=a.next,s.pending=a.next=h)}}function _y(i,s){var a=s.action,l=s.payload,d=i.state;if(s.isTransition){var h=O.T,_={};O.T=_;try{var T=a(d,l),L=O.S;L!==null&&L(_,T),by(i,s,T)}catch(Z){Pp(i,s,Z)}finally{h!==null&&_.types!==null&&(h.types=_.types),O.T=h}}else try{h=a(d,l),by(i,s,h)}catch(Z){Pp(i,s,Z)}}function by(i,s,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){yy(i,s,l)},function(l){return Pp(i,s,l)}):yy(i,s,a)}function yy(i,s,a){s.status="fulfilled",s.value=a,Sy(s),i.state=a,s=i.pending,s!==null&&(a=s.next,a===s?i.pending=null:(a=a.next,s.next=a,_y(i,a)))}function Pp(i,s,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do s.status="rejected",s.reason=a,Sy(s),s=s.next;while(s!==l)}i.action=null}function Sy(i){i=i.listeners;for(var s=0;s<i.length;s++)(0,i[s])()}function wy(i,s){return s}function Cy(i,s){if(xt){var a=Vt.formState;if(a!==null){e:{var l=lt;if(xt){if(Zt){t:{for(var d=Zt,h=is;d.nodeType!==8;){if(!h){d=null;break t}if(d=ss(d.nextSibling),d===null){d=null;break t}}h=d.data,d=h==="F!"||h==="F"?d:null}if(d){Zt=ss(d.nextSibling),l=d.data==="F!";break e}}ia(l)}l=!1}l&&(s=a[0])}}return a=wn(),a.memoizedState=a.baseState=s,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wy,lastRenderedState:s},a.queue=l,a=Ky.bind(null,lt,l),l.dispatch=a,l=zp(!1),h=$p.bind(null,lt,!1,l.queue),l=wn(),d={state:s,dispatch:null,action:i,pending:null},l.queue=d,a=XT.bind(null,lt,d,h,a),d.dispatch=a,l.memoizedState=i,[s,a,!1]}function xy(i){var s=Ci();return ky(s,Pt,i)}function ky(i,s,a){if(s=jp(i,s,wy)[0],i=Od(vr)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var l=yc(s)}catch(_){throw _===tl?xd:_}else l=s;s=Ci();var d=s.queue,h=d.dispatch;return a!==s.memoizedState&&(lt.flags|=2048,al(9,{destroy:void 0},GT.bind(null,d,a),null)),[l,h,i]}function GT(i,s){i.action=s}function Ty(i){var s=Ci(),a=Pt;if(a!==null)return ky(s,a,i);Ci(),s=s.memoizedState,a=Ci();var l=a.queue.dispatch;return a.memoizedState=i,[s,l,!1]}function al(i,s,a,l){return i={tag:i,create:a,deps:l,inst:s,next:null},s=lt.updateQueue,s===null&&(s=Ad(),lt.updateQueue=s),a=s.lastEffect,a===null?s.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,s.lastEffect=i),i}function Ey(){return Ci().memoizedState}function Bd(i,s,a,l){var d=wn();lt.flags|=i,d.memoizedState=al(1|s,{destroy:void 0},a,l===void 0?null:l)}function jd(i,s,a,l){var d=Ci();l=l===void 0?null:l;var h=d.memoizedState.inst;Pt!==null&&l!==null&&Mp(l,Pt.memoizedState.deps)?d.memoizedState=al(s,h,a,l):(lt.flags|=i,d.memoizedState=al(1|s,h,a,l))}function Dy(i,s){Bd(8390656,8,i,s)}function Hp(i,s){jd(2048,8,i,s)}function ZT(i){lt.flags|=4;var s=lt.updateQueue;if(s===null)s=Ad(),lt.updateQueue=s,s.events=[i];else{var a=s.events;a===null?s.events=[i]:a.push(i)}}function Ry(i){var s=Ci().memoizedState;return ZT({ref:s,nextImpl:i}),function(){if((Mt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}function My(i,s){return jd(4,2,i,s)}function Ny(i,s){return jd(4,4,i,s)}function Ay(i,s){if(typeof s=="function"){i=i();var a=s(i);return function(){typeof a=="function"?a():s(null)}}if(s!=null)return i=i(),s.current=i,function(){s.current=null}}function Ly(i,s,a){a=a!=null?a.concat([i]):null,jd(4,4,Ay.bind(null,s,i),a)}function Up(){}function Oy(i,s){var a=Ci();s=s===void 0?null:s;var l=a.memoizedState;return s!==null&&Mp(s,l[1])?l[0]:(a.memoizedState=[i,s],i)}function By(i,s){var a=Ci();s=s===void 0?null:s;var l=a.memoizedState;if(s!==null&&Mp(s,l[1]))return l[0];if(l=i(),uo){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,s],l}function Kp(i,s,a){return a===void 0||(gr&1073741824)!==0&&(wt&261930)===0?i.memoizedState=s:(i.memoizedState=a,i=jS(),lt.lanes|=i,da|=i,a)}function jy(i,s,a,l){return Sn(a,s)?a:nl.current!==null?(i=Kp(i,a,l),Sn(i,s)||(Di=!0),i):(gr&42)===0||(gr&1073741824)!==0&&(wt&261930)===0?(Di=!0,i.memoizedState=a):(i=jS(),lt.lanes|=i,da|=i,s)}function Iy(i,s,a,l,d){var h=M.p;M.p=h!==0&&8>h?h:8;var _=O.T,T={};O.T=T,$p(i,!1,s,a);try{var L=d(),Z=O.S;if(Z!==null&&Z(T,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var he=qT(L,l);Sc(i,s,he,Wn(i))}else Sc(i,s,l,Wn(i))}catch(_e){Sc(i,s,{then:function(){},status:"rejected",reason:_e},Wn())}finally{M.p=h,_!==null&&T.types!==null&&(_.types=T.types),O.T=_}}function QT(){}function Fp(i,s,a,l){if(i.tag!==5)throw Error(r(476));var d=zy(i).queue;Iy(i,d,s,j,a===null?QT:function(){return Py(i),a(l)})}function zy(i){var s=i.memoizedState;if(s!==null)return s;s={memoizedState:j,baseState:j,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:j},next:null};var a={};return s.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:a},next:null},i.memoizedState=s,i=i.alternate,i!==null&&(i.memoizedState=s),s}function Py(i){var s=zy(i);s.next===null&&(s=i.alternate.memoizedState),Sc(i,s.next.queue,{},Wn())}function Wp(){return rn(zc)}function Hy(){return Ci().memoizedState}function Uy(){return Ci().memoizedState}function JT(i){for(var s=i.return;s!==null;){switch(s.tag){case 24:case 3:var a=Wn();i=ra(a);var l=aa(s,i,a);l!==null&&(Nn(l,s,a),gc(l,s,a)),s={cache:bp()},i.payload=s;return}s=s.return}}function eE(i,s,a){var l=Wn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Id(i)?Fy(s,a):(a=lp(i,s,a,l),a!==null&&(Nn(a,i,l),Wy(a,s,l)))}function Ky(i,s,a){var l=Wn();Sc(i,s,a,l)}function Sc(i,s,a,l){var d={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Id(i))Fy(s,d);else{var h=i.alternate;if(i.lanes===0&&(h===null||h.lanes===0)&&(h=s.lastRenderedReducer,h!==null))try{var _=s.lastRenderedState,T=h(_,a);if(d.hasEagerState=!0,d.eagerState=T,Sn(T,_))return vd(i,s,d,0),Vt===null&&gd(),!1}catch{}if(a=lp(i,s,d,l),a!==null)return Nn(a,i,l),Wy(a,s,l),!0}return!1}function $p(i,s,a,l){if(l={lane:2,revertLane:Cm(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Id(i)){if(s)throw Error(r(479))}else s=lp(i,a,l,2),s!==null&&Nn(s,i,2)}function Id(i){var s=i.alternate;return i===lt||s!==null&&s===lt}function Fy(i,s){sl=Md=!0;var a=i.pending;a===null?s.next=s:(s.next=a.next,a.next=s),i.pending=s}function Wy(i,s,a){if((a&4194048)!==0){var l=s.lanes;l&=i.pendingLanes,a|=l,s.lanes=a,ei(i,a)}}var wc={readContext:rn,use:Ld,useCallback:di,useContext:di,useEffect:di,useImperativeHandle:di,useLayoutEffect:di,useInsertionEffect:di,useMemo:di,useReducer:di,useRef:di,useState:di,useDebugValue:di,useDeferredValue:di,useTransition:di,useSyncExternalStore:di,useId:di,useHostTransitionStatus:di,useFormState:di,useActionState:di,useOptimistic:di,useMemoCache:di,useCacheRefresh:di};wc.useEffectEvent=di;var $y={readContext:rn,use:Ld,useCallback:function(i,s){return wn().memoizedState=[i,s===void 0?null:s],i},useContext:rn,useEffect:Dy,useImperativeHandle:function(i,s,a){a=a!=null?a.concat([i]):null,Bd(4194308,4,Ay.bind(null,s,i),a)},useLayoutEffect:function(i,s){return Bd(4194308,4,i,s)},useInsertionEffect:function(i,s){Bd(4,2,i,s)},useMemo:function(i,s){var a=wn();s=s===void 0?null:s;var l=i();if(uo){Et(!0);try{i()}finally{Et(!1)}}return a.memoizedState=[l,s],l},useReducer:function(i,s,a){var l=wn();if(a!==void 0){var d=a(s);if(uo){Et(!0);try{a(s)}finally{Et(!1)}}}else d=s;return l.memoizedState=l.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},l.queue=i,i=i.dispatch=eE.bind(null,lt,i),[l.memoizedState,i]},useRef:function(i){var s=wn();return i={current:i},s.memoizedState=i},useState:function(i){i=zp(i);var s=i.queue,a=Ky.bind(null,lt,s);return s.dispatch=a,[i.memoizedState,a]},useDebugValue:Up,useDeferredValue:function(i,s){var a=wn();return Kp(a,i,s)},useTransition:function(){var i=zp(!1);return i=Iy.bind(null,lt,i.queue,!0,!1),wn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,s,a){var l=lt,d=wn();if(xt){if(a===void 0)throw Error(r(407));a=a()}else{if(a=s(),Vt===null)throw Error(r(349));(wt&127)!==0||hy(l,s,a)}d.memoizedState=a;var h={value:a,getSnapshot:s};return d.queue=h,Dy(py.bind(null,l,h,i),[i]),l.flags|=2048,al(9,{destroy:void 0},fy.bind(null,l,h,a,s),null),a},useId:function(){var i=wn(),s=Vt.identifierPrefix;if(xt){var a=Ks,l=Us;a=(l&~(1<<32-ut(l)-1)).toString(32)+a,s="_"+s+"R_"+a,a=Nd++,0<a&&(s+="H"+a.toString(32)),s+="_"}else a=VT++,s="_"+s+"r_"+a.toString(32)+"_";return i.memoizedState=s},useHostTransitionStatus:Wp,useFormState:Cy,useActionState:Cy,useOptimistic:function(i){var s=wn();s.memoizedState=s.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=a,s=$p.bind(null,lt,!0,a),a.dispatch=s,[i,s]},useMemoCache:Bp,useCacheRefresh:function(){return wn().memoizedState=JT.bind(null,lt)},useEffectEvent:function(i){var s=wn(),a={impl:i};return s.memoizedState=a,function(){if((Mt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},qp={readContext:rn,use:Ld,useCallback:Oy,useContext:rn,useEffect:Hp,useImperativeHandle:Ly,useInsertionEffect:My,useLayoutEffect:Ny,useMemo:By,useReducer:Od,useRef:Ey,useState:function(){return Od(vr)},useDebugValue:Up,useDeferredValue:function(i,s){var a=Ci();return jy(a,Pt.memoizedState,i,s)},useTransition:function(){var i=Od(vr)[0],s=Ci().memoizedState;return[typeof i=="boolean"?i:yc(i),s]},useSyncExternalStore:dy,useId:Hy,useHostTransitionStatus:Wp,useFormState:xy,useActionState:xy,useOptimistic:function(i,s){var a=Ci();return vy(a,Pt,i,s)},useMemoCache:Bp,useCacheRefresh:Uy};qp.useEffectEvent=Ry;var qy={readContext:rn,use:Ld,useCallback:Oy,useContext:rn,useEffect:Hp,useImperativeHandle:Ly,useInsertionEffect:My,useLayoutEffect:Ny,useMemo:By,useReducer:Ip,useRef:Ey,useState:function(){return Ip(vr)},useDebugValue:Up,useDeferredValue:function(i,s){var a=Ci();return Pt===null?Kp(a,i,s):jy(a,Pt.memoizedState,i,s)},useTransition:function(){var i=Ip(vr)[0],s=Ci().memoizedState;return[typeof i=="boolean"?i:yc(i),s]},useSyncExternalStore:dy,useId:Hy,useHostTransitionStatus:Wp,useFormState:Ty,useActionState:Ty,useOptimistic:function(i,s){var a=Ci();return Pt!==null?vy(a,Pt,i,s):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Bp,useCacheRefresh:Uy};qy.useEffectEvent=Ry;function Vp(i,s,a,l){s=i.memoizedState,a=a(l,s),a=a==null?s:b({},s,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Yp={enqueueSetState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=ra(l);d.payload=s,a!=null&&(d.callback=a),s=aa(i,d,l),s!==null&&(Nn(s,i,l),gc(s,i,l))},enqueueReplaceState:function(i,s,a){i=i._reactInternals;var l=Wn(),d=ra(l);d.tag=1,d.payload=s,a!=null&&(d.callback=a),s=aa(i,d,l),s!==null&&(Nn(s,i,l),gc(s,i,l))},enqueueForceUpdate:function(i,s){i=i._reactInternals;var a=Wn(),l=ra(a);l.tag=2,s!=null&&(l.callback=s),s=aa(i,l,a),s!==null&&(Nn(s,i,a),gc(s,i,a))}};function Vy(i,s,a,l,d,h,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,h,_):s.prototype&&s.prototype.isPureReactComponent?!Jr(a,l)||!Jr(d,h):!0}function Yy(i,s,a,l){i=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(a,l),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(a,l),s.state!==i&&Yp.enqueueReplaceState(s,s.state,null)}function ho(i,s){var a=s;if("ref"in s){a={};for(var l in s)l!=="ref"&&(a[l]=s[l])}if(i=i.defaultProps){a===s&&(a=b({},a));for(var d in i)a[d]===void 0&&(a[d]=i[d])}return a}function Xy(i){md(i)}function Gy(i){console.error(i)}function Zy(i){md(i)}function zd(i,s){try{var a=i.onUncaughtError;a(s.value,{componentStack:s.stack})}catch(l){setTimeout(function(){throw l})}}function Qy(i,s,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function Xp(i,s,a){return a=ra(a),a.tag=3,a.payload={element:null},a.callback=function(){zd(i,s)},a}function Jy(i){return i=ra(i),i.tag=3,i}function eS(i,s,a,l){var d=a.type.getDerivedStateFromError;if(typeof d=="function"){var h=l.value;i.payload=function(){return d(h)},i.callback=function(){Qy(s,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Qy(s,a,l),typeof d!="function"&&(ha===null?ha=new Set([this]):ha.add(this));var T=l.stack;this.componentDidCatch(l.value,{componentStack:T!==null?T:""})})}function tE(i,s,a,l,d){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(s=a.alternate,s!==null&&Qo(s,a,d,!0),a=Hn.current,a!==null){switch(a.tag){case 31:case 13:return ns===null?Gd():a.alternate===null&&hi===0&&(hi=3),a.flags&=-257,a.flags|=65536,a.lanes=d,l===kd?a.flags|=16384:(s=a.updateQueue,s===null?a.updateQueue=new Set([l]):s.add(l),ym(i,l,d)),!1;case 22:return a.flags|=65536,l===kd?a.flags|=16384:(s=a.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=s):(a=s.retryQueue,a===null?s.retryQueue=new Set([l]):a.add(l)),ym(i,l,d)),!1}throw Error(r(435,a.tag))}return ym(i,l,d),Gd(),!1}if(xt)return s=Hn.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=d,l!==pp&&(i=Error(r(422),{cause:l}),dc(Jn(i,a)))):(l!==pp&&(s=Error(r(423),{cause:l}),dc(Jn(s,a))),i=i.current.alternate,i.flags|=65536,d&=-d,i.lanes|=d,l=Jn(l,a),d=Xp(i.stateNode,l,d),kp(i,d),hi!==4&&(hi=2)),!1;var h=Error(r(520),{cause:l});if(h=Jn(h,a),Mc===null?Mc=[h]:Mc.push(h),hi!==4&&(hi=2),s===null)return!0;l=Jn(l,a),a=s;do{switch(a.tag){case 3:return a.flags|=65536,i=d&-d,a.lanes|=i,i=Xp(a.stateNode,l,i),kp(a,i),!1;case 1:if(s=a.type,h=a.stateNode,(a.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(ha===null||!ha.has(h))))return a.flags|=65536,d&=-d,a.lanes|=d,d=Jy(d),eS(d,i,a,l),kp(a,d),!1}a=a.return}while(a!==null);return!1}var Gp=Error(r(461)),Di=!1;function an(i,s,a,l){s.child=i===null?sy(s,null,a,l):co(s,i.child,a,l)}function tS(i,s,a,l,d){a=a.render;var h=s.ref;if("ref"in l){var _={};for(var T in l)T!=="ref"&&(_[T]=l[T])}else _=l;return ro(s),l=Np(i,s,a,_,h,d),T=Ap(),i!==null&&!Di?(Lp(i,s,d),_r(i,s,d)):(xt&&T&&hp(s),s.flags|=1,an(i,s,l,d),s.child)}function iS(i,s,a,l,d){if(i===null){var h=a.type;return typeof h=="function"&&!cp(h)&&h.defaultProps===void 0&&a.compare===null?(s.tag=15,s.type=h,nS(i,s,h,l,d)):(i=bd(a.type,null,l,s,s.mode,d),i.ref=s.ref,i.return=s,s.child=i)}if(h=i.child,!sm(i,d)){var _=h.memoizedProps;if(a=a.compare,a=a!==null?a:Jr,a(_,l)&&i.ref===s.ref)return _r(i,s,d)}return s.flags|=1,i=hr(h,l),i.ref=s.ref,i.return=s,s.child=i}function nS(i,s,a,l,d){if(i!==null){var h=i.memoizedProps;if(Jr(h,l)&&i.ref===s.ref)if(Di=!1,s.pendingProps=l=h,sm(i,d))(i.flags&131072)!==0&&(Di=!0);else return s.lanes=i.lanes,_r(i,s,d)}return Zp(i,s,a,l,d)}function sS(i,s,a,l){var d=l.children,h=i!==null?i.memoizedState:null;if(i===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((s.flags&128)!==0){if(h=h!==null?h.baseLanes|a:a,i!==null){for(l=s.child=i.child,d=0;l!==null;)d=d|l.lanes|l.childLanes,l=l.sibling;l=d&~h}else l=0,s.child=null;return rS(i,s,h,a,l)}if((a&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},i!==null&&Cd(s,h!==null?h.cachePool:null),h!==null?oy(s,h):Ep(),ly(s);else return l=s.lanes=536870912,rS(i,s,h!==null?h.baseLanes|a:a,a,l)}else h!==null?(Cd(s,h.cachePool),oy(s,h),la(),s.memoizedState=null):(i!==null&&Cd(s,null),Ep(),la());return an(i,s,d,a),s.child}function Cc(i,s){return i!==null&&i.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function rS(i,s,a,l,d){var h=Sp();return h=h===null?null:{parent:Ti._currentValue,pool:h},s.memoizedState={baseLanes:a,cachePool:h},i!==null&&Cd(s,null),Ep(),ly(s),i!==null&&Qo(i,s,l,!0),s.childLanes=d,null}function Pd(i,s){return s=Ud({mode:s.mode,children:s.children},i.mode),s.ref=i.ref,i.child=s,s.return=i,s}function aS(i,s,a){return co(s,i.child,null,a),i=Pd(s,s.pendingProps),i.flags|=2,Un(s),s.memoizedState=null,i}function iE(i,s,a){var l=s.pendingProps,d=(s.flags&128)!==0;if(s.flags&=-129,i===null){if(xt){if(l.mode==="hidden")return i=Pd(s,l),s.lanes=536870912,Cc(null,i);if(Rp(s),(i=Zt)?(i=_0(i,is),i=i!==null&&i.data==="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ea!==null?{id:Us,overflow:Ks}:null,retryLane:536870912,hydrationErrors:null},a=Fb(i),a.return=s,s.child=a,sn=s,Zt=null)):i=null,i===null)throw ia(s);return s.lanes=536870912,null}return Pd(s,l)}var h=i.memoizedState;if(h!==null){var _=h.dehydrated;if(Rp(s),d)if(s.flags&256)s.flags&=-257,s=aS(i,s,a);else if(s.memoizedState!==null)s.child=i.child,s.flags|=128,s=null;else throw Error(r(558));else if(Di||Qo(i,s,a,!1),d=(a&i.childLanes)!==0,Di||d){if(l=Vt,l!==null&&(_=Hi(l,a),_!==0&&_!==h.retryLane))throw h.retryLane=_,to(i,_),Nn(l,i,_),Gp;Gd(),s=aS(i,s,a)}else i=h.treeContext,Zt=ss(_.nextSibling),sn=s,xt=!0,ta=null,is=!1,i!==null&&qb(s,i),s=Pd(s,l),s.flags|=4096;return s}return i=hr(i.child,{mode:l.mode,children:l.children}),i.ref=s.ref,s.child=i,i.return=s,i}function Hd(i,s){var a=s.ref;if(a===null)i!==null&&i.ref!==null&&(s.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(s.flags|=4194816)}}function Zp(i,s,a,l,d){return ro(s),a=Np(i,s,a,l,void 0,d),l=Ap(),i!==null&&!Di?(Lp(i,s,d),_r(i,s,d)):(xt&&l&&hp(s),s.flags|=1,an(i,s,a,d),s.child)}function oS(i,s,a,l,d,h){return ro(s),s.updateQueue=null,a=uy(s,l,a,d),cy(i),l=Ap(),i!==null&&!Di?(Lp(i,s,h),_r(i,s,h)):(xt&&l&&hp(s),s.flags|=1,an(i,s,a,h),s.child)}function lS(i,s,a,l,d){if(ro(s),s.stateNode===null){var h=Yo,_=a.contextType;typeof _=="object"&&_!==null&&(h=rn(_)),h=new a(l,h),s.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Yp,s.stateNode=h,h._reactInternals=s,h=s.stateNode,h.props=l,h.state=s.memoizedState,h.refs={},Cp(s),_=a.contextType,h.context=typeof _=="object"&&_!==null?rn(_):Yo,h.state=s.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Vp(s,a,_,l),h.state=s.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(_=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),_!==h.state&&Yp.enqueueReplaceState(h,h.state,null),_c(s,l,h,d),vc(),h.state=s.memoizedState),typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!0}else if(i===null){h=s.stateNode;var T=s.memoizedProps,L=ho(a,T);h.props=L;var Z=h.context,he=a.contextType;_=Yo,typeof he=="object"&&he!==null&&(_=rn(he));var _e=a.getDerivedStateFromProps;he=typeof _e=="function"||typeof h.getSnapshotBeforeUpdate=="function",T=s.pendingProps!==T,he||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(T||Z!==_)&&Yy(s,h,l,_),sa=!1;var te=s.memoizedState;h.state=te,_c(s,l,h,d),vc(),Z=s.memoizedState,T||te!==Z||sa?(typeof _e=="function"&&(Vp(s,a,_e,l),Z=s.memoizedState),(L=sa||Vy(s,a,L,l,te,Z,_))?(he||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(s.flags|=4194308)):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=l,s.memoizedState=Z),h.props=l,h.state=Z,h.context=_,l=L):(typeof h.componentDidMount=="function"&&(s.flags|=4194308),l=!1)}else{h=s.stateNode,xp(i,s),_=s.memoizedProps,he=ho(a,_),h.props=he,_e=s.pendingProps,te=h.context,Z=a.contextType,L=Yo,typeof Z=="object"&&Z!==null&&(L=rn(Z)),T=a.getDerivedStateFromProps,(Z=typeof T=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(_!==_e||te!==L)&&Yy(s,h,l,L),sa=!1,te=s.memoizedState,h.state=te,_c(s,l,h,d),vc();var ce=s.memoizedState;_!==_e||te!==ce||sa||i!==null&&i.dependencies!==null&&Sd(i.dependencies)?(typeof T=="function"&&(Vp(s,a,T,l),ce=s.memoizedState),(he=sa||Vy(s,a,he,l,te,ce,L)||i!==null&&i.dependencies!==null&&Sd(i.dependencies))?(Z||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(l,ce,L),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(l,ce,L)),typeof h.componentDidUpdate=="function"&&(s.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),s.memoizedProps=l,s.memoizedState=ce),h.props=l,h.state=ce,h.context=L,l=he):(typeof h.componentDidUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&te===i.memoizedState||(s.flags|=1024),l=!1)}return h=l,Hd(i,s),l=(s.flags&128)!==0,h||l?(h=s.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:h.render(),s.flags|=1,i!==null&&l?(s.child=co(s,i.child,null,d),s.child=co(s,null,a,d)):an(i,s,a,d),s.memoizedState=h.state,i=s.child):i=_r(i,s,d),i}function cS(i,s,a,l){return no(),s.flags|=256,an(i,s,a,l),s.child}var Qp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Jp(i){return{baseLanes:i,cachePool:Qb()}}function em(i,s,a){return i=i!==null?i.childLanes&~a:0,s&&(i|=Fn),i}function uS(i,s,a){var l=s.pendingProps,d=!1,h=(s.flags&128)!==0,_;if((_=h)||(_=i!==null&&i.memoizedState===null?!1:(wi.current&2)!==0),_&&(d=!0,s.flags&=-129),_=(s.flags&32)!==0,s.flags&=-33,i===null){if(xt){if(d?oa(s):la(),(i=Zt)?(i=_0(i,is),i=i!==null&&i.data!=="&"?i:null,i!==null&&(s.memoizedState={dehydrated:i,treeContext:ea!==null?{id:Us,overflow:Ks}:null,retryLane:536870912,hydrationErrors:null},a=Fb(i),a.return=s,s.child=a,sn=s,Zt=null)):i=null,i===null)throw ia(s);return jm(i)?s.lanes=32:s.lanes=536870912,null}var T=l.children;return l=l.fallback,d?(la(),d=s.mode,T=Ud({mode:"hidden",children:T},d),l=io(l,d,a,null),T.return=s,l.return=s,T.sibling=l,s.child=T,l=s.child,l.memoizedState=Jp(a),l.childLanes=em(i,_,a),s.memoizedState=Qp,Cc(null,l)):(oa(s),tm(s,T))}var L=i.memoizedState;if(L!==null&&(T=L.dehydrated,T!==null)){if(h)s.flags&256?(oa(s),s.flags&=-257,s=im(i,s,a)):s.memoizedState!==null?(la(),s.child=i.child,s.flags|=128,s=null):(la(),T=l.fallback,d=s.mode,l=Ud({mode:"visible",children:l.children},d),T=io(T,d,a,null),T.flags|=2,l.return=s,T.return=s,l.sibling=T,s.child=l,co(s,i.child,null,a),l=s.child,l.memoizedState=Jp(a),l.childLanes=em(i,_,a),s.memoizedState=Qp,s=Cc(null,l));else if(oa(s),jm(T)){if(_=T.nextSibling&&T.nextSibling.dataset,_)var Z=_.dgst;_=Z,l=Error(r(419)),l.stack="",l.digest=_,dc({value:l,source:null,stack:null}),s=im(i,s,a)}else if(Di||Qo(i,s,a,!1),_=(a&i.childLanes)!==0,Di||_){if(_=Vt,_!==null&&(l=Hi(_,a),l!==0&&l!==L.retryLane))throw L.retryLane=l,to(i,l),Nn(_,i,l),Gp;Bm(T)||Gd(),s=im(i,s,a)}else Bm(T)?(s.flags|=192,s.child=i.child,s=null):(i=L.treeContext,Zt=ss(T.nextSibling),sn=s,xt=!0,ta=null,is=!1,i!==null&&qb(s,i),s=tm(s,l.children),s.flags|=4096);return s}return d?(la(),T=l.fallback,d=s.mode,L=i.child,Z=L.sibling,l=hr(L,{mode:"hidden",children:l.children}),l.subtreeFlags=L.subtreeFlags&65011712,Z!==null?T=hr(Z,T):(T=io(T,d,a,null),T.flags|=2),T.return=s,l.return=s,l.sibling=T,s.child=l,Cc(null,l),l=s.child,T=i.child.memoizedState,T===null?T=Jp(a):(d=T.cachePool,d!==null?(L=Ti._currentValue,d=d.parent!==L?{parent:L,pool:L}:d):d=Qb(),T={baseLanes:T.baseLanes|a,cachePool:d}),l.memoizedState=T,l.childLanes=em(i,_,a),s.memoizedState=Qp,Cc(i.child,l)):(oa(s),a=i.child,i=a.sibling,a=hr(a,{mode:"visible",children:l.children}),a.return=s,a.sibling=null,i!==null&&(_=s.deletions,_===null?(s.deletions=[i],s.flags|=16):_.push(i)),s.child=a,s.memoizedState=null,a)}function tm(i,s){return s=Ud({mode:"visible",children:s},i.mode),s.return=i,i.child=s}function Ud(i,s){return i=Pn(22,i,null,s),i.lanes=0,i}function im(i,s,a){return co(s,i.child,null,a),i=tm(s,s.pendingProps.children),i.flags|=2,s.memoizedState=null,i}function dS(i,s,a){i.lanes|=s;var l=i.alternate;l!==null&&(l.lanes|=s),vp(i.return,s,a)}function nm(i,s,a,l,d,h){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:d,treeForkCount:h}:(_.isBackwards=s,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=d,_.treeForkCount=h)}function hS(i,s,a){var l=s.pendingProps,d=l.revealOrder,h=l.tail;l=l.children;var _=wi.current,T=(_&2)!==0;if(T?(_=_&1|2,s.flags|=128):_&=1,ue(wi,_),an(i,s,l,a),l=xt?uc:0,!T&&i!==null&&(i.flags&128)!==0)e:for(i=s.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&dS(i,a,s);else if(i.tag===19)dS(i,a,s);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===s)break e;for(;i.sibling===null;){if(i.return===null||i.return===s)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(d){case"forwards":for(a=s.child,d=null;a!==null;)i=a.alternate,i!==null&&Rd(i)===null&&(d=a),a=a.sibling;a=d,a===null?(d=s.child,s.child=null):(d=a.sibling,a.sibling=null),nm(s,!1,d,a,h,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,d=s.child,s.child=null;d!==null;){if(i=d.alternate,i!==null&&Rd(i)===null){s.child=d;break}i=d.sibling,d.sibling=a,a=d,d=i}nm(s,!0,a,null,h,l);break;case"together":nm(s,!1,null,null,void 0,l);break;default:s.memoizedState=null}return s.child}function _r(i,s,a){if(i!==null&&(s.dependencies=i.dependencies),da|=s.lanes,(a&s.childLanes)===0)if(i!==null){if(Qo(i,s,a,!1),(a&s.childLanes)===0)return null}else return null;if(i!==null&&s.child!==i.child)throw Error(r(153));if(s.child!==null){for(i=s.child,a=hr(i,i.pendingProps),s.child=a,a.return=s;i.sibling!==null;)i=i.sibling,a=a.sibling=hr(i,i.pendingProps),a.return=s;a.sibling=null}return s.child}function sm(i,s){return(i.lanes&s)!==0?!0:(i=i.dependencies,!!(i!==null&&Sd(i)))}function nE(i,s,a){switch(s.tag){case 3:Ne(s,s.stateNode.containerInfo),na(s,Ti,i.memoizedState.cache),no();break;case 27:case 5:Fe(s);break;case 4:Ne(s,s.stateNode.containerInfo);break;case 10:na(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,Rp(s),null;break;case 13:var l=s.memoizedState;if(l!==null)return l.dehydrated!==null?(oa(s),s.flags|=128,null):(a&s.child.childLanes)!==0?uS(i,s,a):(oa(s),i=_r(i,s,a),i!==null?i.sibling:null);oa(s);break;case 19:var d=(i.flags&128)!==0;if(l=(a&s.childLanes)!==0,l||(Qo(i,s,a,!1),l=(a&s.childLanes)!==0),d){if(l)return hS(i,s,a);s.flags|=128}if(d=s.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),ue(wi,wi.current),l)break;return null;case 22:return s.lanes=0,sS(i,s,a,s.pendingProps);case 24:na(s,Ti,i.memoizedState.cache)}return _r(i,s,a)}function fS(i,s,a){if(i!==null)if(i.memoizedProps!==s.pendingProps)Di=!0;else{if(!sm(i,a)&&(s.flags&128)===0)return Di=!1,nE(i,s,a);Di=(i.flags&131072)!==0}else Di=!1,xt&&(s.flags&1048576)!==0&&$b(s,uc,s.index);switch(s.lanes=0,s.tag){case 16:e:{var l=s.pendingProps;if(i=oo(s.elementType),s.type=i,typeof i=="function")cp(i)?(l=ho(i,l),s.tag=1,s=lS(null,s,i,l,a)):(s.tag=0,s=Zp(null,s,i,l,a));else{if(i!=null){var d=i.$$typeof;if(d===$){s.tag=11,s=tS(null,s,i,l,a);break e}else if(d===W){s.tag=14,s=iS(null,s,i,l,a);break e}}throw s=F(i)||i,Error(r(306,s,""))}}return s;case 0:return Zp(i,s,s.type,s.pendingProps,a);case 1:return l=s.type,d=ho(l,s.pendingProps),lS(i,s,l,d,a);case 3:e:{if(Ne(s,s.stateNode.containerInfo),i===null)throw Error(r(387));l=s.pendingProps;var h=s.memoizedState;d=h.element,xp(i,s),_c(s,l,null,a);var _=s.memoizedState;if(l=_.cache,na(s,Ti,l),l!==h.cache&&_p(s,[Ti],a,!0),vc(),l=_.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:_.cache},s.updateQueue.baseState=h,s.memoizedState=h,s.flags&256){s=cS(i,s,l,a);break e}else if(l!==d){d=Jn(Error(r(424)),s),dc(d),s=cS(i,s,l,a);break e}else for(i=s.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Zt=ss(i.firstChild),sn=s,xt=!0,ta=null,is=!0,a=sy(s,null,l,a),s.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(no(),l===d){s=_r(i,s,a);break e}an(i,s,l,a)}s=s.child}return s;case 26:return Hd(i,s),i===null?(a=x0(s.type,null,s.pendingProps,null))?s.memoizedState=a:xt||(a=s.type,i=s.pendingProps,l=nh(De.current).createElement(a),l[vi]=s,l[_i]=i,on(l,a,i),zt(l),s.stateNode=l):s.memoizedState=x0(s.type,i.memoizedProps,s.pendingProps,i.memoizedState),null;case 27:return Fe(s),i===null&&xt&&(l=s.stateNode=S0(s.type,s.pendingProps,De.current),sn=s,is=!0,d=Zt,ga(s.type)?(Im=d,Zt=ss(l.firstChild)):Zt=d),an(i,s,s.pendingProps.children,a),Hd(i,s),i===null&&(s.flags|=4194304),s.child;case 5:return i===null&&xt&&((d=l=Zt)&&(l=LE(l,s.type,s.pendingProps,is),l!==null?(s.stateNode=l,sn=s,Zt=ss(l.firstChild),is=!1,d=!0):d=!1),d||ia(s)),Fe(s),d=s.type,h=s.pendingProps,_=i!==null?i.memoizedProps:null,l=h.children,Am(d,h)?l=null:_!==null&&Am(d,_)&&(s.flags|=32),s.memoizedState!==null&&(d=Np(i,s,YT,null,null,a),zc._currentValue=d),Hd(i,s),an(i,s,l,a),s.child;case 6:return i===null&&xt&&((i=a=Zt)&&(a=OE(a,s.pendingProps,is),a!==null?(s.stateNode=a,sn=s,Zt=null,i=!0):i=!1),i||ia(s)),null;case 13:return uS(i,s,a);case 4:return Ne(s,s.stateNode.containerInfo),l=s.pendingProps,i===null?s.child=co(s,null,l,a):an(i,s,l,a),s.child;case 11:return tS(i,s,s.type,s.pendingProps,a);case 7:return an(i,s,s.pendingProps,a),s.child;case 8:return an(i,s,s.pendingProps.children,a),s.child;case 12:return an(i,s,s.pendingProps.children,a),s.child;case 10:return l=s.pendingProps,na(s,s.type,l.value),an(i,s,l.children,a),s.child;case 9:return d=s.type._context,l=s.pendingProps.children,ro(s),d=rn(d),l=l(d),s.flags|=1,an(i,s,l,a),s.child;case 14:return iS(i,s,s.type,s.pendingProps,a);case 15:return nS(i,s,s.type,s.pendingProps,a);case 19:return hS(i,s,a);case 31:return iE(i,s,a);case 22:return sS(i,s,a,s.pendingProps);case 24:return ro(s),l=rn(Ti),i===null?(d=Sp(),d===null&&(d=Vt,h=bp(),d.pooledCache=h,h.refCount++,h!==null&&(d.pooledCacheLanes|=a),d=h),s.memoizedState={parent:l,cache:d},Cp(s),na(s,Ti,d)):((i.lanes&a)!==0&&(xp(i,s),_c(s,null,null,a),vc()),d=i.memoizedState,h=s.memoizedState,d.parent!==l?(d={parent:l,cache:l},s.memoizedState=d,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=d),na(s,Ti,l)):(l=h.cache,na(s,Ti,l),l!==d.cache&&_p(s,[Ti],a,!0))),an(i,s,s.pendingProps.children,a),s.child;case 29:throw s.pendingProps}throw Error(r(156,s.tag))}function br(i){i.flags|=4}function rm(i,s,a,l,d){if((s=(i.mode&32)!==0)&&(s=!1),s){if(i.flags|=16777216,(d&335544128)===d)if(i.stateNode.complete)i.flags|=8192;else if(HS())i.flags|=8192;else throw lo=kd,wp}else i.flags&=-16777217}function pS(i,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!R0(s))if(HS())i.flags|=8192;else throw lo=kd,wp}function Kd(i,s){s!==null&&(i.flags|=4),i.flags&16384&&(s=i.tag!==22?Gt():536870912,i.lanes|=s,ul|=s)}function xc(i,s){if(!xt)switch(i.tailMode){case"hidden":s=i.tail;for(var a=null;s!==null;)s.alternate!==null&&(a=s),s=s.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?s||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function Qt(i){var s=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(s)for(var d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags&65011712,l|=d.flags&65011712,d.return=i,d=d.sibling;else for(d=i.child;d!==null;)a|=d.lanes|d.childLanes,l|=d.subtreeFlags,l|=d.flags,d.return=i,d=d.sibling;return i.subtreeFlags|=l,i.childLanes=a,s}function sE(i,s,a){var l=s.pendingProps;switch(fp(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qt(s),null;case 1:return Qt(s),null;case 3:return a=s.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),s.memoizedState.cache!==l&&(s.flags|=2048),mr(Ti),Ue(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Zo(s)?br(s):i===null||i.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,mp())),Qt(s),null;case 26:var d=s.type,h=s.memoizedState;return i===null?(br(s),h!==null?(Qt(s),pS(s,h)):(Qt(s),rm(s,d,null,l,a))):h?h!==i.memoizedState?(br(s),Qt(s),pS(s,h)):(Qt(s),s.flags&=-16777217):(i=i.memoizedProps,i!==l&&br(s),Qt(s),rm(s,d,i,l,a)),null;case 27:if(ne(s),a=De.current,d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Qt(s),null}i=Ce.current,Zo(s)?Vb(s):(i=S0(d,l,a),s.stateNode=i,br(s))}return Qt(s),null;case 5:if(ne(s),d=s.type,i!==null&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(!l){if(s.stateNode===null)throw Error(r(166));return Qt(s),null}if(h=Ce.current,Zo(s))Vb(s);else{var _=nh(De.current);switch(h){case 1:h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":h=_.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":h=_.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":h=_.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?h.multiple=!0:l.size&&(h.size=l.size);break;default:h=typeof l.is=="string"?_.createElement(d,{is:l.is}):_.createElement(d)}}h[vi]=s,h[_i]=l;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)h.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=h;e:switch(on(h,d,l),d){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&br(s)}}return Qt(s),rm(s,s.type,i===null?null:i.memoizedProps,s.pendingProps,a),null;case 6:if(i&&s.stateNode!=null)i.memoizedProps!==l&&br(s);else{if(typeof l!="string"&&s.stateNode===null)throw Error(r(166));if(i=De.current,Zo(s)){if(i=s.stateNode,a=s.memoizedProps,l=null,d=sn,d!==null)switch(d.tag){case 27:case 5:l=d.memoizedProps}i[vi]=s,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||u0(i.nodeValue,a)),i||ia(s,!0)}else i=nh(i).createTextNode(l),i[vi]=s,s.stateNode=i}return Qt(s),null;case 31:if(a=s.memoizedState,i===null||i.memoizedState!==null){if(l=Zo(s),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[vi]=s}else no(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Qt(s),i=!1}else a=mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return s.flags&256?(Un(s),s):(Un(s),null);if((s.flags&128)!==0)throw Error(r(558))}return Qt(s),null;case 13:if(l=s.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=Zo(s),l!==null&&l.dehydrated!==null){if(i===null){if(!d)throw Error(r(318));if(d=s.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[vi]=s}else no(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Qt(s),d=!1}else d=mp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return s.flags&256?(Un(s),s):(Un(s),null)}return Un(s),(s.flags&128)!==0?(s.lanes=a,s):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=s.child,d=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(d=l.alternate.memoizedState.cachePool.pool),h=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(h=l.memoizedState.cachePool.pool),h!==d&&(l.flags|=2048)),a!==i&&a&&(s.child.flags|=8192),Kd(s,s.updateQueue),Qt(s),null);case 4:return Ue(),i===null&&Em(s.stateNode.containerInfo),Qt(s),null;case 10:return mr(s.type),Qt(s),null;case 19:if(U(wi),l=s.memoizedState,l===null)return Qt(s),null;if(d=(s.flags&128)!==0,h=l.rendering,h===null)if(d)xc(l,!1);else{if(hi!==0||i!==null&&(i.flags&128)!==0)for(i=s.child;i!==null;){if(h=Rd(i),h!==null){for(s.flags|=128,xc(l,!1),i=h.updateQueue,s.updateQueue=i,Kd(s,i),s.subtreeFlags=0,i=a,a=s.child;a!==null;)Kb(a,i),a=a.sibling;return ue(wi,wi.current&1|2),xt&&fr(s,l.treeForkCount),s.child}i=i.sibling}l.tail!==null&&ct()>Vd&&(s.flags|=128,d=!0,xc(l,!1),s.lanes=4194304)}else{if(!d)if(i=Rd(h),i!==null){if(s.flags|=128,d=!0,i=i.updateQueue,s.updateQueue=i,Kd(s,i),xc(l,!0),l.tail===null&&l.tailMode==="hidden"&&!h.alternate&&!xt)return Qt(s),null}else 2*ct()-l.renderingStartTime>Vd&&a!==536870912&&(s.flags|=128,d=!0,xc(l,!1),s.lanes=4194304);l.isBackwards?(h.sibling=s.child,s.child=h):(i=l.last,i!==null?i.sibling=h:s.child=h,l.last=h)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=ct(),i.sibling=null,a=wi.current,ue(wi,d?a&1|2:a&1),xt&&fr(s,l.treeForkCount),i):(Qt(s),null);case 22:case 23:return Un(s),Dp(),l=s.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(s.flags|=8192):l&&(s.flags|=8192),l?(a&536870912)!==0&&(s.flags&128)===0&&(Qt(s),s.subtreeFlags&6&&(s.flags|=8192)):Qt(s),a=s.updateQueue,a!==null&&Kd(s,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),l!==a&&(s.flags|=2048),i!==null&&U(ao),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),s.memoizedState.cache!==a&&(s.flags|=2048),mr(Ti),Qt(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function rE(i,s){switch(fp(s),s.tag){case 1:return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 3:return mr(Ti),Ue(),i=s.flags,(i&65536)!==0&&(i&128)===0?(s.flags=i&-65537|128,s):null;case 26:case 27:case 5:return ne(s),null;case 31:if(s.memoizedState!==null){if(Un(s),s.alternate===null)throw Error(r(340));no()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 13:if(Un(s),i=s.memoizedState,i!==null&&i.dehydrated!==null){if(s.alternate===null)throw Error(r(340));no()}return i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 19:return U(wi),null;case 4:return Ue(),null;case 10:return mr(s.type),null;case 22:case 23:return Un(s),Dp(),i!==null&&U(ao),i=s.flags,i&65536?(s.flags=i&-65537|128,s):null;case 24:return mr(Ti),null;case 25:return null;default:return null}}function mS(i,s){switch(fp(s),s.tag){case 3:mr(Ti),Ue();break;case 26:case 27:case 5:ne(s);break;case 4:Ue();break;case 31:s.memoizedState!==null&&Un(s);break;case 13:Un(s);break;case 19:U(wi);break;case 10:mr(s.type);break;case 22:case 23:Un(s),Dp(),i!==null&&U(ao);break;case 24:mr(Ti)}}function kc(i,s){try{var a=s.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var d=l.next;a=d;do{if((a.tag&i)===i){l=void 0;var h=a.create,_=a.inst;l=h(),_.destroy=l}a=a.next}while(a!==d)}}catch(T){jt(s,s.return,T)}}function ca(i,s,a){try{var l=s.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var h=d.next;l=h;do{if((l.tag&i)===i){var _=l.inst,T=_.destroy;if(T!==void 0){_.destroy=void 0,d=s;var L=a,Z=T;try{Z()}catch(he){jt(d,L,he)}}}l=l.next}while(l!==h)}}catch(he){jt(s,s.return,he)}}function gS(i){var s=i.updateQueue;if(s!==null){var a=i.stateNode;try{ay(s,a)}catch(l){jt(i,i.return,l)}}}function vS(i,s,a){a.props=ho(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){jt(i,s,l)}}function Tc(i,s){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(d){jt(i,s,d)}}function Fs(i,s){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(d){jt(i,s,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(d){jt(i,s,d)}else a.current=null}function _S(i){var s=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(d){jt(i,i.return,d)}}function am(i,s,a){try{var l=i.stateNode;EE(l,i.type,a,s),l[_i]=s}catch(d){jt(i,i.return,d)}}function bS(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ga(i.type)||i.tag===4}function om(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||bS(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&&ga(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 lm(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,s):(s=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,s.appendChild(i),a=a._reactRootContainer,a!=null||s.onclick!==null||(s.onclick=Xn));else if(l!==4&&(l===27&&ga(i.type)&&(a=i.stateNode,s=null),i=i.child,i!==null))for(lm(i,s,a),i=i.sibling;i!==null;)lm(i,s,a),i=i.sibling}function Fd(i,s,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,s?a.insertBefore(i,s):a.appendChild(i);else if(l!==4&&(l===27&&ga(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Fd(i,s,a),i=i.sibling;i!==null;)Fd(i,s,a),i=i.sibling}function yS(i){var s=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,d=s.attributes;d.length;)s.removeAttributeNode(d[0]);on(s,l,a),s[vi]=i,s[_i]=a}catch(h){jt(i,i.return,h)}}var yr=!1,Ri=!1,cm=!1,SS=typeof WeakSet=="function"?WeakSet:Set,$i=null;function aE(i,s){if(i=i.containerInfo,Mm=uh,i=pd(i),eo(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var d=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{a.nodeType,h.nodeType}catch{a=null;break e}var _=0,T=-1,L=-1,Z=0,he=0,_e=i,te=null;t:for(;;){for(var ce;_e!==a||d!==0&&_e.nodeType!==3||(T=_+d),_e!==h||l!==0&&_e.nodeType!==3||(L=_+l),_e.nodeType===3&&(_+=_e.nodeValue.length),(ce=_e.firstChild)!==null;)te=_e,_e=ce;for(;;){if(_e===i)break t;if(te===a&&++Z===d&&(T=_),te===h&&++he===l&&(L=_),(ce=_e.nextSibling)!==null)break;_e=te,te=_e.parentNode}_e=ce}a=T===-1||L===-1?null:{start:T,end:L}}else a=null}a=a||{start:0,end:0}}else a=null;for(Nm={focusedElem:i,selectionRange:a},uh=!1,$i=s;$i!==null;)if(s=$i,i=s.child,(s.subtreeFlags&1028)!==0&&i!==null)i.return=s,$i=i;else for(;$i!==null;){switch(s=$i,h=s.alternate,i=s.flags,s.tag){case 0:if((i&4)!==0&&(i=s.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)d=i[a],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&h!==null){i=void 0,a=s,d=h.memoizedProps,h=h.memoizedState,l=a.stateNode;try{var He=ho(a.type,d);i=l.getSnapshotBeforeUpdate(He,h),l.__reactInternalSnapshotBeforeUpdate=i}catch(Je){jt(a,a.return,Je)}}break;case 3:if((i&1024)!==0){if(i=s.stateNode.containerInfo,a=i.nodeType,a===9)Om(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Om(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=s.sibling,i!==null){i.return=s.return,$i=i;break}$i=s.return}}function wS(i,s,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:wr(i,a),l&4&&kc(5,a);break;case 1:if(wr(i,a),l&4)if(i=a.stateNode,s===null)try{i.componentDidMount()}catch(_){jt(a,a.return,_)}else{var d=ho(a.type,s.memoizedProps);s=s.memoizedState;try{i.componentDidUpdate(d,s,i.__reactInternalSnapshotBeforeUpdate)}catch(_){jt(a,a.return,_)}}l&64&&gS(a),l&512&&Tc(a,a.return);break;case 3:if(wr(i,a),l&64&&(i=a.updateQueue,i!==null)){if(s=null,a.child!==null)switch(a.child.tag){case 27:case 5:s=a.child.stateNode;break;case 1:s=a.child.stateNode}try{ay(i,s)}catch(_){jt(a,a.return,_)}}break;case 27:s===null&&l&4&&yS(a);case 26:case 5:wr(i,a),s===null&&l&4&&_S(a),l&512&&Tc(a,a.return);break;case 12:wr(i,a);break;case 31:wr(i,a),l&4&&kS(i,a);break;case 13:wr(i,a),l&4&&TS(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=mE.bind(null,a),BE(i,a))));break;case 22:if(l=a.memoizedState!==null||yr,!l){s=s!==null&&s.memoizedState!==null||Ri,d=yr;var h=Ri;yr=l,(Ri=s)&&!h?Cr(i,a,(a.subtreeFlags&8772)!==0):wr(i,a),yr=d,Ri=h}break;case 30:break;default:wr(i,a)}}function CS(i){var s=i.alternate;s!==null&&(i.alternate=null,CS(s)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(s=i.stateNode,s!==null&&tr(s)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var ii=null,En=!1;function Sr(i,s,a){for(a=a.child;a!==null;)xS(i,s,a),a=a.sibling}function xS(i,s,a){if(Ze&&typeof Ze.onCommitFiberUnmount=="function")try{Ze.onCommitFiberUnmount(rt,a)}catch{}switch(a.tag){case 26:Ri||Fs(a,s),Sr(i,s,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ri||Fs(a,s);var l=ii,d=En;ga(a.type)&&(ii=a.stateNode,En=!1),Sr(i,s,a),Bc(a.stateNode),ii=l,En=d;break;case 5:Ri||Fs(a,s);case 6:if(l=ii,d=En,ii=null,Sr(i,s,a),ii=l,En=d,ii!==null)if(En)try{(ii.nodeType===9?ii.body:ii.nodeName==="HTML"?ii.ownerDocument.body:ii).removeChild(a.stateNode)}catch(h){jt(a,s,h)}else try{ii.removeChild(a.stateNode)}catch(h){jt(a,s,h)}break;case 18:ii!==null&&(En?(i=ii,g0(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),_l(i)):g0(ii,a.stateNode));break;case 4:l=ii,d=En,ii=a.stateNode.containerInfo,En=!0,Sr(i,s,a),ii=l,En=d;break;case 0:case 11:case 14:case 15:ca(2,a,s),Ri||ca(4,a,s),Sr(i,s,a);break;case 1:Ri||(Fs(a,s),l=a.stateNode,typeof l.componentWillUnmount=="function"&&vS(a,s,l)),Sr(i,s,a);break;case 21:Sr(i,s,a);break;case 22:Ri=(l=Ri)||a.memoizedState!==null,Sr(i,s,a),Ri=l;break;default:Sr(i,s,a)}}function kS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{_l(i)}catch(a){jt(s,s.return,a)}}}function TS(i,s){if(s.memoizedState===null&&(i=s.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{_l(i)}catch(a){jt(s,s.return,a)}}function oE(i){switch(i.tag){case 31:case 13:case 19:var s=i.stateNode;return s===null&&(s=i.stateNode=new SS),s;case 22:return i=i.stateNode,s=i._retryCache,s===null&&(s=i._retryCache=new SS),s;default:throw Error(r(435,i.tag))}}function Wd(i,s){var a=oE(i);s.forEach(function(l){if(!a.has(l)){a.add(l);var d=gE.bind(null,i,l);l.then(d,d)}})}function Dn(i,s){var a=s.deletions;if(a!==null)for(var l=0;l<a.length;l++){var d=a[l],h=i,_=s,T=_;e:for(;T!==null;){switch(T.tag){case 27:if(ga(T.type)){ii=T.stateNode,En=!1;break e}break;case 5:ii=T.stateNode,En=!1;break e;case 3:case 4:ii=T.stateNode.containerInfo,En=!0;break e}T=T.return}if(ii===null)throw Error(r(160));xS(h,_,d),ii=null,En=!1,h=d.alternate,h!==null&&(h.return=null),d.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)ES(s,i),s=s.sibling}var Cs=null;function ES(i,s){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Dn(s,i),Rn(i),l&4&&(ca(3,i,i.return),kc(3,i),ca(5,i,i.return));break;case 1:Dn(s,i),Rn(i),l&512&&(Ri||a===null||Fs(a,a.return)),l&64&&yr&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var d=Cs;if(Dn(s,i),Rn(i),l&512&&(Ri||a===null||Fs(a,a.return)),l&4){var h=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,d=d.ownerDocument||d;t:switch(l){case"title":h=d.getElementsByTagName("title")[0],(!h||h[hs]||h[vi]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=d.createElement(l),d.head.insertBefore(h,d.querySelector("head > title"))),on(h,l,a),h[vi]=i,zt(h),l=h;break e;case"link":var _=E0("link","href",d).get(l+(a.href||""));if(_){for(var T=0;T<_.length;T++)if(h=_[T],h.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&h.getAttribute("rel")===(a.rel==null?null:a.rel)&&h.getAttribute("title")===(a.title==null?null:a.title)&&h.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(T,1);break t}}h=d.createElement(l),on(h,l,a),d.head.appendChild(h);break;case"meta":if(_=E0("meta","content",d).get(l+(a.content||""))){for(T=0;T<_.length;T++)if(h=_[T],h.getAttribute("content")===(a.content==null?null:""+a.content)&&h.getAttribute("name")===(a.name==null?null:a.name)&&h.getAttribute("property")===(a.property==null?null:a.property)&&h.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&h.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(T,1);break t}}h=d.createElement(l),on(h,l,a),d.head.appendChild(h);break;default:throw Error(r(468,l))}h[vi]=i,zt(h),l=h}i.stateNode=l}else D0(d,i.type,i.stateNode);else i.stateNode=T0(d,l,i.memoizedProps);else h!==l?(h===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):h.count--,l===null?D0(d,i.type,i.stateNode):T0(d,l,i.memoizedProps)):l===null&&i.stateNode!==null&&am(i,i.memoizedProps,a.memoizedProps)}break;case 27:Dn(s,i),Rn(i),l&512&&(Ri||a===null||Fs(a,a.return)),a!==null&&l&4&&am(i,i.memoizedProps,a.memoizedProps);break;case 5:if(Dn(s,i),Rn(i),l&512&&(Ri||a===null||Fs(a,a.return)),i.flags&32){d=i.stateNode;try{dn(d,"")}catch(He){jt(i,i.return,He)}}l&4&&i.stateNode!=null&&(d=i.memoizedProps,am(i,d,a!==null?a.memoizedProps:d)),l&1024&&(cm=!0);break;case 6:if(Dn(s,i),Rn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(He){jt(i,i.return,He)}}break;case 3:if(ah=null,d=Cs,Cs=sh(s.containerInfo),Dn(s,i),Cs=d,Rn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{_l(s.containerInfo)}catch(He){jt(i,i.return,He)}cm&&(cm=!1,DS(i));break;case 4:l=Cs,Cs=sh(i.stateNode.containerInfo),Dn(s,i),Rn(i),Cs=l;break;case 12:Dn(s,i),Rn(i);break;case 31:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 13:Dn(s,i),Rn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(qd=ct()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 22:d=i.memoizedState!==null;var L=a!==null&&a.memoizedState!==null,Z=yr,he=Ri;if(yr=Z||d,Ri=he||L,Dn(s,i),Ri=he,yr=Z,Rn(i),l&8192)e:for(s=i.stateNode,s._visibility=d?s._visibility&-2:s._visibility|1,d&&(a===null||L||yr||Ri||fo(i)),a=null,s=i;;){if(s.tag===5||s.tag===26){if(a===null){L=a=s;try{if(h=L.stateNode,d)_=h.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{T=L.stateNode;var _e=L.memoizedProps.style,te=_e!=null&&_e.hasOwnProperty("display")?_e.display:null;T.style.display=te==null||typeof te=="boolean"?"":(""+te).trim()}}catch(He){jt(L,L.return,He)}}}else if(s.tag===6){if(a===null){L=s;try{L.stateNode.nodeValue=d?"":L.memoizedProps}catch(He){jt(L,L.return,He)}}}else if(s.tag===18){if(a===null){L=s;try{var ce=L.stateNode;d?v0(ce,!0):v0(L.stateNode,!1)}catch(He){jt(L,L.return,He)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===i)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;a===s&&(a=null),s=s.return}a===s&&(a=null),s.sibling.return=s.return,s=s.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Wd(i,a))));break;case 19:Dn(s,i),Rn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Wd(i,l)));break;case 30:break;case 21:break;default:Dn(s,i),Rn(i)}}function Rn(i){var s=i.flags;if(s&2){try{for(var a,l=i.return;l!==null;){if(bS(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var d=a.stateNode,h=om(i);Fd(i,h,d);break;case 5:var _=a.stateNode;a.flags&32&&(dn(_,""),a.flags&=-33);var T=om(i);Fd(i,T,_);break;case 3:case 4:var L=a.stateNode.containerInfo,Z=om(i);lm(i,Z,L);break;default:throw Error(r(161))}}catch(he){jt(i,i.return,he)}i.flags&=-3}s&4096&&(i.flags&=-4097)}function DS(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var s=i;DS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),i=i.sibling}}function wr(i,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)wS(i,s.alternate,s),s=s.sibling}function fo(i){for(i=i.child;i!==null;){var s=i;switch(s.tag){case 0:case 11:case 14:case 15:ca(4,s,s.return),fo(s);break;case 1:Fs(s,s.return);var a=s.stateNode;typeof a.componentWillUnmount=="function"&&vS(s,s.return,a),fo(s);break;case 27:Bc(s.stateNode);case 26:case 5:Fs(s,s.return),fo(s);break;case 22:s.memoizedState===null&&fo(s);break;case 30:fo(s);break;default:fo(s)}i=i.sibling}}function Cr(i,s,a){for(a=a&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var l=s.alternate,d=i,h=s,_=h.flags;switch(h.tag){case 0:case 11:case 15:Cr(d,h,a),kc(4,h);break;case 1:if(Cr(d,h,a),l=h,d=l.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(Z){jt(l,l.return,Z)}if(l=h,d=l.updateQueue,d!==null){var T=l.stateNode;try{var L=d.shared.hiddenCallbacks;if(L!==null)for(d.shared.hiddenCallbacks=null,d=0;d<L.length;d++)ry(L[d],T)}catch(Z){jt(l,l.return,Z)}}a&&_&64&&gS(h),Tc(h,h.return);break;case 27:yS(h);case 26:case 5:Cr(d,h,a),a&&l===null&&_&4&&_S(h),Tc(h,h.return);break;case 12:Cr(d,h,a);break;case 31:Cr(d,h,a),a&&_&4&&kS(d,h);break;case 13:Cr(d,h,a),a&&_&4&&TS(d,h);break;case 22:h.memoizedState===null&&Cr(d,h,a),Tc(h,h.return);break;case 30:break;default:Cr(d,h,a)}s=s.sibling}}function um(i,s){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(i=s.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&hc(a))}function dm(i,s){i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&hc(i))}function xs(i,s,a,l){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)RS(i,s,a,l),s=s.sibling}function RS(i,s,a,l){var d=s.flags;switch(s.tag){case 0:case 11:case 15:xs(i,s,a,l),d&2048&&kc(9,s);break;case 1:xs(i,s,a,l);break;case 3:xs(i,s,a,l),d&2048&&(i=null,s.alternate!==null&&(i=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==i&&(s.refCount++,i!=null&&hc(i)));break;case 12:if(d&2048){xs(i,s,a,l),i=s.stateNode;try{var h=s.memoizedProps,_=h.id,T=h.onPostCommit;typeof T=="function"&&T(_,s.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(L){jt(s,s.return,L)}}else xs(i,s,a,l);break;case 31:xs(i,s,a,l);break;case 13:xs(i,s,a,l);break;case 23:break;case 22:h=s.stateNode,_=s.alternate,s.memoizedState!==null?h._visibility&2?xs(i,s,a,l):Ec(i,s):h._visibility&2?xs(i,s,a,l):(h._visibility|=2,ol(i,s,a,l,(s.subtreeFlags&10256)!==0||!1)),d&2048&&um(_,s);break;case 24:xs(i,s,a,l),d&2048&&dm(s.alternate,s);break;default:xs(i,s,a,l)}}function ol(i,s,a,l,d){for(d=d&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var h=i,_=s,T=a,L=l,Z=_.flags;switch(_.tag){case 0:case 11:case 15:ol(h,_,T,L,d),kc(8,_);break;case 23:break;case 22:var he=_.stateNode;_.memoizedState!==null?he._visibility&2?ol(h,_,T,L,d):Ec(h,_):(he._visibility|=2,ol(h,_,T,L,d)),d&&Z&2048&&um(_.alternate,_);break;case 24:ol(h,_,T,L,d),d&&Z&2048&&dm(_.alternate,_);break;default:ol(h,_,T,L,d)}s=s.sibling}}function Ec(i,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var a=i,l=s,d=l.flags;switch(l.tag){case 22:Ec(a,l),d&2048&&um(l.alternate,l);break;case 24:Ec(a,l),d&2048&&dm(l.alternate,l);break;default:Ec(a,l)}s=s.sibling}}var Dc=8192;function ll(i,s,a){if(i.subtreeFlags&Dc)for(i=i.child;i!==null;)MS(i,s,a),i=i.sibling}function MS(i,s,a){switch(i.tag){case 26:ll(i,s,a),i.flags&Dc&&i.memoizedState!==null&&VE(a,Cs,i.memoizedState,i.memoizedProps);break;case 5:ll(i,s,a);break;case 3:case 4:var l=Cs;Cs=sh(i.stateNode.containerInfo),ll(i,s,a),Cs=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=Dc,Dc=16777216,ll(i,s,a),Dc=l):ll(i,s,a));break;default:ll(i,s,a)}}function NS(i){var s=i.alternate;if(s!==null&&(i=s.child,i!==null)){s.child=null;do s=i.sibling,i.sibling=null,i=s;while(i!==null)}}function Rc(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,LS(l,i)}NS(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)AS(i),i=i.sibling}function AS(i){switch(i.tag){case 0:case 11:case 15:Rc(i),i.flags&2048&&ca(9,i,i.return);break;case 3:Rc(i);break;case 12:Rc(i);break;case 22:var s=i.stateNode;i.memoizedState!==null&&s._visibility&2&&(i.return===null||i.return.tag!==13)?(s._visibility&=-3,$d(i)):Rc(i);break;default:Rc(i)}}function $d(i){var s=i.deletions;if((i.flags&16)!==0){if(s!==null)for(var a=0;a<s.length;a++){var l=s[a];$i=l,LS(l,i)}NS(i)}for(i=i.child;i!==null;){switch(s=i,s.tag){case 0:case 11:case 15:ca(8,s,s.return),$d(s);break;case 22:a=s.stateNode,a._visibility&2&&(a._visibility&=-3,$d(s));break;default:$d(s)}i=i.sibling}}function LS(i,s){for(;$i!==null;){var a=$i;switch(a.tag){case 0:case 11:case 15:ca(8,a,s);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:hc(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,$i=l;else e:for(a=i;$i!==null;){l=$i;var d=l.sibling,h=l.return;if(CS(l),l===a){$i=null;break e}if(d!==null){d.return=h,$i=d;break e}$i=h}}}var lE={getCacheForType:function(i){var s=rn(Ti),a=s.data.get(i);return a===void 0&&(a=i(),s.data.set(i,a)),a},cacheSignal:function(){return rn(Ti).controller.signal}},cE=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Vt=null,_t=null,wt=0,Bt=0,Kn=null,ua=!1,cl=!1,hm=!1,xr=0,hi=0,da=0,po=0,fm=0,Fn=0,ul=0,Mc=null,Mn=null,pm=!1,qd=0,OS=0,Vd=1/0,Yd=null,ha=null,Bi=0,fa=null,dl=null,kr=0,mm=0,gm=null,BS=null,Nc=0,vm=null;function Wn(){return(Mt&2)!==0&&wt!==0?wt&-wt:O.T!==null?Cm():ti()}function jS(){if(Fn===0)if((wt&536870912)===0||xt){var i=st;st<<=1,(st&3932160)===0&&(st=262144),Fn=i}else Fn=536870912;return i=Hn.current,i!==null&&(i.flags|=32),Fn}function Nn(i,s,a){(i===Vt&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)&&(hl(i,0),pa(i,wt,Fn,!1)),ui(i,a),((Mt&2)===0||i!==Vt)&&(i===Vt&&((Mt&2)===0&&(po|=a),hi===4&&pa(i,wt,Fn,!1)),Ws(i))}function IS(i,s,a){if((Mt&6)!==0)throw Error(r(327));var l=!a&&(s&127)===0&&(s&i.expiredLanes)===0||Ft(i,s),d=l?hE(i,s):bm(i,s,!0),h=l;do{if(d===0){cl&&!l&&pa(i,s,0,!1);break}else{if(a=i.current.alternate,h&&!uE(a)){d=bm(i,s,!1),h=!1;continue}if(d===2){if(h=s,i.errorRecoveryDisabledLanes&h)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){s=_;e:{var T=i;d=Mc;var L=T.current.memoizedState.isDehydrated;if(L&&(hl(T,_).flags|=256),_=bm(T,_,!1),_!==2){if(hm&&!L){T.errorRecoveryDisabledLanes|=h,po|=h,d=4;break e}h=Mn,Mn=d,h!==null&&(Mn===null?Mn=h:Mn.push.apply(Mn,h))}d=_}if(h=!1,d!==2)continue}}if(d===1){hl(i,0),pa(i,s,0,!0);break}e:{switch(l=i,h=d,h){case 0:case 1:throw Error(r(345));case 4:if((s&4194048)!==s)break;case 6:pa(l,s,Fn,!ua);break e;case 2:Mn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((s&62914560)===s&&(d=qd+300-ct(),10<d)){if(pa(l,s,Fn,!ua),Xt(l,0,!0)!==0)break e;kr=s,l.timeoutHandle=p0(zS.bind(null,l,a,Mn,Yd,pm,s,Fn,po,ul,ua,h,"Throttled",-0,0),d);break e}zS(l,a,Mn,Yd,pm,s,Fn,po,ul,ua,h,null,-0,0)}}break}while(!0);Ws(i)}function zS(i,s,a,l,d,h,_,T,L,Z,he,_e,te,ce){if(i.timeoutHandle=-1,_e=s.subtreeFlags,_e&8192||(_e&16785408)===16785408){_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Xn},MS(s,h,_e);var He=(h&62914560)===h?qd-ct():(h&4194048)===h?OS-ct():0;if(He=YE(_e,He),He!==null){kr=h,i.cancelPendingCommit=He(qS.bind(null,i,s,h,a,l,d,_,T,L,he,_e,null,te,ce)),pa(i,h,_,!Z);return}}qS(i,s,h,a,l,d,_,T,L)}function uE(i){for(var s=i;;){var a=s.tag;if((a===0||a===11||a===15)&&s.flags&16384&&(a=s.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var d=a[l],h=d.getSnapshot;d=d.value;try{if(!Sn(h(),d))return!1}catch{return!1}}if(a=s.child,s.subtreeFlags&16384&&a!==null)a.return=s,s=a;else{if(s===i)break;for(;s.sibling===null;){if(s.return===null||s.return===i)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function pa(i,s,a,l){s&=~fm,s&=~po,i.suspendedLanes|=s,i.pingedLanes&=~s,l&&(i.warmLanes|=s),l=i.expirationTimes;for(var d=s;0<d;){var h=31-ut(d),_=1<<h;l[h]=-1,d&=~_}a!==0&&cn(i,a,s)}function Xd(){return(Mt&6)===0?(Ac(0),!1):!0}function _m(){if(_t!==null){if(Bt===0)var i=_t.return;else i=_t,pr=so=null,Op(i),il=null,pc=0,i=_t;for(;i!==null;)mS(i.alternate,i),i=i.return;_t=null}}function hl(i,s){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,ME(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),kr=0,_m(),Vt=i,_t=a=hr(i.current,null),wt=s,Bt=0,Kn=null,ua=!1,cl=Ft(i,s),hm=!1,ul=Fn=fm=po=da=hi=0,Mn=Mc=null,pm=!1,(s&8)!==0&&(s|=s&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=s;0<l;){var d=31-ut(l),h=1<<d;s|=i[d],l&=~h}return xr=s,gd(),a}function PS(i,s){lt=null,O.H=wc,s===tl||s===xd?(s=ty(),Bt=3):s===wp?(s=ty(),Bt=4):Bt=s===Gp?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,Kn=s,_t===null&&(hi=1,zd(i,Jn(s,i.current)))}function HS(){var i=Hn.current;return i===null?!0:(wt&4194048)===wt?ns===null:(wt&62914560)===wt||(wt&536870912)!==0?i===ns:!1}function US(){var i=O.H;return O.H=wc,i===null?wc:i}function KS(){var i=O.A;return O.A=lE,i}function Gd(){hi=4,ua||(wt&4194048)!==wt&&Hn.current!==null||(cl=!0),(da&134217727)===0&&(po&134217727)===0||Vt===null||pa(Vt,wt,Fn,!1)}function bm(i,s,a){var l=Mt;Mt|=2;var d=US(),h=KS();(Vt!==i||wt!==s)&&(Yd=null,hl(i,s)),s=!1;var _=hi;e:do try{if(Bt!==0&&_t!==null){var T=_t,L=Kn;switch(Bt){case 8:_m(),_=6;break e;case 3:case 2:case 9:case 6:Hn.current===null&&(s=!0);var Z=Bt;if(Bt=0,Kn=null,fl(i,T,L,Z),a&&cl){_=0;break e}break;default:Z=Bt,Bt=0,Kn=null,fl(i,T,L,Z)}}dE(),_=hi;break}catch(he){PS(i,he)}while(!0);return s&&i.shellSuspendCounter++,pr=so=null,Mt=l,O.H=d,O.A=h,_t===null&&(Vt=null,wt=0,gd()),_}function dE(){for(;_t!==null;)FS(_t)}function hE(i,s){var a=Mt;Mt|=2;var l=US(),d=KS();Vt!==i||wt!==s?(Yd=null,Vd=ct()+500,hl(i,s)):cl=Ft(i,s);e:do try{if(Bt!==0&&_t!==null){s=_t;var h=Kn;t:switch(Bt){case 1:Bt=0,Kn=null,fl(i,s,h,1);break;case 2:case 9:if(Jb(h)){Bt=0,Kn=null,WS(s);break}s=function(){Bt!==2&&Bt!==9||Vt!==i||(Bt=7),Ws(i)},h.then(s,s);break e;case 3:Bt=7;break e;case 4:Bt=5;break e;case 7:Jb(h)?(Bt=0,Kn=null,WS(s)):(Bt=0,Kn=null,fl(i,s,h,7));break;case 5:var _=null;switch(_t.tag){case 26:_=_t.memoizedState;case 5:case 27:var T=_t;if(_?R0(_):T.stateNode.complete){Bt=0,Kn=null;var L=T.sibling;if(L!==null)_t=L;else{var Z=T.return;Z!==null?(_t=Z,Zd(Z)):_t=null}break t}}Bt=0,Kn=null,fl(i,s,h,5);break;case 6:Bt=0,Kn=null,fl(i,s,h,6);break;case 8:_m(),hi=6;break e;default:throw Error(r(462))}}fE();break}catch(he){PS(i,he)}while(!0);return pr=so=null,O.H=l,O.A=d,Mt=a,_t!==null?0:(Vt=null,wt=0,gd(),hi)}function fE(){for(;_t!==null&&!je();)FS(_t)}function FS(i){var s=fS(i.alternate,i,xr);i.memoizedProps=i.pendingProps,s===null?Zd(i):_t=s}function WS(i){var s=i,a=s.alternate;switch(s.tag){case 15:case 0:s=oS(a,s,s.pendingProps,s.type,void 0,wt);break;case 11:s=oS(a,s,s.pendingProps,s.type.render,s.ref,wt);break;case 5:Op(s);default:mS(a,s),s=_t=Kb(s,xr),s=fS(a,s,xr)}i.memoizedProps=i.pendingProps,s===null?Zd(i):_t=s}function fl(i,s,a,l){pr=so=null,Op(s),il=null,pc=0;var d=s.return;try{if(tE(i,d,s,a,wt)){hi=1,zd(i,Jn(a,i.current)),_t=null;return}}catch(h){if(d!==null)throw _t=d,h;hi=1,zd(i,Jn(a,i.current)),_t=null;return}s.flags&32768?(xt||l===1?i=!0:cl||(wt&536870912)!==0?i=!1:(ua=i=!0,(l===2||l===9||l===3||l===6)&&(l=Hn.current,l!==null&&l.tag===13&&(l.flags|=16384))),$S(s,i)):Zd(s)}function Zd(i){var s=i;do{if((s.flags&32768)!==0){$S(s,ua);return}i=s.return;var a=sE(s.alternate,s,xr);if(a!==null){_t=a;return}if(s=s.sibling,s!==null){_t=s;return}_t=s=i}while(s!==null);hi===0&&(hi=5)}function $S(i,s){do{var a=rE(i.alternate,i);if(a!==null){a.flags&=32767,_t=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!s&&(i=i.sibling,i!==null)){_t=i;return}_t=i=a}while(i!==null);hi=6,_t=null}function qS(i,s,a,l,d,h,_,T,L){i.cancelPendingCommit=null;do Qd();while(Bi!==0);if((Mt&6)!==0)throw Error(r(327));if(s!==null){if(s===i.current)throw Error(r(177));if(h=s.lanes|s.childLanes,h|=op,Wt(i,a,h,_,T,L),i===Vt&&(_t=Vt=null,wt=0),dl=s,fa=i,kr=a,mm=h,gm=d,BS=l,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,vE($e,function(){return ZS(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||l){l=O.T,O.T=null,d=M.p,M.p=2,_=Mt,Mt|=4;try{aE(i,s,a)}finally{Mt=_,M.p=d,O.T=l}}Bi=1,VS(),YS(),XS()}}function VS(){if(Bi===1){Bi=0;var i=fa,s=dl,a=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var l=M.p;M.p=2;var d=Mt;Mt|=4;try{ES(s,i);var h=Nm,_=pd(i.containerInfo),T=h.focusedElem,L=h.selectionRange;if(_!==T&&T&&T.ownerDocument&&fd(T.ownerDocument.documentElement,T)){if(L!==null&&eo(T)){var Z=L.start,he=L.end;if(he===void 0&&(he=Z),"selectionStart"in T)T.selectionStart=Z,T.selectionEnd=Math.min(he,T.value.length);else{var _e=T.ownerDocument||document,te=_e&&_e.defaultView||window;if(te.getSelection){var ce=te.getSelection(),He=T.textContent.length,Je=Math.min(L.start,He),Ut=L.end===void 0?Je:Math.min(L.end,He);!ce.extend&&Je>Ut&&(_=Ut,Ut=Je,Je=_);var K=hd(T,Je),P=hd(T,Ut);if(K&&P&&(ce.rangeCount!==1||ce.anchorNode!==K.node||ce.anchorOffset!==K.offset||ce.focusNode!==P.node||ce.focusOffset!==P.offset)){var G=_e.createRange();G.setStart(K.node,K.offset),ce.removeAllRanges(),Je>Ut?(ce.addRange(G),ce.extend(P.node,P.offset)):(G.setEnd(P.node,P.offset),ce.addRange(G))}}}}for(_e=[],ce=T;ce=ce.parentNode;)ce.nodeType===1&&_e.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<_e.length;T++){var ve=_e[T];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}uh=!!Mm,Nm=Mm=null}finally{Mt=d,M.p=l,O.T=a}}i.current=s,Bi=2}}function YS(){if(Bi===2){Bi=0;var i=fa,s=dl,a=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var l=M.p;M.p=2;var d=Mt;Mt|=4;try{wS(i,s.alternate,s)}finally{Mt=d,M.p=l,O.T=a}}Bi=3}}function XS(){if(Bi===4||Bi===3){Bi=0,Ye();var i=fa,s=dl,a=kr,l=BS;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Bi=5:(Bi=0,dl=fa=null,GS(i,i.pendingLanes));var d=i.pendingLanes;if(d===0&&(ha=null),_n(a),s=s.stateNode,Ze&&typeof Ze.onCommitFiberRoot=="function")try{Ze.onCommitFiberRoot(rt,s,void 0,(s.current.flags&128)===128)}catch{}if(l!==null){s=O.T,d=M.p,M.p=2,O.T=null;try{for(var h=i.onRecoverableError,_=0;_<l.length;_++){var T=l[_];h(T.value,{componentStack:T.stack})}}finally{O.T=s,M.p=d}}(kr&3)!==0&&Qd(),Ws(i),d=i.pendingLanes,(a&261930)!==0&&(d&42)!==0?i===vm?Nc++:(Nc=0,vm=i):Nc=0,Ac(0)}}function GS(i,s){(i.pooledCacheLanes&=s)===0&&(s=i.pooledCache,s!=null&&(i.pooledCache=null,hc(s)))}function Qd(){return VS(),YS(),XS(),ZS()}function ZS(){if(Bi!==5)return!1;var i=fa,s=mm;mm=0;var a=_n(kr),l=O.T,d=M.p;try{M.p=32>a?32:a,O.T=null,a=gm,gm=null;var h=fa,_=kr;if(Bi=0,dl=fa=null,kr=0,(Mt&6)!==0)throw Error(r(331));var T=Mt;if(Mt|=4,AS(h.current),RS(h,h.current,_,a),Mt=T,Ac(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(rt,h)}catch{}return!0}finally{M.p=d,O.T=l,GS(i,s)}}function QS(i,s,a){s=Jn(a,s),s=Xp(i.stateNode,s,2),i=aa(i,s,2),i!==null&&(ui(i,2),Ws(i))}function jt(i,s,a){if(i.tag===3)QS(i,i,a);else for(;s!==null;){if(s.tag===3){QS(s,i,a);break}else if(s.tag===1){var l=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(ha===null||!ha.has(l))){i=Jn(a,i),a=Jy(2),l=aa(s,a,2),l!==null&&(eS(a,l,s,i),ui(l,2),Ws(l));break}}s=s.return}}function ym(i,s,a){var l=i.pingCache;if(l===null){l=i.pingCache=new cE;var d=new Set;l.set(s,d)}else d=l.get(s),d===void 0&&(d=new Set,l.set(s,d));d.has(a)||(hm=!0,d.add(a),i=pE.bind(null,i,s,a),s.then(i,i))}function pE(i,s,a){var l=i.pingCache;l!==null&&l.delete(s),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Vt===i&&(wt&a)===a&&(hi===4||hi===3&&(wt&62914560)===wt&&300>ct()-qd?(Mt&2)===0&&hl(i,0):fm|=a,ul===wt&&(ul=0)),Ws(i)}function JS(i,s){s===0&&(s=Gt()),i=to(i,s),i!==null&&(ui(i,s),Ws(i))}function mE(i){var s=i.memoizedState,a=0;s!==null&&(a=s.retryLane),JS(i,a)}function gE(i,s){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,d=i.memoizedState;d!==null&&(a=d.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(s),JS(i,a)}function vE(i,s){return Re(i,s)}var Jd=null,pl=null,Sm=!1,eh=!1,wm=!1,ma=0;function Ws(i){i!==pl&&i.next===null&&(pl===null?Jd=pl=i:pl=pl.next=i),eh=!0,Sm||(Sm=!0,bE())}function Ac(i,s){if(!wm&&eh){wm=!0;do for(var a=!1,l=Jd;l!==null;){if(i!==0){var d=l.pendingLanes;if(d===0)var h=0;else{var _=l.suspendedLanes,T=l.pingedLanes;h=(1<<31-ut(42|i)+1)-1,h&=d&~(_&~T),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(a=!0,n0(l,h))}else h=wt,h=Xt(l,l===Vt?h:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(h&3)===0||Ft(l,h)||(a=!0,n0(l,h));l=l.next}while(a);wm=!1}}function _E(){e0()}function e0(){eh=Sm=!1;var i=0;ma!==0&&RE()&&(i=ma);for(var s=ct(),a=null,l=Jd;l!==null;){var d=l.next,h=t0(l,s);h===0?(l.next=null,a===null?Jd=d:a.next=d,d===null&&(pl=a)):(a=l,(i!==0||(h&3)!==0)&&(eh=!0)),l=d}Bi!==0&&Bi!==5||Ac(i),ma!==0&&(ma=0)}function t0(i,s){for(var a=i.suspendedLanes,l=i.pingedLanes,d=i.expirationTimes,h=i.pendingLanes&-62914561;0<h;){var _=31-ut(h),T=1<<_,L=d[_];L===-1?((T&a)===0||(T&l)!==0)&&(d[_]=ci(T,s)):L<=s&&(i.expiredLanes|=T),h&=~T}if(s=Vt,a=wt,a=Xt(i,i===s?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===s&&(Bt===2||Bt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&Ie(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Ft(i,a)){if(s=a&-a,s===i.callbackPriority)return s;switch(l!==null&&Ie(l),_n(a)){case 2:case 8:a=Tt;break;case 32:a=$e;break;case 268435456:a=Lt;break;default:a=$e}return l=i0.bind(null,i),a=Re(a,l),i.callbackPriority=s,i.callbackNode=a,s}return l!==null&&l!==null&&Ie(l),i.callbackPriority=2,i.callbackNode=null,2}function i0(i,s){if(Bi!==0&&Bi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Qd()&&i.callbackNode!==a)return null;var l=wt;return l=Xt(i,i===Vt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(IS(i,l,s),t0(i,ct()),i.callbackNode!=null&&i.callbackNode===a?i0.bind(null,i):null)}function n0(i,s){if(Qd())return null;IS(i,s,!0)}function bE(){NE(function(){(Mt&6)!==0?Re(yt,_E):e0()})}function Cm(){if(ma===0){var i=Jo;i===0&&(i=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),ma=i}return ma}function s0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:ys(""+i)}function r0(i,s){var a=s.ownerDocument.createElement("input");return a.name=s.name,a.value=s.value,i.id&&a.setAttribute("form",i.id),s.parentNode.insertBefore(a,s),i=new FormData(i),a.parentNode.removeChild(a),i}function yE(i,s,a,l,d){if(s==="submit"&&a&&a.stateNode===d){var h=s0((d[_i]||null).action),_=l.submitter;_&&(s=(s=_[_i]||null)?s0(s.formAction):_.getAttribute("formAction"),s!==null&&(h=s,_=null));var T=new w("action","action",null,l,d);i.push({event:T,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(ma!==0){var L=_?r0(d,_):new FormData(d);Fp(a,{pending:!0,data:L,method:d.method,action:h},null,L)}}else typeof h=="function"&&(T.preventDefault(),L=_?r0(d,_):new FormData(d),Fp(a,{pending:!0,data:L,method:d.method,action:h},h,L))},currentTarget:d}]})}}for(var xm=0;xm<ap.length;xm++){var km=ap[xm],SE=km.toLowerCase(),wE=km[0].toUpperCase()+km.slice(1);ws(SE,"on"+wE)}ws(qt,"onAnimationEnd"),ws(Ot,"onAnimationIteration"),ws(At,"onAnimationStart"),ws("dblclick","onDoubleClick"),ws("focusin","onFocus"),ws("focusout","onBlur"),ws(Ps,"onTransitionRun"),ws(qo,"onTransitionStart"),ws(Hs,"onTransitionCancel"),ws(lc,"onTransitionEnd"),jn("onMouseEnter",["mouseout","mouseover"]),jn("onMouseLeave",["mouseout","mouseover"]),jn("onPointerEnter",["pointerout","pointerover"]),jn("onPointerLeave",["pointerout","pointerover"]),$t("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),$t("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),$t("onBeforeInput",["compositionend","keypress","textInput","paste"]),$t("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),$t("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),$t("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Lc="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(" "),CE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Lc));function a0(i,s){s=(s&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],d=l.event;l=l.listeners;e:{var h=void 0;if(s)for(var _=l.length-1;0<=_;_--){var T=l[_],L=T.instance,Z=T.currentTarget;if(T=T.listener,L!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=Z;try{h(d)}catch(he){md(he)}d.currentTarget=null,h=L}else for(_=0;_<l.length;_++){if(T=l[_],L=T.instance,Z=T.currentTarget,T=T.listener,L!==h&&d.isPropagationStopped())break e;h=T,d.currentTarget=Z;try{h(d)}catch(he){md(he)}d.currentTarget=null,h=L}}}}function bt(i,s){var a=s[Hr];a===void 0&&(a=s[Hr]=new Set);var l=i+"__bubble";a.has(l)||(o0(s,i,2,!1),a.add(l))}function Tm(i,s,a){var l=0;s&&(l|=4),o0(a,i,l,s)}var th="_reactListening"+Math.random().toString(36).slice(2);function Em(i){if(!i[th]){i[th]=!0,Io.forEach(function(a){a!=="selectionchange"&&(CE.has(a)||Tm(a,!1,i),Tm(a,!0,i))});var s=i.nodeType===9?i:i.ownerDocument;s===null||s[th]||(s[th]=!0,Tm("selectionchange",!1,s))}}function o0(i,s,a,l){switch(j0(s)){case 2:var d=ZE;break;case 8:d=QE;break;default:d=Km}a=d.bind(null,s,a,i),d=void 0,!Xr||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(d=!0),l?d!==void 0?i.addEventListener(s,a,{capture:!0,passive:d}):i.addEventListener(s,a,!0):d!==void 0?i.addEventListener(s,a,{passive:d}):i.addEventListener(s,a,!1)}function Dm(i,s,a,l,d){var h=l;if((s&1)===0&&(s&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var T=l.stateNode.containerInfo;if(T===d)break;if(_===4)for(_=l.return;_!==null;){var L=_.tag;if((L===3||L===4)&&_.stateNode.containerInfo===d)return;_=_.return}for(;T!==null;){if(_=fs(T),_===null)return;if(L=_.tag,L===5||L===6||L===26||L===27){l=h=_;continue e}T=T.parentNode}}l=l.return}Xa(function(){var Z=h,he=Yr(a),_e=[];e:{var te=cc.get(i);if(te!==void 0){var ce=w,He=i;switch(i){case"keypress":if(or(a)===0)break e;case"keydown":case"keyup":ce=Xf;break;case"focusin":He="focus",ce=Is;break;case"focusout":He="blur",ce=Is;break;case"beforeblur":case"afterblur":ce=Is;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":ce=Qe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=Si;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=Gf;break;case qt:case Ot:case At:ce=Uo;break;case lc:ce=lr;break;case"scroll":case"scrollend":ce=z;break;case"wheel":ce=Zf;break;case"copy":case"cut":case"paste":ce=Zl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=Ql;break;case"toggle":case"beforetoggle":ce=Jf}var Je=(s&4)!==0,Ut=!Je&&(i==="scroll"||i==="scrollend"),K=Je?te!==null?te+"Capture":null:te;Je=[];for(var P=Z,G;P!==null;){var ve=P;if(G=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||G===null||K===null||(ve=In(P,K),ve!=null&&Je.push(Oc(P,ve,G))),Ut)break;P=P.return}0<Je.length&&(te=new ce(te,He,null,a,he),_e.push({event:te,listeners:Je}))}}if((s&7)===0){e:{if(te=i==="mouseover"||i==="pointerover",ce=i==="mouseout"||i==="pointerout",te&&a!==bi&&(He=a.relatedTarget||a.fromElement)&&(fs(He)||He[Bn]))break e;if((ce||te)&&(te=he.window===he?he:(te=he.ownerDocument)?te.defaultView||te.parentWindow:window,ce?(He=a.relatedTarget||a.toElement,ce=Z,He=He?fs(He):null,He!==null&&(Ut=c(He),Je=He.tag,He!==Ut||Je!==5&&Je!==27&&Je!==6)&&(He=null)):(ce=null,He=Z),ce!==He)){if(Je=Qe,ve="onMouseLeave",K="onMouseEnter",P="mouse",(i==="pointerout"||i==="pointerover")&&(Je=Ql,ve="onPointerLeave",K="onPointerEnter",P="pointer"),Ut=ce==null?te:ps(ce),G=He==null?te:ps(He),te=new Je(ve,P+"leave",ce,a,he),te.target=Ut,te.relatedTarget=G,ve=null,fs(he)===Z&&(Je=new Je(K,P+"enter",He,a,he),Je.target=G,Je.relatedTarget=Ut,ve=Je),Ut=ve,ce&&He)t:{for(Je=xE,K=ce,P=He,G=0,ve=K;ve;ve=Je(ve))G++;ve=0;for(var Ge=P;Ge;Ge=Je(Ge))ve++;for(;0<G-ve;)K=Je(K),G--;for(;0<ve-G;)P=Je(P),ve--;for(;G--;){if(K===P||P!==null&&K===P.alternate){Je=K;break t}K=Je(K),P=Je(P)}Je=null}else Je=null;ce!==null&&l0(_e,te,ce,Je,!1),He!==null&&Ut!==null&&l0(_e,Ut,He,Je,!0)}}e:{if(te=Z?ps(Z):window,ce=te.nodeName&&te.nodeName.toLowerCase(),ce==="select"||ce==="input"&&te.type==="file")var Dt=ac;else if(Za(te))if(cd)Dt=np;else{Dt=ip;var We=tp}else ce=te.nodeName,!ce||ce.toLowerCase()!=="input"||te.type!=="checkbox"&&te.type!=="radio"?Z&&Vr(Z.elementType)&&(Dt=ac):Dt=ur;if(Dt&&(Dt=Dt(i,Z))){rc(_e,Dt,a,he);break e}We&&We(i,te,Z),i==="focusout"&&Z&&te.type==="number"&&Z.memoizedProps.value!=null&&nr(te,"number",te.value)}switch(We=Z?ps(Z):window,i){case"focusin":(Za(We)||We.contentEditable==="true")&&(dr=We,x=Z,I=null);break;case"focusout":I=x=dr=null;break;case"mousedown":Te=!0;break;case"contextmenu":case"mouseup":case"dragend":Te=!1,qe(_e,a,he);break;case"selectionchange":if(rp)break;case"keydown":case"keyup":qe(_e,a,he)}var ht;if(Ga)e:{switch(i){case"compositionstart":var Ct="onCompositionStart";break e;case"compositionend":Ct="onCompositionEnd";break e;case"compositionupdate":Ct="onCompositionUpdate";break e}Ct=void 0}else Zr?nc(i,a)&&(Ct="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Ct="onCompositionStart");Ct&&(tc&&a.locale!=="ko"&&(Zr||Ct!=="onCompositionStart"?Ct==="onCompositionEnd"&&Zr&&(ht=ar()):(yn=he,Os="value"in yn?yn.value:yn.textContent,Zr=!0)),We=ih(Z,Ct),0<We.length&&(Ct=new Ko(Ct,i,null,a,he),_e.push({event:Ct,listeners:We}),ht?Ct.data=ht:(ht=ad(a),ht!==null&&(Ct.data=ht)))),(ht=Wo?ep(i,a):od(i,a))&&(Ct=ih(Z,"onBeforeInput"),0<Ct.length&&(We=new Ko("onBeforeInput","beforeinput",null,a,he),_e.push({event:We,listeners:Ct}),We.data=ht)),yE(_e,i,Z,a,he)}a0(_e,s)})}function Oc(i,s,a){return{instance:i,listener:s,currentTarget:a}}function ih(i,s){for(var a=s+"Capture",l=[];i!==null;){var d=i,h=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||h===null||(d=In(i,a),d!=null&&l.unshift(Oc(i,d,h)),d=In(i,s),d!=null&&l.push(Oc(i,d,h))),i.tag===3)return l;i=i.return}return[]}function xE(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function l0(i,s,a,l,d){for(var h=s._reactName,_=[];a!==null&&a!==l;){var T=a,L=T.alternate,Z=T.stateNode;if(T=T.tag,L!==null&&L===l)break;T!==5&&T!==26&&T!==27||Z===null||(L=Z,d?(Z=In(a,h),Z!=null&&_.unshift(Oc(a,Z,L))):d||(Z=In(a,h),Z!=null&&_.push(Oc(a,Z,L)))),a=a.return}_.length!==0&&i.push({event:s,listeners:_})}var kE=/\r\n?/g,TE=/\u0000|\uFFFD/g;function c0(i){return(typeof i=="string"?i:""+i).replace(kE,`
|
|
10
|
-
`).replace(TE,"")}function u0(i,s){return s=c0(s),c0(i)===s}function Ht(i,s,a,l,d,h){switch(a){case"children":typeof l=="string"?s==="body"||s==="textarea"&&l===""||dn(i,l):(typeof l=="number"||typeof l=="bigint")&&s!=="body"&&dn(i,""+l);break;case"className":Wr(i,"class",l);break;case"tabIndex":Wr(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Wr(i,a,l);break;case"style":bs(i,l,h);break;case"data":if(s!=="object"){Wr(i,"data",l);break}case"src":case"href":if(l===""&&(s!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ys(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(a==="formAction"?(s!=="input"&&Ht(i,s,"name",d.name,d,null),Ht(i,s,"formEncType",d.formEncType,d,null),Ht(i,s,"formMethod",d.formMethod,d,null),Ht(i,s,"formTarget",d.formTarget,d,null)):(Ht(i,s,"encType",d.encType,d,null),Ht(i,s,"method",d.method,d,null),Ht(i,s,"target",d.target,d,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ys(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Xn);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=ys(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":bt("beforetoggle",i),bt("toggle",i),ms(i,"popover",l);break;case"xlinkActuate":bn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":bn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":bn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":bn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":bn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":bn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":bn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":bn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":bn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":ms(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Ho.get(a)||a,ms(i,a,l))}}function Rm(i,s,a,l,d,h){switch(a){case"style":bs(i,l,h);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(d.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?dn(i,l):(typeof l=="number"||typeof l=="bigint")&&dn(i,""+l);break;case"onScroll":l!=null&&bt("scroll",i);break;case"onScrollEnd":l!=null&&bt("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Xn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Kr.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(d=a.endsWith("Capture"),s=a.slice(2,d?a.length-7:void 0),h=i[_i]||null,h=h!=null?h[a]:null,typeof h=="function"&&i.removeEventListener(s,h,d),typeof l=="function")){typeof h!="function"&&h!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(s,l,d);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):ms(i,a,l)}}}function on(i,s,a){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":bt("error",i),bt("load",i);var l=!1,d=!1,h;for(h in a)if(a.hasOwnProperty(h)){var _=a[h];if(_!=null)switch(h){case"src":l=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ht(i,s,h,_,a,null)}}d&&Ht(i,s,"srcSet",a.srcSet,a,null),l&&Ht(i,s,"src",a.src,a,null);return;case"input":bt("invalid",i);var T=h=_=d=null,L=null,Z=null;for(l in a)if(a.hasOwnProperty(l)){var he=a[l];if(he!=null)switch(l){case"name":d=he;break;case"type":_=he;break;case"checked":L=he;break;case"defaultChecked":Z=he;break;case"value":h=he;break;case"defaultValue":T=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(r(137,s));break;default:Ht(i,s,l,he,a,null)}}_s(i,h,T,L,Z,_,d,!1);return;case"select":bt("invalid",i),l=_=h=null;for(d in a)if(a.hasOwnProperty(d)&&(T=a[d],T!=null))switch(d){case"value":h=T;break;case"defaultValue":_=T;break;case"multiple":l=T;default:Ht(i,s,d,T,a,null)}s=h,a=_,i.multiple=!!l,s!=null?un(i,!!l,s,!1):a!=null&&un(i,!!l,a,!0);return;case"textarea":bt("invalid",i),h=d=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(T=a[_],T!=null))switch(_){case"value":l=T;break;case"defaultValue":d=T;break;case"children":h=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(r(91));break;default:Ht(i,s,_,T,a,null)}Ya(i,l,d,h);return;case"option":for(L in a)a.hasOwnProperty(L)&&(l=a[L],l!=null)&&(L==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":Ht(i,s,L,l,a,null));return;case"dialog":bt("beforetoggle",i),bt("toggle",i),bt("cancel",i),bt("close",i);break;case"iframe":case"object":bt("load",i);break;case"video":case"audio":for(l=0;l<Lc.length;l++)bt(Lc[l],i);break;case"image":bt("error",i),bt("load",i);break;case"details":bt("toggle",i);break;case"embed":case"source":case"link":bt("error",i),bt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in a)if(a.hasOwnProperty(Z)&&(l=a[Z],l!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,s));default:Ht(i,s,Z,l,a,null)}return;default:if(Vr(s)){for(he in a)a.hasOwnProperty(he)&&(l=a[he],l!==void 0&&Rm(i,s,he,l,a,void 0));return}}for(T in a)a.hasOwnProperty(T)&&(l=a[T],l!=null&&Ht(i,s,T,l,a,null))}function EE(i,s,a,l){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,h=null,_=null,T=null,L=null,Z=null,he=null;for(ce in a){var _e=a[ce];if(a.hasOwnProperty(ce)&&_e!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":L=_e;default:l.hasOwnProperty(ce)||Ht(i,s,ce,null,l,_e)}}for(var te in l){var ce=l[te];if(_e=a[te],l.hasOwnProperty(te)&&(ce!=null||_e!=null))switch(te){case"type":h=ce;break;case"name":d=ce;break;case"checked":Z=ce;break;case"defaultChecked":he=ce;break;case"value":_=ce;break;case"defaultValue":T=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(r(137,s));break;default:ce!==_e&&Ht(i,s,te,ce,l,_e)}}mt(i,_,T,L,Z,he,h,d);return;case"select":ce=_=T=te=null;for(h in a)if(L=a[h],a.hasOwnProperty(h)&&L!=null)switch(h){case"value":break;case"multiple":ce=L;default:l.hasOwnProperty(h)||Ht(i,s,h,null,l,L)}for(d in l)if(h=l[d],L=a[d],l.hasOwnProperty(d)&&(h!=null||L!=null))switch(d){case"value":te=h;break;case"defaultValue":T=h;break;case"multiple":_=h;default:h!==L&&Ht(i,s,d,h,l,L)}s=T,a=_,l=ce,te!=null?un(i,!!a,te,!1):!!l!=!!a&&(s!=null?un(i,!!a,s,!0):un(i,!!a,a?[]:"",!1));return;case"textarea":ce=te=null;for(T in a)if(d=a[T],a.hasOwnProperty(T)&&d!=null&&!l.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:Ht(i,s,T,null,l,d)}for(_ in l)if(d=l[_],h=a[_],l.hasOwnProperty(_)&&(d!=null||h!=null))switch(_){case"value":te=d;break;case"defaultValue":ce=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==h&&Ht(i,s,_,d,l,h)}$r(i,te,ce);return;case"option":for(var He in a)te=a[He],a.hasOwnProperty(He)&&te!=null&&!l.hasOwnProperty(He)&&(He==="selected"?i.selected=!1:Ht(i,s,He,null,l,te));for(L in l)te=l[L],ce=a[L],l.hasOwnProperty(L)&&te!==ce&&(te!=null||ce!=null)&&(L==="selected"?i.selected=te&&typeof te!="function"&&typeof te!="symbol":Ht(i,s,L,te,l,ce));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 Je in a)te=a[Je],a.hasOwnProperty(Je)&&te!=null&&!l.hasOwnProperty(Je)&&Ht(i,s,Je,null,l,te);for(Z in l)if(te=l[Z],ce=a[Z],l.hasOwnProperty(Z)&&te!==ce&&(te!=null||ce!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(137,s));break;default:Ht(i,s,Z,te,l,ce)}return;default:if(Vr(s)){for(var Ut in a)te=a[Ut],a.hasOwnProperty(Ut)&&te!==void 0&&!l.hasOwnProperty(Ut)&&Rm(i,s,Ut,void 0,l,te);for(he in l)te=l[he],ce=a[he],!l.hasOwnProperty(he)||te===ce||te===void 0&&ce===void 0||Rm(i,s,he,te,l,ce);return}}for(var K in a)te=a[K],a.hasOwnProperty(K)&&te!=null&&!l.hasOwnProperty(K)&&Ht(i,s,K,null,l,te);for(_e in l)te=l[_e],ce=a[_e],!l.hasOwnProperty(_e)||te===ce||te==null&&ce==null||Ht(i,s,_e,te,l,ce)}function d0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function DE(){if(typeof performance.getEntriesByType=="function"){for(var i=0,s=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var d=a[l],h=d.transferSize,_=d.initiatorType,T=d.duration;if(h&&T&&d0(_)){for(_=0,T=d.responseEnd,l+=1;l<a.length;l++){var L=a[l],Z=L.startTime;if(Z>T)break;var he=L.transferSize,_e=L.initiatorType;he&&d0(_e)&&(L=L.responseEnd,_+=he*(L<T?1:(T-Z)/(L-Z)))}if(--l,s+=8*(h+_)/(d.duration/1e3),i++,10<i)break}}if(0<i)return s/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Mm=null,Nm=null;function nh(i){return i.nodeType===9?i:i.ownerDocument}function h0(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 f0(i,s){if(i===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&s==="foreignObject"?0:i}function Am(i,s){return i==="textarea"||i==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Lm=null;function RE(){var i=window.event;return i&&i.type==="popstate"?i===Lm?!1:(Lm=i,!0):(Lm=null,!1)}var p0=typeof setTimeout=="function"?setTimeout:void 0,ME=typeof clearTimeout=="function"?clearTimeout:void 0,m0=typeof Promise=="function"?Promise:void 0,NE=typeof queueMicrotask=="function"?queueMicrotask:typeof m0<"u"?function(i){return m0.resolve(null).then(i).catch(AE)}:p0;function AE(i){setTimeout(function(){throw i})}function ga(i){return i==="head"}function g0(i,s){var a=s,l=0;do{var d=a.nextSibling;if(i.removeChild(a),d&&d.nodeType===8)if(a=d.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(d),_l(s);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Bc(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Bc(a);for(var h=a.firstChild;h;){var _=h.nextSibling,T=h.nodeName;h[hs]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&h.rel.toLowerCase()==="stylesheet"||a.removeChild(h),h=_}}else a==="body"&&Bc(i.ownerDocument.body);a=d}while(a);_l(s)}function v0(i,s){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?s?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(s?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function Om(i){var s=i.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var a=s;switch(s=s.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Om(a),tr(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function LE(i,s,a,l){for(;i.nodeType===1;){var d=a;if(i.nodeName.toLowerCase()!==s.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[hs])switch(s){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(h=i.getAttribute("rel"),h==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(h!==d.rel||i.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||i.getAttribute("title")!==(d.title==null?null:d.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(h=i.getAttribute("src"),(h!==(d.src==null?null:d.src)||i.getAttribute("type")!==(d.type==null?null:d.type)||i.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&h&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(s==="input"&&i.type==="hidden"){var h=d.name==null?null:""+d.name;if(d.type==="hidden"&&i.getAttribute("name")===h)return i}else return i;if(i=ss(i.nextSibling),i===null)break}return null}function OE(i,s,a){if(s==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=ss(i.nextSibling),i===null))return null;return i}function _0(i,s){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!s||(i=ss(i.nextSibling),i===null))return null;return i}function Bm(i){return i.data==="$?"||i.data==="$~"}function jm(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function BE(i,s){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=s;else if(i.data!=="$?"||a.readyState!=="loading")s();else{var l=function(){s(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function ss(i){for(;i!=null;i=i.nextSibling){var s=i.nodeType;if(s===1||s===3)break;if(s===8){if(s=i.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return i}var Im=null;function b0(i){i=i.nextSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(s===0)return ss(i.nextSibling);s--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||s++}i=i.nextSibling}return null}function y0(i){i=i.previousSibling;for(var s=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(s===0)return i;s--}else a!=="/$"&&a!=="/&"||s++}i=i.previousSibling}return null}function S0(i,s,a){switch(s=nh(a),i){case"html":if(i=s.documentElement,!i)throw Error(r(452));return i;case"head":if(i=s.head,!i)throw Error(r(453));return i;case"body":if(i=s.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function Bc(i){for(var s=i.attributes;s.length;)i.removeAttributeNode(s[0]);tr(i)}var rs=new Map,w0=new Set;function sh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Tr=M.d;M.d={f:jE,r:IE,D:zE,C:PE,L:HE,m:UE,X:FE,S:KE,M:WE};function jE(){var i=Tr.f(),s=Xd();return i||s}function IE(i){var s=Rs(i);s!==null&&s.tag===5&&s.type==="form"?Py(s):Tr.r(i)}var ml=typeof document>"u"?null:document;function C0(i,s,a){var l=ml;if(l&&typeof s=="string"&&s){var d=Oi(s);d='link[rel="'+i+'"][href="'+d+'"]',typeof a=="string"&&(d+='[crossorigin="'+a+'"]'),w0.has(d)||(w0.add(d),i={rel:i,crossOrigin:a,href:s},l.querySelector(d)===null&&(s=l.createElement("link"),on(s,"link",i),zt(s),l.head.appendChild(s)))}}function zE(i){Tr.D(i),C0("dns-prefetch",i,null)}function PE(i,s){Tr.C(i,s),C0("preconnect",i,s)}function HE(i,s,a){Tr.L(i,s,a);var l=ml;if(l&&i&&s){var d='link[rel="preload"][as="'+Oi(s)+'"]';s==="image"&&a&&a.imageSrcSet?(d+='[imagesrcset="'+Oi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(d+='[imagesizes="'+Oi(a.imageSizes)+'"]')):d+='[href="'+Oi(i)+'"]';var h=d;switch(s){case"style":h=gl(i);break;case"script":h=vl(i)}rs.has(h)||(i=b({rel:"preload",href:s==="image"&&a&&a.imageSrcSet?void 0:i,as:s},a),rs.set(h,i),l.querySelector(d)!==null||s==="style"&&l.querySelector(jc(h))||s==="script"&&l.querySelector(Ic(h))||(s=l.createElement("link"),on(s,"link",i),zt(s),l.head.appendChild(s)))}}function UE(i,s){Tr.m(i,s);var a=ml;if(a&&i){var l=s&&typeof s.as=="string"?s.as:"script",d='link[rel="modulepreload"][as="'+Oi(l)+'"][href="'+Oi(i)+'"]',h=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=vl(i)}if(!rs.has(h)&&(i=b({rel:"modulepreload",href:i},s),rs.set(h,i),a.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ic(h)))return}l=a.createElement("link"),on(l,"link",i),zt(l),a.head.appendChild(l)}}}function KE(i,s,a){Tr.S(i,s,a);var l=ml;if(l&&i){var d=Ms(l).hoistableStyles,h=gl(i);s=s||"default";var _=d.get(h);if(!_){var T={loading:0,preload:null};if(_=l.querySelector(jc(h)))T.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":s},a),(a=rs.get(h))&&zm(i,a);var L=_=l.createElement("link");zt(L),on(L,"link",i),L._p=new Promise(function(Z,he){L.onload=Z,L.onerror=he}),L.addEventListener("load",function(){T.loading|=1}),L.addEventListener("error",function(){T.loading|=2}),T.loading|=4,rh(_,s,l)}_={type:"stylesheet",instance:_,count:1,state:T},d.set(h,_)}}}function FE(i,s){Tr.X(i,s);var a=ml;if(a&&i){var l=Ms(a).hoistableScripts,d=vl(i),h=l.get(d);h||(h=a.querySelector(Ic(d)),h||(i=b({src:i,async:!0},s),(s=rs.get(d))&&Pm(i,s),h=a.createElement("script"),zt(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function WE(i,s){Tr.M(i,s);var a=ml;if(a&&i){var l=Ms(a).hoistableScripts,d=vl(i),h=l.get(d);h||(h=a.querySelector(Ic(d)),h||(i=b({src:i,async:!0,type:"module"},s),(s=rs.get(d))&&Pm(i,s),h=a.createElement("script"),zt(h),on(h,"link",i),a.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},l.set(d,h))}}function x0(i,s,a,l){var d=(d=De.current)?sh(d):null;if(!d)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(s=gl(a.href),a=Ms(d).hoistableStyles,l=a.get(s),l||(l={type:"style",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=gl(a.href);var h=Ms(d).hoistableStyles,_=h.get(i);if(_||(d=d.ownerDocument||d,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(i,_),(h=d.querySelector(jc(i)))&&!h._p&&(_.instance=h,_.state.loading=5),rs.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},rs.set(i,a),h||$E(d,i,a,_.state))),s&&l===null)throw Error(r(528,""));return _}if(s&&l!==null)throw Error(r(529,""));return null;case"script":return s=a.async,a=a.src,typeof a=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=vl(a),a=Ms(d).hoistableScripts,l=a.get(s),l||(l={type:"script",instance:null,count:0,state:null},a.set(s,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function gl(i){return'href="'+Oi(i)+'"'}function jc(i){return'link[rel="stylesheet"]['+i+"]"}function k0(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function $E(i,s,a,l){i.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=i.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),on(s,"link",a),zt(s),i.head.appendChild(s))}function vl(i){return'[src="'+Oi(i)+'"]'}function Ic(i){return"script[async]"+i}function T0(i,s,a){if(s.count++,s.instance===null)switch(s.type){case"style":var l=i.querySelector('style[data-href~="'+Oi(a.href)+'"]');if(l)return s.instance=l,zt(l),l;var d=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),zt(l),on(l,"style",d),rh(l,a.precedence,i),s.instance=l;case"stylesheet":d=gl(a.href);var h=i.querySelector(jc(d));if(h)return s.state.loading|=4,s.instance=h,zt(h),h;l=k0(a),(d=rs.get(d))&&zm(l,d),h=(i.ownerDocument||i).createElement("link"),zt(h);var _=h;return _._p=new Promise(function(T,L){_.onload=T,_.onerror=L}),on(h,"link",l),s.state.loading|=4,rh(h,a.precedence,i),s.instance=h;case"script":return h=vl(a.src),(d=i.querySelector(Ic(h)))?(s.instance=d,zt(d),d):(l=a,(d=rs.get(h))&&(l=b({},a),Pm(l,d)),i=i.ownerDocument||i,d=i.createElement("script"),zt(d),on(d,"link",l),i.head.appendChild(d),s.instance=d);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(l=s.instance,s.state.loading|=4,rh(l,a.precedence,i));return s.instance}function rh(i,s,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,h=d,_=0;_<l.length;_++){var T=l[_];if(T.dataset.precedence===s)h=T;else if(h!==d)break}h?h.parentNode.insertBefore(i,h.nextSibling):(s=a.nodeType===9?a.head:a,s.insertBefore(i,s.firstChild))}function zm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.title==null&&(i.title=s.title)}function Pm(i,s){i.crossOrigin==null&&(i.crossOrigin=s.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=s.referrerPolicy),i.integrity==null&&(i.integrity=s.integrity)}var ah=null;function E0(i,s,a){if(ah===null){var l=new Map,d=ah=new Map;d.set(a,l)}else d=ah,l=d.get(a),l||(l=new Map,d.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),d=0;d<a.length;d++){var h=a[d];if(!(h[hs]||h[vi]||i==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var _=h.getAttribute(s)||"";_=i+_;var T=l.get(_);T?T.push(h):l.set(_,[h])}}return l}function D0(i,s,a){i=i.ownerDocument||i,i.head.insertBefore(a,s==="title"?i.querySelector("head > title"):null)}function qE(i,s,a){if(a===1||s.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(i=s.disabled,typeof s.precedence=="string"&&i==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function R0(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function VE(i,s,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var d=gl(l.href),h=s.querySelector(jc(d));if(h){s=h._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(i.count++,i=oh.bind(i),s.then(i,i)),a.state.loading|=4,a.instance=h,zt(h);return}h=s.ownerDocument||s,l=k0(l),(d=rs.get(d))&&zm(l,d),h=h.createElement("link"),zt(h);var _=h;_._p=new Promise(function(T,L){_.onload=T,_.onerror=L}),on(h,"link",l),a.instance=h}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,s),(s=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=oh.bind(i),s.addEventListener("load",a),s.addEventListener("error",a))}}var Hm=0;function YE(i,s){return i.stylesheets&&i.count===0&&ch(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&ch(i,i.stylesheets),i.unsuspend){var h=i.unsuspend;i.unsuspend=null,h()}},6e4+s);0<i.imgBytes&&Hm===0&&(Hm=62500*DE());var d=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&ch(i,i.stylesheets),i.unsuspend)){var h=i.unsuspend;i.unsuspend=null,h()}},(i.imgBytes>Hm?50:800)+s);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function oh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ch(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var lh=null;function ch(i,s){i.stylesheets=null,i.unsuspend!==null&&(i.count++,lh=new Map,s.forEach(XE,i),lh=null,oh.call(i))}function XE(i,s){if(!(s.state.loading&4)){var a=lh.get(i);if(a)var l=a.get(null);else{a=new Map,lh.set(i,a);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<d.length;h++){var _=d[h];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}d=s.instance,_=d.getAttribute("data-precedence"),h=a.get(_)||l,h===l&&a.set(null,d),a.set(_,d),this.count++,l=oh.bind(this),d.addEventListener("load",l),d.addEventListener("error",l),h?h.parentNode.insertBefore(d,h.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(d,i.firstChild)),s.state.loading|=4}}var zc={$$typeof:Y,Provider:null,Consumer:null,_currentValue:j,_currentValue2:j,_threadCount:0};function GE(i,s,a,l,d,h,_,T,L){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=si(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=si(0),this.hiddenUpdates=si(null),this.identifierPrefix=l,this.onUncaughtError=d,this.onCaughtError=h,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=L,this.incompleteTransitions=new Map}function M0(i,s,a,l,d,h,_,T,L,Z,he,_e){return i=new GE(i,s,a,_,L,Z,he,_e,T),s=1,h===!0&&(s|=24),h=Pn(3,null,null,s),i.current=h,h.stateNode=i,s=bp(),s.refCount++,i.pooledCache=s,s.refCount++,h.memoizedState={element:l,isDehydrated:a,cache:s},Cp(h),i}function N0(i){return i?(i=Yo,i):Yo}function A0(i,s,a,l,d,h){d=N0(d),l.context===null?l.context=d:l.pendingContext=d,l=ra(s),l.payload={element:a},h=h===void 0?null:h,h!==null&&(l.callback=h),a=aa(i,l,s),a!==null&&(Nn(a,i,s),gc(a,i,s))}function L0(i,s){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<s?a:s}}function Um(i,s){L0(i,s),(i=i.alternate)&&L0(i,s)}function O0(i){if(i.tag===13||i.tag===31){var s=to(i,67108864);s!==null&&Nn(s,i,67108864),Um(i,67108864)}}function B0(i){if(i.tag===13||i.tag===31){var s=Wn();s=vn(s);var a=to(i,s);a!==null&&Nn(a,i,s),Um(i,s)}}var uh=!0;function ZE(i,s,a,l){var d=O.T;O.T=null;var h=M.p;try{M.p=2,Km(i,s,a,l)}finally{M.p=h,O.T=d}}function QE(i,s,a,l){var d=O.T;O.T=null;var h=M.p;try{M.p=8,Km(i,s,a,l)}finally{M.p=h,O.T=d}}function Km(i,s,a,l){if(uh){var d=Fm(l);if(d===null)Dm(i,s,l,dh,a),I0(i,l);else if(e2(d,i,s,a,l))l.stopPropagation();else if(I0(i,l),s&4&&-1<JE.indexOf(i)){for(;d!==null;){var h=Rs(d);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var _=kt(h.pendingLanes);if(_!==0){var T=h;for(T.pendingLanes|=2,T.entangledLanes|=2;_;){var L=1<<31-ut(_);T.entanglements[1]|=L,_&=~L}Ws(h),(Mt&6)===0&&(Vd=ct()+500,Ac(0))}}break;case 31:case 13:T=to(h,2),T!==null&&Nn(T,h,2),Xd(),Um(h,2)}if(h=Fm(l),h===null&&Dm(i,s,l,dh,a),h===d)break;d=h}d!==null&&l.stopPropagation()}else Dm(i,s,l,null,a)}}function Fm(i){return i=Yr(i),Wm(i)}var dh=null;function Wm(i){if(dh=null,i=fs(i),i!==null){var s=c(i);if(s===null)i=null;else{var a=s.tag;if(a===13){if(i=u(s),i!==null)return i;i=null}else if(a===31){if(i=m(s),i!==null)return i;i=null}else if(a===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return dh=i,null}function j0(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(Nt()){case yt:return 2;case Tt:return 8;case $e:case St:return 32;case Lt:return 268435456;default:return 32}default:return 32}}var $m=!1,va=null,_a=null,ba=null,Pc=new Map,Hc=new Map,ya=[],JE="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 I0(i,s){switch(i){case"focusin":case"focusout":va=null;break;case"dragenter":case"dragleave":_a=null;break;case"mouseover":case"mouseout":ba=null;break;case"pointerover":case"pointerout":Pc.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hc.delete(s.pointerId)}}function Uc(i,s,a,l,d,h){return i===null||i.nativeEvent!==h?(i={blockedOn:s,domEventName:a,eventSystemFlags:l,nativeEvent:h,targetContainers:[d]},s!==null&&(s=Rs(s),s!==null&&O0(s)),i):(i.eventSystemFlags|=l,s=i.targetContainers,d!==null&&s.indexOf(d)===-1&&s.push(d),i)}function e2(i,s,a,l,d){switch(s){case"focusin":return va=Uc(va,i,s,a,l,d),!0;case"dragenter":return _a=Uc(_a,i,s,a,l,d),!0;case"mouseover":return ba=Uc(ba,i,s,a,l,d),!0;case"pointerover":var h=d.pointerId;return Pc.set(h,Uc(Pc.get(h)||null,i,s,a,l,d)),!0;case"gotpointercapture":return h=d.pointerId,Hc.set(h,Uc(Hc.get(h)||null,i,s,a,l,d)),!0}return!1}function z0(i){var s=fs(i.target);if(s!==null){var a=c(s);if(a!==null){if(s=a.tag,s===13){if(s=u(a),s!==null){i.blockedOn=s,Ji(i.priority,function(){B0(a)});return}}else if(s===31){if(s=m(a),s!==null){i.blockedOn=s,Ji(i.priority,function(){B0(a)});return}}else if(s===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function hh(i){if(i.blockedOn!==null)return!1;for(var s=i.targetContainers;0<s.length;){var a=Fm(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);bi=l,a.target.dispatchEvent(l),bi=null}else return s=Rs(a),s!==null&&O0(s),i.blockedOn=a,!1;s.shift()}return!0}function P0(i,s,a){hh(i)&&a.delete(s)}function t2(){$m=!1,va!==null&&hh(va)&&(va=null),_a!==null&&hh(_a)&&(_a=null),ba!==null&&hh(ba)&&(ba=null),Pc.forEach(P0),Hc.forEach(P0)}function fh(i,s){i.blockedOn===s&&(i.blockedOn=null,$m||($m=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,t2)))}var ph=null;function H0(i){ph!==i&&(ph=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ph===i&&(ph=null);for(var s=0;s<i.length;s+=3){var a=i[s],l=i[s+1],d=i[s+2];if(typeof l!="function"){if(Wm(l||a)===null)continue;break}var h=Rs(a);h!==null&&(i.splice(s,3),s-=3,Fp(h,{pending:!0,data:d,method:a.method,action:l},l,d))}}))}function _l(i){function s(L){return fh(L,i)}va!==null&&fh(va,i),_a!==null&&fh(_a,i),ba!==null&&fh(ba,i),Pc.forEach(s),Hc.forEach(s);for(var a=0;a<ya.length;a++){var l=ya[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<ya.length&&(a=ya[0],a.blockedOn===null);)z0(a),a.blockedOn===null&&ya.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var d=a[l],h=a[l+1],_=d[_i]||null;if(typeof h=="function")_||H0(a);else if(_){var T=null;if(h&&h.hasAttribute("formAction")){if(d=h,_=h[_i]||null)T=_.formAction;else if(Wm(d)!==null)continue}else T=_.action;typeof T=="function"?a[l+1]=T:(a.splice(l,3),l-=3),H0(a)}}}function U0(){function i(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(_){return d=_})},focusReset:"manual",scroll:"manual"})}function s(){d!==null&&(d(),d=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,d=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),d!==null&&(d(),d=null)}}}function qm(i){this._internalRoot=i}mh.prototype.render=qm.prototype.render=function(i){var s=this._internalRoot;if(s===null)throw Error(r(409));var a=s.current,l=Wn();A0(a,l,i,s,null,null)},mh.prototype.unmount=qm.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var s=i.containerInfo;A0(i.current,2,null,i,null,null),Xd(),s[Bn]=null}};function mh(i){this._internalRoot=i}mh.prototype.unstable_scheduleHydration=function(i){if(i){var s=ti();i={blockedOn:null,target:i,priority:s};for(var a=0;a<ya.length&&s!==0&&s<ya[a].priority;a++);ya.splice(a,0,i),a===0&&z0(i)}};var K0=t.version;if(K0!=="19.2.6")throw Error(r(527,K0,"19.2.6"));M.findDOMNode=function(i){var s=i._reactInternals;if(s===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(s),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var i2={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gh.isDisabled&&gh.supportsFiber)try{rt=gh.inject(i2),Ze=gh}catch{}}return Fc.createRoot=function(i,s){if(!o(i))throw Error(r(299));var a=!1,l="",d=Xy,h=Gy,_=Zy;return s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(l=s.identifierPrefix),s.onUncaughtError!==void 0&&(d=s.onUncaughtError),s.onCaughtError!==void 0&&(h=s.onCaughtError),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=M0(i,1,!1,null,null,a,l,null,d,h,_,U0),i[Bn]=s.current,Em(i),new qm(s)},Fc.hydrateRoot=function(i,s,a){if(!o(i))throw Error(r(299));var l=!1,d="",h=Xy,_=Gy,T=Zy,L=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(d=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(T=a.onRecoverableError),a.formState!==void 0&&(L=a.formState)),s=M0(i,1,!0,s,a??null,l,d,L,h,_,T,U0),s.context=N0(null),a=s.current,l=Wn(),l=vn(l),d=ra(l),d.callback=null,aa(a,d,l),a=l,s.current.lanes=a,ui(s,a),Ws(s),i[Bn]=s.current,Em(i),new mh(s)},Fc.version="19.2.6",Fc}var Q0;function h2(){if(Q0)return Xm.exports;Q0=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(),Xm.exports=d2(),Xm.exports}var f2=h2();class mo extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function bC(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let u=!1;const m=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{u||(u=!0,m(),o(b))},p=b=>{u||(u=!0,m(),c(b))},y=()=>{t.abort(),p(new mo(0,"Upload aborted."))};if(e.signal?.aborted){p(new mo(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST",e.endpoint??"/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{p(new mo(t.status,"Invalid upload response."))}return}p(new mo(t.status,p2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new mo(0,"Upload failed.")),t.onabort=()=>p(new mo(0,"Upload aborted.")),t.ontimeout=()=>p(new mo(0,"Upload timed out.")),t.send(n)})}function p2(e,t){try{const n=JSON.parse(e),r=typeof n.error=="string"?n.error:n.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}class Ln extends Error{constructor(t,n){super(n),this.status=t,this.name="ApiError"}status}function kf(e=fetch){return{getSession:(t={})=>Ae(e,`/api/auth/session${Ys(t)}`),setupPassword:t=>Ae(e,"/api/auth/password",it("POST",t)),login:t=>Ae(e,"/api/auth/login",it("POST",t)),reauth:t=>Ae(e,"/api/auth/reauth",it("POST",t)),logout:()=>Ae(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ae(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Ae(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ae(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Ae(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ae(e,"/api/auth/devices"),revokeDevice:async t=>{await wl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ae(e,"/api/auth/networks"),addNetwork:t=>Ae(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await wl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ae(e,"/api/agents"),addAgent:t=>Ae(e,"/api/agents",it("POST",t)),reorderAgents:t=>Ae(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,n)=>Ae(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:n})),getMainInfo:()=>Ae(e,"/api/main"),renameMain:t=>Ae(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await wl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ae(e,"/api/stats"),getAgentStats:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ae(e,"/api/version"),checkUpdate:()=>Ae(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ae(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ae(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),getCodeServerStatus:(t={})=>Ae(e,`/api/code-server/status${Ys(t)}`),installCodeServer:()=>Ae(e,"/api/code-server/install",{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(e,"/api/code-server/update",{method:"POST",credentials:"same-origin"}),openCodeServer:t=>Ae(e,"/api/code-server/open",it("POST",t)),stopCodeServer:(t={})=>Ae(e,"/api/code-server/stop",it("POST",t)),uninstallCodeServer:()=>Ae(e,"/api/code-server/uninstall",{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ae(e,"/api/terminals"),getTerminalLayout:()=>Ae(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ae(e,"/api/terminal-layout",it("PUT",t)),createFileRoot:t=>Ae(e,"/api/files/root",it("POST",t)),listFiles:t=>Ae(e,"/api/files/list",it("POST",t)),readFile:t=>Ae(e,"/api/files/read",it("POST",t)),writeFile:t=>Ae(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Ae(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Ae(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Ae(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Ae(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Ae(e,"/api/files/open",it("POST",t)),previewFile:t=>yC(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Ae(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await wl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,n)=>Ae(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:n})),getTerminalHistory:(t,n={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/history${Ys(n)}`),getTerminalTranscriptHistory:(t,n={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Ys(n)}`),getTerminalTranscriptSource:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),getTerminalSubagents:t=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents`),getTerminalSubagentTranscriptHistory:(t,n,r={})=>Ae(e,`/api/terminals/${encodeURIComponent(t)}/subagents/${encodeURIComponent(n)}/transcript-history${Ys(r)}`),listNotificationAssets:()=>Ae(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const n=new FormData;return n.append("asset",t),Ae(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:n})},updateNotificationAssetSelection:t=>Ae(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await wl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:(t,n)=>Ae(e,`/api/push-notifications/status${t||n?Ys({...t!==void 0?{clientId:t}:{},...n!==void 0?{endpointHash:n}:{}}):""}`),preparePushNotifications:t=>Ae(e,"/api/push-notifications/prepare",it("POST",{clientId:t})),subscribePushNotifications:t=>Ae(e,"/api/push-notifications/subscription",it("POST",t)),updatePushNotificationDevice:t=>Ae(e,"/api/push-notifications/device",it("PATCH",t)),unsubscribePushNotifications:t=>Ae(e,"/api/push-notifications/unsubscribe",it("POST",t)),updatePushPresence:t=>Ae(e,"/api/push-notifications/presence",it("POST",t)),testPushNotification:t=>Ae(e,"/api/push-notifications/test",it("POST",t))}}function Bl(e,t=fetch){const n=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Ae(t,n("terminals")),createTerminal:(r={})=>Ae(t,n("terminals"),it("POST",r)),closeTerminal:async r=>{await wl(t,n(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ae(t,n(`terminals/${encodeURIComponent(r)}`),it("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/history`)}${Ys(o)}`),getTerminalTranscriptHistory:(r,o={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Ys(o)}`),getTerminalTranscriptSource:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalSubagents:r=>Ae(t,n(`terminals/${encodeURIComponent(r)}/subagents`)),getTerminalSubagentTranscriptHistory:(r,o,c={})=>Ae(t,`${n(`terminals/${encodeURIComponent(r)}/subagents/${encodeURIComponent(o)}/transcript-history`)}${Ys(c)}`),getTerminalLayout:()=>Ae(t,n("terminal-layout")),saveTerminalLayout:r=>Ae(t,n("terminal-layout"),it("PUT",r)),createFileRoot:r=>Ae(t,n("files/root"),it("POST",r)),listFiles:r=>Ae(t,n("files/list"),it("POST",r)),readFile:r=>Ae(t,n("files/read"),it("POST",r)),writeFile:r=>Ae(t,n("files/write"),it("POST",r)),createFileEntry:r=>Ae(t,n("files/create"),it("POST",r)),moveFileEntry:r=>Ae(t,n("files/move"),it("POST",r)),previewDeleteFileEntry:r=>Ae(t,n("files/delete-preview"),it("POST",r)),deleteFileEntry:r=>Ae(t,n("files/delete"),it("POST",r)),openFileInTerminal:r=>Ae(t,n("files/open"),it("POST",r)),previewFile:r=>yC(t,n("files/preview"),it("POST",r)),uploadComposeAttachments:r=>bC({...r,endpoint:n("attachments")}),getComposeAttachmentLimits:()=>Ae(t,n("attachments/limits")),deleteComposeAttachments:r=>Ae(t,n("attachments/delete"),it("POST",r)),getCodeServerStatus:(r={})=>Ae(t,`${n("code-server/status")}${Ys(r)}`),installCodeServer:()=>Ae(t,n("code-server/install"),{method:"POST",credentials:"same-origin"}),updateCodeServer:()=>Ae(t,n("code-server/update"),{method:"POST",credentials:"same-origin"}),openCodeServer:r=>Ae(t,n("code-server/open"),it("POST",r)),stopCodeServer:(r={})=>Ae(t,n("code-server/stop"),it("POST",r)),uninstallCodeServer:()=>Ae(t,n("code-server/uninstall"),{method:"POST",credentials:"same-origin"}),createWebSocketUrl:(r,o=window.location.href)=>m2(n(`terminals/${encodeURIComponent(r)}/ws`),o)}}function m2(e,t){const n=new URL(t);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.pathname=e,n.search="",n.hash="",n.toString()}function it(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Ys(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.snapshotHistorySize!==void 0&&t.set("snapshotHistorySize",String(e.snapshotHistorySize)),e.snapshotHistoryLimit!==void 0&&t.set("snapshotHistoryLimit",String(e.snapshotHistoryLimit)),e.snapshotHistoryToken!==void 0&&t.set("snapshotHistoryToken",e.snapshotHistoryToken),e.snapshotPaneWidth!==void 0&&t.set("snapshotPaneWidth",String(e.snapshotPaneWidth)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId),e.endpointHash!==void 0&&t.set("endpointHash",e.endpointHash),e.checkLatest!==void 0&&t.set("checkLatest",e.checkLatest?"true":"false");const n=t.toString();return n?`?${n}`:""}async function Ae(e,t,n){const r=await e(t,n??{credentials:"same-origin"});await U_(r);try{return await r.json()}catch{throw new Ln(r.status,"invalid_json_response")}}async function wl(e,t,n){const r=await e(t,n);await U_(r)}async function yC(e,t,n){const r=await e(t,n);return await U_(r),r.blob()}async function U_(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const n=await e.json(),r=typeof n.error=="string"?n.error:n.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new Ln(e.status,t)}const K_="nterminal.theme.id",SC="nterminal.theme.accent",Vg="nterminal:theme",Qh=[{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",...J0({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",...J0({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],jl="midnight";function Tf(e){return Qh.some(t=>t.id===e)?e:jl}function F_(e){return Qh.find(t=>t.id===e)??Qh[0]}function Ia(){if(typeof window>"u")return jl;try{const e=window.localStorage.getItem(K_);return e?Tf(e):y2(window.localStorage.getItem(SC))}catch{return jl}}function g2(e){const t=Tf(e);if(typeof window<"u"){try{window.localStorage.setItem(K_,t)}catch{}W_(t),window.dispatchEvent(new CustomEvent(Vg,{detail:t}))}return t}function W_(e=Ia()){if(typeof document>"u")return;const t=F_(Tf(e)),n=document.documentElement;n.dataset.ntTheme=t.id,n.style.setProperty("color-scheme",t.mode),ft(n,"--nt-bg",t.tokens.bg),ft(n,"--nt-bg-2",t.tokens.bg2),ft(n,"--nt-bg-sidebar",t.tokens.bgSidebar),ft(n,"--nt-line",t.tokens.line),ft(n,"--nt-line-2",t.tokens.line2),ft(n,"--nt-fg",t.tokens.fg),ft(n,"--nt-fg-2",t.tokens.fg2),ft(n,"--nt-fg-3",t.tokens.fg3),ft(n,"--nt-fg-4",t.tokens.fg4),ft(n,"--nt-accent",t.tokens.accent),ft(n,"--nt-accent-soft",t.tokens.accentSoft),ft(n,"--nt-accent-glow",t.tokens.accentGlow),ft(n,"--nt-on-accent",t.tokens.onAccent),ft(n,"--nt-ok",t.tokens.ok),ft(n,"--nt-danger",t.tokens.danger),ft(n,"--nt-on-danger",t.tokens.onDanger),ft(n,"--nt-danger-soft",t.tokens.dangerSoft),ft(n,"--nt-danger-line",t.tokens.dangerLine),ft(n,"--nt-warning",t.tokens.warning),ft(n,"--nt-warn",t.tokens.warning),ft(n,"--nt-warning-soft",t.tokens.warningSoft),ft(n,"--nt-warning-glow",t.tokens.warningGlow),ft(n,"--nt-scrim",t.tokens.scrim),ft(n,"--nt-scrim-soft",t.tokens.scrimSoft),ft(n,"--nt-shadow",t.tokens.shadow),ft(n,"--nt-shadow-strong",t.tokens.shadowStrong),ft(n,"--nt-floating-bg",t.tokens.floatingBg),ft(n,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),ft(n,"--nt-floating-bg-hover",t.tokens.floatingBgHover),ft(n,"--nt-subtle-fill",t.tokens.subtleFill),ft(n,"--nt-hover-fill",t.tokens.hoverFill),ft(n,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),ft(n,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),ft(n,"--nt-transcript-user",t.tokens.transcriptUser),ft(n,"--nt-transcript-assistant",t.tokens.transcriptAssistant),ft(n,"--nt-transcript-tool",t.tokens.transcriptTool),ft(n,"--nt-transcript-command",t.tokens.transcriptCommand),ft(n,"--nt-transcript-code",t.tokens.transcriptCode),ft(n,"--nt-transcript-search",t.tokens.transcriptSearch),ft(n,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),ft(n,"--nt-qr-bg",t.tokens.qrBg)}function v2(e=Ia()){return F_(Tf(e)).xterm}function $_(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===K_||n.key===SC)&&(W_(Ia()),e())};return window.addEventListener(Vg,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Vg,e),window.removeEventListener("storage",t)}}function ft(e,t,n){e.style.setProperty(t,n)}function J0(e){const t=_2(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 _2(e){const t=[];for(let n=16;n<=e;n+=1)t.push(b2(n));return t}function b2(e){if(e>=16&&e<=231){const t=e-16,n=[0,95,135,175,215,255],r=n[Math.floor(t/36)%6],o=n[Math.floor(t/6)%6],c=n[t%6];return ew(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return ew(t,t,t)}return"#000000"}function ew(e,t,n){return`#${Jm(e)}${Jm(t)}${Jm(n)}`}function Jm(e){return e.toString(16).padStart(2,"0")}function y2(e){return e==="signal-red"?"signal-red":jl}function wC(){const e=v.useSyncExternalStore($_,Ia,()=>jl);return F_(e).mode==="light"?"-light":""}function CC({size:e=22}){const t=wC();return f.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function xC({height:e=18}){const t=wC(),n=Math.round(243/34*e);return f.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:n,height:e,alt:"NTerminal"})}var iu=_C();const Ef=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Kl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function q_(e){return"nodeType"in e}function On(e){var t,n;return e?Kl(e)?e:q_(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function V_(e){const{Document:t}=On(e);return e instanceof t}function $u(e){return Kl(e)?!1:e instanceof On(e).HTMLElement}function kC(e){return e instanceof On(e).SVGElement}function Fl(e){return e?Kl(e)?e.document:q_(e)?V_(e)?e:$u(e)||kC(e)?e.ownerDocument:document:document:document}const za=Ef?v.useLayoutEffect:v.useEffect;function Y_(e){const t=v.useRef(e);return za(()=>{t.current=e}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function S2(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ku(e,t){t===void 0&&(t=[e]);const n=v.useRef(e);return za(()=>{n.current!==e&&(n.current=e)},t),n}function qu(e,t){const n=v.useRef();return v.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Jh(e){const t=Y_(e),n=v.useRef(null),r=v.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Yg(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let eg={};function Df(e,t){return v.useMemo(()=>{if(t)return t;const n=eg[e]==null?0:eg[e]+1;return eg[e]=n,e+"-"+n},[e,t])}function TC(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((c,u)=>{const m=Object.entries(u);for(const[g,p]of m){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const Nl=TC(1),ef=TC(-1);function w2(e){return"clientX"in e&&"clientY"in e}function EC(e){if(!e)return!1;const{KeyboardEvent:t}=On(e.target);return t&&e instanceof t}function C2(e){if(!e)return!1;const{TouchEvent:t}=On(e.target);return t&&e instanceof t}function Xg(e){if(C2(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 w2(e)?{x:e.clientX,y:e.clientY}:null}const Gg=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[Gg.Translate.toString(e),Gg.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),tw="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function x2(e){return e.matches(tw)?e:e.querySelector(tw)}const k2={display:"none"};function T2(e){let{id:t,value:n}=e;return Ni.createElement("div",{id:t,style:k2},n)}function E2(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ni.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function D2(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const DC=v.createContext(null);function R2(e){const t=v.useContext(DC);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function M2(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(u=>{var m;return(m=u[o])==null?void 0:m.call(u,c)})},[e]),t]}const N2={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
|
-
`},A2={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 L2(e){let{announcements:t=A2,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=N2}=e;const{announce:c,announcement:u}=D2(),m=Df("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),R2(v.useMemo(()=>({onDragStart(b){let{active:C}=b;c(t.onDragStart({active:C}))},onDragMove(b){let{active:C,over:k}=b;t.onDragMove&&c(t.onDragMove({active:C,over:k}))},onDragOver(b){let{active:C,over:k}=b;c(t.onDragOver({active:C,over:k}))},onDragEnd(b){let{active:C,over:k}=b;c(t.onDragEnd({active:C,over:k}))},onDragCancel(b){let{active:C,over:k}=b;c(t.onDragCancel({active:C,over:k}))}}),[c,t])),!g)return null;const y=Ni.createElement(Ni.Fragment,null,Ni.createElement(T2,{id:r,value:o.draggable}),Ni.createElement(E2,{id:m,announcement:u}));return n?iu.createPortal(y,n):y}var zi;(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"})(zi||(zi={}));function tf(){}function iw(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function O2(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Ts=Object.freeze({x:0,y:0});function B2(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function j2(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function I2(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),u=o-r,m=c-n;if(r<o&&n<c){const g=t.width*t.height,p=e.width*e.height,y=u*m,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const z2=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const c of r){const{id:u}=c,m=n.get(u);if(m){const g=I2(m,t);g>0&&o.push({id:u,data:{droppableContainer:c,value:g}})}}return o.sort(B2)};function P2(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function RC(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ts}function H2(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((u,m)=>({...u,top:u.top+e*m.y,bottom:u.bottom+e*m.y,left:u.left+e*m.x,right:u.right+e*m.x}),{...n})}}const U2=H2(1);function K2(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 F2(e,t,n){const r=K2(t);if(!r)return e;const{scaleX:o,scaleY:c,x:u,y:m}=r,g=e.left-u-(1-o)*parseFloat(n),p=e.top-m-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:p,right:g+y,bottom:p+b,left:g}}const W2={ignoreTransform:!1};function Vu(e,t){t===void 0&&(t=W2);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=On(e).getComputedStyle(e);p&&(n=F2(n,p,y))}const{top:r,left:o,width:c,height:u,bottom:m,right:g}=n;return{top:r,left:o,width:c,height:u,bottom:m,right:g}}function nw(e){return Vu(e,{ignoreTransform:!0})}function $2(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function q2(e,t){return t===void 0&&(t=On(e).getComputedStyle(e)),t.position==="fixed"}function V2(e,t){t===void 0&&(t=On(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function X_(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(V_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!$u(o)||kC(o)||n.includes(o))return n;const c=On(e).getComputedStyle(o);return o!==e&&V2(o,c)&&n.push(o),q2(o,c)?n:r(o.parentNode)}return e?r(e):n}function MC(e){const[t]=X_(e,1);return t??null}function tg(e){return!Ef||!e?null:Kl(e)?e:q_(e)?V_(e)||e===Fl(e).scrollingElement?window:$u(e)?e:null:null}function NC(e){return Kl(e)?e.scrollX:e.scrollLeft}function AC(e){return Kl(e)?e.scrollY:e.scrollTop}function Zg(e){return{x:NC(e),y:AC(e)}}var Vi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vi||(Vi={}));function LC(e){return!Ef||!e?!1:e===document.scrollingElement}function OC(e){const t={x:0,y:0},n=LC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,u=e.scrollTop>=r.y,m=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:u,isRight:m,maxScroll:r,minScroll:t}}const Y2={x:.2,y:.2};function X2(e,t,n,r,o){let{top:c,left:u,right:m,bottom:g}=n;r===void 0&&(r=10),o===void 0&&(o=Y2);const{isTop:p,isBottom:y,isLeft:b,isRight:C}=OC(e),k={x:0,y:0},S={x:0,y:0},D={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+D.height?(k.y=Vi.Backward,S.y=r*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(k.y=Vi.Forward,S.y=r*Math.abs((t.bottom-D.height-g)/D.height)),!C&&m>=t.right-D.width?(k.x=Vi.Forward,S.x=r*Math.abs((t.right-D.width-m)/D.width)):!b&&u<=t.left+D.width&&(k.x=Vi.Backward,S.x=r*Math.abs((t.left+D.width-u)/D.width)),{direction:k,speed:S}}function G2(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function BC(e){return e.reduce((t,n)=>Nl(t,Zg(n)),Ts)}function Z2(e){return e.reduce((t,n)=>t+NC(n),0)}function Q2(e){return e.reduce((t,n)=>t+AC(n),0)}function J2(e,t){if(t===void 0&&(t=Vu),!e)return;const{top:n,left:r,bottom:o,right:c}=t(e);MC(e)&&(o<=0||c<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const eD=[["x",["left","right"],Z2],["y",["top","bottom"],Q2]];class G_{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=X_(n),o=BC(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,u,m]of eD)for(const g of u)Object.defineProperty(this,g,{get:()=>{const p=m(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function tD(e){const{EventTarget:t}=On(e);return e instanceof t?e:Fl(e)}function ig(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var ls;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ls||(ls={}));function sw(e){e.preventDefault()}function iD(e){e.stopPropagation()}var Yt;(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"})(Yt||(Yt={}));const jC={start:[Yt.Space,Yt.Enter],cancel:[Yt.Esc],end:[Yt.Space,Yt.Enter,Yt.Tab]},nD=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Yt.Right:return{...n,x:n.x+25};case Yt.Left:return{...n,x:n.x-25};case Yt.Down:return{...n,y:n.y+25};case Yt.Up:return{...n,y:n.y-25}}};class IC{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 fu(Fl(n)),this.windowListeners=new fu(On(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ls.Resize,this.handleCancel),this.windowListeners.add(ls.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ls.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&J2(r),n(Ts)}handleKeyDown(t){if(EC(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:c=jC,coordinateGetter:u=nD,scrollBehavior:m="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,y=p?{x:p.left,y:p.top}:Ts;this.referenceCoordinates||(this.referenceCoordinates=y);const b=u(t,{active:n,context:r.current,currentCoordinates:y});if(b){const C=ef(b,y),k={x:0,y:0},{scrollableAncestors:S}=r.current;for(const D of S){const B=t.code,{isTop:A,isRight:H,isLeft:Y,isBottom:$,maxScroll:se,minScroll:J}=OC(D),W=G2(D),xe={x:Math.min(B===Yt.Right?W.right-W.width/2:W.right,Math.max(B===Yt.Right?W.left:W.left+W.width/2,b.x)),y:Math.min(B===Yt.Down?W.bottom-W.height/2:W.bottom,Math.max(B===Yt.Down?W.top:W.top+W.height/2,b.y))},re=B===Yt.Right&&!H||B===Yt.Left&&!Y,Ee=B===Yt.Down&&!$||B===Yt.Up&&!A;if(re&&xe.x!==b.x){const ie=D.scrollLeft+C.x,V=B===Yt.Right&&ie<=se.x||B===Yt.Left&&ie>=J.x;if(V&&!C.y){D.scrollTo({left:ie,behavior:m});return}V?k.x=D.scrollLeft-ie:k.x=B===Yt.Right?D.scrollLeft-se.x:D.scrollLeft-J.x,k.x&&D.scrollBy({left:-k.x,behavior:m});break}else if(Ee&&xe.y!==b.y){const ie=D.scrollTop+C.y,V=B===Yt.Down&&ie<=se.y||B===Yt.Up&&ie>=J.y;if(V&&!C.x){D.scrollTo({top:ie,behavior:m});return}V?k.y=D.scrollTop-ie:k.y=B===Yt.Down?D.scrollTop-se.y:D.scrollTop-J.y,k.y&&D.scrollBy({top:-k.y,behavior:m});break}}this.handleMove(t,Nl(ef(b,this.referenceCoordinates),k))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}IC.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=jC,onActivation:o}=t,{active:c}=n;const{code:u}=e.nativeEvent;if(r.start.includes(u)){const m=c.activatorNode.current;return m&&e.target!==m?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function rw(e){return!!(e&&"distance"in e)}function aw(e){return!!(e&&"delay"in e)}class Z_{constructor(t,n,r){var o;r===void 0&&(r=tD(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:u}=c;this.props=t,this.events=n,this.document=Fl(u),this.documentListeners=new fu(this.document),this.listeners=new fu(r),this.windowListeners=new fu(On(u)),this.initialCoordinates=(o=Xg(c))!=null?o:Ts,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(ls.Resize,this.handleCancel),this.windowListeners.add(ls.DragStart,sw),this.windowListeners.add(ls.VisibilityChange,this.handleCancel),this.windowListeners.add(ls.ContextMenu,sw),this.documentListeners.add(ls.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(aw(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(rw(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ls.Click,iD,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ls.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:u,options:{activationConstraint:m}}=c;if(!o)return;const g=(n=Xg(t))!=null?n:Ts,p=ef(o,g);if(!r&&m){if(rw(m)){if(m.tolerance!=null&&ig(p,m.tolerance))return this.handleCancel();if(ig(p,m.distance))return this.handleStart()}if(aw(m)&&ig(p,m.tolerance))return this.handleCancel();this.handlePending(m,p);return}t.cancelable&&t.preventDefault(),u(g)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Yt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const sD={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zC extends Z_{constructor(t){const{event:n}=t,r=Fl(n.target);super(t,sD,r)}}zC.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const rD={move:{name:"mousemove"},end:{name:"mouseup"}};var Qg;(function(e){e[e.RightClick=2]="RightClick"})(Qg||(Qg={}));class PC extends Z_{constructor(t){super(t,rD,Fl(t.event.target))}}PC.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Qg.RightClick?!1:(r?.({event:n}),!0)}}];const ng={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class HC extends Z_{constructor(t){super(t,ng)}static setup(){return window.addEventListener(ng.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ng.move.name,t)};function t(){}}}HC.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var pu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(pu||(pu={}));var nf;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(nf||(nf={}));function aD(e){let{acceleration:t,activator:n=pu.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:u=5,order:m=nf.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:C}=e;const k=lD({delta:b,disabled:!c}),[S,D]=S2(),B=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),H=v.useMemo(()=>{switch(n){case pu.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case pu.DraggableRect:return o}},[n,o,g]),Y=v.useRef(null),$=v.useCallback(()=>{const J=Y.current;if(!J)return;const W=B.current.x*A.current.x,xe=B.current.y*A.current.y;J.scrollBy(W,xe)},[]),se=v.useMemo(()=>m===nf.TreeOrder?[...p].reverse():p,[m,p]);v.useEffect(()=>{if(!c||!p.length||!H){D();return}for(const J of se){if(r?.(J)===!1)continue;const W=p.indexOf(J),xe=y[W];if(!xe)continue;const{direction:re,speed:Ee}=X2(J,xe,H,t,C);for(const ie of["x","y"])k[ie][re[ie]]||(Ee[ie]=0,re[ie]=0);if(Ee.x>0||Ee.y>0){D(),Y.current=J,S($,u),B.current=Ee,A.current=re;return}}B.current={x:0,y:0},A.current={x:0,y:0},D()},[t,$,r,D,c,u,JSON.stringify(H),JSON.stringify(k),S,p,se,y,JSON.stringify(C)])}const oD={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function lD(e){let{delta:t,disabled:n}=e;const r=Yg(t);return qu(o=>{if(n||!r||!o)return oD;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Vi.Backward]:o.x[Vi.Backward]||c.x===-1,[Vi.Forward]:o.x[Vi.Forward]||c.x===1},y:{[Vi.Backward]:o.y[Vi.Backward]||c.y===-1,[Vi.Forward]:o.y[Vi.Forward]||c.y===1}}},[n,t,r])}function cD(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return qu(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function uD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,c=o.activators.map(u=>({eventName:u.eventName,handler:t(u.handler,r)}));return[...n,...c]},[]),[e,t])}var Tu;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Tu||(Tu={}));var Jg;(function(e){e.Optimized="optimized"})(Jg||(Jg={}));const ow=new Map;function dD(e,t){let{dragging:n,dependencies:r,config:o}=t;const[c,u]=v.useState(null),{frequency:m,measure:g,strategy:p}=o,y=v.useRef(e),b=B(),C=ku(b),k=v.useCallback(function(A){A===void 0&&(A=[]),!C.current&&u(H=>H===null?A:H.concat(A.filter(Y=>!H.includes(Y))))},[C]),S=v.useRef(null),D=qu(A=>{if(b&&!n)return ow;if(!A||A===ow||y.current!==e||c!=null){const H=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){H.set(Y.id,Y.rect.current);continue}const $=Y.node.current,se=$?new G_(g($),$):null;Y.rect.current=se,se&&H.set(Y.id,se)}return H}return A},[e,c,n,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||k()},[n,b]),v.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof m!="number"||S.current!==null||(S.current=setTimeout(()=>{k(),S.current=null},m))},[m,b,k,...r]),{droppableRects:D,measureDroppableContainers:k,measuringScheduled:c!=null};function B(){switch(p){case Tu.Always:return!1;case Tu.BeforeDragging:return n;default:return!n}}}function UC(e,t){return qu(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function hD(e,t){return UC(e,t)}function fD(e){let{callback:t,disabled:n}=e;const r=Y_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function Rf(e){let{callback:t,disabled:n}=e;const r=Y_(t),o=v.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[n]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function pD(e){return new G_(Vu(e),e)}function lw(e,t,n){t===void 0&&(t=pD);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??n)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const u=fD({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),m=Rf({callback:c});return za(()=>{c(),e?(m?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(m?.disconnect(),u?.disconnect())},[e]),r}function mD(e){const t=UC(e);return RC(e,t)}const cw=[];function gD(e){const t=v.useRef(e),n=qu(r=>e?r&&r!==cw&&e&&t.current&&e.parentNode===t.current.parentNode?r:X_(e):cw,[e]);return v.useEffect(()=>{t.current=e},[e]),n}function vD(e){const[t,n]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const u=tg(c.target);u&&n(m=>m?(m.set(u,Zg(u)),new Map(m)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){u(c);const m=e.map(g=>{const p=tg(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,Zg(p)]):null}).filter(g=>g!=null);n(m.length?new Map(m):null),r.current=e}return()=>{u(e),u(c)};function u(m){m.forEach(g=>{const p=tg(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,u)=>Nl(c,u),Ts):BC(e):Ts,[e,t])}function uw(e,t){t===void 0&&(t=[]);const n=v.useRef(null);return v.useEffect(()=>{n.current=null},t),v.useEffect(()=>{const r=e!==Ts;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ef(e,n.current):Ts}function _D(e){v.useEffect(()=>{if(!Ef)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function bD(e,t){return v.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:c}=r;return n[o]=u=>{c(u,t)},n},{}),[e,t])}function KC(e){return v.useMemo(()=>e?$2(e):null,[e])}const dw=[];function yD(e,t){t===void 0&&(t=Vu);const[n]=e,r=KC(n?On(n):null),[o,c]=v.useState(dw);function u(){c(()=>e.length?e.map(g=>LC(g)?r:new G_(t(g),g)):dw)}const m=Rf({callback:u});return za(()=>{m?.disconnect(),u(),e.forEach(g=>m?.observe(g))},[e]),o}function SD(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return $u(t)?t:e}function wD(e){let{measure:t}=e;const[n,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if($u(y)){r(b=>{const C=t(y);return b?{...b,width:C.width,height:C.height}:C});break}},[t]),c=Rf({callback:o}),u=v.useCallback(p=>{const y=SD(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[m,g]=Jh(u);return v.useMemo(()=>({nodeRef:m,rect:n,setRef:g}),[n,m,g])}const CD=[{sensor:zC,options:{}},{sensor:IC,options:{}}],xD={current:{}},Bh={draggable:{measure:nw},droppable:{measure:nw,strategy:Tu.WhileDragging,frequency:Jg.Optimized},dragOverlay:{measure:Vu}};class mu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const kD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:tf},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bh,measureDroppableContainers:tf,windowRect:null,measuringScheduled:!1},TD={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:tf,draggableNodes:new Map,over:null,measureDroppableContainers:tf},Mf=v.createContext(TD),ED=v.createContext(kD);function DD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mu}}}function RD(e,t){switch(t.type){case zi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case zi.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 zi.DragEnd:case zi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case zi.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new mu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case zi.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||r!==c.key)return e;const u=new mu(e.droppable.containers);return u.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:u}}}case zi.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const c=new mu(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function MD(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=v.useContext(Mf),c=Yg(r),u=Yg(n?.id);return v.useEffect(()=>{if(!t&&!r&&c&&u!=null){if(!EC(c)||document.activeElement===c.target)return;const m=o.get(u);if(!m)return;const{activatorNode:g,node:p}=m;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=x2(y);if(b){b.focus();break}}})}},[r,t,o,u,c]),null}function ND(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),n):n}function AD(e){return v.useMemo(()=>({draggable:{...Bh.draggable,...e?.draggable},droppable:{...Bh.droppable,...e?.droppable},dragOverlay:{...Bh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function LD(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:u,y:m}=typeof o=="boolean"?{x:o,y:o}:o;za(()=>{if(!u&&!m||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=n(p),b=RC(y,r);if(u||(b.x=0),m||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const C=MC(p);C&&C.scrollBy({top:b.y,left:b.x})}},[t,u,m,r,n])}const FC=v.createContext({...Ts,scaleX:1,scaleY:1});var Da;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Da||(Da={}));const OD=v.memo(function(t){var n,r,o,c;let{id:u,accessibility:m,autoScroll:g=!0,children:p,sensors:y=CD,collisionDetection:b=z2,measuring:C,modifiers:k,...S}=t;const D=v.useReducer(RD,void 0,DD),[B,A]=D,[H,Y]=M2(),[$,se]=v.useState(Da.Uninitialized),J=$===Da.Initialized,{draggable:{active:W,nodes:xe,translate:re},droppable:{containers:Ee}}=B,ie=W!=null?xe.get(W):null,V=v.useRef({initial:null,translated:null}),X=v.useMemo(()=>{var tt;return W!=null?{id:W,data:(tt=ie?.data)!=null?tt:xD,rect:V}:null},[W,ie]),F=v.useRef(null),[le,O]=v.useState(null),[M,j]=v.useState(null),ae=ku(S,Object.values(S)),we=Df("DndDescribedBy",u),N=v.useMemo(()=>Ee.getEnabled(),[Ee]),U=AD(C),{droppableRects:ue,measureDroppableContainers:Ce,measuringScheduled:Oe}=dD(N,{dragging:J,dependencies:[re.x,re.y],config:U.droppable}),De=cD(xe,W),Be=v.useMemo(()=>M?Xg(M):null,[M]),Ne=st(),Ue=hD(De,U.draggable.measure);LD({activeNode:W!=null?xe.get(W):null,config:Ne.layoutShiftCompensation,initialRect:Ue,measure:U.draggable.measure});const Fe=lw(De,U.draggable.measure,Ue),ne=lw(De?De.parentElement:null),me=v.useRef({activatorEvent:null,active:null,activeNode:De,collisionRect:null,collisions:null,droppableRects:ue,draggableNodes:xe,draggingNode:null,draggingNodeRect:null,droppableContainers:Ee,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),R=Ee.getNodeFor((n=me.current.over)==null?void 0:n.id),q=wD({measure:U.dragOverlay.measure}),fe=(r=q.nodeRef.current)!=null?r:De,ge=J?(o=q.rect)!=null?o:Fe:null,Q=!!(q.nodeRef.current&&q.rect),ke=mD(Q?null:Fe),de=KC(fe?On(fe):null),Re=gD(J?R??De:null),Ie=yD(Re),je=ND(k,{transform:{x:re.x-ke.x,y:re.y-ke.y,scaleX:1,scaleY:1},activatorEvent:M,active:X,activeNodeRect:Fe,containerNodeRect:ne,draggingNodeRect:ge,over:me.current.over,overlayNodeRect:q.rect,scrollableAncestors:Re,scrollableAncestorRects:Ie,windowRect:de}),Ye=Be?Nl(Be,re):null,ct=vD(Re),Nt=uw(ct),yt=uw(ct,[Fe]),Tt=Nl(je,Nt),$e=ge?U2(ge,je):null,St=X&&$e?b({active:X,collisionRect:$e,droppableRects:ue,droppableContainers:N,pointerCoordinates:Ye}):null,Lt=j2(St,"id"),[ye,Xe]=v.useState(null),rt=Q?je:Nl(je,yt),Ze=P2(rt,(c=ye?.rect)!=null?c:null,Fe),Et=v.useRef(null),ut=v.useCallback((tt,kt)=>{let{sensor:Xt,options:Ft}=kt;if(F.current==null)return;const ci=xe.get(F.current);if(!ci)return;const Gt=tt.nativeEvent,si=new Xt({active:F.current,activeNode:ci,event:Gt,options:Ft,context:me,onAbort(Wt){if(!xe.get(Wt))return;const{onDragAbort:ei}=ae.current,Hi={id:Wt};ei?.(Hi),H({type:"onDragAbort",event:Hi})},onPending(Wt,cn,ei,Hi){if(!xe.get(Wt))return;const{onDragPending:_n}=ae.current,ti={id:Wt,constraint:cn,initialCoordinates:ei,offset:Hi};_n?.(ti),H({type:"onDragPending",event:ti})},onStart(Wt){const cn=F.current;if(cn==null)return;const ei=xe.get(cn);if(!ei)return;const{onDragStart:Hi}=ae.current,vn={activatorEvent:Gt,active:{id:cn,data:ei.data,rect:V}};iu.unstable_batchedUpdates(()=>{Hi?.(vn),se(Da.Initializing),A({type:zi.DragStart,initialCoordinates:Wt,active:cn}),H({type:"onDragStart",event:vn}),O(Et.current),j(Gt)})},onMove(Wt){A({type:zi.DragMove,coordinates:Wt})},onEnd:ui(zi.DragEnd),onCancel:ui(zi.DragCancel)});Et.current=si;function ui(Wt){return async function(){const{active:ei,collisions:Hi,over:vn,scrollAdjustedTranslate:_n}=me.current;let ti=null;if(ei&&_n){const{cancelDrop:Ji}=ae.current;ti={activatorEvent:Gt,active:ei,collisions:Hi,delta:_n,over:vn},Wt===zi.DragEnd&&typeof Ji=="function"&&await Promise.resolve(Ji(ti))&&(Wt=zi.DragCancel)}F.current=null,iu.unstable_batchedUpdates(()=>{A({type:Wt}),se(Da.Uninitialized),Xe(null),O(null),j(null),Et.current=null;const Ji=Wt===zi.DragEnd?"onDragEnd":"onDragCancel";if(ti){const ri=ae.current[Ji];ri?.(ti),H({type:Ji,event:ti})}})}}},[xe]),Tn=v.useCallback((tt,kt)=>(Xt,Ft)=>{const ci=Xt.nativeEvent,Gt=xe.get(Ft);if(F.current!==null||!Gt||ci.dndKit||ci.defaultPrevented)return;const si={active:Gt};tt(Xt,kt.options,si)===!0&&(ci.dndKit={capturedBy:kt.sensor},F.current=Ft,ut(Xt,kt))},[xe,ut]),gi=uD(y,Tn);_D(y),za(()=>{Fe&&$===Da.Initializing&&se(Da.Initialized)},[Fe,$]),v.useEffect(()=>{const{onDragMove:tt}=ae.current,{active:kt,activatorEvent:Xt,collisions:Ft,over:ci}=me.current;if(!kt||!Xt)return;const Gt={active:kt,activatorEvent:Xt,collisions:Ft,delta:{x:Tt.x,y:Tt.y},over:ci};iu.unstable_batchedUpdates(()=>{tt?.(Gt),H({type:"onDragMove",event:Gt})})},[Tt.x,Tt.y]),v.useEffect(()=>{const{active:tt,activatorEvent:kt,collisions:Xt,droppableContainers:Ft,scrollAdjustedTranslate:ci}=me.current;if(!tt||F.current==null||!kt||!ci)return;const{onDragOver:Gt}=ae.current,si=Ft.get(Lt),ui=si&&si.rect.current?{id:si.id,rect:si.rect.current,data:si.data,disabled:si.disabled}:null,Wt={active:tt,activatorEvent:kt,collisions:Xt,delta:{x:ci.x,y:ci.y},over:ui};iu.unstable_batchedUpdates(()=>{Xe(ui),Gt?.(Wt),H({type:"onDragOver",event:Wt})})},[Lt]),za(()=>{me.current={activatorEvent:M,active:X,activeNode:De,collisionRect:$e,collisions:St,droppableRects:ue,draggableNodes:xe,draggingNode:fe,draggingNodeRect:ge,droppableContainers:Ee,over:ye,scrollableAncestors:Re,scrollAdjustedTranslate:Tt},V.current={initial:ge,translated:$e}},[X,De,St,$e,xe,fe,ge,ue,Ee,ye,Re,Tt]),aD({...Ne,delta:re,draggingRect:$e,pointerCoordinates:Ye,scrollableAncestors:Re,scrollableAncestorRects:Ie});const ee=v.useMemo(()=>({active:X,activeNode:De,activeNodeRect:Fe,activatorEvent:M,collisions:St,containerNodeRect:ne,dragOverlay:q,draggableNodes:xe,droppableContainers:Ee,droppableRects:ue,over:ye,measureDroppableContainers:Ce,scrollableAncestors:Re,scrollableAncestorRects:Ie,measuringConfiguration:U,measuringScheduled:Oe,windowRect:de}),[X,De,Fe,M,St,ne,q,xe,Ee,ue,ye,Ce,Re,Ie,U,Oe,de]),Pe=v.useMemo(()=>({activatorEvent:M,activators:gi,active:X,activeNodeRect:Fe,ariaDescribedById:{draggable:we},dispatch:A,draggableNodes:xe,over:ye,measureDroppableContainers:Ce}),[M,gi,X,Fe,A,we,xe,ye,Ce]);return Ni.createElement(DC.Provider,{value:Y},Ni.createElement(Mf.Provider,{value:Pe},Ni.createElement(ED.Provider,{value:ee},Ni.createElement(FC.Provider,{value:Ze},p)),Ni.createElement(MD,{disabled:m?.restoreFocus===!1})),Ni.createElement(L2,{...m,hiddenTextDescribedById:we}));function st(){const tt=le?.autoScrollEnabled===!1,kt=typeof g=="object"?g.enabled===!1:g===!1,Xt=J&&!tt&&!kt;return typeof g=="object"?{...g,enabled:Xt}:{enabled:Xt}}}),BD=v.createContext(null),hw="button",jD="Draggable";function WC(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const c=Df(jD),{activators:u,activatorEvent:m,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:C}=v.useContext(Mf),{role:k=hw,roleDescription:S="draggable",tabIndex:D=0}=o??{},B=g?.id===t,A=v.useContext(B?FC:BD),[H,Y]=Jh(),[$,se]=Jh(),J=bD(u,t),W=ku(n);za(()=>(b.set(t,{id:t,key:c,node:H,activatorNode:$,data:W}),()=>{const re=b.get(t);re&&re.key===c&&b.delete(t)}),[b,t]);const xe=v.useMemo(()=>({role:k,tabIndex:D,"aria-disabled":r,"aria-pressed":B&&k===hw?!0:void 0,"aria-roledescription":S,"aria-describedby":y.draggable}),[r,k,D,B,S,y.draggable]);return{active:g,activatorEvent:m,activeNodeRect:p,attributes:xe,isDragging:B,listeners:r?void 0:J,node:H,over:C,setNodeRef:Y,setActivatorNodeRef:se,transform:A}}const ID="Droppable",zD={timeout:25};function Q_(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const c=Df(ID),{active:u,dispatch:m,over:g,measureDroppableContainers:p}=v.useContext(Mf),y=v.useRef({disabled:n}),b=v.useRef(!1),C=v.useRef(null),k=v.useRef(null),{disabled:S,updateMeasurementsFor:D,timeout:B}={...zD,...o},A=ku(D??r),H=v.useCallback(()=>{if(!b.current){b.current=!0;return}k.current!=null&&clearTimeout(k.current),k.current=setTimeout(()=>{p(Array.isArray(A.current)?A.current:[A.current]),k.current=null},B)},[B]),Y=Rf({callback:H,disabled:S||!u}),$=v.useCallback((xe,re)=>{Y&&(re&&(Y.unobserve(re),b.current=!1),xe&&Y.observe(xe))},[Y]),[se,J]=Jh($),W=ku(t);return v.useEffect(()=>{!Y||!se.current||(Y.disconnect(),b.current=!1,Y.observe(se.current))},[se,Y]),v.useEffect(()=>(m({type:zi.RegisterDroppable,element:{id:r,key:c,disabled:n,node:se,rect:C,data:W}}),()=>m({type:zi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{n!==y.current.disabled&&(m({type:zi.SetDroppableDisabled,id:r,key:c,disabled:n}),y.current.disabled=n)},[r,c,n,m]),{active:u,rect:C,isOver:g?.id===r,node:se,over:g,setNodeRef:J}}const PD=128,HD=512,Wl=100,UD="too_many_detached_terminals",KD=64,FD=4096;function $C(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>PD)return null;const n=t.workspaces.map(WD);if(n.some(u=>u===null))return null;const r=n,o=new Set,c=new Set;for(const u of r){if(o.has(u.id))return null;o.add(u.id);for(const m of u.tabs){if(c.has(m.id))return null;c.add(m.id)}}return{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function qC(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(n=>{if(!n||typeof n!="object")return!1;const r=n.detachedTerminalIds;return Array.isArray(r)&&r.length>Wl}):!1}function WD(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>HD)return null;const n=t.tabs.map($D);if(n.some(o=>o===null))return null;const r=XD(t.detachedTerminalIds,Wl);return r===null?null:{id:t.id,title:t.title,defaultCwd:YD(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:n}}function $D(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=qD(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function qD(e){if(!e||typeof e!="object")return null;let t=0;return ev(e,1,()=>(t+=1,t<=FD))}function ev(e,t,n){if(!e||typeof e!="object"||t>KD||!n())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=ev(r.first,t+1,n),c=ev(r.second,t+1,n);return!o||!c?null:{type:"split",direction:r.direction,ratio:VD(r.ratio),first:o,second:c}}function VD(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function YD(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function XD(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const n=new Set,r=[];for(const o of e)typeof o!="string"||!o||n.has(o)||(n.add(o),r.push(o));return r}const VC=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],GD="nterminal-focus",ZD=/^[A-Za-z0-9_.:-]{1,128}$/;function QD(e){if(!e.startsWith("#"))return null;const t=new URLSearchParams(e.slice(1));return t.get(GD)!=="terminal"?null:Nf({kind:"terminal",agentId:t.get("agentId"),terminalId:t.get("terminalId")})}function Nf(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="terminal"||!fw(t.terminalId))return null;const n=t.agentId===null||t.agentId===void 0||t.agentId===""?null:t.agentId;return n!==null&&!fw(n)?null:{kind:"terminal",agentId:n,terminalId:t.terminalId}}function fw(e){return typeof e=="string"&&ZD.test(e)}const Yi="__main__",YC=128,JD=600*1e3,XC="nterminal.clientDiagnostics.v1",GC="nterminal.terminalDiagnosticsCursor.v1",Af=150,eR=24,tR=160,iR=48*1024,nR="terminal-connection-recovery";let pw=!1,Wc=null,$c=null,sg=0;function sR(){pw||typeof window>"u"||(pw=!0,gn("page.load",{navigation:SR(),visibility:document.visibilityState,online:navigator.onLine,viewport:tx(),standalone:yR()}),document.addEventListener("visibilitychange",()=>{gn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{gn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{gn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>gn("network.online")),window.addEventListener("offline",()=>gn("network.offline")),window.addEventListener("focus",()=>gn("window.focus")),window.addEventListener("blur",()=>gn("window.blur")),window.addEventListener("error",e=>{gn("runtime.error",{message:e.message,source:wR(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{gn("runtime.unhandledrejection",{reason:CR(e.reason)})}))}function gn(e,t={}){const n={id:fR(),at:new Date().toISOString(),event:Eu(e,80),data:ex({...t,visibility:t.visibility??_R(),online:t.online??bR(),viewport:t.viewport??tx()})},r=J_();return r.push(n),dR(r.slice(-Af)),n}function J_(){try{const e=window.localStorage.getItem(XC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(hR).filter(n=>n!==null).slice(-Af):[]}catch{return[]}}async function eb(e,t=fetch){if(Wc)return Wc;const n=J_(),r={reason:Eu(e,80),events:n},o=JSON.stringify(r);Wc=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Wc}finally{Wc=null}}function Lf(){return ZC().events.length>0}async function rR(e=fetch){if($c)return $c;$c=aR(e);try{return await $c}finally{$c=null}}async function aR(e){const t=ZC();if(t.events.length===0)return{outcome:"empty"};try{const n=await e("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:!0,body:t.body});return n.ok?(uR(t.events),{outcome:"sent",hasMore:t.hasMore}):n.status===401||n.status===403?{outcome:"auth_blocked"}:{outcome:"retryable"}}catch{return{outcome:"retryable"}}}function ZC(){const e=QC(),t=J_().filter(o=>oR(o)&&cR(o,e)),n=[];let r=mw([]);for(const o of t){const c=[...n,o],u=mw(c);if(lR(u)>iR)break;n.push(o),r=u}return{events:n,body:r,hasMore:n.length<t.length}}function mw(e){return JSON.stringify({reason:nR,events:e})}function oR(e){return e.event.startsWith("terminal.connection.")||e.event.startsWith("terminal.input.")}function lR(e){return new TextEncoder().encode(e).byteLength}function cR(e,t){return t===null||e.at>t.at?!0:e.at===t.at&&!t.boundaryIds.includes(JC(e))}function QC(){try{const e=window.localStorage.getItem(GC);if(!e)return null;if(!e.startsWith("{"))return{at:e.slice(0,40),boundaryIds:[]};const t=JSON.parse(e);return typeof t.at!="string"?null:{at:t.at.slice(0,40),boundaryIds:Array.isArray(t.boundaryIds)?t.boundaryIds.filter(n=>typeof n=="string").slice(-Af):[]}}catch{return null}}function uR(e){const t=e.at(-1);if(!t)return;const n=QC(),r=new Set(n?.at===t.at?n.boundaryIds:[]);for(const c of e)c.at===t.at&&r.add(JC(c));const o={at:t.at.slice(0,40),boundaryIds:Array.from(r).slice(-Af)};try{window.localStorage.setItem(GC,JSON.stringify(o))}catch{}}function dR(e){try{window.localStorage.setItem(XC,JSON.stringify(e))}catch{}}function hR(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{...typeof t.id=="string"?{id:Eu(t.id,128)}:{},at:t.at.slice(0,40),event:Eu(t.event,80),...t.data&&typeof t.data=="object"?{data:ex(t.data)}:{}}}function fR(){return sg=(sg+1)%Number.MAX_SAFE_INTEGER,`${globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}-${sg.toString(36)}`.slice(0,128)}function JC(e){if(e.id)return e.id;let t=2166136261;const n=`${e.at}\0${e.event}\0${JSON.stringify(e.data??{})}`;for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=Math.imul(t,16777619);return`legacy-${(t>>>0).toString(16)}`}function ex(e){const t={};for(const[n,r]of Object.entries(e).slice(0,eR)){const o=Eu(n,64);if(!o||pR(o))continue;const c=mR(r);c!==void 0&&(t[o]=c)}return t}function pR(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function mR(e){if(typeof e=="string")return gR(e,tR);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Eu(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function gR(e,t){return vR(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function vR(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 _R(){return typeof document>"u"?void 0:document.visibilityState}function bR(){return typeof navigator>"u"?void 0:navigator.onLine}function tx(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function yR(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function SR(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function wR(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 CR(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}const ix="nterminal.notifications.completionEnabled",tb="nterminal.notifications.completionToastEnabled",ib="nterminal.notifications.completionToastDurationSeconds",nb="nterminal.notifications.completionToastPersistent",tv="nterminal:completion-toast-display",iv="nterminal:notification-focus",gu=6.5,nv=2,sv=60;function Of(){return typeof window<"u"&&"Notification"in window}function sb(){try{return window.localStorage.getItem(ix)==="true"}catch{return!1}}function gw(e){try{window.localStorage.setItem(ix,e?"true":"false")}catch{}}function ko(){return{enabled:ER(),durationSeconds:TR(),persistUntilDismissed:DR()}}function xR(e){if(typeof window<"u"){try{window.localStorage.setItem(tb,e?"true":"false")}catch{}rb()}return ko()}function vw(e){const t=sx(e);if(typeof window<"u"){try{window.localStorage.setItem(ib,String(t))}catch{}rb()}return ko()}function kR(e){if(typeof window<"u"){try{window.localStorage.setItem(nb,e?"true":"false")}catch{}rb()}return ko()}function nx(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===tb||n.key===ib||n.key===nb)&&e()};return window.addEventListener(tv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(tv,e),window.removeEventListener("storage",t)}}function $l(){return Of()?window.Notification.permission:"unsupported"}function TR(){if(typeof window>"u")return gu;try{const e=window.localStorage.getItem(ib);return e===null?gu:sx(Number(e))}catch{return gu}}function ER(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tb)!=="false"}catch{return!0}}function DR(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(nb)==="true"}catch{return!1}}function sx(e){if(!Number.isFinite(e))return gu;const t=Math.round(e*2)/2;return Math.max(nv,Math.min(sv,t))}function rb(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(tv))}async function rx(){if(!Of())return"unsupported";try{return await window.Notification.requestPermission()}catch{return $l()}}function RR(e){if(!Of()||$l()!=="granted"||!sb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.outcome==="stopped"?"stopped":"finished",n=e.commandName?`${e.commandName} ${t}`:`Command ${t}`,r=Nf({kind:"terminal",agentId:e.agentId,terminalId:e.terminalId});try{const o=new Notification(`NTerminal · ${e.tabTitle}`,{body:n,tag:e.terminalId,icon:"/icons/app-icon-384.png",data:r?{focus:r}:void 0,silent:!0});r&&(o.onclick=()=>{window.focus(),MR(r)})}catch{}}function MR(e){typeof window>"u"||window.dispatchEvent(new CustomEvent(iv,{detail:e}))}const _w="nterminal.push.clientId",NR=2e4,bw=[5e3,3e4,12e4];function Ar(){try{const e=window.localStorage.getItem(_w);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${av()}`;return window.localStorage.setItem(_w,t),t}catch{return`client-${av()}`}}function AR(){return`page-${av()}`}function Bf(){const e=typeof window<"u"&&window.isSecureContext===!0,t=PR(),n=HR(),r=n==="mobile"||n==="tablet",o=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone"&&r;return{supported:o,secure:e,displayMode:t,deviceKind:n,reason:e?t!=="standalone"?"not_standalone":r?o?"supported":"unsupported":"not_mobile":"insecure"}}async function LR(e,t){const n=Bf();if(!n.supported)throw new Error(n.reason);if(($l()==="granted"?"granted":await rx())!=="granted")throw new Error("permission_denied");const o=Ar(),c=await navigator.serviceWorker.register("/sw.js"),u=await e.preparePushNotifications(o),g=await KR(c,u.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:lx(u.publicKey)});await e.subscribePushNotifications({clientId:o,subscription:ox(g),deviceKind:n.deviceKind,displayMode:n.displayMode,label:ax(n.deviceKind),alwaysNotify:t})}async function OR(e){const t=Bf();if(!t.supported||$l()!=="granted")return!1;const n=await navigator.serviceWorker.getRegistration(),r=await n?.pushManager.getSubscription();if(!n||!r)return!1;const o=Ar(),c=await FR(r.endpoint),u=await e.getPushNotificationStatus(o,c);if(u.currentDevice&&u.endpointRegistered===!0&&u.vapidPublicKey&&rv(r,u.vapidPublicKey))return!1;const m=await e.preparePushNotifications(o),g=u.endpointRegistered===!0&&rv(r,m.publicKey);g||await r.unsubscribe();const p=g?r:await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:lx(m.publicKey)});return await e.subscribePushNotifications({clientId:o,subscription:ox(p),deviceKind:t.deviceKind,displayMode:t.displayMode,label:ax(t.deviceKind),alwaysNotify:!1}),!0}function BR(e){let t=!1,n=!1,r=0,o=null;const c=()=>{o!==null&&(window.clearTimeout(o),o=null)},u=y=>{t||n||(n=!0,OR(e).then(b=>{r=0,b&&gn("push.subscription.reconciled",{trigger:y})}).catch(b=>{if(gn("push.subscription.reconcile_failed",{trigger:y,reason:b instanceof Error?b.message:String(b)}),!t&&r<bw.length){const C=bw[r++];o=window.setTimeout(()=>{o=null,u("retry")},C)}}).finally(()=>{n=!1}))},m=y=>{c(),r=0,u(y)},g=()=>m("online"),p=()=>m("pageshow");return window.addEventListener("online",g),window.addEventListener("pageshow",p),u("startup"),()=>{t=!0,c(),window.removeEventListener("online",g),window.removeEventListener("pageshow",p)}}async function jR(e){const t=Ar();let n;try{const o=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();n=o?.endpoint,await o?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...n?{endpoint:n}:{}})}async function IR(e,t){await e.updatePushNotificationDevice({clientId:Ar(),alwaysNotify:t})}function zR(e){if(typeof window>"u")return()=>{};const t=Ar(),n=AR();let r=null,o=!1;const c=(p=!0)=>{const y=Bf();e.updatePushPresence({clientId:t,pageId:n,visibilityState:UR(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:sb()&&$l()==="granted",active:p}).catch(()=>{})},u=()=>{o||r!==null||(r=window.setInterval(()=>c(!0),NR))},m=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",m),window.addEventListener("blur",m),document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",g),c(!0),u(),()=>{o=!0,r!==null&&(window.clearInterval(r),r=null),window.removeEventListener("focus",m),window.removeEventListener("blur",m),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",g),c(!1)}}function PR(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function HR(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function ax(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function UR(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function ox(e){const t=e.toJSON(),n=t.keys?.p256dh,r=t.keys?.auth;if(!t.endpoint||!n||!r)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:n,auth:r}}}async function KR(e,t){const n=await e.pushManager.getSubscription();return n?rv(n,t)?n:(await n.unsubscribe(),null):null}function rv(e,t){const n=e.options.applicationServerKey;return n?cx(n)===t:!0}async function FR(e){const t=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return cx(t)}function lx(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),o=new ArrayBuffer(r.length),c=new Uint8Array(o);for(let u=0;u<r.length;u+=1)c[u]=r.charCodeAt(u);return o}function cx(e){const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function av(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Nr(e,t){const n=[Yi,...t.map(u=>u.id)],r=new Set(n),o=new Set,c=[];for(const u of e??[])!r.has(u)||o.has(u)||(o.add(u),c.push(u));for(const u of n)o.has(u)||c.push(u);return c}function WR(e,t){return Nr(e,t).map(n=>n===Yi?null:n)}function $R(e){return e===void 0?"unknown":e.status==="offline"?"offline":"ok"}function qR(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const yw="Local",VR=3e4,YR=2,XR=6,ux="nterminal.serverList.viewMode.v1";function GR(){try{return window.localStorage.getItem(ux)==="list"?"list":"stats"}catch{return"stats"}}function ZR(e){try{window.localStorage.setItem(ux,e)}catch{}}function QR(e,t){const n=new Map(e.map(r=>[r.id,r]));return Nr(t,e).flatMap(r=>{if(r===Yi)return[{kind:"main",id:Yi}];const o=n.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Sw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function dx(e){return e===void 0?"":e.status==="offline"?"offline":e.value?[`CPU ${us(e.value.cpuPercent)} ${ab(e.value)}`,`MEM ${us(e.value.memoryPercent)} ${Br(e.value.memoryUsedBytes,e.value.memoryTotalBytes)}`,`DISK ${us(e.value.diskPercent)} ${Br(e.value.diskUsedBytes,e.value.diskTotalBytes)}`,`SWAP ${us(e.value.swapPercent)} ${Br(e.value.swapUsedBytes,e.value.swapTotalBytes)}`].join(" · ")+(e.stale?" · last known":""):"stats unavailable"}function ww(e){if(e===void 0||e.status==="offline"||!e.value)return;const t=[`CPU ${us(e.value.cpuPercent)} (${ab(e.value)})`,`RAM ${us(e.value.memoryPercent)} (${Br(e.value.memoryUsedBytes,e.value.memoryTotalBytes)})`,`Disk ${us(e.value.diskPercent)} (${Br(e.value.diskUsedBytes,e.value.diskTotalBytes)})`,`Swap ${us(e.value.swapPercent)} (${Br(e.value.swapUsedBytes,e.value.swapTotalBytes)})`].join(" · ");return e.stale?`Last known resource usage — ${t}`:t}function JR(e,t){const n=dx(t);return`${e}${n?` — ${n}`:""}. Double-click to rename.`}function us(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function ab(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`:`${ov(e.cpuPercent/100*t)}/${t} cores`}function Br(e,t){return!Cw(e)||!Cw(t)?"–/–":eM(e,t)}function eM(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${ov(e/r)}/${ov(t/r)} ${n}`}function ov(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Cw(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function vh(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function tM(e){return[{label:"CPU",percent:us(e.cpuPercent),detail:ab(e),tone:vh(e.cpuPercent)},{label:"MEM",percent:us(e.memoryPercent),detail:Br(e.memoryUsedBytes,e.memoryTotalBytes),tone:vh(e.memoryPercent)},{label:"DISK",percent:us(e.diskPercent),detail:Br(e.diskUsedBytes,e.diskTotalBytes),tone:vh(e.diskPercent)},{label:"SWAP",percent:us(e.swapPercent),detail:Br(e.swapUsedBytes,e.swapTotalBytes),tone:vh(e.swapPercent)}]}function iM({entry:e}){return e?.status==="offline"?f.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0||!e.value?f.jsx("span",{className:"server-list-stats server-list-stats-grid",title:e?.status==="online"?"Server reachable; resource usage unavailable":void 0,"aria-label":e?.status==="online"?"Server reachable; resource usage unavailable":"Resource usage loading",children:["CPU","MEM","DISK","SWAP"].map(t=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t}),f.jsx("span",{className:"server-list-stat-value",children:"–"})]}),f.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):f.jsx("span",{className:`server-list-stats server-list-stats-grid${e.stale?" server-list-stats-grid--stale":""}`,title:ww(e),"aria-label":ww(e),children:tM(e.value).map(t=>f.jsxs("span",{className:"server-list-stat-cell",children:[f.jsxs("span",{className:"server-list-stat-head",children:[f.jsx("span",{className:"server-list-stat-label",children:t.label}),f.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),f.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function xw({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:r,refreshToken:o=0,onServerLabelsChange:c,renderServerChildren:u,compact:m=!1}){const[g,p]=v.useState([]),[y,b]=v.useState([Yi]),[C,k]=v.useState(null),[S,D]=v.useState(null),[B,A]=v.useState(""),H=v.useRef(null),[Y,$]=v.useState(()=>GR()),[se,J]=v.useState(null),[W,xe]=v.useState(null),[re,Ee]=v.useState({}),ie=v.useRef({}),V=v.useRef(0),X=v.useRef([]),F=v.useRef([Yi]),le=v.useRef(null);v.useEffect(()=>{X.current=g},[g]),v.useEffect(()=>{const ne=Nr(y,g);F.current=ne,Sw(ne,y)||b(ne)},[g,y]),v.useEffect(()=>{let ne=!1;return e.listAgents().then(me=>{ne||(p(me.agents),b(Nr(me.serverOrder,me.agents)))}).catch(()=>{}),e.getMainInfo().then(me=>{ne||k(me.name)}).catch(()=>{}),()=>{ne=!0}},[e,o]),v.useEffect(()=>{S&&(H.current?.focus(),H.current?.select())},[S]),v.useEffect(()=>{let ne=!1;function me(){const q=[{key:Yi,load:()=>e.getMainStats(),probe:async()=>(await e.getMainInfo(),!0)},...g.map(ge=>({key:ge.id,load:()=>e.getAgentStats(ge.id),probe:async()=>(await e.pingAgent(ge.id)).ok}))],fe=new Set(q.map(ge=>ge.key));for(const ge of Object.keys(ie.current))fe.has(ge)||delete ie.current[ge];Ee(ge=>{const Q={};for(const ke of fe)ke in ge&&(Q[ke]=ge[ke]);return Q});for(const ge of q)ge.load().then(Q=>{ne||(ie.current[ge.key]=0,Ee(ke=>fe.has(ge.key)?{...ke,[ge.key]:{status:"online",value:Q,stale:!1}}:ke))}).catch(async Q=>{if(ne)return;if(Q instanceof Ln&&Q.status===401&&ge.key===Yi){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}if(ge.key===Yi&&Q instanceof Ln){ie.current[ge.key]=0,Ee(de=>{if(!fe.has(ge.key))return de;const Re=de[ge.key];return{...de,[ge.key]:{status:"online",value:Re?.value??null,stale:!0}}});return}if(ge.probe)try{if(await ge.probe()){if(ne)return;ie.current[ge.key]=0,Ee(de=>{if(!fe.has(ge.key))return de;const Re=de[ge.key];return{...de,[ge.key]:{status:"online",value:Re?.value??null,stale:!0}}});return}}catch(de){if(ne)return;if(de instanceof Ln&&de.status===401){r?.({source:ge.key===Yi?"main-health-401":"agent-health-401",status:401,activeAgentId:null});return}}const ke=(ie.current[ge.key]??0)+1;ie.current[ge.key]=ke,ke>=YR&&Ee(de=>fe.has(ge.key)?{...de,[ge.key]:{status:"offline",value:de[ge.key]?.value??null,stale:!0}}:de)})}me();const R=window.setInterval(me,VR);return()=>{ne=!0,window.clearInterval(R)}},[e,g,r]);function O(ne){ne==="main"?(A(C??""),D({kind:"main"})):(A(ne.name),D({kind:"agent",id:ne.id}))}async function M(){if(!S)return;const ne=B.trim(),me=S;if(D(null),me.kind==="main"){const R=ne||"";try{const q=await e.renameMain(R);k(q.name)}catch{}}else{if(!ne)return;const R=g.find(q=>q.id===me.id)?.name;p(q=>q.map(fe=>fe.id===me.id?{...fe,name:ne}:fe));try{await e.renameAgent(me.id,ne)}catch{R!==void 0&&p(q=>q.map(fe=>fe.id===me.id?{...fe,name:R}:fe))}}}function j(){D(null)}function ae(ne){$(ne),ZR(ne)}function we(ne,me,R){if(ne===me)return;const q=Nr(F.current,X.current),fe=q.findIndex(je=>je===ne),ge=q.findIndex(je=>je===me);if(fe<0||ge<0)return;const Q=[...q],[ke]=Q.splice(fe,1);if(!ke)return;const de=Q.findIndex(je=>je===me);if(de<0)return;const Re=R==="before"?de:de+1;if(Q.splice(Re,0,ke),Sw(Q,q))return;const Ie=V.current+1;V.current=Ie,F.current=Q,b(Q),e.reorderAgents(Q).then(je=>{if(V.current===Ie){X.current=je.agents;const Ye=Nr(je.serverOrder,je.agents);F.current=Ye,p(je.agents),b(Ye)}}).catch(async()=>{if(V.current===Ie)try{const je=await e.listAgents();if(V.current===Ie){X.current=je.agents;const Ye=Nr(je.serverOrder,je.agents);F.current=Ye,p(je.agents),b(Ye)}}catch{V.current===Ie&&(F.current=q,b(q))}})}function N(ne,me){const R=Nr(F.current,X.current),q=R.findIndex(ge=>ge===ne),fe=R[q+me];q<0||!fe||we(ne,fe,me<0?"before":"after")}function U(ne,me){me.pointerType==="mouse"&&me.button!==0||(me.stopPropagation(),le.current={sourceId:ne,pointerId:me.pointerId,startX:me.clientX,startY:me.clientY,active:!1,targetId:null,placement:"after"},me.currentTarget.setPointerCapture?.(me.pointerId))}function ue(ne){const me=le.current;if(!me||me.pointerId!==ne.pointerId)return;const R=Math.hypot(ne.clientX-me.startX,ne.clientY-me.startY);if(!me.active){if(R<XR)return;me.active=!0,J(me.sourceId)}const fe=document.elementFromPoint(ne.clientX,ne.clientY)?.closest("[data-server-id]"),ge=fe?.dataset.serverId??null;if(!fe||!ge||ge===me.sourceId){me.targetId=null,xe(null);return}const Q=fe.getBoundingClientRect(),ke=ne.clientY<Q.top+Q.height/2?"before":"after";me.targetId=ge,me.placement=ke,xe({serverId:ge,placement:ke})}function Ce(ne){const me=le.current;!me||me.pointerId!==ne.pointerId||(ne.stopPropagation(),ne.currentTarget.releasePointerCapture?.(ne.pointerId),le.current=null,J(null),xe(null),me.active&&me.targetId&&we(me.sourceId,me.targetId,me.placement))}function Oe(ne){const me=le.current;me&&me.pointerId===ne.pointerId&&ne.currentTarget.releasePointerCapture?.(ne.pointerId),le.current=null,J(null),xe(null)}const De=C?.trim()||yw,Be=S?.kind==="main",Ne=Y==="stats",Ue=QR(g,y),Fe=Ue.length>1;return v.useEffect(()=>{c?.([{agentId:null,label:De},...g.map(ne=>({agentId:ne.id,label:ne.name}))])},[g,De,c]),m?f.jsx("div",{className:"server-list server-list--compact",children:Ue.map(ne=>{const me=ne.kind==="main",R=me?De:ne.agent.name,q=me?Yi:ne.id,fe=re[q],ge=dx(fe);return f.jsxs("button",{type:"button",className:`server-list-chip${(me?t===null:t===ne.id)?" server-list-chip--active":""}`,onClick:()=>n(me?null:ne.id),"aria-label":`${R}${ge?` — ${ge}`:""}`,title:`${R}${ge?` — ${ge}`:""}`,children:[f.jsx("span",{className:"server-list-chip-initial",children:qR(R)}),f.jsx("span",{className:"server-list-chip-pip","data-status":$R(fe)})]},ne.id)})}):f.jsxs("div",{className:`server-list server-list--${Y}`,children:[f.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="list",onClick:()=>ae("list"),title:"Show server names only",children:"List"}),f.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":Y==="stats",onClick:()=>ae("stats"),title:"Show resource usage",children:"Stats"})]}),Ue.map(ne=>{const me=ne.kind==="main",R=me?De:ne.agent.name,q=me?Yi:ne.id,fe=me?t===null:t===ne.id,ge=me?Be:S?.kind==="agent"&&S.id===ne.id,Q=u?.({agentId:me?null:ne.id,serverId:ne.id,label:R,active:fe}),ke=W?.serverId===ne.id&&se!==ne.id?` server-list-section--drop-target server-list-section--drop-${W.placement}`:"";return f.jsxs("section",{className:`server-list-section${ke}`,"aria-label":`${R} server`,children:[f.jsx("div",{className:["server-list-row",se===ne.id?"server-list-row--dragging":"",W?.serverId===ne.id&&se!==ne.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":ne.id,children:ge?f.jsxs(f.Fragment,{children:[Fe?f.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,f.jsx("form",{className:"server-list-editor",onSubmit:de=>{de.preventDefault(),M()},children:f.jsx("input",{ref:H,"aria-label":me?"Rename main server":`Rename ${R}`,value:B,onChange:de=>A(de.target.value),onBlur:()=>{M()},onKeyDown:de=>{de.key==="Escape"&&(de.preventDefault(),j())},placeholder:me?yw:void 0})})]}):f.jsxs(f.Fragment,{children:[Fe?f.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":ne.id,title:"Drag to reorder","aria-label":`Reorder ${R}`,"aria-grabbed":se===ne.id,onPointerDown:de=>U(ne.id,de),onPointerMove:ue,onPointerUp:Ce,onPointerCancel:Oe,onKeyDown:de=>{(de.key==="ArrowUp"||de.key==="ArrowDown")&&(de.preventDefault(),de.stopPropagation(),N(ne.id,de.key==="ArrowUp"?-1:1))},onClick:de=>de.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:`server-list-item${fe?" server-list-item--active":""}`,onClick:()=>n(me?null:ne.id),onDoubleClick:de=>{de.preventDefault(),O(me?"main":{id:ne.id,name:R})},title:JR(R,re[q]),children:[f.jsxs("span",{className:"server-list-item-header",children:[f.jsx("span",{className:"server-list-dot"}),f.jsx("span",{className:"server-list-name",title:me?void 0:ne.agent.url??"Outbound connection to main",children:R})]}),Ne?f.jsx(iM,{entry:re[q]}):null]})]})}),Q?f.jsx("div",{className:"server-list-children",children:Q}):null]},ne.id)})]})}function nM({api:e}){const[t,n]=v.useState([]),[r,o]=v.useState([]),[c,u]=v.useState(!1),[m,g]=v.useState(null),[p,y]=v.useState(""),[b,C]=v.useState("");async function k(){try{const[A,H,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(A.devices),o(H.networks),u(Y.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{k()},[]);async function S(A){await e.revokeDevice(A),await k()}async function D(A){await e.removeNetwork(A),await k()}async function B(A){A.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),C(""),await k()}catch(H){g(H instanceof Error?H.message:"Failed to add network")}}return f.jsxs(f.Fragment,{children:[m?f.jsx("p",{className:"form-error",children:m}):null,f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted devices"}),f.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?f.jsx("p",{className:"muted",children:"No trusted devices."}):f.jsx("ul",{className:"security-list",children:t.map(A=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[A.label,A.current?f.jsx("span",{className:"security-badge",children:"this device"}):null]}),f.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{S(A.id)},children:"revoke"})]},A.id))})]}),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Trusted networks"}),f.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?f.jsx("p",{className:"muted",children:"No trusted networks."}):f.jsx("ul",{className:"security-list",children:r.map(A=>f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?f.jsx("span",{className:"security-item-meta",children:A.label}):null]}),f.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(A.id)},children:"remove"})]},A.id))}),f.jsxs("form",{className:"security-add-form",onSubmit:B,children:[f.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:A=>y(A.currentTarget.value),required:!0}),f.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>C(A.currentTarget.value)}),f.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Two-factor authentication"}),f.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),f.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await k()},children:"Disable 2FA"})]}):null]})}const sM=1500,ob="nterminal.terminal.fontSize",lb="nterminal.terminal.fontFamily",lv="nterminal:terminal-font-size",cv="nterminal:terminal-font-family",uv=11,dv=20,So=14,sf=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Il="meslo";hv(Il);async function rg(e=So,t=Il){if(typeof document>"u"||!document.fonts)return;const n=px(t).webFontFamilies;if(n.length===0)return;const r=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,sM)})])}function hx(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return So;const n=Math.round(t);return Math.max(uv,Math.min(dv,n))}function fx(e){return sf.some(t=>t.id===e)?e:Il}function hv(e){return px(e).cssFamily}function px(e){return sf.find(t=>t.id===e)??sf[0]}function fv(){if(typeof window>"u")return So;try{const e=window.localStorage.getItem(ob);return e?hx(e):So}catch{return So}}function pv(){if(typeof window>"u")return Il;try{return fx(window.localStorage.getItem(lb))}catch{return Il}}function _h(e){const t=hx(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ob,String(t))}catch{}return window.dispatchEvent(new CustomEvent(lv,{detail:t})),t}function rM(e){const t=fx(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lb,t)}catch{}return window.dispatchEvent(new CustomEvent(cv,{detail:t})),t}function mx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===ob&&e()};return window.addEventListener(lv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(lv,e),window.removeEventListener("storage",t)}}function gx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===lb&&e()};return window.addEventListener(cv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(cv,e),window.removeEventListener("storage",t)}}const cb="nterminal.terminal.showScrollProgress",mv="nterminal:terminal-scroll-progress",ub="nterminal.terminal.tmuxScrollback.shell",db="nterminal.terminal.tmuxScrollback.agent",hb="nterminal.terminal.tmuxScrollback.overrides",Du="nterminal:terminal-tmux-scrollback",aM=200;function gv(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(cb)!=="false"}catch{return!0}}function oM(e){if(typeof window<"u"){try{window.localStorage.setItem(cb,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(mv,{detail:e}))}return e}function vx(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cb&&e()};return window.addEventListener(mv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(mv,e),window.removeEventListener("storage",t)}}function vv(){return _x(ub,!0)}function lM(e){return bx(ub,e,Du)}function _v(){return _x(db,!0)}function cM(e){return bx(db,e,Du)}function jh(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===ub||n.key===db||n.key===hb)&&e()};return window.addEventListener(Du,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Du,e),window.removeEventListener("storage",t)}}function ag(e){const n=yx()[e];return typeof n=="boolean"?n:null}function uM(e,t){if(typeof window<"u"){try{const n=yx(),r=Object.entries(n).filter(([c])=>c!==e);r.push([e,t]);const o=r.slice(-aM);window.localStorage.setItem(hb,JSON.stringify(Object.fromEntries(o)))}catch{}window.dispatchEvent(new CustomEvent(Du,{detail:{terminalId:e,enabled:t}}))}return t}function _x(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 bx(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 yx(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(hb);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}const fb="nterminal.shortcuts.workspace.v1",bv="nterminal:workspace-shortcuts",Ru=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"subagents.toggle",label:"Toggle view agents",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],jf={"server.previous":fi("ArrowUp",{ctrlKey:!0}),"server.next":fi("ArrowDown",{ctrlKey:!0}),"tab.previous":fi("ArrowLeft",{ctrlKey:!0}),"tab.next":fi("ArrowRight",{ctrlKey:!0}),"tab.index":fi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":fi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":fi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":fi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":fi("KeyH",{altKey:!0}),"subagents.toggle":fi("KeyA",{altKey:!0}),"scrollback.toggle":fi("KeyS",{altKey:!0})},dM={"server.previous":fi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":fi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":fi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":fi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":fi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":fi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":fi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":fi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":fi("KeyH",{altKey:!0}),"subagents.toggle":fi("KeyA",{altKey:!0}),"scrollback.toggle":fi("KeyS",{altKey:!0})};function To(){const e=Cx(jf);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(fb);if(!t)return e;const n=JSON.parse(t);for(const r of Ru){const o=n[r.id];if(bM(o)){const c=xx(o,r);_M(c,dM[r.id])||(e[r.id]=c)}}}catch{return e}return e}function kw(){return JSON.stringify(To())}function hM(e,t){const n=To(),r=Ru.find(o=>o.id===e);return r&&(n[e]=xx(t,r),pb(n)),n}function fM(e){const t=To();return t[e]={...jf[e]},pb(t),t}function pM(){const e=Cx(jf);return pb(e),e}function vu(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===fb&&e()};return window.addEventListener(bv,e),window.addEventListener("storage",t),()=>{window.removeEventListener(bv,e),window.removeEventListener("storage",t)}}function mM(e,t){const n=Ex(e);return!n||SM(n)||t.indexed&&Tx(e)===null||t.requiresPrimaryModifier&&!kx(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function Sx(e){const t=To();for(const n of Ru){const r=t[n.id];if(!(!r||!yM(e,r))){if(n.indexed){if(r.code!=="Digit")continue;const o=Tx(e);if(o!==null)return{id:n.id,index:o};continue}if(Ex(e)===r.code)return{id:n.id,index:null}}}return null}function _u(e){return wx(To()[e])}function wx(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(wM(e.code)),t.join("+")}const gM=()=>_u("split.right"),vM=()=>_u("split.down");function fi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Cx(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function _M(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function pb(e){if(!(typeof window>"u")){try{window.localStorage.setItem(fb,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(bv))}}function xx(e,t){return t.requiresPrimaryModifier&&!kx(e)?{...jf[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function kx(e){return e.ctrlKey||e.altKey||e.metaKey}function bM(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 yM(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Tx(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 Ex(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 SM(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function wM(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 CM="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 xM(e="nterminal",t=new Date){return{reason:"permission",message:CM,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function kM(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 Dx=3600*1e3,TM="local",yv=new Set,Aa=new Map;let Pa={checking:!1,hasUpdates:!1,lastCheckedAt:null},mb=null,bu=null,rf=0,Ea=null;function EM(e){return yv.add(e),()=>{yv.delete(e)}}function Tw(){return Pa}function DM(e){const t=LM();mb=e,gb(),Sv(e,t);const n=()=>{if(document.visibilityState!=="visible"||!Ha(e,t))return;const r=Pa.lastCheckedAt;(r===null||Date.now()-r>=Dx)&&Sv(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),Ha(e,t)&&AM()}}function RM(e,t){Aa.set(e,Rx(t)),zl({...Pa,hasUpdates:vb(),lastCheckedAt:Date.now()})}function og(e){e===void 0?Aa.clear():Aa.set(e,!1),zl({...Pa,hasUpdates:vb()})}async function Sv(e,t){if(!Ha(e,t))return;if(Ea&&Ea.api===e&&Ea.runId===t)return Ea.promise;zl({...Pa,checking:!0});const n=MM(e,t).finally(()=>{Ea?.promise===n&&(Ea=null),Ha(e,t)&&(zl({...Pa,checking:!1,lastCheckedAt:Date.now()}),NM(e,t))});return Ea={api:e,runId:t,promise:n},n}async function MM(e,t){try{const n=await e.listAgents();if(!Ha(e,t))return;const r=[{key:TM,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const u=await c.check();o.set(c.key,Rx(u))}catch{o.set(c.key,Aa.get(c.key)??!1)}})),!Ha(e,t))return;Aa.clear();for(const[c,u]of o)Aa.set(c,u);zl({...Pa,hasUpdates:vb()})}catch{}}function NM(e,t){Ha(e,t)&&(gb(),bu=window.setTimeout(()=>{bu=null,Ha(e,t)&&Sv(e,t)},Dx))}function AM(){rf+=1,gb(),mb=null,Ea=null,Aa.clear(),zl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function gb(){bu!==null&&(window.clearTimeout(bu),bu=null)}function LM(){return rf+=1,rf}function Ha(e,t){return mb===e&&rf===t}function Rx(e){return e.updateAvailable===!0}function vb(){return Array.from(Aa.values()).some(Boolean)}function zl(e){Pa=e;for(const t of Array.from(yv))t()}const OM=e=>new Promise(t=>setTimeout(t,e));function BM({api:e,onAgentRemoved:t}){const[n,r]=v.useState([{key:"local",id:null,name:"Local"}]),[o,c]=v.useState({}),[u,m]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[C,k]=v.useState({});function S(M,j){c(ae=>({...ae,[M]:{...ae[M],...j}}))}function D(M,j){k(ae=>({...ae,[M]:{status:ae[M]?.status??null,busy:ae[M]?.busy??!1,error:ae[M]?.error??null,...j}}))}const B=M=>M.id===null?e.getVersion():e.getAgentVersion(M.id),A=M=>M.id===null?e.checkUpdate():e.checkAgentUpdate(M.id),H=M=>M.id===null?e.runUpdate():e.runAgentUpdate(M.id),Y=M=>M.id===null?e:Bl(M.id);v.useEffect(()=>{let M=!1;return e.listAgents().then(async j=>{if(M)return;let ae="Local";try{ae=(await e.getMainInfo()).name?.trim()||ae}catch{}if(M)return;const we=new Map(j.agents.map(U=>[U.id,U])),N=Nr(j.serverOrder,j.agents).flatMap(U=>{if(U===Yi)return[{key:"local",id:null,name:ae}];const ue=we.get(U);return ue?[{key:ue.id,id:ue.id,name:ue.name}]:[]});r(N);for(const U of N)B(U).then(ue=>S(U.key,{version:ue,manualUpdate:ue.manualUpdate??null})).catch(ue=>S(U.key,{error:ue instanceof Error?ue.message:"unreachable"})),F(U)}).catch(()=>{}),()=>{M=!0}},[]);async function $(M){S(M.key,{busy:!0,status:"checking…",error:void 0});try{const j=await A(M);RM(M.key,j),S(M.key,{latestVersion:j.latestVersion,updateAvailable:j.updateAvailable,status:ie(j),...j.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(j){S(M.key,{busy:!1,error:j instanceof Error?j.message:"check failed"})}}async function se(){m(!0),await Promise.all(n.map(M=>$(M))),m(!1)}async function J(M,j){const ae=Date.now()+18e4;for(;Date.now()<ae;){await OM(3e3);try{const we=await B(M);if(j&&we.runningVersion!==j.runningVersion)return we}catch{}}return null}async function W(M){let j=o[M.key]?.version;if(!j)try{j=await B(M),S(M.key,{version:j,manualUpdate:j.manualUpdate??null})}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"version check failed"}),"failed"}S(M.key,{busy:!0,status:"updating…",error:void 0});let ae;try{ae=await H(M)}catch(N){return S(M.key,{busy:!1,error:N instanceof Error?N.message:"update failed"}),"failed"}if(!ae.ok){const N=ae.manualUpdate??(kM(ae.message)?xM():null);return N?(S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:N}),"manual"):(S(M.key,{busy:!1,status:void 0,error:ae.message}),"failed")}if(!ae.changed)return S(M.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),og(M.key),"unchanged";S(M.key,{status:"restarting…"});const we=await J(M,j);return we?(S(M.key,{busy:!1,version:we,updateAvailable:!1,status:"updated",manualUpdate:we.manualUpdate??null}),og(M.key),M.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(S(M.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function xe(M){if(!(M.id===null||!window.confirm([`Delete secondary server "${M.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(M.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const ae=await e.uninstallAgent(M.id);r(we=>we.filter(N=>N.key!==M.key)),c(we=>{const N={...we};return delete N[M.key],N}),og(M.key),t?.(M.id),p(ae.message)}catch(ae){S(M.key,{busy:!1,status:void 0,error:ae instanceof Error?ae.message:"delete failed"})}}}async function re(){m(!0),p(null);const M=n.filter(ue=>ue.id!==null),j=n.find(ue=>ue.id===null),ae=await Promise.all(M.map(ue=>W(ue))),we=ae.filter(ue=>ue==="failed").length;let N=ae.filter(ue=>ue==="manual").length,U=null;if(j&&(U=await W(j),U==="manual"&&(N+=1),U==="updated")){we>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),m(!1);return}we>0&&N>0?p("Some servers failed and some need manual update. Check each marked row."):we>0?p("Some secondary servers failed to update. Check their rows and retry."):N>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),m(!1)}function Ee(M){return M?M.error?M.error:M.status?M.status:M.manualUpdate?"manual update required":M.version?`v${M.version.version}`:"…":"…"}function ie(M){return M.error?M.error:typeof M.updateAvailable=="boolean"?M.updateAvailable?`latest v${M.latestVersion??"available"}`:"up to date":"unknown"}function V(M){const j=M?.version;return j?`npm package v${j.runningVersion}`:""}async function X(M,j){try{await IM(j),S(M,{copiedCommand:!0}),window.setTimeout(()=>S(M,{copiedCommand:!1}),1800)}catch(ae){S(M,{error:ae instanceof Error?ae.message:"copy failed"})}}async function F(M,j=!1){try{const ae=await Y(M).getCodeServerStatus(j?{checkLatest:!0}:void 0);D(M.key,{status:ae,error:null})}catch(ae){D(M.key,{error:ae instanceof Error?ae.message:"code-server status failed"})}}async function le(M,j){if(j==="uninstall"&&!window.confirm(`Uninstall the VS Code add-on on ${M.name} and stop its running VS Code sessions?`))return;const ae=Y(M);D(M.key,{busy:!0,error:null});try{if(j==="install"){const we=await ae.installCodeServer();D(M.key,{status:we.status})}else if(j==="update"){const we=await ae.updateCodeServer();D(M.key,{status:we.status})}else if(j==="stop")D(M.key,{status:await ae.stopCodeServer()});else{const we=await ae.uninstallCodeServer();D(M.key,{status:we.status})}}catch(we){D(M.key,{error:we instanceof Error?we.message:"code-server action failed"})}finally{D(M.key,{busy:!1})}}const O=n.filter(M=>C[M.key]?.status?.job?.status==="running").map(M=>M.key).join("|");return v.useEffect(()=>{const M=n.filter(ae=>C[ae.key]?.status?.job?.status==="running");if(M.length===0)return;const j=window.setInterval(()=>{for(const ae of M)F(ae)},1e3);return()=>window.clearInterval(j)},[O]),f.jsxs("section",{className:"security-section",children:[f.jsx("h3",{children:"Servers"}),f.jsxs("div",{className:"update-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{se()},disabled:u,children:"Check for updates"}),f.jsx("button",{type:"button",onClick:()=>{re()},disabled:u,children:"Update all"})]}),g?f.jsx("p",{className:"settings-status",children:g}):null,y?f.jsxs("div",{className:"server-reload-required",role:"status",children:[f.jsx("span",{children:"Main server update is ready."}),f.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,f.jsx("ul",{className:"security-list",children:n.map(M=>{const j=o[M.key],ae=V(j),we=j?.manualUpdate??null,N=C[M.key]??{status:null,busy:!1,error:null},U=j?.version!==void 0&&j?.updateAvailable!==!1&&!j?.busy&&!u,ue=M.id!==null&&!j?.busy&&!u;return f.jsxs("li",{children:[f.jsxs("div",{className:"server-row-main",children:[f.jsxs("div",{children:[f.jsxs("span",{className:"security-item-label",children:[M.name,M.id===null?f.jsx("span",{className:"security-badge",children:"Main"}):null]}),f.jsxs("span",{className:"security-item-meta",children:[ae?`${ae} — `:"",Ee(j)]})]}),we?f.jsxs("div",{className:"server-manual-update",children:[f.jsx("span",{children:we.message}),f.jsxs("div",{className:"server-manual-command",children:[f.jsx("code",{children:we.command}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{X(M.key,we.command)},children:j?.copiedCommand?"Copied":"Copy"})]})]}):null,f.jsx(jM,{status:N.status,busy:N.busy,error:N.error,onCheck:()=>{F(M,!0)},onInstall:()=>{le(M,"install")},onUpdate:()=>{le(M,"update")},onStop:()=>{le(M,"stop")},onUninstall:()=>{le(M,"uninstall")}})]}),f.jsxs("div",{className:"server-row-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{W(M)},disabled:!U,children:j?.busy?"…":"Update"}),M.id!==null?f.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{xe(M)},disabled:!ue,children:"Delete"}):null]})]},M.key)})})]})}function jM({status:e,busy:t,error:n,onCheck:r,onInstall:o,onUpdate:c,onStop:u,onUninstall:m}){const g=e?.job??null,p=g?.status==="running",y=e!==null,b=e?.installed===!0,C=(e?.instances.length??0)>0,k=e?.supported!==!1,S=e===null&&!n;return f.jsxs("div",{className:"server-code-addon",children:[f.jsxs("div",{children:[f.jsx("span",{className:"security-item-label",children:"VS Code add-on"}),f.jsxs("span",{className:"security-item-meta",children:[k?S?"checking...":b?`code-server v${e?.version??"unknown"}${C?` — ${e?.instances.length} running`:""}`:"not installed":e?.unsupportedReason??"unsupported",e?.updateAvailable?" — update available":""]})]}),n?f.jsx("p",{className:"settings-error",children:n}):null,g?f.jsx("pre",{className:"server-code-addon-log",children:g.logs.length>0?g.logs.slice(-8).join(`
|
|
16
|
-
`):`${g.action} ${g.status}`}):null,f.jsxs("div",{className:"server-code-addon-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:t||p||!k,children:"Check"}),b?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:c,disabled:t||p||!k,children:e?.updateAvailable?"Update code-server":"Reinstall"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!C,children:"Stop"}),f.jsx("button",{type:"button",className:"server-delete-button",onClick:m,disabled:t||p,children:"Uninstall"})]}):f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:!y||S||t||p||!k,children:"Install code-server"})]})]})}async function IM(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 bh=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function zM({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??kf(),[t]),[u,m]=v.useState(()=>fv()),[g,p]=v.useState(()=>pv()),[y,b]=v.useState(()=>gv()),[C,k]=v.useState(()=>vv()),[S,D]=v.useState(()=>_v()),[B,A]=v.useState(()=>Ia()),[H,Y]=v.useState(()=>To()),[$,se]=v.useState(null),[J,W]=v.useState(null),[xe,re]=v.useState("appearance"),[Ee,ie]=v.useState(()=>sb()),[V,X]=v.useState(()=>ko()),[F,le]=v.useState(()=>$l()),[O,M]=v.useState([]),[j,ae]=v.useState([]),[we,N]=v.useState([]),[U,ue]=v.useState(5*1024*1024),[Ce,Oe]=v.useState(!1),[De,Be]=v.useState(null),[Ne,Ue]=v.useState(null),[Fe,ne]=v.useState(!1),[me,R]=v.useState(null),[q,fe]=v.useState(null),ge=v.useRef(null),Q=v.useRef(null),ke=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),de=v.useMemo(()=>new Set(j),[j]),Re=!HM(j,we),Ie=v.useMemo(()=>Bf(),[]),je=Ne?.displayMode==="standalone"&&(Ne.deviceKind==="mobile"||Ne.deviceKind==="tablet");v.useEffect(()=>mx(()=>m(fv())),[]),v.useEffect(()=>gx(()=>p(pv())),[]),v.useEffect(()=>vx(()=>b(gv())),[]),v.useEffect(()=>jh(()=>{k(vv()),D(_v())}),[]),v.useEffect(()=>$_(()=>A(Ia())),[]),v.useEffect(()=>vu(()=>Y(To())),[]),v.useEffect(()=>nx(()=>X(ko())),[]),v.useEffect(()=>{if(!$)return;const ee=Ru.find(st=>st.id===$);if(!ee)return;const Pe=st=>{if(st.preventDefault(),st.stopPropagation(),st.key==="Escape"){se(null),W(null);return}const tt=mM(st,ee);if(!tt){W(PM(ee));return}Y(hM($,tt)),se(null),W(null)};return window.addEventListener("keydown",Pe,!0),()=>window.removeEventListener("keydown",Pe,!0)},[$]),v.useEffect(()=>{let ee=!1;return c.listNotificationAssets().then(Pe=>{ee||St(Pe)}).catch(Pe=>{ee||Be(Cl(Pe))}),()=>{ee=!0}},[c]),v.useEffect(()=>{let ee=!1;return c.getPushNotificationStatus(Ar()).then(Pe=>{ee||(Ue(Pe.currentDevice),R(null))}).catch(Pe=>{ee||R(Cl(Pe))}),()=>{ee=!0}},[c]);function Ye(ee){m(_h(Number(ee)))}function ct(ee){X(vw(Number(ee)))}function Nt(ee){re(ee);const Pe=Q.current,st=ke.current[ee];if(!Pe||!st)return;const tt=Math.max(0,Ew(st,Pe)-12);typeof Pe.scrollTo=="function"?Pe.scrollTo({top:tt,behavior:"smooth"}):Pe.scrollTop=tt}function yt(){const ee=Q.current;if(!ee)return;if(ee.scrollTop+ee.clientHeight>=ee.scrollHeight-2){re(bh[bh.length-1].id);return}let Pe="appearance";const st=ee.scrollTop+Math.min(180,Math.max(48,ee.clientHeight*.28));for(const tt of bh){const kt=ke.current[tt.id];kt&&Ew(kt,ee)<=st&&(Pe=tt.id)}re(Pe)}function Tt(ee){Y(fM(ee)),se(null),W(null)}function $e(){Y(pM()),se(null),W(null)}function St(ee){const Pe=ee.assets.filter(st=>st.enabled).map(st=>st.id);M(ee.assets),ae(Pe),N(Pe),ue(ee.maxFileBytes),Be(null)}async function Lt(){if(Ee){gw(!1),ie(!1);return}let ee=F;ee==="default"&&(ee=await rx(),le(ee)),ee==="granted"&&(gw(!0),ie(!0))}async function ye(){ne(!0),R(null),fe(null);try{if(Ne)await jR(c),Ue(null);else{await LR(c,!1);const ee=await c.getPushNotificationStatus(Ar());Ue(ee.currentDevice)}}catch(ee){R(cg(ee))}finally{ne(!1)}}async function Xe(ee){ne(!0),R(null),fe(null);try{await IR(c,ee);const Pe=await c.getPushNotificationStatus(Ar());Ue(Pe.currentDevice)}catch(Pe){R(cg(Pe))}finally{ne(!1)}}async function rt(){ne(!0),R(null),fe(null);try{await c.testPushNotification({clientId:Ar()}),fe("Test notification accepted by the push service.")}catch(ee){R(cg(ee))}finally{ne(!1)}}async function Ze(ee){const Pe=ee?.[0];if(Pe){if(Pe.size>U){Be(`File must be ${lg(U)} or smaller.`),ut();return}if(Pe.type!=="video/mp4"&&Pe.type!=="video/webm"){Be("Upload an MP4 or WebM video."),ut();return}Oe(!0),Be(null);try{await c.uploadNotificationAsset(Pe),St(await c.listNotificationAssets()),r?.()}catch(st){Be(Cl(st))}finally{Oe(!1),ut()}}}async function Et(ee){Oe(!0),Be(null);try{await c.deleteNotificationAsset(ee),St(await c.listNotificationAssets()),r?.()}catch(Pe){Be(Cl(Pe))}finally{Oe(!1)}}function ut(){ge.current&&(ge.current.value="")}function Tn(ee,Pe){const st=new Set(j);if(Pe?st.add(ee):st.delete(ee),st.size===0){Be("Keep at least one toast video selected.");return}Be(null),ae(Array.from(st))}async function gi(){if(j.length===0){Be("Keep at least one toast video selected.");return}Oe(!0),Be(null);try{const ee=await c.updateNotificationAssetSelection({enabledAssetIds:j});St(ee),r?.()}catch(ee){Be(Cl(ee))}finally{Oe(!1)}}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:f.jsxs("div",{className:"security-panel settings-panel",onClick:ee=>ee.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{children:"Settings"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),f.jsxs("div",{className:"settings-layout",children:[f.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:bh.map(ee=>f.jsxs("button",{type:"button","data-active":xe===ee.id?"true":"false","aria-current":xe===ee.id?"true":void 0,onClick:()=>Nt(ee.id),children:[ee.label,ee.id==="servers"&&n?f.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ee.id))}),f.jsxs("div",{ref:Q,className:"settings-content",onScroll:yt,children:[f.jsxs("section",{id:"settings-appearance",ref:ee=>{ke.current.appearance=ee},className:"security-section settings-section",children:[f.jsx("h3",{children:"Appearance"}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Theme"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),f.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Qh.map(ee=>f.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":B===ee.id,"data-active":B===ee.id?"true":"false",onClick:()=>A(g2(ee.id)),style:{"--settings-theme-bg":ee.tokens.bg,"--settings-theme-bg-2":ee.tokens.bg2,"--settings-theme-sidebar":ee.tokens.bgSidebar,"--settings-theme-line":ee.tokens.line,"--settings-theme-fg":ee.tokens.fg,"--settings-theme-fg-2":ee.tokens.fg2,"--settings-theme-accent":ee.tokens.accent,"--settings-theme-xterm-bg":ee.xterm.background,"--settings-theme-xterm-fg":ee.xterm.foreground,"--settings-theme-xterm-selection":ee.xterm.selectionBackground},children:[f.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[f.jsxs("span",{className:"settings-theme-preview-sidebar",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-main",children:[f.jsxs("span",{className:"settings-theme-preview-tabs",children:[f.jsx("span",{}),f.jsx("span",{})]}),f.jsxs("span",{className:"settings-theme-preview-terminal",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})]})]}),f.jsxs("span",{className:"settings-theme-card-copy",children:[f.jsx("strong",{children:ee.label}),f.jsx("small",{children:ee.description})]})]},ee.id))}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font size"}),f.jsxs("span",{className:"settings-control-value",children:[u,"px"]}),f.jsx("input",{type:"range",min:uv,max:dv,step:1,value:u,"aria-label":"Terminal font size",onChange:ee=>Ye(ee.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row",children:[f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(_h(u-1)),children:"-"}),f.jsx("input",{type:"number",min:uv,max:dv,step:1,value:u,"aria-label":"Terminal font size value",onChange:ee=>Ye(ee.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>m(_h(u+1)),children:"+"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>m(_h(So)),children:"Reset"})]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Font family"}),f.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:ee=>p(rM(ee.currentTarget.value)),children:sf.map(ee=>f.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:y,onChange:ee=>b(oM(ee.currentTarget.checked))}),"Show scroll progress"]}),f.jsx("div",{className:"settings-section-heading",children:f.jsxs("div",{children:[f.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),f.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:C,onChange:ee=>k(lM(ee.currentTarget.checked))}),"Shell panes"]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:S,onChange:ee=>D(cM(ee.currentTarget.checked))}),"Codex/Claude panes"]})]}),f.jsxs("section",{id:"settings-shortcuts",ref:ee=>{ke.current.shortcuts=ee},className:"security-section settings-section",children:[f.jsxs("div",{className:"settings-section-heading",children:[f.jsx("h3",{children:"Shortcuts"}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:$e,children:"Reset all"})]}),f.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),J?f.jsx("p",{className:"settings-error",children:J}):null,f.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Ru.map(ee=>{const Pe=$===ee.id;return f.jsxs("li",{children:[f.jsxs("div",{children:[f.jsx("span",{className:"settings-shortcut-label",children:ee.label}),f.jsx("span",{className:"settings-shortcut-group",children:ee.group})]}),f.jsxs("div",{className:"settings-shortcut-actions",children:[f.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Pe?"true":"false",onClick:()=>{se(ee.id),W(null)},children:Pe?"Press keys…":wx(H[ee.id])}),f.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Tt(ee.id),children:"Reset"})]})]},ee.id)})})]}),f.jsxs("section",{id:"settings-notifications",ref:ee=>{ke.current.notifications=ee},className:"security-section settings-section",children:[f.jsx("h3",{children:"Notifications"}),Of()?f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Ee&&F==="granted",onChange:()=>{Lt()},disabled:F==="denied"}),"System notification when page is hidden"]}),F==="denied"?f.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):f.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):f.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),f.jsxs("div",{className:"settings-subsection",children:[f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:!!Ne,onChange:()=>{ye()},disabled:Fe||!Ie.supported}),"Installed app push notifications"]}),f.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Ie.supported?null:f.jsx("p",{className:"muted",children:Ih(Ie.reason)}),Ne?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"muted",children:["Registered as ",Ne.label,". Last active ",new Date(Ne.lastActiveAt).toLocaleString(),"."]}),f.jsx("button",{type:"button",className:"secondary-button settings-push-test-button",onClick:()=>{rt()},disabled:Fe,children:"Send test notification"})]}):null,je?f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:Ne?.alwaysNotify===!0,onChange:ee=>{Xe(ee.currentTarget.checked)},disabled:Fe||!Ne}),"Always notify this mobile device"]}):null,me?f.jsx("p",{className:"form-error",children:me}):null,q?f.jsx("p",{className:"muted",role:"status",children:q}):null]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:V.enabled,onChange:ee=>X(xR(ee.currentTarget.checked))}),"Show animated completion toast"]}),f.jsxs("label",{className:"settings-control",children:[f.jsx("span",{children:"Toast duration"}),f.jsx("span",{className:"settings-control-value",children:V.persistUntilDismissed?"Until closed":`${V.durationSeconds}s`}),f.jsx("input",{type:"range",min:nv,max:sv,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ee=>ct(ee.currentTarget.value)})]}),f.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[f.jsx("input",{type:"number",min:nv,max:sv,step:.5,value:V.durationSeconds,disabled:!V.enabled||V.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ee=>ct(ee.currentTarget.value)}),f.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!V.enabled||V.persistUntilDismissed,onClick:()=>X(vw(gu)),children:"Reset"})]}),f.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[f.jsx("input",{type:"checkbox",checked:V.persistUntilDismissed,disabled:!V.enabled,onChange:ee=>X(kR(ee.currentTarget.checked))}),"Keep toast until dismissed"]}),f.jsxs("div",{className:"settings-assets-header",children:[f.jsx("span",{children:"Toast videos"}),f.jsxs("span",{children:[lg(U)," max"]})]}),f.jsx("input",{ref:ge,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ee=>{Ze(ee.currentTarget.files)}}),f.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Ce,onClick:()=>ge.current?.click(),children:"Upload video"}),De?f.jsx("p",{className:"settings-error",children:De}):null,O.length>0?f.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:O.map(ee=>f.jsxs("li",{"data-enabled":de.has(ee.id)?"true":"false",children:[f.jsxs("label",{className:"settings-asset-choice",children:[f.jsx("input",{type:"checkbox",checked:de.has(ee.id),disabled:Ce,"aria-label":`Use ${ee.filename}`,onChange:Pe=>Tn(ee.id,Pe.currentTarget.checked)}),f.jsx("video",{src:ee.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),f.jsxs("span",{className:"settings-asset-copy",children:[f.jsx("span",{children:ee.filename}),f.jsx("small",{children:ee.source==="built-in"?"Built-in":lg(ee.size)})]})]}),ee.source==="uploaded"?f.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Ce,"aria-label":`Delete ${ee.filename}`,onClick:()=>{Et(ee.id)},children:"x"}):null]},ee.id))}):f.jsx("p",{className:"muted",children:"Built-in videos will be used."}),f.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Ce||O.length===0||!Re,onClick:()=>{gi()},children:"Save selected videos"})]}),f.jsx("div",{id:"settings-security",ref:ee=>{ke.current.security=ee},className:"settings-section-group",children:f.jsx(nM,{api:c})}),f.jsx("div",{id:"settings-servers",ref:ee=>{ke.current.servers=ee},className:"settings-section-group",children:f.jsx(BM,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Ew(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function lg(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 Cl(e){return e instanceof Error?e.message:"Request failed."}function Ih(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":e==="not_mobile"?"Installed app push notifications are available on mobile and tablet devices.":"This browser does not support installed app push notifications."}function cg(e){const t=Cl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?Ih("not_standalone"):t==="insecure"?Ih("insecure"):t==="not_mobile"?Ih("not_mobile"):t==="push_subscription_not_found"?"This app is no longer registered for push. Turn installed app notifications off and on again.":t==="push_delivery_failed"?"The push service rejected the test notification. Check Android notification permission and try re-registering this app.":t}function PM(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 HM(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(r=>n.has(r))}const UM="modulepreload",KM=function(e){return"/"+e},Dw={},_b=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");o=g(n.map(p=>{if(p=KM(p),p in Dw)return;Dw[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const C=document.createElement("link");if(C.rel=y?"stylesheet":UM,y||(C.as="script"),C.crossOrigin="",C.href=p,m&&C.setAttribute("nonce",m),document.head.appendChild(C),y)return new Promise((k,S)=>{C.addEventListener("load",k),C.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(u){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=u,window.dispatchEvent(m),!m.defaultPrevented)throw u}return o.then(u=>{for(const m of u||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})},FM=v.lazy(()=>_b(()=>import("./MarkdownPreview-4fzY6p-f.js"),__vite__mapDeps([0,1])));function WM({api:e,activeTerminalId:t,activeTerminalCwd:n,workspaceRootPath:r=null,onOpenFile:o}){const[c,u]=v.useState(null),[m,g]=v.useState(""),[p,y]=v.useState({}),[b,C]=v.useState(()=>new Set),[k,S]=v.useState(null),[D,B]=v.useState({type:"empty"}),[A,H]=v.useState("idle"),[Y,$]=v.useState(null),se=v.useRef(null),J=v.useRef(null),W=v.useRef(!1),xe=v.useRef(0),re=v.useRef(null);re.current===null&&t&&(re.current=t);const Ee=re.current,ie=r?qM(r):t?Rw(t,n):null,V=c?[c.rootPath,m].filter(Boolean).join("/"):"",X=k?.path??null;v.useEffect(()=>(W.current=!0,()=>{W.current=!1,xe.current+=1,ne()}),[]),v.useEffect(()=>{re.current=t,J.current=null,F(ie)},[e]),v.useEffect(()=>{r&&ie!==J.current&&le(r,ie)},[r,ie]),v.useEffect(()=>{if(r||!Ee||t!==Ee)return;const Q=Rw(Ee,n);Q!==J.current&&O(Ee,Q)},[Ee,t,n,r]);async function F(Q=ie){if(r){await le(r,Q);return}await O(t,Q)}async function le(Q,ke=ie){const de=me();if(J.current=ke,ne(),u(null),g(""),y({}),C(new Set),S(null),B({type:"empty"}),$(null),!Q){H("idle");return}H("loading");try{const Re=await e.createFileRoot({path:Q});if(!R(de))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Ie=await e.listFiles({rootToken:Re.rootToken,path:""});if(!R(de))return;ae(Ie),H("idle")}catch(Re){R(de)&&($(Er(Re)),H("idle"))}}async function O(Q,ke=ie){const de=me();if(J.current=ke,ne(),u(null),g(""),y({}),C(new Set),S(null),B({type:"empty"}),$(null),!Q){H("idle");return}H("loading");try{const Re=await e.createFileRoot({terminalId:Q});if(!R(de))return;u({rootToken:Re.rootToken,rootPath:Re.rootPath});const Ie=await e.listFiles({rootToken:Re.rootToken,path:""});if(!R(de))return;ae(Ie),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(Er(Re)),H("idle"))}}async function M(Q=m,ke=c){if(!ke)return;const de=me();H("loading"),$(null);try{const Re=await e.listFiles({rootToken:ke.rootToken,path:Q});if(!R(de))return;ae(Re),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(Er(Re)),H("idle"))}}async function j(){if(r){await le(r,ie);return}re.current=t,await O(t,ie)}function ae(Q){y(ke=>({...ke,[Q.path]:VM(Q.entries)}))}async function we(Q){if(!(!ug(Q)||!c)){if(S(Q),$(null),Q.kind==="directory"){g(Q.path),Fe(),await U(Q);return}if(g(go(Q.path)),Q.editable){await Ce(Q);return}Q.previewKind!=="none"&&await De(Q,Q.previewKind)}}async function N(Q){if(!(!ug(Q)||!c)){if(S(Q),$(null),Q.kind==="directory"){g(Q.path),Fe(),await U(Q);return}if(g(go(Q.path)),Q.editable){await Oe(Q);return}Q.previewKind!=="none"&&await De(Q,Q.previewKind)}}async function U(Q){if(b.has(Q.path)){C(ke=>{const de=new Set(ke);return de.delete(Q.path),de});return}C(ke=>new Set(ke).add(Q.path)),await M(Q.path)}function ue(Q,ke){Q.key==="Enter"&&(Q.preventDefault(),N(ke))}async function Ce(Q){if(!c)return;const ke=me();H("loading"),ne();try{const de=await e.readFile({rootToken:c.rootToken,path:Q.path});if(!R(ke))return;B({type:"text-preview",file:Q,read:de}),H("idle")}catch(de){if(await q(de,ke))return;R(ke)&&($(Er(de)),H("idle"))}}async function Oe(Q){if(!c)return;const ke=me();H("loading");try{await o({rootToken:c.rootToken,path:Q.path,...t?{terminalId:t}:{}}),R(ke)&&H("idle")}catch(de){if(await q(de,ke))return;R(ke)&&($(Er(de)),H("idle"))}}async function De(Q,ke){if(!c)return;const de=me();H("loading"),ne();try{const Re=await e.previewFile({rootToken:c.rootToken,path:Q.path});if(!R(de))return;const Ie=URL.createObjectURL(Re);if(!R(de)){URL.revokeObjectURL(Ie);return}se.current=Ie,B({type:"preview",file:Q,previewKind:ke,url:Ie}),H("idle")}catch(Re){if(await q(Re,de))return;R(de)&&($(Er(Re)),H("idle"))}}async function Be(Q){if(!c)return;const ke=Q==="file"?"New file":"New folder",de=window.prompt(ke,""),Re=k?k.kind==="directory"?k.path:go(k.path):m,Ie=Mw(de,Re);if(Ie){$(null);try{const je=await e.createFileEntry({rootToken:c.rootToken,path:Ie,kind:Q});S(je.entry),await M(Re)}catch(je){if(await q(je))return;$(Er(je))}}}async function Ne(){if(!c||!k)return;const Q=window.prompt("Move selected entry",k.path),ke=Mw(Q,"");if(!ke||ke===k.path)return;const de=go(k.path),Re=go(ke);$(null);try{const Ie=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:k.path,destinationPath:ke});S(Ie.entry),g(Ie.entry.kind==="directory"?Ie.entry.path:go(Ie.entry.path)),Fe(),await M(de),Re!==de&&await M(Re)}catch(Ie){if(await q(Ie))return;$(Er(Ie))}}async function Ue(){if(!c||!k)return;const Q=k.path,ke=go(Q);$(null);try{const de=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:k.path}),Re=de.descendantCount>0?` and ${de.descendantCount} nested item${de.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${de.path}${Re}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:k.path,previewToken:de.previewToken}),S(null),g(ke),C(Ie=>{const je=new Set(Ie);for(const Ye of Ie)(Ye===Q||Ye.startsWith(`${Q}/`))&&je.delete(Ye);return je}),Fe(),await M(ke)}catch(de){if(await q(de))return;$(Er(de))}}function Fe(){xe.current+=1,ne(),B({type:"empty"})}function ne(){se.current&&(URL.revokeObjectURL(se.current),se.current=null)}function me(){return xe.current+=1,xe.current}function R(Q){return W.current&&Q===xe.current}async function q(Q,ke){return YM(Q)?(ke!==void 0&&!R(ke)||await F(ie),!0):!1}function fe(Q,ke){const de=ug(Q),Re=Q.kind==="directory"&&b.has(Q.path),Ie=p[Q.path]??[],je={"--file-tree-depth":ke};return f.jsxs(Ni.Fragment,{children:[f.jsxs("button",{type:"button",className:"file-entry-button","data-kind":Q.kind,"data-expanded":Re,"data-active":X===Q.path,disabled:!de,style:je,"aria-expanded":Q.kind==="directory"?Re:void 0,"aria-label":`${Q.kind==="directory"?"Open folder":"Open file"} ${Q.name}`,title:Q.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{we(Q)},onDoubleClick:()=>{N(Q)},onKeyDown:Ye=>ue(Ye,Q),children:[f.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:Q.kind==="directory"?Re?"▾":"▸":""}),f.jsx("span",{className:"file-entry-name",children:Q.name}),f.jsx("small",{children:$M(Q)})]}),Re?f.jsx("div",{className:"file-tree-children",role:"group",children:Ie.map(Ye=>fe(Ye,ke+1))}):null]},Q.path)}const ge=p[""]??[];return f.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[f.jsxs("header",{className:"file-explorer-header",children:[f.jsx("div",{className:"file-explorer-path",title:V,children:V||"No active pane"}),f.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[f.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{j()},children:"↻"}),f.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Be("file")},children:"+"}),f.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Be("directory")},children:"▣"})]})]}),Y?f.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,f.jsxs("div",{className:"file-explorer-layout",children:[f.jsx("div",{className:"file-tree","aria-label":V?`Files in ${V}`:"Files",children:ge.map(Q=>fe(Q,0))}),f.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[f.jsxs("div",{className:"file-detail-header",children:[f.jsx("strong",{children:k?.name??"detail"}),f.jsxs("div",{className:"file-detail-actions",children:[f.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!k,onClick:()=>{Ne()},children:"Move"}),f.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!k,onClick:()=>{Ue()},children:"Delete"})]})]}),A==="loading"?f.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&A!=="loading"?f.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?f.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?f.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?f.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?f.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:f.jsx(FM,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?f.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function ug(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function $M(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Rw(e,t){return`${e}\0${t??""}`}function qM(e){return`workspace\0${e}`}function VM(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 go(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Mw(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 Er(e){return e instanceof Error?e.message:"Request failed"}function YM(e){return e instanceof Ln&&e.status===409&&e.message==="terminal_cwd_changed"}const XM=v.lazy(()=>_b(()=>import("./MarkdownPreview-4fzY6p-f.js"),__vite__mapDeps([0,1])));function Nw({api:e,editor:t,canClose:n,onClose:r}){const[o,c]=v.useState(t.read),[u,m]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[C,k]=v.useState(!1),[S,D]=v.useState("edit"),B=v.useRef(t),A=v.useRef(t.read),H=v.useRef(t.read.content),Y=v.useRef(!1),$=v.useRef(!1),se=v.useRef(0),J=u!==o.content&&g!=="saving"&&!C;v.useEffect(()=>($.current=!0,()=>{$.current=!1,se.current+=1}),[]),v.useEffect(()=>{se.current+=1,Y.current=!1,B.current=t,A.current=t.read,H.current=t.read.content,c(t.read),m(t.read.content),p("idle"),b(null),k(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{H.current=u},[u]),v.useEffect(()=>{if(u===o.content||C)return;const ie=window.setInterval(()=>{!Y.current&&H.current!==A.current.content&&W()},1e3);return()=>window.clearInterval(ie)},[u===o.content,C,t.id]);async function W(){if(Y.current)return;const ie=H.current,V=A.current;if(ie===V.content)return;const X=B.current,F=se.current;Y.current=!0,p("saving"),b(null),k(!1);try{const le=await e.writeFile({rootToken:X.rootToken,path:X.path,content:ie,expectedVersion:V.version});if(!$.current||F!==se.current)return;const O={...V,content:ie,version:le.version};A.current=O,c(O),p(H.current===ie?"saved":"idle")}catch(le){if(!$.current||F!==se.current)return;if(le instanceof Ln&&le.status===409){k(!0),p("idle");return}b(GM(le)),p("idle")}finally{F===se.current&&(Y.current=!1)}}const xe=g==="saving"?"saving":g==="saved"?"saved":o.language,re=o.language==="markdown",Ee=re&&S==="preview";return f.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[f.jsxs("header",{className:"editor-pane-header",children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("strong",{children:t.title}),f.jsx("span",{className:"terminal-pane-spacer"}),f.jsx("span",{className:"terminal-pane-state",children:xe}),f.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!J,onClick:()=>{W()},children:"Save"}),re?f.jsx("button",{type:"button","aria-label":`${Ee?"Edit":"Preview"} ${t.title}`,onClick:()=>D(ie=>ie==="preview"?"edit":"preview"),children:Ee?"Edit":"Preview"}):null,n?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,C?f.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Ee?f.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:f.jsx(v.Suspense,{fallback:f.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:f.jsx(XM,{content:u})})}):f.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:u,onChange:ie=>{const V=ie.target.value;H.current=V,m(V),p("idle"),b(null),k(!1)}})]})}function GM(e){return e instanceof Error?e.message:"Request failed"}var ZM=2,QM=1,JM=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),u={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},m=u.top+u.bottom,g=u.right+u.left,p=r-m,y=o-g-t;return{cols:Math.max(ZM,Math.floor(y/e.css.cell.width)),rows:Math.max(QM,Math.floor(p/e.css.cell.height))}}};var Mx=Object.defineProperty,eN=Object.getOwnPropertyDescriptor,tN=(e,t)=>{for(var n in t)Mx(e,n,{get:t[n],enumerable:!0})},mi=(e,t,n,r)=>{for(var o=r>1?void 0:r?eN(t,n):t,c=e.length-1,u;c>=0;c--)(u=e[c])&&(o=(r?u(t,n,o):u(o))||o);return r&&o&&Mx(t,n,o),o},ze=(e,t)=>(n,r)=>t(n,r,e),Aw="Terminal input",wv={get:()=>Aw,set:e=>Aw=e},Lw="Too much output to announce, navigate to rows manually to read",Cv={get:()=>Lw,set:e=>Lw=e};function iN(e){return e.replace(/\r?\n/g,"\r")}function nN(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sN(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function rN(e,t,n,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Nx(o,t,n,r)}}function Nx(e,t,n,r){e=iN(e),e=nN(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Ax(e,t,n){let r=n.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Ow(e,t,n,r,o){Ax(e,t,n),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ra(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function If(e,t=0,n=e.length){let r="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var aN=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<n;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=n)return this._interim=u,r;let m=e.charCodeAt(c);56320<=m&&m<=57343?t[r++]=(u-55296)*1024+m-56320+65536:(t[r++]=u,t[r++]=m);continue}u!==65279&&(t[r++]=u)}return r}},oN=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,o,c,u,m,g=0,p=0;if(this.interim[0]){let C=!1,k=this.interim[0];k&=(k&224)===192?31:(k&240)===224?15:7;let S=0,D;for(;(D=this.interim[++S]&63)&&S<4;)k<<=6,k|=D;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=B-S;for(;p<A;){if(p>=n)return 0;if(D=e[p++],(D&192)!==128){p--,C=!0;break}else this.interim[S++]=D,k<<=6,k|=D&63}C||(B===2?k<128?p--:t[r++]=k:B===3?k<2048||k>=55296&&k<=57343||k===65279||(t[r++]=k):k<65536||k>1114111||(t[r++]=k)),this.interim.fill(0)}let y=n-4,b=p;for(;b<n;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((u=e[b+2])&128)&&!((m=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=u,t[r++]=m,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|u&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=n)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,r;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=u,r;if(m=e[b++],(m&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(u&63)<<6|m&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},Lx="",Na=" ",Yu=class Ox{constructor(){this.fg=0,this.bg=0,this.extended=new af}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 Ox;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}},af=class Bx{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 Bx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ds=class jx extends Yu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new af,this.combinedData=""}static fromCharData(t){let n=new jx;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?Ra(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Bw="di$target",xv="di$dependencies",dg=new Map;function lN(e){return e[xv]||[]}function Qi(e){if(dg.has(e))return dg.get(e);let t=function(n,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");cN(t,n,o)};return t._id=e,dg.set(e,t),t}function cN(e,t,n){t[Bw]===t?t[xv].push({id:e,index:n}):(t[xv]=[{id:e,index:n}],t[Bw]=t)}var xn=Qi("BufferService"),Ix=Qi("CoreMouseService"),Ao=Qi("CoreService"),uN=Qi("CharsetService"),bb=Qi("InstantiationService"),zx=Qi("LogService"),kn=Qi("OptionsService"),Px=Qi("OscLinkService"),dN=Qi("UnicodeService"),Xu=Qi("DecorationService"),kv=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new ds,u=n.getTrimmedLength(),m=-1,g=-1,p=!1;for(let y=0;y<u;y++)if(!(g===-1&&!n.hasContent(y))){if(n.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,m=c.extended.urlId;continue}else p=c.extended.urlId!==m;else g!==-1&&(p=!0);if(p||g!==-1&&y===u-1){let b=this._oscLinkService.getLinkData(m)?.uri;if(b){let C={start:{x:g+1,y:e},end:{x:y+(!p&&y===u-1?1:0),y:e}},k=!1;if(!o?.allowNonHttpProtocols)try{let S=new URL(b);["http:","https:"].includes(S.protocol)||(k=!0)}catch{k=!0}k||r.push({text:b,range:C,activate:(S,D)=>o?o.activate(S,D,C):hN(S,D),hover:(S,D)=>o?.hover?.(S,D,C),leave:(S,D)=>o?.leave?.(S,D,C)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,m=c.extended.urlId):(g=-1,m=-1)}}t(r)}};kv=mi([ze(0,xn),ze(1,kn),ze(2,Px)],kv);function hN(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
17
|
-
|
|
18
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var zf=Qi("CharSizeService"),zr=Qi("CoreBrowserService"),yb=Qi("MouseService"),Pr=Qi("RenderService"),fN=Qi("SelectionService"),Hx=Qi("CharacterJoinerService"),ql=Qi("ThemeService"),Ux=Qi("LinkProviderService"),pN=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?jw.isErrorNoTelemetry(e)?new jw(e.message+`
|
|
19
|
-
|
|
20
|
-
`+e.stack):new Error(e.message+`
|
|
21
|
-
|
|
22
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},mN=new pN;function zh(e){gN(e)||mN.onUnexpectedError(e)}var Tv="Canceled";function gN(e){return e instanceof vN?!0:e instanceof Error&&e.name===Tv&&e.message===Tv}var vN=class extends Error{constructor(){super(Tv),this.name=this.message}};function _N(e){return new Error(`Illegal argument: ${e}`)}var jw=class Ev extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ev)return t;let n=new Ev;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Dv=class Kx extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Kx.prototype)}};function $n(e,t=0){return e[e.length-(1+t)]}var bN;(e=>{function t(c){return c<0}e.isLessThan=t;function n(c){return c<=0}e.isLessThanOrEqual=n;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(bN||={});function yN(e,t){let n=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(n,arguments))),o}}var Fx;(e=>{function t($){return $&&typeof $=="object"&&typeof $[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*o($){yield $}e.single=o;function c($){return t($)?$:o($)}e.wrap=c;function u($){return $||n}e.from=u;function*m($){for(let se=$.length-1;se>=0;se--)yield $[se]}e.reverse=m;function g($){return!$||$[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p($){return $[Symbol.iterator]().next().value}e.first=p;function y($,se){let J=0;for(let W of $)if(se(W,J++))return!0;return!1}e.some=y;function b($,se){for(let J of $)if(se(J))return J}e.find=b;function*C($,se){for(let J of $)se(J)&&(yield J)}e.filter=C;function*k($,se){let J=0;for(let W of $)yield se(W,J++)}e.map=k;function*S($,se){let J=0;for(let W of $)yield*se(W,J++)}e.flatMap=S;function*D(...$){for(let se of $)yield*se}e.concat=D;function B($,se,J){let W=J;for(let xe of $)W=se(W,xe);return W}e.reduce=B;function*A($,se,J=$.length){for(se<0&&(se+=$.length),J<0?J+=$.length:J>$.length&&(J=$.length);se<J;se++)yield $[se]}e.slice=A;function H($,se=Number.POSITIVE_INFINITY){let J=[];if(se===0)return[J,$];let W=$[Symbol.iterator]();for(let xe=0;xe<se;xe++){let re=W.next();if(re.done)return[J,e.empty()];J.push(re.value)}return[J,{[Symbol.iterator](){return W}}]}e.consume=H;async function Y($){let se=[];for await(let J of $)se.push(J);return Promise.resolve(se)}e.asyncToArray=Y})(Fx||={});function Eo(e){if(Fx.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function SN(...e){return ni(()=>Eo(e))}function ni(e){return{dispose:yN(()=>{e()})}}var Wx=class $x{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{Eo(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?$x.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)}};Wx.DISABLE_DISPOSED_WARNING=!1;var La=Wx,vt=class{constructor(){this._store=new La,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)}};vt.None=Object.freeze({dispose(){}});var Pl=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}},Lr=typeof window=="object"?window:globalThis,Rv=class Mv{constructor(t){this.element=t,this.next=Mv.Undefined,this.prev=Mv.Undefined}};Rv.Undefined=new Rv(void 0);var oi=Rv,Iw=class{constructor(){this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===oi.Undefined}clear(){let e=this._first;for(;e!==oi.Undefined;){let t=e.next;e.prev=oi.Undefined,e.next=oi.Undefined,e=t}this._first=oi.Undefined,this._last=oi.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new oi(e);if(this._first===oi.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==oi.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==oi.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==oi.Undefined&&e.next!==oi.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===oi.Undefined&&e.next===oi.Undefined?(this._first=oi.Undefined,this._last=oi.Undefined):e.next===oi.Undefined?(this._last=this._last.prev,this._last.next=oi.Undefined):e.prev===oi.Undefined&&(this._first=this._first.next,this._first.prev=oi.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==oi.Undefined;)yield e.element,e=e.next}},wN=globalThis.performance&&typeof globalThis.performance.now=="function",CN=class qx{static create(t){return new qx(t)}constructor(t){this._now=wN&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},ln;(e=>{e.None=()=>vt.None;function t(V,X){return b(V,()=>{},0,void 0,!0,void 0,X)}e.defer=t;function n(V){return(X,F=null,le)=>{let O=!1,M;return M=V(j=>{if(!O)return M?M.dispose():O=!0,X.call(F,j)},null,le),O&&M.dispose(),M}}e.once=n;function r(V,X,F){return p((le,O=null,M)=>V(j=>le.call(O,X(j)),null,M),F)}e.map=r;function o(V,X,F){return p((le,O=null,M)=>V(j=>{X(j),le.call(O,j)},null,M),F)}e.forEach=o;function c(V,X,F){return p((le,O=null,M)=>V(j=>X(j)&&le.call(O,j),null,M),F)}e.filter=c;function u(V){return V}e.signal=u;function m(...V){return(X,F=null,le)=>{let O=SN(...V.map(M=>M(j=>X.call(F,j))));return y(O,le)}}e.any=m;function g(V,X,F,le){let O=F;return r(V,M=>(O=X(O,M),O),le)}e.reduce=g;function p(V,X){let F,le={onWillAddFirstListener(){F=V(O.fire,O)},onDidRemoveLastListener(){F?.dispose()}},O=new Le(le);return X?.add(O),O.event}function y(V,X){return X instanceof Array?X.push(V):X&&X.add(V),V}function b(V,X,F=100,le=!1,O=!1,M,j){let ae,we,N,U=0,ue,Ce={leakWarningThreshold:M,onWillAddFirstListener(){ae=V(De=>{U++,we=X(we,De),le&&!N&&(Oe.fire(we),we=void 0),ue=()=>{let Be=we;we=void 0,N=void 0,(!le||U>1)&&Oe.fire(Be),U=0},typeof F=="number"?(clearTimeout(N),N=setTimeout(ue,F)):N===void 0&&(N=0,queueMicrotask(ue))})},onWillRemoveListener(){O&&U>0&&ue?.()},onDidRemoveLastListener(){ue=void 0,ae.dispose()}},Oe=new Le(Ce);return j?.add(Oe),Oe.event}e.debounce=b;function C(V,X=0,F){return e.debounce(V,(le,O)=>le?(le.push(O),le):[O],X,void 0,!0,void 0,F)}e.accumulate=C;function k(V,X=(le,O)=>le===O,F){let le=!0,O;return c(V,M=>{let j=le||!X(M,O);return le=!1,O=M,j},F)}e.latch=k;function S(V,X,F){return[e.filter(V,X,F),e.filter(V,le=>!X(le),F)]}e.split=S;function D(V,X=!1,F=[],le){let O=F.slice(),M=V(we=>{O?O.push(we):ae.fire(we)});le&&le.add(M);let j=()=>{O?.forEach(we=>ae.fire(we)),O=null},ae=new Le({onWillAddFirstListener(){M||(M=V(we=>ae.fire(we)),le&&le.add(M))},onDidAddFirstListener(){O&&(X?setTimeout(j):j())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return le&&le.add(ae),ae.event}e.buffer=D;function B(V,X){return(F,le,O)=>{let M=X(new H);return V(function(j){let ae=M.evaluate(j);ae!==A&&F.call(le,ae)},void 0,O)}}e.chain=B;let A=Symbol("HaltChainable");class H{constructor(){this.steps=[]}map(X){return this.steps.push(X),this}forEach(X){return this.steps.push(F=>(X(F),F)),this}filter(X){return this.steps.push(F=>X(F)?F:A),this}reduce(X,F){let le=F;return this.steps.push(O=>(le=X(le,O),le)),this}latch(X=(F,le)=>F===le){let F=!0,le;return this.steps.push(O=>{let M=F||!X(O,le);return F=!1,le=O,M?O:A}),this}evaluate(X){for(let F of this.steps)if(X=F(X),X===A)break;return X}}function Y(V,X,F=le=>le){let le=(...ae)=>j.fire(F(...ae)),O=()=>V.on(X,le),M=()=>V.removeListener(X,le),j=new Le({onWillAddFirstListener:O,onDidRemoveLastListener:M});return j.event}e.fromNodeEventEmitter=Y;function $(V,X,F=le=>le){let le=(...ae)=>j.fire(F(...ae)),O=()=>V.addEventListener(X,le),M=()=>V.removeEventListener(X,le),j=new Le({onWillAddFirstListener:O,onDidRemoveLastListener:M});return j.event}e.fromDOMEventEmitter=$;function se(V){return new Promise(X=>n(V)(X))}e.toPromise=se;function J(V){let X=new Le;return V.then(F=>{X.fire(F)},()=>{X.fire(void 0)}).finally(()=>{X.dispose()}),X.event}e.fromPromise=J;function W(V,X){return V(F=>X.fire(F))}e.forward=W;function xe(V,X,F){return X(F),V(le=>X(le))}e.runAndSubscribe=xe;class re{constructor(X,F){this._observable=X,this._counter=0,this._hasChanged=!1;let le={onWillAddFirstListener:()=>{X.addObserver(this)},onDidRemoveLastListener:()=>{X.removeObserver(this)}};this.emitter=new Le(le),F&&F.add(this.emitter)}beginUpdate(X){this._counter++}handlePossibleChange(X){}handleChange(X,F){this._hasChanged=!0}endUpdate(X){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(V,X){return new re(V,X).emitter.event}e.fromObservable=Ee;function ie(V){return(X,F,le)=>{let O=0,M=!1,j={beginUpdate(){O++},endUpdate(){O--,O===0&&(V.reportChanges(),M&&(M=!1,X.call(F)))},handlePossibleChange(){},handleChange(){M=!0}};V.addObserver(j),V.reportChanges();let ae={dispose(){V.removeObserver(j)}};return le instanceof La?le.add(ae):Array.isArray(le)&&le.push(ae),ae}}e.fromObservableLight=ie})(ln||={});var Nv=class Av{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Av._idPool++}`,Av.all.add(this)}start(t){this._stopWatch=new CN,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}}};Nv.all=new Set,Nv._idPool=0;var xN=Nv,kN=-1,Vx=class Yx{constructor(t,n,r=(Yx._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,u]=this.getMostFrequentStack(),m=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(m),console.warn(c);let g=new DN(m,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,o]of this._stacks)(!t||n<o)&&(t=[r,o],n=o);return t}};Vx._idPool=1;var TN=Vx,EN=class Xx{constructor(t){this.value=t}static create(){let t=new Error;return new Xx(t.stack??"")}print(){console.warn(this.value.split(`
|
|
23
|
-
`).slice(2).join(`
|
|
24
|
-
`))}},DN=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},RN=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},MN=0,hg=class{constructor(e){this.value=e,this.id=MN++}},NN=2,AN,Le=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new TN(e?.onListenerError??zh,this._options?.leakWarningThreshold??kN):void 0,this._perfMon=this._options?._profName?new xN(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new RN(`${u}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(this._options?.onListenerError||zh)(g),vt.None}if(this._disposed)return vt.None;t&&(e=e.bind(t));let r=new hg(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=EN.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof hg?(this._deliveryQueue??=new LN,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=ni(()=>{o?.(),this._removeListener(r)});return n instanceof La?n.add(c):Array.isArray(n)&&n.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*NN<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||zh;if(!n){e.value(t);return}try{e.value(t)}catch(r){n(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof hg)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}},LN=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}},Lv=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Le,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Le,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let r=this.getWindowId(n);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Lv.INSTANCE=new Lv;var Sb=Lv;function ON(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}Sb.INSTANCE.onDidChangeZoomLevel;function BN(e){return Sb.INSTANCE.getZoomFactor(e)}Sb.INSTANCE.onDidChangeFullscreen;var Vl=typeof navigator=="object"?navigator.userAgent:"",Ov=Vl.indexOf("Firefox")>=0,jN=Vl.indexOf("AppleWebKit")>=0,wb=Vl.indexOf("Chrome")>=0,IN=!wb&&Vl.indexOf("Safari")>=0;Vl.indexOf("Electron/")>=0;Vl.indexOf("Android")>=0;var fg=!1;if(typeof Lr.matchMedia=="function"){let e=Lr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Lr.matchMedia("(display-mode: fullscreen)");fg=e.matches,ON(Lr,e,({matches:n})=>{fg&&t.matches||(fg=n)})}var Tl="en",Bv=!1,jv=!1,Ph=!1,Gx=!1,yh,Hh=Tl,zw=Tl,zN,Rr,wo=globalThis,Yn;typeof wo.vscode<"u"&&typeof wo.vscode.process<"u"?Yn=wo.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Yn=process);var PN=typeof Yn?.versions?.electron=="string",HN=PN&&Yn?.type==="renderer";if(typeof Yn=="object"){Bv=Yn.platform==="win32",jv=Yn.platform==="darwin",Ph=Yn.platform==="linux",Ph&&Yn.env.SNAP&&Yn.env.SNAP_REVISION,Yn.env.CI||Yn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yh=Tl,Hh=Tl;let e=Yn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);yh=t.userLocale,zw=t.osLocale,Hh=t.resolvedLanguage||Tl,zN=t.languagePack?.translationsConfigFile}catch{}Gx=!0}else typeof navigator=="object"&&!HN?(Rr=navigator.userAgent,Bv=Rr.indexOf("Windows")>=0,jv=Rr.indexOf("Macintosh")>=0,(Rr.indexOf("Macintosh")>=0||Rr.indexOf("iPad")>=0||Rr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ph=Rr.indexOf("Linux")>=0,Rr?.indexOf("Mobi")>=0,Hh=globalThis._VSCODE_NLS_LANGUAGE||Tl,yh=navigator.language.toLowerCase(),zw=yh):console.error("Unable to resolve platform.");var Zx=Bv,Gs=jv,UN=Ph,Pw=Gx,Qs=Rr,wa=Hh,KN;(e=>{function t(){return wa}e.value=t;function n(){return wa.length===2?wa==="en":wa.length>=3?wa[0]==="e"&&wa[1]==="n"&&wa[2]==="-":!1}e.isDefaultVariant=n;function r(){return wa==="en"}e.isDefault=r})(KN||={});var FN=typeof wo.postMessage=="function"&&!wo.importScripts;(()=>{if(FN){let e=[];wo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===n.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),wo.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var WN=!!(Qs&&Qs.indexOf("Chrome")>=0);Qs&&Qs.indexOf("Firefox")>=0;!WN&&Qs&&Qs.indexOf("Safari")>=0;Qs&&Qs.indexOf("Edg/")>=0;Qs&&Qs.indexOf("Android")>=0;var bl=typeof navigator=="object"?navigator:{};Pw||document.queryCommandSupported&&document.queryCommandSupported("copy")||bl&&bl.clipboard&&bl.clipboard.writeText,Pw||bl&&bl.clipboard&&bl.clipboard.readText;var Cb=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}},pg=new Cb,Hw=new Cb,Uw=new Cb,$N=new Array(230),Qx;(e=>{function t(m){return pg.keyCodeToStr(m)}e.toString=t;function n(m){return pg.strToKeyCode(m)}e.fromString=n;function r(m){return Hw.keyCodeToStr(m)}e.toUserSettingsUS=r;function o(m){return Uw.keyCodeToStr(m)}e.toUserSettingsGeneral=o;function c(m){return Hw.strToKeyCode(m)||Uw.strToKeyCode(m)}e.fromUserSettings=c;function u(m){if(m>=98&&m<=113)return null;switch(m){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return pg.keyCodeToStr(m)}e.toElectronAccelerator=u})(Qx||={});var qN=class Jx{constructor(t,n,r,o,c){this.ctrlKey=t,this.shiftKey=n,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Jx&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new VN([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},VN=class{constructor(e){if(e.length===0)throw _N("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 YN(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Qx.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Ov)switch(t){case 59:return 85;case 60:if(UN)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Gs)return 57;break}else if(jN&&(Gs&&t===93||!Gs&&t===92))return 57;return $N[t]||0}var XN=Gs?256:2048,GN=512,ZN=1024,QN=Gs?2048:256,Kw=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=YN(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|=XN),this.altKey&&(t|=GN),this.shiftKey&&(t|=ZN),this.metaKey&&(t|=QN),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new qN(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Fw=new WeakMap;function JN(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 eA=class{static getSameOriginWindowChain(e){let t=Fw.get(e);if(!t){t=[],Fw.set(e,t);let n=e,r;do r=JN(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let u=c.window.deref();if(n+=u?.scrollY??0,r+=u?.scrollX??0,u===t||!c.iframeElement)break;let m=c.iframeElement.getBoundingClientRect();n+=m.top,r+=m.left}return{top:n,left:r}}},Sh=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=eA.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ww=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(wb){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,u=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*u):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?Ov&&!Gs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")IN&&Zx?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*u):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?Ov&&!Gs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*u):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},ek=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),tA;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof iA?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ln.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ek})})(tA||={});var iA=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?ek:(this._emitter||(this._emitter=new Le),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},xb=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 Dv("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Dv("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},nA=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 Dv("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=ni(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},sA;(e=>{async function t(r){let o,c=await Promise.all(r.map(u=>u.then(m=>m,m=>{o||(o=m)})));if(typeof o<"u")throw o;return c}e.settled=t;function n(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(u){c(u)}})}e.withAsyncBody=n})(sA||={});var $w=class os{static fromArray(t){return new os(n=>{n.emitMany(t)})}static fromPromise(t){return new os(async n=>{n.emitMany(await t)})}static fromPromises(t){return new os(async n=>{await Promise.all(t.map(async r=>n.emitOne(await r)))})}static merge(t){return new os(async n=>{await Promise.all(t.map(async r=>{for await(let o of r)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Le,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await ln.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new os(async r=>{for await(let o of t)r.emitOne(n(o))})}map(t){return os.map(this,t)}static filter(t,n){return new os(async r=>{for await(let o of t)n(o)&&r.emitOne(o)})}filter(t){return os.filter(this,t)}static coalesce(t){return os.filter(t,n=>!!n)}coalesce(){return os.coalesce(this)}static async toPromise(t){let n=[];for await(let r of t)n.push(r);return n}toPromise(){return os.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())}};$w.EMPTY=$w.fromArray([]);var{getWindow:Xs,getWindowId:rA,onDidRegisterWindow:aA}=(function(){let e=new Map,t={window:Lr,disposables:new La};e.set(Lr.vscodeWindowId,t);let n=new Le,r=new Le,o=new Le;function c(u,m){return(typeof u=="number"?e.get(u):void 0)??(m?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(u){if(e.has(u.vscodeWindowId))return vt.None;let m=new La,g={window:u,disposables:m.add(new La)};return e.set(u.vscodeWindowId,g),m.add(ni(()=>{e.delete(u.vscodeWindowId),r.fire(u)})),m.add(nt(u,qi.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(g),m},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:c,getWindow(u){let m=u;if(m?.ownerDocument?.defaultView)return m.ownerDocument.defaultView.window;let g=u;return g?.view?g.view.window:Lr},getDocument(u){return Xs(u).document}}})(),oA=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function nt(e,t,n,r){return new oA(e,t,n,r)}var qw=function(e,t,n,r){return nt(e,t,n,r)},kb,lA=class extends nA{constructor(e){super(),this.defaultTarget=e&&Xs(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Vw=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){zh(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,o=c=>{n.set(c,!1);let u=e.get(c)??[];for(t.set(c,u),e.set(c,[]),r.set(c,!0);u.length>0;)u.sort(Vw.sort),u.shift().execute();r.set(c,!1)};kb=(c,u,m=0)=>{let g=rA(c),p=new Vw(u,m),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),n.get(g)||(n.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function cA(e){let t=e.getBoundingClientRect(),n=Xs(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var qi={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"},uA=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=An(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=An(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=An(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=An(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=An(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=An(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=An(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=An(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=An(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=An(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=An(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=An(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=An(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=An(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function An(e){return typeof e=="number"?`${e}px`:e}function yu(e){return new uA(e)}var tk=class{constructor(){this._hooks=new La,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(ni(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Xs(e)}this._hooks.add(nt(c,qi.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(nt(c,qi.POINTER_UP,u=>this.stopMonitoring(!0)))}};function dA(e,t,n){let r=null,o=null;if(typeof n.value=="function"?(r="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(r="get",o=n.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;n[r]=function(...u){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[c]}}var Vs;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Vs||={});var nu=class mn extends vt{constructor(){super(),this.dispatched=!1,this.targets=new Iw,this.ignoreTargets=new Iw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ln.runAndSubscribe(aA,({window:t,disposables:n})=>{n.add(nt(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),n.add(nt(t.document,"touchend",r=>this.onTouchEnd(t,r))),n.add(nt(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Lr,disposables:this._store}))}static addTarget(t){if(!mn.isTouchDevice())return vt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.targets.push(t);return ni(n)}static ignoreTarget(t){if(!mn.isTouchDevice())return vt.None;mn.INSTANCE||(mn.INSTANCE=new mn);let n=mn.INSTANCE.ignoreTargets.push(t);return ni(n)}static isTouchDevice(){return"ontouchstart"in Lr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:n,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[n],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let u=this.newGestureEvent(Vs.Start,c.target);u.pageX=c.pageX,u.pageY=c.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,u=n.changedTouches.length;c<u;c++){let m=n.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(m.identifier))){console.warn("move of an UNKNOWN touch",m);continue}let g=this.activeTouches[m.identifier],p=Date.now()-g.initialTimeStamp;if(p<mn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Vs.Tap,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(p>=mn.HOLD_DELAY&&Math.abs(g.initialPageX-$n(g.rollingPageX))<30&&Math.abs(g.initialPageY-$n(g.rollingPageY))<30){let y=this.newGestureEvent(Vs.Contextmenu,g.initialTarget);y.pageX=$n(g.rollingPageX),y.pageY=$n(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=$n(g.rollingPageX),b=$n(g.rollingPageY),C=$n(g.rollingTimestamps)-g.rollingTimestamps[0],k=y-g.rollingPageX[0],S=b-g.rollingPageY[0],D=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,D,r,Math.abs(k)/C,k>0?1:-1,y,Math.abs(S)/C,S>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Vs.End,g.initialTarget)),delete this.activeTouches[m.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=n,r.tapCount=0,r}dispatchEvent(t){if(t.type===Vs.Tap){let n=new Date().getTime(),r=0;n-this._lastSetTapCountTime>mn.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Vs.Change||t.type===Vs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let n=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;n.push([o,r])}n.sort((r,o)=>r[0]-o[0]);for(let[r,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,o,c,u,m,g,p){this.handle=kb(t,()=>{let y=Date.now(),b=y-r,C=0,k=0,S=!0;o+=mn.SCROLL_FRICTION*b,m+=mn.SCROLL_FRICTION*b,o>0&&(S=!1,C=c*o*b),m>0&&(S=!1,k=g*m*b);let D=this.newGestureEvent(Vs.Change);D.translationX=C,D.translationY=k,n.forEach(B=>B.dispatchEvent(D)),S||this.inertia(t,n,y,o,c,u+C,m,g,p+k)})}onTouchMove(t){let n=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let u=this.activeTouches[c.identifier],m=this.newGestureEvent(Vs.Change,u.initialTarget);m.translationX=c.pageX-$n(u.rollingPageX),m.translationY=c.pageY-$n(u.rollingPageY),m.pageX=c.pageX,m.pageY=c.pageY,this.dispatchEvent(m),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(c.pageX),u.rollingPageY.push(c.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};nu.SCROLL_FRICTION=-.005,nu.HOLD_DELAY=700,nu.CLEAR_TAP_COUNT_TIME=400,mi([dA],nu,"isTouchDevice",1);var hA=nu,Tb=class extends vt{onclick(e,t){this._register(nt(e,qi.CLICK,n=>t(new Sh(Xs(e),n))))}onmousedown(e,t){this._register(nt(e,qi.MOUSE_DOWN,n=>t(new Sh(Xs(e),n))))}onmouseover(e,t){this._register(nt(e,qi.MOUSE_OVER,n=>t(new Sh(Xs(e),n))))}onmouseleave(e,t){this._register(nt(e,qi.MOUSE_LEAVE,n=>t(new Sh(Xs(e),n))))}onkeydown(e,t){this._register(nt(e,qi.KEY_DOWN,n=>t(new Kw(n))))}onkeyup(e,t){this._register(nt(e,qi.KEY_UP,n=>t(new Kw(n))))}oninput(e,t){this._register(nt(e,qi.INPUT,t))}onblur(e,t){this._register(nt(e,qi.BLUR,t))}onfocus(e,t){this._register(nt(e,qi.FOCUS,t))}onchange(e,t){this._register(nt(e,qi.CHANGE,t))}ignoreGesture(e){return hA.ignoreTarget(e)}},Yw=11,fA=class extends Tb{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=Yw+"px",this.domNode.style.height=Yw+"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 tk),this._register(qw(this.bgDomNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(qw(this.domNode,qi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new lA),this._pointerdownScheduleRepeatTimer=this._register(new xb)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Xs(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()}},pA=class Iv{constructor(t,n,r,o,c,u,m){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,r=r|0,o=o|0,c=c|0,u=u|0,m=m|0),this.rawScrollLeft=o,this.rawScrollTop=m,n<0&&(n=0),o+n>r&&(o=r-n),o<0&&(o=0),c<0&&(c=0),m+c>u&&(m=u-c),m<0&&(m=0),this.width=n,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=u,this.scrollTop=m}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new Iv(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 Iv(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,m=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:u,scrollHeightChanged:m,scrollTopChanged:g}}},mA=class extends vt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new pA(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;t?r=new Gw(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Gw.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)))}},Xw=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function mg(e,t){let n=t-e;return function(r){return e+n*_A(r)}}function gA(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Gw=class zv{constructor(t,n,r,o){this.from=t,this.to=n,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,r){if(Math.abs(t-n)>2.5*r){let o,c;return t<n?(o=t+.75*r,c=n-.75*r):(o=t-.75*r,c=n+.75*r),gA(mg(t,o),mg(c,n),.33)}return mg(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let r=this.scrollLeft(n),o=this.scrollTop(n);return new Xw(r,o,!1)}return new Xw(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return zv.start(t,n,r)}static start(t,n,r){r=r+10;let o=Date.now()-10;return new zv(t,n,o,r)}};function vA(e){return Math.pow(e,3)}function _A(e){return 1-vA(1-e)}var bA=class extends vt{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 xb)}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":"")))}},yA=140,ik=class extends Tb{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 bA(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new tk),this._shouldRender=!0,this.domNode=yu(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(nt(this.domNode.domNode,qi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new fA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=yu(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(nt(this.slider.domNode,qi.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=cA(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),u=Math.abs(c-n);if(Zx&&u>yA){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let m=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(m))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},nk=class Pv{constructor(t,n,r,o,c,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pv(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,r,o,c){let u=Math.max(0,r-t),m=Math.max(0,u-2*n),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(m),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*m/o))),y=(m-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(u),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Pv._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,r=this._scrollPosition;return n<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},SA=class extends ik{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new nk(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},wA=class extends ik{constructor(e,t,n){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new nk(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},CA=500,Zw=50,xA=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Hv=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,n+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(wb){let n=Xs(t.browserEvent),r=BN(n);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,r){let o=null,c=new xA(t,n,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),n){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),u=Math.abs(n.deltaX),m=Math.abs(n.deltaY),g=Math.max(Math.min(o,u),1),p=Math.max(Math.min(c,m),1),y=Math.max(o,u),b=Math.max(c,m);y%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Hv.INSTANCE=new Hv;var kA=Hv,TA=class extends Tb{constructor(e,t,n){super(),this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Le),this.onWillScroll=this._onWillScroll.event,this._options=DA(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new wA(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new SA(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=yu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=yu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=yu(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new xb),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Eo(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,Gs&&(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 Ww(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Eo(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Ww(n))};this._mouseWheelToDispose.push(nt(this._listenOnDomNode,qi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=kA.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let u=!Gs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=Zw*o,y=m.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=Zw*c,y=m.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(m.scrollLeft!==g.scrollLeft||m.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?" left":"",o=t?" top":"",c=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),CA)}},EA=class extends TA{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 DA(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,Gs&&(t.className+=" mac"),t}var Uv=class extends vt{constructor(e,t,n,r,o,c,u,m){super(),this._bufferService=n,this._optionsService=u,this._renderService=m,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new mA({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>kb(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new EA(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ln.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ni(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ni(()=>this._styleElement.remove())),this._register(ln.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
25
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Uv=mi([ze(2,xn),ze(3,zr),ze(4,Ix),ze(5,ql),ze(6,kn),ze(7,Pr)],Uv);var Kv=class extends vt{constructor(e,t,n,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(ni(()=>{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()}};Kv=mi([ze(1,xn),ze(2,zr),ze(3,Xu),ze(4,Pr)],Kv);var RA=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)}},$s={full:0,left:0,center:0,right:0},Ca={full:0,left:0,center:0,right:0},qc={full:0,left:0,center:0,right:0},of=class extends vt{constructor(e,t,n,r,o,c,u,m){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=u,this._coreBrowserService=m,this._colorZoneStore=new RA,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(ni(()=>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);Ca.full=this._canvas.width,Ca.left=e,Ca.center=t,Ca.right=e,this._refreshDrawHeightConstants(),qc.full=1,qc.left=1,qc.center=1+Ca.left,qc.right=1+Ca.left+Ca.center}_refreshDrawHeightConstants(){$s.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);$s.left=t,$s.center=t,$s.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$s.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$s.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$s.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*$s.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(qc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-$s[e.position||"full"]/2),Ca[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+$s[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}))}};of=mi([ze(2,xn),ze(3,Xu),ze(4,Pr),ze(5,kn),ze(6,ql),ze(7,zr)],of);var be;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
26
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(be||={});var Uh;(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=""))(Uh||={});var sk;(e=>e.ST=`${be.ESC}\\`)(sk||={});var Fv=class{constructor(e,t,n,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${be.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Fv=mi([ze(2,xn),ze(3,kn),ze(4,Ao),ze(5,Pr)],Fv);var Xi=0,Gi=0,Zi=0,pi=0,Qw={css:"#00000000",rgba:0},Ai;(e=>{function t(o,c,u,m){return m!==void 0?`#${vo(o)}${vo(c)}${vo(u)}${vo(m)}`:`#${vo(o)}${vo(c)}${vo(u)}`}e.toCss=t;function n(o,c,u,m=255){return(o<<24|c<<16|u<<8|m)>>>0}e.toRgba=n;function r(o,c,u,m){return{css:e.toCss(o,c,u,m),rgba:e.toRgba(o,c,u,m)}}e.toColor=r})(Ai||={});var Jt;(e=>{function t(g,p){if(pi=(p.rgba&255)/255,pi===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,C=p.rgba>>8&255,k=g.rgba>>24&255,S=g.rgba>>16&255,D=g.rgba>>8&255;Xi=k+Math.round((y-k)*pi),Gi=S+Math.round((b-S)*pi),Zi=D+Math.round((C-D)*pi);let B=Ai.toCss(Xi,Gi,Zi),A=Ai.toRgba(Xi,Gi,Zi);return{css:B,rgba:A}}e.blend=t;function n(g){return(g.rgba&255)===255}e.isOpaque=n;function r(g,p,y){let b=Kh.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return Ai.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Xi,Gi,Zi]=Kh.toChannels(p),{css:Ai.toCss(Xi,Gi,Zi),rgba:p}}e.opaque=o;function c(g,p){return pi=Math.round(p*255),[Xi,Gi,Zi]=Kh.toChannels(g.rgba),{css:Ai.toCss(Xi,Gi,Zi,pi),rgba:Ai.toRgba(Xi,Gi,Zi,pi)}}e.opacity=c;function u(g,p){return pi=g.rgba&255,c(g,pi*p/255)}e.multiplyOpacity=u;function m(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=m})(Jt||={});var li;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),Ai.toColor(Xi,Gi,Zi);case 5:return Xi=parseInt(o.slice(1,2).repeat(2),16),Gi=parseInt(o.slice(2,3).repeat(2),16),Zi=parseInt(o.slice(3,4).repeat(2),16),pi=parseInt(o.slice(4,5).repeat(2),16),Ai.toColor(Xi,Gi,Zi,pi);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Xi=parseInt(c[1]),Gi=parseInt(c[2]),Zi=parseInt(c[3]),pi=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Ai.toColor(Xi,Gi,Zi,pi);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Xi,Gi,Zi,pi]=t.getImageData(0,0,1,1).data,pi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ai.toRgba(Xi,Gi,Zi,pi),css:o}}e.toColor=r})(li||={});var Cn;(e=>{function t(r){return n(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function n(r,o,c){let u=r/255,m=o/255,g=c/255,p=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),y=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+y*.7152+b*.0722}e.relativeLuminance2=n})(Cn||={});var Kh;(e=>{function t(u,m){if(pi=(m&255)/255,pi===1)return m;let g=m>>24&255,p=m>>16&255,y=m>>8&255,b=u>>24&255,C=u>>16&255,k=u>>8&255;return Xi=b+Math.round((g-b)*pi),Gi=C+Math.round((p-C)*pi),Zi=k+Math.round((y-k)*pi),Ai.toRgba(Xi,Gi,Zi)}e.blend=t;function n(u,m,g){let p=Cn.relativeLuminance(u>>8),y=Cn.relativeLuminance(m>>8);if(Dr(p,y)<g){if(y<p){let k=r(u,m,g),S=Dr(p,Cn.relativeLuminance(k>>8));if(S<g){let D=o(u,m,g),B=Dr(p,Cn.relativeLuminance(D>>8));return S>B?k:D}return k}let b=o(u,m,g),C=Dr(p,Cn.relativeLuminance(b>>8));if(C<g){let k=r(u,m,g),S=Dr(p,Cn.relativeLuminance(k>>8));return C>S?b:k}return b}}e.ensureContrastRatio=n;function r(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,C=m>>24&255,k=m>>16&255,S=m>>8&255,D=Dr(Cn.relativeLuminance2(C,k,S),Cn.relativeLuminance2(p,y,b));for(;D<g&&(C>0||k>0||S>0);)C-=Math.max(0,Math.ceil(C*.1)),k-=Math.max(0,Math.ceil(k*.1)),S-=Math.max(0,Math.ceil(S*.1)),D=Dr(Cn.relativeLuminance2(C,k,S),Cn.relativeLuminance2(p,y,b));return(C<<24|k<<16|S<<8|255)>>>0}e.reduceLuminance=r;function o(u,m,g){let p=u>>24&255,y=u>>16&255,b=u>>8&255,C=m>>24&255,k=m>>16&255,S=m>>8&255,D=Dr(Cn.relativeLuminance2(C,k,S),Cn.relativeLuminance2(p,y,b));for(;D<g&&(C<255||k<255||S<255);)C=Math.min(255,C+Math.ceil((255-C)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),D=Dr(Cn.relativeLuminance2(C,k,S),Cn.relativeLuminance2(p,y,b));return(C<<24|k<<16|S<<8|255)>>>0}e.increaseLuminance=o;function c(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=c})(Kh||={});function vo(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Dr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var MA=class extends Yu{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},lf=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ds}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),o=0,c=0,u=0,m=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==m||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,u,c,t,o);for(let b=0;b<y.length;b++)n.push(y[b])}o=p,u=c,m=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Na.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,u,c,t,o);for(let y=0;y<p.length;y++)n.push(p[y])}return n}_getJoinedRanges(e,t,n,r,o){let c=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(c)}catch(m){console.error(m)}for(let m=1;m<this._characterJoiners.length;m++)try{let g=this._characterJoiners[m].handler(c);for(let p=0;p<g.length;p++)lf._mergeRanges(u,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(u,r,o),u}_stringRangesToCellRanges(e,t,n){let r=0,o=!1,c=0,u=e[r];if(u){for(let m=n;m<this._bufferService.cols;m++){let g=t.getWidth(m),p=t.getString(m).length||Na.length;if(g!==0){if(!o&&u[0]<=c&&(u[0]=m,o=!0),u[1]<=c){if(u[1]=m,u=e[++r],!u)break;u[0]<=c?(u[0]=m,o=!0):o=!1}c+=p}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(n){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};lf=mi([ze(0,xn)],lf);function NA(e){return 57508<=e&&e<=57558}function AA(e){return 9472<=e&&e<=9631}function LA(e){return NA(e)||AA(e)}function OA(){return{css:{canvas:wh(),cell:wh()},device:{canvas:wh(),cell:wh(),char:{width:0,height:0,left:0,top:0}}}}function wh(){return{width:0,height:0}}var Wv=class{constructor(e,t,n,r,o,c,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=u,this._workCell=new ds,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,o,c,u,m,g,p,y){let b=[],C=this._characterJoinerService.getJoinedCharacters(t),k=this._themeService.colors,S=e.getNoBgTrimmedLength();n&&S<c+1&&(S=c+1);let D,B=0,A="",H=0,Y=0,$=0,se=0,J=!1,W=0,xe=!1,re=0,Ee=0,ie=[],V=p!==-1&&y!==-1;for(let X=0;X<S;X++){e.loadCell(X,this._workCell);let F=this._workCell.getWidth();if(F===0)continue;let le=!1,O=X>=Ee,M=X,j=this._workCell;if(C.length>0&&X===C[0][0]&&O){let R=C.shift(),q=this._isCellInSelection(R[0],t);for(H=R[0]+1;H<R[1];H++)O&&=q===this._isCellInSelection(H,t);O&&=!n||c<R[0]||c>=R[1],O?(le=!0,j=new MA(this._workCell,e.translateToString(!0,R[0],R[1]),R[1]-R[0]),M=R[1]-1,F=j.getWidth()):Ee=R[1]}let ae=this._isCellInSelection(X,t),we=n&&X===c,N=V&&X>=p&&X<=y,U=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,R=>{U=!0});let ue=j.getChars()||Na;if(ue===" "&&(j.isUnderline()||j.isOverline())&&(ue=" "),re=F*m-g.get(ue,j.isBold(),j.isItalic()),!D)D=this._document.createElement("span");else if(B&&(ae&&xe||!ae&&!xe&&j.bg===Y)&&(ae&&xe&&k.selectionForeground||j.fg===$)&&j.extended.ext===se&&N===J&&re===W&&!we&&!le&&!U&&O){j.isInvisible()?A+=Na:A+=ue,B++;continue}else B&&(D.textContent=A),D=this._document.createElement("span"),B=0,A="";if(Y=j.bg,$=j.fg,se=j.extended.ext,J=N,W=re,xe=ae,le&&c>=X&&c<=M&&(c=X),!this._coreService.isCursorHidden&&we&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&ie.push("xterm-cursor-blink"),ie.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(j.isBold()&&ie.push("xterm-bold"),j.isItalic()&&ie.push("xterm-italic"),j.isDim()&&ie.push("xterm-dim"),j.isInvisible()?A=Na:A=j.getChars()||Na,j.isUnderline()&&(ie.push(`xterm-underline-${j.extended.underlineStyle}`),A===" "&&(A=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${Yu.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let R=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&R<8&&(R+=8),D.style.textDecorationColor=k.ansi[R].css}j.isOverline()&&(ie.push("xterm-overline"),A===" "&&(A=" ")),j.isStrikethrough()&&ie.push("xterm-strikethrough"),N&&(D.style.textDecoration="underline");let Ce=j.getFgColor(),Oe=j.getFgColorMode(),De=j.getBgColor(),Be=j.getBgColorMode(),Ne=!!j.isInverse();if(Ne){let R=Ce;Ce=De,De=R;let q=Oe;Oe=Be,Be=q}let Ue,Fe,ne=!1;this._decorationService.forEachDecorationAtCell(X,t,void 0,R=>{R.options.layer!=="top"&&ne||(R.backgroundColorRGB&&(Be=50331648,De=R.backgroundColorRGB.rgba>>8&16777215,Ue=R.backgroundColorRGB),R.foregroundColorRGB&&(Oe=50331648,Ce=R.foregroundColorRGB.rgba>>8&16777215,Fe=R.foregroundColorRGB),ne=R.options.layer==="top")}),!ne&&ae&&(Ue=this._coreBrowserService.isFocused?k.selectionBackgroundOpaque:k.selectionInactiveBackgroundOpaque,De=Ue.rgba>>8&16777215,Be=50331648,ne=!0,k.selectionForeground&&(Oe=50331648,Ce=k.selectionForeground.rgba>>8&16777215,Fe=k.selectionForeground)),ne&&ie.push("xterm-decoration-top");let me;switch(Be){case 16777216:case 33554432:me=k.ansi[De],ie.push(`xterm-bg-${De}`);break;case 50331648:me=Ai.toColor(De>>16,De>>8&255,De&255),this._addStyle(D,`background-color:#${Jw((De>>>0).toString(16),"0",6)}`);break;default:Ne?(me=k.foreground,ie.push("xterm-bg-257")):me=k.background}switch(Ue||j.isDim()&&(Ue=Jt.multiplyOpacity(me,.5)),Oe){case 16777216:case 33554432:j.isBold()&&Ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ce+=8),this._applyMinimumContrast(D,me,k.ansi[Ce],j,Ue,void 0)||ie.push(`xterm-fg-${Ce}`);break;case 50331648:let R=Ai.toColor(Ce>>16&255,Ce>>8&255,Ce&255);this._applyMinimumContrast(D,me,R,j,Ue,Fe)||this._addStyle(D,`color:#${Jw(Ce.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,me,k.foreground,j,Ue,Fe)||Ne&&ie.push("xterm-fg-257")}ie.length&&(D.className=ie.join(" "),ie.length=0),!we&&!le&&!U&&O?B++:D.textContent=A,re!==this.defaultSpacing&&(D.style.letterSpacing=`${re}px`),b.push(D),X=M}return D&&B&&(D.textContent=A),b}_applyMinimumContrast(e,t,n,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||LA(r.getCode()))return!1;let u=this._getContrastCache(r),m;if(!o&&!c&&(m=u.getColor(t.rgba,n.rgba)),m===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);m=Jt.ensureContrastRatio(o||t,c||n,g),u.setColor((o||t).rgba,(c||n).rgba,m??null)}return m?(this._addStyle(e,`color:${m.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Wv=mi([ze(1,Hx),ze(2,kn),ze(3,zr),ze(4,Ao),ze(5,Xu),ze(6,ql)],Wv);function Jw(e,t,n){for(;e.length<n;)e=t+e;return e}var BA=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[n,r,o,c],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let u=this._measure(e,0);return u>0&&(this._flat[r]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let c=this._holey.get(o);if(c===void 0){let u=0;t&&(u|=1),n&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},jA=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,u=n[1]-o,m=Math.max(c,0),g=Math.min(u,e.rows-1);if(m>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=u,this.viewportCappedStartRow=m,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function IA(){return new jA}var gg="xterm-dom-renderer-owner-",as="xterm-rows",Ch="xterm-fg-",e1="xterm-bg-",Vc="xterm-focus",xh="xterm-selection",zA=1,$v=class extends vt{constructor(e,t,n,r,o,c,u,m,g,p,y,b,C,k){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=u,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=C,this._themeService=k,this._terminalClass=zA++,this._rowElements=[],this._selectionRenderModel=IA(),this.onRequestRedraw=this._register(new Le).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(as),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(xh),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=OA(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=m.createInstance(Wv,document),this._element.classList.add(gg+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(ni(()=>{this._element.classList.remove(gg+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new BA(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} .${as} 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} .${as} { 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} .${as} .xterm-dim { color: ${Jt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${as}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${as}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${as}.${Vc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${as} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${as} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${as} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${as} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${as} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${xh} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${xh} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${xh} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Ch}${c} { color: ${u.css}; }${this._terminalSelector} .${Ch}${c}.xterm-dim { color: ${Jt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${e1}${c} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Ch}257 { color: ${Jt.opaque(e.background).css}; }${this._terminalSelector} .${Ch}257.xterm-dim { color: ${Jt.multiplyOpacity(Jt.opaque(e.background),.5).css}; }${this._terminalSelector} .${e1}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Vc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vc),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,m=this._document.createDocumentFragment();if(n){let g=e[0]>t[0];m.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],u-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(c,g,p));let y=u-c-1;if(m.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==u){let b=o===u?t[0]:this._bufferService.cols;m.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(m)}_createSelectionElement(e,t,n,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+n.ydisp,y=this._rowElements[g],b=n.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,u,m,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${gg}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,o,c){n<0&&(e=0),r<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),r=Math.max(Math.min(r,u),0),o=Math.min(o,this._bufferService.cols);let m=this._bufferService.buffer,g=m.ybase+m.y,p=Math.min(m.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,C=this._optionsService.rawOptions.cursorInactiveStyle;for(let k=n;k<=r;++k){let S=k+m.ydisp,D=this._rowElements[k],B=m.lines.get(S);if(!D||!B)break;D.replaceChildren(...this._rowFactory.createRow(B,S,S===g,b,C,p,y,this.dimensions.css.cell.width,this._widthCache,c?k===n?e:0:-1,c?(k===r?t:o)-1:-1))}}};$v=mi([ze(7,bb),ze(8,zf),ze(9,kn),ze(10,xn),ze(11,Ao),ze(12,zr),ze(13,ql)],$v);var qv=class extends vt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Le),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new HA(this._optionsService))}catch{this._measureStrategy=this._register(new PA(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())}};qv=mi([ze(2,kn)],qv);var rk=class extends vt{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)}},PA=class extends rk{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}},HA=class extends rk{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}},UA=class extends vt{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 KA(this._window)),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Le),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(ln.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(nt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(nt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},KA=class extends vt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Pl),this._onDprChange=this._register(new Le),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ni(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=nt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},FA=class extends vt{constructor(){super(),this.linkProviders=[],this._register(ni(()=>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 Eb(e,t,n){let r=n.getBoundingClientRect(),o=e.getComputedStyle(n),c=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-u]}function WA(e,t,n,r,o,c,u,m,g){if(!c)return;let p=Eb(e,t,n);if(p)return p[0]=Math.ceil((p[0]+(g?u/2:0))/u),p[1]=Math.ceil(p[1]/m),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var Vv=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,o){return WA(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Eb(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])}}};Vv=mi([ze(0,Pr),ze(1,zf)],Vv);var $A=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=[]}},ak={};tN(ak,{getSafariVersion:()=>VA,isChromeOS:()=>uk,isFirefox:()=>ok,isIpad:()=>YA,isIphone:()=>XA,isLegacyEdge:()=>qA,isLinux:()=>Db,isMac:()=>cf,isNode:()=>Pf,isSafari:()=>lk,isWindows:()=>ck});var Pf=typeof process<"u"&&"title"in process,Gu=Pf?"node":navigator.userAgent,Zu=Pf?"node":navigator.platform,ok=Gu.includes("Firefox"),qA=Gu.includes("Edge"),lk=/^((?!chrome|android).)*safari/i.test(Gu);function VA(){if(!lk)return 0;let e=Gu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cf=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Zu),YA=Zu==="iPad",XA=Zu==="iPhone",ck=["Windows","Win16","Win32","WinCE"].includes(Zu),Db=Zu.indexOf("Linux")>=0,uk=/\bCrOS\b/.test(Gu),dk=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},GA=class extends dk{_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())}}},ZA=class extends dk{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},uf=!Pf&&"requestIdleCallback"in window?ZA:GA,QA=class{constructor(){this._queue=new uf}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Yv=class extends vt{constructor(e,t,n,r,o,c,u,m,g){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=o,this._coreBrowserService=m,this._renderer=this._register(new Pl),this._pausedResizeTask=new QA,this._observerDisposable=this._register(new Pl),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 Le),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Le),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Le),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new $A((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new JA(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ni(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=ni(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Yv=mi([ze(2,kn),ze(3,zf),ze(4,Ao),ze(5,Xu),ze(6,xn),ze(7,zr),ze(8,ql)],Yv);var JA=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 eL(e,t,n,r){let o=n.buffer.x,c=n.buffer.y;if(!n.buffer.hasScrollback)return nL(o,c,e,t,n,r)+Hf(c,t,n,r)+sL(o,c,e,t,n,r);let u;if(c===t)return u=o>e?"D":"C",Nu(Math.abs(o-e),Mu(u,r));u=c>t?"D":"C";let m=Math.abs(c-t),g=iL(c>t?e:o,n)+(m-1)*n.cols+1+tL(c>t?o:e);return Nu(g,Mu(u,r))}function tL(e,t){return e-1}function iL(e,t){return t.cols-e}function nL(e,t,n,r,o,c){return Hf(t,r,o,c).length===0?"":Nu(fk(e,t,e,t-Do(t,o),!1,o).length,Mu("D",c))}function Hf(e,t,n,r){let o=e-Do(e,n),c=t-Do(t,n),u=Math.abs(o-c)-rL(e,t,n);return Nu(u,Mu(hk(e,t),r))}function sL(e,t,n,r,o,c){let u;Hf(t,r,o,c).length>0?u=r-Do(r,o):u=t;let m=r,g=aL(e,t,n,r,o,c);return Nu(fk(e,u,n,m,g==="C",o).length,Mu(g,c))}function rL(e,t,n){let r=0,o=e-Do(e,n),c=t-Do(t,n);for(let u=0;u<Math.abs(o-c);u++){let m=hk(e,t)==="A"?-1:1;n.buffer.lines.get(o+m*u)?.isWrapped&&r++}return r}function Do(e,t){let n=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return n}function aL(e,t,n,r,o,c){let u;return Hf(n,r,o,c).length>0?u=r-Do(r,o):u=t,e<n&&u<=r||e>=n&&u<r?"C":"D"}function hk(e,t){return e>t?"A":"B"}function fk(e,t,n,r,o,c){let u=e,m=t,g="";for(;(u!==n||m!==r)&&m>=0&&m<c.buffer.lines.length;)u+=o?1:-1,o&&u>c.cols-1?(g+=c.buffer.translateBufferLineToString(m,!1,e,u),u=0,e=0,m++):!o&&u<0&&(g+=c.buffer.translateBufferLineToString(m,!1,0,e+1),u=c.cols-1,e=u,m--);return g+c.buffer.translateBufferLineToString(m,!1,e,u)}function Mu(e,t){let n=t?"O":"[";return be.ESC+n+e}function Nu(e,t){e=Math.floor(e);let n="";for(let r=0;r<e;r++)n+=t;return n}var oL=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 t1(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 vg=50,lL=15,cL=50,uL=500,dL=" ",hL=new RegExp(dL,"g"),Xv=class extends vt{constructor(e,t,n,r,o,c,u,m,g){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=u,this._renderService=m,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ds,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Le),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Le),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Le),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new oL(this._bufferService),this._activeSelectionMode=0,this._register(ni(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let m=n.translateBufferLineToString(u,!0,o,c);r.push(m)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let u=n.lines.get(c),m=n.translateBufferLineToString(c,!0);u?.isWrapped?r[r.length-1]+=m:r.push(m)}if(e[1]!==t[1]){let c=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=u:r.push(u)}}return r.map(o=>o.replace(hL," ")).join(ck?`\r
|
|
27
|
-
`:`
|
|
28
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Db&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=t1(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Eb(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,-vg),vg),t/=vg,t/Math.abs(t)+Math.round(t*(lL-1)))}shouldForceSelection(e){return cf?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(),cL)}_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&&!(cf&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<uL&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=eL(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==r&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let u=o.translateBufferLineToString(e[1],!1),m=this._convertViewportColToCharacterIndex(c,e[0]),g=m,p=e[0]-m,y=0,b=0,C=0,k=0;if(u.charAt(m)===" "){for(;m>0&&u.charAt(m-1)===" ";)m--;for(;g<u.length&&u.charAt(g+1)===" ";)g++}else{let B=e[0],A=e[0];c.getWidth(B)===0&&(y++,B--),c.getWidth(A)===2&&(b++,A++);let H=c.getString(A).length;for(H>1&&(k+=H-1,g+=H-1);B>0&&m>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,B--):Y>1&&(C+=Y-1,m-=Y-1),m--,B--}for(;A<c.length&&g+1<u.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?(b++,A++):Y>1&&(k+=Y-1,g+=Y-1),g++,A++}}g++;let S=m+p-y+C,D=Math.min(this._bufferService.cols,g-m+y+b-C-k);if(!(!t&&u.slice(m,g).trim()==="")){if(n&&S===0&&c.getCodePoint(0)!==32){let B=o.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let H=this._bufferService.cols-A.start;S-=H,D+=H}}}if(r&&S+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=o.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(D+=A.length)}}return{start:S,length:D}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=t1(n,this._bufferService.cols)}};Xv=mi([ze(3,xn),ze(4,Ao),ze(5,yb),ze(6,kn),ze(7,Pr),ze(8,zr)],Xv);var i1=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={}}},n1=class{constructor(){this._color=new i1,this._css=new i1}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()}},ji=Object.freeze((()=>{let e=[li.toColor("#2e3436"),li.toColor("#cc0000"),li.toColor("#4e9a06"),li.toColor("#c4a000"),li.toColor("#3465a4"),li.toColor("#75507b"),li.toColor("#06989a"),li.toColor("#d3d7cf"),li.toColor("#555753"),li.toColor("#ef2929"),li.toColor("#8ae234"),li.toColor("#fce94f"),li.toColor("#729fcf"),li.toColor("#ad7fa8"),li.toColor("#34e2e2"),li.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],o=t[n/6%6|0],c=t[n%6];e.push({css:Ai.toCss(r,o,c),rgba:Ai.toRgba(r,o,c)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Ai.toCss(r,r,r),rgba:Ai.toRgba(r,r,r)})}return e})()),_o=li.toColor("#ffffff"),su=li.toColor("#000000"),s1=li.toColor("#ffffff"),r1=su,Yc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},fL=_o,Gv=class extends vt{constructor(e){super(),this._optionsService=e,this._contrastCache=new n1,this._halfContrastCache=new n1,this._onChangeColors=this._register(new Le),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_o,background:su,cursor:s1,cursorAccent:r1,selectionForeground:void 0,selectionBackgroundTransparent:Yc,selectionBackgroundOpaque:Jt.blend(su,Yc),selectionInactiveBackgroundTransparent:Yc,selectionInactiveBackgroundOpaque:Jt.blend(su,Yc),scrollbarSliderBackground:Jt.opacity(_o,.2),scrollbarSliderHoverBackground:Jt.opacity(_o,.4),scrollbarSliderActiveBackground:Jt.opacity(_o,.5),overviewRulerBorder:_o,ansi:ji.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=Kt(e.foreground,_o),t.background=Kt(e.background,su),t.cursor=Jt.blend(t.background,Kt(e.cursor,s1)),t.cursorAccent=Jt.blend(t.background,Kt(e.cursorAccent,r1)),t.selectionBackgroundTransparent=Kt(e.selectionBackground,Yc),t.selectionBackgroundOpaque=Jt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Kt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Jt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Kt(e.selectionForeground,Qw):void 0,t.selectionForeground===Qw&&(t.selectionForeground=void 0),Jt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Jt.opacity(t.selectionBackgroundTransparent,.3)),Jt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Jt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Kt(e.scrollbarSliderBackground,Jt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Kt(e.scrollbarSliderHoverBackground,Jt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Kt(e.scrollbarSliderActiveBackground,Jt.opacity(t.foreground,.5)),t.overviewRulerBorder=Kt(e.overviewRulerBorder,fL),t.ansi=ji.slice(),t.ansi[0]=Kt(e.black,ji[0]),t.ansi[1]=Kt(e.red,ji[1]),t.ansi[2]=Kt(e.green,ji[2]),t.ansi[3]=Kt(e.yellow,ji[3]),t.ansi[4]=Kt(e.blue,ji[4]),t.ansi[5]=Kt(e.magenta,ji[5]),t.ansi[6]=Kt(e.cyan,ji[6]),t.ansi[7]=Kt(e.white,ji[7]),t.ansi[8]=Kt(e.brightBlack,ji[8]),t.ansi[9]=Kt(e.brightRed,ji[9]),t.ansi[10]=Kt(e.brightGreen,ji[10]),t.ansi[11]=Kt(e.brightYellow,ji[11]),t.ansi[12]=Kt(e.brightBlue,ji[12]),t.ansi[13]=Kt(e.brightMagenta,ji[13]),t.ansi[14]=Kt(e.brightCyan,ji[14]),t.ansi[15]=Kt(e.brightWhite,ji[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=Kt(e.extendedAnsi[r],ji[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Gv=mi([ze(0,kn)],Gv);function Kt(e,t){if(e!==void 0)try{return li.toColor(e)}catch{}return t}var pL=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)}},mL=class{constructor(){this._services=new pL,this._services.set(bb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=lN(e).sort((c,u)=>c.index-u.index),r=[];for(let c of n){let u=this._services.get(c.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},gL={trace:0,debug:1,info:2,warn:3,error:4,off:5},vL="xterm.js: ",Zv=class extends vt{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=gL[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?"":vL)+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)}};Zv=mi([ze(0,kn)],Zv);var a1=class extends vt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Le),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Le),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Le),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},gt=3,Mi=Object.freeze(new Yu),kh=0,_g=2,ru=class pk{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*gt);let o=n||ds.fromCharData([0,Lx,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let n=this._data[t*gt+0],r=n&2097151;return[this._data[t*gt+1],n&2097152?this._combined[t]:r?Ra(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*gt+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*gt+0]=t|2097152|n[2]<<22):this._data[t*gt+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*gt+0]>>22}hasWidth(t){return this._data[t*gt+0]&12582912}getFg(t){return this._data[t*gt+1]}getBg(t){return this._data[t*gt+2]}hasContent(t){return this._data[t*gt+0]&4194303}getCodePoint(t){let n=this._data[t*gt+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*gt+0]&2097152}getString(t){let n=this._data[t*gt+0];return n&2097152?this._combined[t]:n&2097151?Ra(n&2097151):""}isProtected(t){return this._data[t*gt+2]&536870912}loadCell(t,n){return kh=t*gt,n.content=this._data[kh+0],n.fg=this._data[kh+1],n.bg=this._data[kh+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*gt+0]=n.content,this._data[t*gt+1]=n.fg,this._data[t*gt+2]=n.bg}setCellFromCodepoint(t,n,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*gt+0]=n|r<<22,this._data[t*gt+1]=o.fg,this._data[t*gt+2]=o.bg}addCodepointToCell(t,n,r){let o=this._data[t*gt+0];o&2097152?this._combined[t]+=Ra(n):o&2097151?(this._combined[t]=Ra(o&2097151)+Ra(n),o&=-2097152,o|=2097152):o=n|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*gt+0]=o}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let o=new ds;for(let c=this.length-t-n-1;c>=0;--c)this.setCell(t+n+c,this.loadCell(t+c,o));for(let c=0;c<n;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let o=new ds;for(let c=0;c<this.length-t-n;++c)this.setCell(t+c,this.loadCell(t+n+c,o));for(let c=this.length-n;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*_g<this._data.buffer.byteLength;let r=t*gt;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let m=parseInt(o[u],10);m>=t&&delete this._combined[m]}let c=Object.keys(this._extendedAttrs);for(let u=0;u<c.length;u++){let m=parseInt(c[u],10);m>=t&&delete this._extendedAttrs[m]}}return this.length=t,r*4*_g<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*_g<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new pk(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*gt+0]&4194303)return t+(this._data[t*gt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*gt+0]&4194303||this._data[t*gt+2]&50331648)return t+(this._data[t*gt+0]>>22);return 0}copyCellsFrom(t,n,r,o,c){let u=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<gt;p++)this._data[(r+g)*gt+p]=u[(n+g)*gt+p];u[(n+g)*gt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}else for(let g=0;g<o;g++){for(let p=0;p<gt;p++)this._data[(r+g)*gt+p]=u[(n+g)*gt+p];u[(n+g)*gt+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[n+g])}let m=Object.keys(t._combined);for(let g=0;g<m.length;g++){let p=parseInt(m[g],10);p>=n&&(this._combined[p-n+r]=t._combined[p])}}translateToString(t,n,r,o){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;n<r;){let u=this._data[n*gt+0],m=u&2097151,g=u&2097152?this._combined[n]:m?Ra(m):Na;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(n);n+=u>>22||1}return o&&o.push(n),c}};function _L(e,t,n,r,o,c){let u=[];for(let m=0;m<e.length-1;m++){let g=m,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(m)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=m&&r<g){m+=y.length-1;continue}let b=0,C=Au(y,b,t),k=1,S=0;for(;k<y.length;){let B=Au(y,k,t),A=B-S,H=n-C,Y=Math.min(A,H);y[b].copyCellsFrom(y[k],S,C,Y,!1),C+=Y,C===n&&(b++,C=0),S+=Y,S===B&&(k++,S=0),C===0&&b!==0&&y[b-1].getWidth(n-1)===2&&(y[b].copyCellsFrom(y[b-1],n-1,C++,1,!1),y[b-1].setCell(n-1,o))}y[b].replaceCells(C,n,o);let D=0;for(let B=y.length-1;B>0&&(B>b||y[B].getTrimmedLength()===0);B--)D++;D>0&&(u.push(m+y.length-D),u.push(D)),m+=y.length-1}return u}function bL(e,t){let n=[],r=0,o=t[r],c=0;for(let u=0;u<e.length;u++)if(o===u){let m=t[++r];e.onDeleteEmitter.fire({index:u-c,amount:m}),u+=m-1,c+=m,o=t[++r]}else n.push(u);return{layout:n,countRemoved:c}}function yL(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function SL(e,t,n){let r=[],o=e.map((g,p)=>Au(e,p,t)).reduce((g,p)=>g+p),c=0,u=0,m=0;for(;m<o;){if(o-m<n){r.push(o-m);break}c+=n;let g=Au(e,u,t);c>g&&(c-=g,u++);let p=e[u].getWidth(c-1)===2;p&&c--;let y=p?n-1:n;r.push(y),m+=y}return r}function Au(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?n-1:n}var mk=class gk{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=gk._nextId++,this._onDispose=this.register(new Le),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Eo(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};mk._nextId=1;var wL=mk,Pi={},bo=Pi.B;Pi[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Pi.A={"#":"£"};Pi.B=void 0;Pi[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pi.C=Pi[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pi.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pi.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pi.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pi.E=Pi[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pi.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pi.H=Pi[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pi["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var o1=4294967295,l1=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Mi.clone(),this.savedCharset=bo,this.markers=[],this._nullCell=ds.fromCharData([0,Lx,1,0]),this._whitespaceCell=ds.fromCharData([0,Na,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new uf,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new a1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new af),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 af),this._whitespaceCell}getBlankLine(e,t){return new ru(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>o1?o1:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Mi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new a1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Mi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)r+=+this.lines.get(u).resize(e,n);let c=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ru(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 ru(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=_L(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Mi),n);if(r.length>0){let o=bL(this.lines,r);yL(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Mi),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ru(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Mi),o=[],c=0;for(let u=this.lines.length-1;u>=0;u--){let m=this.lines.get(u);if(!m||!m.isWrapped&&m.getTrimmedLength()<=e)continue;let g=[m];for(;m.isWrapped&&u>0;)m=this.lines.get(--u),g.unshift(m);if(!n){let Y=this.ybase+this.y;if(Y>=u&&Y<u+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=SL(g,this._cols,e),b=y.length-g.length,C;this.ybase===0&&this.y!==this.lines.length-1?C=Math.max(0,this.y-this.lines.maxLength+b):C=Math.max(0,this.lines.length-this.lines.maxLength+b);let k=[];for(let Y=0;Y<b;Y++){let $=this.getBlankLine(Mi,!0);k.push($)}k.length>0&&(o.push({start:u+g.length+c,newLines:k}),c+=k.length),g.push(...k);let S=y.length-1,D=y[S];D===0&&(S--,D=y[S]);let B=g.length-b-1,A=p;for(;B>=0;){let Y=Math.min(A,D);if(g[S]===void 0)break;if(g[S].copyCellsFrom(g[B],A-Y,D-Y,Y,!0),D-=Y,D===0&&(S--,D=y[S]),A-=Y,A===0){B--;let $=Math.max(B,0);A=Au(g,$,this._cols)}}for(let Y=0;Y<g.length;Y++)y[Y]<e&&g[Y].setCell(y[Y],r);let H=b-C;for(;H-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],m=[];for(let D=0;D<this.lines.length;D++)m.push(this.lines.get(D));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let C=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>p+C){for(let B=b.newLines.length-1;B>=0;B--)this.lines.set(D--,b.newLines[B]);D++,u.push({index:p+1,amount:b.newLines.length}),C+=b.newLines.length,b=o[++y]}else this.lines.set(D,m[p--]);let k=0;for(let D=u.length-1;D>=0;D--)u[D].index+=k,this.lines.onInsertEmitter.fire(u[D]),k+=u[D].amount;let S=Math.max(0,g+c-this.lines.maxLength);S>0&&this.lines.onTrimEmitter.fire(S)}}translateBufferLineToString(e,t,n=0,r){let o=this.lines.get(e);return o?o.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new wL(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)}},CL=class extends vt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Le),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 l1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l1(!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)}},vk=2,_k=1,Qv=class extends vt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vk),this.rows=Math.max(e.rawOptions.rows||0,_k),this.buffers=this._register(new CL(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=n.ybase+n.scrollTop,c=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;c===n.lines.length-1?u?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(c+1,0,r.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=c-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(c,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Qv=mi([ze(0,kn)],Qv);var yl={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:cf,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},xL=["normal","bold","100","200","300","400","500","600","700","800","900"],kL=class extends vt{constructor(e){super(),this._onOptionChange=this._register(new Le),this.onOptionChange=this._onOptionChange.event;let t={...yl};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ni(()=>{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 yl))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in yl))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=yl[e]),!TL(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=yl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=xL.includes(t)?t:yl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function TL(e){return e==="block"||e==="underline"||e==="bar"}function au(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&au(e[r],t-1);return n}var c1=Object.freeze({insertMode:!1}),u1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Jv=class extends vt{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 Le),this.onData=this._onData.event,this._onUserInput=this._register(new Le),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Le),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=au(c1),this.decPrivateModes=au(u1)}reset(){this.modes=au(c1),this.decPrivateModes=au(u1)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Jv=mi([ze(0,xn),ze(1,zx),ze(2,kn)],Jv);var d1={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 bg(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 yg=String.fromCharCode,h1={DEFAULT:e=>{let t=[bg(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${yg(t[0])}${yg(t[1])}${yg(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${bg(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${bg(e,!0)};${e.x};${e.y}${t}`}},e_=class extends vt{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 Le),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(d1))this.addProtocol(r,d1[r]);for(let r of Object.keys(h1))this.addEncoding(r,h1[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};e_=mi([ze(0,xn),ze(1,Ao),ze(2,kn)],e_);var Sg=[[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]],EL=[[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]],Ii;function DL(e,t){let n=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(o=n+r>>1,e>t[o][1])n=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var RL=class{constructor(){if(this.version="6",!Ii){Ii=new Uint8Array(65536),Ii.fill(1),Ii[0]=0,Ii.fill(0,1,32),Ii.fill(0,127,160),Ii.fill(2,4352,4448),Ii[9001]=2,Ii[9002]=2,Ii.fill(2,11904,42192),Ii[12351]=1,Ii.fill(2,44032,55204),Ii.fill(2,63744,64256),Ii.fill(2,65040,65050),Ii.fill(2,65072,65136),Ii.fill(2,65280,65377),Ii.fill(2,65504,65511);for(let e=0;e<Sg.length;++e)Ii.fill(0,Sg[e][0],Sg[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ii[e]:DL(e,EL)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let o=yo.extractWidth(t);o===0?r=!1:o>n&&(n=o)}return yo.createPropertyValue(0,n,r)}},yo=class Fh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Le,this.onChange=this._onChange.event;let t=new RL;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,o=t.length;for(let c=0;c<o;++c){let u=t.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=o)return n+this.wcwidth(u);let p=t.charCodeAt(c);56320<=p&&p<=57343?u=(u-55296)*1024+p-56320+65536:n+=this.wcwidth(p)}let m=this.charProperties(u,r),g=Fh.extractWidth(m);Fh.extractShouldJoin(m)&&(g-=Fh.extractWidth(r)),n+=g,r=m}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},ML=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 f1(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 Xc=2147483647,NL=256,bk=class t_{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>NL)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 t_;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)n.addSubParam(o[c]);else n.addParam(o)}return n}clone(){let t=new t_(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Xc?Xc: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>Xc?Xc:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-r>0&&(t[n]=this._subParams.slice(r,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[n-1];r[n-1]=~o?Math.min(o*10+t,Xc):t}},Gc=[],AL=class{constructor(){this._state=0,this._active=Gc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gc}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=Gc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Gc,!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",If(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Gc,this._id=-1,this._state=0}}},qn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=If(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}},Zc=[],LL=class{constructor(){this._handlers=Object.create(null),this._active=Zc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Zc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Zc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Zc,!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",If(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=Zc,this._ident=0}},ou=new bk;ou.addParam(0);var p1=class{constructor(e){this._handler=e,this._data="",this._params=ou,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ou,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=If(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=ou,this._data="",this._hitLimit=!1,n));return this._params=ou,this._data="",this._hitLimit=!1,t}},OL=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|r}},cs=160,BL=(function(){let e=new OL(4095),t=Array.apply(null,Array(256)).map((m,g)=>g),n=(m,g)=>t.slice(m,g),r=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let c=n(0,14),u;e.setDefault(1,0),e.addMany(r,0,2,0);for(u in c)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(cs,0,2,0),e.add(cs,8,5,8),e.add(cs,6,0,6),e.add(cs,11,0,11),e.add(cs,13,13,13),e})(),jL=class extends vt{constructor(e=BL){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 bk,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ni(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new AL),this._dcsParser=this._register(new LL),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,n){let r=0,o=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let m=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&g>-1){for(;g>=0&&(u=m[g](),u!==!0);g--)if(u instanceof Promise)return this._parseStack.handlerPos=g,u}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],u=this._oscParser.end(r!==24&&r!==26,n),u)return u;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let m=c;m<t;++m){switch(r=e[m],o=this._transitions.table[this.currentState<<8|(r<160?r:cs)],o>>4){case 2:for(let C=m+1;;++C){if(C>=t||(r=e[C])<32||r>126&&r<cs){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<cs){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<cs){this._printHandler(e,m,C),m=C-1;break}if(++C>=t||(r=e[C])<32||r>126&&r<cs){this._printHandler(e,m,C),m=C-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:m,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(u=g[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._preserveStack(3,g,p,o,m),u;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++m<t&&(r=e[m])>47&&r<60);m--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(u=y[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,y,b,o,m),u;b<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let C=m+1;;++C)if(C>=t||(r=e[C])===24||r===26||r===27||r>127&&r<cs){this._dcsParser.put(e,m,C),m=C-1;break}break;case 14:if(u=this._dcsParser.unhook(r!==24&&r!==26),u)return this._preserveStack(6,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let C=m+1;;C++)if(C>=t||(r=e[C])<32||r>127&&r<cs){this._oscParser.put(e,m,C),m=C-1;break}break;case 6:if(u=this._oscParser.end(r!==24&&r!==26),u)return this._preserveStack(5,[],0,o,m),u;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},IL=/^([\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})$/,zL=/^[\da-f]+$/;function m1(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=IL.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),zL.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(n*o,n*o+n),16);r[o]=n===1?c<<4:n===2?c:n===3?c>>4:c>>8}return r}}function wg(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function PL(e,t=16){let[n,r,o]=e;return`rgb:${wg(n,t)}/${wg(r,t)}/${wg(o,t)}`}var HL={"(":0,")":1,"*":2,"+":3,"-":1,".":2},xa=131072,g1=10;function v1(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 _1=5e3,b1=0,UL=class extends vt{constructor(e,t,n,r,o,c,u,m,g=new jL){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=u,this._unicodeService=m,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new aN,this._utf8Decoder=new oN,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.clone(),this._onRequestBell=this._register(new Le),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Le),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Le),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Le),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Le),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Le),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Le),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Le),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Le),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Le),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 i_(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,b)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(be.BEL,()=>this.bell()),this._parser.setExecuteHandler(be.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(be.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(be.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(be.BS,()=>this.backspace()),this._parser.setExecuteHandler(be.HT,()=>this.tab()),this._parser.setExecuteHandler(be.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(be.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Uh.IND,()=>this.index()),this._parser.setExecuteHandler(Uh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Uh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new qn(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new qn(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new qn(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new qn(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new qn(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new qn(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new qn(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new qn(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new qn(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new qn(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new qn(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new qn(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Pi)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new p1((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),_1))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${_1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>xa&&(c=this._parseStack.position+xa)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<xa&&(this._parseBuffer=new Uint32Array(Math.min(e.length,xa))),u||this._dirtyRowTracker.clearRange(),e.length>xa)for(let p=c;p<e.length;p+=xa){let y=p+xa<e.length?p+xa:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(n),n}else if(!u){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let m=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(m,this._bufferService.rows-1)})}print(e,t,n){let r,o,c=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,m=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let C=this._parser.precedingJoinState;for(let k=t;k<n;++k){if(r=e[k],r<127&&c){let A=c[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let S=this._unicodeService.charProperties(r,C);o=yo.extractWidth(S);let D=yo.extractShouldJoin(S),B=D?yo.extractWidth(C):0;if(C=S,u&&this._onA11yChar.fire(Ra(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>m){if(g){let A=b,H=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&b instanceof ru&&b.copyCellsFrom(A,H,0,B,!1);H<m;)A.setCellFromCodepoint(H++,0,1,y)}else if(this._activeBuffer.x=m-1,o===2)continue}if(D&&this._activeBuffer.x){let A=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-A,r,o);for(let H=o-B;--H>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(y)),b.getWidth(m-1)===2&&b.setCellFromCodepoint(m-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=C,this._activeBuffer.x<m&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>v1(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new p1(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new qn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Mi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=yo.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*n),m=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;u[m++]=y,p+=y>65535?2:1}let g=m;for(let p=1;p<n;++p)u.copyWithin(g,0,m),g+=m;return this.print(u,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(be.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(be.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(be.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(be.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(be.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,bo),this._charsetService.setgCharset(1,bo),this._charsetService.setgCharset(2,bo),this._charsetService.setgCharset(3,bo);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(D=>(D[D.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",D[D.SET=1]="SET",D[D.RESET=2]="RESET",D[D.PERMANENTLY_SET=3]="PERMANENTLY_SET",D[D.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,u=this._coreService,{buffers:m,cols:g}=this._bufferService,{active:p,alt:y}=m,b=this._optionsService.rawOptions,C=(D,B)=>(u.triggerDataEvent(`${be.ESC}[${t?"":"?"}${D};${B}$y`),!0),k=D=>D?1:2,S=e.params[0];return t?S===2?C(S,4):S===4?C(S,k(u.modes.insertMode)):S===12?C(S,3):S===20?C(S,k(b.convertEol)):C(S,0):S===1?C(S,k(r.applicationCursorKeys)):S===3?C(S,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):S===6?C(S,k(r.origin)):S===7?C(S,k(r.wraparound)):S===8?C(S,3):S===9?C(S,k(o==="X10")):S===12?C(S,k(b.cursorBlink)):S===25?C(S,k(!u.isCursorHidden)):S===45?C(S,k(r.reverseWraparound)):S===66?C(S,k(r.applicationKeypad)):S===67?C(S,4):S===1e3?C(S,k(o==="VT200")):S===1002?C(S,k(o==="DRAG")):S===1003?C(S,k(o==="ANY")):S===1004?C(S,k(r.sendFocus)):S===1005?C(S,4):S===1006?C(S,k(c==="SGR")):S===1015?C(S,4):S===1016?C(S,k(c==="SGR_PIXELS")):S===1048?C(S,1):S===47||S===1047||S===1049?C(S,k(p===y)):S===2004?C(S,k(r.bracketedPasteMode)):S===2026?C(S,k(r.synchronizedOutput)):C(S,0)}_updateAttrColor(e,t,n,r,o){return t===2?(e|=50331648,e&=-16777216,e|=Yu.fromColorRGB([n,r,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let u=e.getSubParams(t+c),m=0;do r[1]===5&&(o=1),r[c+m+1+o]=u[m];while(++m<u.length&&m+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let u=2;u<r.length;++u)r[u]===-1&&(r[u]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Mi.fg,e.bg=Mi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Mi.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Mi.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Mi.fg&16777215,r.bg&=-67108864,r.bg|=Mi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${be.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${be.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(`${be.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Mi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!v1(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(`${be.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>g1&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>g1&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),o=n.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(y1(c))if(o==="?")t.push({type:0,index:c});else{let u=m1(o);u&&t.push({type:1,index:c,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,o=n.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=m1(n[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let o=parseInt(n[r]);y1(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,bo),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(HL[e[0]],Pi[e[1]]||bo),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Mi.clone(),this._eraseAttrDataInternal=Mi.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new ds;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${be.ESC}${u}${be.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},i_=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(b1=e,e=t,t=b1),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};i_=mi([ze(0,xn)],i_);function y1(e){return 0<=e&&e<256}var KL=5e7,S1=12,FL=50,WL=class extends vt{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 Le),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>KL)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let u=m=>performance.now()-n>=S1?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(n,m);o.catch(m=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=S1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>FL&&(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()}},n_=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let m=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[m]};return m.onDispose(()=>this._removeMarkerFromLink(g,m)),this._dataByLinkId.set(g.id,g),g.id}let n=e,r=this._getEntryIdKey(n),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};n_=mi([ze(0,xn)],n_);var w1=!1,$L=class extends vt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Pl),this._onBinary=this._register(new Le),this.onBinary=this._onBinary.event,this._onData=this._register(new Le),this.onData=this._onData.event,this._onLineFeed=this._register(new Le),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Le),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Le),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Le),this._instantiationService=new mL,this.optionsService=this._register(new kL(e)),this._instantiationService.setService(kn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Qv)),this._instantiationService.setService(xn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Zv)),this._instantiationService.setService(zx,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Jv)),this._instantiationService.setService(Ao,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(e_)),this._instantiationService.setService(Ix,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(yo)),this._instantiationService.setService(dN,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ML),this._instantiationService.setService(uN,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(n_),this._instantiationService.setService(Px,this._oscLinkService),this._inputHandler=this._register(new UL(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ln.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ln.forward(this._bufferService.onResize,this._onResize)),this._register(ln.forward(this.coreService.onData,this._onData)),this._register(ln.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new WL((t,n)=>this._inputHandler.parse(t,n))),this._register(ln.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Le),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&&!w1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w1=!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,vk),t=Math.max(t,_k),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(f1.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(f1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ni(()=>{for(let t of e)t.dispose()})}}},qL={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 VL(e,t,n,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=be.ESC+"OA":o.key=be.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=be.ESC+"OD":o.key=be.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=be.ESC+"OC":o.key=be.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=be.ESC+"OB":o.key=be.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":be.DEL,e.altKey&&(o.key=be.ESC+o.key);break;case 9:if(e.shiftKey){o.key=be.ESC+"[Z";break}o.key=be.HT,o.cancel=!0;break;case 13:o.key=e.altKey?be.ESC+be.CR:be.CR,o.cancel=!0;break;case 27:o.key=be.ESC,e.altKey&&(o.key=be.ESC+be.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"D":t?o.key=be.ESC+"OD":o.key=be.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"C":t?o.key=be.ESC+"OC":o.key=be.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"A":t?o.key=be.ESC+"OA":o.key=be.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=be.ESC+"[1;"+(c+1)+"B":t?o.key=be.ESC+"OB":o.key=be.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=be.ESC+"[2~");break;case 46:c?o.key=be.ESC+"[3;"+(c+1)+"~":o.key=be.ESC+"[3~";break;case 36:c?o.key=be.ESC+"[1;"+(c+1)+"H":t?o.key=be.ESC+"OH":o.key=be.ESC+"[H";break;case 35:c?o.key=be.ESC+"[1;"+(c+1)+"F":t?o.key=be.ESC+"OF":o.key=be.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=be.ESC+"[5;"+(c+1)+"~":o.key=be.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=be.ESC+"[6;"+(c+1)+"~":o.key=be.ESC+"[6~";break;case 112:c?o.key=be.ESC+"[1;"+(c+1)+"P":o.key=be.ESC+"OP";break;case 113:c?o.key=be.ESC+"[1;"+(c+1)+"Q":o.key=be.ESC+"OQ";break;case 114:c?o.key=be.ESC+"[1;"+(c+1)+"R":o.key=be.ESC+"OR";break;case 115:c?o.key=be.ESC+"[1;"+(c+1)+"S":o.key=be.ESC+"OS";break;case 116:c?o.key=be.ESC+"[15;"+(c+1)+"~":o.key=be.ESC+"[15~";break;case 117:c?o.key=be.ESC+"[17;"+(c+1)+"~":o.key=be.ESC+"[17~";break;case 118:c?o.key=be.ESC+"[18;"+(c+1)+"~":o.key=be.ESC+"[18~";break;case 119:c?o.key=be.ESC+"[19;"+(c+1)+"~":o.key=be.ESC+"[19~";break;case 120:c?o.key=be.ESC+"[20;"+(c+1)+"~":o.key=be.ESC+"[20~";break;case 121:c?o.key=be.ESC+"[21;"+(c+1)+"~":o.key=be.ESC+"[21~";break;case 122:c?o.key=be.ESC+"[23;"+(c+1)+"~":o.key=be.ESC+"[23~";break;case 123:c?o.key=be.ESC+"[24;"+(c+1)+"~":o.key=be.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=be.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=be.DEL:e.keyCode===219?o.key=be.ESC:e.keyCode===220?o.key=be.FS:e.keyCode===221&&(o.key=be.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let u=qL[e.keyCode]?.[e.shiftKey?1:0];if(u)o.key=be.ESC+u;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(m);e.shiftKey&&(g=g.toUpperCase()),o.key=be.ESC+g}else if(e.keyCode===32)o.key=be.ESC+(e.ctrlKey?be.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=be.ESC+m,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=be.US),e.key==="@"&&(o.key=be.NUL));break}return o}var xi=0,YL=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new uf,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new uf,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[o]=e[t],t++):r[o]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xi=this._search(t),xi===-1)||this._getKey(this._array[xi])!==t)return!1;do if(this._array[xi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xi),!0;while(++xi<this._array.length&&this._getKey(this._array[xi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,n=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[r++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do yield this._array[xi];while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do t(this._array[xi]);while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,o=this._getKey(this._array[r]);if(o>e)n=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Cg=0,C1=0,XL=class extends vt{constructor(){super(),this._decorations=new YL(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Le),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Le),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ni(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new GL(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!n||(c.options.layer??"bottom")===n)&&(yield c)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,o=>{Cg=o.options.x??0,C1=Cg+(o.options.width??1),e>=Cg&&e<C1&&(!n||(o.options.layer??"bottom")===n)&&r(o)})}},GL=class extends La{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Le),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Le),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=li.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=li.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ZL=1e3,QL=class{constructor(e,t=ZL){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},x1=20,df=class extends vt{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new QL(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
29
|
-
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(nt(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ni(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<x1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
30
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===x1+1&&(this._liveRegion.textContent+=Cv.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let o=e;o<=t;o++){let c=n.lines.get(n.ydisp+o),u=[],m=c?.translateToString(!0,void 0,void 0,u)||"",g=(n.ydisp+o+1).toString(),p=this._rowElements[o];p&&(m.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=m,this._rowColumns.set(p,u)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let u,m;if(t===0?(u=n,m=this._rowElements.pop(),this._rowContainer.removeChild(m)):(u=this._rowElements.shift(),m=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),m.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let o=({node:m,offset:g})=>{let p=m instanceof Text?m.parentNode:m,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let C=g<b.length?b[g]:b.slice(-1)[0]+1;return C>=this._terminal.cols&&(++y,C=0),{row:y,column:C}},c=o(t),u=o(n);if(!(!c||!u)){if(c.row>u.row||c.row===u.row&&c.column>=u.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(u.row-c.row)*this._terminal.cols-c.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};df=mi([ze(1,bb),ze(2,zr),ze(3,Pr)],df);var s_=class extends vt{constructor(e,t,n,r,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Le),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Le),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ni(()=>{Eo(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(nt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(nt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(nt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(nt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let o=n[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let u=c?.map(m=>({link:m}));this._activeProviderReplies?.set(r,u),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let u=o[c],m=u.link.range.start.y<e?0:u.link.range.start.x,g=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let p=m;p<=g;p++){if(n.has(p)){o.splice(c--,1);break}n.add(p)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(u=>this._linkAtPosition(u.link,t));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=this._activeProviderReplies.get(c)?.find(m=>this._linkAtPosition(m.link,t));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&JL(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,Eo(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,o){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:o}}};s_=mi([ze(1,yb),ze(2,Pr),ze(3,xn),ze(4,Ux)],s_);function JL(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 e3=class extends $L{constructor(e={}){super(e),this._linkifier=this._register(new Pl),this.browser=ak,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Pl),this._onCursorMove=this._register(new Le),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Le),this.onKey=this._onKey.event,this._onRender=this._register(new Le),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Le),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Le),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Le),this.onBell=this._onBell.event,this._onFocus=this._register(new Le),this._onBlur=this._register(new Le),this._onA11yCharEmitter=this._register(new Le),this._onA11yTabEmitter=this._register(new Le),this._onWillOpen=this._register(new Le),this._setup(),this._decorationService=this._instantiationService.createInstance(XL),this._instantiationService.setService(Xu,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(FA),this._instantiationService.setService(Ux,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(kv)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(ln.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ln.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ln.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ln.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ni(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let o=Jt.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${be.ESC}]${r};${PL(o)}${sk.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Ai.toColor(...t.color));else{let c=n;this._themeService.modifyColors(u=>u[c]=Ai.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(df,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(be.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(be.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),c=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,m=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=m+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(nt(this.element,"copy",t=>{this.hasSelection()&&sN(t,this._selectionService)}));let e=t=>rN(t,this.textarea,this.coreService,this.optionsService);this._register(nt(this.textarea,"paste",e)),this._register(nt(this.element,"paste",e)),ok?this._register(nt(this.element,"mousedown",t=>{t.button===2&&Ow(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(nt(this.element,"contextmenu",t=>{Ow(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Db&&this._register(nt(this.element,"auxclick",t=>{t.button===1&&Ax(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(nt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(nt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(nt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(nt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(nt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(nt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(nt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(nt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",wv.get()),uk||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(UA,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(zr,this._coreBrowserService),this._register(nt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(nt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(qv,this._document,this._helperContainer),this._instantiationService.setService(zf,this._charSizeService),this._themeService=this._instantiationService.createInstance(Gv),this._instantiationService.setService(ql,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lf),this._instantiationService.setService(Hx,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yv,this.rows,this.screenElement)),this._instantiationService.setService(Pr,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Fv,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Vv),this._instantiationService.setService(yb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(s_,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(Uv,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Xv,this.element,this.screenElement,r)),this._instantiationService.setService(fN,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(ln.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Kv,this.screenElement)),this._register(nt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(df,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(of,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(of,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance($v,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(c){let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let m,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(m=3,c.button!==void 0&&(m=c.button<3?c.button:3)):m=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,m=c.button<3?c.button:3;break;case"mousedown":g=1,m=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,m=4;break;default:return!1}return g===void 0||m===void 0||m>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:m,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(n(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(n(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&n(c)},mousemove:c=>{c.buttons||n(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(nt(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return n(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(nt(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let u=be.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Nx(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=VL(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===be.ETX||n.key===be.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)&&(t3(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Mi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(be.ESC+"[I"):this.coreService.triggerDataEvent(be.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(`${be.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${be.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function t3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var i3=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)}},n3=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 ds)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},k1=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 n3(t)}getNullCell(){return new ds}},s3=class extends vt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Le),this.onBufferChange=this._onBufferChange.event,this._normal=new k1(this._core.buffers.normal,"normal"),this._alternate=new k1(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)}},r3=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},a3=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}},o3=["cols","rows"],qs=0,l3=class extends vt{constructor(e){super(),this._core=this._register(new e3(e)),this._addonManager=this._register(new i3),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(o3.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 r3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new a3(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 s3(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
31
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wv.get()},set promptLabel(e){wv.set(e)},get tooMuchOutput(){return Cv.get()},set tooMuchOutput(e){Cv.set(e)}}}_verifyIntegers(...e){for(qs of e)if(qs===1/0||isNaN(qs)||qs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qs of e)if(qs&&(qs===1/0||isNaN(qs)||qs%1!==0||qs<0))throw new Error("This API only accepts positive integers")}};const c3=Ni.lazy(()=>_b(()=>import("./TranscriptMarkdownBody-Bkq8AHtC.js"),__vite__mapDeps([2,1])));function yk({entries:e,searchQuery:t,activeEntryIndex:n,activeEntryMode:r,activeSearchMatch:o,fontSize:c}){const u=v.useRef(new Map);v.useEffect(()=>{if(n===null)return;const g=u.current.get(n);if(!g||typeof g.scrollIntoView!="function")return;if(r==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const p=g.querySelectorAll(".transcript-search-hit");((o?.entryIndex===n?p[o.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[n,r,o,t]);let m=-1;return f.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,p)=>{const y=g.kind==="user"?++m:null,b=n===p?r==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return f.jsxs("section",{ref:C=>{C?u.current.set(p,C):u.current.delete(p)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":p,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?f.jsx("div",{className:"transcript-entry-header",children:Sk(g.header,t)}):null,g.body?f.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?f.jsx(T1,{text:g.body,searchQuery:t}):f.jsx(Ni.Suspense,{fallback:f.jsx(T1,{text:g.body,searchQuery:t}),children:f.jsx(c3,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${p}`)})})}function T1({text:e,searchQuery:t}){const n=e.endsWith(`
|
|
32
|
-
`)?e.slice(0,-1).split(`
|
|
33
|
-
`):e.split(`
|
|
34
|
-
`);return f.jsx("pre",{className:"transcript-entry-pre",children:n.map((r,o)=>f.jsx("span",{className:`transcript-line transcript-line-${p3(r,o===0||n[o-1]?.trim()==="")}`,children:Sk(r,t)},o))})}function Sk(e,t){const n=t.trim();if(!n)return e||" ";const r=e.toLowerCase(),o=n.toLowerCase(),c=[];let u=0,m=r.indexOf(o);for(;m!==-1;){m>u&&c.push(e.slice(u,m));const g=m+n.length;c.push(f.jsx("mark",{className:"transcript-search-hit",children:e.slice(m,g)},`${m}-${g}`)),u=g,m=r.indexOf(o,u)}return u<e.length&&c.push(e.slice(u)),c.length>0?c:e||" "}function u3(e,t){const n=t.trim().toLowerCase();if(!n)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(n);for(;c!==-1;)o+=1,c=r.indexOf(n,c+n.length);return o}function wk(e){const t=e.endsWith(`
|
|
35
|
-
`)?e.slice(0,-1):e;if(!t)return[];const n=[];let r=null,o="plain",c=[];function u(){const m=d3(c).join(`
|
|
36
|
-
`);(r||m)&&n.push({header:r,body:m,kind:o}),r=null,o="plain",c=[]}for(const m of t.split(`
|
|
37
|
-
`)){const g=h3(m);g?(u(),r=m,o=g):c.push(m)}return u(),n}function d3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function h3(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 f3(e,t){const n=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
38
|
-
${o.body}`:o.body,u=u3(c,t);for(let m=0;m<u;m+=1)n.push({entryIndex:r,matchIndexInEntry:m})}return n}function p3(e,t){const n=e.trim();if(!n)return"blank";const r=n.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(n);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||kk(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 Ro(e){return e==="codex"?"Codex":"Claude"}function r_(e,t,n={}){const r=`[nterminal] ${Ro(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
39
|
-
`).replace(/\r/g,`
|
|
40
|
-
`).replace(r,"").replace(/\n{3,}/g,`
|
|
41
|
-
|
|
42
|
-
`).trimEnd(),c=Ck(o),u=n.includeTools?c:xk(c);return u?`${u}
|
|
43
|
-
`:""}function Ck(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,n)=>{const r=m3(n);return r?`[${r}]`:t})}function m3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const n=t.getFullYear(),r=Qc(t.getMonth()+1),o=Qc(t.getDate()),c=Qc(t.getHours()),u=Qc(t.getMinutes()),m=Qc(t.getSeconds());return`${n}-${r}-${o} ${c}:${u}:${m}`}function Qc(e){return e.toString().padStart(2,"0")}function hf(e,t){return e.map(n=>t?n:xk(n)).filter(Boolean).map(n=>n.endsWith(`
|
|
44
|
-
`)?n:`${n}
|
|
45
|
-
`).join("")}function xk(e){if(!e)return"";const t=e.split(`
|
|
46
|
-
`),n=[];let r=!1,o=!1,c=!0;for(const u of t){const m=u.trim()==="",g=c?g3(u):null;if(g&&(r=g==="tool",o=!1),kk(u)){o=!0,c=!1;continue}if(o){m?(o=!1,r||n.push(u),c=!0):c=!1;continue}r||n.push(u),c=m}return n.join(`
|
|
47
|
-
`).replace(/\n{3,}/g,`
|
|
48
|
-
|
|
49
|
-
`).trimEnd()}function g3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function kk(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function Rb(e,t){return e.provider===t.provider&&e.sessionId===t.sessionId}function Th(e,t){return e===null?t===null:t!==null&&Rb(e,t)}const v3=5e3,_3=200,b3=1200,y3=4,S3=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c}){const u=v.useRef(null),m=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(!1),[C,k]=v.useState(null),[S,D]=v.useState(null),[B,A]=v.useState(null),[H,Y]=v.useState(()=>new Set),[$,se]=v.useState(!1),[J,W]=v.useState(!1),[xe,re]=v.useState([]),[Ee,ie]=v.useState(null),[V,X]=v.useState(!1),[F,le]=v.useState(!1),[O,M]=v.useState(!1),[j,ae]=v.useState(null),we=C?.find(R=>R.id===B)??null;v.useEffect(()=>{function R(q){q.key==="Escape"&&(q.preventDefault(),q.stopPropagation(),c())}return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[c]);const N=v.useCallback(async()=>{try{const R=await n.getTerminalSubagents(t);if(D(null),k(q=>q&&T3(q,R.subagents)?q:R.subagents),!b.current){const q=R.subagents.find(fe=>fe.hasTranscript);q&&(b.current=!0,A(fe=>fe??q.id))}}catch(R){D(R instanceof Error?R.message:"Failed to load subagents."),k(q=>q??[])}},[n,t]);v.useEffect(()=>{N();const R=window.setInterval(()=>{document.hidden||N()},v3);function q(){document.hidden||N()}return document.addEventListener("visibilitychange",q),()=>{window.clearInterval(R),document.removeEventListener("visibilitychange",q)}},[N]),v.useEffect(()=>{m.current+=1;const R=m.current;return g.current=!1,p.current=!0,y.current=null,re([]),ie(null),X(!1),ae(null),B&&U(null,"initial",R),()=>{m.current===R&&(m.current+=1)}},[n,t,B,J]),v.useLayoutEffect(()=>{const R=u.current;if(!R)return;if(p.current){if(F||xe.length===0)return;p.current=!1;const fe=()=>{R.scrollTop=R.scrollHeight};fe(),window.requestAnimationFrame?.(fe);return}const q=y.current;q!==null&&(y.current=null,R.scrollTop+=R.scrollHeight-q)},[xe,F,J]);async function U(R,q,fe=m.current){const ge=B;if(!(!ge||g.current)){g.current=!0,q==="initial"?le(!0):(M(!0),y.current=u.current?.scrollHeight??null),ae(null);try{let Q=R,ke=0,de=0,Re=[];for(;m.current===fe;){const Ie=await n.getTerminalSubagentTranscriptHistory(t,ge,{...Q?{cursor:Q}:{},limit:_3,maxLines:b3,includeTools:J});if(m.current!==fe)return;if(!Ie.source){if(de<1){de+=1,await new Promise(Ye=>setTimeout(Ye,600));continue}ae("Subagent transcript is unavailable.");return}const je=r_(Ie.output,Ie.source.provider,{includeTools:J});if(ie(Ie.cursor),X(!!(Ie.hasMore&&Ie.cursor)),je&&(Re=[je,...Re],hf(Re,J))){re(Ye=>q==="older"?[...Re,...Ye]:Re);return}if(!Ie.hasMore||!Ie.cursor||ke>=y3){Re.length>0&&re(Ye=>q==="older"?[...Re,...Ye]:Re);return}Q=Ie.cursor,ke+=1}}catch(Q){if(m.current!==fe)return;ae(Q instanceof Error?Q.message:"Failed to load subagent transcript.")}finally{m.current===fe&&(g.current=!1,le(!1),M(!1))}}}function ue(){const R=u.current;R&&(R.scrollTop>72||!V||!Ee||g.current||U(Ee,"older"))}function Ce(R){Y(q=>{const fe=new Set(q);return fe.delete(R)||fe.add(R),fe})}function Oe(R){b.current=!0,se(!0),R.id!==B&&A(R.id),De(R.id)}function De(R){const q=x3(C??[],R);q.length!==0&&Y(fe=>{if(q.every(Q=>fe.has(Q)))return fe;const ge=new Set(fe);for(const Q of q)ge.add(Q);return ge})}function Be(){m.current+=1;const R=m.current;g.current=!1,p.current=!0,y.current=null,re([]),ie(null),X(!1),ae(null),U(null,"initial",R)}const Ne=v.useMemo(()=>hf(xe,J),[xe,J]),Ue=v.useMemo(()=>wk(Ne),[Ne]),Fe=C===null;v.useEffect(()=>{if(F||O||!V||!Ee||g.current)return;const R=u.current;!R||xe.length===0||R.scrollHeight<=R.clientHeight+4&&U(Ee,"older")},[xe,V,Ee,F,O]);const ne=C?.filter(R=>R.state==="working").length??0,me=v.useMemo(()=>Dk(w3(C??[]),H),[C,H]);return f.jsx("div",{className:"security-overlay transcript-overlay subagents-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"subagents-dialog-title",onPointerDown:R=>R.stopPropagation(),onMouseDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog subagents-dialog","data-mobile-view":$?"transcript":"list",onPointerDown:R=>R.stopPropagation(),onMouseDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"subagents-dialog-title",children:["Subagents",C&&C.length>0?f.jsx("span",{className:"subagents-count",children:ne>0?`${ne} working · ${C.length} total`:`${C.length} total`}):null]}),f.jsxs("span",{title:r.sessionId,children:[Ro(r.provider)," session ",r.sessionId]})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close subagents dialog",onClick:c,children:"×"})]}),f.jsxs("div",{className:"subagents-body",children:[f.jsxs("aside",{className:"subagents-list","aria-label":"Subagents",children:[Fe?f.jsx("div",{className:"subagents-list-status",children:"Loading subagents..."}):null,!Fe&&S?f.jsx("div",{className:"subagents-list-status subagents-list-error",children:S}):null,!Fe&&!S&&C!==null&&C.length===0?f.jsx("div",{className:"subagents-list-status",children:"No subagents found for this session yet."}):null,me.map(R=>{const q=R.subagent,fe=H.has(q.id);return f.jsxs("div",{className:"subagent-row-wrap",style:R.level>0?{paddingLeft:`${Math.min(R.level,4)*14}px`}:void 0,children:[R.nestedCount>0?f.jsxs("button",{type:"button",className:"subagent-expander","aria-expanded":fe,"aria-label":`${fe?"Collapse":"Expand"} ${R.nestedCount} nested subagents of ${q.name}`,title:R.nestedWorkingCount>0?`${R.nestedCount} nested · ${R.nestedWorkingCount} working`:`${R.nestedCount} nested`,onClick:()=>Ce(q.id),children:[f.jsx("span",{"aria-hidden":"true",children:fe?"▾":"▸"}),f.jsx("span",{className:"subagent-expander-count","data-working":R.nestedWorkingCount>0?"true":"false",children:R.nestedCount})]}):f.jsx("span",{className:"subagent-expander-spacer","aria-hidden":"true"}),f.jsxs("button",{type:"button",className:"subagent-row","data-selected":q.id===B?"true":"false","data-state":q.state,disabled:!q.hasTranscript,title:q.hasTranscript?void 0:"Transcript file not found for this subagent.",onClick:()=>Oe(q),children:[f.jsx("span",{className:"subagent-row-dot","data-state":q.state,"aria-hidden":"true"}),f.jsxs("span",{className:"subagent-row-main",children:[f.jsxs("span",{className:"subagent-row-title",children:[f.jsx("strong",{children:q.name}),f.jsx("span",{className:"subagent-row-badge","data-kind":q.kind,children:q.kind==="cross"?Ro(q.provider):q.provider})]}),q.description?f.jsx("span",{className:"subagent-row-description",children:q.description}):null,f.jsxs("span",{className:"subagent-row-meta",children:[E3(q.state),q.model?` · ${q.model}`:"",q.updatedAt?` · ${D3(q.updatedAt)}`:"",R.nestedCount>0&&!fe?` · ${R.nestedCount} nested${R.nestedWorkingCount>0?` (${R.nestedWorkingCount} working)`:""}`:""]})]})]})]},q.id)})]}),f.jsxs("section",{className:"subagents-transcript","aria-label":"Subagent transcript",children:[f.jsxs("div",{className:"subagents-transcript-controls",children:[f.jsx("button",{type:"button",className:"subagents-back","aria-label":"Back to subagent list",onClick:()=>se(!1),children:"‹ List"}),f.jsx("span",{className:"subagents-transcript-name",children:we?we.name:"Select a subagent"}),f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle subagents-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:J,onChange:R=>W(R.currentTarget.checked)}),"Show tool output"]}),f.jsx("button",{type:"button",className:"subagents-refresh","aria-label":"Reload subagent transcript",title:"Reload latest entries",disabled:!we,onClick:Be,children:"↻"})]}),we?f.jsx("div",{className:"subagents-transcript-hint",children:k3(we)}):null,f.jsxs("div",{ref:u,className:"transcript-dialog-scroll subagents-transcript-scroll",onScroll:ue,children:[O?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!F&&V?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,Ne?f.jsx(yk,{entries:Ue,searchQuery:"",activeEntryIndex:null,activeEntryMode:null,activeSearchMatch:null,fontSize:o}):null,F?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!F&&we&&!Ne&&!j?V&&Ee?f.jsxs("div",{className:"transcript-dialog-status",children:[J?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{U(Ee,"older")},disabled:O,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,!we&&!Fe&&!Ne?f.jsx("div",{className:"transcript-dialog-status",children:"Select a subagent on the left to view its conversation."}):null,j?f.jsx("div",{className:"transcript-dialog-error",children:j}):null]})]})]})]})})});function w3(e){const t=new Map;for(const r of e)t.set(r.id,{subagent:r,children:[],nestedCount:0,nestedWorkingCount:0});const n=[];for(const r of t.values()){const o=C3(r,t);o?o.children.push(r):n.push(r)}for(const r of n)Tk(r);return Ek(n),n}function C3(e,t){const n=e.subagent.parentId;if(!n)return null;const r=t.get(n);if(!r||r===e)return null;const o=new Set([e.subagent.id]);for(let c=r;c;){if(o.has(c.subagent.id))return null;o.add(c.subagent.id);const u=c.subagent.parentId;c=u?t.get(u):void 0}return r}function Tk(e){let t=0,n=0;for(const r of e.children)Tk(r),t+=1+r.nestedCount,n+=(r.subagent.state==="working"?1:0)+r.nestedWorkingCount;e.nestedCount=t,e.nestedWorkingCount=n,Ek(e.children)}function Ek(e){e.sort((t,n)=>{const r=t.subagent.state==="working"||t.nestedWorkingCount>0?0:1,o=n.subagent.state==="working"||n.nestedWorkingCount>0?0:1;return r!==o?r-o:(n.subagent.updatedAt??"").localeCompare(t.subagent.updatedAt??"")})}function Dk(e,t,n=0){const r=[];for(const o of e)r.push({subagent:o.subagent,level:n,nestedCount:o.nestedCount,nestedWorkingCount:o.nestedWorkingCount}),o.children.length>0&&t.has(o.subagent.id)&&r.push(...Dk(o.children,t,n+1));return r}function x3(e,t){const n=new Map(e.map(u=>[u.id,u])),r=[],o=new Set([t]);let c=n.get(t)?.parentId??null;for(;c&&!o.has(c);)o.add(c),r.push(c),c=n.get(c)?.parentId??null;return r}function k3(e){return e.kind==="cross"?'"User" entries are the prompt the parent session passed to codex exec, not operator input.':e.provider==="codex"?"Codex forks the parent thread to start a teammate; the inherited history is hidden here. Coordinator instructions are stored encrypted by Codex, so they show as placeholders.":`"User" entries are the parent session's instructions and tool results, not operator input.`}function T3(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],o=t[n];if(r.id!==o.id||r.provider!==o.provider||r.kind!==o.kind||r.name!==o.name||r.description!==o.description||r.model!==o.model||r.spawnDepth!==o.spawnDepth||r.parentId!==o.parentId||r.state!==o.state||r.updatedAt!==o.updatedAt||r.hasTranscript!==o.hasTranscript)return!1}return!0}function E3(e){switch(e){case"working":return"working";case"done":return"done";case"stopped":return"stopped";case"idle":return"idle";default:return"unknown"}}function D3(e){const t=Date.parse(e);if(!Number.isFinite(t))return"";const n=Date.now()-t;if(n<45e3)return"just now";const r=Math.round(n/6e4);if(r<60)return`${r}m ago`;const o=Math.round(r/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}class R3{pending=null;accept(t){let n="";for(const r of t)n+=this.acceptChar(r);return n}acceptChar(t){return t===""?this.acceptBackspace():Ak.has(t)?this.acceptConsonant(t):Lk.has(t)?this.acceptVowel(t):L3(t)&&this.canReplacePendingWith(t)?(this.pending=D1(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(Ok.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const n=A3.get(`${this.pending.final}${t}`);if(n)return this.pending.final=n,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=N3.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const n=E1.get(this.pending.final);if(n){this.pending.final=n[0];const c=this.flushPending();return this.pending={initial:n[1],vowel:t},c}const r=this.pending.final,o=R1({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=E1.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=D1(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=R1(this.pending);return this.pending=null,t}}const ff=44032,pf=21,El=28,M3=19*pf*El,Rk=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Mk=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],Nk=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],Ak=Mb(Rk),Lk=Mb(Mk),Ok=Mb(Nk),N3=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),Bk=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],A3=new Map(Bk),E1=new Map(Bk.map(([e,t])=>[t,[e[0],e[1]]]));function Mb(e){return new Map(e.map((t,n)=>[t,n]))}function L3(e){const t=e.codePointAt(0);return t!==void 0&&t>=ff&&t<ff+M3}function D1(e){const t=e.codePointAt(0)-ff,n=Math.floor(t/(pf*El)),r=Math.floor(t%(pf*El)/El),o=t%El,c={initial:Rk[n],vowel:Mk[r]};return o===0?c:{...c,final:Nk[o]}}function R1(e){if(!e.vowel)return e.initial;const t=Ak.get(e.initial),n=Lk.get(e.vowel),r=e.final?Ok.get(e.final):0;return t===void 0||n===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(ff+(t*pf+n)*El+r)}const O3=[{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 B3({ctrlActive:e,onCtrl:t,onStandaloneKey:n,onPreserveFocus:r,onHide:o}){function c(u){u.preventDefault(),u.stopPropagation(),r()}return f.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[f.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),O3.map(u=>f.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":u.ariaLabel,onClick:()=>n(u.key),children:u.label},u.key)),f.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const j3={interrupt:"",escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function I3(e){return j3[e]}function z3(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const jk="--nterminal-viewport-height",Ik="--nterminal-keyboard-inset-bottom",zk="data-nterminal-keyboard-visible",Uf="data-nterminal-compose-open",mf="nterminal:viewport-refresh",P3=120;function H3(e=window){const t=e.document.documentElement,n=e.visualViewport,r=q3(e);function o(){Nb(e)}return o(),n?.addEventListener("resize",o),n?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(mf,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{n?.removeEventListener("resize",o),n?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(mf,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(jk),t.style.removeProperty(Ik),t.removeAttribute(zk)}}function Nb(e=window){const t=e.document.documentElement,{keyboardInsetBottom:n,keyboardVisible:r}=a_(e),o=U3(e,r);return o!==null&&M1(t,jk,`${o}px`),M1(t,Ik,`${n}px`),K3(t,zk,String(r)),{viewportHeight:o,keyboardInsetBottom:n,keyboardVisible:r}}function a_(e=window){const t=F3(e);return{keyboardInsetBottom:t,keyboardVisible:t>P3}}function U3(e,t){if((e.document.documentElement.hasAttribute(Uf)||t)&&Co(e.innerHeight))return e.innerHeight;const n=e.visualViewport?.height;return Co(n)?n:Co(e.innerHeight)?e.innerHeight:null}function Co(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function M1(e,t,n){e.style.getPropertyValue(t)!==n&&e.style.setProperty(t,n)}function K3(e,t,n){e.getAttribute(t)!==n&&e.setAttribute(t,n)}function F3(e){return Math.max(W3(e),$3(e))}function W3(e){const t=e.visualViewport?.height;if(!Co(t)||!Co(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 $3(e){if(!Co(e.innerHeight))return 0;const n=Pk(e)?.boundingRect?.height;return!Co(n)||n>=e.innerHeight*.8?0:Math.round(n)}function Pk(e){return e.navigator.virtualKeyboard}function q3(e){const t=Pk(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Qu=new Map,Lu=new Map,V3=Object.freeze({open:!1,text:""});function Y3(e){let t=Lu.get(e);return t||(t=new Set,Lu.set(e,t)),t}function Hk(e){const t=Lu.get(e);if(t)for(const n of Array.from(t))n()}function Al(e){return Qu.get(e)??V3}function X3(e,t){const n=Y3(e);return n.add(t),()=>{n.delete(t)}}function G3(e,t){const n=Al(e);n.open!==t&&(Qu.set(e,{...n,open:t}),Hk(e))}function Z3(e,t){const n=Al(e);n.text!==t&&(Qu.set(e,{...n,text:t}),Hk(e))}function Eh(e){Qu.delete(e),Lu.delete(e)}function N1(){Qu.clear(),Lu.clear()}const Ua=new Map,Ou=new Map,gf=new Map,Q3=Object.freeze([]);function Bu(e){return Ua.get(e)??Q3}function J3(e,t){let n=Ou.get(e);return n||(n=new Set,Ou.set(e,n)),n.add(t),()=>n?.delete(t)}function xg(e,t){t.length!==0&&(Ua.set(e,[...Bu(e),...t]),Kf(e))}function kg(e){const t=gf.get(e)??1;return gf.set(e,t+1),`attach${t}`}function o_(e){gf.delete(e)}function Jc(e,t,n){const r=Bu(e);r.length!==0&&(Ua.set(e,r.map(o=>t.has(o.id)?n(o):o)),Kf(e))}function Dh(e,t){const n=Bu(e);n.find(c=>c.id===t)?.cancel?.();const o=n.filter(c=>c.id!==t);o.length!==n.length&&(o.length===0?Ua.delete(e):Ua.set(e,o),Kf(e))}function Uk(e){const t=Ua.get(e);if(t){for(const n of t)n.cancel?.();Ua.delete(e),Kf(e)}}function lu(e){Uk(e),o_(e),Ou.delete(e)}function A1(){for(const e of Array.from(Ua.keys()))lu(e);Ou.clear(),gf.clear()}function Kf(e){for(const t of Array.from(Ou.get(e)??[]))t()}class eO extends Error{constructor(t){super(t),this.name="UploadDropError"}}function Dl(e){return e?Array.from(e.types??[]).includes("Files")||qk(e.items).some(n=>n.kind==="file")?!0:Vk(e.files).length>0:!1}async function Kk(e){const t=qk(e.items).filter(n=>n.kind==="file");return t.length>0?tO(t):iO(e.files)}async function tO(e){const t=[];for(const n of e){const r=aO(n);if(r){await Fk(r,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Wk(o),file:o});continue}throw new eO("Folder upload is not supported by this browser.")}return t}function iO(e){return Vk(e).map(t=>({relativePath:Wk(t),file:t}))}async function Fk(e,t,n){const r=lO(t,e.name);if(e.isFile){const u=await nO(e);n.push({relativePath:r,file:u});return}if(!e.isDirectory)return;const o=e.createReader(),c=await sO(o);for(const u of c)await Fk(u,r,n)}function nO(e){return new Promise((t,n)=>{e.file(t,r=>n(r))})}async function sO(e){const t=[];for(;;){const n=await rO(e);if(n.length===0)return t;t.push(...n)}}function rO(e){return new Promise((t,n)=>{e.readEntries(t,r=>n(r))})}function Wk(e){const t=e.webkitRelativePath;return $k(typeof t=="string"&&t?t:e.name)}function aO(e){const t=e.webkitGetAsEntry?.();return oO(t)?t:null}function oO(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 lO(e,t){return $k(e?`${e}/${t}`:t)}function $k(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function qk(e){return e?Array.from(e):[]}function Vk(e){return e?Array.from(e):[]}const cO=120,uO="\x1B[200~",dO="\x1B[201~";function Tg(e,t){const n=t.stripTrailingLineBreaks===!1?e:Ab(e),r=fO(n);return r?t.bracketedPasteMode?`${uO}${r}${dO}`:r:""}function hO(e){return e==="queue"?" ":"\r"}function Ab(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function fO(e){return e.replace(/\r\n/g,`
|
|
50
|
-
`).replace(/\r/g,`
|
|
51
|
-
`).replace(/\n/g,"\r")}const pO=420,mO=3e3,L1=650,gO=80,vO=3,_O=10,bO=50*1024*1024,yO=100*1024*1024,SO={maxFiles:_O,maxFileBytes:bO,maxBatchBytes:yO},Wh=new Set;let Ll=null;function wO({terminalId:e,onSubmit:t,queueAvailable:n=!1,disabled:r=!1,onUploadAttachments:o,onGetAttachmentLimits:c,onDeleteAttachments:u}){const m=v.useMemo(()=>R=>X3(e,R),[e]),g=v.useMemo(()=>()=>Al(e),[e]),p=v.useSyncExternalStore(m,g,g),{open:y,text:b}=p,C=v.useMemo(()=>R=>J3(e,R),[e]),k=v.useMemo(()=>()=>Bu(e),[e]),S=v.useSyncExternalStore(C,k,k),[D,B]=v.useState(SO),[A,H]=v.useState(!1),Y=v.useRef(null),$=v.useRef(null),se=v.useRef(null),J=v.useRef(null),W=v.useRef(new Map),xe=v.useRef(c),re=v.useRef(u),Ee=v.useRef(null),ie=v.useRef({start:0,end:0});xe.current=c,re.current=u,v.useEffect(()=>()=>{Ee.current?.(),Ee.current=null},[]),v.useEffect(()=>{if(!y||!xe.current)return;let R=!0;return xe.current().then(q=>{R&&B(q)}).catch(()=>{}),()=>{R=!1}},[y,e]),v.useLayoutEffect(()=>{if(!(!y||!$h()))return RO(e),()=>MO(e)},[y,e]),v.useLayoutEffect(()=>{const R=Y.current?.closest(".terminal-pane");if(!R)return;function q(){R?.removeAttribute("data-compose-open"),R?.style.removeProperty("--compose-drawer-panel-height")}if(!y){q();return}const fe=$.current;R.setAttribute("data-compose-open","true");function ge(){const Re=fe?.getBoundingClientRect().height??0;Re>0&&R?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Re)}px`)}ge();const Q=[window.setTimeout(ge,0),window.setTimeout(ge,180),window.setTimeout(ge,260)],ke=window.requestAnimationFrame?.(ge)??null,de=typeof ResizeObserver=="function"&&fe?new ResizeObserver(ge):null;return de&&fe&&de.observe(fe),()=>{for(const Re of Q)window.clearTimeout(Re);ke!==null&&window.cancelAnimationFrame?.(ke),de?.disconnect(),q()}},[y]),v.useEffect(()=>{if(!y){Ee.current?.(),Ee.current=null;return}Mg(se.current),Fe()},[y]);function V(R){G3(e,R)}function X(R){Z3(e,R)}function F(){DO(Y.current),V(!1),j1()}function le(R="send"){const q=S.filter(ge=>ge.status==="uploaded"&&ge.path);if(r||S.some(ge=>ge.status==="uploading"||ge.status==="failed")||!b&&q.length===0)return;const fe=kO(b,S);if(fe.parts.some(ge=>ge.kind==="image"||ge.value.trim())&&t(fe,R)){if(X(""),Uk(e),o_(e),$h()){se.current?.blur(),j1();return}window.setTimeout(()=>se.current?.focus(),cO+20)}}async function O(R){if(r||R.length===0)return;const q=Bu(e).filter(je=>je.status!=="failed"),fe=q.reduce((je,Ye)=>je+Ye.file.size,0);let ge=0,Q=q.length;const ke=[],de=R.filter((je,Ye)=>{const ct=fe+ge+je.file.size,Nt=je.file.size>D.maxFileBytes?`File exceeds the ${B1(D.maxFileBytes)} attachment limit.`:Q>=D.maxFiles?`A compose message can include up to ${D.maxFiles} attachments.`:ct>D.maxBatchBytes?`Compose attachments cannot exceed ${B1(D.maxBatchBytes)} in total.`:null;return Nt?(ke.push({id:Dg(Ye),reference:kg(e),file:je.file,relativePath:O1(je.relativePath,je.file.name),status:"failed",error:Nt}),!1):(Q+=1,ge+=je.file.size,!0)});if(ke.length>0&&xg(e,ke),de.length===0)return;const Re=new Map,Ie=de.map((je,Ye)=>{const ct=Dg(Ye),Nt=new AbortController;return Re.set(ct,Nt),{id:ct,reference:kg(e),file:je.file,relativePath:O1(je.relativePath,je.file.name),status:"uploading",loaded:0,total:je.file.size,cancel:()=>Nt.abort()}});xg(e,Ie),ne(Ie.map(je=>je.reference));for(const je of Ie)W.current.set(je.id,Re.get(je.id));await Promise.all(Ie.map(async je=>{const Ye=Re.get(je.id),ct=new Set([je.id]);try{const yt=(await o([{relativePath:je.relativePath,file:je.file}],{signal:Ye.signal,onProgress:Tt=>{Jc(e,ct,$e=>({...$e,loaded:Tt.loaded,total:Tt.total}))}})).results[0];if(Ye.signal.aborted){const Tt=re.current;yt?.status==="uploaded"&&yt.attachmentId&&Tt&&Tt([yt.attachmentId]).catch(()=>{});return}Jc(e,ct,Tt=>{const{error:$e,cancel:St,...Lt}=Tt;return yt?.status==="uploaded"&&yt.path?{...Lt,status:"uploaded",...yt.attachmentId?{attachmentId:yt.attachmentId}:{},path:yt.path,loaded:yt.size??Tt.file.size,total:yt.size??Tt.file.size}:{...Lt,status:"failed",error:yt?.error??"upload_failed"}})}catch(Nt){const yt=Ye.signal.aborted?"Upload canceled.":Rg(Nt);Jc(e,ct,Tt=>{const{cancel:$e,...St}=Tt;return{...St,status:"failed",error:yt}})}finally{W.current.get(je.id)===Ye&&W.current.delete(je.id)}}))}function M(R){if(R.status!=="removing"){if(me(R.reference),R.status!=="uploaded"&&R.status!=="failed"||!R.attachmentId||!re.current){W.current.delete(R.id),Dh(e,R.id);return}ae([R])}}function j(){X(""),o_(e);const R=S.filter(q=>!!(q.path&&q.attachmentId));for(const q of S)R.includes(q)||(W.current.delete(q.id),Dh(e,q.id));R.length>0&&ae(R)}function ae(R){const q=R.flatMap(ge=>ge.attachmentId?[ge.attachmentId]:[]);if(q.length===0||!re.current){for(const ge of R)Dh(e,ge.id);return}const fe=new Set(R.map(ge=>ge.id));Jc(e,fe,ge=>{const{error:Q,...ke}=ge;return{...ke,status:"removing"}}),re.current(q).then(()=>{for(const ge of R)Dh(e,ge.id)}).catch(ge=>{Jc(e,fe,Q=>({...Q,status:"failed",error:`Could not remove attachment: ${Rg(ge)}`}))})}function we(R){const q=Array.from(R.currentTarget.files??[]).map(fe=>({relativePath:fe.name,file:fe}));R.currentTarget.value="",O(q)}function N(R){const q=Array.from(R.clipboardData.files??[]);q.length!==0&&O(q.map(fe=>({relativePath:fe.name,file:fe})))}function U(R){r||!Dl(R.dataTransfer)||(R.preventDefault(),R.stopPropagation(),R.dataTransfer.dropEffect="copy",H(!0))}function ue(R){r||!Dl(R.dataTransfer)||(R.preventDefault(),R.stopPropagation(),H(!0))}function Ce(R){if(!Dl(R.dataTransfer))return;const q=R.relatedTarget;q instanceof Node&&R.currentTarget.contains(q)||H(!1)}function Oe(R){Dl(R.dataTransfer)&&(R.preventDefault(),R.stopPropagation(),H(!1),Kk(R.dataTransfer).then(O).catch(q=>{const fe={id:Dg(0),reference:kg(e),file:new File([],"attachment"),relativePath:"attachment",status:"failed",error:Rg(q)};xg(e,[fe])}))}const De=S.some(R=>R.status==="uploading"),Be=S.some(R=>R.status==="failed"),Ne=S.filter(R=>R.status==="uploaded"&&R.path).length,Ue=!r&&!De&&!Be&&(!!b||Ne>0);function Fe(){$h()&&(Ee.current?.(),Ee.current=NO())}function ne(R){if(R.length===0)return;const q=R.map(Nt=>`@${Nt}`).join(" "),fe=Al(e).text,ge=Math.min(ie.current.start,fe.length),Q=Math.min(Math.max(ge,ie.current.end),fe.length),ke=fe.slice(0,ge),de=fe.slice(Q),Re=ke&&!/\s$/.test(ke)?" ":"",Ie=de&&!/^\s/.test(de)?" ":"",je=`${Re}${q}${Ie}`,Ye=`${ke}${je}${de}`,ct=ke.length+je.length;ie.current={start:ct,end:ct},X(Ye),window.requestAnimationFrame(()=>{const Nt=se.current;Nt&&(Mg(Nt),Nt.setSelectionRange(ct,ct))})}function me(R){const q=Al(e).text,fe=q.replace(new RegExp(`@${EO(R)}(?![A-Za-z0-9_])`,"g"),"");fe!==q&&X(fe.replace(/[ \t]{2,}/g," "))}return f.jsxs("div",{ref:Y,className:"compose-drawer","data-open":y?"true":"false",children:[f.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":y?"true":void 0,tabIndex:y?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>V(!0),children:[f.jsx("span",{"aria-hidden":"true",children:"▴"}),f.jsx("span",{children:"compose"}),b||S.length>0?f.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),f.jsxs("div",{ref:$,className:"compose-drawer-panel","aria-hidden":y?void 0:"true","data-file-drag-active":A?"true":void 0,onDragEnter:ue,onDragOver:U,onDragLeave:Ce,onDrop:Oe,children:[A?f.jsx("div",{className:"compose-drawer-drop-overlay","aria-hidden":"true",children:"Drop files to attach"}):null,f.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:y?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:F,children:[f.jsx("span",{"aria-hidden":"true",children:"▾"}),f.jsx("span",{className:"compose-drawer-title",children:"compose"}),f.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:n?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),f.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),f.jsx("textarea",{ref:se,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:y?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:b,onChange:R=>{ie.current={start:R.target.selectionStart,end:R.target.selectionEnd},X(R.target.value)},onSelect:R=>{ie.current={start:R.currentTarget.selectionStart,end:R.currentTarget.selectionEnd}},onPaste:N,onFocus:Fe,onKeyDown:R=>{if(R.key==="Enter"&&(R.metaKey||R.ctrlKey)){if(R.preventDefault(),R.shiftKey){n&&le("queue");return}le("send");return}R.key==="Escape"&&(R.preventDefault(),F())},placeholder:n?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),f.jsx("input",{ref:J,className:"compose-drawer-file-input",type:"file",multiple:!0,tabIndex:-1,onChange:we}),S.length>0?f.jsx("div",{className:"compose-attachments","aria-label":"Compose attachments",children:S.map(R=>f.jsx(CO,{attachment:R,onRemove:()=>M(R)},R.id))}):null,f.jsxs("div",{className:"compose-drawer-actions",children:[f.jsx("button",{type:"button",className:"compose-drawer-attach",tabIndex:y?0:-1,title:"Attach files to this message","aria-label":"Attach files",onClick:()=>J.current?.click(),disabled:r,children:"+"}),f.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:y?0:-1,onClick:()=>{j(),Mg(se.current),Fe()},disabled:!b&&S.length===0,children:"Clear"}),n?f.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:y?0:-1,title:Be?"Remove failed attachments before sending.":"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>le("queue"),disabled:!Ue,children:"Queue"}):null,f.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:y?0:-1,title:Be?"Remove failed attachments before sending.":void 0,onClick:()=>le("send"),disabled:!Ue,children:"Send"})]})]})]})}function CO({attachment:e,onRemove:t}){const n=xO(e.file,e.status==="uploaded"||e.status==="uploading"||e.status==="removing"),r=e.file.type.startsWith("image/"),o=e.relativePath.split("/").at(-1)??e.relativePath;return f.jsxs("div",{className:"compose-attachment","data-status":e.status,children:[r&&n?f.jsx("img",{src:n,alt:""}):f.jsx("span",{className:"compose-attachment-file","aria-hidden":"true",children:"file"}),f.jsxs("span",{className:"compose-attachment-reference",title:`Reference @${e.reference}`,children:["@",e.reference]}),f.jsx("span",{className:"compose-attachment-name",title:e.relativePath,children:o}),f.jsx("span",{className:"compose-attachment-state",children:e.status==="uploading"?e.total?`${Math.round((e.loaded??0)/e.total*100)}%`:"Uploading":e.status==="removing"?"Removing":e.status==="uploaded"?"Ready":e.error??"Failed"}),f.jsx("button",{type:"button","aria-label":`Remove ${o}`,title:"Remove attachment",onClick:t,disabled:e.status==="removing",children:"x"})]})}function xO(e,t){const n=v.useMemo(()=>t&&e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(e):null,[t,e]);return v.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n}function kO(e,t){const n=new Map(t.map(m=>[m.reference,m])),r=[],o=/@([A-Za-z][A-Za-z0-9_]*)(?![A-Za-z0-9_])/g;let c=0,u;for(;(u=o.exec(e))!==null;){const m=n.get(u[1]);m&&(Eg(r,e.slice(c,u.index)),m.status==="uploaded"&&m.path&&(TO(m)?r.push({kind:"image",path:m.path}):Eg(r,m.path)),c=o.lastIndex)}return Eg(r,e.slice(c)),{parts:r}}function Eg(e,t){if(!t)return;const n=e.at(-1);if(n?.kind==="text"){n.value+=t;return}e.push({kind:"text",value:t})}function TO(e){return e.file.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|jpe?g|png|webp)$/i.test(e.relativePath)}function EO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function O1(e,t){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")||t||"attachment"}function Dg(e){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`attachment-${Date.now()}-${e}-${Math.random().toString(16).slice(2)}`}function Rg(e){return e instanceof Error&&e.message?e.message:"Upload failed."}function B1(e){return e%(1024*1024)===0?`${e/(1024*1024)} MB`:e>=1024*1024?`${Math.round(e/(1024*1024)*10)/10} MB`:`${Math.ceil(e/1024)} KB`}function DO(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function Mg(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function $h(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function j1(){if(!$h())return;const e=Rl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function RO(e){Ll!==null&&(window.clearTimeout(Ll),Ll=null),Wh.add(e),document.documentElement.setAttribute(Uf,"true"),Rl()}function MO(e){if(Wh.delete(e),Wh.size>0||Ll!==null){Rl();return}Ll=window.setTimeout(()=>{if(Ll=null,Wh.size>0){Rl();return}document.documentElement.removeAttribute(Uf),Rl()},pO),Rl()}function NO(){let e=!1,t=null,n=null,r=null,o=0;const c=Date.now(),u=window.visualViewport,m=AO();function g(){t!==null&&(window.clearTimeout(t),t=null),n!==null&&(window.cancelAnimationFrame?.(n),n=null)}function p(){e||(e=!0,g(),u?.removeEventListener("resize",b),u?.removeEventListener("scroll",b),m?.removeEventListener("geometrychange",b))}function y(C){if(!e){if(C<L1&&typeof window.requestAnimationFrame=="function"){n=window.requestAnimationFrame(b);return}t=window.setTimeout(b,gO)}}function b(){if(e)return;g();const C=Nb(),k=Date.now()-c;if(C.keyboardInsetBottom>0&&C.keyboardInsetBottom===r?o+=1:(o=C.keyboardInsetBottom>0?1:0,r=C.keyboardInsetBottom),k>=mO||k>=L1&&o>=vO){p();return}y(k)}return u?.addEventListener("resize",b),u?.addEventListener("scroll",b),m?.addEventListener("geometrychange",b),b(),p}function Rl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Nb()}function AO(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function LO(e,t={}){const n=typeof t=="function"?{onPasteText:t}:t;e.attachCustomKeyEventHandler(u=>{if(jO(u))return u.preventDefault(),u.stopPropagation(),OO(e),!1;if(BO(u)&&n.onInterrupt&&n.shouldInterruptPlainCtrlC?.())return u.preventDefault(),u.stopPropagation(),n.onInterrupt(),!1;if(IO(u)){const m=l_(e);return m?(u.preventDefault(),u.stopPropagation(),c_(m),!1):!0}return zO(u)?(u.preventDefault(),u.stopPropagation(),PO(e,n.onPasteText),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const o=u=>{const m=l_(e);if(m){if(u.clipboardData){u.clipboardData.setData("text/plain",m),u.preventDefault();return}u.preventDefault(),c_(m)}},c=u=>{const m=u.clipboardData?.getData("text/plain");if(!m)return;const g=Ab(m);u.preventDefault(),u.stopImmediatePropagation(),Yk(e,g,n.onPasteText)};return r.addEventListener("copy",o,!0),r.addEventListener("paste",c,!0),{dispose(){r.removeEventListener("copy",o,!0),r.removeEventListener("paste",c,!0),e.attachCustomKeyEventHandler(()=>!0)}}}async function OO(e){const t=l_(e);t&&await c_(t)}function BO(e){return e.type==="keydown"&&e.key.toLowerCase()==="c"&&e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey}function jO(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 IO(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function zO(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 PO(e,t){if(navigator.clipboard?.readText)try{const n=await navigator.clipboard.readText();if(!n)return;Yk(e,Ab(n),t)}catch{}}function Yk(e,t,n){if(t){if(n){n(t);return}e.paste(t)}}function l_(e){return e.hasSelection()?e.getSelection():HO(e.element??null)}function HO(e){if(!e||typeof window.getSelection!="function")return"";const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount<=0)return"";const n=t.toString();if(!n)return"";for(let r=0;r<t.rangeCount;r+=1){const o=t.getRangeAt(r);if(e.contains(o.commonAncestorContainer))return n}return""}async function c_(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}UO(e)}function UO(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 KO=[4,10,11,12];function FO(e,t){const n=[e.parser.registerCsiHandler({final:"c"},r=>I1(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>I1(r)),e.parser.registerCsiHandler({final:"n"},r=>WO(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>$O(r)),e.parser.registerCsiHandler({final:"t"},r=>qO(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...KO.map(r=>e.parser.registerOscHandler(r,o=>VO(o)))];return{dispose(){for(const r of n)r.dispose()}}}function I1(e){return Ff(e)===0}function WO(e){const t=Ff(e);return t===5||t===6}function $O(e){return Ff(e)===6}function qO(e){const t=Ff(e);return t===14||t===16||t===18}function VO(e){return e.split(";").some(t=>t==="?")}function Ff(e){const t=e[0];return typeof t=="number"?t:0}const Es=new Map,Ng=2*1024*1024,YO=1500,z1=25e3,XO=2500,GO=2500,ZO=1e3,QO=2e3,JO=3e4,e5=16*1024*1024,u_=256,Xk=JD-3e4,t5=3e3,Gk=1e4,i5=3e3,d_=16*1024*1024,Wf=4*1024*1024,vf=25,n5=1e3,s5=3e3,Ag=8,r5=100,Zk=1e3,P1=[2e3,5e3,15e3,6e4];let a5=0,o5=0,Lg=0,Og=null,qh=!1,h_=0,Vh=0,Oa=!1,H1=!1,Su=null,U1=!1,f_=0,ju=document.visibilityState!=="hidden";const _f=new Set;let Ol=null,wu=0;const l5=new TextEncoder,c5=N5();function u5(e,t){h5(),b5(),Lf()&&Or(0);let n=Es.get(e);n||(n=m5(e),Es.set(e,n),Yl(n)),n.listeners.add(t);const r=Symbol(e);queueMicrotask(()=>Ob(n));const o=(m,g)=>S5(n,m,g),c=m=>{m?(n.foregroundAttachments.add(r),bf(),eT(n)):(n.foregroundAttachments.delete(r),p_())},u=()=>{n.listeners.delete(t),n.foregroundAttachments.delete(r),p_()};return{status:n.status,snapshot:n.snapshot,output:n.output.slice(),history:n.history,send:o,setForeground:c,detach:u}}function cu(e){const t=Es.get(e);t&&(M5(t),Es.delete(e),p_())}function d5(e){const t=Es.get(e);if(!t)return!1;t.exited=!1,t.reconnectEnabled=!0,t.reconnectTimer!==null&&(window.clearTimeout(t.reconnectTimer),t.reconnectTimer=null),Wa(t),ks(t),Js(t),$a(t),Zs(t,"reconnecting"),qa(t);const n=t.socket;return t.socket=null,Ma(t,"reconnecting"),n&&(n.readyState===WebSocket.OPEN||n.readyState===WebSocket.CONNECTING)&&n.close(),Yl(t),!0}function h5(){if(U1)return;U1=!0;const e=()=>{if(document.visibilityState==="hidden"){ju=!1,f_+=1,tT(),Jk(),f5();return}Lb(),wu=Date.now(),bf()};document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",e),window.addEventListener("online",e),bf()}function bf(){Ol!==null||document.visibilityState==="hidden"||!Qk()||typeof window.requestAnimationFrame!="function"||(Ol=window.requestAnimationFrame(()=>{if(Ol=null,document.visibilityState==="hidden")return;const e=Date.now(),t=wu>0?e-wu:0;if(wu=e,t>=QO){for(const n of Es.values())n.foregroundAttachments.size>0&&!n.exited&&n.reconnectEnabled&&Ka("terminal.connection.foreground_gap",n,{gapMs:t});Lb(void 0,{foregroundOnly:!0})}bf()}))}function Qk(){for(const e of Es.values())if(e.foregroundAttachments.size>0)return!0;return!1}function p_(){Qk()||(Jk(),wu=0)}function Jk(){Ol!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Ol),Ol=null}function eT(e){if(document.visibilityState!=="hidden"){if(!ju||e?.heartbeatSuspended){Lb(e);return}e&&m_(e)}}function Lb(e,t={}){if(document.visibilityState==="hidden")return;ju=!0;const n=++f_;tT();const r=Array.from(Es.values()).filter(m=>!m.exited&&m.reconnectEnabled&&m.status!=="unauthorized"),o=r.filter(m=>m===e||m.foregroundAttachments.size>0||C5(m)),c=new Set(o),u=r.filter(m=>!c.has(m));for(const m of o)m_(m);if(!t.foregroundOnly)for(let m=0;m<u.length;m+=Ag){const g=u.slice(m,m+Ag),p=Math.floor(m/Ag)*r5,y=window.setTimeout(()=>{if(_f.delete(y),!(n!==f_||!ju||document.visibilityState==="hidden"))for(const b of g)m_(b)},p);_f.add(y)}}function tT(){for(const e of _f)window.clearTimeout(e);_f.clear()}function m_(e){if(e.heartbeatSuspended=!1,e.exited||!e.reconnectEnabled||e.status==="unauthorized")return Promise.resolve("skipped");const t=e.socket;if(!t)return e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null,Yl(e)),Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(t.readyState!==WebSocket.OPEN)return Promise.resolve(e.status==="closed"?"skipped":"reconnecting");if(e.resumeProbe?.socket===t)return e.resumeProbe.promise;const n=Date.now();if(e.lastResumeProbeSocket===t&&n-e.lastResumeProbeAt<ZO)return Promise.resolve("alive");Zs(e,"reconnecting"),qa(e),e.lastResumeProbeSocket=t,e.lastResumeProbeAt=n;const r=`resume-${n.toString(36)}-${(++a5).toString(36)}`;let o;const c=new Promise(m=>{o=m}),u={socket:t,nonce:r,timeout:0,promise:c,resolve:o};e.resumeProbe=u,u.timeout=window.setTimeout(()=>{e.resumeProbe!==u||e.socket!==t||(Ka("terminal.connection.resume_timeout",e,{pendingInputs:Ba(e)}),Zs(e,"reconnecting"),ja(e))},XO);try{t.send(JSON.stringify({type:"ping",nonce:r}))}catch{Zs(e,"reconnecting"),ja(e)}return c}function f5(){ju=!1;for(const e of Es.values())e.heartbeatSuspended=!0,Wa(e),ks(e),Js(e),$a(e),e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0,Zs(e,"skipped"),qa(e)}function p5(){Oa=!1,Lf()&&Or(0);for(const e of Es.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Wa(e),ks(e),Js(e),$a(e),Zs(e,"reconnecting"),qa(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ma(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Yl(e)}}function Bg(){for(const e of Array.from(Es.keys()))cu(e)}function m5(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],pendingOutBytes:0,unackedInputs:new Map,unackedInputBytes:0,pendingAckReceipts:new Map,inputAckWatchdog:null,inputAckProbe:null,protocolHandshakeWatchdog:null,inputProtocolMode:"unknown",serverInstanceId:null,pendingNotices:[],outboundFlushTimer:null,outboundFlushDelayMs:vf,outboundStallWatchdog:null,listeners:new Set,foregroundAttachments:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,heartbeatTickAt:0,heartbeatSuspended:!1,isAlive:!1,resumeProbe:null,lastResumeProbeSocket:null,lastResumeProbeAt:0,lastUpgradeAuthProbeAt:0,exited:!1}}function Yl(e){if(!e.reconnectEnabled)return;Ma(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,ks(e),Js(e),$a(e),e.isAlive=!1,e.inputProtocolMode="unknown",e.lastResumeProbeSocket=null,e.lastResumeProbeAt=0;let n=!1;t.addEventListener("open",()=>{e.socket===t&&(n=!0,e.lastUpgradeAuthProbeAt=0,Wa(e),ks(e),Ma(e,"connected"),Fa(e,t),iT(e,t),e.isAlive=!0,K1(e))}),t.addEventListener("message",r=>{if(e.socket!==t)return;const o=typeof r.data=="string"?r.data:"";if(!o)return;let c=null;try{c=JSON.parse(o)}catch{return}if(!c||typeof c.type!="string")return;if(P5(c)){H5(e,t,c.instanceId,c.inputAck,c.inputReceipt===!0),Oa&&(Oa=!1,Lf()&&Or(0));return}if(e.inputProtocolMode==="unknown"&&rT(e,t),c.type==="pong"){e.isAlive=!0;const m=e.resumeProbe;m?.socket===t&&m.nonce===c.nonce&&(e.lastResumeProbeAt=Date.now(),Ba(e)>0&&Ka("terminal.connection.resume_alive",e,{pendingInputs:Ba(e)}),Zs(e,"alive"),Fa(e,t),K1(e),Mo(e));const g=e.inputAckProbe;g?.socket===t&&g.nonce===c.nonce&&(zu(e),Ka("terminal.input.delivery_probe_live_but_unreceived",e,{pendingInputs:Ba(e)}),ja(e));return}if(c.type==="input_ack"){B5(e,t,c);return}if(c.type==="input_received"){j5(e,t,c);return}if(c.type==="error"&&I5(e,c),c.type==="input_ack_confirmed"){K5(e,c);return}const u=v5(e,c);if(Iu(e,{type:"message",message:u}),c.type==="snapshot"){for(const m of e.pendingNotices)m.ready=!0;Ob(e)}}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,e.inputProtocolMode="unknown",Wa(e),ks(e),Js(e),$a(e),Zs(e,"reconnecting"),qa(e),r.code===1008){e.reconnectEnabled=!1,Ma(e,g5(r.reason)?"unauthorized":"closed");return}if(!n&&r.code===1006){const o=Date.now();(e.lastUpgradeAuthProbeAt===0||o-e.lastUpgradeAuthProbeAt>=JO)&&(e.lastUpgradeAuthProbeAt=o,Iu(e,{type:"upgrade_rejected"}))}if(e.exited||!e.reconnectEnabled){Ma(e,"closed");return}Ma(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Yl(e)},YO)}}),t.addEventListener("error",()=>{})}function K1(e){if(qa(e),e.heartbeatSuspended||document.visibilityState==="hidden"){e.heartbeatSuspended=!0;return}e.heartbeatTickAt=Date.now(),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN)return;const n=Date.now(),r=n-e.heartbeatTickAt>z1*1.5;if(e.heartbeatTickAt=n,!e.isAlive&&!r){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:n.toString(36)}))},z1)}function qa(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null),e.heartbeatTickAt=0}function g5(e){const t=e.trim().toLowerCase();return t==="unauthorized"||t==="session expired"||t==="session revoked"||t==="authentication no longer valid"}function v5(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.output=t.output.slice(),e.outputBytes=e.output.reduce((n,r)=>n+jr(r),0),F1(e),e.exited&&Yh(e),t):t.type==="output"?(e.output.push(t.data),e.outputBytes+=jr(t.data),F1(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0,Yh(e)),t):(t.type==="exit"&&(e.exited=!0,Yh(e),e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function F1(e){for(;e.outputBytes>Ng&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=jr(t)}e.outputBytes>Ng&&e.output.length===1&&(e.output[0]=W5(e.output[0],Ng),e.outputBytes=jr(e.output[0]))}function Ma(e,t){e.status!==t&&(e.status=t,Iu(e,{type:"status",status:t}))}function Iu(e,t){for(const n of Array.from(e.listeners))n(t)}function Ba(e){return e.unackedInputs.size+e.pendingOut.reduce((t,n)=>t+(n.message.type==="input"&&!n.message.messageId?1:0),0)}function _5(e){if(e.snapshot?.id)return e.snapshot.id;for(const t of e.pendingOut)if(t.message.type==="input")return t.message.terminalId;for(const t of e.unackedInputs.values())if(t.message.type==="input")return t.message.terminalId;return null}function Ka(e,t,n={}){gn(e,{...n,status:t.status,socketState:t.socket?.readyState??null,heartbeatSuspended:t.heartbeatSuspended,resumePending:t.resumeProbe!==null,queuedInputs:Ba(t),unacknowledgedInputs:t.unackedInputs.size,terminalId:n.terminalId??_5(t)}),h_+=1,Vh=0,Or(Zk)}function b5(){if(H1)return;H1=!0;const e=()=>{document.visibilityState==="hidden"||Oa||Lf()&&Or(0)};window.addEventListener("online",e),window.addEventListener("pageshow",e),document.addEventListener("visibilitychange",e)}function Or(e){if(qh){Su=Su===null?e:Math.min(Su,e);return}Og!==null||Oa||document.visibilityState==="hidden"||navigator.onLine===!1||(Og=window.setTimeout(()=>{Og=null,y5()},e))}async function y5(){if(qh||Oa||document.visibilityState==="hidden"||navigator.onLine===!1)return;qh=!0;const e=h_;try{const t=await rR();if(t.outcome==="auth_blocked"){Oa=!0;return}if(t.outcome==="retryable"){const n=P1[Math.min(Vh,P1.length-1)];Vh+=1,Or(n);return}if(Vh=0,t.outcome==="sent"&&t.hasMore){Or(0);return}}finally{qh=!1;const t=Su;Su=null,t!==null&&Or(t),h_!==e&&!Oa&&Or(Zk)}}function S5(e,t,n={}){if(e.exited||!e.reconnectEnabled||e.status==="closed"||e.status==="unauthorized")return"rejected";const r=L5(e,t);if(!r)return"rejected";const o=JSON.stringify(r),c=jr(o);if(c>e5)return"rejected";const u=n.durability!=="live-only",m={message:r,encoded:o,bytes:c,sentInstanceId:null,receivedInstanceId:null,firstSentAt:null,lastSentAt:null,receivedAt:null,writeSlowReported:!1,inputState:r.type==="input"?"queued":null,durable:u};if(!O5(e,m))return"rejected";const g=e.socket,p=g?.readyState===WebSocket.OPEN;r.type==="input"&&u&&e.heartbeatSuspended&&document.visibilityState==="visible"&&(Ka("terminal.input.foreground_resume",e,{terminalId:r.terminalId,pendingInputs:Ba(e)}),eT(e));const b=r.type!=="ping"&&r.type!=="resize";if(b&&(!p||r.type==="input"&&e.inputProtocolMode==="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.pendingOut.length>0||(g?.bufferedAmount??0)>Wf))return!u&&r.type==="input"?"rejected":w5(e,r)?(p&&g&&Fa(e,g),"queued"):e.pendingOut.length>=u_||e.pendingOutBytes+c>d_?"rejected":(e.pendingOut.push(m),e.pendingOutBytes+=c,$1(e,m),p&&g&&Fa(e,g),"queued");if(p){$1(e,m);try{return g.send(o),sT(e,m),"sent"}catch{if(b&&u&&e.pendingOut.length<u_&&e.pendingOutBytes+c<=d_)return e.pendingOut.push(m),e.pendingOutBytes+=c,g.close(),"queued";Lo(e,m),g.close()}}return"rejected"}function Fa(e,t){if(e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe||e.heartbeatSuspended||document.visibilityState==="hidden"){ks(e);return}let n=!1;for(;e.pendingOut.length>0;){if(t.bufferedAmount>Wf){F5(e,t),k5(e,t);return}const r=e.pendingOut[0];if(r.message.type==="input"&&e.inputProtocolMode==="unknown"){iT(e,t);return}try{t.send(r.encoded),sT(e,r)}catch{t.close();return}e.pendingOut.shift(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),e.outboundFlushDelayMs=vf,n=!0}e.outboundFlushDelayMs=vf,ks(e),n&&queueMicrotask(()=>{e.pendingOut.length===0&&Iu(e,{type:"outbound_flushed"})})}function w5(e,t){const n=e.pendingOut.at(-1);if(!n||!("terminalId"in t)||!("terminalId"in n.message)||n.message.terminalId!==t.terminalId)return!1;let r=null;if(t.type==="resize"&&n.message.type==="resize")r=t;else{if(t.type==="refresh_cwd"&&n.message.type==="refresh_cwd")return!0;if(t.type==="cancel_scrollback"&&n.message.type==="cancel_scrollback")return!0;if(t.type==="scrollback_scroll"&&n.message.type==="scrollback_scroll"){const u=Math.max(-240,Math.min(240,n.message.lines+t.lines));if(u===0)return e.pendingOut.pop(),e.pendingOutBytes=Math.max(0,e.pendingOutBytes-n.bytes),!0;r={...t,lines:u}}}if(!r)return!1;const o=JSON.stringify(r),c=jr(o);return e.pendingOutBytes+=c-n.bytes,n.message=r,n.encoded=o,n.bytes=c,!0}function Wa(e){e.outboundFlushTimer!==null&&(window.clearTimeout(e.outboundFlushTimer),e.outboundFlushTimer=null),e.outboundFlushDelayMs=vf}function ks(e){e.outboundStallWatchdog!==null&&(window.clearTimeout(e.outboundStallWatchdog),e.outboundStallWatchdog=null)}function yf(e){return e.pendingOut.some(t=>t.message.type==="input")}function C5(e){return yf(e)||e.unackedInputs.size>0}function x5(e){if(!yf(e))return;const t=e.pendingOut.filter(n=>n.message.type!=="scrollback_scroll");t.length!==e.pendingOut.length&&(e.pendingOut=t,e.pendingOutBytes=t.reduce((n,r)=>n+r.bytes,0))}function k5(e,t){e.outboundStallWatchdog!==null||!yf(e)||(e.outboundStallWatchdog=window.setTimeout(()=>{if(e.outboundStallWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||!yf(e))return;const n=e.inputProtocolMode==="unknown",r=t.bufferedAmount>Wf;if(!n&&!r){Fa(e,t);return}x5(e),ja(e)},s5))}function Js(e){e.protocolHandshakeWatchdog!==null&&(window.clearTimeout(e.protocolHandshakeWatchdog),e.protocolHandshakeWatchdog=null)}function iT(e,t){e.protocolHandshakeWatchdog!==null||e.inputProtocolMode!=="unknown"||e.unackedInputs.size===0||e.heartbeatSuspended||document.visibilityState==="hidden"||(e.protocolHandshakeWatchdog=window.setTimeout(()=>{e.protocolHandshakeWatchdog=null,!(e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="unknown"||e.resumeProbe!==null||e.heartbeatSuspended||document.visibilityState==="hidden"||e.unackedInputs.size===0)&&ja(e)},i5))}function nT(e){e.inputAckWatchdog!==null&&(window.clearTimeout(e.inputAckWatchdog),e.inputAckWatchdog=null)}function zu(e){const t=e.inputAckProbe;t&&(e.inputAckProbe=null,window.clearTimeout(t.timeout))}function $a(e){nT(e),zu(e)}function Mo(e){nT(e),g_(e,{notifyImmediately:!0});const t=e.socket;if(!t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId||e.heartbeatSuspended||document.visibilityState==="hidden")return;const n=W1(e),r=T5(e),o=D5(e);if(n===null&&r===null&&o===null){zu(e);return}if(e.inputAckProbe)return;const c=n===null?Number.POSITIVE_INFINITY:n+t5,u=Math.max(0,Math.min(c,r??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)-Date.now());e.inputAckWatchdog=window.setTimeout(()=>{if(e.inputAckWatchdog=null,e.socket!==t||t.readyState!==WebSocket.OPEN||e.inputProtocolMode!=="receipt-ack"||e.heartbeatSuspended||document.visibilityState==="hidden")return;if(g_(e,{notifyImmediately:!0})){Mo(e);return}if(E5(e),W1(e)===null){Mo(e);return}R5(e,t)},u)}function T5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.receivedAt===null||n.writeSlowReported)continue;const r=n.receivedAt+Gk;t=t===null?r:Math.min(t,r)}return t}function E5(e){const t=Date.now();for(const n of e.unackedInputs.values())n.receivedAt===null||n.writeSlowReported||t-n.receivedAt<Gk||(n.writeSlowReported=!0,Ka("terminal.input.pty_write_slow",e,{terminalId:n.message.type==="input"?n.message.terminalId:null,waitMs:t-n.receivedAt}))}function W1(e){let t=null;for(const n of e.unackedInputs.values())n.sentInstanceId!==e.serverInstanceId||n.receivedInstanceId===e.serverInstanceId||n.lastSentAt===null||(t=t===null?n.lastSentAt:Math.min(t,n.lastSentAt));return t}function D5(e){let t=null;for(const n of e.unackedInputs.values()){if(n.firstSentAt===null)continue;const r=n.firstSentAt+Xk;t=t===null?r:Math.min(t,r)}return t}function R5(e,t){if(e.inputAckProbe||e.socket!==t||t.readyState!==WebSocket.OPEN)return;if(t.bufferedAmount>Wf){ja(e);return}const n=`input-ack-${Date.now().toString(36)}-${(++o5).toString(36)}`;Ka("terminal.input.delivery_probe_started",e,{pendingInputs:Ba(e)});const r={socket:t,nonce:n,timeout:0};e.inputAckProbe=r,r.timeout=window.setTimeout(()=>{e.inputAckProbe!==r||e.socket!==t||(Ka("terminal.input.delivery_probe_timeout",e,{pendingInputs:Ba(e)}),zu(e),ja(e))},GO);try{t.send(JSON.stringify({type:"ping",nonce:n}))}catch{zu(e),ja(e)}}function Zs(e,t){const n=e.resumeProbe;n&&(e.resumeProbe=null,window.clearTimeout(n.timeout),n.resolve(t))}function ja(e){if(e.exited||!e.reconnectEnabled)return;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Wa(e),ks(e),Js(e),$a(e),Zs(e,"reconnecting"),qa(e);const t=e.socket;e.socket=null,Ma(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Yl(e)}function M5(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Wa(e),ks(e),Js(e),$a(e),Zs(e,"skipped"),qa(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Yh(e),e.listeners.clear()}function N5(){const e=globalThis.crypto?.randomUUID?.();return e||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function A5(){return Lg=(Lg+1)%Number.MAX_SAFE_INTEGER,`${c5}-${Lg.toString(36)}`.slice(0,YC)}function L5(e,t){if(t.type!=="input")return t;if(e.inputProtocolMode==="legacy"){const{messageId:r,...o}=t;return o}const n=A5();return n.length===0||n.length>YC?null:{...t,messageId:n}}function O5(e,t){if(t.message.type!=="input"||e.inputProtocolMode==="legacy")return!0;const n=t.message.messageId;return!!(n&&!e.unackedInputs.has(n)&&e.unackedInputs.size+e.pendingAckReceipts.size<u_&&e.unackedInputBytes+t.bytes<=d_)}function $1(e,t){t.message.type!=="input"||!t.message.messageId||(e.unackedInputs.set(t.message.messageId,t),e.unackedInputBytes+=t.bytes)}function Lo(e,t){t.message.type!=="input"||!t.message.messageId||e.unackedInputs.get(t.message.messageId)===t&&(e.unackedInputs.delete(t.message.messageId),e.unackedInputBytes=Math.max(0,e.unackedInputBytes-t.bytes))}function B5(e,t,n){const r=e.unackedInputs.get(n.messageId);if(!r||r.message.type!=="input"||r.message.terminalId!==n.terminalId){const c=e.pendingAckReceipts.get(n.messageId);c?.terminalId===n.terminalId&&v_(e,t,c);return}if(Lo(e,r),Mo(e),!Bb(e.inputProtocolMode)||!e.serverInstanceId)return;const o={terminalId:n.terminalId,messageId:n.messageId,instanceId:e.serverInstanceId,encoded:JSON.stringify({type:"input_ack_received",terminalId:n.terminalId,messageId:n.messageId})};e.pendingAckReceipts.set(n.messageId,o),v_(e,t,o)}function j5(e,t,n){if(e.socket!==t||e.inputProtocolMode!=="receipt-ack"||!e.serverInstanceId)return;const r=e.unackedInputs.get(n.messageId);r?.message.type!=="input"||r.message.terminalId!==n.terminalId||r.sentInstanceId!==e.serverInstanceId||(r.receivedInstanceId=e.serverInstanceId,r.receivedAt=Date.now(),r.writeSlowReported=!1,r.inputState="received",Mo(e))}function I5(e,t){if(!t.terminalId||!t.messageId)return;const n=e.unackedInputs.get(t.messageId);n?.message.type==="input"&&n.message.terminalId===t.terminalId&&(Lo(e,n),Mo(e))}function sT(e,t){if(t.message.type!=="input"||!t.message.messageId||!Bb(e.inputProtocolMode)||!e.serverInstanceId)return;const n=Date.now();t.sentInstanceId=e.serverInstanceId,t.receivedInstanceId=null,t.receivedAt=null,t.writeSlowReported=!1,t.firstSentAt??=n,t.lastSentAt=n,t.inputState="sent",Mo(e)}function z5(e){if(g_(e),e.unackedInputs.size===0)return;const t=new Set(e.pendingOut.flatMap(r=>r.message.type==="input"&&r.message.messageId?[r.message.messageId]:[])),n=[];for(const r of Array.from(e.unackedInputs.values())){if(!r.durable){Lo(e,r);continue}r.message.type==="input"&&r.message.messageId&&!t.has(r.message.messageId)&&(r.inputState="queued",n.push(r))}n.length!==0&&(e.pendingOut.unshift(...n),e.pendingOutBytes+=n.reduce((r,o)=>r+o.bytes,0))}function g_(e,t={}){const n=Date.now(),r=new Set;let o=0;for(const[c,u]of e.unackedInputs)u.firstSentAt!==null&&n-u.firstSentAt>=Xk&&(r.add(c),u.durable&&(o+=1));if(r.size===0)return!1;e.pendingOut=e.pendingOut.filter(c=>{const u=c.message.type==="input"?c.message.messageId:void 0;return!u||!r.has(u)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-c.bytes),!1)});for(const c of r){const u=e.unackedInputs.get(c);u&&Lo(e,u)}return o>0&&(oT(e,{message:`NTerminal did not receive confirmation for ${o} ${o===1?"input":"inputs"} before the safe replay window expired, so it did not send ${o===1?"it":"them"} again.`,ready:t.notifyImmediately===!0}),t.notifyImmediately===!0&&Ob(e)),!0}function P5(e){return e.type==="terminal_protocol"&&typeof e.inputAck=="boolean"&&typeof e.instanceId=="string"&&e.instanceId.length>0&&e.instanceId.length<=128}function H5(e,t,n,r,o){if(e.socket!==t||e.inputProtocolMode!=="unknown")return;if(!r){rT(e,t);return}Js(e);const c=e.serverInstanceId;e.inputProtocolMode=o?"receipt-ack":"ack",e.serverInstanceId=n,c===n?(z5(e),U5(e,t)):c!==null&&(aT(e),lT(e)),Fa(e,t)}function rT(e,t){if(!(e.socket!==t||e.inputProtocolMode!=="unknown")){e.inputProtocolMode="legacy",Js(e),e.serverInstanceId=null,aT(e),lT(e);for(const n of e.pendingOut){if(n.message.type!=="input"||!n.message.messageId)continue;Lo(e,n);const{messageId:r,...o}=n.message;n.message=o,n.encoded=JSON.stringify(o);const c=jr(n.encoded);e.pendingOutBytes+=c-n.bytes,n.bytes=c}Fa(e,t)}}function aT(e){const t=new Set;let n=0;for(const[r,o]of e.unackedInputs)o.sentInstanceId!==null&&(t.add(r),o.durable&&(n+=1));if(t.size!==0){e.pendingOut=e.pendingOut.filter(r=>{const o=r.message.type==="input"?r.message.messageId:void 0;return!o||!t.has(o)?!0:(e.pendingOutBytes=Math.max(0,e.pendingOutBytes-r.bytes),!1)});for(const r of t){const o=e.unackedInputs.get(r);o&&Lo(e,o)}n>0&&oT(e,{message:`The terminal server restarted before ${n} ${n===1?"input was":"inputs were"} acknowledged. NTerminal did not resend ${n===1?"it":"them"} to avoid running input twice.`,ready:!1})}}function oT(e,t){e.pendingNotices.push(t),e.pendingNotices.length>8&&e.pendingNotices.splice(0,e.pendingNotices.length-8)}function Ob(e){if(e.listeners.size===0)return;const t=e.pendingNotices.filter(n=>n.ready);if(t.length!==0){e.pendingNotices=e.pendingNotices.filter(n=>!n.ready);for(const n of t)Iu(e,{type:"message",message:{type:"error",message:n.message}})}}function Yh(e){Wa(e),ks(e),Js(e),$a(e),e.pendingOut.length=0,e.pendingOutBytes=0,e.unackedInputs.clear(),e.unackedInputBytes=0,e.pendingAckReceipts.clear()}function v_(e,t,n){if(!(e.socket!==t||t.readyState!==WebSocket.OPEN||!Bb(e.inputProtocolMode)||e.serverInstanceId!==n.instanceId))try{t.send(n.encoded)}catch{t.close()}}function Bb(e){return e==="ack"||e==="receipt-ack"}function U5(e,t){for(const n of e.pendingAckReceipts.values())if(v_(e,t,n),e.socket!==t||t.readyState!==WebSocket.OPEN)return}function K5(e,t){e.pendingAckReceipts.get(t.messageId)?.terminalId===t.terminalId&&e.pendingAckReceipts.delete(t.messageId)}function lT(e){e.pendingAckReceipts.clear()}function F5(e,t){if(e.outboundFlushTimer!==null)return;const n=e.outboundFlushDelayMs;e.outboundFlushDelayMs=Math.min(n5,n*2),e.outboundFlushTimer=window.setTimeout(()=>{e.outboundFlushTimer=null,Fa(e,t)},n)}function jr(e){return l5.encode(e).byteLength}function W5(e,t){if(jr(e)<=t)return e;let n=0,r=e.length;for(;n<r;){const o=Math.floor((n+r)/2);jr(e.slice(o))<=t?r=o:n=o+1}return n>0&&n<e.length&&e.charCodeAt(n)>=56320&&e.charCodeAt(n)<=57343&&(n+=1),e.slice(n)}const $5=[0,50,150,350],q5=[100,300,750],V5=2,Y5=[300,1200,2500],X5=1e3,G5=1e5,Z5="",__="\x1B[?1049l\x1B[?1047l\x1B[?47l",Q5=new Set(["47","1047","1049"]),J5=400,eB=9,tB=9,iB=32,nB=1.42,sB=2,rB=24,aB=720,oB=60,lB=1260,cB=6,uB=2,q1=[500,1500,3e3,5e3,8e3],V1=15e3,dB=2,hB=1e3,Y1="Do not take action. Wait for my next input.",Sf=6e4,fB=Sf+5*6e4,X1=Sf+6e4,pB=40,Rh=240,mB=5e3,Cu=new Map,xl=new Map;function G1({terminal:e,serverApi:t,active:n,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:u,codeServerContext:m,onSelect:g,onClose:p,onExit:y,onSnapshot:b,onAuthClose:C}){const k=v.useSyncExternalStore(mx,fv,()=>So),S=v.useSyncExternalStore(gx,pv,()=>Il),D=v.useSyncExternalStore(vx,gv,()=>!0),B=v.useSyncExternalStore(jh,vv,()=>!0),A=v.useSyncExternalStore(jh,_v,()=>!0),H=v.useSyncExternalStore($_,Ia,()=>jl),Y=v.useSyncExternalStore(vu,()=>_u("history.toggle"),()=>"Alt+H"),$=v.useSyncExternalStore(vu,()=>_u("scrollback.toggle"),()=>"Alt+S"),se=v.useSyncExternalStore(vu,()=>_u("subagents.toggle"),()=>"Alt+A"),J=v.useRef(null),W=v.useRef(null),xe=v.useRef(null),re=v.useRef(null),Ee=v.useRef(null),ie=v.useRef(e.id),V=v.useRef({onExit:y,onSnapshot:b}),X=v.useRef(t.createWebSocketUrl),F=v.useRef(C),le=v.useRef(null),O=v.useRef(null),M=v.useRef(null),j=v.useRef(!1),ae=v.useRef(new Map),we=v.useRef(new Map),N=v.useRef(new Set),U=v.useRef([]),ue=v.useRef(!1),Ce=v.useRef(null),Oe=v.useRef(0),De=v.useRef(!1),Be=v.useRef(!1),Ne=v.useRef(!1),Ue=v.useRef({terminalId:e.id,enabled:!1}),Fe=v.useRef([]),ne=v.useRef([]),me=v.useRef(0),R=v.useRef(!1),q=v.useRef(null),fe=v.useRef(0),ge=v.useRef(0),Q=v.useRef(null),ke=v.useRef(null),de=v.useRef(!1),Re=v.useRef(!1),Ie=v.useRef(!1),je=v.useRef(null),Ye=v.useRef(!1),ct=v.useRef(null),Nt=v.useRef(null),yt=v.useRef(!1),Tt=v.useRef(!1),$e=v.useRef(!1),St=v.useRef(!1),Lt=v.useRef(!1),ye=v.useRef(!1),Xe=v.useRef(!1),rt=v.useRef(n),Ze=v.useRef(r),Et=v.useRef(c),ut=v.useRef(k),Tn=v.useRef(S),gi=v.useRef(!1),ee=v.useRef(!1),Pe=v.useRef(null),st=v.useRef(0),tt=v.useRef(0),kt=v.useRef(e.id),Xt=v.useRef(()=>{}),Ft=v.useRef(null),ci=v.useRef(null),Gt=v.useRef(!1),si=v.useRef({key:null,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1}),ui=v.useRef(0),Wt=v.useRef(null),cn=v.useRef(0),ei=v.useRef(null),Hi=v.useRef(0),vn=v.useRef(!1),_n=v.useRef(!1),ti=v.useRef(null),Ji=v.useRef(null),[,ri]=v.useState("connecting"),[vi,_i]=v.useState(!1),[Bn,Hr]=v.useState(null),[jo,Ur]=v.useState(!1),[er,hs]=v.useState(null),[tr,fs]=v.useState(!1),[Rs,ps]=v.useState(!1),[Ms,zt]=v.useState(!1),[Io,Kr]=v.useState(!1),[$t,jn]=v.useState(null),en=e.agentCache&&$t&&e.agentCache.source.provider===$t.provider&&e.agentCache.source.sessionId===$t.sessionId?e.agentCache:null,[Fr,zo]=v.useState(()=>Date.now()),[ir,ms]=v.useState(!1),[Wr,bn]=v.useState(null),[Ui,Ns]=v.useState(!1),[Va,gs]=v.useState(!1),[Ki,vs]=v.useState(null),[As,Oi]=v.useState(!1),[mt,_s]=v.useState(!1),[nr,un]=v.useState(null),[$r,Ya]=v.useState(null),dn=m?.serverKey.trim()||(t.isAgent?"agent":"local"),[Po,qr]=v.useState(()=>ag(e.id)),bs=$t?.provider??e.agentStatus?.provider??null,Vr=bs!==null||kl(e.currentCommand),Ho=bs==="claude"||fT(e.currentCommand),Gl=bs!==null||kl(e.currentCommand),ys=e.capabilities?.tmuxScrollback===!0,bi=ys&&(Po??(Gl?A:B)),[Yr,Fi]=v.useState(!1);v.useLayoutEffect(()=>{rt.current=n},[n]),v.useLayoutEffect(()=>{Ze.current=r},[r]),v.useLayoutEffect(()=>{Et.current=c},[c]),v.useLayoutEffect(()=>{ut.current=k},[k]),v.useLayoutEffect(()=>{Tn.current=S},[S]),v.useLayoutEffect(()=>{gi.current=Ui},[Ui]),v.useLayoutEffect(()=>{ee.current=Va},[Va]),v.useLayoutEffect(()=>{Pe.current=$t},[$t]);const ai=v.useCallback((x,I={})=>{!x&&I.preserveOnNull||(Th(Pe.current,x)||(tt.current+=1),Pe.current=x,jn(Te=>Te&&x&&Te.provider===x.provider&&Te.sessionId===x.sessionId?Te:x))},[]),Ls=v.useCallback(async()=>(await t.getTerminalTranscriptSource(e.id)).source,[t,e.id]),sr=v.useCallback(()=>{const x=Pe.current,I=tt.current;x&&(async()=>{let Te=x;try{Te=await Ls()??Te}catch{}Te&&kt.current===e.id&&tt.current===I&&Th(x,Pe.current)&&(ai(Te,{preserveOnNull:!0}),Ft.current=zg(e.id,Te),gs(!1),Ns(!0))})()},[ai,Ls,e.id]),Xa=v.useCallback(()=>{Pe.current&&(Ns(!1),gs(!0))},[]),In=v.useCallback(async(x={})=>{const I=await Q1(dn,t,x);return vs(I),I},[dn,t]),yi=v.useCallback((x,I="info")=>{ei.current!==null&&window.clearTimeout(ei.current),Ya({id:cn.current++,message:x,tone:I}),ei.current=window.setTimeout(()=>{Ya(null),ei.current=null},3200)},[]),Xr=v.useCallback(()=>{const x=m?.serverKey.trim()||"local",I=m?.serverName.trim()||"Local",Te=m?.tabName.trim()||e.title||"Terminal",qe=Ki?.instances.find(dt=>dt.cwd===e.cwd);if(qe&&J1(Mh(x,qe.id))){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}if(qe&&jg(Mh(x,qe.id),qe.url)){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}let Ke=null;const et=()=>((!Ke||uT(Ke))&&(Ke=window.open("about:blank","_blank"),gB(Ke)),Ke);Ki?.installed!==!0&&et(),_s(!0),un(null),(async()=>{let dt=Ki;if(dt?.installed||(dt=await In({force:!0})),!dt?.installed||dt.supported===!1){Ig(Ke),Oi(!0);return}const pt=dt.instances.find(Ot=>Ot.cwd===e.cwd);if(pt){const Ot=Mh(x,pt.id);if(eC(Ke,Ot,pt.url)||jg(Ot,pt.url)!==null){yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}}const Ve=et();return{response:await t.openCodeServer({terminalId:e.id,serverName:I,tabName:Te}),targetPopup:Ve}})().then(dt=>{if(!dt)return;const{response:pt,targetPopup:Ve}=dt;b_(dn,pt.status),vs(pt.status);const qt=Mh(x,pt.instance.id);if(J1(qt)){Ig(Ve),yi("VS Code is already open. If your browser stayed here, check the existing VS Code tab.");return}eC(Ve,qt,pt.url)||jg(qt,pt.url)?yi("Opening VS Code..."):yi("Your browser blocked the VS Code tab. Allow pop-ups for this site and try again.","warning")}).catch(dt=>{Ig(Ke),Oi(!0),un(Nh(dt))}).finally(()=>_s(!1))},[m?.serverName,m?.tabName,dn,Ki,In,t,yi,e.cwd,e.id,e.title]);v.useEffect(()=>{let x=!1;return Q1(dn,t).then(I=>{x||vs(I)}).catch(()=>{}),()=>{x=!0}},[dn,t]),v.useEffect(()=>{if(Ki?.job?.status!=="running")return;const x=window.setInterval(()=>{In({force:!0}).catch(I=>un(Nh(I)))},1e3);return()=>window.clearInterval(x)},[Ki?.job?.status,In]),v.useEffect(()=>()=>{ei.current!==null&&window.clearTimeout(ei.current)},[]),v.useLayoutEffect(()=>{Xt.current=sr},[sr]),v.useLayoutEffect(()=>{ci.current=en},[en]),v.useLayoutEffect(()=>{Gt.current=ir},[ir]),v.useLayoutEffect(()=>{vn.current=Vr},[Vr]),v.useLayoutEffect(()=>{_n.current=Ho},[Ho]),v.useLayoutEffect(()=>{const x=Ue.current;Be.current=bi,Ne.current=ys,Ue.current={terminalId:e.id,enabled:bi},iC(J.current,bi),x.terminalId===e.id&&x.enabled&&!bi&&Qa(),bi||zt(!1)},[e.id,bi,ys]),v.useEffect(()=>{qr(ag(e.id)),Oe.current=0,De.current=!1,zt(!1),Za()},[e.id]),v.useEffect(()=>jh(()=>{qr(ag(e.id))}),[e.id]),v.useEffect(()=>()=>{$o()},[]),v.useEffect(()=>{Ee.current?.(r&&e.status==="running"),r&&e.status==="running"&&w()},[r,e.id,e.status]),v.useEffect(()=>{r&&n&&e.status==="running"&&Ss("auto")},[n,r,e.status]),v.useEffect(()=>{V.current={onExit:y,onSnapshot:b}},[y,b]),v.useLayoutEffect(()=>{X.current=t.createWebSocketUrl,F.current=C},[t,C]),v.useLayoutEffect(()=>{ie.current=e.id,Xe.current=!1,Kr(!1)},[e.id]),v.useEffect(()=>{let x=!1,I=null,Te=0;const qe=e.agentStatus?.provider==="codex"||e.agentStatus?.provider==="claude",Ke=qe||zB(e.currentCommand),et=qe||kl(e.currentCommand);function dt(){I!==null&&(window.clearTimeout(I),I=null)}function pt(qt){if(x)return;let Ot;if(qt)Ot=V1;else if(Te<q1.length){if(!Ke)return;Ot=q1[Te++]}else{if(!et)return;Ot=V1}I=window.setTimeout(()=>{I=null,Ve()},Ot)}async function Ve(){try{const qt=Pe.current!==null,Ot=await Ls();if(x)return;if(Ot){st.current=0,ai(Ot),pt(!0);return}st.current+=1;const At=!!(qt&&Ke&&st.current<dB);ai(null,{preserveOnNull:At}),pt(At)}catch(qt){if(x)return;Pg(qt)&&ai(null),pt(!1)}}return kt.current!==e.id&&(kt.current=e.id,tt.current+=1,Pe.current=null,st.current=0,jn(null)),e.status!=="running"?(tt.current+=1,Pe.current=null,st.current=0,jn(null),()=>{x=!0,dt()}):(Ve(),()=>{x=!0,dt()})},[ai,Ls,t,e.agentStatus?.provider,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const x=zg(e.id,$t),I=Ft.current;I!==null&&x!==null&&I!==x&&(ke.current=null,de.current=!1,Re.current=!1,gi.current&&Ns(!1),gs(!1)),Ft.current=x},[e.id,$t?.provider,$t?.sessionId]),v.useEffect(()=>{if(e.status!=="running"||!$t){ms(!1);return}const x=window.setInterval(()=>{zo(Date.now())},hB);return()=>{window.clearInterval(x)}},[e.status,$t?.provider,$t?.sessionId]),v.useEffect(()=>{const x=bB(en);si.current.key!==x&&(si.current={key:x,warnedFiveMinutes:!1,warnedOneMinute:!1,sent:!1,skipped:!1})},[en?.expiresAt,en?.source?.provider,en?.source?.sessionId]),v.useEffect(()=>{if(!ir||!en||en.status!=="ready")return;const x=dT(en,Fr);if(x===null||x<=0)return;const I=si.current;!I.warnedFiveMinutes&&x<=fB&&x>X1&&(I.warnedFiveMinutes=!0,Zn({tone:"info",message:"Cache keep-alive will be sent in 5m",detail:"Use Skip once or Turn off if you do not want NTerminal to send a short idle prompt."})),!I.warnedOneMinute&&x<=X1&&x>Sf&&(I.warnedOneMinute=!0,Zn({tone:"warning",message:"Cache keep-alive will be sent in 1m",detail:"NTerminal will only send it if this pane is idle."})),!I.sent&&!I.skipped&&x<=Sf&&oc()},[ir,Fr,en,e.activity,e.agentStatus?.state,e.status]),v.useEffect(()=>{function x(I){if(!rt.current||!Ze.current||I.isComposing||I.key==="Process"||wB(I.target))return;const Te=Sx(I);if(Te?.id==="history.toggle"&&Pe.current){I.preventDefault(),I.stopPropagation(),gi.current?Ns(!1):Xt.current();return}if(Te?.id==="subagents.toggle"&&Pe.current){I.preventDefault(),I.stopPropagation(),ee.current?gs(!1):Xa();return}if(Te?.id==="scrollback.toggle"&&Ne.current){I.preventDefault(),I.stopPropagation(),ac();return}}return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{const x=W.current;x&&(x.options.disableStdin=e.status==="exited"),e.status==="exited"&&ri("closed")},[e.status]),v.useEffect(()=>{const x=W.current;x&&(x.options.fontSize=k,rg(k,Tn.current).then(()=>{ut.current===k&&tn()}))},[k]),v.useEffect(()=>{const x=W.current;x&&(x.options.fontFamily=hv(S),rg(ut.current,S).then(()=>{Tn.current===S&&tn()}))},[S]),v.useEffect(()=>{const x=W.current;x&&(x.options.theme=Z1(H))},[H]),v.useEffect(()=>{const x=J.current;if(!x)return;let I=!1,Te=null,qe=null,Ke=null,et=null,dt=null,pt=null,Ve=null;le.current=null,Lt.current=!1,ye.current=!1,Ye.current=!1,Ju(),ed(),yn(),ue.current=!1;const qt=ut.current,Ot=Tn.current,At=new l3({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:hv(Ot),fontSize:qt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:G5,theme:{...Z1(Ia())}}),Ps=new JM;return At.loadAddon(Ps),et=FO(At),W.current=At,xe.current=Ps,rg(qt,Ot).then(()=>{if(I)return;At.open(x),iC(x,Be.current),Lt.current=!0,Te=LO(At,{onPasteText:sp,onInterrupt:np,shouldInterruptPlainCtrlC:()=>_n.current}),Ze.current&&rt.current&&e.status==="running"&&Ss("auto"),tn(),dt=WB(x,At,()=>ut.current*1.2,zs,Hs=>{hn(Hs)},Ga,cr,()=>Be.current,Qr),pt=UB(x,At,zs,Hs=>{hn(Hs)},Ga,cr,()=>Be.current,Qr);const qo=new R3;qe=At.onData(Hs=>{if(Xe.current){const cc=z3(Hs);if(cc){eo(!1),ur(cc);return}}const lc=qo.accept(Hs);lc&&ur(lc)}),Ke=At.onScroll(Hs=>{if(Tt.current||St.current||$e.current){nn();return}Ql(),Vn(At)&&lr({scrollToBottom:!0}),zs(),!Be.current&&Hs<=3&&hn()}),Ve=new ResizeObserver(()=>{pe()}),Ve.observe(x),ye.current&&(or(),ye.current=!1,tn()),Zl()}),()=>{ld(re.current,{updateUi:!1}),I=!0,Lt.current=!1,ye.current=!1,Ju(),ed(),O.current=null,M.current=null,j.current=!1,td(),ue.current=!1,id(),$e.current=!1,R.current=!1,fe.current+=1,ge.current+=1,q.current=null,ti.current=null,Ji.current=null,Ie.current=!1,je.current=null,_i(!1),dt?.(),pt?.(),Ve?.disconnect(),Te?.dispose(),qe?.dispose(),Ke?.dispose(),et?.dispose(),At.dispose(),W.current=null,xe.current=null}},[e.id]),v.useEffect(()=>{const x=X.current(e.id),I=u5(x,rr);return re.current=I.send,Ee.current=I.setForeground,I.setForeground(Ze.current&&e.status==="running"),ri(I.status),I.status==="connected"&&tn(),I.snapshot&&(V.current.onSnapshot(I.snapshot,{notifyCompletion:!1}),W.current&&(tn(),Os(I.output,I.history),tn())),()=>{ld(I.send,{updateUi:!1}),I.setForeground(!1),I.detach(),re.current=null,Ee.current=null}},[e.id,e.status]);function rr(x){if(x.type==="status"){ri(x.status),x.status==="unauthorized"&&F.current?.({source:"terminal-ws-1008",terminalId:e.id}),x.status==="connected"&&(tn(),Ko());return}if(x.type==="upgrade_rejected"){F.current?.({source:"terminal-ws-upgrade-rejected",terminalId:e.id});return}if(x.type==="outbound_flushed"){ue.current&&(ue.current=!1,Jr());return}z(x.message)}function yn(x=[],I=null){Fe.current=[],ne.current=Ah(x),me.current=0,R.current=!1,q.current=null,$e.current=!1,fe.current+=1,Q.current=I,ke.current=null,de.current=!1,Re.current=!1,Ie.current=!1,je.current=null,ye.current=!1,ti.current=null,Ji.current=null,ct.current=null,yt.current=!1,_i(!1),Hr(null),Ur(!1),hs(null),fs(!1),ps(!1)}function Os(x=[],I=null){if($e.current||R.current){Ji.current={output:x,history:I,appendFromLiveOutputIndex:ne.current.length};return}yn(x,I),ar()}function Bs(){if($e.current||R.current)return!1;const x=Ji.current;if(!x)return!1;const I=ne.current.slice(x.appendFromLiveOutputIndex);return Ji.current=null,yn([...x.output,...I],x.history),ar(),!0}function ar(){if(!W.current||!Lt.current){ye.current=!0;return}ye.current=!1,or()}async function or(){const x=W.current;if(!x)return;const I=Lh(x,yt.current),Te=I?ne.current.length:me.current,qe=await js(x,{liveOutputLimit:Te,scrollToBottom:I});W.current===x&&(nn(),qe&&Ko())}function js(x,I={}){return new Promise(Te=>{$e.current=!0,R.current=!1;const qe=fe.current+1;fe.current=qe;const Ke=Math.max(0,Math.min(I.liveOutputLimit??ne.current.length,ne.current.length)),et=I.historyPages??Fe.current,dt=()=>W.current===x&&fe.current===qe,pt=()=>dt()&&(I.isCurrent?.()??!0),Ve=()=>{dt()&&($e.current=!1),Te(!1)},qt=()=>{if(!pt()){Ve();return}try{me.current=Ke,I.scrollToBottom&&Wo(x)}finally{if($e.current=!1,Bs()){Te(!1);return}const At=sd();At?lr(At):I.applyDeferredSnapshot!==!1&&ec(),Te(!0)}},Ot=()=>{if(!pt()){Ve();return}x.clear();const At=Ah([...et,...ne.current.slice(0,Ke)]);if(At.length===0){qt();return}for(let Ps=0;Ps<At.length;Ps+=1){const qo=At[Ps];Ps===At.length-1?x.write(qo,qt):x.write(qo)}};if(x.buffer.active.type==="alternate"){x.write(__,Ot);return}Ot()})}async function hn(x=0){const I=W.current;if(Ie.current||!I)return;if(Jl(I)){nn();return}const Te=Q.current,qe=ge.current,Ke=Symbol("history-load"),et=()=>W.current===I&&ge.current===qe;je.current=Ke,Ie.current=!0,_i(!0);const dt=I.buffer.active.viewportY;try{let pt=!!(Te&&!Te.hasMore);if(!pt)try{const Ve=await t.getTerminalHistory(e.id,{beforeLine:Te?.startLine??0,...Te?.snapshotHistorySize!==void 0?{snapshotHistorySize:Te.snapshotHistorySize}:{},...Te?.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Te.snapshotHistoryLimit}:{},...Te?.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Te.snapshotHistoryToken}:{},...Te?.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Te.snapshotPaneWidth}:{},limit:X5});if(!et()||Q.current!==Te)return;const qt=()=>et()&&Q.current===Te;if(Ve.invalidated){E();return}const Ot=Ve.hasMore&&Ve.snapshotHistorySize!==void 0&&Ve.snapshotPaneWidth!==void 0,At={startLine:Ve.startLine,endLine:Ve.endLine,hasMore:Ot,...Ve.snapshotHistorySize!==void 0?{snapshotHistorySize:Ve.snapshotHistorySize}:{},...Ve.snapshotHistoryLimit!==void 0?{snapshotHistoryLimit:Ve.snapshotHistoryLimit}:{},...Ve.snapshotHistoryToken!==void 0?{snapshotHistoryToken:Ve.snapshotHistoryToken}:{},...Ve.snapshotPaneWidth!==void 0?{snapshotPaneWidth:Ve.snapshotPaneWidth}:{}};if(Ve.output.length>0){await Gn(I,Ve.output,dt,x)&&qt()&&(Q.current=At);return}if(!qt())return;Q.current=At,pt=!Ot}catch(Ve){pt=et()&&Pg(Ve)}if(pt){if(!et()||Jl(I)){nn();return}await ki(I,dt,x,et)}}catch{}finally{je.current===Ke&&(je.current=null,Ie.current=!1,_i(!1))}}async function ki(x,I,Te,qe){if(!qe()||de.current||Re.current)return;const Ke=Pe.current,et=tt.current,dt=ke.current,pt=()=>qe()&&tt.current===et&&Th(Ke,Pe.current)&&ke.current===dt;try{const Ve=await t.getTerminalTranscriptHistory(e.id,{...dt?{cursor:dt}:{},limit:J5}),qt=Ve.output.map(Ck);if(!Ve.source||Ve.terminalId!==e.id||!pt())return;if(Ke&&!Rb(Ke,Ve.source)){ke.current=null,de.current=!1,Re.current=!1,ai(Ve.source);return}if(qt.length===0){ai(Ve.source),ke.current=Ve.cursor,Re.current=!Ve.hasMore||!Ve.cursor;return}await Gn(x,qt,I,Te,pt)&&pt()&&(ai(Ve.source),ke.current=Ve.cursor,Re.current=!Ve.hasMore||!Ve.cursor)}catch(Ve){pt()&&Pg(Ve)&&(de.current=!0)}}async function Gn(x,I,Te,qe,Ke){if(Jl(x)||Ke&&!Ke())return nn(),!1;const et=Fe.current,dt=[...I,...et],pt=PB(I),Ve=fe.current+1,qt=await js(x,{liveOutputLimit:me.current,scrollToBottom:!1,historyPages:dt,applyDeferredSnapshot:!1,...Ke?{isCurrent:Ke}:{}}),Ot=Ke!==void 0&&!Ke();return!qt||Ot||W.current!==x?(Ot&&W.current===x&&fe.current===Ve&&await js(x,{liveOutputLimit:me.current,scrollToBottom:!1,historyPages:et,applyDeferredSnapshot:!1})&&W.current===x&&(tc(x,Te),yt.current=!Vn(x),zs()),!1):(Fe.current=dt,tc(x,Math.max(0,Te+pt+Math.min(0,qe))),yt.current=!Vn(x),zs(),!0)}v.useEffect(()=>{const x=window.visualViewport;function I(){document.visibilityState!=="hidden"&&w()}function Te(){w()}function qe(){w()}function Ke(){pe()}function et(){Qe()}return document.addEventListener("visibilitychange",I),window.addEventListener("pageshow",Te),window.addEventListener("online",qe),window.addEventListener("resize",Ke),window.addEventListener(mf,et),x?.addEventListener("resize",Ke),x?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",I),window.removeEventListener("pageshow",Te),window.removeEventListener("online",qe),window.removeEventListener("resize",Ke),window.removeEventListener(mf,et),x?.removeEventListener("resize",Ke),x?.removeEventListener("scroll",Ke)}},[e.id]);function w(){document.visibilityState==="hidden"||!Ze.current||(Ko(),tn())}function E(){const x=X.current(e.id);ge.current+=1,Ye.current=!0,ti.current=null,ri("reconnecting"),tn(),d5(x)}function z(x){if(x.type==="snapshot"&&x.terminal.id===e.id){ge.current+=1,V.current.onSnapshot(x.terminal,{notifyCompletion:!1});const Te=Ye.current;Ye.current=!1;const qe=W.current;if(!qe)return;if(tn(),Te){oe(x.output,x.history??null);return}if(Zf(qe,x.terminal)){Jf(x.output,x.history??null),nn(),tn();return}Os(x.output,x.history??null),tn();return}if(x.type==="terminal_updated"&&x.terminal.id===e.id){V.current.onSnapshot(x.terminal,{notifyCompletion:!0});return}if(x.type==="output"&&x.terminalId===e.id){const Te=pT(x.data);if(!Te)return;ne.current.push(Te),W.current&&Lt.current?lr({scrollToBottom:!0}):ye.current=!0;return}const I=W.current;if(I){if(x.type==="exit"&&x.terminalId===e.id){V.current.onExit(x.exitCode),ri("closed");return}x.type==="error"&&I.writeln(`\r
|
|
52
|
-
[nterminal] ${x.message}`)}}function oe(x,I){Os(x,I),tn()}function Se(x=25){if(document.visibilityState==="hidden"||!Ze.current||ae.current.has(x))return;const I=window.setTimeout(()=>{ae.current.delete(x),!Me()&&ep()},x);ae.current.set(x,I)}function pe(){Me()||Zl()}function Me(){const x=Wi();return x&&ot(x)?(j.current=!0,M.current=x,!0):x&&Si(x)?(j.current=!1,M.current=null,!0):((!x||!x.composeOpen&&!x.keyboardVisible)&&(j.current=!1,M.current=null),!1)}function Qe(){if(!j.current)return;const x=Wi();x&&(x.composeOpen||x.keyboardVisible)||(j.current=!1,M.current=null)}function ot(x){if(!x.mobileLike||!x.composeOpen&&!x.keyboardVisible)return!1;const I=O.current;return I?Gr(x.windowWidth,I.windowWidth)&&Gr(x.visualViewportWidth,I.visualViewportWidth)&&Gr(x.containerWidth,I.containerWidth):!1}function Si(x){if(!x.mobileLike||x.composeOpen||x.keyboardVisible)return!1;const I=M.current;return!I||!I.composeOpen&&!I.keyboardVisible?!1:Gr(x.windowWidth,I.windowWidth)&&Gr(x.visualViewportWidth,I.visualViewportWidth)&&Gr(x.containerWidth,I.containerWidth)}function Wi(){const x=J.current;if(!x||x.isConnected===!1)return null;const I=x.getBoundingClientRect(),Te=Uo(window.innerWidth)??0,qe=Uo(window.visualViewport?.width)??Te,Ke=Uo(I.width)??Uo(x.clientWidth)??Te;if(Te<=0||qe<=0||Ke<=0)return null;const{keyboardVisible:et}=a_(),dt=document.documentElement.hasAttribute(Uf),pt=Is()||et;return{windowWidth:Te,visualViewportWidth:qe,containerWidth:Ke,composeOpen:dt,keyboardVisible:et,mobileLike:pt}}function Is(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function zn(){return a_().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function Uo(x){return typeof x=="number"&&Number.isFinite(x)&&x>0?x:null}function Gr(x,I){return Math.abs(x-I)<=V5}function Zl(){for(const x of $5)Se(x)}function tn(){le.current=null,Zl()}function Ko(){if(Fo(),N.current.size===0&&typeof window.requestAnimationFrame=="function"){const x=window.requestAnimationFrame(()=>{N.current.delete(x),Fo();const I=window.requestAnimationFrame(()=>{N.current.delete(I),Fo()});N.current.add(I)});N.current.add(x)}for(const x of q5){if(we.current.has(x))continue;const I=window.setTimeout(()=>{we.current.delete(x),Fo()},x);we.current.set(x,I)}}function Fo(){const x=W.current;if(!(!x||!Lt.current||document.visibilityState==="hidden"||!Ze.current||J.current?.isConnected===!1))try{x.refresh(0,Math.max(0,x.rows-1))}catch{}}function Ju(){for(const x of ae.current.values())window.clearTimeout(x);ae.current.clear()}function ed(){for(const x of we.current.values())window.clearTimeout(x);we.current.clear();for(const x of N.current)window.cancelAnimationFrame(x);N.current.clear()}function td(){for(const x of U.current)window.clearTimeout(x);U.current=[]}function zs(){if(nn(),!ct.current){Ur(!1);return}Ur(!0),id(),Nt.current=window.setTimeout(()=>{Nt.current=null,Ur(!1)},1200)}function nn(){const x=W.current,I=x?HB(x):null;if(ct.current=I,Hr(I),ps(!!(x&&I)),fs(!!(x&&I&&!Vn(x))),I||!x||!Xf()){hs(null);return}hs({alternate:x.buffer.active.type==="alternate"})}function Xf(){const x=Q.current;return Fe.current.length>0||!!x?.hasMore}function id(){Nt.current!==null&&(window.clearTimeout(Nt.current),Nt.current=null)}function Ql(){const x=W.current;x&&(yt.current=!Vn(x),nn())}function nd(x){q.current=Hg(q.current,x)}function Gf(x){const I=q.current;return q.current=null,Hg(I,x)}function sd(){const x=q.current;return q.current=null,x}function lr(x={}){const I=W.current;if(!I||!Lt.current){ye.current=!0;return}if(ti.current&&!$e.current&&!R.current&&Vn(I)){ec();return}if($e.current){nd(x);return}if(R.current){nd(x);return}const Te=Gf(x);if(!Te.force&&!Lh(I,yt.current)){nn();return}R.current=!0;const qe=fe.current,Ke=()=>{if(W.current!==I||fe.current!==qe)return;if(!Te.force&&!Lh(I,yt.current)){if(R.current=!1,Bs())return;nn();return}const et=me.current,dt=ne.current[et];if(dt===void 0){if(R.current=!1,Bs())return;Te.scrollToBottom&&Wo(I),nn();const pt=sd();pt?lr(Hg(Te,pt)):ec();return}I.write(dt,()=>{W.current!==I||fe.current!==qe||(me.current=et+1,Ke())})};Ke()}function Jl(x){return ti.current!==null||!Vn(x)&&(Qf()||R.current||$e.current)}function Zf(x,I){return(I?.agentStatus?.provider==="codex"||I?.agentStatus?.provider==="claude"||vn.current||kl(I?.currentCommand))&&!Vn(x)}function Qf(){return me.current<ne.current.length}function Jf(x,I){ti.current={output:x,history:I,appendFromLiveOutputIndex:ne.current.length}}function ec(){const x=W.current,I=ti.current;if(!x||!I||!Vn(x)||R.current||$e.current)return;const Te=Ah(I.output),qe=Ah(ne.current.slice(I.appendFromLiveOutputIndex));ti.current=null,Os([...Te,...qe],I.history),tn()}function Ga(){St.current=!0}function cr(){Ql(),St.current=!1;const x=W.current;x&&Vn(x)&&lr({scrollToBottom:!0})}function Wo(x){ic(()=>nC(x))&&(yt.current=!1)}function tc(x,I){ic(()=>(x.scrollToLine(I),!0))}function ic(x){Tt.current=!0;try{return x()}finally{Tt.current=!1}}function rd(){const x=W.current;if(!x)return;const I=()=>{Be.current&&(Ja(re.current),zt(!1)),nC(x),yt.current=!1,nn(),lr({force:!0,scrollToBottom:!0}),Ss("scroll-action")};if(x.buffer.active.type==="alternate"){x.write(__,I);return}I()}function nc(x){const I=W.current,Te=J.current;if(!I||!Te)return;const qe=Te.getBoundingClientRect();if(qe.height<=0)return;const Ke=Math.max(0,Math.min(1,(x-qe.top)/qe.height)),et=Math.round(I.buffer.active.baseY*Ke);Ga();try{I.scrollToLine(et)}finally{cr()}yt.current=!Vn(I),nn(),zs(),et<=3&&hn()}function ad(x){x.preventDefault(),x.stopPropagation(),x.currentTarget.setPointerCapture?.(x.pointerId),nc(x.clientY)}function Zr(x){(x.buttons&1)!==0&&(x.preventDefault(),x.stopPropagation(),nc(x.clientY))}function ep(){const x=W.current,I=xe.current;if(!(!x||!I)&&!(document.visibilityState==="hidden"||!Ze.current||J.current?.isConnected===!1))try{const Te=Lh(x,yt.current),qe=Wi();I.fit(),qe&&(O.current=qe),Te&&Wo(x),x.refresh(0,Math.max(0,x.rows-1)),nn();const Ke={cols:x.cols,rows:x.rows},et=le.current;if(et&&et.cols===Ke.cols&&et.rows===Ke.rows)return;sc({type:"resize",terminalId:e.id,cols:Ke.cols,rows:Ke.rows})&&(le.current=Ke)}catch{}}function od(x,I){const Te=re.current;return Te?Te(x,I):"rejected"}function sc(x){return od(x)!=="rejected"}function Za(){Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null)}function rc(){Za();const x=Math.max(-Rh,Math.min(Rh,Oe.current));if(Oe.current=0,x===0)return!1;const I=sc({type:"scrollback_scroll",terminalId:e.id,lines:x});return I&&(De.current=!0,x<0&&zt(!0)),I}function Qr(x){if(!Be.current||x===0)return;const I=Oe.current+x;Oe.current=Math.max(-Rh,Math.min(Rh,I)),Ce.current===null&&(Ce.current=window.setTimeout(()=>{Ce.current=null,rc()},pB))}function Qa(){Ja(re.current)}function ld(x=re.current,I={}){const Te=De.current;Za(),Oe.current=0,De.current=!1,I.updateUi!==!1&&zt(!1),Te&&x?.({type:"cancel_scrollback",terminalId:e.id})}function Ja(x){Za(),Oe.current=0,De.current=!1,zt(!1),x?.({type:"cancel_scrollback",terminalId:e.id})}function ac(){if(!Ne.current)return;const x=!Be.current;qr(uM(ie.current,x)),ip()}function cd(){const x=!Gt.current;Gt.current=x,ms(x),Zn({tone:x?"info":"skipped",message:x?"Cache keep-alive enabled":"Cache keep-alive off",...x?{detail:"NTerminal will send a short idle prompt before the estimated cache expires."}:{}})}function $o(){Wt.current!==null&&(window.clearTimeout(Wt.current),Wt.current=null)}function Zn(x,I={}){$o();const Te=ui.current+1;ui.current=Te,bn({...x,id:Te}),!I.sticky&&(Wt.current=window.setTimeout(()=>{Wt.current=null,bn(qe=>qe?.id===Te?null:qe)},12e3))}function ud(){si.current.skipped=!0,Zn({tone:"skipped",message:"Skipped this cache keep-alive",detail:"The timer will watch the next cache window if keep-alive stays on."})}function dd(){Gt.current=!1,ms(!1),Zn({tone:"skipped",message:"Cache keep-alive off"})}async function oc(){const x=si.current;if(x.sent||x.skipped)return;const I=tp();if(x.sent=!0,I){Zn({tone:"skipped",message:"Skipped cache keep-alive",detail:I});return}if(ur(`${Y1}\r`,{userInitiated:!1})==="rejected"){Zn({tone:"skipped",message:"Skipped cache keep-alive",detail:"The terminal connection was unavailable."});return}Zn({tone:"success",message:"Cache keep-alive sent",detail:Y1})}function tp(){const x=ci.current,I=Pe.current;return Gt.current?e.status!=="running"?"Pane is not running.":!x||x.status!=="ready"||!x.source||!I?"Transcript cache status is unavailable.":x.source.provider!==I.provider||x.source.sessionId!==I.sessionId?"The transcript session changed.":e.agentStatus?.state==="working"?`${Ro(I.provider)} is still working.`:e.activity==="busy"?e.currentCommand?`Pane is busy: ${e.currentCommand}.`:"Pane is busy.":Al(e.id).text.trim()?"Compose has an unsent draft.":CB(J.current)?"Pane input is focused.":Date.now()-Hi.current<5*6e4?"User input was sent recently.":null:"Keep-alive was turned off."}function ip(){const x=W.current;x&&(Wo(x),nn())}function ur(x,I={}){rc();const Te=De.current;lr({force:!0,scrollToBottom:!0});const qe=od({type:"input",terminalId:e.id,data:x,...Te?{cancelScrollbackMode:!0}:{}},{durability:I.userInitiated===!1?"live-only":"durable"});return qe==="rejected"?(I.userInitiated!==!1&&yi("Input was not sent because the terminal connection buffer is full or unavailable.","error"),qe):(I.userInitiated!==!1&&(Hi.current=Date.now()),Te&&(De.current=!1,zt(!1)),IB(x)&&(qe==="sent"?Jr():qe==="queued"&&(ue.current=!0)),qe)}function np(){Xe.current&&eo(!1),ur(Z5)}function sp(x){const I=Tg(x,{bracketedPasteMode:W.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});I&&ur(I)}function Sn(x,I){const Te=W.current?.modes.bracketedPasteMode===!0,qe=bs==="codex"||bs==="claude"||kl(e.currentCommand),Ke=x.parts.map(et=>et.kind==="image"&&qe?Tg(et.path,{bracketedPasteMode:!0,stripTrailingLineBreaks:!0}):Tg(et.kind==="image"?et.path:et.value,{bracketedPasteMode:Te,stripTrailingLineBreaks:!1})).join("");return Ke?ur(`${Ke}${hO(I)}`)!=="rejected":!1}function Jr(){!Et.current||!rt.current||(td(),U.current=Y5.map(x=>{const I=window.setTimeout(()=>{U.current=U.current.filter(Te=>Te!==I),Et.current&&rt.current&&sc({type:"refresh_cwd",terminalId:e.id})},x);return I}))}function Ss(x="terminal-interaction"){gi.current||zn()&&(x==="auto"||x==="scroll-action")||W.current?.focus()}const hd=v.useCallback(()=>{Ns(!1)},[]),fd=v.useCallback(async()=>{const x=Pe.current,I=tt.current;try{const Te=await t.getTerminalTranscriptSource(e.id);if(!Te.source||kt.current!==e.id||tt.current!==I||!Th(x,Pe.current))return;ke.current=null,de.current=!1,Re.current=!1,ai(Te.source),Ft.current=zg(e.id,Te.source)}catch{}},[ai,t,e.id]);function pd(){Kr(x=>{const I=!x;return Xe.current=I,I}),Ss("input-action")}function eo(x){Xe.current=x,Kr(x)}function rp(x){Xe.current&&eo(!1),ur(I3(x)),Ss("input-action")}async function dr(x="install"){_s(!0),un(null);try{const I=x==="update"?await t.updateCodeServer():await t.installCodeServer();b_(dn,I.status),vs(I.status)}catch(I){un(Nh(I))}finally{_s(!1)}}return f.jsxs("section",{className:"terminal-pane","data-active":n,"data-tmux-scrollback":bi?"true":"false",onMouseDown:()=>{n||g()},children:[f.jsx(xB,{terminal:e,canClose:o,tabId:u,transcriptSource:$t,transcriptShortcutLabel:Y,subagentsShortcutLabel:se,transcriptCacheStatus:en,transcriptCacheNow:Fr,cacheKeepAliveEnabled:ir,codeServerAvailable:!0,codeServerInstallState:Ki===null?"unknown":Ki.installed?"installed":"missing",codeServerBusy:mt||Ki?.job?.status==="running",codeServerSupported:Ki?.supported!==!1,scrollbackShortcutLabel:$,tmuxScrollbackSupported:ys,tmuxScrollbackEnabled:bi,onToggleCacheKeepAlive:cd,onOpenCodeServer:Xr,onToggleTmuxScrollback:ac,onOpenTranscript:sr,onOpenSubagents:Xa,onReload:E,onClose:p}),f.jsx("div",{className:"xterm-container",ref:J}),vi?f.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:f.jsx("span",{"aria-hidden":"true"})}):null,D&&!bi&&Bn?f.jsxs("div",{className:"terminal-scroll-progress","data-active":jo,"aria-hidden":"true",children:[Bn.current,"/",Bn.total]}):D&&!bi&&er?f.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":er.alternate?"alternate":"normal","aria-hidden":"true",children:[er.alternate?"alt ":"","0/?"]}):null,tr||bi&&Ms?f.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),rd()},children:"↓"}):null,Rs&&!bi?f.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:ad,onPointerMove:Zr,children:f.jsx("span",{"aria-hidden":"true"})}):null,n&&e.status==="running"?Yr?f.jsx(B3,{ctrlActive:Io,onCtrl:pd,onStandaloneKey:rp,onPreserveFocus:()=>Ss("input-action"),onHide:()=>Fi(!1)}):f.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:x=>{x.stopPropagation(),Ss("input-action")},onPointerDown:x=>{x.stopPropagation(),Ss("input-action")},onClick:()=>Fi(!0),children:"⌨"}):null,f.jsx(wO,{terminalId:e.id,onSubmit:Sn,onUploadAttachments:(x,I)=>t.uploadComposeAttachments({terminalId:e.id,files:x,signal:I.signal,onProgress:I.onProgress}),...typeof t.getComposeAttachmentLimits=="function"?{onGetAttachmentLimits:()=>t.getComposeAttachmentLimits()}:{},...typeof t.deleteComposeAttachments=="function"?{onDeleteAttachments:x=>t.deleteComposeAttachments({terminalId:e.id,attachmentIds:x})}:{},queueAvailable:bs==="codex"||hT(e.currentCommand),disabled:e.status!=="running"}),f.jsx(DB,{toast:Wr,onSendNow:()=>{oc()},onSkipOnce:ud,onTurnOff:dd,onDismiss:()=>bn(null)}),Ui&&$t?f.jsx(RB,{terminalId:e.id,serverApi:t,source:$t,fontSize:k,onClose:hd,onReloadLatest:fd}):null,Va&&$t?f.jsx(S3,{terminalId:e.id,serverApi:t,source:$t,fontSize:k,onClose:()=>gs(!1)}):null,$r?f.jsx(TB,{notice:$r}):null,As?f.jsx(kB,{status:Ki,busy:mt,error:nr,onInstall:()=>{dr("install")},onUpdate:()=>{dr("update")},onOpen:Xr,onRefresh:()=>{In({checkLatest:!0}).catch(x=>un(Nh(x)))},onClose:()=>Oi(!1)}):null]})}function Z1(e){return v2(e)}async function Q1(e,t,n={}){const r=n.checkLatest===!0,o=n.force===!0||r,c=Date.now(),u=xl.get(e);if(!o&&u?.status&&c-u.fetchedAt<=mB)return u.status;if(u?.inflight&&(!r||u.inflightCheckLatest))return u.inflight;let m;return m=t.getCodeServerStatus(r?{checkLatest:!0}:void 0).then(g=>(b_(e,g),g)).catch(g=>{const p=xl.get(e);throw p?.inflight===m&&(p.status?xl.set(e,{status:p.status,fetchedAt:p.fetchedAt}):xl.delete(e)),g}),xl.set(e,{...u?.status?{status:u.status,fetchedAt:u.fetchedAt}:{fetchedAt:c},inflight:m,inflightCheckLatest:r}),m}function b_(e,t){xl.set(e,{status:t,fetchedAt:Date.now()})}function Mh(e,t){return`${e}:${t}`}function cT(e){return`nterminal-code-server-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function J1(e){const t=Cu.get(e);if(!t)return!1;try{return t.closed?(Cu.delete(e),!1):(t.focus(),!0)}catch{return Cu.delete(e),!1}}function jg(e,t){const n=window.open(t,cT(e));if(!n)return null;Cu.set(e,n);try{n.focus()}catch{}return n}function eC(e,t,n){if(!e||uT(e))return!1;try{return e.name=cT(t),e.location.href=n,Cu.set(t,e),e.focus(),!0}catch{return!1}}function gB(e){if(e)try{e.document.title="Opening VS Code...",e.document.body.style.margin="0",e.document.body.style.background="#0a0d10",e.document.body.style.color="#e2e8ee",e.document.body.style.font="13px ui-monospace, SFMono-Regular, Menlo, monospace",e.document.body.textContent="Opening VS Code..."}catch{}}function uT(e){if(!e)return!0;try{return e.closed}catch{return!0}}function Ig(e){if(e)try{e.closed||e.close()}catch{}}function vB(e,t,n){const r=_B(e,t),o=tC(r*Math.max(1,n),oB,lB);return{limit:tC(Math.ceil(o/sB),rB,aB),maxLines:o}}function _B(e,t){const n=e?.clientHeight??0;if(n<=0)return iB;const r=Math.max(10,t*nB);return Math.max(1,Math.floor(n/r))}function tC(e,t,n){return Math.max(t,Math.min(n,Math.floor(e)))}function bB(e){return!e?.source||!e.expiresAt?null:`${e.source.provider}:${e.source.sessionId}:${e.expiresAt}`}function zg(e,t){return t?`${e}:${t.provider}:${t.sessionId}`:null}function dT(e,t){if(!e||e.status!=="ready"||!e.expiresAt)return null;const n=Date.parse(e.expiresAt);return Number.isFinite(n)?n-t:null}function yB(e,t){return!e||e.status!=="ready"||t===null?"unknown":t<=0?"expired":t<=2*6e4?"critical":t<=10*6e4?"warning":"ok"}function SB(e){if(e<=0)return"0m";const t=Math.ceil(e/1e3);if(t<60)return"<1m";const n=Math.ceil(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),o=n%60;if(r<24&&o>0)return`${r}h ${o}m`;if(r<24)return`${r}h`;const c=Math.floor(r/24),u=r%24;return u>0?`${c}d ${u}h`:`${c}d`}function wB(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function Nh(e){return e instanceof Ln||e instanceof Error?e.message:"Something went wrong."}function CB(e){const t=document.activeElement;return!e||!(t instanceof HTMLElement)||!e.contains(t)?!1:!!t.closest(".xterm-helper-textarea, .compose-drawer-input")}function xB({terminal:e,canClose:t,tabId:n,transcriptSource:r,transcriptShortcutLabel:o,subagentsShortcutLabel:c,transcriptCacheStatus:u,transcriptCacheNow:m,cacheKeepAliveEnabled:g,codeServerAvailable:p,codeServerInstallState:y,codeServerBusy:b,codeServerSupported:C,scrollbackShortcutLabel:k,tmuxScrollbackSupported:S,tmuxScrollbackEnabled:D,onToggleCacheKeepAlive:B,onOpenCodeServer:A,onToggleTmuxScrollback:H,onOpenTranscript:Y,onOpenSubagents:$,onReload:se,onClose:J}){const W=WC({id:`pane-${e.id}`,disabled:!n,...n?{data:{kind:"pane",sourceTabId:n,terminalId:e.id}}:{}}),xe={cursor:n?"grab":"default",opacity:W.isDragging?.5:void 0};return f.jsxs("header",{ref:W.setNodeRef,className:"terminal-pane-header",style:xe,"data-dragging":W.isDragging,...W.attributes,...W.listeners,children:[f.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),f.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),f.jsx("span",{className:"terminal-pane-spacer"}),p?f.jsx("button",{type:"button",className:"terminal-pane-code","data-state":y,"data-busy":b?"true":"false",disabled:!C||b,title:y==="missing"?"Install code-server add-on":"Open this pane in VS Code","aria-label":y==="missing"?"Install code-server add-on":"Open this pane in VS Code",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),A()},children:f.jsx("img",{src:"/brand/vscode.png",width:"13",height:"13",alt:"","aria-hidden":"true",draggable:!1})}):null,r?f.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${Ro(r.provider)} transcript history`,"aria-label":`View ${Ro(r.provider)} transcript history`,onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),Y()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View history"}),f.jsx("span",{className:"pane-button-label-short",children:"History"}),f.jsx("kbd",{children:o})]}):null,r?f.jsxs("button",{type:"button",className:"terminal-pane-transcript terminal-pane-subagents","data-provider":r.provider,title:"View subagents launched by this session","aria-label":"View subagents launched by this session",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),$()},children:[f.jsx("span",{className:"pane-button-label-full",children:"View agents"}),f.jsx("span",{className:"pane-button-label-short",children:"Agents"}),f.jsx("kbd",{children:c})]}):null,r?f.jsx(EB,{status:u,now:m,keepAliveEnabled:g,onToggle:B}):null,e.status==="exited"?f.jsx("span",{className:"terminal-pane-state terminal-pane-state-exited",children:"exited"}):null,S&&e.status==="running"?f.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":D?"true":"false","aria-pressed":D,"aria-label":`Toggle tmux scrollback (${k})`,title:D?`Scroll input uses tmux scrollback (${k}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${k}).`,onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),H()},children:[D?f.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),f.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):f.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),f.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),f.jsx("kbd",{children:k})]}):null,e.status==="running"?f.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),se()},children:"↻"}):null,t?f.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),J()},children:"x"}):null]})}function kB({status:e,busy:t,error:n,onInstall:r,onUpdate:o,onOpen:c,onRefresh:u,onClose:m}){const g=e?.job??null,p=g?.status==="running",y=e?.installed===!0,b=e?.supported!==!1,C=e===null&&t,k=e?.updateAvailable===!0,S=y?"VS Code add-on":"Install VS Code add-on";return f.jsx("div",{className:"security-overlay code-server-dialog-backdrop",role:"dialog","aria-modal":"true","aria-label":S,onClick:m,children:f.jsxs("section",{className:"security-panel code-server-dialog",onClick:D=>D.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{children:[f.jsx("h2",{children:S}),f.jsx("p",{children:C?"Checking code-server status...":y?`code-server ${e?.version??""}`:"Optional code-server runtime"})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close VS Code add-on dialog",onClick:m,children:"x"})]}),f.jsxs("div",{className:"code-server-dialog-scroll",children:[f.jsxs("div",{className:"code-server-dialog-body",children:[f.jsxs("p",{children:["NTerminal installs code-server under ",f.jsx("code",{children:e?.installPath??"~/.nterminal/addons/code-server/current"})," and opens it through the authenticated NTerminal proxy."]}),C?f.jsx("p",{className:"code-server-dialog-muted",children:"Checking the local add-on before showing install actions."}):null]}),b?null:f.jsx("p",{className:"code-server-dialog-error",children:e?.unsupportedReason??"This platform is not supported."}),n?f.jsx("p",{className:"code-server-dialog-error",children:n}):null,g?f.jsxs("div",{className:"code-server-progress","data-status":g.status,children:[f.jsxs("div",{className:"code-server-progress-heading",children:[f.jsx("span",{children:g.action}),f.jsx("strong",{children:g.status})]}),f.jsx("pre",{children:g.logs.length>0?g.logs.join(`
|
|
53
|
-
`):"Preparing..."})]}):null]}),f.jsxs("div",{className:"code-server-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:u,disabled:t||p||!b,children:"Check"}),y?f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:o,disabled:t||p||!b,children:k?"Update":"Reinstall"}),f.jsx("button",{type:"button",onClick:c,disabled:t||p,children:"Open"})]}):f.jsx("button",{type:"button",onClick:r,disabled:t||p||!b,children:p?"Installing...":"Install"})]})]})})}function TB({notice:e}){return f.jsx("div",{className:"code-server-notice","data-tone":e.tone,role:"status","aria-live":"polite",children:e.message})}function EB({status:e,now:t,keepAliveEnabled:n,onToggle:r}){const o=dT(e,t),c=yB(e,o),u=o===null?"?":SB(o),m=["Estimated cache remaining time based on session history.",n?"Keep-alive is on.":"Click to keep cache warm before estimated expiry.",e?.confidence==="estimated"?"TTL is estimated for this provider.":null].filter(Boolean).join(" ");return f.jsxs("button",{type:"button",className:"terminal-pane-cache","data-state":c,"data-enabled":n?"true":"false","aria-pressed":n,"aria-label":n?"Disable cache keep-alive":"Enable cache keep-alive",title:m,onPointerDown:g=>g.stopPropagation(),onMouseDown:g=>g.stopPropagation(),onClick:g=>{g.stopPropagation(),r()},children:[f.jsxs("svg",{viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[f.jsx("circle",{cx:"8",cy:"8",r:"5.8",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),f.jsx("path",{d:"M8 4.7v3.55l2.25 1.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),f.jsx("span",{children:u})]})}function DB({toast:e,onSendNow:t,onSkipOnce:n,onTurnOff:r,onDismiss:o}){if(!e)return null;const c=e.tone==="info"||e.tone==="warning";return f.jsxs("aside",{className:"cache-keepalive-toast","data-tone":e.tone,role:"status","aria-live":"polite",children:[f.jsxs("header",{children:[f.jsx("strong",{children:e.message}),f.jsx("button",{type:"button","aria-label":"Dismiss cache keep-alive alert",onClick:o,children:"x"})]}),e.detail?f.jsx("p",{children:e.detail}):null,c?f.jsxs("div",{className:"cache-keepalive-toast-actions",children:[f.jsx("button",{type:"button",onClick:t,children:"Send now"}),f.jsx("button",{type:"button",onClick:n,children:"Skip once"}),f.jsx("button",{type:"button",onClick:r,children:"Turn off"})]}):null]})}const RB=Ni.memo(function({terminalId:t,serverApi:n,source:r,fontSize:o,onClose:c,onReloadLatest:u}){const m=v.useRef(null),g=v.useRef(0),p=v.useRef(!1),y=v.useRef(!1),b=v.useRef(null),C=v.useRef(""),k=v.useRef(null),S=v.useRef(null),[D,B]=v.useState([]),[A,H]=v.useState(!1),[Y,$]=v.useState(""),[se,J]=v.useState(-1),[W,xe]=v.useState(!1),[re,Ee]=v.useState(-1),[ie,V]=v.useState(null),[X,F]=v.useState(null),[le,O]=v.useState(!1),[M,j]=v.useState(!0),[ae,we]=v.useState(!1),[N,U]=v.useState(null),[ue,Ce]=v.useState(!1);v.useEffect(()=>{function ye(Xe){Xe.key==="Escape"&&(Xe.preventDefault(),Xe.stopPropagation(),c())}return document.addEventListener("keydown",ye,!0),()=>document.removeEventListener("keydown",ye,!0)},[c]),v.useEffect(()=>{g.current+=1;const ye=g.current;return p.current=!1,y.current=!0,b.current=null,k.current=null,S.current=null,B([]),F(null),O(!1),U(null),Ce(!1),J(-1),Ee(-1),V(null),Ye(null,"initial",ye),()=>{g.current===ye&&(g.current+=1)}},[n,A,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ye=m.current;if(!ye)return;if(y.current){if(M||D.length===0)return;y.current=!1;const rt=()=>{ye.scrollTop=ye.scrollHeight};rt(),window.requestAnimationFrame?.(rt);return}const Xe=b.current;Xe!==null&&(b.current=null,ye.scrollTop+=ye.scrollHeight-Xe)},[D,M,A]);const Oe=Ro(r.provider),De=hf(D,A),Be=wk(De),Ne=MB(Be),Ue=Ne.map(ye=>ye.key).join(""),Fe=ie?Ne.find(ye=>ye.key===ie)?.entryIndex??null:null,ne=Y.trim().length>0,me=f3(Be,Y),R=me.length,q=R>0?se>=0&&se<R?se:0:-1,fe=q>=0?me[q]?.entryIndex??null:null,ge=q>=0?me[q]??null:null,Q=ne?fe:Fe,ke=ne?fe===null?null:"search":Fe===null?null:"prompt",de=De?De.split(`
|
|
54
|
-
`).length-1:0,Re=Ne.length>0&&re>=0&&re<Ne.length?re:Ne.length-1,Ie=ie??(Re>=0?Ne[Re]?.key??null:null),je=ne?R>0?`${q+1}/${R} ${R===1?"match":"matches"} · ${de} ${de===1?"line":"lines"}`:`0 matches · ${de} ${de===1?"line":"lines"}`:Ne.length>0?`${Re+1}/${Ne.length} prompts · ${de} ${de===1?"line":"lines"}`:`0 prompts · ${de} ${de===1?"line":"lines"}`;v.useEffect(()=>{const ye=Y.trim().toLowerCase();J(Xe=>!ye||R===0?-1:C.current!==ye?0:Xe>=0&&Xe<R?Xe:0),C.current=ye},[Y,R]),v.useEffect(()=>{if(ne){V(null);return}ie&&!Ne.some(ye=>ye.key===ie)&&V(null),Ee(ye=>{if(Ne.length===0)return S.current=null,-1;const Xe=S.current?Ne.findIndex(Ze=>Ze.key===S.current):-1,rt=Xe>=0?Xe:ye>=0&&ye<Ne.length?ye:Ne.length-1;return S.current=Ne[rt]?.key??null,rt})},[ie,ne,Ue]),v.useEffect(()=>{const ye=k.current;if(!ye||Ne.length===0)return;k.current=null;const Xe=ye.anchorKey?Ne.findIndex(Ze=>Ze.key===ye.anchorKey):-1,rt=Xe>0?Xe-1:0;$e(rt)},[Ue]);async function Ye(ye,Xe,rt=g.current){if(!p.current){p.current=!0,Xe==="initial"?j(!0):(we(!0),b.current=m.current?.scrollHeight??null),U(null);try{await ct(ye,Xe,rt)}catch(Ze){if(g.current!==rt)return;U(Ze instanceof Error?Ze.message:"Failed to load transcript history.")}finally{g.current===rt&&(p.current=!1,j(!1),we(!1))}}}async function ct(ye,Xe,rt){let Ze=ye,Et=0,ut=[];const Tn=Xe==="initial"&&r.provider!=="claude"?uB:cB;for(;g.current===rt;){const gi=await n.getTerminalTranscriptHistory(t,{...Ze?{cursor:Ze}:{},...vB(m.current,o,Xe==="initial"?eB:tB),includeTools:A});if(g.current!==rt)return;if(!gi.source){U("Transcript source is temporarily unavailable.");return}if(!Rb(r,gi.source)){Ce(!0),O(!1);return}const ee=r_(gi.output,r.provider,{includeTools:A}),Pe=Nt(gi,Xe,ut,ee);if(ee&&(ut=[ee,...ut],Pe))return;if(!gi.hasMore||!gi.cursor||Et>=Tn){ut.length>0&&B(st=>Xe==="older"?[...ut,...st]:ut);return}Ze=gi.cursor,Et+=1}}function Nt(ye,Xe,rt,Ze=r_(ye.output,r.provider,{includeTools:A})){if(F(ye.cursor),O(!!(ye.hasMore&&ye.cursor)),!Ze)return!1;const Et=[Ze,...rt];return hf(Et,A)?(B(ut=>Xe==="older"?[...Et,...ut]:Et),!0):!1}function yt(){const ye=m.current;ye&&(Lt(),!(ye.scrollTop>72||!le||!X||p.current)&&Ye(X,"older"))}function Tt(ye){R!==0&&J(Xe=>{const rt=q>=0?q:ye>0?-1:0;return((Xe>=0&&Xe<R?Xe:rt)+ye+R)%R})}function $e(ye){const Xe=Ne[ye];Xe&&(S.current=Xe.key,Ee(ye),V(Xe.key))}async function St(ye){if(Ne.length===0){ye<0&&le&&X&&!p.current&&(k.current={anchorKey:null},await Ye(X,"older"));return}const rt=(re>=0&&re<Ne.length?re:ye<0?Ne.length-1:-1)+ye;if(rt>=0&&rt<Ne.length){$e(rt);return}ye<0&&rt<0&&le&&X&&!p.current&&(k.current={anchorKey:Ne[0]?.key??null},await Ye(X,"older"))}function Lt(){if(ne)return;const ye=m.current;if(!ye)return;const rt=ye.getBoundingClientRect().top+Math.min(140,Math.max(48,ye.clientHeight*.28));let Ze=null;for(const Et of BB(ye)){const ut=jB(Et);if(ut!==null)if(Et.getBoundingClientRect().top<=rt)Ze=ut;else break}if(Ze!==null){const Et=Ne[Ze]?.key??null;S.current=Et,Ee(Ze),ie&&ie!==Et&&V(null)}}return f.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>{ye.stopPropagation(),c()},children:f.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ye=>ye.stopPropagation(),onMouseDown:ye=>ye.stopPropagation(),onClick:ye=>ye.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsxs("div",{className:"transcript-dialog-title",children:[f.jsxs("h2",{id:"transcript-dialog-title",children:[Oe," JSONL"]}),f.jsx("span",{title:r.sessionId,children:r.sessionId})]}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),f.jsxs("div",{className:"transcript-dialog-controls",children:[f.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[f.jsx("input",{type:"checkbox",checked:A,onChange:ye=>H(ye.currentTarget.checked)}),"Show tool output"]}),f.jsx("label",{className:"transcript-search",children:f.jsx("input",{type:"search",value:Y,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:ye=>$(ye.currentTarget.value),onKeyDown:ye=>{ye.key==="Enter"&&(ye.preventDefault(),ne?Tt(ye.shiftKey?-1:1):St(ye.shiftKey?-1:1))}})}),f.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":W,"aria-label":"Toggle prompt list",onClick:()=>xe(ye=>!ye),disabled:Ne.length===0,children:"List"}),f.jsxs("div",{className:"transcript-search-actions","aria-label":ne?"Search result navigation":"Prompt navigation",children:[f.jsx("button",{type:"button",onClick:()=>ne?Tt(-1):void St(-1),disabled:ne?R===0:Ne.length===0&&!le,"aria-label":ne?"Previous search match":"Previous user prompt",title:ne?"Previous search match":"Previous user prompt",children:"Prev"}),f.jsx("button",{type:"button",onClick:()=>ne?Tt(1):void St(1),disabled:ne?R===0:Ne.length===0,"aria-label":ne?"Next search match":"Next user prompt",title:ne?"Next search match":"Next user prompt",children:"Next"})]}),f.jsx("span",{className:"transcript-result-count",children:je})]}),W?f.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:Ne.length>0?Ne.map((ye,Xe)=>f.jsxs("button",{type:"button",className:Ie===ye.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>$e(Xe),children:[f.jsx("span",{children:ye.timestampLabel}),f.jsx("strong",{children:ye.snippet})]},`${ye.key}:${Xe}`)):f.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,f.jsxs("div",{ref:m,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:yt,children:[ae?f.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!M&&le?f.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,De?f.jsx(yk,{entries:Be,searchQuery:Y,activeEntryIndex:Q,activeEntryMode:ke,activeSearchMatch:ge,fontSize:o}):null,M?f.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,ue?f.jsxs("div",{className:"transcript-dialog-status",children:["This pane switched to another agent session."," ",f.jsx("button",{type:"button",onClick:()=>{u()},children:"Load current session"})]}):null,!ue&&!M&&!De&&!N?le&&X?f.jsxs("div",{className:"transcript-dialog-status",children:[A?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",f.jsx("button",{type:"button",onClick:()=>{Ye(X,"older")},disabled:ae,children:"Search earlier entries"})]}):f.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,N?f.jsx("div",{className:"transcript-dialog-error",children:N}):null]})]})})});function MB(e){const t=[];for(let o=0;o<e.length;o+=1){const c=e[o];!c||c.kind!=="user"||t.push({contentKey:NB(c),entry:c,entryIndex:o})}const n=new Map,r=new Map;for(let o=t.length-1;o>=0;o-=1){const c=t[o];if(!c)continue;const u=n.get(c.contentKey)??0;n.set(c.contentKey,u+1),r.set(o,JSON.stringify([c.contentKey,u]))}return t.map((o,c)=>({entryIndex:o.entryIndex,key:r.get(c)??JSON.stringify([o.contentKey,0]),snippet:LB(o.entry.body),timestampLabel:OB(o.entry.header)}))}function NB(e){return JSON.stringify([e.header??"",e.body.length,AB(e.body)])}function AB(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 LB(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function OB(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function BB(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function jB(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 IB(e){return e.includes("\r")||e.includes(`
|
|
55
|
-
`)}function Pg(e){return e instanceof Ln&&e.status===404}function kl(e){return hT(e)||fT(e)}function hT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function fT(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function zB(e){if(kl(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function PB(e){let t=0;for(const n of e){if(!n)continue;const r=n.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Ah(e){const t=[];for(const n of e){const r=pT(n);r&&t.push(r)}return t}function pT(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,r)=>{const o=n.split(";").filter(Boolean).filter(c=>!Q5.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function Hg(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function HB(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 iC(e,t){const n=e?.querySelector(".xterm .xterm-viewport");if(n){if(t){n.dataset.nterminalTmuxScrollHidden="true",n.style.setProperty("overflow-y","hidden","important"),n.style.setProperty("scrollbar-color","transparent transparent","important"),n.style.setProperty("scrollbar-width","none","important"),n.style.setProperty("-ms-overflow-style","none");return}n.dataset.nterminalTmuxScrollHidden==="true"&&(delete n.dataset.nterminalTmuxScrollHidden,n.style.removeProperty("overflow-y"),n.style.removeProperty("scrollbar-color"),n.style.removeProperty("scrollbar-width"),n.style.removeProperty("-ms-overflow-style"))}}function Vn(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Lh(e,t){return!t||Vn(e)}function nC(e){return Vn(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function UB(e,t,n,r,o,c,u,m){const g=p=>{const y=FB(p);if(y!==0){if(u()){if(qB(t))return;p.cancelable&&p.preventDefault(),p.stopPropagation(),m(y);return}p.cancelable&&p.preventDefault(),p.stopPropagation(),KB(t,y,n,r,o,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function KB(e,t,n,r,o,c){const u=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(__,u);return}u()}function FB(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const r=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,r))}function WB(e,t,n,r,o,c,u,m,g){let p=null,y=0;const b={passive:!1};function C(D){p=Ug(D),y=0}function k(D){const B=Ug(D);if(B===null){p=null,y=0;return}if(p===null){p=B;return}const A=B.clientY-p.clientY;if(p=B,D.cancelable&&D.preventDefault(),A===0)return;if($B(t)&&VB(t,B,-A)){y=0;return}y-=A/n();const H=y<0?Math.ceil(y):Math.floor(y);if(H!==0){if(y-=H,m()){g(H);return}c();try{t.scrollLines(H)}finally{u()}r(),H<0&&t.buffer.active.viewportY<=3&&o(H)}}function S(D){if(D.touches.length>0){p=Ug(D);return}p=null,y=0}return e.addEventListener("touchstart",C,b),e.addEventListener("touchmove",k,b),e.addEventListener("touchend",S),e.addEventListener("touchcancel",S),()=>{e.removeEventListener("touchstart",C,b),e.removeEventListener("touchmove",k,b),e.removeEventListener("touchend",S),e.removeEventListener("touchcancel",S)}}function Ug(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function $B(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function qB(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function VB(e,t,n){const r=e.element;return r?(r.dispatchEvent(YB(t,n)),!0):!1}function YB(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function y_({node:e,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:u=!1,tabId:m,codeServerContext:g,dropZoneActive:p=!1,draggingTerminalId:y=null,mobileFocusLeafKey:b=null,path:C=[],totalPanes:k,onSelect:S,onClose:D,onResize:B,onExit:A,onSnapshot:H,onCloseEditor:Y,onAuthClose:$}){const se=k??S_(e);if(C.length===0&&b){const re=w_(e),Ee=re.some(ie=>ie.key===b)?b:re[0]?.key;if(re.length>1&&Ee)return f.jsx("div",{className:"mobile-focused-split",children:re.map(ie=>{const V=ie.key===Ee;if(ie.type==="editor"){const F=n[ie.editorId];return f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:F?f.jsx(Nw,{api:r,editor:F,canClose:se>1,onClose:()=>Y(ie.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},ie.key)}const X=t[ie.terminalId];return X?f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx(G1,{terminal:X,serverApi:r,active:V,visible:c&&V,canClose:se>1,refreshCwdOnEnter:u&&V,tabId:m,codeServerContext:g,onSelect:()=>S(ie.terminalId),onClose:()=>D(ie.terminalId),onExit:F=>A(ie.terminalId,F),onSnapshot:H,...$?{onAuthClose:$}:{}})},ie.key):f.jsx("div",{className:"mobile-focused-pane","data-active":V,"aria-hidden":!V,children:f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},ie.key)})})}if(e.type==="pane"){const re=t[e.terminalId];if(!re)return f.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const Ee=f.jsx(G1,{terminal:re,serverApi:r,active:e.terminalId===o,visible:c,canClose:se>1,refreshCwdOnEnter:u&&e.terminalId===o,tabId:m,codeServerContext:g,onSelect:()=>S(e.terminalId),onClose:()=>D(e.terminalId),onExit:V=>A(e.terminalId,V),onSnapshot:H,...$?{onAuthClose:$}:{}});return p&&y!==e.terminalId?f.jsxs("div",{className:"pane-drop-host",children:[Ee,f.jsx(Oh,{terminalId:e.terminalId,side:"top"}),f.jsx(Oh,{terminalId:e.terminalId,side:"right"}),f.jsx(Oh,{terminalId:e.terminalId,side:"bottom"}),f.jsx(Oh,{terminalId:e.terminalId,side:"left"})]}):Ee}if(e.type==="editor"){const re=n[e.editorId];return re?f.jsx(Nw,{api:r,editor:re,canClose:se>1,onClose:()=>Y(e.editorId)}):f.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const J=Math.max(.1,Math.min(.9,e.ratio)),W=1-J,xe=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${J}fr) 1px minmax(0, ${W}fr)`}:{gridTemplateRows:`minmax(0, ${J}fr) 1px minmax(0, ${W}fr)`};return f.jsxs("div",{className:"split-pane","data-direction":e.direction,style:xe,children:[f.jsx("div",{className:"split-cell",children:f.jsx(y_,{node:e.first,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,0],totalPanes:se,onSelect:S,onClose:D,onResize:B,onExit:A,onSnapshot:H,onCloseEditor:Y,...$?{onAuthClose:$}:{}})}),f.jsx(XB,{direction:e.direction,path:C,onResize:B}),f.jsx("div",{className:"split-cell",children:f.jsx(y_,{node:e.second,terminals:t,editors:n,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:u,tabId:m,codeServerContext:g,dropZoneActive:p,draggingTerminalId:y,mobileFocusLeafKey:b,path:[...C,1],totalPanes:se,onSelect:S,onClose:D,onResize:B,onExit:A,onSnapshot:H,onCloseEditor:Y,...$?{onAuthClose:$}:{}})})]})}function Oh({terminalId:e,side:t}){const{setNodeRef:n,isOver:r}=Q_({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return f.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function XB({direction:e,path:t,onResize:n}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const u=c.parentElement;if(!u)return;const m=u.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-m.left)/m.width:(y.clientY-m.top)/m.height;n(t,Math.min(.9,Math.max(.1,b)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return f.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:f.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function S_(e){return e.type==="pane"||e.type==="editor"?1:S_(e.first)+S_(e.second)}function w_(e){return e.type==="pane"?[{key:GB(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:ZB(e.editorId),type:"editor",editorId:e.editorId}]:[...w_(e.first),...w_(e.second)]}function GB(e){return`terminal:${e}`}function ZB(e){return`editor:${e}`}const $f="workspace-default",QB="NTerminal";function JB(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function e4(e,t){switch(t.type){case"workspace.hydrated":return C_(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return t4(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return r4(e,t.workspaceId);case"workspace.selected":return mT(e,t.workspaceId);case"workspace.renamed":return i4(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return n4(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return s4(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return gT(e,t.terminal);case"terminal.split":return a4(e,t.terminal,t.direction);case"terminal.updated":return v4(e,t.terminal);case"terminal.exited":return _4(e,t.terminalId,t.exitCode);case"terminal.closed":return bT(e,t.terminalId);case"terminal.detached":return b4(e,t.terminalId,t.workspaceId);case"editor.split":return o4(e,t.editorId,t.title,t.direction);case"editor.closed":return y4(e,t.editorId);case"pane.selected":return m4(e,t.terminalId);case"pane.resized":return g4(e,t.path,t.ratio);case"tab.selected":return c4(e,t.tabId);case"tab.renamed":return p4(e,t.tabId,t.title);case"tab.reordered":return jb(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return u4(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return vT(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return _T(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return d4(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return l4(e);default:return e}}function t4(e,t){if(e.workspaces.some(r=>r.id===t.id))return mT(e,t.id);const n={id:t.id,title:t.title,defaultCwd:Ds(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function mT(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function i4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.title===r?u:(o=!0,{...u,title:r}));return o?{...e,workspaces:c}:e}function n4(e,t,n){const r=Ds(n);let o=!1;const c=e.workspaces.map(u=>u.id!==t||u.defaultCwd===r?u:(o=!0,{...u,defaultCwd:r}));return o?{...e,workspaces:c}:e}function s4(e,t,n,r){if(t===n)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===n);if(o<0||c<0)return e;const u=e.workspaces.slice(),[m]=u.splice(o,1);if(!m)return e;const g=u.findIndex(b=>b.id===n);if(g<0)return e;const p=r==="before"?g:g+1,y=u.slice();return y.splice(p,0,m),f4(e.workspaces,y)?e:{...e,workspaces:y}}function r4(e,t){if(e.workspaces.length<=1||!e.workspaces.some(m=>m.id===t))return e;const n=e.workspaces.find(m=>m.id===t),r=new Set(n?wf(n):[]),o={...e.terminals};for(const m of r)delete o[m];const c=e.workspaces.filter(m=>m.id!==t),u=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:u,terminals:o}}function gT(e,t){const n=ST(e),r=Oo(n)??Vf(),o=TT(t);return{...n,activeWorkspaceId:r.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??Ds(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>u!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:kT(c,t.id))}}function a4(e,t,n){const r=Oo(e),o=r?qf(r):void 0;if(!r||!o)return gT(e,t);const c=o.activeTerminalId,u=Hu(o.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(m=>m.id===r.id?{...m,defaultCwd:m.defaultCwd??Ds(t.cwd),detachedTerminalIds:m.detachedTerminalIds.filter(g=>g!==t.id),tabs:m.tabs.map(g=>g.id===o.id?{...g,root:u,activeTerminalId:t.id}:g)}:kT(m,t.id))}}function o4(e,t,n,r){const o=Oo(e),c=o?qf(o):void 0;if(!o||!c)return e;const u=c.activeTerminalId,m=Hu(c.root,u,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:u},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:m,activeTerminalId:u}:p)}:g)}}function l4(e){const t=Oo(e),n=t?qf(t):void 0;return n?bT(e,n.activeTerminalId):e}function c4(e,t){const n=Oo(e);return!n||!n.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===n.id?{...r,activeTabId:t}:r)}}function jb(e,t,n){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const u=o.tabs.slice(),[m]=u.splice(c,1);if(!m)return o;const g=Math.max(0,Math.min(u.length,n)),p=u.slice();return p.splice(g,0,m),h4(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function u4(e,t,n,r,o){if(n===r||!e.terminals[n]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(S=>S.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=Hl(y.root,n);if(!b){const S=g.tabs.filter((D,B)=>B!==p);return{...g,tabs:S}}const C={...y,root:b,activeTerminalId:Li(b)[0]??y.activeTerminalId},k=g.tabs.slice();return k[p]=C,{...g,tabs:k}});const u=o==="left"||o==="right"?"vertical":"horizontal",m=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(D=>Li(D.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:n},C={type:"split",direction:u,ratio:.5,first:m?b:{type:"pane",terminalId:r},second:m?{type:"pane",terminalId:r}:b},k=Hu(y.root,r,C),S=g.tabs.slice();return S[p]={...y,root:k,activeTerminalId:n},{...g,tabs:S,activeTabId:y.id}}),ST({...e,workspaces:c})}function vT(e,t,n,r){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const A=e.workspaces[B].tabs.findIndex(H=>H.id===t);if(A>=0){o=B,c=A;break}}if(o<0)return e;const u=e.workspaces[o],m=u.tabs[c],g=Li(m.root);if(!g.includes(n))return e;if(g.length===1)return jb(e,t,r);const p=Hl(m.root,n);if(!p)return e;const y={...m,root:p,activeTerminalId:Li(p)[0]??m.activeTerminalId},b=e.terminals[n],C={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:b?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},k=u.tabs.slice();k[c]=y;const S=Math.max(0,Math.min(k.length,r));k.splice(S,0,C);const D=e.workspaces.slice();return D[o]={...u,tabs:k,activeTabId:C.id},{...e,workspaces:D}}function _T(e,t,n,r=Number.MAX_SAFE_INTEGER){const o=wT(e.workspaces,t),c=e.workspaces.find(p=>p.id===n);if(!o||!c)return e;if(o.workspace.id===n)return r===Number.MAX_SAFE_INTEGER?e:jb(e,t,r);const u=Li(o.tab.root),m=u.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Bo({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===n){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??Ds(m?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(C=>!u.includes(C)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:n}}function d4(e,t,n,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(k=>k.id===r),u=wT(e.workspaces,t);if(!c||!u||!e.terminals[n]||!Li(u.tab.root).includes(n))return e;if(u.workspace.id===r)return vT(e,t,n,o);if(Li(u.tab.root).length===1)return _T(e,t,r,o);const g=Hl(u.tab.root,n);if(!g)return e;const p={...u.tab,root:g,activeTerminalId:Li(g)[0]??u.tab.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y.title??n,activeTerminalId:n,root:{type:"pane",terminalId:n}},C=e.workspaces.map(k=>{if(k.id===u.workspace.id)return Bo({...k,tabs:k.tabs.map(S=>S.id===t?p:S)});if(k.id===r){const S=k.tabs.slice(),D=Math.max(0,Math.min(S.length,o));return S.splice(D,0,b),{...k,defaultCwd:k.defaultCwd??Ds(y.cwd),detachedTerminalIds:k.detachedTerminalIds.filter(B=>B!==n),tabs:S,activeTabId:b.id}}return k});return{...e,workspaces:C,activeWorkspaceId:r}}function h4(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 f4(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 p4(e,t,n){const r=n.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(u=>{let m=!1;const g=u.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,m=!0,{...p,title:r}));return m?{...u,tabs:g}:u});return o?{...e,workspaces:c}:e}function m4(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>Ul(c.root,t))),r=n?.tabs.find(o=>Ul(o.root,t));return!n||!r?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function g4(e,t,n){const r=Oo(e),o=r?qf(r):void 0;if(!r||!o)return e;const c=R_(o.root,t,RT(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(u=>u.id===r.id?{...u,tabs:u.tabs.map(m=>m.id===o.id?{...m,root:c}:m)}:u)}}function C_(e,t,n,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),u=new Set,m=!!(n&&n.some(b=>ET(b))||t&&t.some(b=>DT(b)));let g=S4(t,n,c,u);g.length===0&&(g=[Vf()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??$f;for(const b of e)if(!u.has(b.id)){if(m)g=x4(g,y,b.id,b);else{const C=TT(b);g=T4(g,y,C,b)}u.add(b.id)}return{workspaces:g.map(b=>Bo(k4(b,o))),activeWorkspaceId:p,terminals:o}}function Pu(e){return Li(e.root)}function x_(e){return M_(e.root)}function wf(e){return Ib([...e.tabs.flatMap(t=>Li(t.root)),...e.detachedTerminalIds])}function Kg(e){const t=e.workspaces.map(n=>{const r=n.tabs.flatMap(o=>{const c=E_(o.root);return c?[{...o,root:c}]:[]});return Bo({...n,tabs:r})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function v4(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(r=>Ul(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function _4(e,t,n){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:n}}}:e}function bT(e,t){const n={...e.terminals};return delete n[t],yT(e,t,n)}function b4(e,t,n){if(!e.terminals[t])return e;const r=(n&&e.workspaces.some(c=>c.id===n)?n:null)??w4(e,t)?.id??C4(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??$f,o=e.workspaces.find(c=>c.id===r);return!o||!xT(o,t)?e:yT(e,t,{...e.terminals},{detachToWorkspaceId:r})}function yT(e,t,n,r={}){let o=e.workspaces.map(u=>{const m=[];for(const g of u.tabs){const p=Hl(g.root,t);if(!p)continue;const y=Li(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&m.push({...g,root:p,activeTerminalId:b})}return Bo({...u,detachedTerminalIds:u.detachedTerminalIds.filter(g=>g!==t),tabs:m})});r.detachToWorkspaceId&&n[t]&&(o=o.map(u=>u.id===r.detachToWorkspaceId?CT(u,t,n[t]):u));const c=o.some(u=>u.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:n}}function y4(e,t){const n=e.workspaces.map(o=>{const c=[];for(const u of o.tabs){const m=k_(u.root,t);if(!m)continue;const g=Li(m),p=g.includes(u.activeTerminalId)?u.activeTerminalId:g[0];p&&c.push({...u,root:m,activeTerminalId:p})}return Bo({...o,tabs:c})}),r=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:r?e.activeWorkspaceId:n[0]?.id??null}}function S4(e,t,n,r){if(t&&t.length>0){const o=[];for(const c of t)ET(c)&&o.push(sC(c,n,r));if(o.length>0)return o}return[sC({...Vf(),tabs:e??[]},n,r)]}function sC(e,t,n){const r=[];for(const c of e.tabs){if(!DT(c))continue;const u=T_(c.root,t);if(!u)continue;const m=Li(u);for(const p of m)n.add(p);const g=m.includes(c.activeTerminalId)?c.activeTerminalId:m[0];g&&r.push({...c,root:u,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||n.has(c)||(n.add(c),o.push(c));return Bo({...e,defaultCwd:Ds(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function ST(e){return Oo(e)?e:{...e,workspaces:[Vf()],activeWorkspaceId:$f}}function Oo(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function qf(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function wT(e,t){for(const n of e){const r=n.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:n,tab:n.tabs[r],tabIndex:r}}return null}function w4(e,t){return e.workspaces.find(n=>n.tabs.some(r=>Ul(r.root,t)))}function C4(e,t){return e.workspaces.find(n=>n.detachedTerminalIds.includes(t))}function x4(e,t,n,r){return e.map(o=>o.id===t?CT(o,n,r):o)}function CT(e,t,n){return xT(e,t)?{...e,defaultCwd:e.defaultCwd??Ds(n?.cwd),detachedTerminalIds:Ib([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function xT(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Wl}function kT(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(n=>n!==t)}:e}function k4(e,t){if(e.defaultCwd)return e;const n=wf(e).find(o=>!!t[o]),r=n?Ds(t[n]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Vf(){return{id:$f,title:QB,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Bo(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,defaultCwd:Ds(e.defaultCwd),detachedTerminalIds:Ib(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function T4(e,t,n,r){const o=Li(n.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??Ds(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(u=>!o.includes(u)),tabs:[...c.tabs,n],activeTabId:c.activeTabId??n.id}:c)}function TT(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Hu(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:Hu(e.first,t,n),second:Hu(e.second,t,n)}}function Hl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=Hl(e.first,t),r=Hl(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function k_(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=k_(e.first,t),r=k_(e.second,t);return n&&r?{...e,first:n,second:r}:n??r}function T_(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=T_(e.first,t),r=T_(e.second,t);return n&&r?{...e,ratio:RT(e.ratio),first:n,second:r}:n??r}function E_(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=E_(e.first),n=E_(e.second);return t&&n?{...e,first:t,second:n}:t??n}function ET(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 DT(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&D_(t.root)}function D_(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")&&D_(t.first)&&D_(t.second):!1}function R_(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[r,...o]=t;if(r===0){const c=R_(e.first,o,n);return c===e.first?e:{...e,first:c}}if(r===1){const c=R_(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function RT(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Ds(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Ib(e){const t=new Set,n=[];for(const r of e)!r||t.has(r)||(t.add(r),n.push(r));return n}function Ul(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Ul(e.first,t)||Ul(e.second,t)}function Li(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Li(e.first),...Li(e.second)]}function M_(e){return e.type==="pane"||e.type==="editor"?1:M_(e.first)+M_(e.second)}const Ir=new Map,Uu=new Map,Ku=new Map,Fu=new Map,Wu=new Map,N_=new Set;let MT=0;function No(e){return e??"__local__"}function E4(e){return{agentId:e,state:JB(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function It(e){const t=No(e);let n=Ir.get(t);return n||(n=E4(e),Ir.set(t,n)),n}function NT(e,t){const n=No(e);let r=Uu.get(n);return r||(r=new Set,Uu.set(n,r)),r.add(t),()=>{r.delete(t)}}function D4(e){const t=No(e),n=Uu.get(t);if(n)for(const r of Array.from(n))r()}function Xl(e,t,n=!0){const r=Ir.get(No(e)),o=n&&rC(r)!==rC(t);Ir.set(No(e),t),D4(e),o&&Pb()}function A_(e){return!e||e.status!=="running"?!1:e.agentStatus?e.agentStatus.state==="working"||e.agentStatus.state==="unknown"&&e.activity==="busy":e.activity==="busy"}function zb(e,t){const n=e.state.workspaces.find(u=>u.id===t);if(!n)return{workingTerminalCount:0,unreadCompletionCount:0};const r=new Set;for(const u of n.tabs)for(const m of Li(u.root))r.add(m);let o=0,c=0;for(const u of r)A_(e.state.terminals[u])&&(o+=1),e.unreadCompletions.has(u)&&(c+=1);return{workingTerminalCount:o,unreadCompletionCount:c}}function rC(e){return e?e.state.workspaces.map(t=>{const n=zb(e,t.id);return`${t.id}:${n.workingTerminalCount}:${n.unreadCompletionCount}`}).join("|"):""}function AT(e){return!!(e&&e.state.workspaces.some(t=>{const n=zb(e,t.id);return n.workingTerminalCount>0||n.unreadCompletionCount>0}))}function Pb(){MT+=1;for(const e of Array.from(N_))e()}function R4(e){return N_.add(e),()=>{N_.delete(e)}}function aC(){return MT}function M4(e,t){return zb(It(e),t)}const L_=new Set;function N4(e){return L_.add(e),()=>{L_.delete(e)}}function Sl(e,t){const n=It(e),r=No(e),o=L4(n.state,t);t.type==="workspace.hydrated"&&(Ku.delete(r),Fu.delete(r),Wu.delete(r));const c=e4(n.state,t);let u=n.unreadCompletions,m=null;if(t.type==="terminal.updated"){const y=n.state.terminals[t.terminal.id],b=H4(r),C=U4(r),k=O4(r);if(t.terminal.agentStatus){const S=t.terminal.agentStatus.state,D=t.terminal.agentStatus.sessionId,B=k.get(t.terminal.id),A=!!(y&&(y.currentCommand!==t.terminal.currentCommand||y.agentStatus?.provider!==t.terminal.agentStatus.provider||A4(B,D)));A&&(C.delete(t.terminal.id),b.delete(t.terminal.id),k.delete(t.terminal.id)),D&&k.set(t.terminal.id,D),t.notifyCompletion===!0&&(S==="working"?(C.add(t.terminal.id),b.delete(t.terminal.id)):S==="unknown"&&t.terminal.activity==="busy"&&b.add(t.terminal.id)),!A&&(S==="done"||S==="stopped")&&(C.has(t.terminal.id)||b.has(t.terminal.id))&&(m=cC(c,t.terminal.id,y?.currentCommand??null,S==="stopped"?"stopped":"finished"),C.delete(t.terminal.id),b.delete(t.terminal.id)),S==="idle"&&(C.delete(t.terminal.id),b.delete(t.terminal.id))}else{y?.agentStatus&&(C.delete(t.terminal.id),k.delete(t.terminal.id));const S=y?.activity==="busy",D=t.terminal.activity==="busy",B=t.terminal.activity==="idle";t.notifyCompletion===!0&&D&&b.add(t.terminal.id),t.notifyCompletion===!0&&S&&B&&b.has(t.terminal.id)&&(m=cC(c,t.terminal.id,y?.currentCommand??null,"finished")),(B||t.terminal.status==="exited")&&b.delete(t.terminal.id)}if(m){const S=LT(c,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==c.activeWorkspaceId)&&(u.has(t.terminal.id)||(u=new Set(u),u.add(t.terminal.id)))}t.terminal.status==="exited"&&(b.delete(t.terminal.id),C.delete(t.terminal.id),k.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let y=null;if(t.type==="tab.selected")y=B4(c,t.tabId)?.tab??null;else{const C=c.workspaces.find(k=>k.id===t.workspaceId);y=C?.tabs.find(k=>k.id===C.activeTabId)??null}const b=y?Li(y.root):[];if(b.some(C=>u.has(C))){const C=new Set(u);for(const k of b)C.delete(k);u=C}}const g=c!==n.state,p=u!==n.unreadCompletions;if((g||p)&&Xl(e,{...n,state:c,unreadCompletions:u},o||p),p&&Yf(),m)for(const y of Array.from(L_))y({agentId:e,...m})}function A4(e,t){return e!==void 0&&t!==void 0&&e!==t}function L4(e,t){switch(t.type){case"terminal.updated":return A_(e.terminals[t.terminal.id])!==A_(t.terminal);case"workspace.renamed":case"workspace.defaultCwdChanged":case"workspace.reordered":case"editor.split":case"editor.closed":case"pane.selected":case"pane.resized":case"tab.renamed":case"tab.reordered":return!1;default:return!0}}function O4(e){let t=Wu.get(e);return t||(t=new Map,Wu.set(e,t)),t}function LT(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Li(r.root).includes(t))return{workspace:n,tab:r};return null}function B4(e,t){for(const n of e.workspaces){const r=n.tabs.find(o=>o.id===t);if(r)return{workspace:n,tab:r}}return null}const O_=new Set;function j4(e){return O_.add(e),()=>{O_.delete(e)}}function I4(){let e=0;for(const t of Ir.values())e+=t.unreadCompletions.size;return e}function Yf(){for(const e of Array.from(O_))e()}function oC(e,t){const n=It(e);if(!n.unreadCompletions.has(t))return;const r=new Set(n.unreadCompletions);r.delete(t),Xl(e,{...n,unreadCompletions:r}),Yf()}function lC(e,t){const n=It(e);t!==n.state&&Xl(e,{...n,state:t})}function Fg(e,t){const n=It(e),r=t(n.editors);r!==n.editors&&Xl(e,{...n,editors:r},!1)}function ka(e,t,n){const r=It(e);r.loaded===t&&r.error===n||Xl(e,{...r,loaded:t,error:n},!1)}function eu(e,t,n){const r=It(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===n||Xl(e,{...r,layoutRevision:t,lastPersistedLayoutJson:n},!1)}function z4(e){const t=It(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function P4(e){const t=No(e),n=Ir.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const r=n?n.unreadCompletions.size>0:!1,o=AT(n);Ir.delete(t),Uu.delete(t),Ku.delete(t),Fu.delete(t),Wu.delete(t),r&&Yf(),o&&Pb()}function Wg(){let e=!1,t=!1;for(const n of Ir.values()){const r=n.mutable.saveCoord.saveTimer;r!==null&&window.clearTimeout(r),n.unreadCompletions.size>0&&(e=!0),AT(n)&&(t=!0)}Ir.clear(),Uu.clear(),Ku.clear(),Fu.clear(),Wu.clear(),e&&Yf(),t&&Pb()}function H4(e){let t=Ku.get(e);return t||(t=new Set,Ku.set(e,t)),t}function U4(e){let t=Fu.get(e);return t||(t=new Set,Fu.set(e,t)),t}function cC(e,t,n,r){const o=LT(e,t);return o?{terminalId:t,tabId:o.tab.id,commandName:n,outcome:r}:null}function B_(e,t){let n=!1,r=!1,o=null,c=!1;for(const u of Pu(e)){const m=t[u];if(m){if(m.status==="exited"){c=!0,n=!0;continue}m.activity==="busy"?(r=!0,n=!0,!o&&m.currentCommand&&(o=m.currentCommand)):m.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Hb(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function j_(e,t){const n=t[e.activeTerminalId];return e.title||n?.title||e.activeTerminalId}function K4(e,t,n,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${n} pane${n===1?"":"s"}`}function F4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:u,onToggleWorkspaces:m,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:C,onRenameTab:k,activePaneAvailable:S}){const[D,B]=v.useState(null),[A,H]=v.useState(!1),[Y,$]=v.useState(null),se=v.useRef(null),J=e.findIndex(F=>F.id===t),W=J>=0?e[J]:e[0]??null,xe=W?B_(W,n):null,re=W?x_(W):0,Ee=W?j_(W,n):"No tab";v.useEffect(()=>{se.current?.focus(),se.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!A)return;const F=le=>{le.key==="Escape"&&H(!1)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[A]),v.useEffect(()=>{A&&e.length===0&&H(!1)},[A,e.length]);function ie(F,le){B({tabId:F,title:le})}function V(){if(!D)return;const F=D.title.trim();F&&k(D.tabId,F),B(null)}function X(){return f.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${gM()}`,onClick:b,disabled:!S,children:f.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),f.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${vM()}`,onClick:C,disabled:!S,children:f.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return f.jsxs(f.Fragment,{children:[f.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[f.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:m,children:f.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[f.jsx("span",{}),f.jsx("span",{}),f.jsx("span",{})]})}),f.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:Ee,onClick:()=>H(!0),disabled:e.length===0,children:[xe?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":xe.state,"aria-hidden":"true",title:Hb(xe)}):null,f.jsx("span",{children:Ee}),f.jsxs("small",{children:[J>=0?J+1:0,"/",e.length||0,re>1?` / ${re}`:""]})]}),f.jsxs("div",{className:"terminal-tab-list",children:[e.map((F,le)=>{const O=Pu(F),M=x_(F),j=j_(F,n),ae=F.id===t,we=D?.tabId===F.id,N=B_(F,n),U=r?.has(F.id)??!1;return f.jsxs(Ni.Fragment,{children:[f.jsx(uC,{index:le}),f.jsx(W4,{tab:F,active:ae,editing:we,title:j,paneCount:M,terminalIds:O,canClose:e.length>1,editValue:we?D.title:null,editInputRef:we?se:null,activity:N,unread:U,onSelect:()=>c(F.id),onBeginRename:()=>ie(F.id,j),onCloseAll:()=>g(O),onCommitRename:V,onCancelRename:()=>B(null),onRenameChange:ue=>B({tabId:F.id,title:ue})})]},F.id)}),f.jsx(uC,{index:e.length}),f.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:u,children:"+"}),(o?.length??0)>0?f.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(F=>f.jsx(q4,{terminal:F,onReattach:()=>p?.(F.id),onDelete:()=>$(F)},F.id))}):null]}),f.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:u,children:"+"}),S?X():null]}),A?f.jsx($4,{tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:D,editInputRef:se,onClose:()=>H(!1),onSelectTab:F=>{c(F),H(!1)},onCreateTab:()=>{u(),H(!1)},onBeginRename:ie,onCloseTerminals:F=>{g(F),H(!1)},onCommitRename:V,onCancelRename:()=>B(null),onRenameChange:(F,le)=>B({tabId:F,title:le}),onReattachTerminal:F=>{p?.(F),H(!1)},onDeleteTerminal:F=>{$(F),H(!1)}}):null,Y?f.jsx(V4,{terminal:Y,onCancel:()=>$(null),onConfirm:()=>{y?.(Y.id),$(null)}}):null]})}function W4({tab:e,active:t,editing:n,title:r,paneCount:o,canClose:c,editValue:u,editInputRef:m,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:C,onCommitRename:k,onCancelRename:S,onRenameChange:D}){const{attributes:B,listeners:A,setNodeRef:H,transform:Y,isDragging:$}=WC({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),se={transform:Gg.Translate.toString(Y),opacity:$?.4:void 0,zIndex:$?2:void 0};return f.jsxs("div",{ref:H,className:"terminal-tab","data-active":t,"data-dragging":$,"data-unread":p?"true":void 0,style:se,...B,...A,children:[g?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Hb(g)}):null,n&&m&&u!==null?f.jsxs("form",{className:"terminal-tab-editor",onSubmit:J=>{J.preventDefault(),k()},children:[f.jsx("input",{ref:m,"aria-label":`Rename ${r}`,value:u,onBlur:k,onChange:J=>D(J.target.value),onKeyDown:J=>{if(J.key==="Enter"){J.preventDefault(),k();return}J.key==="Escape"&&(J.preventDefault(),S())}}),f.jsx("small",{children:o})]}):f.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:J=>{J.preventDefault(),b()},children:[f.jsx("span",{children:r}),f.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?f.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:J=>J.stopPropagation(),onClick:J=>{J.stopPropagation(),C()},children:"x"}):null]})}function $4({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:u,onClose:m,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:C,onCancelRename:k,onRenameChange:S,onReattachTerminal:D,onDeleteTerminal:B}){const A=v.useRef(null);return v.useEffect(()=>{A.current?.scrollIntoView?.({block:"nearest"})},[t]),f.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:m,children:f.jsxs("section",{className:"mobile-tab-sheet",onClick:H=>H.stopPropagation(),children:[f.jsxs("header",{children:[f.jsxs("div",{children:[f.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),f.jsxs("small",{children:[e.length," open"]})]}),f.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[f.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),f.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:m,children:"×"})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((H,Y)=>{const $=Pu(H),se=x_(H),J=j_(H,n),W=H.id===t,xe=c?.tabId===H.id,re=B_(H,n),Ee=r?.has(H.id)??!1;return f.jsxs("div",{ref:W?A:null,className:"mobile-tab-sheet-row","data-active":W,"data-unread":Ee?"true":void 0,children:[xe&&c?f.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),C()},children:f.jsx("input",{ref:u,"aria-label":`Rename ${J}`,value:c.title,onBlur:C,onChange:ie=>S(H.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),C();return}ie.key==="Escape"&&(ie.preventDefault(),k())}})}):f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${J}`,onClick:()=>g(H.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:J}),f.jsx("small",{children:K4(H,n,se,re)})]}),f.jsxs("span",{className:"mobile-tab-sheet-meta",children:[re?f.jsx("span",{className:"terminal-tab-status-dot","data-activity":re.state,"aria-hidden":"true",title:Hb(re)}):null,f.jsx("span",{children:se})]})]}),f.jsxs("div",{className:"mobile-tab-sheet-actions",children:[xe?f.jsx("button",{type:"button","aria-label":`Done renaming ${J}`,onClick:C,children:"Done"}):f.jsx("button",{type:"button","aria-label":`Rename ${J}`,onClick:()=>y(H.id,J),children:"Rename"}),e.length>1?f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${J}`,onClick:()=>b($),children:"×"}):null]})]},H.id)}),(o?.length??0)>0?f.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[f.jsx("span",{children:"Detached"}),(o??[]).map(H=>{const Y=H.title||H.cwd||H.id.slice(0,8);return f.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[f.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>D(H.id),children:[f.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),f.jsxs("span",{className:"mobile-tab-sheet-copy",children:[f.jsx("strong",{children:Y}),f.jsx("small",{children:H.cwd})]}),f.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),f.jsx("div",{className:"mobile-tab-sheet-actions",children:f.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>B(H),children:"×"})})]},H.id)})]}):null]})]})})}function uC({index:e}){const{setNodeRef:t,isOver:n}=Q_({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return f.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function q4({terminal:e,onReattach:t,onDelete:n}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
56
|
-
${e.cwd}
|
|
57
|
-
(detached — click to re-open, × to delete)`;return f.jsxs("span",{className:"terminal-detached-pill",title:o,children:[f.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),f.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function V4({terminal:e,onCancel:t,onConfirm:n}){const r=e.title||e.cwd||e.id.slice(0,8);return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:"Delete this terminal?"}),f.jsx("span",{children:r}),f.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function Y4({uploads:e,onDismiss:t,onDismissAll:n,onRetry:r,onCancel:o}){if(e.length===0)return null;const u=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",m=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return f.jsxs("aside",{className:`upload-toast upload-toast-${J4(e)}`,role:u,"aria-live":u==="alert"?"assertive":"polite",children:[f.jsxs("header",{className:"upload-toast-header",children:[f.jsx("strong",{children:e.length===1?Xh(e[0]):`Uploads ${m>0?`(${m} active)`:`(${e.length})`}`}),f.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),f.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>f.jsx(X4,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function X4({upload:e,compact:t,onDismiss:n,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,u=e.status==="failed"||e.status==="partial",m=e.status==="queued"||e.status==="uploading";return f.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Xh(e),children:[f.jsxs("div",{className:"upload-queue-item-header",children:[f.jsx("strong",{children:Xh(e)}),f.jsxs("div",{className:"upload-queue-actions",children:[m?f.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,u?f.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,f.jsx("button",{type:"button","aria-label":`Dismiss ${Xh(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?f.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?f.jsx(G4,{toast:e}):null,c&&"message"in e&&e.message?f.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?f.jsx(Z4,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?f.jsx("p",{children:e.message}):null]})}function G4({toast:e}){const t=e.percent===null?e6(e.loaded):`${e.percent}%`;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"upload-progress-row",children:[f.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),f.jsx("span",{children:t})]}),f.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:f.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function Z4({response:e,compact:t}){const n=e.results.filter(u=>u.status==="failed"),r=e.results.filter(u=>u.status==="uploaded"),o=t?3:6,c=[...n,...r].slice(0,o);return f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?f.jsx("ul",{className:"upload-result-list",children:c.map((u,m)=>f.jsx(Q4,{result:u},`${u.relativePath}-${m}`))}):null,e.results.length>c.length?f.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function Q4({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return f.jsxs("li",{"data-status":e.status,children:[f.jsx("span",{className:"upload-result-path",children:t}),n?f.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?f.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Xh(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function J4(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 e6(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function t6({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const r=e,o=r.outcome==="stopped"?"stopped":"finished",c=r.commandName?`${r.commandName} ${o}`:`Command ${o}`;function u(g){g.stopPropagation(),n()}function m(g){g.target===g.currentTarget&&(g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),t(r)))}return f.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:m,children:[f.jsxs("header",{className:"completion-toast-header",children:[f.jsxs("div",{className:"completion-toast-copy",children:[f.jsx("strong",{children:r.tabTitle}),f.jsx("span",{children:c})]}),f.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:u,onPointerDown:g=>g.stopPropagation(),children:"x"})]}),f.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const i6=du(0,0,1,1),Mr=1e-6;function n6(e){return OT(e).map(t=>t.terminalId)}function OT(e){return uu(e,i6).sort(o6).map((t,n)=>({...t,index:n+1}))}function s6(e,t,n){const r=OT(e),o=r.find(u=>u.terminalId===t);return o?r.filter(u=>u.terminalId!==t).map(u=>a6(o,u,n)).filter(u=>u!==null).sort(l6)[0]?.entry.terminalId??null:null}function r6(e,t){return!Number.isInteger(t)||t<1?null:n6(e)[t-1]??null}function uu(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=c6(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...uu(e.first,du(t.left,t.top,o,t.bottom)),...uu(e.second,du(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*n;return[...uu(e.first,du(t.left,t.top,t.right,r)),...uu(e.second,du(t.left,r,t.right,t.bottom))]}function a6(e,t,n){const r=e.bounds,o=t.bounds,c=dC(r.left,r.right,o.left,o.right),u=dC(r.top,r.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=r.centerX-Mr||u<=Mr?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"right":return o.centerX<=r.centerX+Mr||u<=Mr?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:u};case"up":return o.centerY>=r.centerY-Mr||c<=Mr?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Mr||c<=Mr?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function o6(e,t){return Ml(e.bounds.top,t.bounds.top)||Ml(e.bounds.left,t.bounds.left)}function l6(e,t){return Ml(e.primaryDistance,t.primaryDistance)||Ml(e.perpendicularDistance,t.perpendicularDistance)||Ml(t.overlap,e.overlap)||Ml(e.entry.index,t.entry.index)}function Ml(e,t){const n=e-t;return Math.abs(n)<=Mr?0:n}function dC(e,t,n,r){return Math.max(0,Math.min(t,r)-Math.max(e,n))}function du(e,t,n,r){return{left:e,top:t,right:n,bottom:r,centerX:e+(n-e)/2,centerY:t+(r-t)/2}}function c6(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const hC="nterminal.terminalWorkspaces.v2",BT="nterminal.sidebarCollapsed.v1",u6=75,fC=VC.map(e=>e.url),d6=VC[0].url,h6=6;function f6({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r,sessionExpiresAt:o=null,previewMode:c=!1,onLogout:u=async()=>{},onSessionInvalid:m}){const g=v.useMemo(()=>e??kf(),[e]),p=v.useMemo(()=>t??Bl(null),[t]),y=v.useMemo(()=>j6(n),[n]),b=v.useMemo(()=>w=>NT(n,w),[n]),C=v.useMemo(()=>()=>It(n),[n]),k=v.useSyncExternalStore(b,C,C),S=k.state,D=k.editors,B=!k.loaded,A=k.error,[H,Y]=v.useState(!1),[$,se]=v.useState(()=>F6()),[J,W]=v.useState("servers"),[xe,re]=v.useState(!1),Ee=v.useSyncExternalStore(EM,Tw,Tw);v.useSyncExternalStore(vu,kw,kw);const[ie,V]=v.useState(0),[X,F]=v.useState(null),[le,O]=v.useState(()=>[null]),[M,j]=v.useState(()=>({[Yi]:"Local"})),[ae,we]=v.useState(0),[N,U]=v.useState(()=>[n]),[ue,Ce]=v.useState(()=>new Set),[Oe,De]=v.useState({}),[Be,Ne]=v.useState(null),Ue=v.useRef(0),Fe=v.useRef(0),[ne,me]=v.useState(null),[R,q]=v.useState(null),fe=v.useRef(null),ge=v.useRef(0),Q=v.useRef(null),ke=v.useRef(null),de=v.useRef(null),Re=v.useRef(null),Ie=v.useRef(()=>{}),[je,Ye]=v.useState(null),ct=O2(iw(PC,{activationConstraint:{distance:8}}),iw(HC,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>DM(g),[g]);function Nt(w){const E=w.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Ye({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Ye({tabId:E.sourceTabId,terminalId:E.terminalId})}}function yt(w){Ye(null);const E=w.active.data.current,z=w.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){mt({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){mt({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&mt({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){mt({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){mt({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&mt({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Tt(){Ye(null)}const $e=S.workspaces.find(w=>w.id===S.activeWorkspaceId)??S.workspaces[0],St=$e?.tabs.find(w=>w.id===$e.activeTabId)??$e?.tabs[0],Lt=St?.activeTerminalId??null,ye=Lt?S.terminals[Lt]:void 0,Xe=M6("(max-width: 760px)"),rt=v.useMemo(()=>St?Cf(St.root):[],[St]),Ze=$e&&St?hu(n,$e.id,St.id):null,Et=St?jT(rt,St.activeTerminalId,Ze?Oe[Ze]:void 0):null,ut=Xe&&rt.length>1,Tn=v.useMemo(()=>($e?.detachedTerminalIds??[]).flatMap(w=>{const E=S.terminals[w];return E?[E]:[]}),[$e?.detachedTerminalIds,S.terminals]),gi=v.useMemo(()=>{const w=new Set;for(const E of $e?.tabs??[])Pu(E).some(z=>k.unreadCompletions.has(z))&&w.add(E.id);return w},[$e?.tabs,k.unreadCompletions]);v.useSyncExternalStore(R4,aC,aC);const[ee,Pe]=v.useState([]),st=v.useRef([]),tt=v.useRef(null),[kt,Xt]=v.useState(null),[Ft,ci]=v.useState(null),[Gt,si]=v.useState([]),[ui,Wt]=v.useState(()=>ko()),cn=v.useRef(0),ei=v.useRef(n),Hi=v.useRef(fC),vn=v.useRef(ui),_n=v.useRef(()=>{});_n.current=dn,Ie.current=rr;const ti=v.useCallback(async()=>{try{const w=await g.listNotificationAssets();si(w.assets.filter(E=>E.enabled).map(E=>E.url))}catch{si([])}},[g]),Ji=v.useCallback(w=>{j(E=>{const z={...E};for(const oe of w)z[z_(oe.agentId)]=oe.label;return $g(E,z)?E:z})},[]);v.useEffect(()=>{U(w=>w.some(E=>pn(E,n))?w:[...w,n])},[n]);const ri=v.useCallback(w=>{const E=It(w),z=Bl(w);for(const oe of Object.keys(E.state.terminals))cu(z.createWebSocketUrl(oe)),Eh(oe),lu(oe);P4(w),U(oe=>oe.filter(Se=>!pn(Se,w))),Ce(oe=>{const Se=`${Zh(w)}:`;let pe=!1;const Me=new Set;for(const Qe of oe){if(Qe.startsWith(Se)){pe=!0;continue}Me.add(Qe)}return pe?Me:oe}),De(oe=>{const Se=`${Zh(w)}:`;let pe=!1;const Me={};for(const[Qe,ot]of Object.entries(oe)){if(Qe.startsWith(Se)){pe=!0;continue}Me[Qe]=ot}return pe?Me:oe})},[]);v.useEffect(()=>{let w=!1;return g.getMainInfo().then(E=>{if(w)return;const z=E.name?.trim()||"Local";j(oe=>{const Se={...oe,[Yi]:z};return $g(oe,Se)?oe:Se})}).catch(()=>{}),g.listAgents().then(E=>{if(!w){const z=E.agents.map(Se=>Se.id),oe=WR(E.serverOrder,E.agents);j(Se=>{const pe={[Yi]:Se[Yi]??"Local"};for(const Me of E.agents)pe[Me.id]=Me.name;return $g(Se,pe)?Se:pe}),n!==null&&!z.includes(n)&&(ri(n),r?.(null)),O(oe)}}).catch(()=>{}),()=>{w=!0}},[n,g,ri,r,ae]);const vi=v.useCallback(w=>{ri(w),we(E=>E+1),pn(w,ei.current)&&r?.(null)},[ri,r]);v.useEffect(()=>{O(w=>w.some(E=>pn(E,n))?w:[...w,n])},[n]),v.useEffect(()=>{ei.current=n},[n]),v.useEffect(()=>{F(null)},[n]),v.useEffect(()=>{const w=Q.current;if(!w)return;if(!pn(w.agentId,n)){Q.current=null;return}if(!k.loaded||S.workspaces.length===0)return;Q.current=null;const E=w.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];E&&E.id!==S.activeWorkspaceId&&mt({type:"workspace.selected",workspaceId:E.id})},[n,k.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const w=ke.current;if(w){if(!pn(w.agentId,n)){ke.current=null;return}k.loaded&&(ke.current=null,S.workspaces.some(E=>E.id===w.workspaceId)&&mt({type:"workspace.selected",workspaceId:w.workspaceId}))}},[n,k.loaded,S.workspaces]),v.useEffect(()=>{const w=de.current;if(w){if(!pn(w.agentId,n)){de.current=null;return}k.loaded&&(de.current=null,k.error||jo())}},[n,k.error,k.loaded]),v.useEffect(()=>{yn()},[n,k.loaded,S]),v.useEffect(()=>{const w=()=>{const oe=A6();oe&&Ie.current(oe)},E=oe=>{const Se=L6(oe.data);Se&&Ie.current(Se)},z=oe=>{const Se=Nf(oe.detail);Se&&Ie.current(Se)};return w(),window.addEventListener("hashchange",w),window.addEventListener(iv,z),navigator.serviceWorker?.addEventListener?.("message",E),()=>{window.removeEventListener("hashchange",w),window.removeEventListener(iv,z),navigator.serviceWorker?.removeEventListener?.("message",E)}},[]),v.useEffect(()=>{ti()},[ti]),v.useEffect(()=>nx(()=>Wt(ko())),[]),v.useEffect(()=>{const w=E=>{_n.current(E)};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[]),v.useEffect(()=>{Hi.current=Gt.length>0?Gt:fC},[Gt]),v.useEffect(()=>{vn.current=ui},[ui]),v.useEffect(()=>{if(!k.loaded||!$e||!St)return;const w=hu(n,$e.id,St.id);Ce(E=>{if(E.has(w))return E;const z=new Set(E);return z.add(w),z})},[n,k.loaded,$e?.id,St?.id]),v.useEffect(()=>()=>{Bs()},[]),v.useEffect(()=>{const w=BR(g),E=zR(g);return()=>{w(),E()}},[g]),v.useEffect(()=>N4(w=>{const E=It(w.agentId).state,z=E.workspaces.flatMap(Me=>Me.tabs).find(Me=>Me.id===w.tabId),oe=E.terminals[w.terminalId],Se=z?.title?.trim()||oe?.title||w.commandName||"terminal",pe=document.visibilityState==="visible"&&pn(w.agentId,ei.current)&&w.tabId===B6(E);if(pe||RR({agentId:w.agentId,tabTitle:Se,commandName:w.commandName,terminalId:w.terminalId,outcome:w.outcome}),!pe&&document.visibilityState==="visible"&&vn.current.enabled){const Me=cn.current+1;cn.current=Me;const Qe=Hi.current;Xt({id:Me,agentId:w.agentId,terminalId:w.terminalId,tabId:w.tabId,tabTitle:Se,commandName:w.commandName,outcome:w.outcome,assetSrc:Qe[Math.floor(Math.random()*Qe.length)]??d6})}}),[]),v.useEffect(()=>{if(!kt||ui.persistUntilDismissed)return;const w=window.setTimeout(()=>{Xt(E=>E?.id===kt.id?null:E)},ui.durationSeconds*1e3);return()=>window.clearTimeout(w)},[kt,ui]),v.useEffect(()=>{W6($),$&&Bn()},[$]),v.useEffect(()=>{let w=!1;async function E(){if(!It(n).loaded){ka(n,!1,null);try{let oe=null,Se=null;try{oe=I6(y)}catch(ot){if(!(ot instanceof xf))throw ot;Se=ot}const[pe,Me]=await Promise.all([p.listTerminals(),p.getTerminalLayout()]),Qe=pe.terminals.length>0?pe.terminals:[(await p.createTerminal({cols:80,rows:24})).terminal];if(!w){const ot=Me.layout?zT(Me.layout):null;if(!ot&&Se)throw Se;const Si=ot??oe??{},Wi=C_(Qe,void 0,Si.savedWorkspaces,Si.savedActiveWorkspaceId),Is=Kg(Wi);lC(n,Wi),eu(n,Me.revision,JSON.stringify(Is)),ka(n,!0,null),!ot&&oe&&ar(Is,{baseRevision:Me.revision})}}catch(oe){!w&&!Oi(oe)&&ka(n,!0,Ta(oe))}}}return E(),()=>{w=!0}},[n,p,ie]);function _i(){ka(n,!1,null),V(w=>w+1)}function Bn(){Ue.current+=1,Fe.current+=1,Ne(null)}function Hr(w){Ue.current+=1,Fe.current+=1,Ne(E=>E&&{...E,cwd:w,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function jo(){Ue.current+=1,Fe.current+=1;const w=S.workspaces.length+1,E=hs();Ne({mode:"create",workspaceId:null,title:`Workspace ${w}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&tr(E)}function Ur(w){if(pn(w,n)){jo();return}de.current={agentId:w},r?.(w)}function er(w){if($&&!H)return;const E=S.workspaces.find(oe=>oe.id===w);if(!E)return;Ue.current+=1,Fe.current+=1;const z=E.defaultCwd??ye?.cwd??"";Ne({mode:"edit",workspaceId:w,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&tr(z)}function hs(){return $e?.defaultCwd??ye?.cwd??""}async function tr(w){const E=Ue.current+1;Ue.current=E;const z=w.trim();if(Ne(oe=>oe&&{...oe,cwd:w,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const oe=await p.createFileRoot({path:z}),Se=await p.listFiles({rootToken:oe.rootToken,path:""});if(Ue.current!==E)return;Ne(pe=>pe&&{...pe,cwd:oe.rootPath,browseRoot:{rootToken:oe.rootToken,rootPath:oe.rootPath},browseEntries:Se.entries.filter(Me=>Me.kind==="directory"),browseStatus:"idle",error:null})}catch(oe){if(Ue.current!==E)return;Ne(Se=>Se&&{...Se,browseStatus:"idle",error:Ta(oe)})}}async function fs(){const w=Be;if(!w)return;const E=w.title.trim(),z=w.cwd.trim();if(!E||!z){Ne({...w,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const oe=Fe.current+1;Fe.current=oe,Ne({...w,submitStatus:"submitting",error:null});try{const Se=await p.createFileRoot({path:z});if(Fe.current!==oe)return;if(w.mode==="create"){const pe=S.workspaces.length+1;mt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${pe}`,title:E,defaultCwd:Se.rootPath})}else w.workspaceId&&(mt({type:"workspace.renamed",workspaceId:w.workspaceId,title:E}),mt({type:"workspace.defaultCwdChanged",workspaceId:w.workspaceId,defaultCwd:Se.rootPath}));Ne(null)}catch(Se){if(Fe.current!==oe)return;Ne(pe=>pe&&{...pe,submitStatus:"idle",error:Ta(Se)})}}function Rs(w){Fe.current+=1,Ne(w)}function ps(w,E,z){if(w===E)return;const oe=S.workspaces.some(pe=>pe.id===w),Se=S.workspaces.some(pe=>pe.id===E);!oe||!Se||mt({type:"workspace.reordered",sourceWorkspaceId:w,targetWorkspaceId:E,placement:z})}function Ms(w,E){const z=S.workspaces.findIndex(Se=>Se.id===w),oe=S.workspaces[z+E];z<0||!oe||ps(w,oe.id,E<0?"before":"after")}function zt(w,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),fe.current={sourceId:w,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function Io(w){const E=fe.current;if(!E||E.pointerId!==w.pointerId)return;const z=Math.hypot(w.clientX-E.startX,w.clientY-E.startY);if(!E.active){if(z<h6)return;E.active=!0,me(E.sourceId)}const Se=document.elementFromPoint(w.clientX,w.clientY)?.closest("[data-workspace-id]"),pe=Se?.dataset.workspaceId??null;if(!Se||!pe||pe===E.sourceId||!S.workspaces.some(ot=>ot.id===pe)){E.targetId=null,q(null);return}const Me=Se.getBoundingClientRect(),Qe=w.clientY<Me.top+Me.height/2?"before":"after";E.targetId=pe,E.placement=Qe,q({workspaceId:pe,placement:Qe})}function Kr(w){const E=fe.current;!E||E.pointerId!==w.pointerId||(w.preventDefault(),w.stopPropagation(),w.currentTarget.releasePointerCapture?.(w.pointerId),fe.current=null,me(null),q(null),E.active&&E.targetId&&ps(E.sourceId,E.targetId,E.placement))}function $t(w){const E=fe.current;E&&E.pointerId===w.pointerId&&w.currentTarget.releasePointerCapture?.(w.pointerId),fe.current=null,me(null),q(null)}async function jn(){await As(async()=>{const w=$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},E=await p.createTerminal(w);mt({type:"terminal.created",terminal:E.terminal})})}async function en(w){await As(async()=>{const E=Lt?{parentTerminalId:Lt,cols:80,rows:24}:$e?.defaultCwd?{cols:80,rows:24,cwd:$e.defaultCwd}:{cols:80,rows:24},z=await p.createTerminal(E);mt({type:"terminal.split",terminal:z.terminal,direction:w})})}async function Fr(w){let E=Lt,z=Ze;const oe=$e?.defaultCwd?.trim();if(!E&&!oe)throw new Error("No active pane is available.");const Se=await p.readFile(w);if(!E&&oe){const Qe=await p.createTerminal({cols:80,rows:24,cwd:oe});E=Qe.terminal.id,mt({type:"terminal.created",terminal:Qe.terminal})}if(E){mt({type:"pane.selected",terminalId:E});const Qe=It(n).state,ot=Qe.workspaces.find(Wi=>Wi.id===Qe.activeWorkspaceId)??Qe.workspaces[0],Si=ot?.tabs.find(Wi=>Wi.id===ot.activeTabId)??ot?.tabs[0];z=ot&&Si?hu(n,ot.id,Si.id):null}const pe=`editor-${Date.now().toString(36)}-${z4(n)}`,Me=K6(Se.path);Fg(n,Qe=>({...Qe,[pe]:{id:pe,title:Me,rootToken:w.rootToken,path:Se.path,read:Se}})),z&&De(Qe=>({...Qe,[z]:IT(pe)})),mt({type:"editor.split",editorId:pe,title:Me,direction:"vertical"})}function zo(w){Fg(n,E=>{const z={...E};return delete z[w],z}),mt({type:"editor.closed",editorId:w})}function ir(w){ms([w])}function ms(w){const E=[...new Set(w)].filter(oe=>S.terminals[oe]);if(E.length===0)return;const z=E.length===1?S.terminals[E[0]]?.title||S.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;F(null),ci({terminalIds:E,label:z,workspaceId:$e?.id??S.activeWorkspaceId??null})}function Wr(w,E){const z=Vr(w,E);if(!z)return!1;const oe=w.filter(Se=>!z.detachedTerminalIds.includes(Se));if(z.detachedTerminalIds.length+oe.length>Wl)return F(P6(z.detachedTerminalIds.length)),!1;F(null);for(const Se of w)mt(z.id?{type:"terminal.detached",terminalId:Se,workspaceId:z.id}:{type:"terminal.detached",terminalId:Se});return!0}async function bn(w){await As(async()=>{for(const E of w)await Ki(E),cu(p.createWebSocketUrl(E)),Eh(E),lu(E),mt({type:"terminal.closed",terminalId:E})})}async function Ui(w){const E=S.workspaces.find(z=>z.id===w);!E||S.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await As(async()=>{const z=wf(E),oe=[];let Se=null;for(const Me of z)try{await Ki(Me)}catch(Qe){oe.push(Ta(Qe)),Qe instanceof Ln&&Qe.status===401&&!p.isAgent&&(Se=Qe)}finally{cu(p.createWebSocketUrl(Me)),Eh(Me),lu(Me)}const pe=E.tabs.flatMap(Me=>I_(Me.root));if(pe.length>0){const Me=new Set(pe);Fg(n,Qe=>{const ot={...Qe};for(const Si of Me)delete ot[Si];return ot})}if(mt({type:"workspace.closed",workspaceId:w}),Se)throw Se;if(oe.length>0)throw new Error(`Workspace was removed, but ${oe.length} terminal session${oe.length===1?"":"s"} may still be running. ${oe[0]}`)})}async function Ns(w){await As(async()=>{await Ki(w),cu(p.createWebSocketUrl(w)),Eh(w),lu(w),mt({type:"terminal.closed",terminalId:w})})}async function Va(w,E){const z=E.trim();if(!z)return;let oe=null;for(const Se of S.workspaces){const pe=Se.tabs.find(Me=>Me.id===w);if(pe){oe=pe.activeTerminalId;break}}if(mt({type:"tab.renamed",tabId:w,title:z}),!!oe)try{const Se=await p.renameTerminal(oe,z);_s({type:"terminal.updated",terminal:Se.terminal})}catch(Se){ka(n,!0,Ta(Se))}}function gs(w){const E=S.terminals[w];E&&mt({type:"terminal.created",terminal:E})}async function Ki(w){try{await p.closeTerminal(w)}catch(E){if(E instanceof Ln&&E.status===404)return;throw E}}async function vs(){await As(async()=>{await u()})}async function As(w){ka(n,!0,null);try{await w()}catch(E){if(Oi(E))return;ka(n,!0,Ta(E))}}function Oi(w){return w instanceof Ln&&w.status===401&&!p.isAgent&&m?(m({source:"workspace-api-401",status:401,activeAgentId:n}),!0):!1}function mt(w){Sl(n,w);const E=It(n),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const oe=Kg(z);JSON.stringify(oe)!==E.lastPersistedLayoutJson&&Os(oe)}function _s(w){Sl(n,w)}function nr(w,E,z,oe){const Se=hu(w,E,z);De(pe=>({...pe,[Se]:oe}))}function un(w){Ze&&De(E=>({...E,[Ze]:w}))}function $r(w,E){const z=xu(w);E?nr(n,E.workspaceId,E.tabId,z):un(z),mt({type:"pane.selected",terminalId:w})}function Ya(w){un(w.key),w.type==="terminal"&&mt({type:"pane.selected",terminalId:w.terminalId})}function dn(w){if(xe||Ft||w.isComposing||w.key==="Process"||b6(w.target))return;const E=m6(w);if(!E)return;if(w.preventDefault(),w.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){qr(E.type==="server.next"?1:-1);return}const z=It(n).state,oe=z.workspaces.find(Me=>Me.id===z.activeWorkspaceId)??z.workspaces[0],Se=oe?.tabs.find(Me=>Me.id===oe.activeTabId)??oe?.tabs[0];if(E.type==="split"){if(!Se)return;en(E.direction);return}if(!oe||!Se)return;if(E.type==="tab.previous"||E.type==="tab.next"){const Me=_6(oe.tabs,Se.id,E.type==="tab.next"?1:-1);Me&&mt({type:"tab.selected",tabId:Me.id});return}if(E.type==="tab.index"){const Me=oe.tabs[E.index-1];Me&&mt({type:"tab.selected",tabId:Me.id});return}const pe=g6(Se.root,Se.activeTerminalId,E);pe&&$r(pe,{workspaceId:oe.id,tabId:Se.id})}function Po(w,E){if(!r||le.length===0)return;const z=le.findIndex(Me=>pn(Me,n)),Se=((z===-1?0:z)+w+le.length)%le.length,pe=le[Se]??null;pn(pe,n)||(E&&(Q.current={agentId:pe,edge:E}),r(pe))}function qr(w){const E=It(n).state,z=E.workspaces;if(z.length===0){Po(w,w===1?"first":"last");return}const oe=z.findIndex(Me=>Me.id===E.activeWorkspaceId),pe=(oe===-1?0:oe)+w;if(pe>=0&&pe<z.length){mt({type:"workspace.selected",workspaceId:z[pe].id});return}Po(w,w===1?"first":"last")}function bs(w,E){if(pn(w,n)){mt({type:"workspace.selected",workspaceId:E});return}ke.current={agentId:w,workspaceId:E},r?.(w)}function Vr(w,E){if(E)return S.workspaces.find(z=>z.id===E)??null;for(const z of w){const oe=S.workspaces.find(pe=>pe.tabs.some(Me=>Pu(Me).includes(z)));if(oe)return oe;const Se=S.workspaces.find(pe=>pe.detachedTerminalIds.includes(z));if(Se)return Se}return S.workspaces.find(z=>z.id===S.activeWorkspaceId)??S.workspaces[0]??null}function Ho(w){Dl(w.dataTransfer)&&(w.preventDefault(),w.dataTransfer.dropEffect="copy")}function Gl(w){if(!Dl(w.dataTransfer))return;w.preventDefault();const E=H6(It(n).state),z=ge.current+1;if(ge.current=z,!E){Yr({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Yr({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),ys(z,E.id,w.dataTransfer)}async function ys(w,E,z){try{const oe=await Kk(z);if(oe.length===0)throw new Error("No files were found in the drop.");Fi(w,{id:w,status:"queued",fileCount:oe.length,message:"Queued"},{terminalId:E,files:oe})}catch(oe){Fi(w,{id:w,status:"failed",fileCount:0,message:Ta(oe)},{terminalId:E})}finally{bi()}}async function Xn(w){const E=st.current.find(pe=>pe.id===w);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,oe=E.files,Se=new AbortController;tt.current=w,Fi(w,{id:w,status:"uploading",fileCount:oe.length,loaded:0,total:null,percent:null},{terminalId:z,files:oe,abortController:Se});try{const pe=await bC({terminalId:z,files:oe,signal:Se.signal,onProgress:Si=>{Fi(w,{id:w,status:"uploading",fileCount:oe.length,loaded:Si.loaded,total:Si.total,percent:Si.percent},{terminalId:z,files:oe,abortController:Se})}}),Me=pe.failed>0?pe.uploaded>0?"partial":"failed":"success",Qe=pe.failed>0?U6(pe):void 0,ot={id:w,status:Me,fileCount:oe.length,response:pe};Qe&&(ot.message=Qe),Fi(w,ot,{terminalId:z,files:oe})}catch(pe){Fi(w,{id:w,status:"failed",fileCount:oe.length,message:Se.signal.aborted?"Upload canceled.":Ta(pe)},{terminalId:z,files:oe})}finally{tt.current===w&&(tt.current=null),bi()}}function bi(){if(tt.current!==null)return;const w=st.current.find(E=>E.status==="queued");w?.terminalId&&w.files&&w.files.length>0&&Xn(w.id)}function Yr(w){ai(E=>[...E,w])}function Fi(w,E,z={}){ai(oe=>oe.map(Se=>{if(Se.id!==w)return Se;const pe={...E},Me=z.terminalId??Se.terminalId,Qe=z.files??Se.files;return Me!==void 0&&(pe.terminalId=Me),Qe!==void 0&&(pe.files=Qe),z.abortController!==void 0&&(pe.abortController=z.abortController),pe}))}function ai(w){const E=w(st.current);st.current=E,Pe(E)}function Ls(w){st.current.find(z=>z.id===w)?.abortController?.abort(),tt.current===w&&(tt.current=null),ai(z=>z.filter(oe=>oe.id!==w)),bi()}function sr(){for(const w of st.current)w.abortController?.abort();tt.current=null,ai(()=>[])}function Xa(w){const E=st.current.find(z=>z.id===w);if(E){if(E.status==="queued"){Ls(w);return}E.abortController?.abort()}}function In(w){const E=st.current.find(oe=>oe.id===w);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=yi(E);if(z.length===0){Fi(w,{id:w,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}Fi(w,{id:w,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),bi()}function yi(w){const E=w.files??[],z="response"in w?w.response:void 0;if(!z)return E;const oe=z.results.filter(Me=>Me.status==="failed").map(Me=>Me.relativePath);if(oe.length===0)return[];const Se=new Map;for(const Me of E){const Qe=Se.get(Me.relativePath)??[];Qe.push(Me),Se.set(Me.relativePath,Qe)}const pe=[];for(const Me of oe){const ot=Se.get(Me)?.shift();ot&&pe.push(ot)}return pe}function Xr(w){const z=It(w.agentId).state.workspaces.find(oe=>oe.tabs.some(Se=>Se.id===w.tabId));z&&nr(w.agentId,z.id,w.tabId,xu(w.terminalId)),Sl(w.agentId,{type:"pane.selected",terminalId:w.terminalId}),oC(w.agentId,w.terminalId),pn(w.agentId,n)||r?.(w.agentId),Xt(null)}function rr(w){if(Re.current=w,!pn(w.agentId,n)){r?r(w.agentId):Re.current=null;return}yn()}function yn(){const w=Re.current;if(!w||!pn(w.agentId,n)||!k.loaded)return;const E=It(w.agentId),z=O6(E.state,w.terminalId);Re.current=null,z&&(nr(w.agentId,z.workspaceId,z.tabId,xu(w.terminalId)),Sl(w.agentId,{type:"pane.selected",terminalId:w.terminalId}),oC(w.agentId,w.terminalId))}function Os(w){const E=It(n).mutable.saveCoord;E.pendingLayoutSave=w,tu(w,y),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&ar(z)},u6)}function Bs(){const w=It(n).mutable.saveCoord;w.saveTimer!==null&&(window.clearTimeout(w.saveTimer),w.saveTimer=null);const E=w.pendingLayoutSave;w.pendingLayoutSave=null,E&&(tu(E,y),ar(E))}function ar(w,E={}){const z=It(n).mutable.saveCoord;z.nextPersistLayout=w,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const oe=z.nextPersistLayout,Se=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,oe&&await or(oe,Se!==void 0?{baseRevision:Se}:{})}))}async function or(w,E={}){const z=It(n),oe=E.baseRevision??z.layoutRevision,Se={layout:w,...typeof oe=="number"?{baseRevision:oe}:{}};try{const pe=await p.saveTerminalLayout(Se),Me=pe.layout??w;eu(n,pe.revision,JSON.stringify(Me)),tu(Me,y);return}catch(pe){if(pe instanceof Ln&&pe.status===400&&pe.message===UD){z6(n,y),ka(n,!0,PT());return}if(pe instanceof Ln&&pe.status===409)try{const Me=await p.getTerminalLayout(),Qe=It(n).mutable.saveCoord;if(Qe.nextPersistLayout||Qe.pendingLayoutSave){const ot=Me.layout?JSON.stringify(Me.layout):It(n).lastPersistedLayoutJson;eu(n,Me.revision,ot);return}if(Me.layout){const ot=It(n).state,Si=C_(Object.values(ot.terminals),void 0,Me.layout.workspaces,Me.layout.activeWorkspaceId),Wi=Kg(Si);lC(n,Si),eu(n,Me.revision,JSON.stringify(Wi)),tu(Wi,y)}else eu(n,Me.revision,z.lastPersistedLayoutJson);return}catch{}tu(w,y)}}const js=$6(o),hn=!$||H,ki=hn?J:"servers";function Gn(w){const E=w.active?k:It(w.agentId),z=w.active?S:E.state,oe=w.active?k.loaded:E.loaded,Se=w.active?A:E.error;return f.jsxs("div",{className:`workspace-list-panel${w.active?" workspace-list-panel--active-server":""}`,"aria-label":`${w.label} workspaces`,children:[f.jsxs("div",{className:"workspace-list-header",children:[f.jsx("span",{children:"Workspaces"}),f.jsx("button",{type:"button","aria-label":`New workspace on ${w.label}`,title:"New workspace",onClick:()=>Ur(w.agentId),children:"+"})]}),oe?Se?f.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(w.agentId),children:Se}):f.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(pe=>{const Me=w.active&&pe.id===$e?.id,Qe=wf(pe).length,ot=M4(w.agentId,pe.id),Si=x6(ot),Wi=w.active&&z.workspaces.length>1,Is=R?.workspaceId===pe.id&&ne!==pe.id?R.placement:null;return f.jsxs(T6,{workspaceId:pe.id,active:Me,disabled:!w.active,reorderable:Wi,dragging:ne===pe.id,dropPlacement:Is,working:ot.workingTerminalCount>0,unread:ot.unreadCompletionCount>0,children:[Wi?f.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":ne===pe.id,onPointerDown:zn=>zt(pe.id,zn),onPointerMove:Io,onPointerUp:Kr,onPointerCancel:$t,onKeyDown:zn=>{(zn.key==="ArrowUp"||zn.key==="ArrowDown")&&(zn.preventDefault(),zn.stopPropagation(),Ms(pe.id,zn.key==="ArrowUp"?-1:1))},onClick:zn=>zn.stopPropagation(),children:"::"}):null,f.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Me?"page":void 0,title:pe.defaultCwd??void 0,onClick:()=>bs(w.agentId,pe.id),onDoubleClick:()=>{w.active&&er(pe.id)},children:[f.jsxs("span",{className:"workspace-list-title-row",children:[f.jsx("span",{className:"workspace-list-name",children:pe.title}),ot.workingTerminalCount>0||ot.unreadCompletionCount>0?f.jsxs("span",{className:"workspace-list-attention",title:Si,"aria-label":Si,children:[ot.workingTerminalCount>0?f.jsx("span",{className:"workspace-list-working-indicator","aria-hidden":"true"}):null,ot.unreadCompletionCount>0?f.jsx("span",{className:"workspace-list-unread-count","aria-hidden":"true",children:C6(ot.unreadCompletionCount)}):null]}):null]}),f.jsxs("small",{children:[pe.defaultCwd??"No folder"," · ",Qe," ",Qe===1?"session":"sessions"]})]}),w.active?f.jsxs("div",{className:"workspace-list-actions",children:[f.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${pe.title}`,title:"Edit workspace",onClick:()=>er(pe.id),children:"..."}),f.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${pe.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Ui(pe.id)},children:"x"})]}):null]},pe.id)})}):f.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(w.agentId),children:"Open server to load workspaces"})]})}return f.jsx(OD,{sensors:ct,onDragStart:Nt,onDragEnd:yt,onDragCancel:Tt,children:f.jsxs("main",{className:"terminal-shell","data-collapsed":$,"data-sidebar-open":H,onDragOver:Ho,onDrop:Gl,children:[f.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),f.jsxs("aside",{className:"workspace-sidebar",children:[f.jsxs("header",{className:"workspace-brand",children:[f.jsxs("div",{className:"workspace-brand-lockup",children:[hn?f.jsx(xC,{height:20}):f.jsx(CC,{size:24}),c&&hn?f.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),f.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":$?"Expand sidebar":"Collapse sidebar",title:$?"Expand sidebar":"Collapse sidebar",onClick:()=>se(w=>!w),children:$?">":"<"}),f.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),f.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${ki==="files"?"files":"servers"}`,children:[hn?f.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[f.jsx("button",{type:"button",role:"tab","aria-selected":J==="servers",onClick:()=>{W("servers")},children:"Workspaces"}),f.jsx("button",{type:"button",role:"tab","aria-selected":J==="files",onClick:()=>{W("files")},children:"Files"})]}):null,ki==="servers"&&hn?f.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:f.jsx(xw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Ji,renderServerChildren:Gn})}):null,hn?null:f.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:f.jsx(xw,{api:g,activeAgentId:n,onSelectServer:r??(()=>{}),onSessionInvalid:m,refreshToken:ae,onServerLabelsChange:Ji,compact:!0})}),ki==="files"?f.jsx(WM,{api:p,activeTerminalId:Lt,activeTerminalCwd:ye?.cwd??null,workspaceRootPath:Lt?null:$e?.defaultCwd??null,onOpenFile:Fr},`${n??"local"}:${$e?.id??"no-workspace"}`):null]}),f.jsxs("div",{className:"workspace-sidebar-footer",children:[hn?f.jsx("span",{children:js}):null,f.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[f.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>re(!0),children:[f.jsx(mC,{name:"settings"}),Ee.hasUpdates?f.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),hn?f.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{vs()},children:f.jsx(mC,{name:"logout"})}):null]})]})]}),xe?f.jsx(zM,{api:g,onClose:()=>re(!1),updateAvailable:Ee.hasUpdates,onNotificationAssetsChanged:()=>{ti()},onAgentRemoved:vi}):null,Be?f.jsx(y6,{dialog:Be,activePaneCwd:ye?.cwd??null,activeWorkspaceCwd:$e?.defaultCwd??null,onChange:Rs,onManualCwdChange:Hr,onBrowse:tr,onCancel:Bn,onSubmit:()=>{fs()}}):null,f.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":ut?"true":void 0,children:[f.jsx(F4,{tabs:$e?.tabs??[],activeTabId:$e?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:gi,detachedTerminals:Tn,onSelectTab:w=>mt({type:"tab.selected",tabId:w}),onCreateTab:()=>{jn()},onToggleWorkspaces:()=>Y(w=>!w),onCloseTerminals:w=>ms(w),onReattachTerminal:w=>gs(w),onDeleteTerminal:w=>{Ns(w)},onSplitVertical:()=>{en("vertical")},onSplitHorizontal:()=>{en("horizontal")},onRenameTab:(w,E)=>{Va(w,E)},activePaneAvailable:!!Lt}),ut?f.jsx(D6,{targets:rt,activeLeafKey:Et,terminals:S.terminals,editors:D,onSelect:Ya}):null,A?f.jsxs("div",{className:"workspace-error",role:"alert",children:[f.jsx("span",{children:A}),f.jsxs("div",{className:"workspace-error-actions",children:[f.jsx("button",{type:"button",onClick:_i,children:"Retry"}),n!==null&&r?f.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,f.jsxs("section",{className:"workspace-body","aria-busy":B,children:[B?f.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!B&&!St?f.jsx(k6,{onCreate:()=>{jn()}}):null,N.map(w=>{const E=pn(w,n);return f.jsx(p6,{agentId:w,serverName:M[z_(w)]??(w===null?"Local":"Server"),active:E,activeServerApi:E?p:void 0,visitedTabKeys:ue,refreshCwdOnEnter:E,draggingTab:E?je:null,mobileSplitFocus:Xe,mobileFocusedLeafByTabKey:Oe,onSelect:z=>{E&&$r(z)},onClose:z=>{E&&ir(z)},onCloseEditor:z=>{E&&zo(z)},onResize:(z,oe)=>{E&&mt({type:"pane.resized",path:z,ratio:oe})},onExit:(z,oe)=>{E?_s({type:"terminal.exited",terminalId:z,exitCode:oe}):Sl(w,{type:"terminal.exited",terminalId:z,exitCode:oe})},onSnapshot:(z,oe)=>{const Se={type:"terminal.updated",terminal:z,notifyCompletion:oe?.notifyCompletion===!0};E?_s(Se):Sl(w,Se)},...m?{onAuthClose:z=>m({...z,source:z?.source??"terminal-ws-1008",activeAgentId:w})}:{}},Zh(w))})]}),Ft?f.jsx(E6,{label:Ft.label,count:Ft.terminalIds.length,warning:X,onCancel:()=>{F(null),ci(null)},onHide:()=>{Wr(Ft.terminalIds,Ft.workspaceId)&&ci(null)},onDelete:()=>{const w=Ft.terminalIds;F(null),ci(null),bn(w)}}):null,f.jsx(t6,{toast:kt,onActivate:Xr,onDismiss:()=>Xt(null)}),f.jsx(Y4,{uploads:ee,onDismiss:Ls,onDismissAll:sr,onRetry:In,onCancel:Xa})]})]})})}function p6({agentId:e,serverName:t,active:n,activeServerApi:r,visitedTabKeys:o,refreshCwdOnEnter:c,draggingTab:u,mobileSplitFocus:m,mobileFocusedLeafByTabKey:g,onSelect:p,onClose:y,onCloseEditor:b,onResize:C,onExit:k,onSnapshot:S,onAuthClose:D}){const B=v.useMemo(()=>Ee=>NT(e,Ee),[e]),A=v.useMemo(()=>()=>It(e),[e]),H=v.useSyncExternalStore(B,A,A),Y=v.useMemo(()=>Bl(e),[e]),$=r??Y,se=H.state,J=se.workspaces.find(Ee=>Ee.id===se.activeWorkspaceId)??se.workspaces[0],W=J?.id??null,re=(J?.tabs.find(Ee=>Ee.id===J.activeTabId)??J?.tabs[0])?.id??null;return!H.loaded||se.workspaces.length===0?null:f.jsx("div",{className:"workspace-server-surface","data-active":n,"aria-hidden":!n,children:se.workspaces.flatMap(Ee=>Ee.tabs.map(ie=>{const V=n&&Ee.id===W&&ie.id===re,X=hu(e,Ee.id,ie.id),F=Cf(ie.root),le=m&&F.length>1?jT(F,ie.activeTerminalId,g[X]):null;return!V&&!o.has(X)?null:f.jsx("div",{className:"workspace-tab-surface","data-active":V,"aria-hidden":!V,children:f.jsx(y_,{node:ie.root,terminals:se.terminals,editors:H.editors,api:$,activeTerminalId:ie.activeTerminalId,visible:V,refreshCwdOnEnter:V&&c,tabId:ie.id,codeServerContext:{serverKey:z_(e),serverName:t,tabName:ie.title||se.terminals[ie.activeTerminalId]?.title||"Terminal"},dropZoneActive:V&&u!==null,draggingTerminalId:V?u?.terminalId??null:null,mobileFocusLeafKey:le,onSelect:p,onClose:y,onCloseEditor:b,onResize:C,onExit:k,onSnapshot:S,...D?{onAuthClose:D}:{}})},ie.id)}))})}function m6(e){const t=Sx(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=v6(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function g6(e,t,n){switch(n.type){case"pane.direction":return s6(e,t,n.direction);case"pane.index":return r6(e,n.index);default:return null}}function v6(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function _6(e,t,n){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+n+e.length)%e.length]??null}function Cf(e){return e.type==="pane"?[{key:xu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:IT(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Cf(e.first),...Cf(e.second)]}function I_(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...I_(e.first),...I_(e.second)]}function jT(e,t,n){if(n&&e.some(o=>o.key===n))return n;const r=t?xu(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function xu(e){return`terminal:${e}`}function IT(e){return`editor:${e}`}function b6(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 y6({dialog:e,activePaneCwd:t,activeWorkspaceCwd:n,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:u,onSubmit:m}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(k=>k.kind==="directory"),y=e.submitStatus==="submitting";function b(k){r(S=>S&&{...S,...k})}function C(k){k&&(b({cwd:k,error:null}),c(k))}return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:u,children:f.jsxs("form",{className:"security-panel workspace-dialog",onClick:k=>k.stopPropagation(),onSubmit:k=>{k.preventDefault(),y||m()},children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:u,children:"x"})]}),f.jsxs("section",{className:"workspace-dialog-body",children:[f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Name"}),f.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:k=>b({title:k.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),f.jsxs("label",{className:"workspace-dialog-field",children:[f.jsx("span",{children:"Default cwd"}),f.jsxs("div",{className:"workspace-dialog-path-row",children:[f.jsx("input",{value:e.cwd,disabled:y,onChange:k=>o(k.currentTarget.value),placeholder:"/home/user/project"}),f.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),f.jsxs("div",{className:"workspace-dialog-quick-actions",children:[f.jsx("button",{type:"button",onClick:()=>C(t),disabled:y||!t,children:"Use active pane"}),f.jsx("button",{type:"button",onClick:()=>C(n),disabled:y||!n,children:"Use current workspace"})]}),f.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[f.jsxs("div",{className:"workspace-dialog-browser-header",children:[f.jsx("span",{title:g,children:g||"No folder selected"}),f.jsx("button",{type:"button",onClick:()=>{c(w6(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?f.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?f.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?f.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(k=>f.jsxs("button",{type:"button","aria-label":`Choose folder ${k.name}`,disabled:y,onClick:()=>{c(S6(g,k.path))},children:[f.jsx("span",{children:k.name}),f.jsx("small",{children:k.path})]},k.path))}):null]}),e.error?f.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),f.jsxs("div",{className:"workspace-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:u,children:"Cancel"}),f.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function S6(e,t){return t?t.startsWith("/")?Gh(t):Gh(`${e||"/"}/${t}`):Gh(e)}function w6(e){const t=Gh(e);if(!t||t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function Gh(e){const t=e.trim();if(!t)return"";const n=t.replace(/\/+/g,"/");return n==="/"?"/":n.endsWith("/")?n.slice(0,-1):n}function C6(e){return e>99?"99+":String(e)}function x6(e){const t=[];return e.workingTerminalCount>0&&t.push(`${e.workingTerminalCount} ${e.workingTerminalCount===1?"pane is":"panes are"} working`),e.unreadCompletionCount>0&&t.push(`${e.unreadCompletionCount} unreviewed completion${e.unreadCompletionCount===1?"":"s"}`),t.join(" · ")}function k6({onCreate:e}){return f.jsxs("div",{className:"empty-workspace",children:[f.jsx("span",{children:"No terminal is open."}),f.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function T6({workspaceId:e,active:t,disabled:n=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,working:u=!1,unread:m=!1,children:g}){const{setNodeRef:p,isOver:y}=Q_({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:n}),b=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",u?"workspace-list-item--working":"",m?"workspace-list-item--unread":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return f.jsx("div",{ref:p,className:b,"data-workspace-id":e,"data-drop-over":y?"true":void 0,children:g})}function E6({label:e,count:t,warning:n,onCancel:r,onHide:o,onDelete:c}){return f.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:f.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:u=>u.stopPropagation(),children:[f.jsxs("header",{className:"security-panel-header",children:[f.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),f.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),f.jsxs("section",{className:"terminal-delete-dialog-body",children:[f.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),f.jsx("span",{children:e}),f.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),n?f.jsx("div",{className:"terminal-delete-warning",role:"alert",children:n}):null]}),f.jsxs("div",{className:"terminal-delete-dialog-actions",children:[f.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),f.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function D6({targets:e,activeLeafKey:t,terminals:n,editors:r,onSelect:o}){const[c,u]=v.useState(!1);if(e.length<=1)return null;const m=t?e.findIndex(C=>C.key===t):-1,g=m>=0?m:0,p=e[g]??e[0],y=pC(p,n,r);function b(C){const k=(g+C+e.length)%e.length,S=e[k];S&&o(S)}return f.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[f.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),f.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>u(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),f.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?f.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>u(!1),children:f.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:C=>C.stopPropagation(),children:[f.jsxs("header",{children:[f.jsx("strong",{children:"Panes"}),f.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>u(!1),children:"x"})]}),f.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((C,k)=>{const S=pC(C,n,r),D=R6(C,n,r),B=C.key===p.key;return f.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(C),u(!1)},children:[f.jsx("span",{className:"mobile-pane-sheet-index",children:k+1}),f.jsxs("span",{className:"mobile-pane-sheet-copy",children:[f.jsx("strong",{children:S}),f.jsx("small",{children:D})]}),f.jsx("span",{className:"mobile-pane-sheet-type",children:C.type})]},C.key)})})]})}):null]})}function pC(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function R6(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function M6(e){const[t,n]=v.useState(()=>N6(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const r=window.matchMedia(e),o=()=>n(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function N6(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function A6(){if(typeof window>"u")return null;const e=QD(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 L6(e){if(!e||typeof e!="object")return null;const t=e;return t.type!=="nterminal.notificationFocus"?null:Nf(t.focus)}function O6(e,t){for(const n of e.workspaces)for(const r of n.tabs)if(Li(r.root).includes(t))return{workspaceId:n.id,tabId:r.id};return null}function pn(e,t){return e===t}function B6(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function Zh(e){return e??"__local__"}function hu(e,t,n){return`${Zh(e)}:${t}:${n}`}class xf extends Error{constructor(){super(PT())}}function j6(e){return e?{workspaceKey:`${hC}:${e}`}:{workspaceKey:hC}}function I6(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t);if(qC(n))throw new xf;const r=$C(n);return r?zT(r):null}catch(n){if(n instanceof xf)throw n;return null}}function zT(e){if(qC(e))throw new xf;const t=$C(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function tu(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function z6(e,t){const n=It(e).lastPersistedLayoutJson;if(n){localStorage.setItem(t.workspaceKey,n);return}localStorage.removeItem(t.workspaceKey)}function P6(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Wl}. Re-open or delete hidden sessions before hiding more.`}function PT(){return`A saved terminal layout has more than ${Wl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function H6(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=n?e.terminals[n.activeTerminalId]:void 0;return r?.status==="running"?r:null}function U6(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function K6(e){return e.split("/").filter(Boolean).pop()??e}function F6(){try{return localStorage.getItem(BT)==="true"}catch{return!1}}function W6(e){try{localStorage.setItem(BT,e?"true":"false")}catch{}}function z_(e){return e??Yi}function $g(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>e[o]===t[o])}function $6(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const r=Math.max(1,Math.floor(n/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function mC({name:e}){return f.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M4 7h9"}),f.jsx("path",{d:"M17 7h3"}),f.jsx("circle",{cx:"15",cy:"7",r:"2"}),f.jsx("path",{d:"M4 12h3"}),f.jsx("path",{d:"M11 12h9"}),f.jsx("circle",{cx:"9",cy:"12",r:"2"}),f.jsx("path",{d:"M4 17h9"}),f.jsx("path",{d:"M17 17h3"}),f.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?f.jsxs(f.Fragment,{children:[f.jsx("path",{d:"M10 6H6v12h4"}),f.jsx("path",{d:"M13 8l4 4-4 4"}),f.jsx("path",{d:"M8 12h9"})]}):null]})}function Ta(e){return e instanceof Error?e.message:"Request failed"}function q6({api:e,onDone:t}){const[n,r]=v.useState(null),[o,c]=v.useState(null),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[C,k]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(B=>{D||(r(B.qrDataUrl),c(B.secret))}).catch(B=>{D||k(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function S(D){if(D.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:u}),t()}catch(B){b(B instanceof Error?B.message:"Verification failed")}finally{p(!1)}}}return C?f.jsx("p",{className:"form-error",children:C}):!n||!o?f.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):f.jsxs("div",{className:"totp-setup",children:[f.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),f.jsx("div",{className:"totp-qr-container",children:f.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),f.jsxs("details",{className:"totp-secret-details",children:[f.jsx("summary",{children:"Can't scan? Enter manually"}),f.jsx("p",{className:"totp-secret-text",children:o})]}),f.jsxs("form",{className:"auth-form",onSubmit:S,children:[f.jsxs("label",{children:["Verification code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:D=>m(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?f.jsx("p",{className:"form-error",children:y}):null,f.jsx("button",{type:"submit",disabled:g||u.length!==6,children:"Activate 2FA"})]})]})}function V6(e){return{source:qg(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:qg(e.terminalId)}:{},...e?.detail?{detail:qg(e.detail)}:{}}}function Y6(e){return{invalidationSource:e.source}}function X6(e){gn("auth.session_invalid.request",HT(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),eb("session-invalid-request").catch(()=>{}))}function G6(e,t){gn("auth.session_invalid.result",{...HT(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),eb("session-invalid-result").catch(()=>{}))}function HT(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 qg(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function Z6({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:r}){const o=v.useMemo(()=>e??kf(),[e]),c=v.useMemo(()=>t??Bl(null),[t]),[u,m]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(H=>{A||(m(H),p(null))}).catch(H=>{A||(p(xo(H)),m(null))}),()=>{A=!0}},[o]);const C=tj(u);v.useEffect(()=>{const A=b.current;gn("auth.view",{view:C,previousView:A,authenticated:u?.authenticated??null,passwordSet:u?.passwordSet??null,totpEnabled:u?.totpEnabled??null,deviceTrusted:u?.deviceTrusted??null,currentIpWhitelisted:u?.currentIpWhitelisted??null}),A==="workspace"&&C!=="workspace"&&eb(`auth-left-workspace-${C}`).catch(()=>{}),b.current=C},[u,C]);async function k(){const A=await o.getSession();m(A),p(null)}async function S(){Bg(),Wg(),N1(),A1(),p(null),m(null);try{await k()}catch(A){p(xo(A))}}function D(A){const H=V6(A);if(X6(H),y.current)return y.current;const Y=(async()=>{p(null);try{const $=await o.getSession(Y6(H));if(G6(H,$.authenticated),m($),$.authenticated){p5();return}Bg(),Wg(),N1(),A1()}catch($){p(xo($))}finally{y.current=null}})();return y.current=Y,Y}if(C==="workspace")return f.jsx(f6,{api:o,serverApi:c,activeAgentId:n,onSelectServer:r,sessionExpiresAt:u?.expiresAt??null,previewMode:u?.previewMode===!0,onSessionInvalid:A=>{D(A)},onLogout:async()=>{Bg(),Wg();const A=await o.logout();m(A)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return f.jsxs("main",{className:"auth-screen",children:[f.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[f.jsx("div",{className:"auth-grid"}),f.jsx("div",{className:"auth-glow"})]}),f.jsxs("section",{className:"auth-panel","aria-busy":C==="loading",children:[f.jsxs("header",{className:"auth-header",children:[f.jsxs("div",{className:"auth-brand",children:[f.jsx(CC,{size:26}),f.jsxs("div",{children:[f.jsx(xC,{height:17}),f.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),f.jsx("h1",{children:B[C]})]}),g?f.jsx("p",{className:"form-error",children:g}):null,C==="loading"?f.jsx("p",{className:"muted",children:"Checking session..."}):null,C==="loading"&&g?f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{S()},children:"Retry"}):null,C==="setup_password"?f.jsx(Q6,{api:o,onSession:A=>{m(A)}}):null,C==="setup_totp"?f.jsx(q6,{api:o,onDone:()=>{k()}}):null,C==="login"?f.jsx(J6,{api:o,session:u,onSession:m,onRefresh:k}):null,C==="reauth"?f.jsx(ej,{api:o,session:u,onSession:m,onFullLogin:()=>m(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function Q6({api:e,onSession:t}){const[n,r]=v.useState(""),[o,c]=v.useState(""),[u,m]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),m(!0),p(null);try{if(n!==o){p("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(C){p(xo(C))}finally{m(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:y,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,value:n,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),f.jsxs("label",{children:["Confirm password",f.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?f.jsx("p",{className:"form-error",children:g}):null,f.jsx("button",{type:"submit",disabled:u||n.length<8||o.length<8,children:"Set password"})]})}function J6({api:e,session:t,onSession:n,onRefresh:r}){const[o,c]=v.useState(""),[u,m]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[C,k]=v.useState(null),S=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function B(A){A.preventDefault(),b(!0),k(null);try{n(await e.login({password:o,...S?{otp:u}:{},rememberNetwork:g}))}catch(H){k(xo(H))}finally{b(!1)}}return f.jsxs("form",{className:"auth-form",onSubmit:B,children:[f.jsxs("label",{children:["Password",f.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),S?f.jsxs("label",{children:["Authenticator code",f.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:u,onChange:A=>m(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:g,onChange:A=>p(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),C?f.jsx("p",{className:"form-error",children:C}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:y||o.length===0||S&&u.length!==6,children:"Unlock"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function ej({api:e,session:t,onSession:n,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,u]=v.useState(""),[m,g]=v.useState(!1),[p,y]=v.useState(!1),[b,C]=v.useState(!1),[k,S]=v.useState(!1),[D,B]=v.useState(null),A=Ni.useCallback(async(Y,$)=>{y(!0),B(null);try{n(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:$}))}catch(se){B(xo(se))}finally{y(!1)}},[e,n]);v.useEffect(()=>{if(o){let Y=!1;C(!0),S(!1),B(null);const $=window.setTimeout(()=>{Y||S(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(se=>{Y||n(se)}).catch(se=>{Y||(B(xo(se)),S(!0))}).finally(()=>{window.clearTimeout($),Y||C(!1)}),()=>{Y=!0,window.clearTimeout($)}}},[e,o,n]);async function H(Y){Y.preventDefault(),await A(c,m)}return o&&b&&!k&&!D?f.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):f.jsxs("form",{className:"auth-form",onSubmit:H,children:[o&&k&&!D?f.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,f.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),f.jsxs("label",{children:["Authenticator code",f.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>u(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),f.jsxs("label",{className:"auth-checkbox",children:[f.jsx("input",{type:"checkbox",checked:m,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?f.jsx("p",{className:"form-error",children:D}):null,f.jsxs("div",{className:"button-row",children:[f.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),f.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function tj(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function xo(e){return e instanceof Error?e.message:"Request failed"}const gC="NTerminal",P_="nterminal.activeAgentId";function ij(){const[e,t]=v.useState(()=>nj()),n=v.useMemo(()=>kf(),[]),r=v.useMemo(()=>Bl(e),[e]);v.useEffect(()=>{const c=()=>{const u=I4();document.title=u>0?`(${u}) ${gC}`:gC};return c(),j4(c)},[]);function o(c){sj(c),t(c)}return f.jsx(Z6,{api:n,activeAgentId:e,serverApi:r,onSelectServer:o})}function nj(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(P_);return e&&e.trim()?e:null}catch{return null}}function sj(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(P_,e);return}window.localStorage.removeItem(P_)}catch{}}const vC=["gesturestart","gesturechange","gestureend"],rj=[".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 aj(e=window){if(!lj(e))return()=>{};const t={passive:!1},n=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const u=c.touches;!u||u.length===0||(u.length>1||!oj(c.target))&&r(c)}for(const c of vC)n.addEventListener(c,r,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",r,t),()=>{for(const c of vC)n.removeEventListener(c,r,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",r,t)}}function oj(e){return e instanceof Element&&e.closest(rj)!==null}function lj(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}sR();H3();aj();W_();f2.createRoot(document.getElementById("root")).render(f.jsx(Ni.StrictMode,{children:f.jsx(ij,{})}));export{Ni as R,s2 as g,f as j};
|