nterminal 1.2.67 → 1.2.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/MarkdownPreview-DCHLz_jq.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-BHQbyM6J.js → TranscriptMarkdownBody-BaMp6W3l.js} +1 -1
- package/dist/client/assets/index-CDfP5jMv.js +55 -0
- package/dist/client/assets/{index-BXCYmdDY.js → index-CLUAqRpO.js} +1 -1
- package/dist/client/assets/index-CszWmeOA.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +51 -0
- package/dist/server/auth/authService.d.ts +1 -0
- package/dist/server/auth/authService.js +9 -3
- package/dist/server/auth/authService.js.map +1 -1
- package/dist/server/http.d.ts +2 -1
- package/dist/server/http.js +5 -0
- package/dist/server/http.js.map +1 -1
- package/dist/server/index.js +30 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/notifications/agentCompletionMonitor.d.ts +27 -0
- package/dist/server/notifications/agentCompletionMonitor.js +148 -0
- package/dist/server/notifications/agentCompletionMonitor.js.map +1 -0
- package/dist/server/notifications/clientPresence.d.ts +40 -0
- package/dist/server/notifications/clientPresence.js +75 -0
- package/dist/server/notifications/clientPresence.js.map +1 -0
- package/dist/server/notifications/completionNotificationRouter.d.ts +28 -0
- package/dist/server/notifications/completionNotificationRouter.js +100 -0
- package/dist/server/notifications/completionNotificationRouter.js.map +1 -0
- package/dist/server/notifications/pushNotificationService.d.ts +80 -0
- package/dist/server/notifications/pushNotificationService.js +300 -0
- package/dist/server/notifications/pushNotificationService.js.map +1 -0
- package/dist/server/routes/pushNotificationRoutes.d.ts +11 -0
- package/dist/server/routes/pushNotificationRoutes.js +138 -0
- package/dist/server/routes/pushNotificationRoutes.js.map +1 -0
- package/dist/server/routes/terminalRoutes.d.ts +1 -0
- package/dist/server/routes/terminalRoutes.js +4 -1
- package/dist/server/routes/terminalRoutes.js.map +1 -1
- package/dist/server/storage/fileStore.d.ts +25 -1
- package/dist/server/storage/fileStore.js +65 -0
- package/dist/server/storage/fileStore.js.map +1 -1
- package/dist/server/terminal/TerminalManager.d.ts +14 -0
- package/dist/server/terminal/TerminalManager.js +104 -3
- package/dist/server/terminal/TerminalManager.js.map +1 -1
- package/dist/server/terminal/agentTranscriptStatus.d.ts +11 -0
- package/dist/server/terminal/agentTranscriptStatus.js +187 -0
- package/dist/server/terminal/agentTranscriptStatus.js.map +1 -0
- package/dist/shared/protocol.d.ts +67 -0
- package/dist/shared/protocol.js.map +1 -1
- package/dist/shared/types.d.ts +4 -0
- package/package.json +3 -1
- package/public/sw.js +51 -0
- package/dist/client/assets/MarkdownPreview-BDn9o2c8.js +0 -1
- package/dist/client/assets/index-BgvJmNhz.js +0 -55
- package/dist/client/assets/index-Br4cNNw1.css +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-DCHLz_jq.js","assets/index-CLUAqRpO.js","assets/TranscriptMarkdownBody-BaMp6W3l.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();function Dk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qf={exports:{}},Oo={};var Oy;function Rk(){if(Oy)return Oo;Oy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,l,c){var h=null;if(c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),"key"in l){c={};for(var p in l)p!=="key"&&(c[p]=l[p])}else c=l;return l=c.ref,{$$typeof:e,type:s,key:h,ref:l!==void 0?l:null,props:c}}return Oo.Fragment=t,Oo.jsx=r,Oo.jsxs=r,Oo}var zy;function Mk(){return zy||(zy=1,Qf.exports=Rk()),Qf.exports}var m=Mk(),Jf={exports:{}},Qe={};var jy;function Nk(){if(jy)return Qe;jy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),S=Symbol.iterator;function w(M){return M===null||typeof M!="object"?null:(M=S&&M[S]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,L={};function A(M,Q,de){this.props=M,this.context=Q,this.refs=L,this.updater=de||x}A.prototype.isReactComponent={},A.prototype.setState=function(M,Q){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,Q,"setState")},A.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function B(){}B.prototype=A.prototype;function Y(M,Q,de){this.props=M,this.context=Q,this.refs=L,this.updater=de||x}var P=Y.prototype=new B;P.constructor=Y,D(P,A.prototype),P.isPureReactComponent=!0;var q=Array.isArray;function re(){}var ne={H:null,A:null,T:null,S:null},he=Object.prototype.hasOwnProperty;function ve(M,Q,de){var me=de.ref;return{$$typeof:e,type:M,key:Q,ref:me!==void 0?me:null,props:de}}function U(M,Q){return ve(M.type,Q,M.props)}function K(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function W(M){var Q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(de){return Q[de]})}var H=/\/+/g;function j(M,Q){return typeof M=="object"&&M!==null&&M.key!=null?W(""+M.key):Q.toString(36)}function ae(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(re,re):(M.status="pending",M.then(function(Q){M.status==="pending"&&(M.status="fulfilled",M.value=Q)},function(Q){M.status==="pending"&&(M.status="rejected",M.reason=Q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function R(M,Q,de,me,ge){var Se=typeof M;(Se==="undefined"||Se==="boolean")&&(M=null);var Ee=!1;if(M===null)Ee=!0;else switch(Se){case"bigint":case"string":case"number":Ee=!0;break;case"object":switch(M.$$typeof){case e:case t:Ee=!0;break;case y:return Ee=M._init,R(Ee(M._payload),Q,de,me,ge)}}if(Ee)return ge=ge(M),Ee=me===""?"."+j(M,0):me,q(ge)?(de="",Ee!=null&&(de=Ee.replace(H,"$&/")+"/"),R(ge,Q,de,"",function(se){return se})):ge!=null&&(K(ge)&&(ge=U(ge,de+(ge.key==null||M&&M.key===ge.key?"":(""+ge.key).replace(H,"$&/")+"/")+Ee)),Q.push(ge)),1;Ee=0;var De=me===""?".":me+":";if(q(M))for(var Ke=0;Ke<M.length;Ke++)me=M[Ke],Se=De+j(me,Ke),Ee+=R(me,Q,de,Se,ge);else if(Ke=w(M),typeof Ke=="function")for(M=Ke.call(M),Ke=0;!(me=M.next()).done;)me=me.value,Se=De+j(me,Ke++),Ee+=R(me,Q,de,Se,ge);else if(Se==="object"){if(typeof M.then=="function")return R(ae(M),Q,de,me,ge);throw Q=String(M),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.")}return Ee}function X(M,Q,de){if(M==null)return M;var me=[],ge=0;return R(M,me,"","",function(Se){return Q.call(de,Se,ge++)}),me}function Z(M){if(M._status===-1){var Q=M._result;Q=Q(),Q.then(function(de){(M._status===0||M._status===-1)&&(M._status=1,M._result=de)},function(de){(M._status===0||M._status===-1)&&(M._status=2,M._result=de)}),M._status===-1&&(M._status=0,M._result=Q)}if(M._status===1)return M._result.default;throw M._result}var Ce=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},Te={map:X,forEach:function(M,Q,de){X(M,function(){Q.apply(this,arguments)},de)},count:function(M){var Q=0;return X(M,function(){Q++}),Q},toArray:function(M){return X(M,function(Q){return Q})||[]},only:function(M){if(!K(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Qe.Activity=b,Qe.Children=Te,Qe.Component=A,Qe.Fragment=r,Qe.Profiler=l,Qe.PureComponent=Y,Qe.StrictMode=s,Qe.Suspense=g,Qe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ne,Qe.__COMPILER_RUNTIME={__proto__:null,c:function(M){return ne.H.useMemoCache(M)}},Qe.cache=function(M){return function(){return M.apply(null,arguments)}},Qe.cacheSignal=function(){return null},Qe.cloneElement=function(M,Q,de){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var me=D({},M.props),ge=M.key;if(Q!=null)for(Se in Q.key!==void 0&&(ge=""+Q.key),Q)!he.call(Q,Se)||Se==="key"||Se==="__self"||Se==="__source"||Se==="ref"&&Q.ref===void 0||(me[Se]=Q[Se]);var Se=arguments.length-2;if(Se===1)me.children=de;else if(1<Se){for(var Ee=Array(Se),De=0;De<Se;De++)Ee[De]=arguments[De+2];me.children=Ee}return ve(M.type,ge,me)},Qe.createContext=function(M){return M={$$typeof:h,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Qe.createElement=function(M,Q,de){var me,ge={},Se=null;if(Q!=null)for(me in Q.key!==void 0&&(Se=""+Q.key),Q)he.call(Q,me)&&me!=="key"&&me!=="__self"&&me!=="__source"&&(ge[me]=Q[me]);var Ee=arguments.length-2;if(Ee===1)ge.children=de;else if(1<Ee){for(var De=Array(Ee),Ke=0;Ke<Ee;Ke++)De[Ke]=arguments[Ke+2];ge.children=De}if(M&&M.defaultProps)for(me in Ee=M.defaultProps,Ee)ge[me]===void 0&&(ge[me]=Ee[me]);return ve(M,Se,ge)},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function(M){return{$$typeof:p,render:M}},Qe.isValidElement=K,Qe.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:Z}},Qe.memo=function(M,Q){return{$$typeof:f,type:M,compare:Q===void 0?null:Q}},Qe.startTransition=function(M){var Q=ne.T,de={};ne.T=de;try{var me=M(),ge=ne.S;ge!==null&&ge(de,me),typeof me=="object"&&me!==null&&typeof me.then=="function"&&me.then(re,Ce)}catch(Se){Ce(Se)}finally{Q!==null&&de.types!==null&&(Q.types=de.types),ne.T=Q}},Qe.unstable_useCacheRefresh=function(){return ne.H.useCacheRefresh()},Qe.use=function(M){return ne.H.use(M)},Qe.useActionState=function(M,Q,de){return ne.H.useActionState(M,Q,de)},Qe.useCallback=function(M,Q){return ne.H.useCallback(M,Q)},Qe.useContext=function(M){return ne.H.useContext(M)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function(M,Q){return ne.H.useDeferredValue(M,Q)},Qe.useEffect=function(M,Q){return ne.H.useEffect(M,Q)},Qe.useEffectEvent=function(M){return ne.H.useEffectEvent(M)},Qe.useId=function(){return ne.H.useId()},Qe.useImperativeHandle=function(M,Q,de){return ne.H.useImperativeHandle(M,Q,de)},Qe.useInsertionEffect=function(M,Q){return ne.H.useInsertionEffect(M,Q)},Qe.useLayoutEffect=function(M,Q){return ne.H.useLayoutEffect(M,Q)},Qe.useMemo=function(M,Q){return ne.H.useMemo(M,Q)},Qe.useOptimistic=function(M,Q){return ne.H.useOptimistic(M,Q)},Qe.useReducer=function(M,Q,de){return ne.H.useReducer(M,Q,de)},Qe.useRef=function(M){return ne.H.useRef(M)},Qe.useState=function(M){return ne.H.useState(M)},Qe.useSyncExternalStore=function(M,Q,de){return ne.H.useSyncExternalStore(M,Q,de)},Qe.useTransition=function(){return ne.H.useTransition()},Qe.version="19.2.6",Qe}var Py;function dg(){return Py||(Py=1,Jf.exports=Nk()),Jf.exports}var v=dg();const Mi=Dk(v);var ep={exports:{}},zo={},tp={exports:{}},ip={};var Hy;function Ak(){return Hy||(Hy=1,(function(e){function t(R,X){var Z=R.length;R.push(X);e:for(;0<Z;){var Ce=Z-1>>>1,Te=R[Ce];if(0<l(Te,X))R[Ce]=X,R[Z]=Te,Z=Ce;else break e}}function r(R){return R.length===0?null:R[0]}function s(R){if(R.length===0)return null;var X=R[0],Z=R.pop();if(Z!==X){R[0]=Z;e:for(var Ce=0,Te=R.length,M=Te>>>1;Ce<M;){var Q=2*(Ce+1)-1,de=R[Q],me=Q+1,ge=R[me];if(0>l(de,Z))me<Te&&0>l(ge,de)?(R[Ce]=ge,R[me]=Z,Ce=me):(R[Ce]=de,R[Q]=Z,Ce=Q);else if(me<Te&&0>l(ge,Z))R[Ce]=ge,R[me]=Z,Ce=me;else break e}}return X}function l(R,X){var Z=R.sortIndex-X.sortIndex;return Z!==0?Z:R.id-X.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var h=Date,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],y=1,b=null,S=3,w=!1,x=!1,D=!1,L=!1,A=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function P(R){for(var X=r(f);X!==null;){if(X.callback===null)s(f);else if(X.startTime<=R)s(f),X.sortIndex=X.expirationTime,t(g,X);else break;X=r(f)}}function q(R){if(D=!1,P(R),!x)if(r(g)!==null)x=!0,re||(re=!0,W());else{var X=r(f);X!==null&&ae(q,X.startTime-R)}}var re=!1,ne=-1,he=5,ve=-1;function U(){return L?!0:!(e.unstable_now()-ve<he)}function K(){if(L=!1,re){var R=e.unstable_now();ve=R;var X=!0;try{e:{x=!1,D&&(D=!1,B(ne),ne=-1),w=!0;var Z=S;try{t:{for(P(R),b=r(g);b!==null&&!(b.expirationTime>R&&U());){var Ce=b.callback;if(typeof Ce=="function"){b.callback=null,S=b.priorityLevel;var Te=Ce(b.expirationTime<=R);if(R=e.unstable_now(),typeof Te=="function"){b.callback=Te,P(R),X=!0;break t}b===r(g)&&s(g),P(R)}else s(g);b=r(g)}if(b!==null)X=!0;else{var M=r(f);M!==null&&ae(q,M.startTime-R),X=!1}}break e}finally{b=null,S=Z,w=!1}X=void 0}}finally{X?W():re=!1}}}var W;if(typeof Y=="function")W=function(){Y(K)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=K,W=function(){j.postMessage(null)}}else W=function(){A(K,0)};function ae(R,X){ne=A(function(){R(e.unstable_now())},X)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(R){R.callback=null},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):he=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(R){switch(S){case 1:case 2:case 3:var X=3;break;default:X=S}var Z=S;S=X;try{return R()}finally{S=Z}},e.unstable_requestPaint=function(){L=!0},e.unstable_runWithPriority=function(R,X){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var Z=S;S=R;try{return X()}finally{S=Z}},e.unstable_scheduleCallback=function(R,X,Z){var Ce=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?Ce+Z:Ce):Z=Ce,R){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=Z+Te,R={id:y++,callback:X,priorityLevel:R,startTime:Z,expirationTime:Te,sortIndex:-1},Z>Ce?(R.sortIndex=Z,t(f,R),r(g)===null&&R===r(f)&&(D?(B(ne),ne=-1):D=!0,ae(q,Z-Ce))):(R.sortIndex=Te,t(g,R),x||w||(x=!0,re||(re=!0,W()))),R},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(R){var X=S;return function(){var Z=S;S=X;try{return R.apply(this,arguments)}finally{S=Z}}}})(ip)),ip}var Iy;function Lk(){return Iy||(Iy=1,tp.exports=Ak()),tp.exports}var np={exports:{}},rn={};var Uy;function Bk(){if(Uy)return rn;Uy=1;var e=dg();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var s={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(g,f,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:b==null?null:""+b,children:g,containerInfo:f,implementation:y}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,rn.createPortal=function(g,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,y)},rn.flushSync=function(g){var f=h.T,y=s.p;try{if(h.T=null,s.p=2,g)return g()}finally{h.T=f,s.p=y,s.d.f()}},rn.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(g,f))},rn.prefetchDNS=function(g){typeof g=="string"&&s.d.D(g)},rn.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var y=f.as,b=p(y,f.crossOrigin),S=typeof f.integrity=="string"?f.integrity:void 0,w=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;y==="style"?s.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:b,integrity:S,fetchPriority:w}):y==="script"&&s.d.X(g,{crossOrigin:b,integrity:S,fetchPriority:w,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},rn.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var y=p(f.as,f.crossOrigin);s.d.M(g,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(g)},rn.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var y=f.as,b=p(y,f.crossOrigin);s.d.L(g,y,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},rn.preloadModule=function(g,f){if(typeof g=="string")if(f){var y=p(f.as,f.crossOrigin);s.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(g)},rn.requestFormReset=function(g){s.d.r(g)},rn.unstable_batchedUpdates=function(g,f){return g(f)},rn.useFormState=function(g,f,y){return h.H.useFormState(g,f,y)},rn.useFormStatus=function(){return h.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var Ky;function X0(){if(Ky)return np.exports;Ky=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),np.exports=Bk(),np.exports}var Wy;function Ok(){if(Wy)return zo;Wy=1;var e=Lk(),t=dg(),r=X0();function s(i){var n="https://react.dev/errors/"+i;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var n=i,a=i;if(i.alternate)for(;n.return;)n=n.return;else{i=n;do n=i,(n.flags&4098)!==0&&(a=n.return),i=n.return;while(i)}return n.tag===3?a:null}function h(i){if(i.tag===13){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function p(i){if(i.tag===31){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(s(188))}function f(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(s(188));return n!==i?null:i}for(var a=i,o=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(o=u.return,o!==null){a=o;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===o)return g(u),n;d=d.sibling}throw Error(s(188))}if(a.return!==o.return)a=u,o=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,o=d;break}if(C===o){_=!0,o=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,o=u;break}if(C===o){_=!0,o=d,a=u;break}C=C.sibling}if(!_)throw Error(s(189))}}if(a.alternate!==o)throw Error(s(190))}if(a.tag!==3)throw Error(s(188));return a.stateNode.current===a?i:n}function y(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=y(i),n!==null)return n;i=i.sibling}return null}var b=Object.assign,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),he=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function W(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===H?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case D:return"Fragment";case A:return"Profiler";case L:return"StrictMode";case q:return"Suspense";case re:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case Y:return i.displayName||"Context";case B:return(i._context.displayName||"Context")+".Consumer";case P:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ne:return n=i.displayName||null,n!==null?n:j(i.type)||"Memo";case he:n=i._payload,i=i._init;try{return j(i(n))}catch{}}return null}var ae=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},Ce=[],Te=-1;function M(i){return{current:i}}function Q(i){0>Te||(i.current=Ce[Te],Ce[Te]=null,Te--)}function de(i,n){Te++,Ce[Te]=i.current,i.current=n}var me=M(null),ge=M(null),Se=M(null),Ee=M(null);function De(i,n){switch(de(Se,n),de(ge,i),de(me,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?ry(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=ry(n),i=sy(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}Q(me),de(me,i)}function Ke(){Q(me),Q(ge),Q(Se)}function se(i){i.memoizedState!==null&&de(Ee,i);var n=me.current,a=sy(n,i.type);n!==a&&(de(ge,i),de(me,a))}function pe(i){ge.current===i&&(Q(me),Q(ge)),Ee.current===i&&(Q(Ee),No._currentValue=Z)}var Le,be;function Me(i){if(Le===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Le=n&&n[1]||"",be=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Le+i+be}var Pe=!1;function ze(i,n){if(!i||Pe)return"";Pe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(ee){var G=ee}Reflect.construct(i,[],ue)}else{try{ue.call()}catch(ee){G=ee}i.call(ue.prototype)}}else{try{throw Error()}catch(ee){G=ee}(ue=i())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(ee){if(ee&&G&&typeof ee.stack=="string")return[ee.stack,G.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=o.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var N=_.split(`
|
|
5
|
+
`),V=C.split(`
|
|
6
|
+
`);for(u=o=0;o<N.length&&!N[o].includes("DetermineComponentFrameRoot");)o++;for(;u<V.length&&!V[u].includes("DetermineComponentFrameRoot");)u++;if(o===N.length||u===V.length)for(o=N.length-1,u=V.length-1;1<=o&&0<=u&&N[o]!==V[u];)u--;for(;1<=o&&0<=u;o--,u--)if(N[o]!==V[u]){if(o!==1||u!==1)do if(o--,u--,0>u||N[o]!==V[u]){var le=`
|
|
7
|
+
`+N[o].replace(" at new "," at ");return i.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",i.displayName)),le}while(1<=o&&0<=u);break}}}finally{Pe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?Me(a):""}function ie(i,n){switch(i.tag){case 26:case 27:case 5:return Me(i.type);case 16:return Me("Lazy");case 13:return i.child!==n&&n!==null?Me("Suspense Fallback"):Me("Suspense");case 19:return Me("SuspenseList");case 0:case 15:return ze(i.type,!1);case 11:return ze(i.type.render,!1);case 1:return ze(i.type,!0);case 31:return Me("Activity");default:return""}}function ke(i){try{var n="",a=null;do n+=ie(i,a),a=i,i=i.return;while(i);return n}catch(o){return`
|
|
8
|
+
Error generating stack: `+o.message+`
|
|
9
|
+
`+o.stack}}var Re=Object.prototype.hasOwnProperty,Be=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,at=e.unstable_shouldYield,Xt=e.unstable_requestPaint,Ve=e.unstable_now,xt=e.unstable_getCurrentPriorityLevel,ti=e.unstable_ImmediatePriority,kt=e.unstable_UserBlockingPriority,_e=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,Je=e.unstable_IdlePriority,ct=e.log,Pt=e.unstable_setDisableYieldValue,bt=null,Nt=null;function Ft(i){if(typeof ct=="function"&&Pt(i),Nt&&typeof Nt.setStrictMode=="function")try{Nt.setStrictMode(bt,i)}catch{}}var F=Math.clz32?Math.clz32:Si,Ue=Math.log,st=Math.LN2;function Si(i){return i>>>=0,i===0?32:31-(Ue(i)/st|0)|0}var wi=256,Ai=262144,St=4194304;function At(i){var n=i&42;if(n!==0)return n;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function qt(i,n,a){var o=i.pendingLanes;if(o===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=o&134217727;return C!==0?(o=C&~d,o!==0?u=At(o):(_&=C,_!==0?u=At(_):a||(a=C&~i,a!==0&&(u=At(a))))):(C=o&~d,C!==0?u=At(C):_!==0?u=At(_):a||(a=o&~i,a!==0&&(u=At(a)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,a=n&-n,d>=a||d===32&&(a&4194048)!==0)?n:u}function Gt(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function Ci(i,n){switch(i){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 li(){var i=St;return St<<=1,(St&62914560)===0&&(St=4194304),i}function zt(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function Wi(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ht(i,n,a,o,u,d){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var C=i.entanglements,N=i.expirationTimes,V=i.hiddenUpdates;for(a=_&~a;0<a;){var le=31-F(a),ue=1<<le;C[le]=0,N[le]=-1;var G=V[le];if(G!==null)for(V[le]=null,le=0;le<G.length;le++){var ee=G[le];ee!==null&&(ee.lane&=-536870913)}a&=~ue}o!==0&&Et(i,o,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function Et(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var o=31-F(n);i.entangledLanes|=n,i.entanglements[o]=i.entanglements[o]|1073741824|a&261930}function Zt(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var o=31-F(a),u=1<<o;u&n|i[o]&n&&(i[o]|=n),a&=~u}}function oi(i,n){var a=n&-n;return a=(a&42)!==0?1:Qi(a),(a&(i.suspendedLanes|n))!==0?0:a}function Qi(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 wn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Li(){var i=X.p;return i!==0?i:(i=window.event,i===void 0?32:Dy(i.type))}function Cn(i,n){var a=X.p;try{return X.p=i,n()}finally{X.p=a}}var Fi=Math.random().toString(36).slice(2),$t="__reactFiber$"+Fi,Bi="__reactProps$"+Fi,ci="__reactContainer$"+Fi,Rr="__reactEvents$"+Fi,Ha="__reactListeners$"+Fi,Yl="__reactHandles$"+Fi,ts="__reactResources$"+Fi,Jn="__reactMarker$"+Fi;function $s(i){delete i[$t],delete i[Bi],delete i[Rr],delete i[Ha],delete i[Yl]}function er(i){var n=i[$t];if(n)return n;for(var a=i.parentNode;a;){if(n=a[ci]||a[$t]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=dy(i);i!==null;){if(a=i[$t])return a;i=dy(i)}return n}i=a,a=i.parentNode}return null}function tr(i){if(i=i[$t]||i[ci]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function jn(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(s(33))}function ir(i){var n=i[ts];return n||(n=i[ts]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function It(i){i[Jn]=!0}var Ia=new Set,Ua={};function nr(i,n){Pn(i,n),Pn(i+"Capture",n)}function Pn(i,n){for(Ua[i]=n,i=0;i<n.length;i++)Ia.add(n[i])}var Ka=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]*$"),Wa={},Fa={};function Xl(i){return Re.call(Fa,i)?!0:Re.call(Wa,i)?!1:Ka.test(i)?Fa[i]=!0:(Wa[i]=!0,!1)}function fr(i,n,a){if(Xl(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function is(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function an(i,n,a,o){if(o===null)i.removeAttribute(a);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+o)}}function xi(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Ji(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function ns(i,n,a){var o=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,d=o.set;return Object.defineProperty(i,n,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,n,{enumerable:o.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function $e(i){if(!i._valueTracker){var n=Ji(i)?"checked":"value";i._valueTracker=ns(i,n,""+i[n])}}function Mr(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),o="";return i&&(o=Ji(i)?i.checked?"true":"false":i.value),i=o,i!==a?(n.setValue(i),!0):!1}function pr(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 mr=/[\n"\\]/g;function gt(i){return i.replace(mr,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Vs(i,n,a,o,u,d,_,C){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),n!=null?_==="number"?(n===0&&i.value===""||i.value!=n)&&(i.value=""+xi(n)):i.value!==""+xi(n)&&(i.value=""+xi(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?Nr(i,_,xi(n)):a!=null?Nr(i,_,xi(a)):o!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+xi(C):i.removeAttribute("name")}function Ys(i,n,a,o,u,d,_,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),n!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){$e(i);return}a=a!=null?""+xi(a):"",n=n!=null?""+xi(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,i.checked=C?i.checked:!!o,i.defaultChecked=!!o,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),$e(i)}function Nr(i,n,a){n==="number"&&pr(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function rr(i,n,a,o){if(i=i.options,n){n={};for(var u=0;u<a.length;u++)n["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=n.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&o&&(i[a].defaultSelected=!0)}else{for(a=""+xi(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,o&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function qa(i,n,a){if(n!=null&&(n=""+xi(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+xi(a):""}function Xs(i,n,a,o){if(n==null){if(o!=null){if(a!=null)throw Error(s(92));if(ae(o)){if(1<o.length)throw Error(s(93));o=o[0]}a=o}a==null&&(a=""),n=a}a=xi(n),i.defaultValue=a,o=i.textContent,o===a&&o!==""&&o!==null&&(i.value=o),$e(i)}function en(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Gs=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 $a(i,n,a){var o=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?o?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":o?i.setProperty(n,a):typeof a!="number"||a===0||Gs.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Zs(i,n,a){if(n!=null&&typeof n!="object")throw Error(s(62));if(i=i.style,a!=null){for(var o in a)!a.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="");for(var u in n)o=n[u],n.hasOwnProperty(u)&&a[u]!==o&&$a(i,u,o)}else for(var d in n)n.hasOwnProperty(d)&&$a(i,d,n[d])}function gr(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 Qs=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"]]),dn=/^[\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 xn(i){return dn.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function qi(){}var Js=null;function rs(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var _r=null,sr=null;function Va(i){var n=tr(i);if(n&&(i=n.stateNode)){var a=i[Bi]||null;e:switch(i=n.stateNode,n.type){case"input":if(Vs(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+gt(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var o=a[n];if(o!==i&&o.form===i.form){var u=o[Bi]||null;if(!u)throw Error(s(90));Vs(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)o=a[n],o.form===i.form&&Mr(o)}break e;case"textarea":qa(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&rr(i,!!a.multiple,n,!1)}}}var ea=!1;function Ya(i,n,a){if(ea)return i(n,a);ea=!0;try{var o=i(n);return o}finally{if(ea=!1,(_r!==null||sr!==null)&&(vu(),_r&&(n=_r,i=sr,sr=_r=null,Va(n),i)))for(n=0;n<i.length;n++)Va(i[n])}}function fn(i,n){var a=i.stateNode;if(a===null)return null;var o=a[Bi]||null;if(o===null)return null;a=o[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(i=i.type,o=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!o;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(s(231,n,typeof a));return a}var tn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ss=!1;if(tn)try{var $i={};Object.defineProperty($i,"passive",{get:function(){ss=!0}}),window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{ss=!1}var ln=null,as=null,k=null;function E(){if(k)return k;var i,n=as,a=n.length,o,u="value"in ln?ln.value:ln.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(o=1;o<=_&&n[a-o]===u[d-o];o++);return k=u.slice(i,1<o?1-o:void 0)}function z(i){var n=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&n===13&&(i=13)):i=n,i===10&&(i=13),32<=i||i===13?i:0}function te(){return!0}function ye(){return!1}function oe(i){function n(a,o,u,d,_){this._reactName=a,this._targetInst=u,this.type=o,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(a=i[C],this[C]=a?a(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?te:ye,this.isPropagationStopped=ye,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=te)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=te)},persist:function(){},isPersistent:te}),n}var we={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},He=oe(we),it=b({},we,{view:0,detail:0}),fi=oe(it),jt,ls,T,J=b({},it,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:id,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!==T&&(T&&i.type==="mousemove"?(jt=i.screenX-T.screenX,ls=i.screenY-T.screenY):ls=jt=0,T=i),jt)},movementY:function(i){return"movementY"in i?i.movementY:ls}}),We=oe(J),Xe=b({},J,{dataTransfer:0}),Ze=oe(Xe),dt=b({},it,{relatedTarget:0}),ii=oe(dt),nn=b({},we,{animationName:0,elapsedTime:0,pseudoElement:0}),Qt=oe(nn),ki=b({},we,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),ta=oe(ki),kn=b({},we,{data:0}),Gl=oe(kn),td={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},vr={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"},Oc={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zc(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=Oc[i])?!!n[i]:!1}function id(){return zc}var HC=b({},it,{key:function(i){if(i.key){var n=td[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=z(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?vr[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:id,charCode:function(i){return i.type==="keypress"?z(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?z(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),IC=oe(HC),UC=b({},J,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),c_=oe(UC),KC=b({},it,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:id}),WC=oe(KC),FC=b({},we,{propertyName:0,elapsedTime:0,pseudoElement:0}),qC=oe(FC),$C=b({},J,{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}),VC=oe($C),YC=b({},we,{newState:0,oldState:0}),XC=oe(YC),GC=[9,13,27,32],nd=tn&&"CompositionEvent"in window,Zl=null;tn&&"documentMode"in document&&(Zl=document.documentMode);var ZC=tn&&"TextEvent"in window&&!Zl,u_=tn&&(!nd||Zl&&8<Zl&&11>=Zl),h_=" ",d_=!1;function f_(i,n){switch(i){case"keyup":return GC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function p_(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Xa=!1;function QC(i,n){switch(i){case"compositionend":return p_(n);case"keypress":return n.which!==32?null:(d_=!0,h_);case"textInput":return i=n.data,i===h_&&d_?null:i;default:return null}}function JC(i,n){if(Xa)return i==="compositionend"||!nd&&f_(i,n)?(i=E(),k=as=ln=null,Xa=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return u_&&n.locale!=="ko"?null:n.data;default:return null}}var ex={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 m_(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!ex[i.type]:n==="textarea"}function g_(i,n,a,o){_r?sr?sr.push(o):sr=[o]:_r=o,n=ku(n,"onChange"),0<n.length&&(a=new He("onChange","change",null,a,o),i.push({event:a,listeners:n}))}var Ql=null,Jl=null;function tx(i){Qb(i,0)}function jc(i){var n=jn(i);if(Mr(n))return i}function __(i,n){if(i==="change")return n}var v_=!1;if(tn){var rd;if(tn){var sd="oninput"in document;if(!sd){var b_=document.createElement("div");b_.setAttribute("oninput","return;"),sd=typeof b_.oninput=="function"}rd=sd}else rd=!1;v_=rd&&(!document.documentMode||9<document.documentMode)}function y_(){Ql&&(Ql.detachEvent("onpropertychange",S_),Jl=Ql=null)}function S_(i){if(i.propertyName==="value"&&jc(Jl)){var n=[];g_(n,Jl,i,rs(i)),Ya(tx,n)}}function ix(i,n,a){i==="focusin"?(y_(),Ql=n,Jl=a,Ql.attachEvent("onpropertychange",S_)):i==="focusout"&&y_()}function nx(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return jc(Jl)}function rx(i,n){if(i==="click")return jc(n)}function sx(i,n){if(i==="input"||i==="change")return jc(n)}function ax(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var En=typeof Object.is=="function"?Object.is:ax;function eo(i,n){if(En(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),o=Object.keys(n);if(a.length!==o.length)return!1;for(o=0;o<a.length;o++){var u=a[o];if(!Re.call(n,u)||!En(i[u],n[u]))return!1}return!0}function w_(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function C_(i,n){var a=w_(i);i=0;for(var o;a;){if(a.nodeType===3){if(o=i+a.textContent.length,i<=n&&o>=n)return{node:a,offset:n-i};i=o}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=w_(a)}}function x_(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?x_(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function k_(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=pr(i.document);n instanceof i.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)i=n.contentWindow;else break;n=pr(i.document)}return n}function ad(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n&&(n==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||n==="textarea"||i.contentEditable==="true")}var lx=tn&&"documentMode"in document&&11>=document.documentMode,Ga=null,ld=null,to=null,od=!1;function E_(i,n,a){var o=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;od||Ga==null||Ga!==pr(o)||(o=Ga,"selectionStart"in o&&ad(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),to&&eo(to,o)||(to=o,o=ku(ld,"onSelect"),0<o.length&&(n=new He("onSelect","select",null,n,a),i.push({event:n,listeners:o}),n.target=Ga)))}function ia(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var Za={animationend:ia("Animation","AnimationEnd"),animationiteration:ia("Animation","AnimationIteration"),animationstart:ia("Animation","AnimationStart"),transitionrun:ia("Transition","TransitionRun"),transitionstart:ia("Transition","TransitionStart"),transitioncancel:ia("Transition","TransitionCancel"),transitionend:ia("Transition","TransitionEnd")},cd={},T_={};tn&&(T_=document.createElement("div").style,"AnimationEvent"in window||(delete Za.animationend.animation,delete Za.animationiteration.animation,delete Za.animationstart.animation),"TransitionEvent"in window||delete Za.transitionend.transition);function na(i){if(cd[i])return cd[i];if(!Za[i])return i;var n=Za[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in T_)return cd[i]=n[a];return i}var D_=na("animationend"),R_=na("animationiteration"),M_=na("animationstart"),ox=na("transitionrun"),cx=na("transitionstart"),ux=na("transitioncancel"),N_=na("transitionend"),A_=new Map,ud="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(" ");ud.push("scrollEnd");function ar(i,n){A_.set(i,n),nr(n,[i])}var Pc=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=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(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Hn=[],Qa=0,hd=0;function Hc(){for(var i=Qa,n=hd=Qa=0;n<i;){var a=Hn[n];Hn[n++]=null;var o=Hn[n];Hn[n++]=null;var u=Hn[n];Hn[n++]=null;var d=Hn[n];if(Hn[n++]=null,o!==null&&u!==null){var _=o.pending;_===null?u.next=u:(u.next=_.next,_.next=u),o.pending=u}d!==0&&L_(a,u,d)}}function Ic(i,n,a,o){Hn[Qa++]=i,Hn[Qa++]=n,Hn[Qa++]=a,Hn[Qa++]=o,hd|=o,i.lanes|=o,i=i.alternate,i!==null&&(i.lanes|=o)}function dd(i,n,a,o){return Ic(i,n,a,o),Uc(i)}function ra(i,n){return Ic(i,null,null,n),Uc(i)}function L_(i,n,a){i.lanes|=a;var o=i.alternate;o!==null&&(o.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,o=d.alternate,o!==null&&(o.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&n!==null&&(u=31-F(a),i=d.hiddenUpdates,o=i[u],o===null?i[u]=[n]:o.push(n),n.lane=a|536870912),d):null}function Uc(i){if(50<xo)throw xo=0,wf=null,Error(s(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var Ja={};function hx(i,n,a,o){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tn(i,n,a,o){return new hx(i,n,a,o)}function fd(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ar(i,n){var a=i.alternate;return a===null?(a=Tn(i.tag,n,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=n,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,n=i.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function B_(i,n){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=n,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,n=a.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),i}function Kc(i,n,a,o,u,d){var _=0;if(o=i,typeof i=="function")fd(i)&&(_=1);else if(typeof i=="string")_=gk(i,a,me.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=Tn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case D:return sa(a.children,u,d,n);case L:_=8,u|=24;break;case A:return i=Tn(12,a,n,u|2),i.elementType=A,i.lanes=d,i;case q:return i=Tn(13,a,n,u),i.elementType=q,i.lanes=d,i;case re:return i=Tn(19,a,n,u),i.elementType=re,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Y:_=10;break e;case B:_=9;break e;case P:_=11;break e;case ne:_=14;break e;case he:_=16,o=null;break e}_=29,a=Error(s(130,i===null?"null":typeof i,"")),o=null}return n=Tn(_,a,n,u),n.elementType=i,n.type=o,n.lanes=d,n}function sa(i,n,a,o){return i=Tn(7,i,o,n),i.lanes=a,i}function pd(i,n,a){return i=Tn(6,i,null,n),i.lanes=a,i}function O_(i){var n=Tn(18,null,null,0);return n.stateNode=i,n}function md(i,n,a){return n=Tn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var z_=new WeakMap;function In(i,n){if(typeof i=="object"&&i!==null){var a=z_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:ke(n)},z_.set(i,n),n)}return{value:i,source:n,stack:ke(n)}}var el=[],tl=0,Wc=null,io=0,Un=[],Kn=0,os=null,br=1,yr="";function Lr(i,n){el[tl++]=io,el[tl++]=Wc,Wc=i,io=n}function j_(i,n,a){Un[Kn++]=br,Un[Kn++]=yr,Un[Kn++]=os,os=i;var o=br;i=yr;var u=32-F(o)-1;o&=~(1<<u),a+=1;var d=32-F(n)+u;if(30<d){var _=u-u%5;d=(o&(1<<_)-1).toString(32),o>>=_,u-=_,br=1<<32-F(n)+u|a<<u|o,yr=d+i}else br=1<<d|a<<u|o,yr=i}function gd(i){i.return!==null&&(Lr(i,1),j_(i,1,0))}function _d(i){for(;i===Wc;)Wc=el[--tl],el[tl]=null,io=el[--tl],el[tl]=null;for(;i===os;)os=Un[--Kn],Un[Kn]=null,yr=Un[--Kn],Un[Kn]=null,br=Un[--Kn],Un[Kn]=null}function P_(i,n){Un[Kn++]=br,Un[Kn++]=yr,Un[Kn++]=os,br=n.id,yr=n.overflow,os=i}var Vi=null,Ut=null,mt=!1,cs=null,Wn=!1,vd=Error(s(519));function us(i){var n=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw no(In(n,i)),vd}function H_(i){var n=i.stateNode,a=i.type,o=i.memoizedProps;switch(n[$t]=i,n[Bi]=o,a){case"dialog":ht("cancel",n),ht("close",n);break;case"iframe":case"object":case"embed":ht("load",n);break;case"video":case"audio":for(a=0;a<Eo.length;a++)ht(Eo[a],n);break;case"source":ht("error",n);break;case"img":case"image":case"link":ht("error",n),ht("load",n);break;case"details":ht("toggle",n);break;case"input":ht("invalid",n),Ys(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ht("invalid",n);break;case"textarea":ht("invalid",n),Xs(n,o.value,o.defaultValue,o.children)}a=o.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||o.suppressHydrationWarning===!0||iy(n.textContent,a)?(o.popover!=null&&(ht("beforetoggle",n),ht("toggle",n)),o.onScroll!=null&&ht("scroll",n),o.onScrollEnd!=null&&ht("scrollend",n),o.onClick!=null&&(n.onclick=qi),n=!0):n=!1,n||us(i,!0)}function I_(i){for(Vi=i.return;Vi;)switch(Vi.tag){case 5:case 31:case 13:Wn=!1;return;case 27:case 3:Wn=!0;return;default:Vi=Vi.return}}function il(i){if(i!==Vi)return!1;if(!mt)return I_(i),mt=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||jf(i.type,i.memoizedProps)),a=!a),a&&Ut&&us(i),I_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ut=hy(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(317));Ut=hy(i)}else n===27?(n=Ut,xs(i.type)?(i=Kf,Kf=null,Ut=i):Ut=n):Ut=Vi?qn(i.stateNode.nextSibling):null;return!0}function aa(){Ut=Vi=null,mt=!1}function bd(){var i=cs;return i!==null&&(_n===null?_n=i:_n.push.apply(_n,i),cs=null),i}function no(i){cs===null?cs=[i]:cs.push(i)}var yd=M(null),la=null,Br=null;function hs(i,n,a){de(yd,n._currentValue),n._currentValue=a}function Or(i){i._currentValue=yd.current,Q(yd)}function Sd(i,n,a){for(;i!==null;){var o=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),i===a)break;i=i.return}}function wd(i,n,a,o){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=u;for(var N=0;N<n.length;N++)if(C.context===n[N]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),Sd(d.return,a,i),o||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(s(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),Sd(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function nl(i,n,a,o){i=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(s(387));if(_=_.memoizedProps,_!==null){var C=u.type;En(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Ee.current){if(_=u.alternate,_===null)throw Error(s(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(No):i=[No])}u=u.return}i!==null&&wd(n,i,a,o),n.flags|=262144}function Fc(i){for(i=i.firstContext;i!==null;){if(!En(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function oa(i){la=i,Br=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Yi(i){return U_(la,i)}function qc(i,n){return la===null&&oa(i),U_(i,n)}function U_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Br===null){if(i===null)throw Error(s(308));Br=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Br=Br.next=n;return a}var dx=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,o){i.push(o)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},fx=e.unstable_scheduleCallback,px=e.unstable_NormalPriority,pi={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Cd(){return{controller:new dx,data:new Map,refCount:0}}function ro(i){i.refCount--,i.refCount===0&&fx(px,function(){i.controller.abort()})}var so=null,xd=0,rl=0,sl=null;function mx(i,n){if(so===null){var a=so=[];xd=0,rl=Df(),sl={status:"pending",value:void 0,then:function(o){a.push(o)}}}return xd++,n.then(K_,K_),n}function K_(){if(--xd===0&&so!==null){sl!==null&&(sl.status="fulfilled");var i=so;so=null,rl=0,sl=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function gx(i,n){var a=[],o={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){o.status="fulfilled",o.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(o.status="rejected",o.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),o}var W_=R.S;R.S=function(i,n){Eb=Ve(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&mx(i,n),W_!==null&&W_(i,n)};var ca=M(null);function kd(){var i=ca.current;return i!==null?i:Lt.pooledCache}function $c(i,n){n===null?de(ca,ca.current):de(ca,n.pool)}function F_(){var i=kd();return i===null?null:{parent:pi._currentValue,pool:i}}var al=Error(s(460)),Ed=Error(s(474)),Vc=Error(s(542)),Yc={then:function(){}};function q_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function $_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(qi,qi),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,Y_(i),i;default:if(typeof n.status=="string")n.then(qi,qi);else{if(i=Lt,i!==null&&100<i.shellSuspendCounter)throw Error(s(482));i=n,i.status="pending",i.then(function(o){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=o}},function(o){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,Y_(i),i}throw ha=n,al}}function ua(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ha=a,al):a}}var ha=null;function V_(){if(ha===null)throw Error(s(459));var i=ha;return ha=null,i}function Y_(i){if(i===al||i===Vc)throw Error(s(483))}var ll=null,ao=0;function Xc(i){var n=ao;return ao+=1,ll===null&&(ll=[]),$_(ll,i,n)}function lo(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Gc(i,n){throw n.$$typeof===S?Error(s(525)):(i=Object.prototype.toString.call(n),Error(s(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function X_(i){function n(I,O){if(i){var $=I.deletions;$===null?(I.deletions=[O],I.flags|=16):$.push(O)}}function a(I,O){if(!i)return null;for(;O!==null;)n(I,O),O=O.sibling;return null}function o(I){for(var O=new Map;I!==null;)I.key!==null?O.set(I.key,I):O.set(I.index,I),I=I.sibling;return O}function u(I,O){return I=Ar(I,O),I.index=0,I.sibling=null,I}function d(I,O,$){return I.index=$,i?($=I.alternate,$!==null?($=$.index,$<O?(I.flags|=67108866,O):$):(I.flags|=67108866,O)):(I.flags|=1048576,O)}function _(I){return i&&I.alternate===null&&(I.flags|=67108866),I}function C(I,O,$,ce){return O===null||O.tag!==6?(O=pd($,I.mode,ce),O.return=I,O):(O=u(O,$),O.return=I,O)}function N(I,O,$,ce){var qe=$.type;return qe===D?le(I,O,$.props.children,ce,$.key):O!==null&&(O.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===he&&ua(qe)===O.type)?(O=u(O,$.props),lo(O,$),O.return=I,O):(O=Kc($.type,$.key,$.props,null,I.mode,ce),lo(O,$),O.return=I,O)}function V(I,O,$,ce){return O===null||O.tag!==4||O.stateNode.containerInfo!==$.containerInfo||O.stateNode.implementation!==$.implementation?(O=md($,I.mode,ce),O.return=I,O):(O=u(O,$.children||[]),O.return=I,O)}function le(I,O,$,ce,qe){return O===null||O.tag!==7?(O=sa($,I.mode,ce,qe),O.return=I,O):(O=u(O,$),O.return=I,O)}function ue(I,O,$){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=pd(""+O,I.mode,$),O.return=I,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case w:return $=Kc(O.type,O.key,O.props,null,I.mode,$),lo($,O),$.return=I,$;case x:return O=md(O,I.mode,$),O.return=I,O;case he:return O=ua(O),ue(I,O,$)}if(ae(O)||W(O))return O=sa(O,I.mode,$,null),O.return=I,O;if(typeof O.then=="function")return ue(I,Xc(O),$);if(O.$$typeof===Y)return ue(I,qc(I,O),$);Gc(I,O)}return null}function G(I,O,$,ce){var qe=O!==null?O.key:null;if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return qe!==null?null:C(I,O,""+$,ce);if(typeof $=="object"&&$!==null){switch($.$$typeof){case w:return $.key===qe?N(I,O,$,ce):null;case x:return $.key===qe?V(I,O,$,ce):null;case he:return $=ua($),G(I,O,$,ce)}if(ae($)||W($))return qe!==null?null:le(I,O,$,ce,null);if(typeof $.then=="function")return G(I,O,Xc($),ce);if($.$$typeof===Y)return G(I,O,qc(I,$),ce);Gc(I,$)}return null}function ee(I,O,$,ce,qe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return I=I.get($)||null,C(O,I,""+ce,qe);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return I=I.get(ce.key===null?$:ce.key)||null,N(O,I,ce,qe);case x:return I=I.get(ce.key===null?$:ce.key)||null,V(O,I,ce,qe);case he:return ce=ua(ce),ee(I,O,$,ce,qe)}if(ae(ce)||W(ce))return I=I.get($)||null,le(O,I,ce,qe,null);if(typeof ce.then=="function")return ee(I,O,$,Xc(ce),qe);if(ce.$$typeof===Y)return ee(I,O,$,qc(O,ce),qe);Gc(O,ce)}return null}function Oe(I,O,$,ce){for(var qe=null,_t=null,Ie=O,nt=O=0,pt=null;Ie!==null&&nt<$.length;nt++){Ie.index>nt?(pt=Ie,Ie=null):pt=Ie.sibling;var vt=G(I,Ie,$[nt],ce);if(vt===null){Ie===null&&(Ie=pt);break}i&&Ie&&vt.alternate===null&&n(I,Ie),O=d(vt,O,nt),_t===null?qe=vt:_t.sibling=vt,_t=vt,Ie=pt}if(nt===$.length)return a(I,Ie),mt&&Lr(I,nt),qe;if(Ie===null){for(;nt<$.length;nt++)Ie=ue(I,$[nt],ce),Ie!==null&&(O=d(Ie,O,nt),_t===null?qe=Ie:_t.sibling=Ie,_t=Ie);return mt&&Lr(I,nt),qe}for(Ie=o(Ie);nt<$.length;nt++)pt=ee(Ie,I,nt,$[nt],ce),pt!==null&&(i&&pt.alternate!==null&&Ie.delete(pt.key===null?nt:pt.key),O=d(pt,O,nt),_t===null?qe=pt:_t.sibling=pt,_t=pt);return i&&Ie.forEach(function(Rs){return n(I,Rs)}),mt&&Lr(I,nt),qe}function Ye(I,O,$,ce){if($==null)throw Error(s(151));for(var qe=null,_t=null,Ie=O,nt=O=0,pt=null,vt=$.next();Ie!==null&&!vt.done;nt++,vt=$.next()){Ie.index>nt?(pt=Ie,Ie=null):pt=Ie.sibling;var Rs=G(I,Ie,vt.value,ce);if(Rs===null){Ie===null&&(Ie=pt);break}i&&Ie&&Rs.alternate===null&&n(I,Ie),O=d(Rs,O,nt),_t===null?qe=Rs:_t.sibling=Rs,_t=Rs,Ie=pt}if(vt.done)return a(I,Ie),mt&&Lr(I,nt),qe;if(Ie===null){for(;!vt.done;nt++,vt=$.next())vt=ue(I,vt.value,ce),vt!==null&&(O=d(vt,O,nt),_t===null?qe=vt:_t.sibling=vt,_t=vt);return mt&&Lr(I,nt),qe}for(Ie=o(Ie);!vt.done;nt++,vt=$.next())vt=ee(Ie,I,nt,vt.value,ce),vt!==null&&(i&&vt.alternate!==null&&Ie.delete(vt.key===null?nt:vt.key),O=d(vt,O,nt),_t===null?qe=vt:_t.sibling=vt,_t=vt);return i&&Ie.forEach(function(Tk){return n(I,Tk)}),mt&&Lr(I,nt),qe}function Rt(I,O,$,ce){if(typeof $=="object"&&$!==null&&$.type===D&&$.key===null&&($=$.props.children),typeof $=="object"&&$!==null){switch($.$$typeof){case w:e:{for(var qe=$.key;O!==null;){if(O.key===qe){if(qe=$.type,qe===D){if(O.tag===7){a(I,O.sibling),ce=u(O,$.props.children),ce.return=I,I=ce;break e}}else if(O.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===he&&ua(qe)===O.type){a(I,O.sibling),ce=u(O,$.props),lo(ce,$),ce.return=I,I=ce;break e}a(I,O);break}else n(I,O);O=O.sibling}$.type===D?(ce=sa($.props.children,I.mode,ce,$.key),ce.return=I,I=ce):(ce=Kc($.type,$.key,$.props,null,I.mode,ce),lo(ce,$),ce.return=I,I=ce)}return _(I);case x:e:{for(qe=$.key;O!==null;){if(O.key===qe)if(O.tag===4&&O.stateNode.containerInfo===$.containerInfo&&O.stateNode.implementation===$.implementation){a(I,O.sibling),ce=u(O,$.children||[]),ce.return=I,I=ce;break e}else{a(I,O);break}else n(I,O);O=O.sibling}ce=md($,I.mode,ce),ce.return=I,I=ce}return _(I);case he:return $=ua($),Rt(I,O,$,ce)}if(ae($))return Oe(I,O,$,ce);if(W($)){if(qe=W($),typeof qe!="function")throw Error(s(150));return $=qe.call($),Ye(I,O,$,ce)}if(typeof $.then=="function")return Rt(I,O,Xc($),ce);if($.$$typeof===Y)return Rt(I,O,qc(I,$),ce);Gc(I,$)}return typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint"?($=""+$,O!==null&&O.tag===6?(a(I,O.sibling),ce=u(O,$),ce.return=I,I=ce):(a(I,O),ce=pd($,I.mode,ce),ce.return=I,I=ce),_(I)):a(I,O)}return function(I,O,$,ce){try{ao=0;var qe=Rt(I,O,$,ce);return ll=null,qe}catch(Ie){if(Ie===al||Ie===Vc)throw Ie;var _t=Tn(29,Ie,null,I.mode);return _t.lanes=ce,_t.return=I,_t}}}var da=X_(!0),G_=X_(!1),ds=!1;function Td(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Dd(i,n){i=i.updateQueue,n.updateQueue===i&&(n.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function fs(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ps(i,n,a){var o=i.updateQueue;if(o===null)return null;if(o=o.shared,(yt&2)!==0){var u=o.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),o.pending=n,n=Uc(i),L_(i,null,a),n}return Ic(i,o,n,a),Uc(i)}function oo(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var o=n.lanes;o&=i.pendingLanes,a|=o,n.lanes=a,Zt(i,a)}}function Rd(i,n){var a=i.updateQueue,o=i.alternate;if(o!==null&&(o=o.updateQueue,a===o)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=n:d=d.next=n}else u=d=n;a={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:o.shared,callbacks:o.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var Md=!1;function co(){if(Md){var i=sl;if(i!==null)throw i}}function uo(i,n,a,o){Md=!1;var u=i.updateQueue;ds=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var N=C,V=N.next;N.next=null,_===null?d=V:_.next=V,_=N;var le=i.alternate;le!==null&&(le=le.updateQueue,C=le.lastBaseUpdate,C!==_&&(C===null?le.firstBaseUpdate=V:C.next=V,le.lastBaseUpdate=N))}if(d!==null){var ue=u.baseState;_=0,le=V=N=null,C=d;do{var G=C.lane&-536870913,ee=G!==C.lane;if(ee?(ft&G)===G:(o&G)===G){G!==0&&G===rl&&(Md=!0),le!==null&&(le=le.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Oe=i,Ye=C;G=n;var Rt=a;switch(Ye.tag){case 1:if(Oe=Ye.payload,typeof Oe=="function"){ue=Oe.call(Rt,ue,G);break e}ue=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Ye.payload,G=typeof Oe=="function"?Oe.call(Rt,ue,G):Oe,G==null)break e;ue=b({},ue,G);break e;case 2:ds=!0}}G=C.callback,G!==null&&(i.flags|=64,ee&&(i.flags|=8192),ee=u.callbacks,ee===null?u.callbacks=[G]:ee.push(G))}else ee={lane:G,tag:C.tag,payload:C.payload,callback:C.callback,next:null},le===null?(V=le=ee,N=ue):le=le.next=ee,_|=G;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;ee=C,C=ee.next,ee.next=null,u.lastBaseUpdate=ee,u.shared.pending=null}}while(!0);le===null&&(N=ue),u.baseState=N,u.firstBaseUpdate=V,u.lastBaseUpdate=le,d===null&&(u.shared.lanes=0),bs|=_,i.lanes=_,i.memoizedState=ue}}function Z_(i,n){if(typeof i!="function")throw Error(s(191,i));i.call(n)}function Q_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)Z_(a[i],n)}var ol=M(null),Zc=M(0);function J_(i,n){i=Fr,de(Zc,i),de(ol,n),Fr=i|n.baseLanes}function Nd(){de(Zc,Fr),de(ol,ol.current)}function Ad(){Fr=Zc.current,Q(ol),Q(Zc)}var Dn=M(null),Fn=null;function ms(i){var n=i.alternate;de(ui,ui.current&1),de(Dn,i),Fn===null&&(n===null||ol.current!==null||n.memoizedState!==null)&&(Fn=i)}function Ld(i){de(ui,ui.current),de(Dn,i),Fn===null&&(Fn=i)}function ev(i){i.tag===22?(de(ui,ui.current),de(Dn,i),Fn===null&&(Fn=i)):gs()}function gs(){de(ui,ui.current),de(Dn,Dn.current)}function Rn(i){Q(Dn),Fn===i&&(Fn=null),Q(ui)}var ui=M(0);function Qc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||If(a)||Uf(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var zr=0,et=null,Tt=null,mi=null,Jc=!1,cl=!1,fa=!1,eu=0,ho=0,ul=null,_x=0;function ni(){throw Error(s(321))}function Bd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!En(i[a],n[a]))return!1;return!0}function Od(i,n,a,o,u,d){return zr=d,et=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,R.H=i===null||i.memoizedState===null?jv:Gd,fa=!1,d=a(o,u),fa=!1,cl&&(d=iv(n,a,o,u)),tv(i),d}function tv(i){R.H=mo;var n=Tt!==null&&Tt.next!==null;if(zr=0,mi=Tt=et=null,Jc=!1,ho=0,ul=null,n)throw Error(s(300));i===null||gi||(i=i.dependencies,i!==null&&Fc(i)&&(gi=!0))}function iv(i,n,a,o){et=i;var u=0;do{if(cl&&(ul=null),ho=0,cl=!1,25<=u)throw Error(s(301));if(u+=1,mi=Tt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}R.H=Pv,d=n(a,o)}while(cl);return d}function vx(){var i=R.H,n=i.useState()[0];return n=typeof n.then=="function"?fo(n):n,i=i.useState()[0],(Tt!==null?Tt.memoizedState:null)!==i&&(et.flags|=1024),n}function zd(){var i=eu!==0;return eu=0,i}function jd(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function Pd(i){if(Jc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Jc=!1}zr=0,mi=Tt=et=null,cl=!1,ho=eu=0,ul=null}function on(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mi===null?et.memoizedState=mi=i:mi=mi.next=i,mi}function hi(){if(Tt===null){var i=et.alternate;i=i!==null?i.memoizedState:null}else i=Tt.next;var n=mi===null?et.memoizedState:mi.next;if(n!==null)mi=n,Tt=i;else{if(i===null)throw et.alternate===null?Error(s(467)):Error(s(310));Tt=i,i={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},mi===null?et.memoizedState=mi=i:mi=mi.next=i}return mi}function tu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function fo(i){var n=ho;return ho+=1,ul===null&&(ul=[]),i=$_(ul,i,n),n=et,(mi===null?n.memoizedState:mi.next)===null&&(n=n.alternate,R.H=n===null||n.memoizedState===null?jv:Gd),i}function iu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return fo(i);if(i.$$typeof===Y)return Yi(i)}throw Error(s(438,String(i)))}function Hd(i){var n=null,a=et.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var o=et.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=tu(),et.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),o=0;o<i;o++)a[o]=U;return n.index++,a}function jr(i,n){return typeof n=="function"?n(i):n}function nu(i){var n=hi();return Id(n,Tt,i)}function Id(i,n,a){var o=i.queue;if(o===null)throw Error(s(311));o.lastRenderedReducer=a;var u=i.baseQueue,d=o.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,o.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,N=null,V=n,le=!1;do{var ue=V.lane&-536870913;if(ue!==V.lane?(ft&ue)===ue:(zr&ue)===ue){var G=V.revertLane;if(G===0)N!==null&&(N=N.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),ue===rl&&(le=!0);else if((zr&G)===G){V=V.next,G===rl&&(le=!0);continue}else ue={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(C=N=ue,_=d):N=N.next=ue,et.lanes|=G,bs|=G;ue=V.action,fa&&a(d,ue),d=V.hasEagerState?V.eagerState:a(d,ue)}else G={lane:ue,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},N===null?(C=N=G,_=d):N=N.next=G,et.lanes|=ue,bs|=ue;V=V.next}while(V!==null&&V!==n);if(N===null?_=d:N.next=C,!En(d,i.memoizedState)&&(gi=!0,le&&(a=sl,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=N,o.lastRenderedState=d}return u===null&&(o.lanes=0),[i.memoizedState,o.dispatch]}function Ud(i){var n=hi(),a=n.queue;if(a===null)throw Error(s(311));a.lastRenderedReducer=i;var o=a.dispatch,u=a.pending,d=n.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);En(d,n.memoizedState)||(gi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,o]}function nv(i,n,a){var o=et,u=hi(),d=mt;if(d){if(a===void 0)throw Error(s(407));a=a()}else a=n();var _=!En((Tt||u).memoizedState,a);if(_&&(u.memoizedState=a,gi=!0),u=u.queue,Fd(av.bind(null,o,u,i),[i]),u.getSnapshot!==n||_||mi!==null&&mi.memoizedState.tag&1){if(o.flags|=2048,hl(9,{destroy:void 0},sv.bind(null,o,u,a,n),null),Lt===null)throw Error(s(349));d||(zr&127)!==0||rv(o,n,a)}return a}function rv(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=et.updateQueue,n===null?(n=tu(),et.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function sv(i,n,a,o){n.value=a,n.getSnapshot=o,lv(n)&&ov(i)}function av(i,n,a){return a(function(){lv(n)&&ov(i)})}function lv(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!En(i,a)}catch{return!0}}function ov(i){var n=ra(i,2);n!==null&&vn(n,i,2)}function Kd(i){var n=on();if(typeof i=="function"){var a=i;if(i=a(),fa){Ft(!0);try{a()}finally{Ft(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:i},n}function cv(i,n,a,o){return i.baseState=a,Id(i,Tt,typeof o=="function"?o:jr)}function bx(i,n,a,o,u){if(au(i))throw Error(s(485));if(i=n.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};R.T!==null?a(!0):d.isTransition=!1,o(d),a=n.pending,a===null?(d.next=n.pending=d,uv(n,d)):(d.next=a.next,n.pending=a.next=d)}}function uv(i,n){var a=n.action,o=n.payload,u=i.state;if(n.isTransition){var d=R.T,_={};R.T=_;try{var C=a(u,o),N=R.S;N!==null&&N(_,C),hv(i,n,C)}catch(V){Wd(i,n,V)}finally{d!==null&&_.types!==null&&(d.types=_.types),R.T=d}}else try{d=a(u,o),hv(i,n,d)}catch(V){Wd(i,n,V)}}function hv(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(o){dv(i,n,o)},function(o){return Wd(i,n,o)}):dv(i,n,a)}function dv(i,n,a){n.status="fulfilled",n.value=a,fv(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,uv(i,a)))}function Wd(i,n,a){var o=i.pending;if(i.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=a,fv(n),n=n.next;while(n!==o)}i.action=null}function fv(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function pv(i,n){return n}function mv(i,n){if(mt){var a=Lt.formState;if(a!==null){e:{var o=et;if(mt){if(Ut){t:{for(var u=Ut,d=Wn;u.nodeType!==8;){if(!d){u=null;break t}if(u=qn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){Ut=qn(u.nextSibling),o=u.data==="F!";break e}}us(o)}o=!1}o&&(n=a[0])}}return a=on(),a.memoizedState=a.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:pv,lastRenderedState:n},a.queue=o,a=Bv.bind(null,et,o),o.dispatch=a,o=Kd(!1),d=Xd.bind(null,et,!1,o.queue),o=on(),u={state:n,dispatch:null,action:i,pending:null},o.queue=u,a=bx.bind(null,et,u,d,a),u.dispatch=a,o.memoizedState=i,[n,a,!1]}function gv(i){var n=hi();return _v(n,Tt,i)}function _v(i,n,a){if(n=Id(i,n,pv)[0],i=nu(jr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=fo(n)}catch(_){throw _===al?Vc:_}else o=n;n=hi();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(et.flags|=2048,hl(9,{destroy:void 0},yx.bind(null,u,a),null)),[o,d,i]}function yx(i,n){i.action=n}function vv(i){var n=hi(),a=Tt;if(a!==null)return _v(n,a,i);hi(),n=n.memoizedState,a=hi();var o=a.queue.dispatch;return a.memoizedState=i,[n,o,!1]}function hl(i,n,a,o){return i={tag:i,create:a,deps:o,inst:n,next:null},n=et.updateQueue,n===null&&(n=tu(),et.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(o=a.next,a.next=i,i.next=o,n.lastEffect=i),i}function bv(){return hi().memoizedState}function ru(i,n,a,o){var u=on();et.flags|=i,u.memoizedState=hl(1|n,{destroy:void 0},a,o===void 0?null:o)}function su(i,n,a,o){var u=hi();o=o===void 0?null:o;var d=u.memoizedState.inst;Tt!==null&&o!==null&&Bd(o,Tt.memoizedState.deps)?u.memoizedState=hl(n,d,a,o):(et.flags|=i,u.memoizedState=hl(1|n,d,a,o))}function yv(i,n){ru(8390656,8,i,n)}function Fd(i,n){su(2048,8,i,n)}function Sx(i){et.flags|=4;var n=et.updateQueue;if(n===null)n=tu(),et.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function Sv(i){var n=hi().memoizedState;return Sx({ref:n,nextImpl:i}),function(){if((yt&2)!==0)throw Error(s(440));return n.impl.apply(void 0,arguments)}}function wv(i,n){return su(4,2,i,n)}function Cv(i,n){return su(4,4,i,n)}function xv(i,n){if(typeof n=="function"){i=i();var a=n(i);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return i=i(),n.current=i,function(){n.current=null}}function kv(i,n,a){a=a!=null?a.concat([i]):null,su(4,4,xv.bind(null,n,i),a)}function qd(){}function Ev(i,n){var a=hi();n=n===void 0?null:n;var o=a.memoizedState;return n!==null&&Bd(n,o[1])?o[0]:(a.memoizedState=[i,n],i)}function Tv(i,n){var a=hi();n=n===void 0?null:n;var o=a.memoizedState;if(n!==null&&Bd(n,o[1]))return o[0];if(o=i(),fa){Ft(!0);try{i()}finally{Ft(!1)}}return a.memoizedState=[o,n],o}function $d(i,n,a){return a===void 0||(zr&1073741824)!==0&&(ft&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=Db(),et.lanes|=i,bs|=i,a)}function Dv(i,n,a,o){return En(a,n)?a:ol.current!==null?(i=$d(i,a,o),En(i,n)||(gi=!0),i):(zr&42)===0||(zr&1073741824)!==0&&(ft&261930)===0?(gi=!0,i.memoizedState=a):(i=Db(),et.lanes|=i,bs|=i,n)}function Rv(i,n,a,o,u){var d=X.p;X.p=d!==0&&8>d?d:8;var _=R.T,C={};R.T=C,Xd(i,!1,n,a);try{var N=u(),V=R.S;if(V!==null&&V(C,N),N!==null&&typeof N=="object"&&typeof N.then=="function"){var le=gx(N,o);po(i,n,le,An(i))}else po(i,n,o,An(i))}catch(ue){po(i,n,{then:function(){},status:"rejected",reason:ue},An())}finally{X.p=d,_!==null&&C.types!==null&&(_.types=C.types),R.T=_}}function wx(){}function Vd(i,n,a,o){if(i.tag!==5)throw Error(s(476));var u=Mv(i).queue;Rv(i,u,n,Z,a===null?wx:function(){return Nv(i),a(o)})}function Mv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:Z},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:jr,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function Nv(i){var n=Mv(i);n.next===null&&(n=i.alternate.memoizedState),po(i,n.next.queue,{},An())}function Yd(){return Yi(No)}function Av(){return hi().memoizedState}function Lv(){return hi().memoizedState}function Cx(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=An();i=fs(a);var o=ps(n,i,a);o!==null&&(vn(o,n,a),oo(o,n,a)),n={cache:Cd()},i.payload=n;return}n=n.return}}function xx(i,n,a){var o=An();a={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},au(i)?Ov(n,a):(a=dd(i,n,a,o),a!==null&&(vn(a,i,o),zv(a,n,o)))}function Bv(i,n,a){var o=An();po(i,n,a,o)}function po(i,n,a,o){var u={lane:o,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(au(i))Ov(n,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var _=n.lastRenderedState,C=d(_,a);if(u.hasEagerState=!0,u.eagerState=C,En(C,_))return Ic(i,n,u,0),Lt===null&&Hc(),!1}catch{}if(a=dd(i,n,u,o),a!==null)return vn(a,i,o),zv(a,n,o),!0}return!1}function Xd(i,n,a,o){if(o={lane:2,revertLane:Df(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},au(i)){if(n)throw Error(s(479))}else n=dd(i,a,o,2),n!==null&&vn(n,i,2)}function au(i){var n=i.alternate;return i===et||n!==null&&n===et}function Ov(i,n){cl=Jc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function zv(i,n,a){if((a&4194048)!==0){var o=n.lanes;o&=i.pendingLanes,a|=o,n.lanes=a,Zt(i,a)}}var mo={readContext:Yi,use:iu,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};mo.useEffectEvent=ni;var jv={readContext:Yi,use:iu,useCallback:function(i,n){return on().memoizedState=[i,n===void 0?null:n],i},useContext:Yi,useEffect:yv,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,ru(4194308,4,xv.bind(null,n,i),a)},useLayoutEffect:function(i,n){return ru(4194308,4,i,n)},useInsertionEffect:function(i,n){ru(4,2,i,n)},useMemo:function(i,n){var a=on();n=n===void 0?null:n;var o=i();if(fa){Ft(!0);try{i()}finally{Ft(!1)}}return a.memoizedState=[o,n],o},useReducer:function(i,n,a){var o=on();if(a!==void 0){var u=a(n);if(fa){Ft(!0);try{a(n)}finally{Ft(!1)}}}else u=n;return o.memoizedState=o.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},o.queue=i,i=i.dispatch=xx.bind(null,et,i),[o.memoizedState,i]},useRef:function(i){var n=on();return i={current:i},n.memoizedState=i},useState:function(i){i=Kd(i);var n=i.queue,a=Bv.bind(null,et,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:qd,useDeferredValue:function(i,n){var a=on();return $d(a,i,n)},useTransition:function(){var i=Kd(!1);return i=Rv.bind(null,et,i.queue,!0,!1),on().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var o=et,u=on();if(mt){if(a===void 0)throw Error(s(407));a=a()}else{if(a=n(),Lt===null)throw Error(s(349));(ft&127)!==0||rv(o,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,yv(av.bind(null,o,d,i),[i]),o.flags|=2048,hl(9,{destroy:void 0},sv.bind(null,o,d,a,n),null),a},useId:function(){var i=on(),n=Lt.identifierPrefix;if(mt){var a=yr,o=br;a=(o&~(1<<32-F(o)-1)).toString(32)+a,n="_"+n+"R_"+a,a=eu++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=_x++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Yd,useFormState:mv,useActionState:mv,useOptimistic:function(i){var n=on();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Xd.bind(null,et,!0,a),a.dispatch=n,[i,n]},useMemoCache:Hd,useCacheRefresh:function(){return on().memoizedState=Cx.bind(null,et)},useEffectEvent:function(i){var n=on(),a={impl:i};return n.memoizedState=a,function(){if((yt&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}},Gd={readContext:Yi,use:iu,useCallback:Ev,useContext:Yi,useEffect:Fd,useImperativeHandle:kv,useInsertionEffect:wv,useLayoutEffect:Cv,useMemo:Tv,useReducer:nu,useRef:bv,useState:function(){return nu(jr)},useDebugValue:qd,useDeferredValue:function(i,n){var a=hi();return Dv(a,Tt.memoizedState,i,n)},useTransition:function(){var i=nu(jr)[0],n=hi().memoizedState;return[typeof i=="boolean"?i:fo(i),n]},useSyncExternalStore:nv,useId:Av,useHostTransitionStatus:Yd,useFormState:gv,useActionState:gv,useOptimistic:function(i,n){var a=hi();return cv(a,Tt,i,n)},useMemoCache:Hd,useCacheRefresh:Lv};Gd.useEffectEvent=Sv;var Pv={readContext:Yi,use:iu,useCallback:Ev,useContext:Yi,useEffect:Fd,useImperativeHandle:kv,useInsertionEffect:wv,useLayoutEffect:Cv,useMemo:Tv,useReducer:Ud,useRef:bv,useState:function(){return Ud(jr)},useDebugValue:qd,useDeferredValue:function(i,n){var a=hi();return Tt===null?$d(a,i,n):Dv(a,Tt.memoizedState,i,n)},useTransition:function(){var i=Ud(jr)[0],n=hi().memoizedState;return[typeof i=="boolean"?i:fo(i),n]},useSyncExternalStore:nv,useId:Av,useHostTransitionStatus:Yd,useFormState:vv,useActionState:vv,useOptimistic:function(i,n){var a=hi();return Tt!==null?cv(a,Tt,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:Hd,useCacheRefresh:Lv};Pv.useEffectEvent=Sv;function Zd(i,n,a,o){n=i.memoizedState,a=a(o,n),a=a==null?n:b({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Qd={enqueueSetState:function(i,n,a){i=i._reactInternals;var o=An(),u=fs(o);u.payload=n,a!=null&&(u.callback=a),n=ps(i,u,o),n!==null&&(vn(n,i,o),oo(n,i,o))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var o=An(),u=fs(o);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=ps(i,u,o),n!==null&&(vn(n,i,o),oo(n,i,o))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=An(),o=fs(a);o.tag=2,n!=null&&(o.callback=n),n=ps(i,o,a),n!==null&&(vn(n,i,a),oo(n,i,a))}};function Hv(i,n,a,o,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(o,d,_):n.prototype&&n.prototype.isPureReactComponent?!eo(a,o)||!eo(u,d):!0}function Iv(i,n,a,o){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,o),n.state!==i&&Qd.enqueueReplaceState(n,n.state,null)}function pa(i,n){var a=n;if("ref"in n){a={};for(var o in n)o!=="ref"&&(a[o]=n[o])}if(i=i.defaultProps){a===n&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function Uv(i){Pc(i)}function Kv(i){console.error(i)}function Wv(i){Pc(i)}function lu(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Fv(i,n,a){try{var o=i.onCaughtError;o(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Jd(i,n,a){return a=fs(a),a.tag=3,a.payload={element:null},a.callback=function(){lu(i,n)},a}function qv(i){return i=fs(i),i.tag=3,i}function $v(i,n,a,o){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=o.value;i.payload=function(){return u(d)},i.callback=function(){Fv(n,a,o)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){Fv(n,a,o),typeof u!="function"&&(ys===null?ys=new Set([this]):ys.add(this));var C=o.stack;this.componentDidCatch(o.value,{componentStack:C!==null?C:""})})}function kx(i,n,a,o,u){if(a.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=a.alternate,n!==null&&nl(n,a,u,!0),a=Dn.current,a!==null){switch(a.tag){case 31:case 13:return Fn===null?bu():a.alternate===null&&ri===0&&(ri=3),a.flags&=-257,a.flags|=65536,a.lanes=u,o===Yc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([o]):n.add(o),kf(i,o,u)),!1;case 22:return a.flags|=65536,o===Yc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([o]):a.add(o)),kf(i,o,u)),!1}throw Error(s(435,a.tag))}return kf(i,o,u),bu(),!1}if(mt)return n=Dn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,o!==vd&&(i=Error(s(422),{cause:o}),no(In(i,a)))):(o!==vd&&(n=Error(s(423),{cause:o}),no(In(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,o=In(o,a),u=Jd(i.stateNode,o,u),Rd(i,u),ri!==4&&(ri=2)),!1;var d=Error(s(520),{cause:o});if(d=In(d,a),Co===null?Co=[d]:Co.push(d),ri!==4&&(ri=2),n===null)return!0;o=In(o,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Jd(a.stateNode,o,i),Rd(a,i),!1;case 1:if(n=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(ys===null||!ys.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=qv(u),$v(u,i,a,o),Rd(a,u),!1}a=a.return}while(a!==null);return!1}var ef=Error(s(461)),gi=!1;function Xi(i,n,a,o){n.child=i===null?G_(n,null,a,o):da(n,i.child,a,o)}function Vv(i,n,a,o,u){a=a.render;var d=n.ref;if("ref"in o){var _={};for(var C in o)C!=="ref"&&(_[C]=o[C])}else _=o;return oa(n),o=Od(i,n,a,_,d,u),C=zd(),i!==null&&!gi?(jd(i,n,u),Pr(i,n,u)):(mt&&C&&gd(n),n.flags|=1,Xi(i,n,o,u),n.child)}function Yv(i,n,a,o,u){if(i===null){var d=a.type;return typeof d=="function"&&!fd(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Xv(i,n,d,o,u)):(i=Kc(a.type,null,o,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!cf(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:eo,a(_,o)&&i.ref===n.ref)return Pr(i,n,u)}return n.flags|=1,i=Ar(d,o),i.ref=n.ref,i.return=n,n.child=i}function Xv(i,n,a,o,u){if(i!==null){var d=i.memoizedProps;if(eo(d,o)&&i.ref===n.ref)if(gi=!1,n.pendingProps=o=d,cf(i,u))(i.flags&131072)!==0&&(gi=!0);else return n.lanes=i.lanes,Pr(i,n,u)}return tf(i,n,a,o,u)}function Gv(i,n,a,o){var u=o.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(o=n.child=i.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~d}else o=0,n.child=null;return Zv(i,n,d,a,o)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&$c(n,d!==null?d.cachePool:null),d!==null?J_(n,d):Nd(),ev(n);else return o=n.lanes=536870912,Zv(i,n,d!==null?d.baseLanes|a:a,a,o)}else d!==null?($c(n,d.cachePool),J_(n,d),gs(),n.memoizedState=null):(i!==null&&$c(n,null),Nd(),gs());return Xi(i,n,u,a),n.child}function go(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Zv(i,n,a,o,u){var d=kd();return d=d===null?null:{parent:pi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&$c(n,null),Nd(),ev(n),i!==null&&nl(i,n,o,!0),n.childLanes=u,null}function ou(i,n){return n=uu({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function Qv(i,n,a){return da(n,i.child,null,a),i=ou(n,n.pendingProps),i.flags|=2,Rn(n),n.memoizedState=null,i}function Ex(i,n,a){var o=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(mt){if(o.mode==="hidden")return i=ou(n,o),n.lanes=536870912,go(null,i);if(Ld(n),(i=Ut)?(i=uy(i,Wn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:os!==null?{id:br,overflow:yr}:null,retryLane:536870912,hydrationErrors:null},a=O_(i),a.return=n,n.child=a,Vi=n,Ut=null)):i=null,i===null)throw us(n);return n.lanes=536870912,null}return ou(n,o)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(Ld(n),u)if(n.flags&256)n.flags&=-257,n=Qv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(s(558));else if(gi||nl(i,n,a,!1),u=(a&i.childLanes)!==0,gi||u){if(o=Lt,o!==null&&(_=oi(o,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,ra(i,_),vn(o,i,_),ef;bu(),n=Qv(i,n,a)}else i=d.treeContext,Ut=qn(_.nextSibling),Vi=n,mt=!0,cs=null,Wn=!1,i!==null&&P_(n,i),n=ou(n,o),n.flags|=4096;return n}return i=Ar(i.child,{mode:o.mode,children:o.children}),i.ref=n.ref,n.child=i,i.return=n,i}function cu(i,n){var a=n.ref;if(a===null)i!==null&&i.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(s(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function tf(i,n,a,o,u){return oa(n),a=Od(i,n,a,o,void 0,u),o=zd(),i!==null&&!gi?(jd(i,n,u),Pr(i,n,u)):(mt&&o&&gd(n),n.flags|=1,Xi(i,n,a,u),n.child)}function Jv(i,n,a,o,u,d){return oa(n),n.updateQueue=null,a=iv(n,o,a,u),tv(i),o=zd(),i!==null&&!gi?(jd(i,n,d),Pr(i,n,d)):(mt&&o&&gd(n),n.flags|=1,Xi(i,n,a,d),n.child)}function eb(i,n,a,o,u){if(oa(n),n.stateNode===null){var d=Ja,_=a.contextType;typeof _=="object"&&_!==null&&(d=Yi(_)),d=new a(o,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Qd,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=o,d.state=n.memoizedState,d.refs={},Td(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Yi(_):Ja,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Zd(n,a,_,o),d.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&Qd.enqueueReplaceState(d,d.state,null),uo(n,o,d,u),co(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,N=pa(a,C);d.props=N;var V=d.context,le=a.contextType;_=Ja,typeof le=="object"&&le!==null&&(_=Yi(le));var ue=a.getDerivedStateFromProps;le=typeof ue=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,le||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||V!==_)&&Iv(n,d,o,_),ds=!1;var G=n.memoizedState;d.state=G,uo(n,o,d,u),co(),V=n.memoizedState,C||G!==V||ds?(typeof ue=="function"&&(Zd(n,a,ue,o),V=n.memoizedState),(N=ds||Hv(n,a,N,o,G,V,_))?(le||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=V),d.props=o,d.state=V,d.context=_,o=N):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{d=n.stateNode,Dd(i,n),_=n.memoizedProps,le=pa(a,_),d.props=le,ue=n.pendingProps,G=d.context,V=a.contextType,N=Ja,typeof V=="object"&&V!==null&&(N=Yi(V)),C=a.getDerivedStateFromProps,(V=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==ue||G!==N)&&Iv(n,d,o,N),ds=!1,G=n.memoizedState,d.state=G,uo(n,o,d,u),co();var ee=n.memoizedState;_!==ue||G!==ee||ds||i!==null&&i.dependencies!==null&&Fc(i.dependencies)?(typeof C=="function"&&(Zd(n,a,C,o),ee=n.memoizedState),(le=ds||Hv(n,a,le,o,G,ee,N)||i!==null&&i.dependencies!==null&&Fc(i.dependencies))?(V||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(o,ee,N),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(o,ee,N)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=ee),d.props=o,d.state=ee,d.context=N,o=le):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&G===i.memoizedState||(n.flags|=1024),o=!1)}return d=o,cu(i,n),o=(n.flags&128)!==0,d||o?(d=n.stateNode,a=o&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&o?(n.child=da(n,i.child,null,u),n.child=da(n,null,a,u)):Xi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Pr(i,n,u),i}function tb(i,n,a,o){return aa(),n.flags|=256,Xi(i,n,a,o),n.child}var nf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function rf(i){return{baseLanes:i,cachePool:F_()}}function sf(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=Nn),i}function ib(i,n,a){var o=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(ui.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(mt){if(u?ms(n):gs(),(i=Ut)?(i=uy(i,Wn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:os!==null?{id:br,overflow:yr}:null,retryLane:536870912,hydrationErrors:null},a=O_(i),a.return=n,n.child=a,Vi=n,Ut=null)):i=null,i===null)throw us(n);return Uf(i)?n.lanes=32:n.lanes=536870912,null}var C=o.children;return o=o.fallback,u?(gs(),u=n.mode,C=uu({mode:"hidden",children:C},u),o=sa(o,u,a,null),C.return=n,o.return=n,C.sibling=o,n.child=C,o=n.child,o.memoizedState=rf(a),o.childLanes=sf(i,_,a),n.memoizedState=nf,go(null,o)):(ms(n),af(n,C))}var N=i.memoizedState;if(N!==null&&(C=N.dehydrated,C!==null)){if(d)n.flags&256?(ms(n),n.flags&=-257,n=lf(i,n,a)):n.memoizedState!==null?(gs(),n.child=i.child,n.flags|=128,n=null):(gs(),C=o.fallback,u=n.mode,o=uu({mode:"visible",children:o.children},u),C=sa(C,u,a,null),C.flags|=2,o.return=n,C.return=n,o.sibling=C,n.child=o,da(n,i.child,null,a),o=n.child,o.memoizedState=rf(a),o.childLanes=sf(i,_,a),n.memoizedState=nf,n=go(null,o));else if(ms(n),Uf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var V=_.dgst;_=V,o=Error(s(419)),o.stack="",o.digest=_,no({value:o,source:null,stack:null}),n=lf(i,n,a)}else if(gi||nl(i,n,a,!1),_=(a&i.childLanes)!==0,gi||_){if(_=Lt,_!==null&&(o=oi(_,a),o!==0&&o!==N.retryLane))throw N.retryLane=o,ra(i,o),vn(_,i,o),ef;If(C)||bu(),n=lf(i,n,a)}else If(C)?(n.flags|=192,n.child=i.child,n=null):(i=N.treeContext,Ut=qn(C.nextSibling),Vi=n,mt=!0,cs=null,Wn=!1,i!==null&&P_(n,i),n=af(n,o.children),n.flags|=4096);return n}return u?(gs(),C=o.fallback,u=n.mode,N=i.child,V=N.sibling,o=Ar(N,{mode:"hidden",children:o.children}),o.subtreeFlags=N.subtreeFlags&65011712,V!==null?C=Ar(V,C):(C=sa(C,u,a,null),C.flags|=2),C.return=n,o.return=n,o.sibling=C,n.child=o,go(null,o),o=n.child,C=i.child.memoizedState,C===null?C=rf(a):(u=C.cachePool,u!==null?(N=pi._currentValue,u=u.parent!==N?{parent:N,pool:N}:u):u=F_(),C={baseLanes:C.baseLanes|a,cachePool:u}),o.memoizedState=C,o.childLanes=sf(i,_,a),n.memoizedState=nf,go(i.child,o)):(ms(n),a=i.child,i=a.sibling,a=Ar(a,{mode:"visible",children:o.children}),a.return=n,a.sibling=null,i!==null&&(_=n.deletions,_===null?(n.deletions=[i],n.flags|=16):_.push(i)),n.child=a,n.memoizedState=null,a)}function af(i,n){return n=uu({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function uu(i,n){return i=Tn(22,i,null,n),i.lanes=0,i}function lf(i,n,a){return da(n,i.child,null,a),i=af(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function nb(i,n,a){i.lanes|=n;var o=i.alternate;o!==null&&(o.lanes|=n),Sd(i.return,n,a)}function of(i,n,a,o,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=o,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function rb(i,n,a){var o=n.pendingProps,u=o.revealOrder,d=o.tail;o=o.children;var _=ui.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,de(ui,_),Xi(i,n,o,a),o=mt?io:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&nb(i,a,n);else if(i.tag===19)nb(i,a,n);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break e;for(;i.sibling===null;){if(i.return===null||i.return===n)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=n.child,u=null;a!==null;)i=a.alternate,i!==null&&Qc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),of(n,!1,u,a,d,o);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Qc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}of(n,!0,a,null,d,o);break;case"together":of(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function Pr(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),bs|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(nl(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(s(153));if(n.child!==null){for(i=n.child,a=Ar(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Ar(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function cf(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Fc(i)))}function Tx(i,n,a){switch(n.tag){case 3:De(n,n.stateNode.containerInfo),hs(n,pi,i.memoizedState.cache),aa();break;case 27:case 5:se(n);break;case 4:De(n,n.stateNode.containerInfo);break;case 10:hs(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Ld(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(ms(n),n.flags|=128,null):(a&n.child.childLanes)!==0?ib(i,n,a):(ms(n),i=Pr(i,n,a),i!==null?i.sibling:null);ms(n);break;case 19:var u=(i.flags&128)!==0;if(o=(a&n.childLanes)!==0,o||(nl(i,n,a,!1),o=(a&n.childLanes)!==0),u){if(o)return rb(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),de(ui,ui.current),o)break;return null;case 22:return n.lanes=0,Gv(i,n,a,n.pendingProps);case 24:hs(n,pi,i.memoizedState.cache)}return Pr(i,n,a)}function sb(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)gi=!0;else{if(!cf(i,a)&&(n.flags&128)===0)return gi=!1,Tx(i,n,a);gi=(i.flags&131072)!==0}else gi=!1,mt&&(n.flags&1048576)!==0&&j_(n,io,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(i=ua(n.elementType),n.type=i,typeof i=="function")fd(i)?(o=pa(i,o),n.tag=1,n=eb(null,n,i,o,a)):(n.tag=0,n=tf(null,n,i,o,a));else{if(i!=null){var u=i.$$typeof;if(u===P){n.tag=11,n=Vv(null,n,i,o,a);break e}else if(u===ne){n.tag=14,n=Yv(null,n,i,o,a);break e}}throw n=j(i)||i,Error(s(306,n,""))}}return n;case 0:return tf(i,n,n.type,n.pendingProps,a);case 1:return o=n.type,u=pa(o,n.pendingProps),eb(i,n,o,u,a);case 3:e:{if(De(n,n.stateNode.containerInfo),i===null)throw Error(s(387));o=n.pendingProps;var d=n.memoizedState;u=d.element,Dd(i,n),uo(n,o,null,a);var _=n.memoizedState;if(o=_.cache,hs(n,pi,o),o!==d.cache&&wd(n,[pi],a,!0),co(),o=_.element,d.isDehydrated)if(d={element:o,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=tb(i,n,o,a);break e}else if(o!==u){u=In(Error(s(424)),n),no(u),n=tb(i,n,o,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Ut=qn(i.firstChild),Vi=n,mt=!0,cs=null,Wn=!0,a=G_(n,null,o,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(aa(),o===u){n=Pr(i,n,a);break e}Xi(i,n,o,a)}n=n.child}return n;case 26:return cu(i,n),i===null?(a=gy(n.type,null,n.pendingProps,null))?n.memoizedState=a:mt||(a=n.type,i=n.pendingProps,o=Eu(Se.current).createElement(a),o[$t]=n,o[Bi]=i,Gi(o,a,i),It(o),n.stateNode=o):n.memoizedState=gy(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return se(n),i===null&&mt&&(o=n.stateNode=fy(n.type,n.pendingProps,Se.current),Vi=n,Wn=!0,u=Ut,xs(n.type)?(Kf=u,Ut=qn(o.firstChild)):Ut=u),Xi(i,n,n.pendingProps.children,a),cu(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&mt&&((u=o=Ut)&&(o=nk(o,n.type,n.pendingProps,Wn),o!==null?(n.stateNode=o,Vi=n,Ut=qn(o.firstChild),Wn=!1,u=!0):u=!1),u||us(n)),se(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,o=d.children,jf(u,d)?o=null:_!==null&&jf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=Od(i,n,vx,null,null,a),No._currentValue=u),cu(i,n),Xi(i,n,o,a),n.child;case 6:return i===null&&mt&&((i=a=Ut)&&(a=rk(a,n.pendingProps,Wn),a!==null?(n.stateNode=a,Vi=n,Ut=null,i=!0):i=!1),i||us(n)),null;case 13:return ib(i,n,a);case 4:return De(n,n.stateNode.containerInfo),o=n.pendingProps,i===null?n.child=da(n,null,o,a):Xi(i,n,o,a),n.child;case 11:return Vv(i,n,n.type,n.pendingProps,a);case 7:return Xi(i,n,n.pendingProps,a),n.child;case 8:return Xi(i,n,n.pendingProps.children,a),n.child;case 12:return Xi(i,n,n.pendingProps.children,a),n.child;case 10:return o=n.pendingProps,hs(n,n.type,o.value),Xi(i,n,o.children,a),n.child;case 9:return u=n.type._context,o=n.pendingProps.children,oa(n),u=Yi(u),o=o(u),n.flags|=1,Xi(i,n,o,a),n.child;case 14:return Yv(i,n,n.type,n.pendingProps,a);case 15:return Xv(i,n,n.type,n.pendingProps,a);case 19:return rb(i,n,a);case 31:return Ex(i,n,a);case 22:return Gv(i,n,a,n.pendingProps);case 24:return oa(n),o=Yi(pi),i===null?(u=kd(),u===null&&(u=Lt,d=Cd(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:o,cache:u},Td(n),hs(n,pi,u)):((i.lanes&a)!==0&&(Dd(i,n),uo(n,null,null,a),co()),u=i.memoizedState,d=n.memoizedState,u.parent!==o?(u={parent:o,cache:o},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),hs(n,pi,o)):(o=d.cache,hs(n,pi,o),o!==u.cache&&wd(n,[pi],a,!0))),Xi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(s(156,n.tag))}function Hr(i){i.flags|=4}function uf(i,n,a,o,u){if((n=(i.mode&32)!==0)&&(n=!1),n){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(Ab())i.flags|=8192;else throw ha=Yc,Ed}else i.flags&=-16777217}function ab(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Sy(n))if(Ab())i.flags|=8192;else throw ha=Yc,Ed}function hu(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?li():536870912,i.lanes|=n,ml|=n)}function _o(i,n){if(!mt)switch(i.tailMode){case"hidden":n=i.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:o.sibling=null}}function Kt(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,o=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=o,i.childLanes=a,n}function Dx(i,n,a){var o=n.pendingProps;switch(_d(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(n),null;case 1:return Kt(n),null;case 3:return a=n.stateNode,o=null,i!==null&&(o=i.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),Or(pi),Ke(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(il(n)?Hr(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,bd())),Kt(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(Hr(n),d!==null?(Kt(n),ab(n,d)):(Kt(n),uf(n,u,null,o,a))):d?d!==i.memoizedState?(Hr(n),Kt(n),ab(n,d)):(Kt(n),n.flags&=-16777217):(i=i.memoizedProps,i!==o&&Hr(n),Kt(n),uf(n,u,i,o,a)),null;case 27:if(pe(n),a=Se.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==o&&Hr(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return Kt(n),null}i=me.current,il(n)?H_(n):(i=fy(u,o,a),n.stateNode=i,Hr(n))}return Kt(n),null;case 5:if(pe(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==o&&Hr(n);else{if(!o){if(n.stateNode===null)throw Error(s(166));return Kt(n),null}if(d=me.current,il(n))H_(n);else{var _=Eu(Se.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof o.is=="string"?_.createElement("select",{is:o.is}):_.createElement("select"),o.multiple?d.multiple=!0:o.size&&(d.size=o.size);break;default:d=typeof o.is=="string"?_.createElement(u,{is:o.is}):_.createElement(u)}}d[$t]=n,d[Bi]=o;e:for(_=n.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===n)break e;for(;_.sibling===null;){if(_.return===null||_.return===n)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}n.stateNode=d;e:switch(Gi(d,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Hr(n)}}return Kt(n),uf(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==o&&Hr(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(s(166));if(i=Se.current,il(n)){if(i=n.stateNode,a=n.memoizedProps,o=null,u=Vi,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}i[$t]=n,i=!!(i.nodeValue===a||o!==null&&o.suppressHydrationWarning===!0||iy(i.nodeValue,a)),i||us(n,!0)}else i=Eu(i).createTextNode(o),i[$t]=n,n.stateNode=i}return Kt(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(o=il(n),a!==null){if(i===null){if(!o)throw Error(s(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[$t]=n}else aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Kt(n),i=!1}else a=bd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(Rn(n),n):(Rn(n),null);if((n.flags&128)!==0)throw Error(s(558))}return Kt(n),null;case 13:if(o=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=il(n),o!==null&&o.dehydrated!==null){if(i===null){if(!u)throw Error(s(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(s(317));u[$t]=n}else aa(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Kt(n),u=!1}else u=bd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(Rn(n),n):(Rn(n),null)}return Rn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=o!==null,i=i!==null&&i.memoizedState!==null,a&&(o=n.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),d=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(d=o.memoizedState.cachePool.pool),d!==u&&(o.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),hu(n,n.updateQueue),Kt(n),null);case 4:return Ke(),i===null&&Af(n.stateNode.containerInfo),Kt(n),null;case 10:return Or(n.type),Kt(n),null;case 19:if(Q(ui),o=n.memoizedState,o===null)return Kt(n),null;if(u=(n.flags&128)!==0,d=o.rendering,d===null)if(u)_o(o,!1);else{if(ri!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Qc(i),d!==null){for(n.flags|=128,_o(o,!1),i=d.updateQueue,n.updateQueue=i,hu(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)B_(a,i),a=a.sibling;return de(ui,ui.current&1|2),mt&&Lr(n,o.treeForkCount),n.child}i=i.sibling}o.tail!==null&&Ve()>gu&&(n.flags|=128,u=!0,_o(o,!1),n.lanes=4194304)}else{if(!u)if(i=Qc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,hu(n,i),_o(o,!0),o.tail===null&&o.tailMode==="hidden"&&!d.alternate&&!mt)return Kt(n),null}else 2*Ve()-o.renderingStartTime>gu&&a!==536870912&&(n.flags|=128,u=!0,_o(o,!1),n.lanes=4194304);o.isBackwards?(d.sibling=n.child,n.child=d):(i=o.last,i!==null?i.sibling=d:n.child=d,o.last=d)}return o.tail!==null?(i=o.tail,o.rendering=i,o.tail=i.sibling,o.renderingStartTime=Ve(),i.sibling=null,a=ui.current,de(ui,u?a&1|2:a&1),mt&&Lr(n,o.treeForkCount),i):(Kt(n),null);case 22:case 23:return Rn(n),Ad(),o=n.memoizedState!==null,i!==null?i.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(a&536870912)!==0&&(n.flags&128)===0&&(Kt(n),n.subtreeFlags&6&&(n.flags|=8192)):Kt(n),a=n.updateQueue,a!==null&&hu(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==a&&(n.flags|=2048),i!==null&&Q(ca),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Or(pi),Kt(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function Rx(i,n){switch(_d(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Or(pi),Ke(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return pe(n),null;case 31:if(n.memoizedState!==null){if(Rn(n),n.alternate===null)throw Error(s(340));aa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(Rn(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(s(340));aa()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return Q(ui),null;case 4:return Ke(),null;case 10:return Or(n.type),null;case 22:case 23:return Rn(n),Ad(),i!==null&&Q(ca),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Or(pi),null;case 25:return null;default:return null}}function lb(i,n){switch(_d(n),n.tag){case 3:Or(pi),Ke();break;case 26:case 27:case 5:pe(n);break;case 4:Ke();break;case 31:n.memoizedState!==null&&Rn(n);break;case 13:Rn(n);break;case 19:Q(ui);break;case 10:Or(n.type);break;case 22:case 23:Rn(n),Ad(),i!==null&&Q(ca);break;case 24:Or(pi)}}function vo(i,n){try{var a=n.updateQueue,o=a!==null?a.lastEffect:null;if(o!==null){var u=o.next;a=u;do{if((a.tag&i)===i){o=void 0;var d=a.create,_=a.inst;o=d(),_.destroy=o}a=a.next}while(a!==u)}}catch(C){Ct(n,n.return,C)}}function _s(i,n,a){try{var o=n.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var d=u.next;o=d;do{if((o.tag&i)===i){var _=o.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var N=a,V=C;try{V()}catch(le){Ct(u,N,le)}}}o=o.next}while(o!==d)}}catch(le){Ct(n,n.return,le)}}function ob(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{Q_(n,a)}catch(o){Ct(i,i.return,o)}}}function cb(i,n,a){a.props=pa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(o){Ct(i,n,o)}}function bo(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var o=i.stateNode;break;case 30:o=i.stateNode;break;default:o=i.stateNode}typeof a=="function"?i.refCleanup=a(o):a.current=o}}catch(u){Ct(i,n,u)}}function Sr(i,n){var a=i.ref,o=i.refCleanup;if(a!==null)if(typeof o=="function")try{o()}catch(u){Ct(i,n,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){Ct(i,n,u)}else a.current=null}function ub(i){var n=i.type,a=i.memoizedProps,o=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&o.focus();break e;case"img":a.src?o.src=a.src:a.srcSet&&(o.srcset=a.srcSet)}}catch(u){Ct(i,i.return,u)}}function hf(i,n,a){try{var o=i.stateNode;Zx(o,i.type,a,n),o[Bi]=n}catch(u){Ct(i,i.return,u)}}function hb(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&xs(i.type)||i.tag===4}function df(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||hb(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&&xs(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 ff(i,n,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(i),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=qi));else if(o!==4&&(o===27&&xs(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(ff(i,n,a),i=i.sibling;i!==null;)ff(i,n,a),i=i.sibling}function du(i,n,a){var o=i.tag;if(o===5||o===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(o!==4&&(o===27&&xs(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(du(i,n,a),i=i.sibling;i!==null;)du(i,n,a),i=i.sibling}function db(i){var n=i.stateNode,a=i.memoizedProps;try{for(var o=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Gi(n,o,a),n[$t]=i,n[Bi]=a}catch(d){Ct(i,i.return,d)}}var Ir=!1,_i=!1,pf=!1,fb=typeof WeakSet=="function"?WeakSet:Set,Oi=null;function Mx(i,n){if(i=i.containerInfo,Of=Lu,i=k_(i),ad(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var o=a.getSelection&&a.getSelection();if(o&&o.rangeCount!==0){a=o.anchorNode;var u=o.anchorOffset,d=o.focusNode;o=o.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,N=-1,V=0,le=0,ue=i,G=null;t:for(;;){for(var ee;ue!==a||u!==0&&ue.nodeType!==3||(C=_+u),ue!==d||o!==0&&ue.nodeType!==3||(N=_+o),ue.nodeType===3&&(_+=ue.nodeValue.length),(ee=ue.firstChild)!==null;)G=ue,ue=ee;for(;;){if(ue===i)break t;if(G===a&&++V===u&&(C=_),G===d&&++le===o&&(N=_),(ee=ue.nextSibling)!==null)break;ue=G,G=ue.parentNode}ue=ee}a=C===-1||N===-1?null:{start:C,end:N}}else a=null}a=a||{start:0,end:0}}else a=null;for(zf={focusedElem:i,selectionRange:a},Lu=!1,Oi=n;Oi!==null;)if(n=Oi,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Oi=i;else for(;Oi!==null;){switch(n=Oi,d=n.alternate,i=n.flags,n.tag){case 0:if((i&4)!==0&&(i=n.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&d!==null){i=void 0,a=n,u=d.memoizedProps,d=d.memoizedState,o=a.stateNode;try{var Oe=pa(a.type,u);i=o.getSnapshotBeforeUpdate(Oe,d),o.__reactInternalSnapshotBeforeUpdate=i}catch(Ye){Ct(a,a.return,Ye)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)Hf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":Hf(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(s(163))}if(i=n.sibling,i!==null){i.return=n.return,Oi=i;break}Oi=n.return}}function pb(i,n,a){var o=a.flags;switch(a.tag){case 0:case 11:case 15:Kr(i,a),o&4&&vo(5,a);break;case 1:if(Kr(i,a),o&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){Ct(a,a.return,_)}else{var u=pa(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){Ct(a,a.return,_)}}o&64&&ob(a),o&512&&bo(a,a.return);break;case 3:if(Kr(i,a),o&64&&(i=a.updateQueue,i!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{Q_(i,n)}catch(_){Ct(a,a.return,_)}}break;case 27:n===null&&o&4&&db(a);case 26:case 5:Kr(i,a),n===null&&o&4&&ub(a),o&512&&bo(a,a.return);break;case 12:Kr(i,a);break;case 31:Kr(i,a),o&4&&_b(i,a);break;case 13:Kr(i,a),o&4&&vb(i,a),o&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=Hx.bind(null,a),sk(i,a))));break;case 22:if(o=a.memoizedState!==null||Ir,!o){n=n!==null&&n.memoizedState!==null||_i,u=Ir;var d=_i;Ir=o,(_i=n)&&!d?Wr(i,a,(a.subtreeFlags&8772)!==0):Kr(i,a),Ir=u,_i=d}break;case 30:break;default:Kr(i,a)}}function mb(i){var n=i.alternate;n!==null&&(i.alternate=null,mb(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&$s(n)),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 Vt=null,pn=!1;function Ur(i,n,a){for(a=a.child;a!==null;)gb(i,n,a),a=a.sibling}function gb(i,n,a){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(bt,a)}catch{}switch(a.tag){case 26:_i||Sr(a,n),Ur(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:_i||Sr(a,n);var o=Vt,u=pn;xs(a.type)&&(Vt=a.stateNode,pn=!1),Ur(i,n,a),Do(a.stateNode),Vt=o,pn=u;break;case 5:_i||Sr(a,n);case 6:if(o=Vt,u=pn,Vt=null,Ur(i,n,a),Vt=o,pn=u,Vt!==null)if(pn)try{(Vt.nodeType===9?Vt.body:Vt.nodeName==="HTML"?Vt.ownerDocument.body:Vt).removeChild(a.stateNode)}catch(d){Ct(a,n,d)}else try{Vt.removeChild(a.stateNode)}catch(d){Ct(a,n,d)}break;case 18:Vt!==null&&(pn?(i=Vt,oy(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),Cl(i)):oy(Vt,a.stateNode));break;case 4:o=Vt,u=pn,Vt=a.stateNode.containerInfo,pn=!0,Ur(i,n,a),Vt=o,pn=u;break;case 0:case 11:case 14:case 15:_s(2,a,n),_i||_s(4,a,n),Ur(i,n,a);break;case 1:_i||(Sr(a,n),o=a.stateNode,typeof o.componentWillUnmount=="function"&&cb(a,n,o)),Ur(i,n,a);break;case 21:Ur(i,n,a);break;case 22:_i=(o=_i)||a.memoizedState!==null,Ur(i,n,a),_i=o;break;default:Ur(i,n,a)}}function _b(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Cl(i)}catch(a){Ct(n,n.return,a)}}}function vb(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Cl(i)}catch(a){Ct(n,n.return,a)}}function Nx(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new fb),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new fb),n;default:throw Error(s(435,i.tag))}}function fu(i,n){var a=Nx(i);n.forEach(function(o){if(!a.has(o)){a.add(o);var u=Ix.bind(null,i,o);o.then(u,u)}})}function mn(i,n){var a=n.deletions;if(a!==null)for(var o=0;o<a.length;o++){var u=a[o],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(xs(C.type)){Vt=C.stateNode,pn=!1;break e}break;case 5:Vt=C.stateNode,pn=!1;break e;case 3:case 4:Vt=C.stateNode.containerInfo,pn=!0;break e}C=C.return}if(Vt===null)throw Error(s(160));gb(d,_,u),Vt=null,pn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)bb(n,i),n=n.sibling}var lr=null;function bb(i,n){var a=i.alternate,o=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:mn(n,i),gn(i),o&4&&(_s(3,i,i.return),vo(3,i),_s(5,i,i.return));break;case 1:mn(n,i),gn(i),o&512&&(_i||a===null||Sr(a,a.return)),o&64&&Ir&&(i=i.updateQueue,i!==null&&(o=i.callbacks,o!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?o:a.concat(o))));break;case 26:var u=lr;if(mn(n,i),gn(i),o&512&&(_i||a===null||Sr(a,a.return)),o&4){var d=a!==null?a.memoizedState:null;if(o=i.memoizedState,a===null)if(o===null)if(i.stateNode===null){e:{o=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Jn]||d[$t]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(o),u.head.insertBefore(d,u.querySelector("head > title"))),Gi(d,o,a),d[$t]=i,It(d),o=d;break e;case"link":var _=by("link","href",u).get(o+(a.href||""));if(_){for(var C=0;C<_.length;C++)if(d=_[C],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(C,1);break t}}d=u.createElement(o),Gi(d,o,a),u.head.appendChild(d);break;case"meta":if(_=by("meta","content",u).get(o+(a.content||""))){for(C=0;C<_.length;C++)if(d=_[C],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(C,1);break t}}d=u.createElement(o),Gi(d,o,a),u.head.appendChild(d);break;default:throw Error(s(468,o))}d[$t]=i,It(d),o=d}i.stateNode=o}else yy(u,i.type,i.stateNode);else i.stateNode=vy(u,o,i.memoizedProps);else d!==o?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,o===null?yy(u,i.type,i.stateNode):vy(u,o,i.memoizedProps)):o===null&&i.stateNode!==null&&hf(i,i.memoizedProps,a.memoizedProps)}break;case 27:mn(n,i),gn(i),o&512&&(_i||a===null||Sr(a,a.return)),a!==null&&o&4&&hf(i,i.memoizedProps,a.memoizedProps);break;case 5:if(mn(n,i),gn(i),o&512&&(_i||a===null||Sr(a,a.return)),i.flags&32){u=i.stateNode;try{en(u,"")}catch(Oe){Ct(i,i.return,Oe)}}o&4&&i.stateNode!=null&&(u=i.memoizedProps,hf(i,u,a!==null?a.memoizedProps:u)),o&1024&&(pf=!0);break;case 6:if(mn(n,i),gn(i),o&4){if(i.stateNode===null)throw Error(s(162));o=i.memoizedProps,a=i.stateNode;try{a.nodeValue=o}catch(Oe){Ct(i,i.return,Oe)}}break;case 3:if(Ru=null,u=lr,lr=Tu(n.containerInfo),mn(n,i),lr=u,gn(i),o&4&&a!==null&&a.memoizedState.isDehydrated)try{Cl(n.containerInfo)}catch(Oe){Ct(i,i.return,Oe)}pf&&(pf=!1,yb(i));break;case 4:o=lr,lr=Tu(i.stateNode.containerInfo),mn(n,i),gn(i),lr=o;break;case 12:mn(n,i),gn(i);break;case 31:mn(n,i),gn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,fu(i,o)));break;case 13:mn(n,i),gn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(mu=Ve()),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,fu(i,o)));break;case 22:u=i.memoizedState!==null;var N=a!==null&&a.memoizedState!==null,V=Ir,le=_i;if(Ir=V||u,_i=le||N,mn(n,i),_i=le,Ir=V,gn(i),o&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||N||Ir||_i||ma(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){N=a=n;try{if(d=N.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=N.stateNode;var ue=N.memoizedProps.style,G=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;C.style.display=G==null||typeof G=="boolean"?"":(""+G).trim()}}catch(Oe){Ct(N,N.return,Oe)}}}else if(n.tag===6){if(a===null){N=n;try{N.stateNode.nodeValue=u?"":N.memoizedProps}catch(Oe){Ct(N,N.return,Oe)}}}else if(n.tag===18){if(a===null){N=n;try{var ee=N.stateNode;u?cy(ee,!0):cy(N.stateNode,!1)}catch(Oe){Ct(N,N.return,Oe)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===i)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}o&4&&(o=i.updateQueue,o!==null&&(a=o.retryQueue,a!==null&&(o.retryQueue=null,fu(i,a))));break;case 19:mn(n,i),gn(i),o&4&&(o=i.updateQueue,o!==null&&(i.updateQueue=null,fu(i,o)));break;case 30:break;case 21:break;default:mn(n,i),gn(i)}}function gn(i){var n=i.flags;if(n&2){try{for(var a,o=i.return;o!==null;){if(hb(o)){a=o;break}o=o.return}if(a==null)throw Error(s(160));switch(a.tag){case 27:var u=a.stateNode,d=df(i);du(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(en(_,""),a.flags&=-33);var C=df(i);du(i,C,_);break;case 3:case 4:var N=a.stateNode.containerInfo,V=df(i);ff(i,V,N);break;default:throw Error(s(161))}}catch(le){Ct(i,i.return,le)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function yb(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;yb(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Kr(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)pb(i,n.alternate,n),n=n.sibling}function ma(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:_s(4,n,n.return),ma(n);break;case 1:Sr(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&cb(n,n.return,a),ma(n);break;case 27:Do(n.stateNode);case 26:case 5:Sr(n,n.return),ma(n);break;case 22:n.memoizedState===null&&ma(n);break;case 30:ma(n);break;default:ma(n)}i=i.sibling}}function Wr(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Wr(u,d,a),vo(4,d);break;case 1:if(Wr(u,d,a),o=d,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(V){Ct(o,o.return,V)}if(o=d,u=o.updateQueue,u!==null){var C=o.stateNode;try{var N=u.shared.hiddenCallbacks;if(N!==null)for(u.shared.hiddenCallbacks=null,u=0;u<N.length;u++)Z_(N[u],C)}catch(V){Ct(o,o.return,V)}}a&&_&64&&ob(d),bo(d,d.return);break;case 27:db(d);case 26:case 5:Wr(u,d,a),a&&o===null&&_&4&&ub(d),bo(d,d.return);break;case 12:Wr(u,d,a);break;case 31:Wr(u,d,a),a&&_&4&&_b(u,d);break;case 13:Wr(u,d,a),a&&_&4&&vb(u,d);break;case 22:d.memoizedState===null&&Wr(u,d,a),bo(d,d.return);break;case 30:break;default:Wr(u,d,a)}n=n.sibling}}function mf(i,n){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&ro(a))}function gf(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&ro(i))}function or(i,n,a,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Sb(i,n,a,o),n=n.sibling}function Sb(i,n,a,o){var u=n.flags;switch(n.tag){case 0:case 11:case 15:or(i,n,a,o),u&2048&&vo(9,n);break;case 1:or(i,n,a,o);break;case 3:or(i,n,a,o),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&ro(i)));break;case 12:if(u&2048){or(i,n,a,o),i=n.stateNode;try{var d=n.memoizedProps,_=d.id,C=d.onPostCommit;typeof C=="function"&&C(_,n.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(N){Ct(n,n.return,N)}}else or(i,n,a,o);break;case 31:or(i,n,a,o);break;case 13:or(i,n,a,o);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?or(i,n,a,o):yo(i,n):d._visibility&2?or(i,n,a,o):(d._visibility|=2,dl(i,n,a,o,(n.subtreeFlags&10256)!==0||!1)),u&2048&&mf(_,n);break;case 24:or(i,n,a,o),u&2048&&gf(n.alternate,n);break;default:or(i,n,a,o)}}function dl(i,n,a,o,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,N=o,V=_.flags;switch(_.tag){case 0:case 11:case 15:dl(d,_,C,N,u),vo(8,_);break;case 23:break;case 22:var le=_.stateNode;_.memoizedState!==null?le._visibility&2?dl(d,_,C,N,u):yo(d,_):(le._visibility|=2,dl(d,_,C,N,u)),u&&V&2048&&mf(_.alternate,_);break;case 24:dl(d,_,C,N,u),u&&V&2048&&gf(_.alternate,_);break;default:dl(d,_,C,N,u)}n=n.sibling}}function yo(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,o=n,u=o.flags;switch(o.tag){case 22:yo(a,o),u&2048&&mf(o.alternate,o);break;case 24:yo(a,o),u&2048&&gf(o.alternate,o);break;default:yo(a,o)}n=n.sibling}}var So=8192;function fl(i,n,a){if(i.subtreeFlags&So)for(i=i.child;i!==null;)wb(i,n,a),i=i.sibling}function wb(i,n,a){switch(i.tag){case 26:fl(i,n,a),i.flags&So&&i.memoizedState!==null&&_k(a,lr,i.memoizedState,i.memoizedProps);break;case 5:fl(i,n,a);break;case 3:case 4:var o=lr;lr=Tu(i.stateNode.containerInfo),fl(i,n,a),lr=o;break;case 22:i.memoizedState===null&&(o=i.alternate,o!==null&&o.memoizedState!==null?(o=So,So=16777216,fl(i,n,a),So=o):fl(i,n,a));break;default:fl(i,n,a)}}function Cb(i){var n=i.alternate;if(n!==null&&(i=n.child,i!==null)){n.child=null;do n=i.sibling,i.sibling=null,i=n;while(i!==null)}}function wo(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var o=n[a];Oi=o,kb(o,i)}Cb(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)xb(i),i=i.sibling}function xb(i){switch(i.tag){case 0:case 11:case 15:wo(i),i.flags&2048&&_s(9,i,i.return);break;case 3:wo(i);break;case 12:wo(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,pu(i)):wo(i);break;default:wo(i)}}function pu(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var o=n[a];Oi=o,kb(o,i)}Cb(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:_s(8,n,n.return),pu(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,pu(n));break;default:pu(n)}i=i.sibling}}function kb(i,n){for(;Oi!==null;){var a=Oi;switch(a.tag){case 0:case 11:case 15:_s(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var o=a.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:ro(a.memoizedState.cache)}if(o=a.child,o!==null)o.return=a,Oi=o;else e:for(a=i;Oi!==null;){o=Oi;var u=o.sibling,d=o.return;if(mb(o),o===a){Oi=null;break e}if(u!==null){u.return=d,Oi=u;break e}Oi=d}}}var Ax={getCacheForType:function(i){var n=Yi(pi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Yi(pi).controller.signal}},Lx=typeof WeakMap=="function"?WeakMap:Map,yt=0,Lt=null,ut=null,ft=0,wt=0,Mn=null,vs=!1,pl=!1,_f=!1,Fr=0,ri=0,bs=0,ga=0,vf=0,Nn=0,ml=0,Co=null,_n=null,bf=!1,mu=0,Eb=0,gu=1/0,_u=null,ys=null,Ei=0,Ss=null,gl=null,qr=0,yf=0,Sf=null,Tb=null,xo=0,wf=null;function An(){return(yt&2)!==0&&ft!==0?ft&-ft:R.T!==null?Df():Li()}function Db(){if(Nn===0)if((ft&536870912)===0||mt){var i=Ai;Ai<<=1,(Ai&3932160)===0&&(Ai=262144),Nn=i}else Nn=536870912;return i=Dn.current,i!==null&&(i.flags|=32),Nn}function vn(i,n,a){(i===Lt&&(wt===2||wt===9)||i.cancelPendingCommit!==null)&&(_l(i,0),ws(i,ft,Nn,!1)),Wi(i,a),((yt&2)===0||i!==Lt)&&(i===Lt&&((yt&2)===0&&(ga|=a),ri===4&&ws(i,ft,Nn,!1)),wr(i))}function Rb(i,n,a){if((yt&6)!==0)throw Error(s(327));var o=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Gt(i,n),u=o?zx(i,n):xf(i,n,!0),d=o;do{if(u===0){pl&&!o&&ws(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!Bx(a)){u=xf(i,n,!1),d=!1;continue}if(u===2){if(d=n,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){n=_;e:{var C=i;u=Co;var N=C.current.memoizedState.isDehydrated;if(N&&(_l(C,_).flags|=256),_=xf(C,_,!1),_!==2){if(_f&&!N){C.errorRecoveryDisabledLanes|=d,ga|=d,u=4;break e}d=_n,_n=u,d!==null&&(_n===null?_n=d:_n.push.apply(_n,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){_l(i,0),ws(i,n,0,!0);break}e:{switch(o=i,d=u,d){case 0:case 1:throw Error(s(345));case 4:if((n&4194048)!==n)break;case 6:ws(o,n,Nn,!vs);break e;case 2:_n=null;break;case 3:case 5:break;default:throw Error(s(329))}if((n&62914560)===n&&(u=mu+300-Ve(),10<u)){if(ws(o,n,Nn,!vs),qt(o,0,!0)!==0)break e;qr=n,o.timeoutHandle=ay(Mb.bind(null,o,a,_n,_u,bf,n,Nn,ga,ml,vs,d,"Throttled",-0,0),u);break e}Mb(o,a,_n,_u,bf,n,Nn,ga,ml,vs,d,null,-0,0)}}break}while(!0);wr(i)}function Mb(i,n,a,o,u,d,_,C,N,V,le,ue,G,ee){if(i.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qi},wb(n,d,ue);var Oe=(d&62914560)===d?mu-Ve():(d&4194048)===d?Eb-Ve():0;if(Oe=vk(ue,Oe),Oe!==null){qr=d,i.cancelPendingCommit=Oe(Pb.bind(null,i,n,d,a,o,u,_,C,N,le,ue,null,G,ee)),ws(i,d,_,!V);return}}Pb(i,n,d,a,o,u,_,C,N)}function Bx(i){for(var n=i;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var o=0;o<a.length;o++){var u=a[o],d=u.getSnapshot;u=u.value;try{if(!En(d(),u))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function ws(i,n,a,o){n&=~vf,n&=~ga,i.suspendedLanes|=n,i.pingedLanes&=~n,o&&(i.warmLanes|=n),o=i.expirationTimes;for(var u=n;0<u;){var d=31-F(u),_=1<<d;o[d]=-1,u&=~_}a!==0&&Et(i,a,n)}function vu(){return(yt&6)===0?(ko(0),!1):!0}function Cf(){if(ut!==null){if(wt===0)var i=ut.return;else i=ut,Br=la=null,Pd(i),ll=null,ao=0,i=ut;for(;i!==null;)lb(i.alternate,i),i=i.return;ut=null}}function _l(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,ek(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),qr=0,Cf(),Lt=i,ut=a=Ar(i.current,null),ft=n,wt=0,Mn=null,vs=!1,pl=Gt(i,n),_f=!1,ml=Nn=vf=ga=bs=ri=0,_n=Co=null,bf=!1,(n&8)!==0&&(n|=n&32);var o=i.entangledLanes;if(o!==0)for(i=i.entanglements,o&=n;0<o;){var u=31-F(o),d=1<<u;n|=i[u],o&=~d}return Fr=n,Hc(),a}function Nb(i,n){et=null,R.H=mo,n===al||n===Vc?(n=V_(),wt=3):n===Ed?(n=V_(),wt=4):wt=n===ef?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Mn=n,ut===null&&(ri=1,lu(i,In(n,i.current)))}function Ab(){var i=Dn.current;return i===null?!0:(ft&4194048)===ft?Fn===null:(ft&62914560)===ft||(ft&536870912)!==0?i===Fn:!1}function Lb(){var i=R.H;return R.H=mo,i===null?mo:i}function Bb(){var i=R.A;return R.A=Ax,i}function bu(){ri=4,vs||(ft&4194048)!==ft&&Dn.current!==null||(pl=!0),(bs&134217727)===0&&(ga&134217727)===0||Lt===null||ws(Lt,ft,Nn,!1)}function xf(i,n,a){var o=yt;yt|=2;var u=Lb(),d=Bb();(Lt!==i||ft!==n)&&(_u=null,_l(i,n)),n=!1;var _=ri;e:do try{if(wt!==0&&ut!==null){var C=ut,N=Mn;switch(wt){case 8:Cf(),_=6;break e;case 3:case 2:case 9:case 6:Dn.current===null&&(n=!0);var V=wt;if(wt=0,Mn=null,vl(i,C,N,V),a&&pl){_=0;break e}break;default:V=wt,wt=0,Mn=null,vl(i,C,N,V)}}Ox(),_=ri;break}catch(le){Nb(i,le)}while(!0);return n&&i.shellSuspendCounter++,Br=la=null,yt=o,R.H=u,R.A=d,ut===null&&(Lt=null,ft=0,Hc()),_}function Ox(){for(;ut!==null;)Ob(ut)}function zx(i,n){var a=yt;yt|=2;var o=Lb(),u=Bb();Lt!==i||ft!==n?(_u=null,gu=Ve()+500,_l(i,n)):pl=Gt(i,n);e:do try{if(wt!==0&&ut!==null){n=ut;var d=Mn;t:switch(wt){case 1:wt=0,Mn=null,vl(i,n,d,1);break;case 2:case 9:if(q_(d)){wt=0,Mn=null,zb(n);break}n=function(){wt!==2&&wt!==9||Lt!==i||(wt=7),wr(i)},d.then(n,n);break e;case 3:wt=7;break e;case 4:wt=5;break e;case 7:q_(d)?(wt=0,Mn=null,zb(n)):(wt=0,Mn=null,vl(i,n,d,7));break;case 5:var _=null;switch(ut.tag){case 26:_=ut.memoizedState;case 5:case 27:var C=ut;if(_?Sy(_):C.stateNode.complete){wt=0,Mn=null;var N=C.sibling;if(N!==null)ut=N;else{var V=C.return;V!==null?(ut=V,yu(V)):ut=null}break t}}wt=0,Mn=null,vl(i,n,d,5);break;case 6:wt=0,Mn=null,vl(i,n,d,6);break;case 8:Cf(),ri=6;break e;default:throw Error(s(462))}}jx();break}catch(le){Nb(i,le)}while(!0);return Br=la=null,R.H=o,R.A=u,yt=a,ut!==null?0:(Lt=null,ft=0,Hc(),ri)}function jx(){for(;ut!==null&&!at();)Ob(ut)}function Ob(i){var n=sb(i.alternate,i,Fr);i.memoizedProps=i.pendingProps,n===null?yu(i):ut=n}function zb(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=Jv(a,n,n.pendingProps,n.type,void 0,ft);break;case 11:n=Jv(a,n,n.pendingProps,n.type.render,n.ref,ft);break;case 5:Pd(n);default:lb(a,n),n=ut=B_(n,Fr),n=sb(a,n,Fr)}i.memoizedProps=i.pendingProps,n===null?yu(i):ut=n}function vl(i,n,a,o){Br=la=null,Pd(n),ll=null,ao=0;var u=n.return;try{if(kx(i,u,n,a,ft)){ri=1,lu(i,In(a,i.current)),ut=null;return}}catch(d){if(u!==null)throw ut=u,d;ri=1,lu(i,In(a,i.current)),ut=null;return}n.flags&32768?(mt||o===1?i=!0:pl||(ft&536870912)!==0?i=!1:(vs=i=!0,(o===2||o===9||o===3||o===6)&&(o=Dn.current,o!==null&&o.tag===13&&(o.flags|=16384))),jb(n,i)):yu(n)}function yu(i){var n=i;do{if((n.flags&32768)!==0){jb(n,vs);return}i=n.return;var a=Dx(n.alternate,n,Fr);if(a!==null){ut=a;return}if(n=n.sibling,n!==null){ut=n;return}ut=n=i}while(n!==null);ri===0&&(ri=5)}function jb(i,n){do{var a=Rx(i.alternate,i);if(a!==null){a.flags&=32767,ut=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){ut=i;return}ut=i=a}while(i!==null);ri=6,ut=null}function Pb(i,n,a,o,u,d,_,C,N){i.cancelPendingCommit=null;do Su();while(Ei!==0);if((yt&6)!==0)throw Error(s(327));if(n!==null){if(n===i.current)throw Error(s(177));if(d=n.lanes|n.childLanes,d|=hd,Ht(i,a,d,_,C,N),i===Lt&&(ut=Lt=null,ft=0),gl=n,Ss=i,qr=a,yf=d,Sf=u,Tb=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,Ux(_e,function(){return Wb(),null})):(i.callbackNode=null,i.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=R.T,R.T=null,u=X.p,X.p=2,_=yt,yt|=4;try{Mx(i,n,a)}finally{yt=_,X.p=u,R.T=o}}Ei=1,Hb(),Ib(),Ub()}}function Hb(){if(Ei===1){Ei=0;var i=Ss,n=gl,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=yt;yt|=4;try{bb(n,i);var d=zf,_=k_(i.containerInfo),C=d.focusedElem,N=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&x_(C.ownerDocument.documentElement,C)){if(N!==null&&ad(C)){var V=N.start,le=N.end;if(le===void 0&&(le=V),"selectionStart"in C)C.selectionStart=V,C.selectionEnd=Math.min(le,C.value.length);else{var ue=C.ownerDocument||document,G=ue&&ue.defaultView||window;if(G.getSelection){var ee=G.getSelection(),Oe=C.textContent.length,Ye=Math.min(N.start,Oe),Rt=N.end===void 0?Ye:Math.min(N.end,Oe);!ee.extend&&Ye>Rt&&(_=Rt,Rt=Ye,Ye=_);var I=C_(C,Ye),O=C_(C,Rt);if(I&&O&&(ee.rangeCount!==1||ee.anchorNode!==I.node||ee.anchorOffset!==I.offset||ee.focusNode!==O.node||ee.focusOffset!==O.offset)){var $=ue.createRange();$.setStart(I.node,I.offset),ee.removeAllRanges(),Ye>Rt?(ee.addRange($),ee.extend(O.node,O.offset)):($.setEnd(O.node,O.offset),ee.addRange($))}}}}for(ue=[],ee=C;ee=ee.parentNode;)ee.nodeType===1&&ue.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<ue.length;C++){var ce=ue[C];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}Lu=!!Of,zf=Of=null}finally{yt=u,X.p=o,R.T=a}}i.current=n,Ei=2}}function Ib(){if(Ei===2){Ei=0;var i=Ss,n=gl,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=R.T,R.T=null;var o=X.p;X.p=2;var u=yt;yt|=4;try{pb(i,n.alternate,n)}finally{yt=u,X.p=o,R.T=a}}Ei=3}}function Ub(){if(Ei===4||Ei===3){Ei=0,Xt();var i=Ss,n=gl,a=qr,o=Tb;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ei=5:(Ei=0,gl=Ss=null,Kb(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(ys=null),wn(a),n=n.stateNode,Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(bt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=R.T,u=X.p,X.p=2,R.T=null;try{for(var d=i.onRecoverableError,_=0;_<o.length;_++){var C=o[_];d(C.value,{componentStack:C.stack})}}finally{R.T=n,X.p=u}}(qr&3)!==0&&Su(),wr(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===wf?xo++:(xo=0,wf=i):xo=0,ko(0)}}function Kb(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,ro(n)))}function Su(){return Hb(),Ib(),Ub(),Wb()}function Wb(){if(Ei!==5)return!1;var i=Ss,n=yf;yf=0;var a=wn(qr),o=R.T,u=X.p;try{X.p=32>a?32:a,R.T=null,a=Sf,Sf=null;var d=Ss,_=qr;if(Ei=0,gl=Ss=null,qr=0,(yt&6)!==0)throw Error(s(331));var C=yt;if(yt|=4,xb(d.current),Sb(d,d.current,_,a),yt=C,ko(0,!1),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(bt,d)}catch{}return!0}finally{X.p=u,R.T=o,Kb(i,n)}}function Fb(i,n,a){n=In(a,n),n=Jd(i.stateNode,n,2),i=ps(i,n,2),i!==null&&(Wi(i,2),wr(i))}function Ct(i,n,a){if(i.tag===3)Fb(i,i,a);else for(;n!==null;){if(n.tag===3){Fb(n,i,a);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(ys===null||!ys.has(o))){i=In(a,i),a=qv(2),o=ps(n,a,2),o!==null&&($v(a,o,n,i),Wi(o,2),wr(o));break}}n=n.return}}function kf(i,n,a){var o=i.pingCache;if(o===null){o=i.pingCache=new Lx;var u=new Set;o.set(n,u)}else u=o.get(n),u===void 0&&(u=new Set,o.set(n,u));u.has(a)||(_f=!0,u.add(a),i=Px.bind(null,i,n,a),n.then(i,i))}function Px(i,n,a){var o=i.pingCache;o!==null&&o.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Lt===i&&(ft&a)===a&&(ri===4||ri===3&&(ft&62914560)===ft&&300>Ve()-mu?(yt&2)===0&&_l(i,0):vf|=a,ml===ft&&(ml=0)),wr(i)}function qb(i,n){n===0&&(n=li()),i=ra(i,n),i!==null&&(Wi(i,n),wr(i))}function Hx(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),qb(i,a)}function Ix(i,n){var a=0;switch(i.tag){case 31:case 13:var o=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:o=i.stateNode;break;case 22:o=i.stateNode._retryCache;break;default:throw Error(s(314))}o!==null&&o.delete(n),qb(i,a)}function Ux(i,n){return Be(i,n)}var wu=null,bl=null,Ef=!1,Cu=!1,Tf=!1,Cs=0;function wr(i){i!==bl&&i.next===null&&(bl===null?wu=bl=i:bl=bl.next=i),Cu=!0,Ef||(Ef=!0,Wx())}function ko(i,n){if(!Tf&&Cu){Tf=!0;do for(var a=!1,o=wu;o!==null;){if(i!==0){var u=o.pendingLanes;if(u===0)var d=0;else{var _=o.suspendedLanes,C=o.pingedLanes;d=(1<<31-F(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Xb(o,d))}else d=ft,d=qt(o,o===Lt?d:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(d&3)===0||Gt(o,d)||(a=!0,Xb(o,d));o=o.next}while(a);Tf=!1}}function Kx(){$b()}function $b(){Cu=Ef=!1;var i=0;Cs!==0&&Jx()&&(i=Cs);for(var n=Ve(),a=null,o=wu;o!==null;){var u=o.next,d=Vb(o,n);d===0?(o.next=null,a===null?wu=u:a.next=u,u===null&&(bl=a)):(a=o,(i!==0||(d&3)!==0)&&(Cu=!0)),o=u}Ei!==0&&Ei!==5||ko(i),Cs!==0&&(Cs=0)}function Vb(i,n){for(var a=i.suspendedLanes,o=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-F(d),C=1<<_,N=u[_];N===-1?((C&a)===0||(C&o)!==0)&&(u[_]=Ci(C,n)):N<=n&&(i.expiredLanes|=C),d&=~C}if(n=Lt,a=ft,a=qt(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o=i.callbackNode,a===0||i===n&&(wt===2||wt===9)||i.cancelPendingCommit!==null)return o!==null&&o!==null&&je(o),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Gt(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(o!==null&&je(o),wn(a)){case 2:case 8:a=kt;break;case 32:a=_e;break;case 268435456:a=Je;break;default:a=_e}return o=Yb.bind(null,i),a=Be(a,o),i.callbackPriority=n,i.callbackNode=a,n}return o!==null&&o!==null&&je(o),i.callbackPriority=2,i.callbackNode=null,2}function Yb(i,n){if(Ei!==0&&Ei!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(Su()&&i.callbackNode!==a)return null;var o=ft;return o=qt(i,i===Lt?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),o===0?null:(Rb(i,o,n),Vb(i,Ve()),i.callbackNode!=null&&i.callbackNode===a?Yb.bind(null,i):null)}function Xb(i,n){if(Su())return null;Rb(i,n,!0)}function Wx(){tk(function(){(yt&6)!==0?Be(ti,Kx):$b()})}function Df(){if(Cs===0){var i=rl;i===0&&(i=wi,wi<<=1,(wi&261888)===0&&(wi=256)),Cs=i}return Cs}function Gb(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:xn(""+i)}function Zb(i,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,i.id&&a.setAttribute("form",i.id),n.parentNode.insertBefore(a,n),i=new FormData(i),a.parentNode.removeChild(a),i}function Fx(i,n,a,o,u){if(n==="submit"&&a&&a.stateNode===u){var d=Gb((u[Bi]||null).action),_=o.submitter;_&&(n=(n=_[Bi]||null)?Gb(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new He("action","action",null,o,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Cs!==0){var N=_?Zb(u,_):new FormData(u);Vd(a,{pending:!0,data:N,method:u.method,action:d},null,N)}}else typeof d=="function"&&(C.preventDefault(),N=_?Zb(u,_):new FormData(u),Vd(a,{pending:!0,data:N,method:u.method,action:d},d,N))},currentTarget:u}]})}}for(var Rf=0;Rf<ud.length;Rf++){var Mf=ud[Rf],qx=Mf.toLowerCase(),$x=Mf[0].toUpperCase()+Mf.slice(1);ar(qx,"on"+$x)}ar(D_,"onAnimationEnd"),ar(R_,"onAnimationIteration"),ar(M_,"onAnimationStart"),ar("dblclick","onDoubleClick"),ar("focusin","onFocus"),ar("focusout","onBlur"),ar(ox,"onTransitionRun"),ar(cx,"onTransitionStart"),ar(ux,"onTransitionCancel"),ar(N_,"onTransitionEnd"),Pn("onMouseEnter",["mouseout","mouseover"]),Pn("onMouseLeave",["mouseout","mouseover"]),Pn("onPointerEnter",["pointerout","pointerover"]),Pn("onPointerLeave",["pointerout","pointerover"]),nr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),nr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),nr("onBeforeInput",["compositionend","keypress","textInput","paste"]),nr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),nr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Eo="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(" "),Vx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Eo));function Qb(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var o=i[a],u=o.event;o=o.listeners;e:{var d=void 0;if(n)for(var _=o.length-1;0<=_;_--){var C=o[_],N=C.instance,V=C.currentTarget;if(C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(le){Pc(le)}u.currentTarget=null,d=N}else for(_=0;_<o.length;_++){if(C=o[_],N=C.instance,V=C.currentTarget,C=C.listener,N!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(le){Pc(le)}u.currentTarget=null,d=N}}}}function ht(i,n){var a=n[Rr];a===void 0&&(a=n[Rr]=new Set);var o=i+"__bubble";a.has(o)||(Jb(n,i,2,!1),a.add(o))}function Nf(i,n,a){var o=0;n&&(o|=4),Jb(a,i,o,n)}var xu="_reactListening"+Math.random().toString(36).slice(2);function Af(i){if(!i[xu]){i[xu]=!0,Ia.forEach(function(a){a!=="selectionchange"&&(Vx.has(a)||Nf(a,!1,i),Nf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[xu]||(n[xu]=!0,Nf("selectionchange",!1,n))}}function Jb(i,n,a,o){switch(Dy(n)){case 2:var u=Sk;break;case 8:u=wk;break;default:u=Vf}a=u.bind(null,n,a,i),u=void 0,!ss||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),o?u!==void 0?i.addEventListener(n,a,{capture:!0,passive:u}):i.addEventListener(n,a,!0):u!==void 0?i.addEventListener(n,a,{passive:u}):i.addEventListener(n,a,!1)}function Lf(i,n,a,o,u){var d=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var _=o.tag;if(_===3||_===4){var C=o.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=o.return;_!==null;){var N=_.tag;if((N===3||N===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=er(C),_===null)return;if(N=_.tag,N===5||N===6||N===26||N===27){o=d=_;continue e}C=C.parentNode}}o=o.return}Ya(function(){var V=d,le=rs(a),ue=[];e:{var G=A_.get(i);if(G!==void 0){var ee=He,Oe=i;switch(i){case"keypress":if(z(a)===0)break e;case"keydown":case"keyup":ee=IC;break;case"focusin":Oe="focus",ee=ii;break;case"focusout":Oe="blur",ee=ii;break;case"beforeblur":case"afterblur":ee=ii;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ee=We;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ee=Ze;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ee=WC;break;case D_:case R_:case M_:ee=Qt;break;case N_:ee=qC;break;case"scroll":case"scrollend":ee=fi;break;case"wheel":ee=VC;break;case"copy":case"cut":case"paste":ee=ta;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ee=c_;break;case"toggle":case"beforetoggle":ee=XC}var Ye=(n&4)!==0,Rt=!Ye&&(i==="scroll"||i==="scrollend"),I=Ye?G!==null?G+"Capture":null:G;Ye=[];for(var O=V,$;O!==null;){var ce=O;if($=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||$===null||I===null||(ce=fn(O,I),ce!=null&&Ye.push(To(O,ce,$))),Rt)break;O=O.return}0<Ye.length&&(G=new ee(G,Oe,null,a,le),ue.push({event:G,listeners:Ye}))}}if((n&7)===0){e:{if(G=i==="mouseover"||i==="pointerover",ee=i==="mouseout"||i==="pointerout",G&&a!==Js&&(Oe=a.relatedTarget||a.fromElement)&&(er(Oe)||Oe[ci]))break e;if((ee||G)&&(G=le.window===le?le:(G=le.ownerDocument)?G.defaultView||G.parentWindow:window,ee?(Oe=a.relatedTarget||a.toElement,ee=V,Oe=Oe?er(Oe):null,Oe!==null&&(Rt=c(Oe),Ye=Oe.tag,Oe!==Rt||Ye!==5&&Ye!==27&&Ye!==6)&&(Oe=null)):(ee=null,Oe=V),ee!==Oe)){if(Ye=We,ce="onMouseLeave",I="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(Ye=c_,ce="onPointerLeave",I="onPointerEnter",O="pointer"),Rt=ee==null?G:jn(ee),$=Oe==null?G:jn(Oe),G=new Ye(ce,O+"leave",ee,a,le),G.target=Rt,G.relatedTarget=$,ce=null,er(le)===V&&(Ye=new Ye(I,O+"enter",Oe,a,le),Ye.target=$,Ye.relatedTarget=Rt,ce=Ye),Rt=ce,ee&&Oe)t:{for(Ye=Yx,I=ee,O=Oe,$=0,ce=I;ce;ce=Ye(ce))$++;ce=0;for(var qe=O;qe;qe=Ye(qe))ce++;for(;0<$-ce;)I=Ye(I),$--;for(;0<ce-$;)O=Ye(O),ce--;for(;$--;){if(I===O||O!==null&&I===O.alternate){Ye=I;break t}I=Ye(I),O=Ye(O)}Ye=null}else Ye=null;ee!==null&&ey(ue,G,ee,Ye,!1),Oe!==null&&Rt!==null&&ey(ue,Rt,Oe,Ye,!0)}}e:{if(G=V?jn(V):window,ee=G.nodeName&&G.nodeName.toLowerCase(),ee==="select"||ee==="input"&&G.type==="file")var _t=__;else if(m_(G))if(v_)_t=sx;else{_t=nx;var Ie=ix}else ee=G.nodeName,!ee||ee.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?V&&gr(V.elementType)&&(_t=__):_t=rx;if(_t&&(_t=_t(i,V))){g_(ue,_t,a,le);break e}Ie&&Ie(i,G,V),i==="focusout"&&V&&G.type==="number"&&V.memoizedProps.value!=null&&Nr(G,"number",G.value)}switch(Ie=V?jn(V):window,i){case"focusin":(m_(Ie)||Ie.contentEditable==="true")&&(Ga=Ie,ld=V,to=null);break;case"focusout":to=ld=Ga=null;break;case"mousedown":od=!0;break;case"contextmenu":case"mouseup":case"dragend":od=!1,E_(ue,a,le);break;case"selectionchange":if(lx)break;case"keydown":case"keyup":E_(ue,a,le)}var nt;if(nd)e:{switch(i){case"compositionstart":var pt="onCompositionStart";break e;case"compositionend":pt="onCompositionEnd";break e;case"compositionupdate":pt="onCompositionUpdate";break e}pt=void 0}else Xa?f_(i,a)&&(pt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(pt="onCompositionStart");pt&&(u_&&a.locale!=="ko"&&(Xa||pt!=="onCompositionStart"?pt==="onCompositionEnd"&&Xa&&(nt=E()):(ln=le,as="value"in ln?ln.value:ln.textContent,Xa=!0)),Ie=ku(V,pt),0<Ie.length&&(pt=new Gl(pt,i,null,a,le),ue.push({event:pt,listeners:Ie}),nt?pt.data=nt:(nt=p_(a),nt!==null&&(pt.data=nt)))),(nt=ZC?QC(i,a):JC(i,a))&&(pt=ku(V,"onBeforeInput"),0<pt.length&&(Ie=new Gl("onBeforeInput","beforeinput",null,a,le),ue.push({event:Ie,listeners:pt}),Ie.data=nt)),Fx(ue,i,V,a,le)}Qb(ue,n)})}function To(i,n,a){return{instance:i,listener:n,currentTarget:a}}function ku(i,n){for(var a=n+"Capture",o=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=fn(i,a),u!=null&&o.unshift(To(i,u,d)),u=fn(i,n),u!=null&&o.push(To(i,u,d))),i.tag===3)return o;i=i.return}return[]}function Yx(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function ey(i,n,a,o,u){for(var d=n._reactName,_=[];a!==null&&a!==o;){var C=a,N=C.alternate,V=C.stateNode;if(C=C.tag,N!==null&&N===o)break;C!==5&&C!==26&&C!==27||V===null||(N=V,u?(V=fn(a,d),V!=null&&_.unshift(To(a,V,N))):u||(V=fn(a,d),V!=null&&_.push(To(a,V,N)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var Xx=/\r\n?/g,Gx=/\u0000|\uFFFD/g;function ty(i){return(typeof i=="string"?i:""+i).replace(Xx,`
|
|
10
|
+
`).replace(Gx,"")}function iy(i,n){return n=ty(n),ty(i)===n}function Dt(i,n,a,o,u,d){switch(a){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||en(i,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&en(i,""+o);break;case"className":is(i,"class",o);break;case"tabIndex":is(i,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":is(i,a,o);break;case"style":Zs(i,o,d);break;case"data":if(n!=="object"){is(i,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=xn(""+o),i.setAttribute(a,o);break;case"action":case"formAction":if(typeof o=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="formAction"?(n!=="input"&&Dt(i,n,"name",u.name,u,null),Dt(i,n,"formEncType",u.formEncType,u,null),Dt(i,n,"formMethod",u.formMethod,u,null),Dt(i,n,"formTarget",u.formTarget,u,null)):(Dt(i,n,"encType",u.encType,u,null),Dt(i,n,"method",u.method,u,null),Dt(i,n,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){i.removeAttribute(a);break}o=xn(""+o),i.setAttribute(a,o);break;case"onClick":o!=null&&(i.onclick=qi);break;case"onScroll":o!=null&&ht("scroll",i);break;case"onScrollEnd":o!=null&&ht("scrollend",i);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"multiple":i.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":i.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){i.removeAttribute("xlink:href");break}a=xn(""+o),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""+o):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":o===!0?i.setAttribute(a,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?i.setAttribute(a,o):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?i.setAttribute(a,o):i.removeAttribute(a);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?i.removeAttribute(a):i.setAttribute(a,o);break;case"popover":ht("beforetoggle",i),ht("toggle",i),fr(i,"popover",o);break;case"xlinkActuate":an(i,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":an(i,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":an(i,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":an(i,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":an(i,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":an(i,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":an(i,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":an(i,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":an(i,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":fr(i,"is",o);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Qs.get(a)||a,fr(i,a,o))}}function Bf(i,n,a,o,u,d){switch(a){case"style":Zs(i,o,d);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(s(61));if(a=o.__html,a!=null){if(u.children!=null)throw Error(s(60));i.innerHTML=a}}break;case"children":typeof o=="string"?en(i,o):(typeof o=="number"||typeof o=="bigint")&&en(i,""+o);break;case"onScroll":o!=null&&ht("scroll",i);break;case"onScrollEnd":o!=null&&ht("scrollend",i);break;case"onClick":o!=null&&(i.onclick=qi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ua.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),n=a.slice(2,u?a.length-7:void 0),d=i[Bi]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof o=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,o,u);break e}a in i?i[a]=o:o===!0?i.setAttribute(a,""):fr(i,a,o)}}}function Gi(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ht("error",i),ht("load",i);var o=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Dt(i,n,d,_,a,null)}}u&&Dt(i,n,"srcSet",a.srcSet,a,null),o&&Dt(i,n,"src",a.src,a,null);return;case"input":ht("invalid",i);var C=d=_=u=null,N=null,V=null;for(o in a)if(a.hasOwnProperty(o)){var le=a[o];if(le!=null)switch(o){case"name":u=le;break;case"type":_=le;break;case"checked":N=le;break;case"defaultChecked":V=le;break;case"value":d=le;break;case"defaultValue":C=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,n));break;default:Dt(i,n,o,le,a,null)}}Ys(i,d,C,N,V,_,u,!1);return;case"select":ht("invalid",i),o=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(C=a[u],C!=null))switch(u){case"value":d=C;break;case"defaultValue":_=C;break;case"multiple":o=C;default:Dt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!o,n!=null?rr(i,!!o,n,!1):a!=null&&rr(i,!!o,a,!0);return;case"textarea":ht("invalid",i),d=u=o=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":o=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(s(91));break;default:Dt(i,n,_,C,a,null)}Xs(i,o,u,d);return;case"option":for(N in a)a.hasOwnProperty(N)&&(o=a[N],o!=null)&&(N==="selected"?i.selected=o&&typeof o!="function"&&typeof o!="symbol":Dt(i,n,N,o,a,null));return;case"dialog":ht("beforetoggle",i),ht("toggle",i),ht("cancel",i),ht("close",i);break;case"iframe":case"object":ht("load",i);break;case"video":case"audio":for(o=0;o<Eo.length;o++)ht(Eo[o],i);break;case"image":ht("error",i),ht("load",i);break;case"details":ht("toggle",i);break;case"embed":case"source":case"link":ht("error",i),ht("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in a)if(a.hasOwnProperty(V)&&(o=a[V],o!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,n));default:Dt(i,n,V,o,a,null)}return;default:if(gr(n)){for(le in a)a.hasOwnProperty(le)&&(o=a[le],o!==void 0&&Bf(i,n,le,o,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(o=a[C],o!=null&&Dt(i,n,C,o,a,null))}function Zx(i,n,a,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,C=null,N=null,V=null,le=null;for(ee in a){var ue=a[ee];if(a.hasOwnProperty(ee)&&ue!=null)switch(ee){case"checked":break;case"value":break;case"defaultValue":N=ue;default:o.hasOwnProperty(ee)||Dt(i,n,ee,null,o,ue)}}for(var G in o){var ee=o[G];if(ue=a[G],o.hasOwnProperty(G)&&(ee!=null||ue!=null))switch(G){case"type":d=ee;break;case"name":u=ee;break;case"checked":V=ee;break;case"defaultChecked":le=ee;break;case"value":_=ee;break;case"defaultValue":C=ee;break;case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,n));break;default:ee!==ue&&Dt(i,n,G,ee,o,ue)}}Vs(i,_,C,N,V,le,d,u);return;case"select":ee=_=C=G=null;for(d in a)if(N=a[d],a.hasOwnProperty(d)&&N!=null)switch(d){case"value":break;case"multiple":ee=N;default:o.hasOwnProperty(d)||Dt(i,n,d,null,o,N)}for(u in o)if(d=o[u],N=a[u],o.hasOwnProperty(u)&&(d!=null||N!=null))switch(u){case"value":G=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==N&&Dt(i,n,u,d,o,N)}n=C,a=_,o=ee,G!=null?rr(i,!!a,G,!1):!!o!=!!a&&(n!=null?rr(i,!!a,n,!0):rr(i,!!a,a?[]:"",!1));return;case"textarea":ee=G=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!o.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Dt(i,n,C,null,o,u)}for(_ in o)if(u=o[_],d=a[_],o.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":G=u;break;case"defaultValue":ee=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(s(91));break;default:u!==d&&Dt(i,n,_,u,o,d)}qa(i,G,ee);return;case"option":for(var Oe in a)G=a[Oe],a.hasOwnProperty(Oe)&&G!=null&&!o.hasOwnProperty(Oe)&&(Oe==="selected"?i.selected=!1:Dt(i,n,Oe,null,o,G));for(N in o)G=o[N],ee=a[N],o.hasOwnProperty(N)&&G!==ee&&(G!=null||ee!=null)&&(N==="selected"?i.selected=G&&typeof G!="function"&&typeof G!="symbol":Dt(i,n,N,G,o,ee));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ye in a)G=a[Ye],a.hasOwnProperty(Ye)&&G!=null&&!o.hasOwnProperty(Ye)&&Dt(i,n,Ye,null,o,G);for(V in o)if(G=o[V],ee=a[V],o.hasOwnProperty(V)&&G!==ee&&(G!=null||ee!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(s(137,n));break;default:Dt(i,n,V,G,o,ee)}return;default:if(gr(n)){for(var Rt in a)G=a[Rt],a.hasOwnProperty(Rt)&&G!==void 0&&!o.hasOwnProperty(Rt)&&Bf(i,n,Rt,void 0,o,G);for(le in o)G=o[le],ee=a[le],!o.hasOwnProperty(le)||G===ee||G===void 0&&ee===void 0||Bf(i,n,le,G,o,ee);return}}for(var I in a)G=a[I],a.hasOwnProperty(I)&&G!=null&&!o.hasOwnProperty(I)&&Dt(i,n,I,null,o,G);for(ue in o)G=o[ue],ee=a[ue],!o.hasOwnProperty(ue)||G===ee||G==null&&ee==null||Dt(i,n,ue,G,o,ee)}function ny(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Qx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),o=0;o<a.length;o++){var u=a[o],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&ny(_)){for(_=0,C=u.responseEnd,o+=1;o<a.length;o++){var N=a[o],V=N.startTime;if(V>C)break;var le=N.transferSize,ue=N.initiatorType;le&&ny(ue)&&(N=N.responseEnd,_+=le*(N<C?1:(C-V)/(N-V)))}if(--o,n+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return n/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Of=null,zf=null;function Eu(i){return i.nodeType===9?i:i.ownerDocument}function ry(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 sy(i,n){if(i===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&n==="foreignObject"?0:i}function jf(i,n){return i==="textarea"||i==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Pf=null;function Jx(){var i=window.event;return i&&i.type==="popstate"?i===Pf?!1:(Pf=i,!0):(Pf=null,!1)}var ay=typeof setTimeout=="function"?setTimeout:void 0,ek=typeof clearTimeout=="function"?clearTimeout:void 0,ly=typeof Promise=="function"?Promise:void 0,tk=typeof queueMicrotask=="function"?queueMicrotask:typeof ly<"u"?function(i){return ly.resolve(null).then(i).catch(ik)}:ay;function ik(i){setTimeout(function(){throw i})}function xs(i){return i==="head"}function oy(i,n){var a=n,o=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(o===0){i.removeChild(u),Cl(n);return}o--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")o++;else if(a==="html")Do(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,Do(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[Jn]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&Do(i.ownerDocument.body);a=u}while(a);Cl(n)}function cy(i,n){var a=i;i=0;do{var o=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),o&&o.nodeType===8)if(a=o.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=o}while(a)}function Hf(i){var n=i.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Hf(a),$s(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function nk(i,n,a,o){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(o){if(!i[Jn])switch(n){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(n==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=qn(i.nextSibling),i===null)break}return null}function rk(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=qn(i.nextSibling),i===null))return null;return i}function uy(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=qn(i.nextSibling),i===null))return null;return i}function If(i){return i.data==="$?"||i.data==="$~"}function Uf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function sk(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var o=function(){n(),a.removeEventListener("DOMContentLoaded",o)};a.addEventListener("DOMContentLoaded",o),i._reactRetry=o}}function qn(i){for(;i!=null;i=i.nextSibling){var n=i.nodeType;if(n===1||n===3)break;if(n===8){if(n=i.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return i}var Kf=null;function hy(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return qn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function dy(i){i=i.previousSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return i;n--}else a!=="/$"&&a!=="/&"||n++}i=i.previousSibling}return null}function fy(i,n,a){switch(n=Eu(a),i){case"html":if(i=n.documentElement,!i)throw Error(s(452));return i;case"head":if(i=n.head,!i)throw Error(s(453));return i;case"body":if(i=n.body,!i)throw Error(s(454));return i;default:throw Error(s(451))}}function Do(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);$s(i)}var $n=new Map,py=new Set;function Tu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var $r=X.d;X.d={f:ak,r:lk,D:ok,C:ck,L:uk,m:hk,X:fk,S:dk,M:pk};function ak(){var i=$r.f(),n=vu();return i||n}function lk(i){var n=tr(i);n!==null&&n.tag===5&&n.type==="form"?Nv(n):$r.r(i)}var yl=typeof document>"u"?null:document;function my(i,n,a){var o=yl;if(o&&typeof n=="string"&&n){var u=gt(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),py.has(u)||(py.add(u),i={rel:i,crossOrigin:a,href:n},o.querySelector(u)===null&&(n=o.createElement("link"),Gi(n,"link",i),It(n),o.head.appendChild(n)))}}function ok(i){$r.D(i),my("dns-prefetch",i,null)}function ck(i,n){$r.C(i,n),my("preconnect",i,n)}function uk(i,n,a){$r.L(i,n,a);var o=yl;if(o&&i&&n){var u='link[rel="preload"][as="'+gt(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+gt(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+gt(a.imageSizes)+'"]')):u+='[href="'+gt(i)+'"]';var d=u;switch(n){case"style":d=Sl(i);break;case"script":d=wl(i)}$n.has(d)||(i=b({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),$n.set(d,i),o.querySelector(u)!==null||n==="style"&&o.querySelector(Ro(d))||n==="script"&&o.querySelector(Mo(d))||(n=o.createElement("link"),Gi(n,"link",i),It(n),o.head.appendChild(n)))}}function hk(i,n){$r.m(i,n);var a=yl;if(a&&i){var o=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+gt(o)+'"][href="'+gt(i)+'"]',d=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=wl(i)}if(!$n.has(d)&&(i=b({rel:"modulepreload",href:i},n),$n.set(d,i),a.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Mo(d)))return}o=a.createElement("link"),Gi(o,"link",i),It(o),a.head.appendChild(o)}}}function dk(i,n,a){$r.S(i,n,a);var o=yl;if(o&&i){var u=ir(o).hoistableStyles,d=Sl(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=o.querySelector(Ro(d)))C.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":n},a),(a=$n.get(d))&&Wf(i,a);var N=_=o.createElement("link");It(N),Gi(N,"link",i),N._p=new Promise(function(V,le){N.onload=V,N.onerror=le}),N.addEventListener("load",function(){C.loading|=1}),N.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Du(_,n,o)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function fk(i,n){$r.X(i,n);var a=yl;if(a&&i){var o=ir(a).hoistableScripts,u=wl(i),d=o.get(u);d||(d=a.querySelector(Mo(u)),d||(i=b({src:i,async:!0},n),(n=$n.get(u))&&Ff(i,n),d=a.createElement("script"),It(d),Gi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function pk(i,n){$r.M(i,n);var a=yl;if(a&&i){var o=ir(a).hoistableScripts,u=wl(i),d=o.get(u);d||(d=a.querySelector(Mo(u)),d||(i=b({src:i,async:!0,type:"module"},n),(n=$n.get(u))&&Ff(i,n),d=a.createElement("script"),It(d),Gi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},o.set(u,d))}}function gy(i,n,a,o){var u=(u=Se.current)?Tu(u):null;if(!u)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=Sl(a.href),a=ir(u).hoistableStyles,o=a.get(n),o||(o={type:"style",instance:null,count:0,state:null},a.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=Sl(a.href);var d=ir(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(Ro(i)))&&!d._p&&(_.instance=d,_.state.loading=5),$n.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},$n.set(i,a),d||mk(u,i,a,_.state))),n&&o===null)throw Error(s(528,""));return _}if(n&&o!==null)throw Error(s(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=wl(a),a=ir(u).hoistableScripts,o=a.get(n),o||(o={type:"script",instance:null,count:0,state:null},a.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function Sl(i){return'href="'+gt(i)+'"'}function Ro(i){return'link[rel="stylesheet"]['+i+"]"}function _y(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function mk(i,n,a,o){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=i.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),Gi(n,"link",a),It(n),i.head.appendChild(n))}function wl(i){return'[src="'+gt(i)+'"]'}function Mo(i){return"script[async]"+i}function vy(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var o=i.querySelector('style[data-href~="'+gt(a.href)+'"]');if(o)return n.instance=o,It(o),o;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return o=(i.ownerDocument||i).createElement("style"),It(o),Gi(o,"style",u),Du(o,a.precedence,i),n.instance=o;case"stylesheet":u=Sl(a.href);var d=i.querySelector(Ro(u));if(d)return n.state.loading|=4,n.instance=d,It(d),d;o=_y(a),(u=$n.get(u))&&Wf(o,u),d=(i.ownerDocument||i).createElement("link"),It(d);var _=d;return _._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Gi(d,"link",o),n.state.loading|=4,Du(d,a.precedence,i),n.instance=d;case"script":return d=wl(a.src),(u=i.querySelector(Mo(d)))?(n.instance=u,It(u),u):(o=a,(u=$n.get(d))&&(o=b({},a),Ff(o,u)),i=i.ownerDocument||i,u=i.createElement("script"),It(u),Gi(u,"link",o),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,Du(o,a.precedence,i));return n.instance}function Du(i,n,a){for(var o=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,d=u,_=0;_<o.length;_++){var C=o[_];if(C.dataset.precedence===n)d=C;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(i,n.firstChild))}function Wf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function Ff(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var Ru=null;function by(i,n,a){if(Ru===null){var o=new Map,u=Ru=new Map;u.set(a,o)}else u=Ru,o=u.get(a),o||(o=new Map,u.set(a,o));if(o.has(i))return o;for(o.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Jn]||d[$t]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=o.get(_);C?C.push(d):o.set(_,[d])}}return o}function yy(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function gk(i,n,a){if(a===1||n.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(i=n.disabled,typeof n.precedence=="string"&&i==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Sy(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function _k(i,n,a,o){if(a.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=Sl(o.href),d=n.querySelector(Ro(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=Mu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,It(d);return}d=n.ownerDocument||n,o=_y(o),(u=$n.get(u))&&Wf(o,u),d=d.createElement("link"),It(d);var _=d;_._p=new Promise(function(C,N){_.onload=C,_.onerror=N}),Gi(d,"link",o),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=Mu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var qf=0;function vk(i,n){return i.stylesheets&&i.count===0&&Au(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var o=setTimeout(function(){if(i.stylesheets&&Au(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&qf===0&&(qf=62500*Qx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&Au(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>qf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Mu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Au(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Nu=null;function Au(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Nu=new Map,n.forEach(bk,i),Nu=null,Mu.call(i))}function bk(i,n){if(!(n.state.loading&4)){var a=Nu.get(i);if(a)var o=a.get(null);else{a=new Map,Nu.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),o=_)}o&&a.set(null,o)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||o,d===o&&a.set(null,u),a.set(_,u),this.count++,o=Mu.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var No={$$typeof:Y,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function yk(i,n,a,o,u,d,_,C,N){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=zt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zt(0),this.hiddenUpdates=zt(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function wy(i,n,a,o,u,d,_,C,N,V,le,ue){return i=new yk(i,n,a,_,N,V,le,ue,C),n=1,d===!0&&(n|=24),d=Tn(3,null,null,n),i.current=d,d.stateNode=i,n=Cd(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:o,isDehydrated:a,cache:n},Td(d),i}function Cy(i){return i?(i=Ja,i):Ja}function xy(i,n,a,o,u,d){u=Cy(u),o.context===null?o.context=u:o.pendingContext=u,o=fs(n),o.payload={element:a},d=d===void 0?null:d,d!==null&&(o.callback=d),a=ps(i,o,n),a!==null&&(vn(a,i,n),oo(a,i,n))}function ky(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function $f(i,n){ky(i,n),(i=i.alternate)&&ky(i,n)}function Ey(i){if(i.tag===13||i.tag===31){var n=ra(i,67108864);n!==null&&vn(n,i,67108864),$f(i,67108864)}}function Ty(i){if(i.tag===13||i.tag===31){var n=An();n=Qi(n);var a=ra(i,n);a!==null&&vn(a,i,n),$f(i,n)}}var Lu=!0;function Sk(i,n,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=2,Vf(i,n,a,o)}finally{X.p=d,R.T=u}}function wk(i,n,a,o){var u=R.T;R.T=null;var d=X.p;try{X.p=8,Vf(i,n,a,o)}finally{X.p=d,R.T=u}}function Vf(i,n,a,o){if(Lu){var u=Yf(o);if(u===null)Lf(i,n,o,Bu,a),Ry(i,o);else if(xk(u,i,n,a,o))o.stopPropagation();else if(Ry(i,o),n&4&&-1<Ck.indexOf(i)){for(;u!==null;){var d=tr(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=At(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var N=1<<31-F(_);C.entanglements[1]|=N,_&=~N}wr(d),(yt&6)===0&&(gu=Ve()+500,ko(0))}}break;case 31:case 13:C=ra(d,2),C!==null&&vn(C,d,2),vu(),$f(d,2)}if(d=Yf(o),d===null&&Lf(i,n,o,Bu,a),d===u)break;u=d}u!==null&&o.stopPropagation()}else Lf(i,n,o,null,a)}}function Yf(i){return i=rs(i),Xf(i)}var Bu=null;function Xf(i){if(Bu=null,i=er(i),i!==null){var n=c(i);if(n===null)i=null;else{var a=n.tag;if(a===13){if(i=h(n),i!==null)return i;i=null}else if(a===31){if(i=p(n),i!==null)return i;i=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;i=null}else n!==i&&(i=null)}}return Bu=i,null}function Dy(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(xt()){case ti:return 2;case kt:return 8;case _e:case Fe:return 32;case Je:return 268435456;default:return 32}default:return 32}}var Gf=!1,ks=null,Es=null,Ts=null,Ao=new Map,Lo=new Map,Ds=[],Ck="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 Ry(i,n){switch(i){case"focusin":case"focusout":ks=null;break;case"dragenter":case"dragleave":Es=null;break;case"mouseover":case"mouseout":Ts=null;break;case"pointerover":case"pointerout":Ao.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lo.delete(n.pointerId)}}function Bo(i,n,a,o,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:o,nativeEvent:d,targetContainers:[u]},n!==null&&(n=tr(n),n!==null&&Ey(n)),i):(i.eventSystemFlags|=o,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function xk(i,n,a,o,u){switch(n){case"focusin":return ks=Bo(ks,i,n,a,o,u),!0;case"dragenter":return Es=Bo(Es,i,n,a,o,u),!0;case"mouseover":return Ts=Bo(Ts,i,n,a,o,u),!0;case"pointerover":var d=u.pointerId;return Ao.set(d,Bo(Ao.get(d)||null,i,n,a,o,u)),!0;case"gotpointercapture":return d=u.pointerId,Lo.set(d,Bo(Lo.get(d)||null,i,n,a,o,u)),!0}return!1}function My(i){var n=er(i.target);if(n!==null){var a=c(n);if(a!==null){if(n=a.tag,n===13){if(n=h(a),n!==null){i.blockedOn=n,Cn(i.priority,function(){Ty(a)});return}}else if(n===31){if(n=p(a),n!==null){i.blockedOn=n,Cn(i.priority,function(){Ty(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Ou(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=Yf(i.nativeEvent);if(a===null){a=i.nativeEvent;var o=new a.constructor(a.type,a);Js=o,a.target.dispatchEvent(o),Js=null}else return n=tr(a),n!==null&&Ey(n),i.blockedOn=a,!1;n.shift()}return!0}function Ny(i,n,a){Ou(i)&&a.delete(n)}function kk(){Gf=!1,ks!==null&&Ou(ks)&&(ks=null),Es!==null&&Ou(Es)&&(Es=null),Ts!==null&&Ou(Ts)&&(Ts=null),Ao.forEach(Ny),Lo.forEach(Ny)}function zu(i,n){i.blockedOn===n&&(i.blockedOn=null,Gf||(Gf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,kk)))}var ju=null;function Ay(i){ju!==i&&(ju=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ju===i&&(ju=null);for(var n=0;n<i.length;n+=3){var a=i[n],o=i[n+1],u=i[n+2];if(typeof o!="function"){if(Xf(o||a)===null)continue;break}var d=tr(a);d!==null&&(i.splice(n,3),n-=3,Vd(d,{pending:!0,data:u,method:a.method,action:o},o,u))}}))}function Cl(i){function n(N){return zu(N,i)}ks!==null&&zu(ks,i),Es!==null&&zu(Es,i),Ts!==null&&zu(Ts,i),Ao.forEach(n),Lo.forEach(n);for(var a=0;a<Ds.length;a++){var o=Ds[a];o.blockedOn===i&&(o.blockedOn=null)}for(;0<Ds.length&&(a=Ds[0],a.blockedOn===null);)My(a),a.blockedOn===null&&Ds.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(o=0;o<a.length;o+=3){var u=a[o],d=a[o+1],_=u[Bi]||null;if(typeof d=="function")_||Ay(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[Bi]||null)C=_.formAction;else if(Xf(u)!==null)continue}else C=_.action;typeof C=="function"?a[o+1]=C:(a.splice(o,3),o-=3),Ay(a)}}}function Ly(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),o||setTimeout(a,20)}function a(){if(!o&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){o=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Zf(i){this._internalRoot=i}Pu.prototype.render=Zf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(s(409));var a=n.current,o=An();xy(a,o,i,n,null,null)},Pu.prototype.unmount=Zf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;xy(i.current,2,null,i,null,null),vu(),n[ci]=null}};function Pu(i){this._internalRoot=i}Pu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Li();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Ds.length&&n!==0&&n<Ds[a].priority;a++);Ds.splice(a,0,i),a===0&&My(i)}};var By=t.version;if(By!=="19.2.6")throw Error(s(527,By,"19.2.6"));X.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(s(188)):(i=Object.keys(i).join(","),Error(s(268,i)));return i=f(n),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var Ek={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hu.isDisabled&&Hu.supportsFiber)try{bt=Hu.inject(Ek),Nt=Hu}catch{}}return zo.createRoot=function(i,n){if(!l(i))throw Error(s(299));var a=!1,o="",u=Uv,d=Kv,_=Wv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=wy(i,1,!1,null,null,a,o,null,u,d,_,Ly),i[ci]=n.current,Af(i),new Zf(n)},zo.hydrateRoot=function(i,n,a){if(!l(i))throw Error(s(299));var o=!1,u="",d=Uv,_=Kv,C=Wv,N=null;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(C=a.onRecoverableError),a.formState!==void 0&&(N=a.formState)),n=wy(i,1,!0,n,a??null,o,u,N,d,_,C,Ly),n.context=Cy(null),a=n.current,o=An(),o=Qi(o),u=fs(o),u.callback=null,ps(a,u,o),a=o,n.current.lanes=a,Wi(n,a),wr(n),i[ci]=n.current,Af(i),new Pu(n)},zo.version="19.2.6",zo}var Fy;function zk(){if(Fy)return ep.exports;Fy=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(),ep.exports=Ok(),ep.exports}var jk=zk();class ur extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}status}function zh(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Dl(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",tt("POST",t)),login:t=>Ne(e,"/api/auth/login",tt("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",tt("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",tt("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",tt("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await El(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",tt("POST",t)),removeNetwork:async t=>{await El(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),addAgent:t=>Ne(e,"/api/agents",tt("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",tt("PUT",{serverIds:t})),renameAgent:(t,r)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,tt("PATCH",{name:r})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",tt("PATCH",{name:t})),removeAgent:async t=>{await El(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ne(e,"/api/stats"),getAgentStats:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ne(e,"/api/version"),checkUpdate:()=>Ne(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ne(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ne(e,"/api/terminals"),getTerminalLayout:()=>Ne(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ne(e,"/api/terminal-layout",tt("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",tt("POST",t)),listFiles:t=>Ne(e,"/api/files/list",tt("POST",t)),readFile:t=>Ne(e,"/api/files/read",tt("POST",t)),writeFile:t=>Ne(e,"/api/files/write",tt("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",tt("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",tt("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",tt("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",tt("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",tt("POST",t)),previewFile:t=>G0(e,"/api/files/preview",tt("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",tt("POST",t)),closeTerminal:async t=>{await El(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,r)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,tt("PATCH",{title:r})),getTerminalHistory:(t,r={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Dl(r)}`),getTerminalTranscriptHistory:(t,r={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Dl(r)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const r=new FormData;return r.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:r})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",tt("PUT",t)),deleteNotificationAsset:async t=>{await El(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},getPushNotificationStatus:t=>Ne(e,`/api/push-notifications/status${t?Dl({clientId:t}):""}`),preparePushNotifications:t=>Ne(e,"/api/push-notifications/prepare",tt("POST",{clientId:t})),subscribePushNotifications:t=>Ne(e,"/api/push-notifications/subscription",tt("POST",t)),updatePushNotificationDevice:t=>Ne(e,"/api/push-notifications/device",tt("PATCH",t)),unsubscribePushNotifications:t=>Ne(e,"/api/push-notifications/unsubscribe",tt("POST",t)),updatePushPresence:t=>Ne(e,"/api/push-notifications/presence",tt("POST",t))}}function hc(e,t=fetch){const r=s=>e?`/api/agents/${encodeURIComponent(e)}/${s}`:`/api/${s}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,r("terminals")),createTerminal:(s={})=>Ne(t,r("terminals"),tt("POST",s)),closeTerminal:async s=>{await El(t,r(`terminals/${encodeURIComponent(s)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(s,l)=>Ne(t,r(`terminals/${encodeURIComponent(s)}`),tt("PATCH",{title:l})),getTerminalHistory:(s,l={})=>Ne(t,`${r(`terminals/${encodeURIComponent(s)}/history`)}${Dl(l)}`),getTerminalTranscriptHistory:(s,l={})=>Ne(t,`${r(`terminals/${encodeURIComponent(s)}/transcript-history`)}${Dl(l)}`),getTerminalTranscriptSource:s=>Ne(t,r(`terminals/${encodeURIComponent(s)}/transcript-source`)),getTerminalLayout:()=>Ne(t,r("terminal-layout")),saveTerminalLayout:s=>Ne(t,r("terminal-layout"),tt("PUT",s)),createFileRoot:s=>Ne(t,r("files/root"),tt("POST",s)),listFiles:s=>Ne(t,r("files/list"),tt("POST",s)),readFile:s=>Ne(t,r("files/read"),tt("POST",s)),writeFile:s=>Ne(t,r("files/write"),tt("POST",s)),createFileEntry:s=>Ne(t,r("files/create"),tt("POST",s)),moveFileEntry:s=>Ne(t,r("files/move"),tt("POST",s)),previewDeleteFileEntry:s=>Ne(t,r("files/delete-preview"),tt("POST",s)),deleteFileEntry:s=>Ne(t,r("files/delete"),tt("POST",s)),openFileInTerminal:s=>Ne(t,r("files/open"),tt("POST",s)),previewFile:s=>G0(t,r("files/preview"),tt("POST",s)),createWebSocketUrl:(s,l=window.location.href)=>Pk(r(`terminals/${encodeURIComponent(s)}/ws`),l)}}function Pk(e,t){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=e,r.search="",r.hash="",r.toString()}function tt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Dl(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource),e.clientId!==void 0&&t.set("clientId",e.clientId);const r=t.toString();return r?`?${r}`:""}async function Ne(e,t,r){const s=await e(t,r??{credentials:"same-origin"});await fg(s);try{return await s.json()}catch{throw new ur(s.status,"invalid_json_response")}}async function El(e,t,r){const s=await e(t,r);await fg(s)}async function G0(e,t,r){const s=await e(t,r);return await fg(s),s.blob()}async function fg(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const r=await e.json(),s=typeof r.error=="string"?r.error:r.message;typeof s=="string"&&s.trim()&&(t=s)}catch{}throw new ur(e.status,t)}const pg="nterminal.theme.id",Z0="nterminal.theme.accent",zp="nterminal:theme",fh=[{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",...qy({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",...qy({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],Ol="midnight";function jh(e){return fh.some(t=>t.id===e)?e:Ol}function mg(e){return fh.find(t=>t.id===e)??fh[0]}function Us(){if(typeof window>"u")return Ol;try{const e=window.localStorage.getItem(pg);return e?jh(e):Wk(window.localStorage.getItem(Z0))}catch{return Ol}}function Hk(e){const t=jh(e);if(typeof window<"u"){try{window.localStorage.setItem(pg,t)}catch{}gg(t),window.dispatchEvent(new CustomEvent(zp,{detail:t}))}return t}function gg(e=Us()){if(typeof document>"u")return;const t=mg(jh(e)),r=document.documentElement;r.dataset.ntTheme=t.id,r.style.setProperty("color-scheme",t.mode),rt(r,"--nt-bg",t.tokens.bg),rt(r,"--nt-bg-2",t.tokens.bg2),rt(r,"--nt-bg-sidebar",t.tokens.bgSidebar),rt(r,"--nt-line",t.tokens.line),rt(r,"--nt-line-2",t.tokens.line2),rt(r,"--nt-fg",t.tokens.fg),rt(r,"--nt-fg-2",t.tokens.fg2),rt(r,"--nt-fg-3",t.tokens.fg3),rt(r,"--nt-fg-4",t.tokens.fg4),rt(r,"--nt-accent",t.tokens.accent),rt(r,"--nt-accent-soft",t.tokens.accentSoft),rt(r,"--nt-accent-glow",t.tokens.accentGlow),rt(r,"--nt-on-accent",t.tokens.onAccent),rt(r,"--nt-ok",t.tokens.ok),rt(r,"--nt-danger",t.tokens.danger),rt(r,"--nt-on-danger",t.tokens.onDanger),rt(r,"--nt-danger-soft",t.tokens.dangerSoft),rt(r,"--nt-danger-line",t.tokens.dangerLine),rt(r,"--nt-warning",t.tokens.warning),rt(r,"--nt-warn",t.tokens.warning),rt(r,"--nt-warning-soft",t.tokens.warningSoft),rt(r,"--nt-warning-glow",t.tokens.warningGlow),rt(r,"--nt-scrim",t.tokens.scrim),rt(r,"--nt-scrim-soft",t.tokens.scrimSoft),rt(r,"--nt-shadow",t.tokens.shadow),rt(r,"--nt-shadow-strong",t.tokens.shadowStrong),rt(r,"--nt-floating-bg",t.tokens.floatingBg),rt(r,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),rt(r,"--nt-floating-bg-hover",t.tokens.floatingBgHover),rt(r,"--nt-subtle-fill",t.tokens.subtleFill),rt(r,"--nt-hover-fill",t.tokens.hoverFill),rt(r,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),rt(r,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),rt(r,"--nt-transcript-user",t.tokens.transcriptUser),rt(r,"--nt-transcript-assistant",t.tokens.transcriptAssistant),rt(r,"--nt-transcript-tool",t.tokens.transcriptTool),rt(r,"--nt-transcript-command",t.tokens.transcriptCommand),rt(r,"--nt-transcript-code",t.tokens.transcriptCode),rt(r,"--nt-transcript-search",t.tokens.transcriptSearch),rt(r,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),rt(r,"--nt-qr-bg",t.tokens.qrBg)}function Ik(e=Us()){return mg(jh(e)).xterm}function _g(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===pg||r.key===Z0)&&(gg(Us()),e())};return window.addEventListener(zp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zp,e),window.removeEventListener("storage",t)}}function rt(e,t,r){e.style.setProperty(t,r)}function qy(e){const t=Uk(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 Uk(e){const t=[];for(let r=16;r<=e;r+=1)t.push(Kk(r));return t}function Kk(e){if(e>=16&&e<=231){const t=e-16,r=[0,95,135,175,215,255],s=r[Math.floor(t/36)%6],l=r[Math.floor(t/6)%6],c=r[t%6];return $y(s,l,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return $y(t,t,t)}return"#000000"}function $y(e,t,r){return`#${rp(e)}${rp(t)}${rp(r)}`}function rp(e){return e.toString(16).padStart(2,"0")}function Wk(e){return e==="signal-red"?"signal-red":Ol}function Q0(){const e=v.useSyncExternalStore(_g,Us,()=>Ol);return mg(e).mode==="light"?"-light":""}function J0({size:e=22}){const t=Q0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function ew({height:e=18}){const t=Q0(),r=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:r,height:e,alt:"NTerminal"})}var Yo=X0();const Ph=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ul(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function vg(e){return"nodeType"in e}function Sn(e){var t,r;return e?Ul(e)?e:vg(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function bg(e){const{Document:t}=Sn(e);return e instanceof t}function kc(e){return Ul(e)?!1:e instanceof Sn(e).HTMLElement}function tw(e){return e instanceof Sn(e).SVGElement}function Kl(e){return e?Ul(e)?e.document:vg(e)?bg(e)?e:kc(e)||tw(e)?e.ownerDocument:document:document:document}const Ks=Ph?v.useLayoutEffect:v.useEffect;function yg(e){const t=v.useRef(e);return Ks(()=>{t.current=e}),v.useCallback(function(){for(var r=arguments.length,s=new Array(r),l=0;l<r;l++)s[l]=arguments[l];return t.current==null?void 0:t.current(...s)},[])}function Fk(){const e=v.useRef(null),t=v.useCallback((s,l)=>{e.current=setInterval(s,l)},[]),r=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function dc(e,t){t===void 0&&(t=[e]);const r=v.useRef(e);return Ks(()=>{r.current!==e&&(r.current=e)},t),r}function Ec(e,t){const r=v.useRef();return v.useMemo(()=>{const s=e(r.current);return r.current=s,s},[...t])}function ph(e){const t=yg(e),r=v.useRef(null),s=v.useCallback(l=>{l!==r.current&&t?.(l,r.current),r.current=l},[]);return[r,s]}function jp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let sp={};function Hh(e,t){return v.useMemo(()=>{if(t)return t;const r=sp[e]==null?0:sp[e]+1;return sp[e]=r,e+"-"+r},[e,t])}function iw(e){return function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];return s.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const y=c[g];y!=null&&(c[g]=y+e*f)}return c},{...t})}}const Ll=iw(1),mh=iw(-1);function qk(e){return"clientX"in e&&"clientY"in e}function nw(e){if(!e)return!1;const{KeyboardEvent:t}=Sn(e.target);return t&&e instanceof t}function $k(e){if(!e)return!1;const{TouchEvent:t}=Sn(e.target);return t&&e instanceof t}function Pp(e){if($k(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return qk(e)?{x:e.clientX,y:e.clientY}:null}const Hp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Hp.Translate.toString(e),Hp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:s}=e;return t+" "+r+"ms "+s}}}),Vy="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Vk(e){return e.matches(Vy)?e:e.querySelector(Vy)}const Yk={display:"none"};function Xk(e){let{id:t,value:r}=e;return Mi.createElement("div",{id:t,style:Yk},r)}function Gk(e){let{id:t,announcement:r,ariaLiveType:s="assertive"}=e;const l={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Mi.createElement("div",{id:t,style:l,role:"status","aria-live":s,"aria-atomic":!0},r)}function Zk(){const[e,t]=v.useState("");return{announce:v.useCallback(s=>{s!=null&&t(s)},[]),announcement:e}}const rw=v.createContext(null);function Qk(e){const t=v.useContext(rw);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Jk(){const[e]=v.useState(()=>new Set),t=v.useCallback(s=>(e.add(s),()=>e.delete(s)),[e]);return[v.useCallback(s=>{let{type:l,event:c}=s;e.forEach(h=>{var p;return(p=h[l])==null?void 0:p.call(h,c)})},[e]),t]}const eE={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
|
+
`},tE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function iE(e){let{announcements:t=tE,container:r,hiddenTextDescribedById:s,screenReaderInstructions:l=eE}=e;const{announce:c,announcement:h}=Zk(),p=Hh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),Qk(v.useMemo(()=>({onDragStart(b){let{active:S}=b;c(t.onDragStart({active:S}))},onDragMove(b){let{active:S,over:w}=b;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(b){let{active:S,over:w}=b;c(t.onDragOver({active:S,over:w}))},onDragEnd(b){let{active:S,over:w}=b;c(t.onDragEnd({active:S,over:w}))},onDragCancel(b){let{active:S,over:w}=b;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const y=Mi.createElement(Mi.Fragment,null,Mi.createElement(Xk,{id:s,value:l.draggable}),Mi.createElement(Gk,{id:p,announcement:h}));return r?Yo.createPortal(y,r):y}var Ri;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ri||(Ri={}));function gh(){}function Yy(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function nE(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const hr=Object.freeze({x:0,y:0});function rE(e,t){let{data:{value:r}}=e,{data:{value:s}}=t;return s-r}function sE(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function aE(e,t){const r=Math.max(t.top,e.top),s=Math.max(t.left,e.left),l=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=l-s,p=c-r;if(s<l&&r<c){const g=t.width*t.height,f=e.width*e.height,y=h*p,b=y/(g+f-y);return Number(b.toFixed(4))}return 0}const lE=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:s}=e;const l=[];for(const c of s){const{id:h}=c,p=r.get(h);if(p){const g=aE(p,t);g>0&&l.push({id:h,data:{droppableContainer:c,value:g}})}}return l.sort(rE)};function oE(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function sw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:hr}function cE(e){return function(r){for(var s=arguments.length,l=new Array(s>1?s-1:0),c=1;c<s;c++)l[c-1]=arguments[c];return l.reduce((h,p)=>({...h,top:h.top+e*p.y,bottom:h.bottom+e*p.y,left:h.left+e*p.x,right:h.right+e*p.x}),{...r})}}const uE=cE(1);function hE(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 dE(e,t,r){const s=hE(t);if(!s)return e;const{scaleX:l,scaleY:c,x:h,y:p}=s,g=e.left-h-(1-l)*parseFloat(r),f=e.top-p-(1-c)*parseFloat(r.slice(r.indexOf(" ")+1)),y=l?e.width/l:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:f,right:g+y,bottom:f+b,left:g}}const fE={ignoreTransform:!1};function Tc(e,t){t===void 0&&(t=fE);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:y}=Sn(e).getComputedStyle(e);f&&(r=dE(r,f,y))}const{top:s,left:l,width:c,height:h,bottom:p,right:g}=r;return{top:s,left:l,width:c,height:h,bottom:p,right:g}}function Xy(e){return Tc(e,{ignoreTransform:!0})}function pE(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function mE(e,t){return t===void 0&&(t=Sn(e).getComputedStyle(e)),t.position==="fixed"}function gE(e,t){t===void 0&&(t=Sn(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=t[l];return typeof c=="string"?r.test(c):!1})}function Sg(e,t){const r=[];function s(l){if(t!=null&&r.length>=t||!l)return r;if(bg(l)&&l.scrollingElement!=null&&!r.includes(l.scrollingElement))return r.push(l.scrollingElement),r;if(!kc(l)||tw(l)||r.includes(l))return r;const c=Sn(e).getComputedStyle(l);return l!==e&&gE(l,c)&&r.push(l),mE(l,c)?r:s(l.parentNode)}return e?s(e):r}function aw(e){const[t]=Sg(e,1);return t??null}function ap(e){return!Ph||!e?null:Ul(e)?e:vg(e)?bg(e)||e===Kl(e).scrollingElement?window:kc(e)?e:null:null}function lw(e){return Ul(e)?e.scrollX:e.scrollLeft}function ow(e){return Ul(e)?e.scrollY:e.scrollTop}function Ip(e){return{x:lw(e),y:ow(e)}}var ji;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ji||(ji={}));function cw(e){return!Ph||!e?!1:e===document.scrollingElement}function uw(e){const t={x:0,y:0},r=cw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},l=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=s.y,p=e.scrollLeft>=s.x;return{isTop:l,isLeft:c,isBottom:h,isRight:p,maxScroll:s,minScroll:t}}const _E={x:.2,y:.2};function vE(e,t,r,s,l){let{top:c,left:h,right:p,bottom:g}=r;s===void 0&&(s=10),l===void 0&&(l=_E);const{isTop:f,isBottom:y,isLeft:b,isRight:S}=uw(e),w={x:0,y:0},x={x:0,y:0},D={height:t.height*l.y,width:t.width*l.x};return!f&&c<=t.top+D.height?(w.y=ji.Backward,x.y=s*Math.abs((t.top+D.height-c)/D.height)):!y&&g>=t.bottom-D.height&&(w.y=ji.Forward,x.y=s*Math.abs((t.bottom-D.height-g)/D.height)),!S&&p>=t.right-D.width?(w.x=ji.Forward,x.x=s*Math.abs((t.right-D.width-p)/D.width)):!b&&h<=t.left+D.width&&(w.x=ji.Backward,x.x=s*Math.abs((t.left+D.width-h)/D.width)),{direction:w,speed:x}}function bE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:r,right:s,bottom:l}=e.getBoundingClientRect();return{top:t,left:r,right:s,bottom:l,width:e.clientWidth,height:e.clientHeight}}function hw(e){return e.reduce((t,r)=>Ll(t,Ip(r)),hr)}function yE(e){return e.reduce((t,r)=>t+lw(r),0)}function SE(e){return e.reduce((t,r)=>t+ow(r),0)}function wE(e,t){if(t===void 0&&(t=Tc),!e)return;const{top:r,left:s,bottom:l,right:c}=t(e);aw(e)&&(l<=0||c<=0||r>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const CE=[["x",["left","right"],yE],["y",["top","bottom"],SE]];class wg{constructor(t,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Sg(r),l=hw(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of CE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(s),y=l[c]-f;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class sc{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...r)})},this.target=t}add(t,r,s){var l;(l=this.target)==null||l.addEventListener(t,r,s),this.listeners.push([t,r,s])}}function xE(e){const{EventTarget:t}=Sn(e);return e instanceof t?e:Kl(e)}function lp(e,t){const r=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+s**2)>t:"x"in t&&"y"in t?r>t.x&&s>t.y:"x"in t?r>t.x:"y"in t?s>t.y:!1}var Xn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Xn||(Xn={}));function Gy(e){e.preventDefault()}function kE(e){e.stopPropagation()}var Ot;(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"})(Ot||(Ot={}));const dw={start:[Ot.Space,Ot.Enter],cancel:[Ot.Esc],end:[Ot.Space,Ot.Enter,Ot.Tab]},EE=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Ot.Right:return{...r,x:r.x+25};case Ot.Left:return{...r,x:r.x-25};case Ot.Down:return{...r,y:r.y+25};case Ot.Up:return{...r,y:r.y-25}}};class fw{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:r}}=t;this.props=t,this.listeners=new sc(Kl(r)),this.windowListeners=new sc(Sn(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xn.Resize,this.handleCancel),this.windowListeners.add(Xn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,s=t.node.current;s&&wE(s),r(hr)}handleKeyDown(t){if(nw(t)){const{active:r,context:s,options:l}=this.props,{keyboardCodes:c=dw,coordinateGetter:h=EE,scrollBehavior:p="smooth"}=l,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=s.current,y=f?{x:f.left,y:f.top}:hr;this.referenceCoordinates||(this.referenceCoordinates=y);const b=h(t,{active:r,context:s.current,currentCoordinates:y});if(b){const S=mh(b,y),w={x:0,y:0},{scrollableAncestors:x}=s.current;for(const D of x){const L=t.code,{isTop:A,isRight:B,isLeft:Y,isBottom:P,maxScroll:q,minScroll:re}=uw(D),ne=bE(D),he={x:Math.min(L===Ot.Right?ne.right-ne.width/2:ne.right,Math.max(L===Ot.Right?ne.left:ne.left+ne.width/2,b.x)),y:Math.min(L===Ot.Down?ne.bottom-ne.height/2:ne.bottom,Math.max(L===Ot.Down?ne.top:ne.top+ne.height/2,b.y))},ve=L===Ot.Right&&!B||L===Ot.Left&&!Y,U=L===Ot.Down&&!P||L===Ot.Up&&!A;if(ve&&he.x!==b.x){const K=D.scrollLeft+S.x,W=L===Ot.Right&&K<=q.x||L===Ot.Left&&K>=re.x;if(W&&!S.y){D.scrollTo({left:K,behavior:p});return}W?w.x=D.scrollLeft-K:w.x=L===Ot.Right?D.scrollLeft-q.x:D.scrollLeft-re.x,w.x&&D.scrollBy({left:-w.x,behavior:p});break}else if(U&&he.y!==b.y){const K=D.scrollTop+S.y,W=L===Ot.Down&&K<=q.y||L===Ot.Up&&K>=re.y;if(W&&!S.x){D.scrollTo({top:K,behavior:p});return}W?w.y=D.scrollTop-K:w.y=L===Ot.Down?D.scrollTop-q.y:D.scrollTop-re.y,w.y&&D.scrollBy({top:-w.y,behavior:p});break}}this.handleMove(t,Ll(mh(b,this.referenceCoordinates),w))}}}handleMove(t,r){const{onMove:s}=this.props;t.preventDefault(),s(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}fw.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:s=dw,onActivation:l}=t,{active:c}=r;const{code:h}=e.nativeEvent;if(s.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function Zy(e){return!!(e&&"distance"in e)}function Qy(e){return!!(e&&"delay"in e)}class Cg{constructor(t,r,s){var l;s===void 0&&(s=xE(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=r;const{event:c}=t,{target:h}=c;this.props=t,this.events=r,this.document=Kl(h),this.documentListeners=new sc(this.document),this.listeners=new sc(s),this.windowListeners=new sc(Sn(h)),this.initialCoordinates=(l=Pp(c))!=null?l:hr,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:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Xn.Resize,this.handleCancel),this.windowListeners.add(Xn.DragStart,Gy),this.windowListeners.add(Xn.VisibilityChange,this.handleCancel),this.windowListeners.add(Xn.ContextMenu,Gy),this.documentListeners.add(Xn.Keydown,this.handleKeydown),r){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qy(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Zy(r)){this.handlePending(r);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,r){const{active:s,onPending:l}=this.props;l(s,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(Xn.Click,kE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xn.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:s,initialCoordinates:l,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!l)return;const g=(r=Pp(t))!=null?r:hr,f=mh(l,g);if(!s&&p){if(Zy(p)){if(p.tolerance!=null&&lp(f,p.tolerance))return this.handleCancel();if(lp(f,p.distance))return this.handleStart()}if(Qy(p)&&lp(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Ot.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const TE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class pw extends Cg{constructor(t){const{event:r}=t,s=Kl(r.target);super(t,TE,s)}}pw.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return!r.isPrimary||r.button!==0?!1:(s?.({event:r}),!0)}}];const DE={move:{name:"mousemove"},end:{name:"mouseup"}};var Up;(function(e){e[e.RightClick=2]="RightClick"})(Up||(Up={}));class mw extends Cg{constructor(t){super(t,DE,Kl(t.event.target))}}mw.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;return r.button===Up.RightClick?!1:(s?.({event:r}),!0)}}];const op={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gw extends Cg{constructor(t){super(t,op)}static setup(){return window.addEventListener(op.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(op.move.name,t)};function t(){}}}gw.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:s}=t;const{touches:l}=r;return l.length>1?!1:(s?.({event:r}),!0)}}];var ac;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ac||(ac={}));var _h;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(_h||(_h={}));function RE(e){let{acceleration:t,activator:r=ac.Pointer,canScroll:s,draggingRect:l,enabled:c,interval:h=5,order:p=_h.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:y,delta:b,threshold:S}=e;const w=NE({delta:b,disabled:!c}),[x,D]=Fk(),L=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),B=v.useMemo(()=>{switch(r){case ac.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case ac.DraggableRect:return l}},[r,l,g]),Y=v.useRef(null),P=v.useCallback(()=>{const re=Y.current;if(!re)return;const ne=L.current.x*A.current.x,he=L.current.y*A.current.y;re.scrollBy(ne,he)},[]),q=v.useMemo(()=>p===_h.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!B){D();return}for(const re of q){if(s?.(re)===!1)continue;const ne=f.indexOf(re),he=y[ne];if(!he)continue;const{direction:ve,speed:U}=vE(re,he,B,t,S);for(const K of["x","y"])w[K][ve[K]]||(U[K]=0,ve[K]=0);if(U.x>0||U.y>0){D(),Y.current=re,x(P,h),L.current=U,A.current=ve;return}}L.current={x:0,y:0},A.current={x:0,y:0},D()},[t,P,s,D,c,h,JSON.stringify(B),JSON.stringify(w),x,f,q,y,JSON.stringify(S)])}const ME={x:{[ji.Backward]:!1,[ji.Forward]:!1},y:{[ji.Backward]:!1,[ji.Forward]:!1}};function NE(e){let{delta:t,disabled:r}=e;const s=jp(t);return Ec(l=>{if(r||!s||!l)return ME;const c={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[ji.Backward]:l.x[ji.Backward]||c.x===-1,[ji.Forward]:l.x[ji.Forward]||c.x===1},y:{[ji.Backward]:l.y[ji.Backward]||c.y===-1,[ji.Forward]:l.y[ji.Forward]||c.y===1}}},[r,t,s])}function AE(e,t){const r=t!=null?e.get(t):void 0,s=r?r.node.current:null;return Ec(l=>{var c;return t==null?null:(c=s??l)!=null?c:null},[s,t])}function LE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{const{sensor:l}=s,c=l.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,s)}));return[...r,...c]},[]),[e,t])}var fc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(fc||(fc={}));var Kp;(function(e){e.Optimized="optimized"})(Kp||(Kp={}));const Jy=new Map;function BE(e,t){let{dragging:r,dependencies:s,config:l}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=l,y=v.useRef(e),b=L(),S=dc(b),w=v.useCallback(function(A){A===void 0&&(A=[]),!S.current&&h(B=>B===null?A:B.concat(A.filter(Y=>!B.includes(Y))))},[S]),x=v.useRef(null),D=Ec(A=>{if(b&&!r)return Jy;if(!A||A===Jy||y.current!==e||c!=null){const B=new Map;for(let Y of e){if(!Y)continue;if(c&&c.length>0&&!c.includes(Y.id)&&Y.rect.current){B.set(Y.id,Y.rect.current);continue}const P=Y.node.current,q=P?new wg(g(P),P):null;Y.rect.current=q,q&&B.set(Y.id,q)}return B}return A},[e,c,r,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||w()},[r,b]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof p!="number"||x.current!==null||(x.current=setTimeout(()=>{w(),x.current=null},p))},[p,b,w,...s]),{droppableRects:D,measureDroppableContainers:w,measuringScheduled:c!=null};function L(){switch(f){case fc.Always:return!1;case fc.BeforeDragging:return r;default:return!r}}}function _w(e,t){return Ec(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function OE(e,t){return _w(e,t)}function zE(e){let{callback:t,disabled:r}=e;const s=yg(t),l=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(s)},[s,r]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function Ih(e){let{callback:t,disabled:r}=e;const s=yg(t),l=v.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(s)},[r]);return v.useEffect(()=>()=>l?.disconnect(),[l]),l}function jE(e){return new wg(Tc(e),e)}function eS(e,t,r){t===void 0&&(t=jE);const[s,l]=v.useState(null);function c(){l(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??r)!=null?f:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const h=zE({callback(g){if(e)for(const f of g){const{type:y,target:b}=f;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),p=Ih({callback:c});return Ks(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),s}function PE(e){const t=_w(e);return sw(e,t)}const tS=[];function HE(e){const t=v.useRef(e),r=Ec(s=>e?s&&s!==tS&&e&&t.current&&e.parentNode===t.current.parentNode?s:Sg(e):tS,[e]);return v.useEffect(()=>{t.current=e},[e]),r}function IE(e){const[t,r]=v.useState(null),s=v.useRef(e),l=v.useCallback(c=>{const h=ap(c.target);h&&r(p=>p?(p.set(h,Ip(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=s.current;if(e!==c){h(c);const p=e.map(g=>{const f=ap(g);return f?(f.addEventListener("scroll",l,{passive:!0}),[f,Ip(f)]):null}).filter(g=>g!=null);r(p.length?new Map(p):null),s.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=ap(g);f?.removeEventListener("scroll",l)})}},[l,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>Ll(c,h),hr):hw(e):hr,[e,t])}function iS(e,t){t===void 0&&(t=[]);const r=v.useRef(null);return v.useEffect(()=>{r.current=null},t),v.useEffect(()=>{const s=e!==hr;s&&!r.current&&(r.current=e),!s&&r.current&&(r.current=null)},[e]),r.current?mh(e,r.current):hr}function UE(e){v.useEffect(()=>{if(!Ph)return;const t=e.map(r=>{let{sensor:s}=r;return s.setup==null?void 0:s.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function KE(e,t){return v.useMemo(()=>e.reduce((r,s)=>{let{eventName:l,handler:c}=s;return r[l]=h=>{c(h,t)},r},{}),[e,t])}function vw(e){return v.useMemo(()=>e?pE(e):null,[e])}const nS=[];function WE(e,t){t===void 0&&(t=Tc);const[r]=e,s=vw(r?Sn(r):null),[l,c]=v.useState(nS);function h(){c(()=>e.length?e.map(g=>cw(g)?s:new wg(t(g),g)):nS)}const p=Ih({callback:h});return Ks(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),l}function FE(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return kc(t)?t:e}function qE(e){let{measure:t}=e;const[r,s]=v.useState(null),l=v.useCallback(f=>{for(const{target:y}of f)if(kc(y)){s(b=>{const S=t(y);return b?{...b,width:S.width,height:S.height}:S});break}},[t]),c=Ih({callback:l}),h=v.useCallback(f=>{const y=FE(f);c?.disconnect(),y&&c?.observe(y),s(y?t(y):null)},[t,c]),[p,g]=ph(h);return v.useMemo(()=>({nodeRef:p,rect:r,setRef:g}),[r,p,g])}const $E=[{sensor:pw,options:{}},{sensor:fw,options:{}}],VE={current:{}},eh={draggable:{measure:Xy},droppable:{measure:Xy,strategy:fc.WhileDragging,frequency:Kp.Optimized},dragOverlay:{measure:Tc}};class lc extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,s;return(r=(s=this.get(t))==null?void 0:s.node.current)!=null?r:void 0}}const YE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new lc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:eh,measureDroppableContainers:gh,windowRect:null,measuringScheduled:!1},XE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:gh,draggableNodes:new Map,over:null,measureDroppableContainers:gh},Uh=v.createContext(XE),GE=v.createContext(YE);function ZE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new lc}}}function QE(e,t){switch(t.type){case Ri.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ri.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ri.DragEnd:case Ri.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ri.RegisterDroppable:{const{element:r}=t,{id:s}=r,l=new lc(e.droppable.containers);return l.set(s,r),{...e,droppable:{...e.droppable,containers:l}}}case Ri.SetDroppableDisabled:{const{id:r,key:s,disabled:l}=t,c=e.droppable.containers.get(r);if(!c||s!==c.key)return e;const h=new lc(e.droppable.containers);return h.set(r,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:h}}}case Ri.UnregisterDroppable:{const{id:r,key:s}=t,l=e.droppable.containers.get(r);if(!l||s!==l.key)return e;const c=new lc(e.droppable.containers);return c.delete(r),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function JE(e){let{disabled:t}=e;const{active:r,activatorEvent:s,draggableNodes:l}=v.useContext(Uh),c=jp(s),h=jp(r?.id);return v.useEffect(()=>{if(!t&&!s&&c&&h!=null){if(!nw(c)||document.activeElement===c.target)return;const p=l.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const y of[g.current,f.current]){if(!y)continue;const b=Vk(y);if(b){b.focus();break}}})}},[s,t,l,h,c]),null}function e2(e,t){let{transform:r,...s}=t;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...s}),r):r}function t2(e){return v.useMemo(()=>({draggable:{...eh.draggable,...e?.draggable},droppable:{...eh.droppable,...e?.droppable},dragOverlay:{...eh.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function i2(e){let{activeNode:t,measure:r,initialRect:s,config:l=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof l=="boolean"?{x:l,y:l}:l;Ks(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!s)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const y=r(f),b=sw(y,s);if(h||(b.x=0),p||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const S=aw(f);S&&S.scrollBy({top:b.y,left:b.x})}},[t,h,p,s,r])}const bw=v.createContext({...hr,scaleX:1,scaleY:1});var zs;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(zs||(zs={}));const n2=v.memo(function(t){var r,s,l,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:y=$E,collisionDetection:b=lE,measuring:S,modifiers:w,...x}=t;const D=v.useReducer(QE,void 0,ZE),[L,A]=D,[B,Y]=Jk(),[P,q]=v.useState(zs.Uninitialized),re=P===zs.Initialized,{draggable:{active:ne,nodes:he,translate:ve},droppable:{containers:U}}=L,K=ne!=null?he.get(ne):null,W=v.useRef({initial:null,translated:null}),H=v.useMemo(()=>{var St;return ne!=null?{id:ne,data:(St=K?.data)!=null?St:VE,rect:W}:null},[ne,K]),j=v.useRef(null),[ae,R]=v.useState(null),[X,Z]=v.useState(null),Ce=dc(x,Object.values(x)),Te=Hh("DndDescribedBy",h),M=v.useMemo(()=>U.getEnabled(),[U]),Q=t2(S),{droppableRects:de,measureDroppableContainers:me,measuringScheduled:ge}=BE(M,{dragging:re,dependencies:[ve.x,ve.y],config:Q.droppable}),Se=AE(he,ne),Ee=v.useMemo(()=>X?Pp(X):null,[X]),De=Ai(),Ke=OE(Se,Q.draggable.measure);i2({activeNode:ne!=null?he.get(ne):null,config:De.layoutShiftCompensation,initialRect:Ke,measure:Q.draggable.measure});const se=eS(Se,Q.draggable.measure,Ke),pe=eS(Se?Se.parentElement:null),Le=v.useRef({activatorEvent:null,active:null,activeNode:Se,collisionRect:null,collisions:null,droppableRects:de,draggableNodes:he,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=U.getNodeFor((r=Le.current.over)==null?void 0:r.id),Me=qE({measure:Q.dragOverlay.measure}),Pe=(s=Me.nodeRef.current)!=null?s:Se,ze=re?(l=Me.rect)!=null?l:se:null,ie=!!(Me.nodeRef.current&&Me.rect),ke=PE(ie?null:se),Re=vw(Pe?Sn(Pe):null),Be=HE(re?be??Se:null),je=WE(Be),at=e2(w,{transform:{x:ve.x-ke.x,y:ve.y-ke.y,scaleX:1,scaleY:1},activatorEvent:X,active:H,activeNodeRect:se,containerNodeRect:pe,draggingNodeRect:ze,over:Le.current.over,overlayNodeRect:Me.rect,scrollableAncestors:Be,scrollableAncestorRects:je,windowRect:Re}),Xt=Ee?Ll(Ee,ve):null,Ve=IE(Be),xt=iS(Ve),ti=iS(Ve,[se]),kt=Ll(at,xt),_e=ze?uE(ze,at):null,Fe=H&&_e?b({active:H,collisionRect:_e,droppableRects:de,droppableContainers:M,pointerCoordinates:Xt}):null,Je=sE(Fe,"id"),[ct,Pt]=v.useState(null),bt=ie?at:Ll(at,ti),Nt=oE(bt,(c=ct?.rect)!=null?c:null,se),Ft=v.useRef(null),F=v.useCallback((St,At)=>{let{sensor:qt,options:Gt}=At;if(j.current==null)return;const Ci=he.get(j.current);if(!Ci)return;const li=St.nativeEvent,zt=new qt({active:j.current,activeNode:Ci,event:li,options:Gt,context:Le,onAbort(Ht){if(!he.get(Ht))return;const{onDragAbort:Zt}=Ce.current,oi={id:Ht};Zt?.(oi),B({type:"onDragAbort",event:oi})},onPending(Ht,Et,Zt,oi){if(!he.get(Ht))return;const{onDragPending:wn}=Ce.current,Li={id:Ht,constraint:Et,initialCoordinates:Zt,offset:oi};wn?.(Li),B({type:"onDragPending",event:Li})},onStart(Ht){const Et=j.current;if(Et==null)return;const Zt=he.get(Et);if(!Zt)return;const{onDragStart:oi}=Ce.current,Qi={activatorEvent:li,active:{id:Et,data:Zt.data,rect:W}};Yo.unstable_batchedUpdates(()=>{oi?.(Qi),q(zs.Initializing),A({type:Ri.DragStart,initialCoordinates:Ht,active:Et}),B({type:"onDragStart",event:Qi}),R(Ft.current),Z(li)})},onMove(Ht){A({type:Ri.DragMove,coordinates:Ht})},onEnd:Wi(Ri.DragEnd),onCancel:Wi(Ri.DragCancel)});Ft.current=zt;function Wi(Ht){return async function(){const{active:Zt,collisions:oi,over:Qi,scrollAdjustedTranslate:wn}=Le.current;let Li=null;if(Zt&&wn){const{cancelDrop:Cn}=Ce.current;Li={activatorEvent:li,active:Zt,collisions:oi,delta:wn,over:Qi},Ht===Ri.DragEnd&&typeof Cn=="function"&&await Promise.resolve(Cn(Li))&&(Ht=Ri.DragCancel)}j.current=null,Yo.unstable_batchedUpdates(()=>{A({type:Ht}),q(zs.Uninitialized),Pt(null),R(null),Z(null),Ft.current=null;const Cn=Ht===Ri.DragEnd?"onDragEnd":"onDragCancel";if(Li){const Fi=Ce.current[Cn];Fi?.(Li),B({type:Cn,event:Li})}})}}},[he]),Ue=v.useCallback((St,At)=>(qt,Gt)=>{const Ci=qt.nativeEvent,li=he.get(Gt);if(j.current!==null||!li||Ci.dndKit||Ci.defaultPrevented)return;const zt={active:li};St(qt,At.options,zt)===!0&&(Ci.dndKit={capturedBy:At.sensor},j.current=Gt,F(qt,At))},[he,F]),st=LE(y,Ue);UE(y),Ks(()=>{se&&P===zs.Initializing&&q(zs.Initialized)},[se,P]),v.useEffect(()=>{const{onDragMove:St}=Ce.current,{active:At,activatorEvent:qt,collisions:Gt,over:Ci}=Le.current;if(!At||!qt)return;const li={active:At,activatorEvent:qt,collisions:Gt,delta:{x:kt.x,y:kt.y},over:Ci};Yo.unstable_batchedUpdates(()=>{St?.(li),B({type:"onDragMove",event:li})})},[kt.x,kt.y]),v.useEffect(()=>{const{active:St,activatorEvent:At,collisions:qt,droppableContainers:Gt,scrollAdjustedTranslate:Ci}=Le.current;if(!St||j.current==null||!At||!Ci)return;const{onDragOver:li}=Ce.current,zt=Gt.get(Je),Wi=zt&&zt.rect.current?{id:zt.id,rect:zt.rect.current,data:zt.data,disabled:zt.disabled}:null,Ht={active:St,activatorEvent:At,collisions:qt,delta:{x:Ci.x,y:Ci.y},over:Wi};Yo.unstable_batchedUpdates(()=>{Pt(Wi),li?.(Ht),B({type:"onDragOver",event:Ht})})},[Je]),Ks(()=>{Le.current={activatorEvent:X,active:H,activeNode:Se,collisionRect:_e,collisions:Fe,droppableRects:de,draggableNodes:he,draggingNode:Pe,draggingNodeRect:ze,droppableContainers:U,over:ct,scrollableAncestors:Be,scrollAdjustedTranslate:kt},W.current={initial:ze,translated:_e}},[H,Se,Fe,_e,he,Pe,ze,de,U,ct,Be,kt]),RE({...De,delta:ve,draggingRect:_e,pointerCoordinates:Xt,scrollableAncestors:Be,scrollableAncestorRects:je});const Si=v.useMemo(()=>({active:H,activeNode:Se,activeNodeRect:se,activatorEvent:X,collisions:Fe,containerNodeRect:pe,dragOverlay:Me,draggableNodes:he,droppableContainers:U,droppableRects:de,over:ct,measureDroppableContainers:me,scrollableAncestors:Be,scrollableAncestorRects:je,measuringConfiguration:Q,measuringScheduled:ge,windowRect:Re}),[H,Se,se,X,Fe,pe,Me,he,U,de,ct,me,Be,je,Q,ge,Re]),wi=v.useMemo(()=>({activatorEvent:X,activators:st,active:H,activeNodeRect:se,ariaDescribedById:{draggable:Te},dispatch:A,draggableNodes:he,over:ct,measureDroppableContainers:me}),[X,st,H,se,A,Te,he,ct,me]);return Mi.createElement(rw.Provider,{value:Y},Mi.createElement(Uh.Provider,{value:wi},Mi.createElement(GE.Provider,{value:Si},Mi.createElement(bw.Provider,{value:Nt},f)),Mi.createElement(JE,{disabled:p?.restoreFocus===!1})),Mi.createElement(iE,{...p,hiddenTextDescribedById:Te}));function Ai(){const St=ae?.autoScrollEnabled===!1,At=typeof g=="object"?g.enabled===!1:g===!1,qt=re&&!St&&!At;return typeof g=="object"?{...g,enabled:qt}:{enabled:qt}}}),r2=v.createContext(null),rS="button",s2="Draggable";function yw(e){let{id:t,data:r,disabled:s=!1,attributes:l}=e;const c=Hh(s2),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:y,draggableNodes:b,over:S}=v.useContext(Uh),{role:w=rS,roleDescription:x="draggable",tabIndex:D=0}=l??{},L=g?.id===t,A=v.useContext(L?bw:r2),[B,Y]=ph(),[P,q]=ph(),re=KE(h,t),ne=dc(r);Ks(()=>(b.set(t,{id:t,key:c,node:B,activatorNode:P,data:ne}),()=>{const ve=b.get(t);ve&&ve.key===c&&b.delete(t)}),[b,t]);const he=v.useMemo(()=>({role:w,tabIndex:D,"aria-disabled":s,"aria-pressed":L&&w===rS?!0:void 0,"aria-roledescription":x,"aria-describedby":y.draggable}),[s,w,D,L,x,y.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:he,isDragging:L,listeners:s?void 0:re,node:B,over:S,setNodeRef:Y,setActivatorNodeRef:q,transform:A}}const a2="Droppable",l2={timeout:25};function xg(e){let{data:t,disabled:r=!1,id:s,resizeObserverConfig:l}=e;const c=Hh(a2),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(Uh),y=v.useRef({disabled:r}),b=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:x,updateMeasurementsFor:D,timeout:L}={...l2,...l},A=dc(D??s),B=v.useCallback(()=>{if(!b.current){b.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),w.current=null},L)},[L]),Y=Ih({callback:B,disabled:x||!h}),P=v.useCallback((he,ve)=>{Y&&(ve&&(Y.unobserve(ve),b.current=!1),he&&Y.observe(he))},[Y]),[q,re]=ph(P),ne=dc(t);return v.useEffect(()=>{!Y||!q.current||(Y.disconnect(),b.current=!1,Y.observe(q.current))},[q,Y]),v.useEffect(()=>(p({type:Ri.RegisterDroppable,element:{id:s,key:c,disabled:r,node:q,rect:S,data:ne}}),()=>p({type:Ri.UnregisterDroppable,key:c,id:s})),[s]),v.useEffect(()=>{r!==y.current.disabled&&(p({type:Ri.SetDroppableDisabled,id:s,key:c,disabled:r}),y.current.disabled=r)},[s,c,r,p]),{active:h,rect:S,isOver:g?.id===s,node:q,over:g,setNodeRef:re}}const o2=128,c2=512,Wl=100,u2="too_many_detached_terminals",h2=64,d2=4096;function Sw(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>o2)return null;const r=t.workspaces.map(f2);return r.some(s=>s===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:r}}function ww(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(r=>{if(!r||typeof r!="object")return!1;const s=r.detachedTerminalIds;return Array.isArray(s)&&s.length>Wl}):!1}function f2(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>c2)return null;const r=t.tabs.map(p2);if(r.some(l=>l===null))return null;const s=v2(t.detachedTerminalIds,Wl);return s===null?null:{id:t.id,title:t.title,defaultCwd:_2(t.defaultCwd),detachedTerminalIds:s,activeTabId:t.activeTabId,tabs:r}}function p2(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 r=m2(t.root);return r?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:r}:null}function m2(e){if(!e||typeof e!="object")return null;let t=0;return Wp(e,1,()=>(t+=1,t<=d2))}function Wp(e,t,r){if(!e||typeof e!="object"||t>h2||!r())return null;const s=e;if(s.type==="pane")return typeof s.terminalId=="string"?{type:"pane",terminalId:s.terminalId}:null;if(s.type!=="split"||s.direction!=="horizontal"&&s.direction!=="vertical")return null;const l=Wp(s.first,t+1,r),c=Wp(s.second,t+1,r);return!l||!c?null:{type:"split",direction:s.direction,ratio:g2(s.ratio),first:l,second:c}}function g2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function _2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function v2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const r=new Set,s=[];for(const l of e)typeof l!="string"||!l||r.has(l)||(r.add(l),s.push(l));return s}const Cw=[{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"}],xw="nterminal.notifications.completionEnabled",kg="nterminal.notifications.completionToastEnabled",Eg="nterminal.notifications.completionToastDurationSeconds",Tg="nterminal.notifications.completionToastPersistent",Fp="nterminal:completion-toast-display",oc=6.5,qp=2,$p=60;function Kh(){return typeof window<"u"&&"Notification"in window}function Dg(){try{return window.localStorage.getItem(xw)==="true"}catch{return!1}}function sS(e){try{window.localStorage.setItem(xw,e?"true":"false")}catch{}}function Na(){return{enabled:w2(),durationSeconds:S2(),persistUntilDismissed:C2()}}function b2(e){if(typeof window<"u"){try{window.localStorage.setItem(kg,e?"true":"false")}catch{}Rg()}return Na()}function aS(e){const t=Ew(e);if(typeof window<"u"){try{window.localStorage.setItem(Eg,String(t))}catch{}Rg()}return Na()}function y2(e){if(typeof window<"u"){try{window.localStorage.setItem(Tg,e?"true":"false")}catch{}Rg()}return Na()}function kw(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===kg||r.key===Eg||r.key===Tg)&&e()};return window.addEventListener(Fp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Fp,e),window.removeEventListener("storage",t)}}function Dc(){return Kh()?window.Notification.permission:"unsupported"}function S2(){if(typeof window>"u")return oc;try{const e=window.localStorage.getItem(Eg);return e===null?oc:Ew(Number(e))}catch{return oc}}function w2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(kg)!=="false"}catch{return!0}}function C2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Tg)==="true"}catch{return!1}}function Ew(e){if(!Number.isFinite(e))return oc;const t=Math.round(e*2)/2;return Math.max(qp,Math.min($p,t))}function Rg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Fp))}async function Tw(){if(!Kh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return Dc()}}function x2(e){if(!Kh()||Dc()!=="granted"||!Dg()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const lS="nterminal.push.clientId",k2=2e4;function Ea(){try{const e=window.localStorage.getItem(lS);if(e&&/^[A-Za-z0-9_.:-]{8,128}$/.test(e))return e;const t=`client-${Vp()}`;return window.localStorage.setItem(lS,t),t}catch{return`client-${Vp()}`}}function E2(){return`page-${Vp()}`}function Mg(){const e=typeof window<"u"&&window.isSecureContext===!0,t=N2(),r=e&&typeof window<"u"&&typeof navigator<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&t==="standalone";return{supported:r,secure:e,displayMode:t,deviceKind:A2(),reason:e?t!=="standalone"?"not_standalone":r?"supported":"unsupported":"insecure"}}async function T2(e,t){const r=Mg();if(!r.supported)throw new Error(r.reason);if((Dc()==="granted"?"granted":await Tw())!=="granted")throw new Error("permission_denied");const l=Ea(),c=await navigator.serviceWorker.register("/sw.js"),h=await e.preparePushNotifications(l),g=await z2(c,h.publicKey)??await c.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:P2(h.publicKey)});await e.subscribePushNotifications({clientId:l,subscription:O2(g),deviceKind:r.deviceKind,displayMode:r.displayMode,label:L2(r.deviceKind),alwaysNotify:t})}async function D2(e){const t=Ea();let r;try{const l=await(await navigator.serviceWorker.getRegistration("/sw.js"))?.pushManager.getSubscription();r=l?.endpoint,await l?.unsubscribe()}catch{}await e.unsubscribePushNotifications({clientId:t,...r?{endpoint:r}:{}})}async function R2(e,t){await e.updatePushNotificationDevice({clientId:Ea(),alwaysNotify:t})}function M2(e){if(typeof window>"u")return()=>{};const t=Ea(),r=E2();let s=null,l=!1;const c=(f=!0)=>{const y=Mg();e.updatePushPresence({clientId:t,pageId:r,visibilityState:B2(),focused:document.hasFocus(),deviceKind:y.deviceKind,displayMode:y.displayMode,browserNotificationsEnabled:Dg()&&Dc()==="granted",active:f}).catch(()=>{})},h=()=>{l||s!==null||(s=window.setInterval(()=>c(!0),k2))},p=()=>c(!0),g=()=>c(!1);return window.addEventListener("focus",p),window.addEventListener("blur",p),document.addEventListener("visibilitychange",p),window.addEventListener("pagehide",g),c(!0),h(),()=>{l=!0,s!==null&&(window.clearInterval(s),s=null),window.removeEventListener("focus",p),window.removeEventListener("blur",p),document.removeEventListener("visibilitychange",p),window.removeEventListener("pagehide",g),c(!1)}}function N2(){return typeof window>"u"?"unknown":navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches?"standalone":"browser"}function A2(){if(typeof navigator>"u")return"unknown";const e=navigator.userAgent.toLowerCase();return/ipad|tablet/.test(e)?"tablet":/mobi|android|iphone|ipod/.test(e)?"mobile":"desktop"}function L2(e){return e==="mobile"?"Mobile PWA":e==="tablet"?"Tablet PWA":e==="desktop"?"Desktop PWA":"Installed PWA"}function B2(){const e=document.visibilityState;return e==="visible"||e==="hidden"||e==="prerender"?e:"unknown"}function O2(e){const t=e.toJSON(),r=t.keys?.p256dh,s=t.keys?.auth;if(!t.endpoint||!r||!s)throw new Error("invalid_subscription");return{endpoint:t.endpoint,expirationTime:t.expirationTime??null,keys:{p256dh:r,auth:s}}}async function z2(e,t){const r=await e.pushManager.getSubscription();return r?j2(r,t)?r:(await r.unsubscribe(),null):null}function j2(e,t){const r=e.options.applicationServerKey;return r?H2(r)===t:!0}function P2(e){const t="=".repeat((4-e.length%4)%4),r=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(r),l=new ArrayBuffer(s.length),c=new Uint8Array(l);for(let h=0;h<s.length;h+=1)c[h]=s.charCodeAt(h);return l}function H2(e){const t=new Uint8Array(e);let r="";for(const s of t)r+=String.fromCharCode(s);return window.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Vp(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}const xa="__main__";function I2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function U2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const oS="Local",K2=3e4,W2=2,F2=6,Dw="nterminal.serverList.viewMode.v1";function q2(){try{return window.localStorage.getItem(Dw)==="list"?"list":"stats"}catch{return"stats"}}function $2(e){try{window.localStorage.setItem(Dw,e)}catch{}}function ya(e,t){const r=[xa,...t.map(h=>h.id)],s=new Set(r),l=new Set,c=[];for(const h of e??[])!s.has(h)||l.has(h)||(l.add(h),c.push(h));for(const h of r)l.has(h)||c.push(h);return c}function V2(e,t){const r=new Map(e.map(s=>[s.id,s]));return ya(t,e).flatMap(s=>{if(s===xa)return[{kind:"main",id:xa}];const l=r.get(s);return l?[{kind:"agent",id:s,agent:l}]:[]})}function cS(e,t){return e.length===t.length&&e.every((r,s)=>r===t[s])}function Rw(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Zn(e.cpuPercent)} ${Ng(e)}`,`MEM ${Zn(e.memoryPercent)} ${Qr(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Zn(e.diskPercent)} ${Qr(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Zn(e.swapPercent)} ${Qr(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function Y2(e){if(!(e===void 0||e==="error"))return[`CPU ${Zn(e.cpuPercent)} (${Ng(e)})`,`RAM ${Zn(e.memoryPercent)} (${Qr(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Zn(e.diskPercent)} (${Qr(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Zn(e.swapPercent)} (${Qr(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function X2(e,t){const r=Rw(t);return`${e}${r?` — ${r}`:""}. Double-click to rename.`}function Zn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Ng(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`:`${Yp(e.cpuPercent/100*t)}/${t} cores`}function Qr(e,t){return!uS(e)||!uS(t)?"–/–":G2(e,t)}function G2(e,t){const r=t>=1073741824?"GB":t>=1048576?"MB":"KB",s=r==="GB"?1024**3:r==="MB"?1024**2:1024;return`${Yp(e/s)}/${Yp(t/s)} ${r}`}function Yp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function uS(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Iu(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function Z2(e){return[{label:"CPU",percent:Zn(e.cpuPercent),detail:Ng(e),tone:Iu(e.cpuPercent)},{label:"MEM",percent:Zn(e.memoryPercent),detail:Qr(e.memoryUsedBytes,e.memoryTotalBytes),tone:Iu(e.memoryPercent)},{label:"DISK",percent:Zn(e.diskPercent),detail:Qr(e.diskUsedBytes,e.diskTotalBytes),tone:Iu(e.diskPercent)},{label:"SWAP",percent:Zn(e.swapPercent),detail:Qr(e.swapUsedBytes,e.swapTotalBytes),tone:Iu(e.swapPercent)}]}function Q2({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:Y2(e),children:Z2(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function hS({api:e,activeAgentId:t,onSelectServer:r,onSessionInvalid:s,refreshToken:l=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,y]=v.useState([xa]),[b,S]=v.useState(null),[w,x]=v.useState(null),[D,L]=v.useState(""),A=v.useRef(null),[B,Y]=v.useState(()=>q2()),[P,q]=v.useState(null),[re,ne]=v.useState(null),[he,ve]=v.useState({}),U=v.useRef({}),K=v.useRef(0),W=v.useRef([]),H=v.useRef([xa]),j=v.useRef(null);v.useEffect(()=>{W.current=p},[p]),v.useEffect(()=>{const se=ya(f,p);H.current=se,cS(se,f)||y(se)},[p,f]),v.useEffect(()=>{let se=!1;return e.listAgents().then(pe=>{se||(g(pe.agents),y(ya(pe.serverOrder,pe.agents)))}).catch(()=>{}),e.getMainInfo().then(pe=>{se||S(pe.name)}).catch(()=>{}),()=>{se=!0}},[e,l]),v.useEffect(()=>{w&&(A.current?.focus(),A.current?.select())},[w]),v.useEffect(()=>{let se=!1;function pe(){const be=[{key:"__main__",load:()=>e.getMainStats()},...p.map(Pe=>({key:Pe.id,load:()=>e.getAgentStats(Pe.id)}))],Me=new Set(be.map(Pe=>Pe.key));for(const Pe of Object.keys(U.current))Me.has(Pe)||delete U.current[Pe];ve(Pe=>{const ze={};for(const ie of Me)ie in Pe&&(ze[ie]=Pe[ie]);return ze});for(const Pe of be)Pe.load().then(ze=>{se||(U.current[Pe.key]=0,ve(ie=>Me.has(Pe.key)?{...ie,[Pe.key]:ze}:ie))}).catch(ze=>{if(se)return;if(ze instanceof ur&&ze.status===401&&Pe.key==="__main__"){s?.({source:"main-stats-401",status:401,activeAgentId:null});return}const ie=(U.current[Pe.key]??0)+1;U.current[Pe.key]=ie,ie>=W2&&ve(ke=>Me.has(Pe.key)?{...ke,[Pe.key]:"error"}:ke)})}pe();const Le=window.setInterval(pe,K2);return()=>{se=!0,window.clearInterval(Le)}},[e,p,s]);function ae(se){se==="main"?(L(b??""),x({kind:"main"})):(L(se.name),x({kind:"agent",id:se.id}))}async function R(){if(!w)return;const se=D.trim(),pe=w;if(x(null),pe.kind==="main"){const Le=se||"";try{const be=await e.renameMain(Le);S(be.name)}catch{}}else{if(!se)return;const Le=p.find(be=>be.id===pe.id)?.name;g(be=>be.map(Me=>Me.id===pe.id?{...Me,name:se}:Me));try{await e.renameAgent(pe.id,se)}catch{Le!==void 0&&g(be=>be.map(Me=>Me.id===pe.id?{...Me,name:Le}:Me))}}}function X(){x(null)}function Z(se){Y(se),$2(se)}function Ce(se,pe,Le){if(se===pe)return;const be=ya(H.current,W.current),Me=be.findIndex(je=>je===se),Pe=be.findIndex(je=>je===pe);if(Me<0||Pe<0)return;const ze=[...be],[ie]=ze.splice(Me,1);if(!ie)return;const ke=ze.findIndex(je=>je===pe);if(ke<0)return;const Re=Le==="before"?ke:ke+1;if(ze.splice(Re,0,ie),cS(ze,be))return;const Be=K.current+1;K.current=Be,H.current=ze,y(ze),e.reorderAgents(ze).then(je=>{if(K.current===Be){W.current=je.agents;const at=ya(je.serverOrder,je.agents);H.current=at,g(je.agents),y(at)}}).catch(async()=>{if(K.current===Be)try{const je=await e.listAgents();if(K.current===Be){W.current=je.agents;const at=ya(je.serverOrder,je.agents);H.current=at,g(je.agents),y(at)}}catch{K.current===Be&&(H.current=be,y(be))}})}function Te(se,pe){const Le=ya(H.current,W.current),be=Le.findIndex(Pe=>Pe===se),Me=Le[be+pe];be<0||!Me||Ce(se,Me,pe<0?"before":"after")}function M(se,pe){pe.pointerType==="mouse"&&pe.button!==0||(pe.stopPropagation(),j.current={sourceId:se,pointerId:pe.pointerId,startX:pe.clientX,startY:pe.clientY,active:!1,targetId:null,placement:"after"},pe.currentTarget.setPointerCapture?.(pe.pointerId))}function Q(se){const pe=j.current;if(!pe||pe.pointerId!==se.pointerId)return;const Le=Math.hypot(se.clientX-pe.startX,se.clientY-pe.startY);if(!pe.active){if(Le<F2)return;pe.active=!0,q(pe.sourceId)}const Me=document.elementFromPoint(se.clientX,se.clientY)?.closest("[data-server-id]"),Pe=Me?.dataset.serverId??null;if(!Me||!Pe||Pe===pe.sourceId){pe.targetId=null,ne(null);return}const ze=Me.getBoundingClientRect(),ie=se.clientY<ze.top+ze.height/2?"before":"after";pe.targetId=Pe,pe.placement=ie,ne({serverId:Pe,placement:ie})}function de(se){const pe=j.current;!pe||pe.pointerId!==se.pointerId||(se.stopPropagation(),se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ne(null),pe.active&&pe.targetId&&Ce(pe.sourceId,pe.targetId,pe.placement))}function me(se){const pe=j.current;pe&&pe.pointerId===se.pointerId&&se.currentTarget.releasePointerCapture?.(se.pointerId),j.current=null,q(null),ne(null)}const ge=b?.trim()||oS,Se=w?.kind==="main",Ee=B==="stats",De=V2(p,f),Ke=De.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:De.map(se=>{const pe=se.kind==="main",Le=pe?ge:se.agent.name,be=pe?xa:se.id,Me=he[be],Pe=Rw(Me);return m.jsxs("button",{type:"button",className:`server-list-chip${(pe?t===null:t===se.id)?" server-list-chip--active":""}`,onClick:()=>r(pe?null:se.id),"aria-label":Le,title:`${Le}${Pe?` — ${Pe}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:U2(Le)}),m.jsx("span",{className:"server-list-chip-pip","data-status":I2(Me)})]},se.id)})}):m.jsxs("div",{className:`server-list server-list--${B}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":B==="list",onClick:()=>Z("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":B==="stats",onClick:()=>Z("stats"),title:"Show resource usage",children:"Stats"})]}),De.map(se=>{const pe=se.kind==="main",Le=pe?ge:se.agent.name,be=pe?xa:se.id,Me=pe?t===null:t===se.id,Pe=pe?Se:w?.kind==="agent"&&w.id===se.id,ze=c?.({agentId:pe?null:se.id,serverId:se.id,label:Le,active:Me}),ie=re?.serverId===se.id&&P!==se.id?` server-list-section--drop-target server-list-section--drop-${re.placement}`:"";return m.jsxs("section",{className:`server-list-section${ie}`,"aria-label":`${Le} server`,children:[m.jsx("div",{className:["server-list-row",P===se.id?"server-list-row--dragging":"",re?.serverId===se.id&&P!==se.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":se.id,children:Pe?m.jsxs(m.Fragment,{children:[Ke?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:ke=>{ke.preventDefault(),R()},children:m.jsx("input",{ref:A,"aria-label":pe?"Rename main server":`Rename ${Le}`,value:D,onChange:ke=>L(ke.target.value),onBlur:()=>{R()},onKeyDown:ke=>{ke.key==="Escape"&&(ke.preventDefault(),X())},placeholder:pe?oS:void 0})})]}):m.jsxs(m.Fragment,{children:[Ke?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":se.id,title:"Drag to reorder","aria-label":`Reorder ${Le}`,"aria-grabbed":P===se.id,onPointerDown:ke=>M(se.id,ke),onPointerMove:Q,onPointerUp:de,onPointerCancel:me,onKeyDown:ke=>{(ke.key==="ArrowUp"||ke.key==="ArrowDown")&&(ke.preventDefault(),ke.stopPropagation(),Te(se.id,ke.key==="ArrowUp"?-1:1))},onClick:ke=>ke.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Me?" server-list-item--active":""}`,onClick:()=>r(pe?null:se.id),onDoubleClick:ke=>{ke.preventDefault(),ae(pe?"main":{id:se.id,name:Le})},title:X2(Le,he[be]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:pe?void 0:se.agent.url,children:Le})]}),Ee?m.jsx(Q2,{entry:he[be]}):null]})]})}),ze?m.jsx("div",{className:"server-list-children",children:ze}):null]},se.id)})]})}function J2({api:e}){const[t,r]=v.useState([]),[s,l]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,y]=v.useState(""),[b,S]=v.useState("");async function w(){try{const[A,B,Y]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);r(A.devices),l(B.networks),h(Y.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function x(A){await e.revokeDevice(A),await w()}async function D(A){await e.removeNetwork(A),await w()}async function L(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:b.trim()}),y(""),S(""),await w()}catch(B){g(B instanceof Error?B.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[p?m.jsx("p",{className:"form-error",children:p}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[A.label,A.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(A.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{x(A.id)},children:"revoke"})]},A.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),s.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:s.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?m.jsx("span",{className:"security-item-meta",children:A.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{D(A.id)},children:"remove"})]},A.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:L,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:A=>y(A.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:A=>S(A.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const eT=1500,Ag="nterminal.terminal.fontSize",Lg="nterminal.terminal.fontFamily",Xp="nterminal:terminal-font-size",Gp="nterminal:terminal-font-family",Zp=11,Qp=20,Ta=14,vh=[{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:[]}],zl="meslo";Jp(zl);async function cp(e=Ta,t=zl){if(typeof document>"u"||!document.fonts)return;const r=Aw(t).webFontFamilies;if(r.length===0)return;const s=Promise.all(r.map(l=>document.fonts.load(`${e}px ${l}`))).then(()=>{}).catch(()=>{});await Promise.race([s,new Promise(l=>{globalThis.setTimeout(l,eT)})])}function Mw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Ta;const r=Math.round(t);return Math.max(Zp,Math.min(Qp,r))}function Nw(e){return vh.some(t=>t.id===e)?e:zl}function Jp(e){return Aw(e).cssFamily}function Aw(e){return vh.find(t=>t.id===e)??vh[0]}function em(){if(typeof window>"u")return Ta;try{const e=window.localStorage.getItem(Ag);return e?Mw(e):Ta}catch{return Ta}}function tm(){if(typeof window>"u")return zl;try{return Nw(window.localStorage.getItem(Lg))}catch{return zl}}function Uu(e){const t=Mw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Ag,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Xp,{detail:t})),t}function tT(e){const t=Nw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(Lg,t)}catch{}return window.dispatchEvent(new CustomEvent(Gp,{detail:t})),t}function Lw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Ag&&e()};return window.addEventListener(Xp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Xp,e),window.removeEventListener("storage",t)}}function Bw(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Lg&&e()};return window.addEventListener(Gp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Gp,e),window.removeEventListener("storage",t)}}const Bg="nterminal.terminal.showScrollProgress",im="nterminal:terminal-scroll-progress",Og="nterminal.terminal.tmuxScrollback.shell",zg="nterminal.terminal.tmuxScrollback.agent",jg="nterminal.terminal.tmuxScrollback.overrides",pc="nterminal:terminal-tmux-scrollback",iT=200;function nm(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Bg)!=="false"}catch{return!0}}function nT(e){if(typeof window<"u"){try{window.localStorage.setItem(Bg,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(im,{detail:e}))}return e}function Ow(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Bg&&e()};return window.addEventListener(im,e),window.addEventListener("storage",t),()=>{window.removeEventListener(im,e),window.removeEventListener("storage",t)}}function rm(){return zw(Og,!0)}function rT(e){return jw(Og,e,pc)}function sm(){return zw(zg,!0)}function sT(e){return jw(zg,e,pc)}function th(e){if(typeof window>"u")return()=>{};const t=r=>{(r.key===Og||r.key===zg||r.key===jg)&&e()};return window.addEventListener(pc,e),window.addEventListener("storage",t),()=>{window.removeEventListener(pc,e),window.removeEventListener("storage",t)}}function up(e){const r=Pw()[e];return typeof r=="boolean"?r:null}function aT(e,t){if(typeof window<"u"){try{const r=Pw(),s=Object.entries(r).filter(([c])=>c!==e);s.push([e,t]);const l=s.slice(-iT);window.localStorage.setItem(jg,JSON.stringify(Object.fromEntries(l)))}catch{}window.dispatchEvent(new CustomEvent(pc,{detail:{terminalId:e,enabled:t}}))}return t}function zw(e,t){if(typeof window>"u")return t;try{const r=window.localStorage.getItem(e);if(r==="true")return!0;if(r==="false")return!1}catch{}return t}function jw(e,t,r){if(typeof window<"u"){try{window.localStorage.setItem(e,t?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(r,{detail:t}))}return t}function Pw(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(jg);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const r={};for(const[s,l]of Object.entries(t))typeof l=="boolean"&&(r[s]=l);return r}catch{return{}}}const Pg="nterminal.shortcuts.workspace.v1",am="nterminal:workspace-shortcuts",mc=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0},{id:"scrollback.toggle",label:"Toggle tmux scrollback",group:"Panes",requiresPrimaryModifier:!0}],Wh={"server.previous":bi("ArrowUp",{ctrlKey:!0}),"server.next":bi("ArrowDown",{ctrlKey:!0}),"tab.previous":bi("ArrowLeft",{ctrlKey:!0}),"tab.next":bi("ArrowRight",{ctrlKey:!0}),"tab.index":bi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":bi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":bi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":bi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":bi("KeyH",{altKey:!0}),"scrollback.toggle":bi("KeyS",{altKey:!0})},lT={"server.previous":bi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":bi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":bi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":bi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":bi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":bi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":bi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":bi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":bi("KeyH",{altKey:!0}),"scrollback.toggle":bi("KeyS",{altKey:!0})};function Aa(){const e=Uw(Wh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Pg);if(!t)return e;const r=JSON.parse(t);for(const s of mc){const l=r[s.id];if(mT(l)){const c=Kw(l,s);pT(c,lT[s.id])||(e[s.id]=c)}}}catch{return e}return e}function dS(){return JSON.stringify(Aa())}function oT(e,t){const r=Aa(),s=mc.find(l=>l.id===e);return s&&(r[e]=Kw(t,s),Hg(r)),r}function cT(e){const t=Aa();return t[e]={...Wh[e]},Hg(t),t}function uT(){const e=Uw(Wh);return Hg(e),e}function bh(e){if(typeof window>"u")return()=>{};const t=r=>{r.key===Pg&&e()};return window.addEventListener(am,e),window.addEventListener("storage",t),()=>{window.removeEventListener(am,e),window.removeEventListener("storage",t)}}function hT(e,t){const r=qw(e);return!r||_T(r)||t.indexed&&Fw(e)===null||t.requiresPrimaryModifier&&!Ww(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":r}}function Hw(e){const t=Aa();for(const r of mc){const s=t[r.id];if(!(!s||!gT(e,s))){if(r.indexed){if(s.code!=="Digit")continue;const l=Fw(e);if(l!==null)return{id:r.id,index:l};continue}if(qw(e)===s.code)return{id:r.id,index:null}}}return null}function yh(e){return Iw(Aa()[e])}function Iw(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(vT(e.code)),t.join("+")}const dT=()=>yh("split.right"),fT=()=>yh("split.down");function bi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function Uw(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r}]))}function pT(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function Hg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(Pg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(am))}}function Kw(e,t){return t.requiresPrimaryModifier&&!Ww(e)?{...Wh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function Ww(e){return e.ctrlKey||e.altKey||e.metaKey}function mT(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 gT(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function Fw(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 qw(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 _T(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function vT(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const r=/^Key([A-Z])$/.exec(e);if(r?.[1])return r[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 bT="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 yT(e="nterminal",t=new Date){return{reason:"permission",message:bT,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function ST(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 $w=3600*1e3,wT="local",lm=new Set,Hs=new Map;let Ws={checking:!1,hasUpdates:!1,lastCheckedAt:null},Ig=null,cc=null,Sh=0,Os=null;function CT(e){return lm.add(e),()=>{lm.delete(e)}}function fS(){return Ws}function xT(e){const t=RT();Ig=e,Ug(),om(e,t);const r=()=>{if(document.visibilityState!=="visible"||!Fs(e,t))return;const s=Ws.lastCheckedAt;(s===null||Date.now()-s>=$w)&&om(e,t)};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r),Fs(e,t)&&DT()}}function kT(e,t){Hs.set(e,Vw(t)),jl({...Ws,hasUpdates:Kg(),lastCheckedAt:Date.now()})}function hp(e){e===void 0?Hs.clear():Hs.set(e,!1),jl({...Ws,hasUpdates:Kg()})}async function om(e,t){if(!Fs(e,t))return;if(Os&&Os.api===e&&Os.runId===t)return Os.promise;jl({...Ws,checking:!0});const r=ET(e,t).finally(()=>{Os?.promise===r&&(Os=null),Fs(e,t)&&(jl({...Ws,checking:!1,lastCheckedAt:Date.now()}),TT(e,t))});return Os={api:e,runId:t,promise:r},r}async function ET(e,t){try{const r=await e.listAgents();if(!Fs(e,t))return;const s=[{key:wT,check:()=>e.checkUpdate()},...r.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],l=new Map;if(await Promise.all(s.map(async c=>{try{const h=await c.check();l.set(c.key,Vw(h))}catch{l.set(c.key,Hs.get(c.key)??!1)}})),!Fs(e,t))return;Hs.clear();for(const[c,h]of l)Hs.set(c,h);jl({...Ws,hasUpdates:Kg()})}catch{}}function TT(e,t){Fs(e,t)&&(Ug(),cc=window.setTimeout(()=>{cc=null,Fs(e,t)&&om(e,t)},$w))}function DT(){Sh+=1,Ug(),Ig=null,Os=null,Hs.clear(),jl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function Ug(){cc!==null&&(window.clearTimeout(cc),cc=null)}function RT(){return Sh+=1,Sh}function Fs(e,t){return Ig===e&&Sh===t}function Vw(e){return e.updateAvailable===!0}function Kg(){return Array.from(Hs.values()).some(Boolean)}function jl(e){Ws=e;for(const t of Array.from(lm))t()}const MT=e=>new Promise(t=>setTimeout(t,e));function NT({api:e,onAgentRemoved:t}){const[r,s]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[l,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[y,b]=v.useState(!1);function S(U,K){c(W=>({...W,[U]:{...W[U],...K}}))}const w=U=>U.id===null?e.getVersion():e.getAgentVersion(U.id),x=U=>U.id===null?e.checkUpdate():e.checkAgentUpdate(U.id),D=U=>U.id===null?e.runUpdate():e.runAgentUpdate(U.id);v.useEffect(()=>{let U=!1;return e.listAgents().then(K=>{if(U)return;const W=[{key:"local",id:null,name:"Local (main)"},...K.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];s(W);for(const H of W)w(H).then(j=>S(H.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(H.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{U=!0}},[]);async function L(U){S(U.key,{busy:!0,status:"checking…",error:void 0});try{const K=await x(U);kT(U.key,K),S(U.key,{latestVersion:K.latestVersion,updateAvailable:K.updateAvailable,status:ne(K),...K.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(K){S(U.key,{busy:!1,error:K instanceof Error?K.message:"check failed"})}}async function A(){p(!0),await Promise.all(r.map(U=>L(U))),p(!1)}async function B(U,K){const W=Date.now()+18e4;for(;Date.now()<W;){await MT(3e3);try{const H=await w(U);if(K&&H.runningVersion!==K.runningVersion)return H}catch{}}return null}async function Y(U){let K=l[U.key]?.version;if(!K)try{K=await w(U),S(U.key,{version:K,manualUpdate:K.manualUpdate??null})}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(U.key,{busy:!0,status:"updating…",error:void 0});let W;try{W=await D(U)}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!W.ok){const j=W.manualUpdate??(ST(W.message)?yT():null);return j?(S(U.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(U.key,{busy:!1,status:void 0,error:W.message}),"failed")}if(!W.changed)return S(U.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),hp(U.key),"unchanged";S(U.key,{status:"restarting…"});const H=await B(U,K);return H?(S(U.key,{busy:!1,version:H,updateAvailable:!1,status:"updated",manualUpdate:H.manualUpdate??null}),hp(U.key),U.id===null&&(b(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(S(U.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function P(U){if(!(U.id===null||!window.confirm([`Delete secondary server "${U.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){S(U.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const W=await e.uninstallAgent(U.id);s(H=>H.filter(j=>j.key!==U.key)),c(H=>{const j={...H};return delete j[U.key],j}),hp(U.key),t?.(U.id),f(W.message)}catch(W){S(U.key,{busy:!1,status:void 0,error:W instanceof Error?W.message:"delete failed"})}}}async function q(){p(!0),f(null);const U=r.filter(R=>R.id!==null),K=r.find(R=>R.id===null),W=await Promise.all(U.map(R=>Y(R))),H=W.filter(R=>R==="failed").length;let j=W.filter(R=>R==="manual").length,ae=null;if(K&&(ae=await Y(K),ae==="manual"&&(j+=1),ae==="updated")){H>0&&f("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),p(!1);return}H>0&&j>0?f("Some servers failed and some need manual update. Check each marked row."):H>0?f("Some secondary servers failed to update. Check their rows and retry."):j>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function re(U){return U?U.error?U.error:U.status?U.status:U.manualUpdate?"manual update required":U.version?`v${U.version.version}`:"…":"…"}function ne(U){return U.error?U.error:typeof U.updateAvailable=="boolean"?U.updateAvailable?`latest v${U.latestVersion??"available"}`:"up to date":"unknown"}function he(U){const K=U?.version;return K?`npm package v${K.runningVersion}`:""}async function ve(U,K){try{await AT(K),S(U,{copiedCommand:!0}),window.setTimeout(()=>S(U,{copiedCommand:!1}),1800)}catch(W){S(U,{error:W instanceof Error?W.message:"copy failed"})}}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{A()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{q()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,y?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsx("ul",{className:"security-list",children:r.map(U=>{const K=l[U.key],W=he(K),H=K?.manualUpdate??null,j=K?.version!==void 0&&K?.updateAvailable!==!1&&!K?.busy&&!h,ae=U.id!==null&&!K?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:U.name}),m.jsxs("span",{className:"security-item-meta",children:[W?`${W} — `:"",re(K)]})]}),H?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:H.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:H.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(U.key,H.command)},children:K?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{Y(U)},disabled:!j,children:K?.busy?"…":"Update"}),U.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{P(U)},disabled:!ae,children:"Delete"}):null]})]},U.key)})})]})}async function AT(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 Ku=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function LT({onClose:e,api:t,updateAvailable:r=!1,onNotificationAssetsChanged:s,onAgentRemoved:l}){const c=v.useMemo(()=>t??zh(),[t]),[h,p]=v.useState(()=>em()),[g,f]=v.useState(()=>tm()),[y,b]=v.useState(()=>nm()),[S,w]=v.useState(()=>rm()),[x,D]=v.useState(()=>sm()),[L,A]=v.useState(()=>Us()),[B,Y]=v.useState(()=>Aa()),[P,q]=v.useState(null),[re,ne]=v.useState(null),[he,ve]=v.useState("appearance"),[U,K]=v.useState(()=>Dg()),[W,H]=v.useState(()=>Na()),[j,ae]=v.useState(()=>Dc()),[R,X]=v.useState([]),[Z,Ce]=v.useState([]),[Te,M]=v.useState([]),[Q,de]=v.useState(5*1024*1024),[me,ge]=v.useState(!1),[Se,Ee]=v.useState(null),[De,Ke]=v.useState(null),[se,pe]=v.useState(!1),[Le,be]=v.useState(null),Me=v.useRef(null),Pe=v.useRef(null),ze=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,servers:null}),ie=v.useMemo(()=>new Set(Z),[Z]),ke=!OT(Z,Te),Re=v.useMemo(()=>Mg(),[]),Be=De?.displayMode==="standalone"&&(De.deviceKind==="mobile"||De.deviceKind==="tablet");v.useEffect(()=>Lw(()=>p(em())),[]),v.useEffect(()=>Bw(()=>f(tm())),[]),v.useEffect(()=>Ow(()=>b(nm())),[]),v.useEffect(()=>th(()=>{w(rm()),D(sm())}),[]),v.useEffect(()=>_g(()=>A(Us())),[]),v.useEffect(()=>bh(()=>Y(Aa())),[]),v.useEffect(()=>kw(()=>H(Na())),[]),v.useEffect(()=>{if(!P)return;const F=mc.find(st=>st.id===P);if(!F)return;const Ue=st=>{if(st.preventDefault(),st.stopPropagation(),st.key==="Escape"){q(null),ne(null);return}const Si=hT(st,F);if(!Si){ne(BT(F));return}Y(oT(P,Si)),q(null),ne(null)};return window.addEventListener("keydown",Ue,!0),()=>window.removeEventListener("keydown",Ue,!0)},[P]),v.useEffect(()=>{let F=!1;return c.listNotificationAssets().then(Ue=>{F||kt(Ue)}).catch(Ue=>{F||Ee(Tl(Ue))}),()=>{F=!0}},[c]),v.useEffect(()=>{let F=!1;return c.getPushNotificationStatus(Ea()).then(Ue=>{F||(Ke(Ue.currentDevice),be(null))}).catch(Ue=>{F||be(Tl(Ue))}),()=>{F=!0}},[c]);function je(F){p(Uu(Number(F)))}function at(F){H(aS(Number(F)))}function Xt(F){ve(F);const Ue=Pe.current,st=ze.current[F];if(!Ue||!st)return;const Si=Math.max(0,pS(st,Ue)-12);typeof Ue.scrollTo=="function"?Ue.scrollTo({top:Si,behavior:"smooth"}):Ue.scrollTop=Si}function Ve(){const F=Pe.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){ve(Ku[Ku.length-1].id);return}let Ue="appearance";const st=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const Si of Ku){const wi=ze.current[Si.id];wi&&pS(wi,F)<=st&&(Ue=Si.id)}ve(Ue)}function xt(F){Y(cT(F)),q(null),ne(null)}function ti(){Y(uT()),q(null),ne(null)}function kt(F){const Ue=F.assets.filter(st=>st.enabled).map(st=>st.id);X(F.assets),Ce(Ue),M(Ue),de(F.maxFileBytes),Ee(null)}async function _e(){if(U){sS(!1),K(!1);return}let F=j;F==="default"&&(F=await Tw(),ae(F)),F==="granted"&&(sS(!0),K(!0))}async function Fe(){pe(!0),be(null);try{if(De)await D2(c),Ke(null);else{await T2(c,!1);const F=await c.getPushNotificationStatus(Ea());Ke(F.currentDevice)}}catch(F){be(mS(F))}finally{pe(!1)}}async function Je(F){pe(!0),be(null);try{await R2(c,F);const Ue=await c.getPushNotificationStatus(Ea());Ke(Ue.currentDevice)}catch(Ue){be(mS(Ue))}finally{pe(!1)}}async function ct(F){const Ue=F?.[0];if(Ue){if(Ue.size>Q){Ee(`File must be ${dp(Q)} or smaller.`),bt();return}if(Ue.type!=="video/mp4"&&Ue.type!=="video/webm"){Ee("Upload an MP4 or WebM video."),bt();return}ge(!0),Ee(null);try{await c.uploadNotificationAsset(Ue),kt(await c.listNotificationAssets()),s?.()}catch(st){Ee(Tl(st))}finally{ge(!1),bt()}}}async function Pt(F){ge(!0),Ee(null);try{await c.deleteNotificationAsset(F),kt(await c.listNotificationAssets()),s?.()}catch(Ue){Ee(Tl(Ue))}finally{ge(!1)}}function bt(){Me.current&&(Me.current.value="")}function Nt(F,Ue){const st=new Set(Z);if(Ue?st.add(F):st.delete(F),st.size===0){Ee("Keep at least one toast video selected.");return}Ee(null),Ce(Array.from(st))}async function Ft(){if(Z.length===0){Ee("Keep at least one toast video selected.");return}ge(!0),Ee(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:Z});kt(F),s?.()}catch(F){Ee(Tl(F))}finally{ge(!1)}}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:F=>F.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Ku.map(F=>m.jsxs("button",{type:"button","data-active":he===F.id?"true":"false","aria-current":he===F.id?"true":void 0,onClick:()=>Xt(F.id),children:[F.label,F.id==="servers"&&r?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),m.jsxs("div",{ref:Pe,className:"settings-content",onScroll:Ve,children:[m.jsxs("section",{id:"settings-appearance",ref:F=>{ze.current.appearance=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:fh.map(F=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":L===F.id,"data-active":L===F.id?"true":"false",onClick:()=>A(Hk(F.id)),style:{"--settings-theme-bg":F.tokens.bg,"--settings-theme-bg-2":F.tokens.bg2,"--settings-theme-sidebar":F.tokens.bgSidebar,"--settings-theme-line":F.tokens.line,"--settings-theme-fg":F.tokens.fg,"--settings-theme-fg-2":F.tokens.fg2,"--settings-theme-accent":F.tokens.accent,"--settings-theme-xterm-bg":F.xterm.background,"--settings-theme-xterm-fg":F.xterm.foreground,"--settings-theme-xterm-selection":F.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:F.label}),m.jsx("small",{children:F.description})]})]},F.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Zp,max:Qp,step:1,value:h,"aria-label":"Terminal font size",onChange:F=>je(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Uu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Zp,max:Qp,step:1,value:h,"aria-label":"Terminal font size value",onChange:F=>je(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Uu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Uu(Ta)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:F=>f(tT(F.currentTarget.value)),children:vh.map(F=>m.jsx("option",{value:F.id,children:F.label},F.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:y,onChange:F=>b(nT(F.currentTarget.checked))}),"Show scroll progress"]}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Scrollback source"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose whether wheel and touch scroll input use tmux scrollback by default."})]})}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:S,onChange:F=>w(rT(F.currentTarget.checked))}),"Shell panes"]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:x,onChange:F=>D(sT(F.currentTarget.checked))}),"Codex/Claude panes"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:F=>{ze.current.shortcuts=F},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ti,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),re?m.jsx("p",{className:"settings-error",children:re}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:mc.map(F=>{const Ue=P===F.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:F.label}),m.jsx("span",{className:"settings-shortcut-group",children:F.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":Ue?"true":"false",onClick:()=>{q(F.id),ne(null)},children:Ue?"Press keys…":Iw(B[F.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>xt(F.id),children:"Reset"})]})]},F.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:F=>{ze.current.notifications=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),Kh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:U&&j==="granted",onChange:()=>{_e()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="denied"?m.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("div",{className:"settings-subsection",children:[m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:!!De,onChange:()=>{Fe()},disabled:se||!Re.supported}),"Installed app push notifications"]}),m.jsx("p",{className:"muted",children:"Sends native completion alerts to this installed PWA when no live page can show the usual in-app or browser notification."}),Re.supported?null:m.jsx("p",{className:"muted",children:cm(Re.reason)}),De?m.jsxs("p",{className:"muted",children:["Registered as ",De.label,". Last active ",new Date(De.lastActiveAt).toLocaleString(),"."]}):null,Be?m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:De?.alwaysNotify===!0,onChange:F=>{Je(F.currentTarget.checked)},disabled:se||!De}),"Always notify this mobile device"]}):null,Le?m.jsx("p",{className:"form-error",children:Le}):null]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.enabled,onChange:F=>H(b2(F.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:W.persistUntilDismissed?"Until closed":`${W.durationSeconds}s`}),m.jsx("input",{type:"range",min:qp,max:$p,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>at(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:qp,max:$p,step:.5,value:W.durationSeconds,disabled:!W.enabled||W.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>at(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!W.enabled||W.persistUntilDismissed,onClick:()=>H(aS(oc)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:W.persistUntilDismissed,disabled:!W.enabled,onChange:F=>H(y2(F.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[dp(Q)," max"]})]}),m.jsx("input",{ref:Me,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{ct(F.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:me,onClick:()=>Me.current?.click(),children:"Upload video"}),Se?m.jsx("p",{className:"settings-error",children:Se}):null,R.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:R.map(F=>m.jsxs("li",{"data-enabled":ie.has(F.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:ie.has(F.id),disabled:me,"aria-label":`Use ${F.filename}`,onChange:Ue=>Nt(F.id,Ue.currentTarget.checked)}),m.jsx("video",{src:F.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:F.filename}),m.jsx("small",{children:F.source==="built-in"?"Built-in":dp(F.size)})]})]}),F.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:me,"aria-label":`Delete ${F.filename}`,onClick:()=>{Pt(F.id)},children:"x"}):null]},F.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:me||R.length===0||!ke,onClick:()=>{Ft()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:F=>{ze.current.security=F},className:"settings-section-group",children:m.jsx(J2,{api:c})}),m.jsx("div",{id:"settings-servers",ref:F=>{ze.current.servers=F},className:"settings-section-group",children:m.jsx(NT,{api:c,...l?{onAgentRemoved:l}:{}})})]})]})]})})}function pS(e,t){const r=e.getBoundingClientRect(),s=t.getBoundingClientRect();return r.top-s.top+t.scrollTop}function dp(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 Tl(e){return e instanceof Error?e.message:"Request failed."}function cm(e){return e==="insecure"?"Installed app push notifications require HTTPS or localhost.":e==="not_standalone"?"Install NTerminal as an app first. On iOS, add it to the Home Screen before enabling push.":"This browser does not support installed app push notifications."}function mS(e){const t=Tl(e);return t==="permission_denied"?"Notification permission was not granted.":t==="not_standalone"?cm("not_standalone"):t==="insecure"?cm("insecure"):t}function BT(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 OT(e,t){if(e.length!==t.length)return!1;const r=new Set(t);return e.every(s=>r.has(s))}class _a extends Error{constructor(t,r){super(r),this.status=t,this.name="UploadClientError"}status}function zT(e){const t=e.createXhr?.()??new XMLHttpRequest,r=new FormData,s=e.files.map((l,c)=>({fieldName:`file${c}`,relativePath:l.relativePath,size:l.file.size}));r.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:s}));for(const[l,c]of e.files.entries())r.append(`file${l}`,c.file);return new Promise((l,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{h||(h=!0,p(),l(b))},f=b=>{h||(h=!0,p(),c(b))},y=()=>{t.abort(),f(new _a(0,"Upload aborted."))};if(e.signal?.aborted){f(new _a(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new _a(t.status,"Invalid upload response."))}return}f(new _a(t.status,jT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new _a(0,"Upload failed.")),t.onabort=()=>f(new _a(0,"Upload aborted.")),t.ontimeout=()=>f(new _a(0,"Upload timed out.")),t.send(r)})}function jT(e,t){try{const r=JSON.parse(e),s=typeof r.error=="string"?r.error:r.message;if(typeof s=="string"&&s.trim())return s}catch{}return t}const PT="modulepreload",HT=function(e){return"/"+e},gS={},Wg=function(t,r,s){let l=Promise.resolve();if(r&&r.length>0){let g=function(f){return Promise.all(f.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");l=g(r.map(f=>{if(f=HT(f),f in gS)return;gS[f]=!0;const y=f.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const S=document.createElement("link");if(S.rel=y?"stylesheet":PT,y||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),y)return new Promise((w,x)=>{S.addEventListener("load",w),S.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return l.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},IT=v.lazy(()=>Wg(()=>import("./MarkdownPreview-DCHLz_jq.js"),__vite__mapDeps([0,1])));function UT({api:e,activeTerminalId:t,activeTerminalCwd:r,workspaceRootPath:s=null,onOpenFile:l}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,y]=v.useState({}),[b,S]=v.useState(()=>new Set),[w,x]=v.useState(null),[D,L]=v.useState({type:"empty"}),[A,B]=v.useState("idle"),[Y,P]=v.useState(null),q=v.useRef(null),re=v.useRef(null),ne=v.useRef(!1),he=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const U=ve.current,K=s?WT(s):t?_S(t,r):null,W=c?[c.rootPath,p].filter(Boolean).join("/"):"",H=w?.path??null;v.useEffect(()=>(ne.current=!0,()=>{ne.current=!1,he.current+=1,pe()}),[]),v.useEffect(()=>{ve.current=t,re.current=null,j(K)},[e]),v.useEffect(()=>{s&&K!==re.current&&ae(s,K)},[s,K]),v.useEffect(()=>{if(s||!U||t!==U)return;const ie=_S(U,r);ie!==re.current&&R(U,ie)},[U,t,r,s]);async function j(ie=K){if(s){await ae(s,ie);return}await R(t,ie)}async function ae(ie,ke=K){const Re=Le();if(re.current=ke,pe(),h(null),g(""),y({}),S(new Set),x(null),L({type:"empty"}),P(null),!ie){B("idle");return}B("loading");try{const Be=await e.createFileRoot({path:ie});if(!be(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const je=await e.listFiles({rootToken:Be.rootToken,path:""});if(!be(Re))return;Ce(je),B("idle")}catch(Be){be(Re)&&(P(Vr(Be)),B("idle"))}}async function R(ie,ke=K){const Re=Le();if(re.current=ke,pe(),h(null),g(""),y({}),S(new Set),x(null),L({type:"empty"}),P(null),!ie){B("idle");return}B("loading");try{const Be=await e.createFileRoot({terminalId:ie});if(!be(Re))return;h({rootToken:Be.rootToken,rootPath:Be.rootPath});const je=await e.listFiles({rootToken:Be.rootToken,path:""});if(!be(Re))return;Ce(je),B("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Vr(Be)),B("idle"))}}async function X(ie=p,ke=c){if(!ke)return;const Re=Le();B("loading"),P(null);try{const Be=await e.listFiles({rootToken:ke.rootToken,path:ie});if(!be(Re))return;Ce(Be),B("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Vr(Be)),B("idle"))}}async function Z(){if(s){await ae(s,K);return}ve.current=t,await R(t,K)}function Ce(ie){y(ke=>({...ke,[ie.path]:FT(ie.entries)}))}async function Te(ie){if(!(!fp(ie)||!c)){if(x(ie),P(null),ie.kind==="directory"){g(ie.path),se(),await Q(ie);return}if(g(va(ie.path)),ie.editable){await me(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function M(ie){if(!(!fp(ie)||!c)){if(x(ie),P(null),ie.kind==="directory"){g(ie.path),se(),await Q(ie);return}if(g(va(ie.path)),ie.editable){await ge(ie);return}ie.previewKind!=="none"&&await Se(ie,ie.previewKind)}}async function Q(ie){if(b.has(ie.path)){S(ke=>{const Re=new Set(ke);return Re.delete(ie.path),Re});return}S(ke=>new Set(ke).add(ie.path)),await X(ie.path)}function de(ie,ke){ie.key==="Enter"&&(ie.preventDefault(),M(ke))}async function me(ie){if(!c)return;const ke=Le();B("loading"),pe();try{const Re=await e.readFile({rootToken:c.rootToken,path:ie.path});if(!be(ke))return;L({type:"text-preview",file:ie,read:Re}),B("idle")}catch(Re){if(await Me(Re,ke))return;be(ke)&&(P(Vr(Re)),B("idle"))}}async function ge(ie){if(!c)return;const ke=Le();B("loading");try{await l({rootToken:c.rootToken,path:ie.path,...t?{terminalId:t}:{}}),be(ke)&&B("idle")}catch(Re){if(await Me(Re,ke))return;be(ke)&&(P(Vr(Re)),B("idle"))}}async function Se(ie,ke){if(!c)return;const Re=Le();B("loading"),pe();try{const Be=await e.previewFile({rootToken:c.rootToken,path:ie.path});if(!be(Re))return;const je=URL.createObjectURL(Be);if(!be(Re)){URL.revokeObjectURL(je);return}q.current=je,L({type:"preview",file:ie,previewKind:ke,url:je}),B("idle")}catch(Be){if(await Me(Be,Re))return;be(Re)&&(P(Vr(Be)),B("idle"))}}async function Ee(ie){if(!c)return;const ke=ie==="file"?"New file":"New folder",Re=window.prompt(ke,""),Be=w?w.kind==="directory"?w.path:va(w.path):p,je=vS(Re,Be);if(je){P(null);try{const at=await e.createFileEntry({rootToken:c.rootToken,path:je,kind:ie});x(at.entry),await X(Be)}catch(at){if(await Me(at))return;P(Vr(at))}}}async function De(){if(!c||!w)return;const ie=window.prompt("Move selected entry",w.path),ke=vS(ie,"");if(!ke||ke===w.path)return;const Re=va(w.path),Be=va(ke);P(null);try{const je=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:ke});x(je.entry),g(je.entry.kind==="directory"?je.entry.path:va(je.entry.path)),se(),await X(Re),Be!==Re&&await X(Be)}catch(je){if(await Me(je))return;P(Vr(je))}}async function Ke(){if(!c||!w)return;const ie=w.path,ke=va(ie);P(null);try{const Re=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Be=Re.descendantCount>0?` and ${Re.descendantCount} nested item${Re.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Re.path}${Be}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:Re.previewToken}),x(null),g(ke),S(je=>{const at=new Set(je);for(const Xt of je)(Xt===ie||Xt.startsWith(`${ie}/`))&&at.delete(Xt);return at}),se(),await X(ke)}catch(Re){if(await Me(Re))return;P(Vr(Re))}}function se(){he.current+=1,pe(),L({type:"empty"})}function pe(){q.current&&(URL.revokeObjectURL(q.current),q.current=null)}function Le(){return he.current+=1,he.current}function be(ie){return ne.current&&ie===he.current}async function Me(ie,ke){return qT(ie)?(ke!==void 0&&!be(ke)||await j(K),!0):!1}function Pe(ie,ke){const Re=fp(ie),Be=ie.kind==="directory"&&b.has(ie.path),je=f[ie.path]??[],at={"--file-tree-depth":ke};return m.jsxs(Mi.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ie.kind,"data-expanded":Be,"data-active":H===ie.path,disabled:!Re,style:at,"aria-expanded":ie.kind==="directory"?Be:void 0,"aria-label":`${ie.kind==="directory"?"Open folder":"Open file"} ${ie.name}`,title:ie.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{Te(ie)},onDoubleClick:()=>{M(ie)},onKeyDown:Xt=>de(Xt,ie),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ie.kind==="directory"?Be?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:ie.name}),m.jsx("small",{children:KT(ie)})]}),Be?m.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Xt=>Pe(Xt,ke+1))}):null]},ie.path)}const ze=f[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":A==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:W,children:W||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!s&&!t,onClick:()=>{Z()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Ee("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Ee("directory")},children:"▣"})]})]}),Y?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:Y}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":W?`Files in ${W}`:"Files",children:ze.map(ie=>Pe(ie,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{De()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{Ke()},children:"Delete"})]})]}),A==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,D.type==="empty"&&A!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,D.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[D.previewKind==="image"?m.jsx("img",{src:D.url,alt:D.file.name}):null,D.previewKind==="pdf"?m.jsx("iframe",{src:D.url,title:D.file.name}):null]}):null,D.type==="text-preview"&&D.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${D.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(IT,{content:D.read.content})})}):null,D.type==="text-preview"&&D.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${D.file.name}`,children:D.read.content}):null]})]})]})}function fp(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function KT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function _S(e,t){return`${e}\0${t??""}`}function WT(e){return`workspace\0${e}`}function FT(e){return[...e].sort((t,r)=>t.kind==="directory"&&r.kind!=="directory"?-1:t.kind!=="directory"&&r.kind==="directory"?1:t.name.localeCompare(r.name))}function va(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function vS(e,t){if(e===null)return null;const r=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return r?!t||r.includes("/")?r:`${t}/${r}`:null}function Vr(e){return e instanceof Error?e.message:"Request failed"}function qT(e){return e instanceof ur&&e.status===409&&e.message==="terminal_cwd_changed"}const $T=v.lazy(()=>Wg(()=>import("./MarkdownPreview-DCHLz_jq.js"),__vite__mapDeps([0,1])));function bS({api:e,editor:t,canClose:r,onClose:s}){const[l,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[y,b]=v.useState(null),[S,w]=v.useState(!1),[x,D]=v.useState("edit"),L=v.useRef(t),A=v.useRef(t.read),B=v.useRef(t.read.content),Y=v.useRef(!1),P=v.useRef(!1),q=v.useRef(0),re=h!==l.content&&g!=="saving"&&!S;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,q.current+=1}),[]),v.useEffect(()=>{q.current+=1,Y.current=!1,L.current=t,A.current=t.read,B.current=t.read.content,c(t.read),p(t.read.content),f("idle"),b(null),w(!1),D("edit")},[t.id,t.read]),v.useEffect(()=>{L.current=t},[t]),v.useEffect(()=>{A.current=l},[l]),v.useEffect(()=>{B.current=h},[h]),v.useEffect(()=>{if(h===l.content||S)return;const K=window.setInterval(()=>{!Y.current&&B.current!==A.current.content&&ne()},1e3);return()=>window.clearInterval(K)},[h===l.content,S,t.id]);async function ne(){if(Y.current)return;const K=B.current,W=A.current;if(K===W.content)return;const H=L.current,j=q.current;Y.current=!0,f("saving"),b(null),w(!1);try{const ae=await e.writeFile({rootToken:H.rootToken,path:H.path,content:K,expectedVersion:W.version});if(!P.current||j!==q.current)return;const R={...W,content:K,version:ae.version};A.current=R,c(R),f(B.current===K?"saved":"idle")}catch(ae){if(!P.current||j!==q.current)return;if(ae instanceof ur&&ae.status===409){w(!0),f("idle");return}b(VT(ae)),f("idle")}finally{j===q.current&&(Y.current=!1)}}const he=g==="saving"?"saving":g==="saved"?"saved":l.language,ve=l.language==="markdown",U=ve&&x==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:he}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!re,onClick:()=>{ne()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${U?"Edit":"Preview"} ${t.title}`,onClick:()=>D(K=>K==="preview"?"edit":"preview"),children:U?"Edit":"Preview"}):null,r?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:s,children:"x"}):null]}),y?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,U?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx($T,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:K=>{const W=K.target.value;B.current=W,p(W),f("idle"),b(null),w(!1)}})]})}function VT(e){return e instanceof Error?e.message:"Request failed"}var YT=2,XT=1,GT=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,r=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(r.getPropertyValue("height")),l=Math.max(0,parseInt(r.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=h.top+h.bottom,g=h.right+h.left,f=s-p,y=l-g-t;return{cols:Math.max(YT,Math.floor(y/e.css.cell.width)),rows:Math.max(XT,Math.floor(f/e.css.cell.height))}}};var Yw=Object.defineProperty,ZT=Object.getOwnPropertyDescriptor,QT=(e,t)=>{for(var r in t)Yw(e,r,{get:t[r],enumerable:!0})},ai=(e,t,r,s)=>{for(var l=s>1?void 0:s?ZT(t,r):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(l=(s?h(t,r,l):h(l))||l);return s&&l&&Yw(t,r,l),l},Ae=(e,t)=>(r,s)=>t(r,s,e),yS="Terminal input",um={get:()=>yS,set:e=>yS=e},SS="Too much output to announce, navigate to rows manually to read",hm={get:()=>SS,set:e=>SS=e};function JT(e){return e.replace(/\r?\n/g,"\r")}function eD(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function tD(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function iD(e,t,r,s){if(e.stopPropagation(),e.clipboardData){let l=e.clipboardData.getData("text/plain");Xw(l,t,r,s)}}function Xw(e,t,r,s){e=JT(e),e=eD(e,r.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),t.value=""}function Gw(e,t,r){let s=r.getBoundingClientRect(),l=e.clientX-s.left-10,c=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${l}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function wS(e,t,r,s,l){Gw(e,t,r),l&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function js(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Fh(e,t=0,r=e.length){let s="";for(let l=t;l<r;++l){let c=e[l];c>65535?(c-=65536,s+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):s+=String.fromCharCode(c)}return s}var nD=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let r=e.length;if(!r)return 0;let s=0,l=0;if(this._interim){let c=e.charCodeAt(l++);56320<=c&&c<=57343?t[s++]=(this._interim-55296)*1024+c-56320+65536:(t[s++]=this._interim,t[s++]=c),this._interim=0}for(let c=l;c<r;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=r)return this._interim=h,s;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[s++]=(h-55296)*1024+p-56320+65536:(t[s++]=h,t[s++]=p);continue}h!==65279&&(t[s++]=h)}return s}},rD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let r=e.length;if(!r)return 0;let s=0,l,c,h,p,g=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let x=0,D;for(;(D=this.interim[++x]&63)&&x<4;)w<<=6,w|=D;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=L-x;for(;f<A;){if(f>=r)return 0;if(D=e[f++],(D&192)!==128){f--,S=!0;break}else this.interim[x++]=D,w<<=6,w|=D&63}S||(L===2?w<128?f--:t[s++]=w:L===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let y=r-4,b=f;for(;b<r;){for(;b<y&&!((l=e[b])&128)&&!((c=e[b+1])&128)&&!((h=e[b+2])&128)&&!((p=e[b+3])&128);)t[s++]=l,t[s++]=c,t[s++]=h,t[s++]=p,b+=4;if(l=e[b++],l<128)t[s++]=l;else if((l&224)===192){if(b>=r)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(l&31)<<6|c&63,g<128){b--;continue}t[s++]=g}else if((l&240)===224){if(b>=r)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=r)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[b++],(h&192)!==128){b--;continue}if(g=(l&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[s++]=g}else if((l&248)===240){if(b>=r)return this.interim[0]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=r)return this.interim[0]=l,this.interim[1]=c,s;if(h=e[b++],(h&192)!==128){b--;continue}if(b>=r)return this.interim[0]=l,this.interim[1]=c,this.interim[2]=h,s;if(p=e[b++],(p&192)!==128){b--;continue}if(g=(l&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[s++]=g}}return s}},Zw="",Ps=" ",Rc=class Qw{constructor(){this.fg=0,this.bg=0,this.extended=new wh}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 Qw;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}},wh=class Jw{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}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 Jw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qn=class e1 extends Rc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wh,this.combinedData=""}static fromCharData(t){let r=new e1;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?js(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 r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let l=t[1].charCodeAt(1);56320<=l&&l<=57343?this.content=(s-55296)*1024+l-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},CS="di$target",dm="di$dependencies",pp=new Map;function sD(e){return e[dm]||[]}function Ki(e){if(pp.has(e))return pp.get(e);let t=function(r,s,l){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");aD(t,r,l)};return t._id=e,pp.set(e,t),t}function aD(e,t,r){t[CS]===t?t[dm].push({id:e,index:r}):(t[dm]=[{id:e,index:r}],t[CS]=t)}var un=Ki("BufferService"),t1=Ki("CoreMouseService"),za=Ki("CoreService"),lD=Ki("CharsetService"),Fg=Ki("InstantiationService"),i1=Ki("LogService"),hn=Ki("OptionsService"),n1=Ki("OscLinkService"),oD=Ki("UnicodeService"),Mc=Ki("DecorationService"),fm=class{constructor(e,t,r){this._bufferService=e,this._optionsService=t,this._oscLinkService=r}provideLinks(e,t){let r=this._bufferService.buffer.lines.get(e-1);if(!r){t(void 0);return}let s=[],l=this._optionsService.rawOptions.linkHandler,c=new Qn,h=r.getTrimmedLength(),p=-1,g=-1,f=!1;for(let y=0;y<h;y++)if(!(g===-1&&!r.hasContent(y))){if(r.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&y===h-1){let b=this._oscLinkService.getLinkData(p)?.uri;if(b){let S={start:{x:g+1,y:e},end:{x:y+(!f&&y===h-1?1:0),y:e}},w=!1;if(!l?.allowNonHttpProtocols)try{let x=new URL(b);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:b,range:S,activate:(x,D)=>l?l.activate(x,D,S):cD(x,D),hover:(x,D)=>l?.hover?.(x,D,S),leave:(x,D)=>l?.leave?.(x,D,S)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,p=c.extended.urlId):(g=-1,p=-1)}}t(s)}};fm=ai([Ae(0,un),Ae(1,hn),Ae(2,n1)],fm);function cD(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var qh=Ki("CharSizeService"),Jr=Ki("CoreBrowserService"),qg=Ki("MouseService"),es=Ki("RenderService"),uD=Ki("SelectionService"),r1=Ki("CharacterJoinerService"),Fl=Ki("ThemeService"),s1=Ki("LinkProviderService"),hD=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xS.isErrorNoTelemetry(e)?new xS(e.message+`
|
|
18
|
+
|
|
19
|
+
`+e.stack):new Error(e.message+`
|
|
20
|
+
|
|
21
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},dD=new hD;function ih(e){fD(e)||dD.onUnexpectedError(e)}var pm="Canceled";function fD(e){return e instanceof pD?!0:e instanceof Error&&e.name===pm&&e.message===pm}var pD=class extends Error{constructor(){super(pm),this.name=this.message}};function mD(e){return new Error(`Illegal argument: ${e}`)}var xS=class mm extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof mm)return t;let r=new mm;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},gm=class a1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,a1.prototype)}};function Ln(e,t=0){return e[e.length-(1+t)]}var gD;(e=>{function t(c){return c<0}e.isLessThan=t;function r(c){return c<=0}e.isLessThanOrEqual=r;function s(c){return c>0}e.isGreaterThan=s;function l(c){return c===0}e.isNeitherLessOrGreaterThan=l,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(gD||={});function _D(e,t){let r=this,s=!1,l;return function(){return s||(s=!0,t||(l=e.apply(r,arguments))),l}}var l1;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let r=Object.freeze([]);function s(){return r}e.empty=s;function*l(P){yield P}e.single=l;function c(P){return t(P)?P:l(P)}e.wrap=c;function h(P){return P||r}e.from=h;function*p(P){for(let q=P.length-1;q>=0;q--)yield P[q]}e.reverse=p;function g(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(P){return P[Symbol.iterator]().next().value}e.first=f;function y(P,q){let re=0;for(let ne of P)if(q(ne,re++))return!0;return!1}e.some=y;function b(P,q){for(let re of P)if(q(re))return re}e.find=b;function*S(P,q){for(let re of P)q(re)&&(yield re)}e.filter=S;function*w(P,q){let re=0;for(let ne of P)yield q(ne,re++)}e.map=w;function*x(P,q){let re=0;for(let ne of P)yield*q(ne,re++)}e.flatMap=x;function*D(...P){for(let q of P)yield*q}e.concat=D;function L(P,q,re){let ne=re;for(let he of P)ne=q(ne,he);return ne}e.reduce=L;function*A(P,q,re=P.length){for(q<0&&(q+=P.length),re<0?re+=P.length:re>P.length&&(re=P.length);q<re;q++)yield P[q]}e.slice=A;function B(P,q=Number.POSITIVE_INFINITY){let re=[];if(q===0)return[re,P];let ne=P[Symbol.iterator]();for(let he=0;he<q;he++){let ve=ne.next();if(ve.done)return[re,e.empty()];re.push(ve.value)}return[re,{[Symbol.iterator](){return ne}}]}e.consume=B;async function Y(P){let q=[];for await(let re of P)q.push(re);return Promise.resolve(q)}e.asyncToArray=Y})(l1||={});function La(e){if(l1.is(e)){let t=[];for(let r of e)if(r)try{r.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function vD(...e){return Yt(()=>La(e))}function Yt(e){return{dispose:_D(()=>{e()})}}var o1=class c1{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{La(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?c1.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)}};o1.DISABLE_DISPOSED_WARNING=!1;var Is=o1,ot=class{constructor(){this._store=new Is,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ot.None=Object.freeze({dispose(){}});var 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}},Zr=typeof window=="object"?window:globalThis,_m=class vm{constructor(t){this.element=t,this.next=vm.Undefined,this.prev=vm.Undefined}};_m.Undefined=new _m(void 0);var Jt=_m,kS=class{constructor(){this._first=Jt.Undefined,this._last=Jt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Jt.Undefined}clear(){let e=this._first;for(;e!==Jt.Undefined;){let t=e.next;e.prev=Jt.Undefined,e.next=Jt.Undefined,e=t}this._first=Jt.Undefined,this._last=Jt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new Jt(e);if(this._first===Jt.Undefined)this._first=r,this._last=r;else if(t){let l=this._last;this._last=r,r.prev=l,l.next=r}else{let l=this._first;this._first=r,r.next=l,l.prev=r}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(r))}}shift(){if(this._first!==Jt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Jt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Jt.Undefined&&e.next!==Jt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Jt.Undefined&&e.next===Jt.Undefined?(this._first=Jt.Undefined,this._last=Jt.Undefined):e.next===Jt.Undefined?(this._last=this._last.prev,this._last.next=Jt.Undefined):e.prev===Jt.Undefined&&(this._first=this._first.next,this._first.prev=Jt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Jt.Undefined;)yield e.element,e=e.next}},bD=globalThis.performance&&typeof globalThis.performance.now=="function",yD=class u1{static create(t){return new u1(t)}constructor(t){this._now=bD&&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}},Zi;(e=>{e.None=()=>ot.None;function t(W,H){return b(W,()=>{},0,void 0,!0,void 0,H)}e.defer=t;function r(W){return(H,j=null,ae)=>{let R=!1,X;return X=W(Z=>{if(!R)return X?X.dispose():R=!0,H.call(j,Z)},null,ae),R&&X.dispose(),X}}e.once=r;function s(W,H,j){return f((ae,R=null,X)=>W(Z=>ae.call(R,H(Z)),null,X),j)}e.map=s;function l(W,H,j){return f((ae,R=null,X)=>W(Z=>{H(Z),ae.call(R,Z)},null,X),j)}e.forEach=l;function c(W,H,j){return f((ae,R=null,X)=>W(Z=>H(Z)&&ae.call(R,Z),null,X),j)}e.filter=c;function h(W){return W}e.signal=h;function p(...W){return(H,j=null,ae)=>{let R=vD(...W.map(X=>X(Z=>H.call(j,Z))));return y(R,ae)}}e.any=p;function g(W,H,j,ae){let R=j;return s(W,X=>(R=H(R,X),R),ae)}e.reduce=g;function f(W,H){let j,ae={onWillAddFirstListener(){j=W(R.fire,R)},onDidRemoveLastListener(){j?.dispose()}},R=new xe(ae);return H?.add(R),R.event}function y(W,H){return H instanceof Array?H.push(W):H&&H.add(W),W}function b(W,H,j=100,ae=!1,R=!1,X,Z){let Ce,Te,M,Q=0,de,me={leakWarningThreshold:X,onWillAddFirstListener(){Ce=W(Se=>{Q++,Te=H(Te,Se),ae&&!M&&(ge.fire(Te),Te=void 0),de=()=>{let Ee=Te;Te=void 0,M=void 0,(!ae||Q>1)&&ge.fire(Ee),Q=0},typeof j=="number"?(clearTimeout(M),M=setTimeout(de,j)):M===void 0&&(M=0,queueMicrotask(de))})},onWillRemoveListener(){R&&Q>0&&de?.()},onDidRemoveLastListener(){de=void 0,Ce.dispose()}},ge=new xe(me);return Z?.add(ge),ge.event}e.debounce=b;function S(W,H=0,j){return e.debounce(W,(ae,R)=>ae?(ae.push(R),ae):[R],H,void 0,!0,void 0,j)}e.accumulate=S;function w(W,H=(ae,R)=>ae===R,j){let ae=!0,R;return c(W,X=>{let Z=ae||!H(X,R);return ae=!1,R=X,Z},j)}e.latch=w;function x(W,H,j){return[e.filter(W,H,j),e.filter(W,ae=>!H(ae),j)]}e.split=x;function D(W,H=!1,j=[],ae){let R=j.slice(),X=W(Te=>{R?R.push(Te):Ce.fire(Te)});ae&&ae.add(X);let Z=()=>{R?.forEach(Te=>Ce.fire(Te)),R=null},Ce=new xe({onWillAddFirstListener(){X||(X=W(Te=>Ce.fire(Te)),ae&&ae.add(X))},onDidAddFirstListener(){R&&(H?setTimeout(Z):Z())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return ae&&ae.add(Ce),Ce.event}e.buffer=D;function L(W,H){return(j,ae,R)=>{let X=H(new B);return W(function(Z){let Ce=X.evaluate(Z);Ce!==A&&j.call(ae,Ce)},void 0,R)}}e.chain=L;let A=Symbol("HaltChainable");class B{constructor(){this.steps=[]}map(H){return this.steps.push(H),this}forEach(H){return this.steps.push(j=>(H(j),j)),this}filter(H){return this.steps.push(j=>H(j)?j:A),this}reduce(H,j){let ae=j;return this.steps.push(R=>(ae=H(ae,R),ae)),this}latch(H=(j,ae)=>j===ae){let j=!0,ae;return this.steps.push(R=>{let X=j||!H(R,ae);return j=!1,ae=R,X?R:A}),this}evaluate(H){for(let j of this.steps)if(H=j(H),H===A)break;return H}}function Y(W,H,j=ae=>ae){let ae=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.on(H,ae),X=()=>W.removeListener(H,ae),Z=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromNodeEventEmitter=Y;function P(W,H,j=ae=>ae){let ae=(...Ce)=>Z.fire(j(...Ce)),R=()=>W.addEventListener(H,ae),X=()=>W.removeEventListener(H,ae),Z=new xe({onWillAddFirstListener:R,onDidRemoveLastListener:X});return Z.event}e.fromDOMEventEmitter=P;function q(W){return new Promise(H=>r(W)(H))}e.toPromise=q;function re(W){let H=new xe;return W.then(j=>{H.fire(j)},()=>{H.fire(void 0)}).finally(()=>{H.dispose()}),H.event}e.fromPromise=re;function ne(W,H){return W(j=>H.fire(j))}e.forward=ne;function he(W,H,j){return H(j),W(ae=>H(ae))}e.runAndSubscribe=he;class ve{constructor(H,j){this._observable=H,this._counter=0,this._hasChanged=!1;let ae={onWillAddFirstListener:()=>{H.addObserver(this)},onDidRemoveLastListener:()=>{H.removeObserver(this)}};this.emitter=new xe(ae),j&&j.add(this.emitter)}beginUpdate(H){this._counter++}handlePossibleChange(H){}handleChange(H,j){this._hasChanged=!0}endUpdate(H){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(W,H){return new ve(W,H).emitter.event}e.fromObservable=U;function K(W){return(H,j,ae)=>{let R=0,X=!1,Z={beginUpdate(){R++},endUpdate(){R--,R===0&&(W.reportChanges(),X&&(X=!1,H.call(j)))},handlePossibleChange(){},handleChange(){X=!0}};W.addObserver(Z),W.reportChanges();let Ce={dispose(){W.removeObserver(Z)}};return ae instanceof Is?ae.add(Ce):Array.isArray(ae)&&ae.push(Ce),Ce}}e.fromObservableLight=K})(Zi||={});var bm=class ym{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ym._idPool++}`,ym.all.add(this)}start(t){this._stopWatch=new yD,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}}};bm.all=new Set,bm._idPool=0;var SD=bm,wD=-1,h1=class d1{constructor(t,r,s=(d1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=r,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let l=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,l+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new kD(p,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,r=0;for(let[s,l]of this._stacks)(!t||r<l)&&(t=[s,l],r=l);return t}};h1._idPool=1;var CD=h1,xD=class f1{constructor(t){this.value=t}static create(){let t=new Error;return new f1(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},kD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ED=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},TD=0,mp=class{constructor(e){this.value=e,this.id=TD++}},DD=2,RD,xe=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new CD(e?.onListenerError??ih,this._options?.leakWarningThreshold??wD):void 0,this._perfMon=this._options?._profName?new SD(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,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let p=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new ED(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||ih)(g),ot.None}if(this._disposed)return ot.None;t&&(e=e.bind(t));let s=new mp(e),l;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=xD.create(),l=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof mp?(this._deliveryQueue??=new MD,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Yt(()=>{l?.(),this._removeListener(s)});return r instanceof Is?r.add(c):Array.isArray(r)&&r.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,r=t.indexOf(e);if(r===-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[r]=void 0;let s=this._deliveryQueue.current===this;if(this._size*DD<=t.length){let l=0;for(let c=0;c<t.length;c++)t[c]?t[l++]=t[c]:s&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=l}}_deliver(e,t){if(!e)return;let r=this._options?.onListenerError||ih;if(!r){e.value(t);return}try{e.value(t)}catch(s){r(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof mp)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}},MD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,r){this.i=0,this.end=r,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Sm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new xe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new xe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,r){if(this.getZoomLevel(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),t)}setFullscreen(t,r){if(this.isFullscreen(r)===t)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Sm.INSTANCE=new Sm;var $g=Sm;function ND(e,t,r){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",r)}$g.INSTANCE.onDidChangeZoomLevel;function AD(e){return $g.INSTANCE.getZoomFactor(e)}$g.INSTANCE.onDidChangeFullscreen;var ql=typeof navigator=="object"?navigator.userAgent:"",wm=ql.indexOf("Firefox")>=0,LD=ql.indexOf("AppleWebKit")>=0,Vg=ql.indexOf("Chrome")>=0,BD=!Vg&&ql.indexOf("Safari")>=0;ql.indexOf("Electron/")>=0;ql.indexOf("Android")>=0;var gp=!1;if(typeof Zr.matchMedia=="function"){let e=Zr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Zr.matchMedia("(display-mode: fullscreen)");gp=e.matches,ND(Zr,e,({matches:r})=>{gp&&t.matches||(gp=r)})}var Rl="en",Cm=!1,xm=!1,nh=!1,p1=!1,Wu,rh=Rl,ES=Rl,OD,Xr,Da=globalThis,zn;typeof Da.vscode<"u"&&typeof Da.vscode.process<"u"?zn=Da.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(zn=process);var zD=typeof zn?.versions?.electron=="string",jD=zD&&zn?.type==="renderer";if(typeof zn=="object"){Cm=zn.platform==="win32",xm=zn.platform==="darwin",nh=zn.platform==="linux",nh&&zn.env.SNAP&&zn.env.SNAP_REVISION,zn.env.CI||zn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Wu=Rl,rh=Rl;let e=zn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Wu=t.userLocale,ES=t.osLocale,rh=t.resolvedLanguage||Rl,OD=t.languagePack?.translationsConfigFile}catch{}p1=!0}else typeof navigator=="object"&&!jD?(Xr=navigator.userAgent,Cm=Xr.indexOf("Windows")>=0,xm=Xr.indexOf("Macintosh")>=0,(Xr.indexOf("Macintosh")>=0||Xr.indexOf("iPad")>=0||Xr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,nh=Xr.indexOf("Linux")>=0,Xr?.indexOf("Mobi")>=0,rh=globalThis._VSCODE_NLS_LANGUAGE||Rl,Wu=navigator.language.toLowerCase(),ES=Wu):console.error("Unable to resolve platform.");var m1=Cm,Tr=xm,PD=nh,TS=p1,Dr=Xr,Ms=rh,HD;(e=>{function t(){return Ms}e.value=t;function r(){return Ms.length===2?Ms==="en":Ms.length>=3?Ms[0]==="e"&&Ms[1]==="n"&&Ms[2]==="-":!1}e.isDefaultVariant=r;function s(){return Ms==="en"}e.isDefault=s})(HD||={});var ID=typeof Da.postMessage=="function"&&!Da.importScripts;(()=>{if(ID){let e=[];Da.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,l=e.length;s<l;s++){let c=e[s];if(c.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),c.callback();return}}});let t=0;return r=>{let s=++t;e.push({id:s,callback:r}),Da.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var UD=!!(Dr&&Dr.indexOf("Chrome")>=0);Dr&&Dr.indexOf("Firefox")>=0;!UD&&Dr&&Dr.indexOf("Safari")>=0;Dr&&Dr.indexOf("Edg/")>=0;Dr&&Dr.indexOf("Android")>=0;var xl=typeof navigator=="object"?navigator:{};TS||document.queryCommandSupported&&document.queryCommandSupported("copy")||xl&&xl.clipboard&&xl.clipboard.writeText,TS||xl&&xl.clipboard&&xl.clipboard.readText;var Yg=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}},_p=new Yg,DS=new Yg,RS=new Yg,KD=new Array(230),g1;(e=>{function t(p){return _p.keyCodeToStr(p)}e.toString=t;function r(p){return _p.strToKeyCode(p)}e.fromString=r;function s(p){return DS.keyCodeToStr(p)}e.toUserSettingsUS=s;function l(p){return RS.keyCodeToStr(p)}e.toUserSettingsGeneral=l;function c(p){return DS.strToKeyCode(p)||RS.strToKeyCode(p)}e.fromUserSettings=c;function h(p){if(p>=98&&p<=113)return null;switch(p){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return _p.keyCodeToStr(p)}e.toElectronAccelerator=h})(g1||={});var WD=class _1{constructor(t,r,s,l,c){this.ctrlKey=t,this.shiftKey=r,this.altKey=s,this.metaKey=l,this.keyCode=c}equals(t){return t instanceof _1&&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",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",l=this.metaKey?"1":"0";return`K${t}${r}${s}${l}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new FD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},FD=class{constructor(e){if(e.length===0)throw mD("chords");this.chords=e}getHashCode(){let e="";for(let t=0,r=this.chords.length;t<r;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 qD(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return g1.fromString(r)}let t=e.keyCode;if(t===3)return 7;if(wm)switch(t){case 59:return 85;case 60:if(PD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Tr)return 57;break}else if(LD&&(Tr&&t===93||!Tr&&t===92))return 57;return KD[t]||0}var $D=Tr?256:2048,VD=512,YD=1024,XD=Tr?2048:256,MS=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=qD(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|=$D),this.altKey&&(t|=VD),this.shiftKey&&(t|=YD),this.metaKey&&(t|=XD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new WD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},NS=new WeakMap;function GD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,r=e.parent.location;if(t.origin!=="null"&&r.origin!=="null"&&t.origin!==r.origin)return null}catch{return null}return e.parent}var ZD=class{static getSameOriginWindowChain(e){let t=NS.get(e);if(!t){t=[],NS.set(e,t);let r=e,s;do s=GD(r),s?t.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):t.push({window:new WeakRef(r),iframeElement:null}),r=s;while(r)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let r=0,s=0,l=this.getSameOriginWindowChain(e);for(let c of l){let h=c.window.deref();if(r+=h?.scrollY??0,s+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();r+=p.top,s+=p.left}return{top:r,left:s}}},Fu=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 r=ZD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},AS=class{constructor(e,t=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=t;let s=!1;if(Vg){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*h):this.deltaY=l.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?wm&&!Tr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")BD&&m1?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*h):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?wm&&!Tr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},v1=Object.freeze(function(e,t){let r=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(r)}}}),QD;(e=>{function t(r){return r===e.None||r===e.Cancelled||r instanceof JD?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Zi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:v1})})(QD||={});var JD=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?v1:(this._emitter||(this._emitter=new xe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Xg=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 gm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new gm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},eR=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,r=globalThis){if(this.isDisposed)throw new gm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=r.setInterval(()=>{e()},t);this.disposable=Yt(()=>{r.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tR;(e=>{async function t(s){let l,c=await Promise.all(s.map(h=>h.then(p=>p,p=>{l||(l=p)})));if(typeof l<"u")throw l;return c}e.settled=t;function r(s){return new Promise(async(l,c)=>{try{await s(l,c)}catch(h){c(h)}})}e.withAsyncBody=r})(tR||={});var LS=class Yn{static fromArray(t){return new Yn(r=>{r.emitMany(t)})}static fromPromise(t){return new Yn(async r=>{r.emitMany(await t)})}static fromPromises(t){return new Yn(async r=>{await Promise.all(t.map(async s=>r.emitOne(await s)))})}static merge(t){return new Yn(async r=>{await Promise.all(t.map(async s=>{for await(let l of s)r.emitOne(l)}))})}constructor(t,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new xe,queueMicrotask(async()=>{let s={emitOne:l=>this.emitOne(l),emitMany:l=>this.emitMany(l),reject:l=>this.reject(l)};try{await Promise.resolve(t(s)),this.resolve()}catch(l){this.reject(l)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Zi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,r){return new Yn(async s=>{for await(let l of t)s.emitOne(r(l))})}map(t){return Yn.map(this,t)}static filter(t,r){return new Yn(async s=>{for await(let l of t)r(l)&&s.emitOne(l)})}filter(t){return Yn.filter(this,t)}static coalesce(t){return Yn.filter(t,r=>!!r)}coalesce(){return Yn.coalesce(this)}static async toPromise(t){let r=[];for await(let s of t)r.push(s);return r}toPromise(){return Yn.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())}};LS.EMPTY=LS.fromArray([]);var{getWindow:Er,getWindowId:iR,onDidRegisterWindow:nR}=(function(){let e=new Map,t={window:Zr,disposables:new Is};e.set(Zr.vscodeWindowId,t);let r=new xe,s=new xe,l=new xe;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:l.event,onDidUnregisterWindow:s.event,registerWindow(h){if(e.has(h.vscodeWindowId))return ot.None;let p=new Is,g={window:h,disposables:p.add(new Is)};return e.set(h.vscodeWindowId,g),p.add(Yt(()=>{e.delete(h.vscodeWindowId),s.fire(h)})),p.add(Ge(h,zi.BEFORE_UNLOAD,()=>{l.fire(h)})),r.fire(g),p},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let p=h;if(p?.ownerDocument?.defaultView)return p.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:Zr},getDocument(h){return Er(h).document}}})(),rR=class{constructor(e,t,r,s){this._node=e,this._type=t,this._handler=r,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ge(e,t,r,s){return new rR(e,t,r,s)}var BS=function(e,t,r,s){return Ge(e,t,r,s)},Gg,sR=class extends eR{constructor(e){super(),this.defaultTarget=e&&Er(e)}cancelAndSet(e,t,r){return super.cancelAndSet(e,t,r??this.defaultTarget)}},OS=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){ih(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,r=new Map,s=new Map,l=c=>{r.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),s.set(c,!0);h.length>0;)h.sort(OS.sort),h.shift().execute();s.set(c,!1)};Gg=(c,h,p=0)=>{let g=iR(c),f=new OS(h,p),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(f),r.get(g)||(r.set(g,!0),c.requestAnimationFrame(()=>l(g))),f}})();function aR(e){let t=e.getBoundingClientRect(),r=Er(e);return{left:t.left+r.scrollX,top:t.top+r.scrollY,width:t.width,height:t.height}}var zi={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},lR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=bn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=bn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=bn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=bn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=bn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=bn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=bn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=bn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=bn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=bn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=bn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=bn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=bn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=bn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function bn(e){return typeof e=="number"?`${e}px`:e}function uc(e){return new lR(e)}var b1=class{constructor(){this._hooks=new Is,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 r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,r,s,l){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=l;let c=e;try{e.setPointerCapture(t),this._hooks.add(Yt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Er(e)}this._hooks.add(Ge(c,zi.POINTER_MOVE,h=>{if(h.buttons!==r){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Ge(c,zi.POINTER_UP,h=>this.stopMonitoring(!0)))}};function oR(e,t,r){let s=null,l=null;if(typeof r.value=="function"?(s="value",l=r.value,l.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(s="get",l=r.get),!l)throw new Error("not supported");let c=`$memoize$${t}`;r[s]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:l.apply(this,h)}),this[c]}}var kr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(kr||={});var Xo=class sn extends ot{constructor(){super(),this.dispatched=!1,this.targets=new kS,this.ignoreTargets=new kS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Zi.runAndSubscribe(nR,({window:t,disposables:r})=>{r.add(Ge(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),r.add(Ge(t.document,"touchend",s=>this.onTouchEnd(t,s))),r.add(Ge(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Zr,disposables:this._store}))}static addTarget(t){if(!sn.isTouchDevice())return ot.None;sn.INSTANCE||(sn.INSTANCE=new sn);let r=sn.INSTANCE.targets.push(t);return Yt(r)}static ignoreTarget(t){if(!sn.isTouchDevice())return ot.None;sn.INSTANCE||(sn.INSTANCE=new sn);let r=sn.INSTANCE.ignoreTargets.push(t);return Yt(r)}static isTouchDevice(){return"ontouchstart"in Zr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,l=t.targetTouches.length;s<l;s++){let c=t.targetTouches.item(s);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:r,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[r],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(kr.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,r){let s=Date.now(),l=Object.keys(this.activeTouches).length;for(let c=0,h=r.changedTouches.length;c<h;c++){let p=r.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(p.identifier))){console.warn("move of an UNKNOWN touch",p);continue}let g=this.activeTouches[p.identifier],f=Date.now()-g.initialTimeStamp;if(f<sn.HOLD_DELAY&&Math.abs(g.initialPageX-Ln(g.rollingPageX))<30&&Math.abs(g.initialPageY-Ln(g.rollingPageY))<30){let y=this.newGestureEvent(kr.Tap,g.initialTarget);y.pageX=Ln(g.rollingPageX),y.pageY=Ln(g.rollingPageY),this.dispatchEvent(y)}else if(f>=sn.HOLD_DELAY&&Math.abs(g.initialPageX-Ln(g.rollingPageX))<30&&Math.abs(g.initialPageY-Ln(g.rollingPageY))<30){let y=this.newGestureEvent(kr.Contextmenu,g.initialTarget);y.pageX=Ln(g.rollingPageX),y.pageY=Ln(g.rollingPageY),this.dispatchEvent(y)}else if(l===1){let y=Ln(g.rollingPageX),b=Ln(g.rollingPageY),S=Ln(g.rollingTimestamps)-g.rollingTimestamps[0],w=y-g.rollingPageX[0],x=b-g.rollingPageY[0],D=[...this.targets].filter(L=>g.initialTarget instanceof Node&&L.contains(g.initialTarget));this.inertia(t,D,s,Math.abs(w)/S,w>0?1:-1,y,Math.abs(x)/S,x>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(kr.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,r){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(t){if(t.type===kr.Tap){let r=new Date().getTime(),s=0;r-this._lastSetTapCountTime>sn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=r,t.tapCount=s}else(t.type===kr.Change||t.type===kr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let r=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let l=0,c=t.initialTarget;for(;c&&c!==s;)l++,c=c.parentElement;r.push([l,s])}r.sort((s,l)=>s[0]-l[0]);for(let[s,l]of r)l.dispatchEvent(t),this.dispatched=!0}}inertia(t,r,s,l,c,h,p,g,f){this.handle=Gg(t,()=>{let y=Date.now(),b=y-s,S=0,w=0,x=!0;l+=sn.SCROLL_FRICTION*b,p+=sn.SCROLL_FRICTION*b,l>0&&(x=!1,S=c*l*b),p>0&&(x=!1,w=g*p*b);let D=this.newGestureEvent(kr.Change);D.translationX=S,D.translationY=w,r.forEach(L=>L.dispatchEvent(D)),x||this.inertia(t,r,y,l,c,h+S,p,g,f+w)})}onTouchMove(t){let r=Date.now();for(let s=0,l=t.changedTouches.length;s<l;s++){let c=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(kr.Change,h.initialTarget);p.translationX=c.pageX-Ln(h.rollingPageX),p.translationY=c.pageY-Ln(h.rollingPageY),p.pageX=c.pageX,p.pageY=c.pageY,this.dispatchEvent(p),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(r)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Xo.SCROLL_FRICTION=-.005,Xo.HOLD_DELAY=700,Xo.CLEAR_TAP_COUNT_TIME=400,ai([oR],Xo,"isTouchDevice",1);var cR=Xo,Zg=class extends ot{onclick(e,t){this._register(Ge(e,zi.CLICK,r=>t(new Fu(Er(e),r))))}onmousedown(e,t){this._register(Ge(e,zi.MOUSE_DOWN,r=>t(new Fu(Er(e),r))))}onmouseover(e,t){this._register(Ge(e,zi.MOUSE_OVER,r=>t(new Fu(Er(e),r))))}onmouseleave(e,t){this._register(Ge(e,zi.MOUSE_LEAVE,r=>t(new Fu(Er(e),r))))}onkeydown(e,t){this._register(Ge(e,zi.KEY_DOWN,r=>t(new MS(r))))}onkeyup(e,t){this._register(Ge(e,zi.KEY_UP,r=>t(new MS(r))))}oninput(e,t){this._register(Ge(e,zi.INPUT,t))}onblur(e,t){this._register(Ge(e,zi.BLUR,t))}onfocus(e,t){this._register(Ge(e,zi.FOCUS,t))}onchange(e,t){this._register(Ge(e,zi.CHANGE,t))}ignoreGesture(e){return cR.ignoreTarget(e)}},zS=11,uR=class extends Zg{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=zS+"px",this.domNode.style.height=zS+"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 b1),this._register(BS(this.bgDomNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(BS(this.domNode,zi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new sR),this._pointerdownScheduleRepeatTimer=this._register(new Xg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Er(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hR=class km{constructor(t,r,s,l,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,s=s|0,l=l|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=l,this.rawScrollTop=p,r<0&&(r=0),l+r>s&&(l=s-r),l<0&&(l=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=r,this.scrollWidth=s,this.scrollLeft=l,this.height=c,this.scrollHeight=h,this.scrollTop=p}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,r){return new km(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new km(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,r){let s=this.width!==t.width,l=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,p=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:r,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:l,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},dR=class extends ot{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hR(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 r=this._state.withScrollDimensions(e,t);this._setState(r,!!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 r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let s;t?s=new PS(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=PS.start(this._state,r,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 r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,t)))}},jS=class{constructor(e,t,r){this.scrollLeft=e,this.scrollTop=t,this.isDone=r}};function vp(e,t){let r=t-e;return function(s){return e+r*mR(s)}}function fR(e,t,r){return function(s){return s<r?e(s/r):t((s-r)/(1-r))}}var PS=class Em{constructor(t,r,s,l){this.from=t,this.to=r,this.duration=l,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,r,s){if(Math.abs(t-r)>2.5*s){let l,c;return t<r?(l=t+.75*s,c=r-.75*s):(l=t-.75*s,c=r+.75*s),fR(vp(t,l),vp(c,r),.33)}return vp(t,r)}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 r=(t-this.startTime)/this.duration;if(r<1){let s=this.scrollLeft(r),l=this.scrollTop(r);return new jS(s,l,!1)}return new jS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,r,s){return Em.start(t,r,s)}static start(t,r,s){s=s+10;let l=Date.now()-10;return new Em(t,r,l,s)}};function pR(e){return Math.pow(e,3)}function mR(e){return 1-pR(1-e)}var gR=class extends ot{constructor(e,t,r){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Xg)}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":"")))}},_R=140,y1=class extends Zg{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 gR(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new b1),this._shouldRender=!0,this.domNode=uc(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(Ge(this.domNode.domNode,zi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new uR(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,r,s){this.slider=uc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof r=="number"&&this.slider.setWidth(r),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ge(this.slider.domNode,zi.POINTER_DOWN,l=>{l.button===0&&(l.preventDefault(),this._sliderPointerDown(l))})),this.onclick(this.slider.domNode,l=>{l.leftButton&&l.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,r=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),l=this._sliderPointerPosition(e);r<=l&&l<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,r=e.offsetY;else{let l=aR(this.domNode.domNode);t=e.pageX-l.left,r=e.pageY-l.top}let s=this._pointerDownRelativePosition(t,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,l=>{let c=this._sliderOrthogonalPointerPosition(l),h=Math.abs(c-r);if(m1&&h>_R){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let p=this._sliderPointerPosition(l)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(p))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},S1=class Tm{constructor(t,r,s,l,c,h){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=l,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Tm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let r=Math.round(t);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(t){let r=Math.round(t);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let r=Math.round(t);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,r,s,l,c){let h=Math.max(0,s-t),p=Math.max(0,h-2*r),g=l>0&&l>s;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*p/l))),y=(p-f)/(l-s),b=c*y;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Tm._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 r=t-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let r=t-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+t;return Math.round(r/this._computedSliderRatio)}},vR=class extends y1{constructor(e,t,r){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new S1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,l.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},bR=class extends y1{constructor(e,t,r){let s=e.getScrollDimensions(),l=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:r,scrollbarState:new S1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,l.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},yR=500,HS=50,SR=class{constructor(e,t,r){this.timestamp=e,this.deltaX=t,this.deltaY=r,this.score=0}},Dm=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,r=0,s=1,l=this._rear;do{let c=l===this._front?t:Math.pow(2,-s);if(t-=c,r+=this._memory[l].score*c,l===this._front)break;l=(this._capacity+l-1)%this._capacity,s++}while(!0);return r<=.5}acceptStandardWheelEvent(t){if(Vg){let r=Er(t.browserEvent),s=AD(r);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,r,s){let l=null,c=new SR(t,r,s);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(l=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,l)}_computeScore(t,r){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),r){let l=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(r.deltaX),p=Math.abs(r.deltaY),g=Math.max(Math.min(l,h),1),f=Math.max(Math.min(c,p),1),y=Math.max(l,h),b=Math.max(c,p);y%g===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Dm.INSTANCE=new Dm;var wR=Dm,CR=class extends Zg{constructor(e,t,r){super(),this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new xe),this.onWillScroll=this._onWillScroll.event,this._options=kR(t),this._scrollable=r,this._register(this._scrollable.onScroll(l=>{this._onWillScroll.fire(l),this._onDidScroll(l),this._onScroll.fire(l)}));let s={onMouseWheel:l=>this._onMouseWheel(l),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new bR(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new vR(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=uc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=uc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=uc(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,l=>this._onMouseOver(l)),this.onmouseleave(this._listenOnDomNode,l=>this._onMouseLeave(l)),this._hideTimeout=this._register(new Xg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=La(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,Tr&&(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 AS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=La(this._mouseWheelToDispose),e)){let t=r=>{this._onMouseWheel(new AS(r))};this._mouseWheelToDispose.push(Ge(this._listenOnDomNode,zi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=wR.INSTANCE;t.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let h=!Tr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(l){let f=HS*l,y=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let f=HS*c,y=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),r=!0)}let s=r;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,r=e.scrollLeft>0,s=r?" left":"",l=t?" top":"",c=r||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${l}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${l}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),yR)}},xR=class extends CR{constructor(e,t,r){super(e,t,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function kR(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,Tr&&(t.className+=" mac"),t}var Rm=class extends ot{constructor(e,t,r,s,l,c,h,p){super(),this._bufferService=r,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new dR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Gg(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new xR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(l.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Zi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Yt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Yt(()=>this._styleElement.remove())),this._register(Zi.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
24
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=t-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};Rm=ai([Ae(2,un),Ae(3,Jr),Ae(4,t1),Ae(5,Fl),Ae(6,hn),Ae(7,es)],Rm);var Mm=class extends ot{constructor(e,t,r,s,l){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=r,this._decorationService=s,this._renderService=l,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(Yt(()=>{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 r=e.options.x??0;return r&&r>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 r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,t=e.element){if(!t)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Mm=ai([Ae(1,un),Ae(2,Jr),Ae(3,Mc),Ae(4,es)],Mm);var ER=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,r){return t>=e.startBufferLine-this._linePadding[r||"full"]&&t<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Cr={full:0,left:0,center:0,right:0},Ns={full:0,left:0,center:0,right:0},jo={full:0,left:0,center:0,right:0},Ch=class extends ot{constructor(e,t,r,s,l,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=r,this._decorationService=s,this._renderService=l,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,this._colorZoneStore=new ER,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(Yt(()=>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);Ns.full=this._canvas.width,Ns.left=e,Ns.center=t,Ns.right=e,this._refreshDrawHeightConstants(),jo.full=1,jo.left=1,jo.center=1+Ns.left,jo.right=1+Ns.left+Ns.center}_refreshDrawHeightConstants(){Cr.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);Cr.left=t,Cr.center=t,Cr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Cr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Cr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Cr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Cr.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(jo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Cr[e.position||"full"]/2),Ns[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Cr[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}))}};Ch=ai([Ae(2,un),Ae(3,Mc),Ae(4,es),Ae(5,hn),Ae(6,Fl),Ae(7,Jr)],Ch);var fe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
25
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(fe||={});var sh;(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=""))(sh||={});var w1;(e=>e.ST=`${fe.ESC}\\`)(w1||={});var Nm=class{constructor(e,t,r,s,l,c){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=s,this._coreService=l,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;t.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(t.start,this._compositionPosition.start):r=this._textarea.value.substring(t.start),r.length>0&&this._coreService.triggerDataEvent(r,!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,r=t.replace(e,"");this._dataAlreadySent=r,t.length>e.length?this._coreService.triggerDataEvent(r,!0):t.length<e.length?this._coreService.triggerDataEvent(`${fe.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),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,l=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=l+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=l+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Nm=ai([Ae(2,un),Ae(3,hn),Ae(4,za),Ae(5,es)],Nm);var Pi=0,Hi=0,Ii=0,si=0,IS={css:"#00000000",rgba:0},yi;(e=>{function t(l,c,h,p){return p!==void 0?`#${ba(l)}${ba(c)}${ba(h)}${ba(p)}`:`#${ba(l)}${ba(c)}${ba(h)}`}e.toCss=t;function r(l,c,h,p=255){return(l<<24|c<<16|h<<8|p)>>>0}e.toRgba=r;function s(l,c,h,p){return{css:e.toCss(l,c,h,p),rgba:e.toRgba(l,c,h,p)}}e.toColor=s})(yi||={});var Wt;(e=>{function t(g,f){if(si=(f.rgba&255)/255,si===1)return{css:f.css,rgba:f.rgba};let y=f.rgba>>24&255,b=f.rgba>>16&255,S=f.rgba>>8&255,w=g.rgba>>24&255,x=g.rgba>>16&255,D=g.rgba>>8&255;Pi=w+Math.round((y-w)*si),Hi=x+Math.round((b-x)*si),Ii=D+Math.round((S-D)*si);let L=yi.toCss(Pi,Hi,Ii),A=yi.toRgba(Pi,Hi,Ii);return{css:L,rgba:A}}e.blend=t;function r(g){return(g.rgba&255)===255}e.isOpaque=r;function s(g,f,y){let b=ah.ensureContrastRatio(g.rgba,f.rgba,y);if(b)return yi.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function l(g){let f=(g.rgba|255)>>>0;return[Pi,Hi,Ii]=ah.toChannels(f),{css:yi.toCss(Pi,Hi,Ii),rgba:f}}e.opaque=l;function c(g,f){return si=Math.round(f*255),[Pi,Hi,Ii]=ah.toChannels(g.rgba),{css:yi.toCss(Pi,Hi,Ii,si),rgba:yi.toRgba(Pi,Hi,Ii,si)}}e.opacity=c;function h(g,f){return si=g.rgba&255,c(g,si*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Wt||={});var ei;(e=>{let t,r;try{let l=document.createElement("canvas");l.width=1,l.height=1;let c=l.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function s(l){if(l.match(/#[\da-f]{3,8}/i))switch(l.length){case 4:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),yi.toColor(Pi,Hi,Ii);case 5:return Pi=parseInt(l.slice(1,2).repeat(2),16),Hi=parseInt(l.slice(2,3).repeat(2),16),Ii=parseInt(l.slice(3,4).repeat(2),16),si=parseInt(l.slice(4,5).repeat(2),16),yi.toColor(Pi,Hi,Ii,si);case 7:return{css:l,rgba:(parseInt(l.slice(1),16)<<8|255)>>>0};case 9:return{css:l,rgba:parseInt(l.slice(1),16)>>>0}}let c=l.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Pi=parseInt(c[1]),Hi=parseInt(c[2]),Ii=parseInt(c[3]),si=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),yi.toColor(Pi,Hi,Ii,si);if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=l,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pi,Hi,Ii,si]=t.getImageData(0,0,1,1).data,si!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:yi.toRgba(Pi,Hi,Ii,si),css:l}}e.toColor=s})(ei||={});var cn;(e=>{function t(s){return r(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function r(s,l,c){let h=s/255,p=l/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+y*.7152+b*.0722}e.relativeLuminance2=r})(cn||={});var ah;(e=>{function t(h,p){if(si=(p&255)/255,si===1)return p;let g=p>>24&255,f=p>>16&255,y=p>>8&255,b=h>>24&255,S=h>>16&255,w=h>>8&255;return Pi=b+Math.round((g-b)*si),Hi=S+Math.round((f-S)*si),Ii=w+Math.round((y-w)*si),yi.toRgba(Pi,Hi,Ii)}e.blend=t;function r(h,p,g){let f=cn.relativeLuminance(h>>8),y=cn.relativeLuminance(p>>8);if(Yr(f,y)<g){if(y<f){let w=s(h,p,g),x=Yr(f,cn.relativeLuminance(w>>8));if(x<g){let D=l(h,p,g),L=Yr(f,cn.relativeLuminance(D>>8));return x>L?w:D}return w}let b=l(h,p,g),S=Yr(f,cn.relativeLuminance(b>>8));if(S<g){let w=s(h,p,g),x=Yr(f,cn.relativeLuminance(w>>8));return S>x?b:w}return b}}e.ensureContrastRatio=r;function s(h,p,g){let f=h>>24&255,y=h>>16&255,b=h>>8&255,S=p>>24&255,w=p>>16&255,x=p>>8&255,D=Yr(cn.relativeLuminance2(S,w,x),cn.relativeLuminance2(f,y,b));for(;D<g&&(S>0||w>0||x>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),x-=Math.max(0,Math.ceil(x*.1)),D=Yr(cn.relativeLuminance2(S,w,x),cn.relativeLuminance2(f,y,b));return(S<<24|w<<16|x<<8|255)>>>0}e.reduceLuminance=s;function l(h,p,g){let f=h>>24&255,y=h>>16&255,b=h>>8&255,S=p>>24&255,w=p>>16&255,x=p>>8&255,D=Yr(cn.relativeLuminance2(S,w,x),cn.relativeLuminance2(f,y,b));for(;D<g&&(S<255||w<255||x<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),D=Yr(cn.relativeLuminance2(S,w,x),cn.relativeLuminance2(f,y,b));return(S<<24|w<<16|x<<8|255)>>>0}e.increaseLuminance=l;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(ah||={});function ba(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Yr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var TR=class extends Rc{constructor(e,t,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=r}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()]}},xh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Qn}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 r=[],s=t.translateToString(!0),l=0,c=0,h=0,p=t.getFg(0),g=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==p||this._workCell.bg!==g){if(f-l>1){let y=this._getJoinedRanges(s,h,c,t,l);for(let b=0;b<y.length;b++)r.push(y[b])}l=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ps.length}if(this._bufferService.cols-l>1){let f=this._getJoinedRanges(s,h,c,t,l);for(let y=0;y<f.length;y++)r.push(f[y])}return r}_getJoinedRanges(e,t,r,s,l){let c=e.substring(t,r),h=[];try{h=this._characterJoiners[0].handler(c)}catch(p){console.error(p)}for(let p=1;p<this._characterJoiners.length;p++)try{let g=this._characterJoiners[p].handler(c);for(let f=0;f<g.length;f++)xh._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,s,l),h}_stringRangesToCellRanges(e,t,r){let s=0,l=!1,c=0,h=e[s];if(h){for(let p=r;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||Ps.length;if(g!==0){if(!l&&h[0]<=c&&(h[0]=p,l=!0),h[1]<=c){if(h[1]=p,h=e[++s],!h)break;h[0]<=c?(h[0]=p,l=!0):l=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let r=!1;for(let s=0;s<e.length;s++){let l=e[s];if(r){if(t[1]<=l[0])return e[s-1][1]=t[1],e;if(t[1]<=l[1])return e[s-1][1]=Math.max(t[1],l[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=l[0])return e.splice(s,0,t),e;if(t[1]<=l[1])return l[0]=Math.min(t[0],l[0]),e;t[0]<l[1]&&(l[0]=Math.min(t[0],l[0]),r=!0);continue}}return r?e[e.length-1][1]=t[1]:e.push(t),e}};xh=ai([Ae(0,un)],xh);function DR(e){return 57508<=e&&e<=57558}function RR(e){return 9472<=e&&e<=9631}function MR(e){return DR(e)||RR(e)}function NR(){return{css:{canvas:qu(),cell:qu()},device:{canvas:qu(),cell:qu(),char:{width:0,height:0,left:0,top:0}}}}function qu(){return{width:0,height:0}}var Am=class{constructor(e,t,r,s,l,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=r,this._coreBrowserService=s,this._coreService=l,this._decorationService=c,this._themeService=h,this._workCell=new Qn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,r){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=r}createRow(e,t,r,s,l,c,h,p,g,f,y){let b=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,x=e.getNoBgTrimmedLength();r&&x<c+1&&(x=c+1);let D,L=0,A="",B=0,Y=0,P=0,q=0,re=!1,ne=0,he=!1,ve=0,U=0,K=[],W=f!==-1&&y!==-1;for(let H=0;H<x;H++){e.loadCell(H,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let ae=!1,R=H>=U,X=H,Z=this._workCell;if(S.length>0&&H===S[0][0]&&R){let be=S.shift(),Me=this._isCellInSelection(be[0],t);for(B=be[0]+1;B<be[1];B++)R&&=Me===this._isCellInSelection(B,t);R&&=!r||c<be[0]||c>=be[1],R?(ae=!0,Z=new TR(this._workCell,e.translateToString(!0,be[0],be[1]),be[1]-be[0]),X=be[1]-1,j=Z.getWidth()):U=be[1]}let Ce=this._isCellInSelection(H,t),Te=r&&H===c,M=W&&H>=f&&H<=y,Q=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{Q=!0});let de=Z.getChars()||Ps;if(de===" "&&(Z.isUnderline()||Z.isOverline())&&(de=" "),ve=j*p-g.get(de,Z.isBold(),Z.isItalic()),!D)D=this._document.createElement("span");else if(L&&(Ce&&he||!Ce&&!he&&Z.bg===Y)&&(Ce&&he&&w.selectionForeground||Z.fg===P)&&Z.extended.ext===q&&M===re&&ve===ne&&!Te&&!ae&&!Q&&R){Z.isInvisible()?A+=Ps:A+=de,L++;continue}else L&&(D.textContent=A),D=this._document.createElement("span"),L=0,A="";if(Y=Z.bg,P=Z.fg,q=Z.extended.ext,re=M,ne=ve,he=Ce,ae&&c>=H&&c<=X&&(c=H),!this._coreService.isCursorHidden&&Te&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(l)switch(l){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(Z.isBold()&&K.push("xterm-bold"),Z.isItalic()&&K.push("xterm-italic"),Z.isDim()&&K.push("xterm-dim"),Z.isInvisible()?A=Ps:A=Z.getChars()||Ps,Z.isUnderline()&&(K.push(`xterm-underline-${Z.extended.underlineStyle}`),A===" "&&(A=" "),!Z.isUnderlineColorDefault()))if(Z.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${Rc.toColorRGB(Z.getUnderlineColor()).join(",")})`;else{let be=Z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Z.isBold()&&be<8&&(be+=8),D.style.textDecorationColor=w.ansi[be].css}Z.isOverline()&&(K.push("xterm-overline"),A===" "&&(A=" ")),Z.isStrikethrough()&&K.push("xterm-strikethrough"),M&&(D.style.textDecoration="underline");let me=Z.getFgColor(),ge=Z.getFgColorMode(),Se=Z.getBgColor(),Ee=Z.getBgColorMode(),De=!!Z.isInverse();if(De){let be=me;me=Se,Se=be;let Me=ge;ge=Ee,Ee=Me}let Ke,se,pe=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,be=>{be.options.layer!=="top"&&pe||(be.backgroundColorRGB&&(Ee=50331648,Se=be.backgroundColorRGB.rgba>>8&16777215,Ke=be.backgroundColorRGB),be.foregroundColorRGB&&(ge=50331648,me=be.foregroundColorRGB.rgba>>8&16777215,se=be.foregroundColorRGB),pe=be.options.layer==="top")}),!pe&&Ce&&(Ke=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Se=Ke.rgba>>8&16777215,Ee=50331648,pe=!0,w.selectionForeground&&(ge=50331648,me=w.selectionForeground.rgba>>8&16777215,se=w.selectionForeground)),pe&&K.push("xterm-decoration-top");let Le;switch(Ee){case 16777216:case 33554432:Le=w.ansi[Se],K.push(`xterm-bg-${Se}`);break;case 50331648:Le=yi.toColor(Se>>16,Se>>8&255,Se&255),this._addStyle(D,`background-color:#${US((Se>>>0).toString(16),"0",6)}`);break;default:De?(Le=w.foreground,K.push("xterm-bg-257")):Le=w.background}switch(Ke||Z.isDim()&&(Ke=Wt.multiplyOpacity(Le,.5)),ge){case 16777216:case 33554432:Z.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(D,Le,w.ansi[me],Z,Ke,void 0)||K.push(`xterm-fg-${me}`);break;case 50331648:let be=yi.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(D,Le,be,Z,Ke,se)||this._addStyle(D,`color:#${US(me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Le,w.foreground,Z,Ke,se)||De&&K.push("xterm-fg-257")}K.length&&(D.className=K.join(" "),K.length=0),!Te&&!ae&&!Q&&R?L++:D.textContent=A,ve!==this.defaultSpacing&&(D.style.letterSpacing=`${ve}px`),b.push(D),H=X}return D&&L&&(D.textContent=A),b}_applyMinimumContrast(e,t,r,s,l,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||MR(s.getCode()))return!1;let h=this._getContrastCache(s),p;if(!l&&!c&&(p=h.getColor(t.rgba,r.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);p=Wt.ensureContrastRatio(l||t,c||r,g),h.setColor((l||t).rgba,(c||r).rgba,p??null)}return p?(this._addStyle(e,`color:${p.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let r=this._selectionStart,s=this._selectionEnd;return!r||!s?!1:this._columnSelectMode?r[0]<=s[0]?e>=r[0]&&t>=r[1]&&e<s[0]&&t<=s[1]:e<r[0]&&t>=r[1]&&e>=s[0]&&t<=s[1]:t>r[1]&&t<s[1]||r[1]===s[1]&&t===r[1]&&e>=r[0]&&e<s[0]||r[1]<s[1]&&t===s[1]&&e<s[0]||r[1]<s[1]&&t===r[1]&&e>=r[0]}};Am=ai([Ae(1,r1),Ae(2,hn),Ae(3,Jr),Ae(4,za),Ae(5,Mc),Ae(6,Fl)],Am);function US(e,t,r){for(;e.length<r;)e=t+e;return e}var AR=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[r,s,l,c],this._container.appendChild(r),this._container.appendChild(s),this._container.appendChild(l),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,r,s){e===this._font&&t===this._fontSize&&r===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=r,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,r){let s=0;if(!t&&!r&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let h=this._measure(e,0);return h>0&&(this._flat[s]=h),h}let l=e;t&&(l+="B"),r&&(l+="I");let c=this._holey.get(l);if(c===void 0){let h=0;t&&(h|=1),r&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(l,c)}return c}_measure(e,t){let r=this._measureElements[t];return r.textContent=e.repeat(32),r.offsetWidth/32}},LR=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,r,s=!1){if(this.selectionStart=t,this.selectionEnd=r,!t||!r||t[0]===r[0]&&t[1]===r[1]){this.clear();return}let l=e.buffers.active.ydisp,c=t[1]-l,h=r[1]-l,p=Math.max(c,0),g=Math.min(h,e.rows-1);if(p>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=r[0]}isCellSelected(e,t,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&r>=this.viewportCappedStartRow&&t<this.endCol&&r<=this.viewportCappedEndRow:t<this.startCol&&r>=this.viewportCappedStartRow&&t>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&t>=this.startCol):!1}};function BR(){return new LR}var bp="xterm-dom-renderer-owner-",Vn="xterm-rows",$u="xterm-fg-",KS="xterm-bg-",Po="xterm-focus",Vu="xterm-selection",OR=1,Lm=class extends ot{constructor(e,t,r,s,l,c,h,p,g,f,y,b,S,w){super(),this._terminal=e,this._document=t,this._element=r,this._screenElement=s,this._viewportElement=l,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=y,this._coreService=b,this._coreBrowserService=S,this._themeService=w,this._terminalClass=OR++,this._rowElements=[],this._selectionRenderModel=BR(),this.onRequestRedraw=this._register(new xe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Vn),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(Vu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=NR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(Am,document),this._element.classList.add(bp+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(Yt(()=>{this._element.classList.remove(bp+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new AR(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 r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Vn} 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} .${Vn} { 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} .${Vn} .xterm-dim { color: ${Wt.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 r=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,l=`blink_block_${this._terminalClass}`;t+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${l} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Vn}.${Po} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${Po} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${Po} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${l} 1s step-end infinite;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Vu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Vu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Vu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${$u}${c} { color: ${h.css}; }${this._terminalSelector} .${$u}${c}.xterm-dim { color: ${Wt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${KS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${$u}257 { color: ${Wt.opaque(e.background).css}; }${this._terminalSelector} .${$u}257.xterm-dim { color: ${Wt.multiplyOpacity(Wt.opaque(e.background),.5).css}; }${this._terminalSelector} .${KS}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 r=this._rowElements.length;r<=t;r++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Po),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Po),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,r),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,r),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,l=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(r){let g=e[0]>t[0];p.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=s===c?e[0]:0,f=c===l?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let y=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==h){let b=l===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,b))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,r,s=1){let l=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(r-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),l.style.height=`${s*this.dimensions.css.cell.height}px`,l.style.top=`${e*this.dimensions.css.cell.height}px`,l.style.left=`${c}px`,l.style.width=`${h}px`,l}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let r=this._bufferService.buffer,s=r.ybase+r.y,l=Math.min(r.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,p=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let f=g+r.ydisp,y=this._rowElements[g],b=r.lines.get(f);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,f,f===s,h,p,l,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${bp}${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,r,s,l,c){r<0&&(e=0),s<0&&(t=0);let h=this._bufferService.rows-1;r=Math.max(Math.min(r,h),0),s=Math.max(Math.min(s,h),0),l=Math.min(l,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,l-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=r;w<=s;++w){let x=w+p.ydisp,D=this._rowElements[w],L=p.lines.get(x);if(!D||!L)break;D.replaceChildren(...this._rowFactory.createRow(L,x,x===g,b,S,f,y,this.dimensions.css.cell.width,this._widthCache,c?w===r?e:0:-1,c?(w===s?t:l)-1:-1))}}};Lm=ai([Ae(7,Fg),Ae(8,qh),Ae(9,hn),Ae(10,un),Ae(11,za),Ae(12,Jr),Ae(13,Fl)],Lm);var Bm=class extends ot{constructor(e,t,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new xe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new jR(this._optionsService))}catch{this._measureStrategy=this._register(new zR(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())}};Bm=ai([Ae(2,hn)],Bm);var C1=class extends ot{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},zR=class extends C1{constructor(e,t,r){super(),this._document=e,this._parentElement=t,this._optionsService=r,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}},jR=class extends C1{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}},PR=class extends ot{constructor(e,t,r){super(),this._textarea=e,this._window=t,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new HR(this._window)),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new xe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Zi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ge(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ge(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}},HR=class extends ot{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Pl),this._onDprChange=this._register(new xe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Yt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ge(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)}},IR=class extends ot{constructor(){super(),this.linkProviders=[],this._register(Yt(()=>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 Qg(e,t,r){let s=r.getBoundingClientRect(),l=e.getComputedStyle(r),c=parseInt(l.getPropertyValue("padding-left")),h=parseInt(l.getPropertyValue("padding-top"));return[t.clientX-s.left-c,t.clientY-s.top-h]}function UR(e,t,r,s,l,c,h,p,g){if(!c)return;let f=Qg(e,t,r);if(f)return f[0]=Math.ceil((f[0]+(g?h/2:0))/h),f[1]=Math.ceil(f[1]/p),f[0]=Math.min(Math.max(f[0],1),s+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),l),f}var Om=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,r,s,l){return UR(window,e,t,r,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(e,t){let r=Qg(window,e,t);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};Om=ai([Ae(0,es),Ae(1,qh)],Om);var KR=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,r){this._rowCount=r,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=[]}},x1={};QT(x1,{getSafariVersion:()=>FR,isChromeOS:()=>D1,isFirefox:()=>k1,isIpad:()=>qR,isIphone:()=>$R,isLegacyEdge:()=>WR,isLinux:()=>Jg,isMac:()=>kh,isNode:()=>$h,isSafari:()=>E1,isWindows:()=>T1});var $h=typeof process<"u"&&"title"in process,Nc=$h?"node":navigator.userAgent,Ac=$h?"node":navigator.platform,k1=Nc.includes("Firefox"),WR=Nc.includes("Edge"),E1=/^((?!chrome|android).)*safari/i.test(Nc);function FR(){if(!E1)return 0;let e=Nc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var kh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ac),qR=Ac==="iPad",$R=Ac==="iPhone",T1=["Windows","Win16","Win32","WinCE"].includes(Ac),Jg=Ac.indexOf("Linux")>=0,D1=/\bCrOS\b/.test(Nc),R1=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,r=0,s=e.timeRemaining(),l=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),l=e.timeRemaining(),r*1.5>l){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=l}this.clear()}},VR=class extends R1{_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())}}},YR=class extends R1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Eh=!$h&&"requestIdleCallback"in window?YR:VR,XR=class{constructor(){this._queue=new Eh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},zm=class extends ot{constructor(e,t,r,s,l,c,h,p,g){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=s,this._coreService=l,this._coreBrowserService=p,this._renderer=this._register(new Pl),this._pausedResizeTask=new XR,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 xe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new xe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new xe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new KR((f,y)=>this._renderRows(f,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new GR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Yt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});r.observe(t),this._observerDisposable.value=Yt(()=>r.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,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),r||(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,r){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,t,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};zm=ai([Ae(2,hn),Ae(3,qh),Ae(4,za),Ae(5,Mc),Ae(6,un),Ae(7,Jr),Ae(8,Fl)],zm);var GR=class{constructor(e,t,r){this._coreBrowserService=e,this._coreService=t,this._onTimeout=r,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 ZR(e,t,r,s){let l=r.buffer.x,c=r.buffer.y;if(!r.buffer.hasScrollback)return eM(l,c,e,t,r,s)+Vh(c,t,r,s)+tM(l,c,e,t,r,s);let h;if(c===t)return h=l>e?"D":"C",_c(Math.abs(l-e),gc(h,s));h=c>t?"D":"C";let p=Math.abs(c-t),g=JR(c>t?e:l,r)+(p-1)*r.cols+1+QR(c>t?l:e);return _c(g,gc(h,s))}function QR(e,t){return e-1}function JR(e,t){return t.cols-e}function eM(e,t,r,s,l,c){return Vh(t,s,l,c).length===0?"":_c(N1(e,t,e,t-Ba(t,l),!1,l).length,gc("D",c))}function Vh(e,t,r,s){let l=e-Ba(e,r),c=t-Ba(t,r),h=Math.abs(l-c)-iM(e,t,r);return _c(h,gc(M1(e,t),s))}function tM(e,t,r,s,l,c){let h;Vh(t,s,l,c).length>0?h=s-Ba(s,l):h=t;let p=s,g=nM(e,t,r,s,l,c);return _c(N1(e,h,r,p,g==="C",l).length,gc(g,c))}function iM(e,t,r){let s=0,l=e-Ba(e,r),c=t-Ba(t,r);for(let h=0;h<Math.abs(l-c);h++){let p=M1(e,t)==="A"?-1:1;r.buffer.lines.get(l+p*h)?.isWrapped&&s++}return s}function Ba(e,t){let r=0,s=t.buffer.lines.get(e),l=s?.isWrapped;for(;l&&e>=0&&e<t.rows;)r++,s=t.buffer.lines.get(--e),l=s?.isWrapped;return r}function nM(e,t,r,s,l,c){let h;return Vh(r,s,l,c).length>0?h=s-Ba(s,l):h=t,e<r&&h<=s||e>=r&&h<s?"C":"D"}function M1(e,t){return e>t?"A":"B"}function N1(e,t,r,s,l,c){let h=e,p=t,g="";for(;(h!==r||p!==s)&&p>=0&&p<c.buffer.lines.length;)h+=l?1:-1,l&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!l&&h<0&&(g+=c.buffer.translateBufferLineToString(p,!1,0,e+1),h=c.cols-1,e=h,p--);return g+c.buffer.translateBufferLineToString(p,!1,e,h)}function gc(e,t){let r=t?"O":"[";return fe.ESC+r+e}function _c(e,t){e=Math.floor(e);let r="";for(let s=0;s<e;s++)r+=t;return r}var rM=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 WS(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 yp=50,sM=15,aM=50,lM=500,oM=" ",cM=new RegExp(oM,"g"),jm=class extends ot{constructor(e,t,r,s,l,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=r,this._bufferService=s,this._coreService=l,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Qn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new xe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new xe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new xe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new rM(this._bufferService),this._activeSelectionMode=0,this._register(Yt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let r=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let l=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let p=r.translateBufferLineToString(h,!0,l,c);s.push(p)}}else{let l=e[1]===t[1]?t[0]:void 0;s.push(r.translateBufferLineToString(e[1],!0,e[0],l));for(let c=e[1]+1;c<=t[1]-1;c++){let h=r.lines.get(c),p=r.translateBufferLineToString(c,!0);h?.isWrapped?s[s.length-1]+=p:s.push(p)}if(e[1]!==t[1]){let c=r.lines.get(t[1]),h=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?s[s.length-1]+=h:s.push(h)}}return s.map(l=>l.replace(cM," ")).join(T1?`\r
|
|
26
|
+
`:`
|
|
27
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Jg&&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),r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s||!t?!1:this._areCoordsInSelection(t,r,s)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!r||!s?!1:this._areCoordsInSelection([e,t],r,s)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=WS(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Qg(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-yp),yp),t/=yp,t/Math.abs(t)+Math.round(t*(sM-1)))}shouldForceSelection(e){return kh?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(),aM)}_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&&!(kh&&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 r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let s=r.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<lM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let s=ZR(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);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,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let s=0;t>=s;s++){let l=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:l>1&&t!==s&&(r+=l-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let l=this._bufferService.buffer,c=l.lines.get(e[1]);if(!c)return;let h=l.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,y=0,b=0,S=0,w=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let L=e[0],A=e[0];c.getWidth(L)===0&&(y++,L--),c.getWidth(A)===2&&(b++,A++);let B=c.getString(A).length;for(B>1&&(w+=B-1,g+=B-1);L>0&&p>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,L--):Y>1&&(S+=Y-1,p-=Y-1),p--,L--}for(;A<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,A++):Y>1&&(w+=Y-1,g+=Y-1),g++,A++}}g++;let x=p+f-y+S,D=Math.min(this._bufferService.cols,g-p+y+b-S-w);if(!(!t&&h.slice(p,g).trim()==="")){if(r&&x===0&&c.getCodePoint(0)!==32){let L=l.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let B=this._bufferService.cols-A.start;x-=B,D+=B}}}if(s&&x+D===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=l.lines.get(e[1]+1);if(L?.isWrapped&&L.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(D+=A.length)}}return{start:x,length:D}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={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=WS(r,this._bufferService.cols)}};jm=ai([Ae(3,un),Ae(4,za),Ae(5,qg),Ae(6,hn),Ae(7,es),Ae(8,Jr)],jm);var FS=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},qS=class{constructor(){this._color=new FS,this._css=new FS}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ti=Object.freeze((()=>{let e=[ei.toColor("#2e3436"),ei.toColor("#cc0000"),ei.toColor("#4e9a06"),ei.toColor("#c4a000"),ei.toColor("#3465a4"),ei.toColor("#75507b"),ei.toColor("#06989a"),ei.toColor("#d3d7cf"),ei.toColor("#555753"),ei.toColor("#ef2929"),ei.toColor("#8ae234"),ei.toColor("#fce94f"),ei.toColor("#729fcf"),ei.toColor("#ad7fa8"),ei.toColor("#34e2e2"),ei.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let s=t[r/36%6|0],l=t[r/6%6|0],c=t[r%6];e.push({css:yi.toCss(s,l,c),rgba:yi.toRgba(s,l,c)})}for(let r=0;r<24;r++){let s=8+r*10;e.push({css:yi.toCss(s,s,s),rgba:yi.toRgba(s,s,s)})}return e})()),Sa=ei.toColor("#ffffff"),Go=ei.toColor("#000000"),$S=ei.toColor("#ffffff"),VS=Go,Ho={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},uM=Sa,Pm=class extends ot{constructor(e){super(),this._optionsService=e,this._contrastCache=new qS,this._halfContrastCache=new qS,this._onChangeColors=this._register(new xe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Sa,background:Go,cursor:$S,cursorAccent:VS,selectionForeground:void 0,selectionBackgroundTransparent:Ho,selectionBackgroundOpaque:Wt.blend(Go,Ho),selectionInactiveBackgroundTransparent:Ho,selectionInactiveBackgroundOpaque:Wt.blend(Go,Ho),scrollbarSliderBackground:Wt.opacity(Sa,.2),scrollbarSliderHoverBackground:Wt.opacity(Sa,.4),scrollbarSliderActiveBackground:Wt.opacity(Sa,.5),overviewRulerBorder:Sa,ansi:Ti.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Mt(e.foreground,Sa),t.background=Mt(e.background,Go),t.cursor=Wt.blend(t.background,Mt(e.cursor,$S)),t.cursorAccent=Wt.blend(t.background,Mt(e.cursorAccent,VS)),t.selectionBackgroundTransparent=Mt(e.selectionBackground,Ho),t.selectionBackgroundOpaque=Wt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Mt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Wt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Mt(e.selectionForeground,IS):void 0,t.selectionForeground===IS&&(t.selectionForeground=void 0),Wt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Wt.opacity(t.selectionBackgroundTransparent,.3)),Wt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Wt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Mt(e.scrollbarSliderBackground,Wt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Mt(e.scrollbarSliderHoverBackground,Wt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Mt(e.scrollbarSliderActiveBackground,Wt.opacity(t.foreground,.5)),t.overviewRulerBorder=Mt(e.overviewRulerBorder,uM),t.ansi=Ti.slice(),t.ansi[0]=Mt(e.black,Ti[0]),t.ansi[1]=Mt(e.red,Ti[1]),t.ansi[2]=Mt(e.green,Ti[2]),t.ansi[3]=Mt(e.yellow,Ti[3]),t.ansi[4]=Mt(e.blue,Ti[4]),t.ansi[5]=Mt(e.magenta,Ti[5]),t.ansi[6]=Mt(e.cyan,Ti[6]),t.ansi[7]=Mt(e.white,Ti[7]),t.ansi[8]=Mt(e.brightBlack,Ti[8]),t.ansi[9]=Mt(e.brightRed,Ti[9]),t.ansi[10]=Mt(e.brightGreen,Ti[10]),t.ansi[11]=Mt(e.brightYellow,Ti[11]),t.ansi[12]=Mt(e.brightBlue,Ti[12]),t.ansi[13]=Mt(e.brightMagenta,Ti[13]),t.ansi[14]=Mt(e.brightCyan,Ti[14]),t.ansi[15]=Mt(e.brightWhite,Ti[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<r;s++)t.ansi[s+16]=Mt(e.extendedAnsi[s],Ti[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Pm=ai([Ae(0,hn)],Pm);function Mt(e,t){if(e!==void 0)try{return ei.toColor(e)}catch{}return t}var hM=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},dM=class{constructor(){this._services=new hM,this._services.set(Fg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=sD(e).sort((c,h)=>c.index-h.index),s=[];for(let c of r){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);s.push(h)}let l=r.length>0?r[0].index:t.length;if(t.length!==l)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${l+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},fM={trace:0,debug:1,info:2,warn:3,error:4,off:5},pM="xterm.js: ",Hm=class extends ot{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=fM[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,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":pM)+t,...r)}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)}};Hm=ai([Ae(0,hn)],Hm);var YS=class extends ot{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new xe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new xe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new xe),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 r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];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,...r){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+r.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<r.length;s++)this._array[this._getCyclicIndex(e+s)]=r[s];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let s=this._length+r.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let l=t-1;l>=0;l--)this.set(e+l+r,this.get(e+l));let s=e+t+r-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+r,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},lt=3,vi=Object.freeze(new Rc),Yu=0,Sp=2,Zo=class A1{constructor(t,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*lt);let l=r||Qn.fromCharData([0,Zw,1,0]);for(let c=0;c<t;++c)this.setCell(c,l);this.length=t}get(t){let r=this._data[t*lt+0],s=r&2097151;return[this._data[t*lt+1],r&2097152?this._combined[t]:s?js(s):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,r){this._data[t*lt+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*lt+0]=t|2097152|r[2]<<22):this._data[t*lt+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*lt+0]>>22}hasWidth(t){return this._data[t*lt+0]&12582912}getFg(t){return this._data[t*lt+1]}getBg(t){return this._data[t*lt+2]}hasContent(t){return this._data[t*lt+0]&4194303}getCodePoint(t){let r=this._data[t*lt+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*lt+0]&2097152}getString(t){let r=this._data[t*lt+0];return r&2097152?this._combined[t]:r&2097151?js(r&2097151):""}isProtected(t){return this._data[t*lt+2]&536870912}loadCell(t,r){return Yu=t*lt,r.content=this._data[Yu+0],r.fg=this._data[Yu+1],r.bg=this._data[Yu+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*lt+0]=r.content,this._data[t*lt+1]=r.fg,this._data[t*lt+2]=r.bg}setCellFromCodepoint(t,r,s,l){l.bg&268435456&&(this._extendedAttrs[t]=l.extended),this._data[t*lt+0]=r|s<<22,this._data[t*lt+1]=l.fg,this._data[t*lt+2]=l.bg}addCodepointToCell(t,r,s){let l=this._data[t*lt+0];l&2097152?this._combined[t]+=js(r):l&2097151?(this._combined[t]=js(l&2097151)+js(r),l&=-2097152,l|=2097152):l=r|1<<22,s&&(l&=-12582913,l|=s<<22),this._data[t*lt+0]=l}insertCells(t,r,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length-t){let l=new Qn;for(let c=this.length-t-r-1;c>=0;--c)this.setCell(t+r+c,this.loadCell(t+c,l));for(let c=0;c<r;++c)this.setCell(t+c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,r,s){if(t%=this.length,r<this.length-t){let l=new Qn;for(let c=0;c<this.length-t-r;++c)this.setCell(t+c,this.loadCell(t+r+c,l));for(let c=this.length-r;c<this.length;++c)this.setCell(c,s)}else for(let l=t;l<this.length;++l)this.setCell(l,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,r,s,l=!1){if(l){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,s);t<r&&t<this.length;)this.setCell(t++,s)}resize(t,r){if(t===this.length)return this._data.length*4*Sp<this._data.buffer.byteLength;let s=t*lt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let l=new Uint32Array(s);l.set(this._data),this._data=l}for(let l=this.length;l<t;++l)this.setCell(l,r)}else{this._data=this._data.subarray(0,s);let l=Object.keys(this._combined);for(let h=0;h<l.length;h++){let p=parseInt(l[h],10);p>=t&&delete this._combined[p]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let p=parseInt(c[h],10);p>=t&&delete this._extendedAttrs[p]}}return this.length=t,s*4*Sp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Sp<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new A1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303)return t+(this._data[t*lt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*lt+0]&4194303||this._data[t*lt+2]&50331648)return t+(this._data[t*lt+0]>>22);return 0}copyCellsFrom(t,r,s,l,c){let h=t._data;if(c)for(let g=l-1;g>=0;g--){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(r+g)*lt+f];h[(r+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}else for(let g=0;g<l;g++){for(let f=0;f<lt;f++)this._data[(s+g)*lt+f]=h[(r+g)*lt+f];h[(r+g)*lt+2]&268435456&&(this._extendedAttrs[s+g]=t._extendedAttrs[r+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=r&&(this._combined[f-r+s]=t._combined[f])}}translateToString(t,r,s,l){r=r??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),l&&(l.length=0);let c="";for(;r<s;){let h=this._data[r*lt+0],p=h&2097151,g=h&2097152?this._combined[r]:p?js(p):Ps;if(c+=g,l)for(let f=0;f<g.length;++f)l.push(r);r+=h>>22||1}return l&&l.push(r),c}};function mM(e,t,r,s,l,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let y=[e.get(p)];for(;g<e.length&&f.isWrapped;)y.push(f),f=e.get(++g);if(!c&&s>=p&&s<g){p+=y.length-1;continue}let b=0,S=vc(y,b,t),w=1,x=0;for(;w<y.length;){let L=vc(y,w,t),A=L-x,B=r-S,Y=Math.min(A,B);y[b].copyCellsFrom(y[w],x,S,Y,!1),S+=Y,S===r&&(b++,S=0),x+=Y,x===L&&(w++,x=0),S===0&&b!==0&&y[b-1].getWidth(r-1)===2&&(y[b].copyCellsFrom(y[b-1],r-1,S++,1,!1),y[b-1].setCell(r-1,l))}y[b].replaceCells(S,r,l);let D=0;for(let L=y.length-1;L>0&&(L>b||y[L].getTrimmedLength()===0);L--)D++;D>0&&(h.push(p+y.length-D),h.push(D)),p+=y.length-1}return h}function gM(e,t){let r=[],s=0,l=t[s],c=0;for(let h=0;h<e.length;h++)if(l===h){let p=t[++s];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,l=t[++s]}else r.push(h);return{layout:r,countRemoved:c}}function _M(e,t){let r=[];for(let s=0;s<t.length;s++)r.push(e.get(t[s]));for(let s=0;s<r.length;s++)e.set(s,r[s]);e.length=t.length}function vM(e,t,r){let s=[],l=e.map((g,f)=>vc(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<l;){if(l-p<r){s.push(l-p);break}c+=r;let g=vc(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let y=f?r-1:r;s.push(y),p+=y}return s}function vc(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,l=e[t+1].getWidth(0)===2;return s&&l?r-1:r}var L1=class B1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=B1._nextId++,this._onDispose=this.register(new xe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),La(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};L1._nextId=1;var bM=L1,Ni={},wa=Ni.B;Ni[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ni.A={"#":"£"};Ni.B=void 0;Ni[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ni.C=Ni[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ni.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ni.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ni.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ni.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ni.E=Ni[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ni.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ni.H=Ni[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ni["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var XS=4294967295,GS=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=vi.clone(),this.savedCharset=wa,this.markers=[],this._nullCell=Qn.fromCharData([0,Zw,1,0]),this._whitespaceCell=Qn.fromCharData([0,Ps,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Eh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new YS(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 wh),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 wh),this._whitespaceCell}getBlankLine(e,t){return new Zo(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>XS?XS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=vi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new YS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(vi),s=0,l=this._getCorrectBufferLength(t);if(l>this.lines.maxLength&&(this.lines.maxLength=l),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)s+=+this.lines.get(h).resize(e,r);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Zo(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Zo(e,r)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(l<this.lines.maxLength){let h=this.lines.length-l;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=l}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=mM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(vi),r);if(s.length>0){let l=gM(this.lines,s);_M(this.lines,l.layout),this._reflowLargerAdjustViewport(e,t,l.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let s=this.getNullCell(vi),l=r;for(;l-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Zo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(vi),l=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let p=this.lines.get(h);if(!p||!p.isWrapped&&p.getTrimmedLength()<=e)continue;let g=[p];for(;p.isWrapped&&h>0;)p=this.lines.get(--h),g.unshift(p);if(!r){let Y=this.ybase+this.y;if(Y>=h&&Y<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),y=vM(g,this._cols,e),b=y.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+b):S=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let Y=0;Y<b;Y++){let P=this.getBlankLine(vi,!0);w.push(P)}w.length>0&&(l.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let x=y.length-1,D=y[x];D===0&&(x--,D=y[x]);let L=g.length-b-1,A=f;for(;L>=0;){let Y=Math.min(A,D);if(g[x]===void 0)break;if(g[x].copyCellsFrom(g[L],A-Y,D-Y,Y,!0),D-=Y,D===0&&(x--,D=y[x]),A-=Y,A===0){L--;let P=Math.max(L,0);A=vc(g,P,this._cols)}}for(let Y=0;Y<g.length;Y++)y[Y]<e&&g[Y].setCell(y[Y],s);let B=b-S;for(;B-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(l.length>0){let h=[],p=[];for(let D=0;D<this.lines.length;D++)p.push(this.lines.get(D));let g=this.lines.length,f=g-1,y=0,b=l[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let D=Math.min(this.lines.maxLength-1,g+c-1);D>=0;D--)if(b&&b.start>f+S){for(let L=b.newLines.length-1;L>=0;L--)this.lines.set(D--,b.newLines[L]);D++,h.push({index:f+1,amount:b.newLines.length}),S+=b.newLines.length,b=l[++y]}else this.lines.set(D,p[f--]);let w=0;for(let D=h.length-1;D>=0;D--)h[D].index+=w,this.lines.onInsertEmitter.fire(h[D]),w+=h[D].amount;let x=Math.max(0,g+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,r=0,s){let l=this.lines.get(e);return l?l.translateToString(t,r,s):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}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 bM(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},yM=class extends ot{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new xe),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 GS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new GS(!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)}},O1=2,z1=1,Im=class extends ot{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,O1),this.rows=Math.max(e.rawOptions.rows||0,z1),this.buffers=this._register(new yM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=r.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let l=r.ybase+r.scrollTop,c=r.ybase+r.scrollBottom;if(r.scrollTop===0){let h=r.lines.isFull;c===r.lines.length-1?h?r.lines.recycle().copyFrom(s):r.lines.push(s.clone()):r.lines.splice(c+1,0,s.clone()),h?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let h=c-l+1;r.lines.shiftElements(l+1,h-1,-1),r.lines.set(c,s.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let s=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),s!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Im=ai([Ae(0,hn)],Im);var kl={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:kh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},SM=["normal","bold","100","200","300","400","500","600","700","800","900"],wM=class extends ot{constructor(e){super(),this._onOptionChange=this._register(new xe),this.onOptionChange=this._onOptionChange.event;let t={...kl};for(let r in e)if(r in t)try{let s=e[r];t[r]=this._sanitizeAndValidateOption(r,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Yt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in kl))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,s)=>{if(!(r in kl))throw new Error(`No option with key "${r}"`);s=this._sanitizeAndValidateOption(r,s),this.rawOptions[r]!==s&&(this.rawOptions[r]=s,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let s={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=kl[e]),!CM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=kl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=SM.includes(t)?t:kl[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 CM(e){return e==="block"||e==="underline"||e==="bar"}function Qo(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let s in e)r[s]=t<=1?e[s]:e[s]&&Qo(e[s],t-1);return r}var ZS=Object.freeze({insertMode:!1}),QS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Um=class extends ot{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new xe),this.onData=this._onData.event,this._onUserInput=this._register(new xe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new xe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Qo(ZS),this.decPrivateModes=Qo(QS)}reset(){this.modes=Qo(ZS),this.decPrivateModes=Qo(QS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Um=ai([Ae(0,un),Ae(1,i1),Ae(2,hn)],Um);var JS={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 wp(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var Cp=String.fromCharCode,e0={DEFAULT:e=>{let t=[wp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Cp(t[0])}${Cp(t[1])}${Cp(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${wp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${wp(e,!0)};${e.x};${e.y}${t}`}},Km=class extends ot{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new xe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(JS))this.addProtocol(s,JS[s]);for(let s of Object.keys(e0))this.addEncoding(s,e0[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let s=t/r,l=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=s+0,Math.abs(e.deltaY)<50&&(l*=.3),this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,r){if(r){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)}};Km=ai([Ae(0,un),Ae(1,za),Ae(2,hn)],Km);var xp=[[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]],xM=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Di;function kM(e,t){let r=0,s=t.length-1,l;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=r;)if(l=r+s>>1,e>t[l][1])r=l+1;else if(e<t[l][0])s=l-1;else return!0;return!1}var EM=class{constructor(){if(this.version="6",!Di){Di=new Uint8Array(65536),Di.fill(1),Di[0]=0,Di.fill(0,1,32),Di.fill(0,127,160),Di.fill(2,4352,4448),Di[9001]=2,Di[9002]=2,Di.fill(2,11904,42192),Di[12351]=1,Di.fill(2,44032,55204),Di.fill(2,63744,64256),Di.fill(2,65040,65050),Di.fill(2,65072,65136),Di.fill(2,65280,65377),Di.fill(2,65504,65511);for(let e=0;e<xp.length;++e)Di.fill(0,xp[e][0],xp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Di[e]:kM(e,xM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),s=r===0&&t!==0;if(s){let l=ka.extractWidth(t);l===0?s=!1:l>r&&(r=l)}return ka.createPropertyValue(0,r,s)}},ka=class lh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new xe,this.onChange=this._onChange.event;let t=new EM;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,r,s=!1){return(t&16777215)<<3|(r&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,s=0,l=t.length;for(let c=0;c<l;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=l)return r+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:r+=this.wcwidth(f)}let p=this.charProperties(h,s),g=lh.extractWidth(p);lh.extractShouldJoin(p)&&(g-=lh.extractWidth(s)),r+=g,s=p}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},TM=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 t0(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var Io=2147483647,DM=256,j1=class Wm{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>DM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new Wm;if(!t.length)return r;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let l=t[s];if(Array.isArray(l))for(let c=0;c<l.length;++c)r.addSubParam(l[c]);else r.addParam(l)}return r}clone(){let t=new Wm(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 r=0;r<this.length;++r){t.push(this.params[r]);let s=this._subParamsIdx[r]>>8,l=this._subParamsIdx[r]&255;l-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,l))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Io?Io: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>Io?Io:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,l=this._subParamsIdx[r]&255;l-s>0&&(t[r]=this._subParams.slice(s,l))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,l=s[r-1];s[r-1]=~l?Math.min(l*10+t,Io):t}},Uo=[],RM=class{constructor(){this._state=0,this._active=Uo,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 r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Uo}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=Uo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Uo,!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,r){if(!this._active.length)this._handlerFb(this._id,"PUT",Fh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&r-t>0&&this._put(e,t,r)}}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 r=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&r===!1){for(;s>=0&&(r=this._active[s].end(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=Uo,this._id=-1,this._state=0}}},Bn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Fh(e,t,r),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(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},Ko=[],MM=class{constructor(){this._handlers=Object.create(null),this._active=Ko,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ko}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ko,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ko,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",Fh(e,t,r));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,s=this._active.length-1,l=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,r=t,l=this._stack.fallThrough,this._stack.paused=!1),!l&&r===!1){for(;s>=0&&(r=this._active[s].unhook(e),r!==!0);s--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,r;s--}for(;s>=0;s--)if(r=this._active[s].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,r}this._active=Ko,this._ident=0}},Jo=new j1;Jo.addParam(0);var i0=class{constructor(e){this._handler=e,this._data="",this._params=Jo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Jo,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=Fh(e,t,r),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(r=>(this._params=Jo,this._data="",this._hitLimit=!1,r));return this._params=Jo,this._data="",this._hitLimit=!1,t}},NM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,s){this.table[t<<8|e]=r<<4|s}addMany(e,t,r,s){for(let l=0;l<e.length;l++)this.table[t<<8|e[l]]=r<<4|s}},Gn=160,AM=(function(){let e=new NM(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),r=(p,g)=>t.slice(p,g),s=r(32,127),l=r(0,24);l.push(25),l.push.apply(l,r(28,32));let c=r(0,14),h;e.setDefault(1,0),e.addMany(s,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(r(128,144),h,3,0),e.addMany(r(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(l,0,3,0),e.addMany(l,1,3,1),e.add(127,1,0,1),e.addMany(l,8,0,8),e.addMany(l,3,3,3),e.add(127,3,0,3),e.addMany(l,4,3,4),e.add(127,4,0,4),e.addMany(l,6,3,6),e.addMany(l,5,3,5),e.add(127,5,0,5),e.addMany(l,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(l,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(l,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(l,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(l,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(l,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(l,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Gn,0,2,0),e.add(Gn,8,5,8),e.add(Gn,6,0,6),e.add(Gn,11,0,11),e.add(Gn,13,13,13),e})(),LM=class extends ot{constructor(e=AM){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 j1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},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(Yt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new RM),this._dcsParser=this._register(new MM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let l=0;l<e.intermediates.length;++l){let c=e.intermediates.charCodeAt(l);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=s,r}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 r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let s=this._escHandlers[r];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let s=this._csiHandlers[r];return s.push(t),{dispose:()=>{let l=s.indexOf(t);l!==-1&&s.splice(l,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,r,s,l){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=s,this._parseStack.chunkPos=l}parse(e,t,r){let s=0,l=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let p=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(r===!1&&g>-1){for(;g>=0&&(h=p[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(s!==24&&s!==26,r),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],h=this._oscParser.end(s!==24&&s!==26,r),h)return h;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let p=c;p<t;++p){switch(s=e[p],l=this._transitions.table[this.currentState<<8|(s<160?s:Gn)],l>>4){case 2:for(let S=p+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Gn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gn){this._printHandler(e,p,S),p=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Gn){this._printHandler(e,p,S),p=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|s],f=g?g.length-1:-1;for(;f>=0&&(h=g[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._preserveStack(3,g,f,l,p),h;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++p<t&&(s=e[p])>47&&s<60);p--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let y=this._escHandlers[this._collect<<8|s],b=y?y.length-1:-1;for(;b>=0&&(h=y[b](),h!==!0);b--)if(h instanceof Promise)return this._preserveStack(4,y,b,l,p),h;b<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let S=p+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Gn){this._dcsParser.put(e,p,S),p=S-1;break}break;case 14:if(h=this._dcsParser.unhook(s!==24&&s!==26),h)return this._preserveStack(6,[],0,l,p),h;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let S=p+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Gn){this._oscParser.put(e,p,S),p=S-1;break}break;case 6:if(h=this._oscParser.end(s!==24&&s!==26),h)return this._preserveStack(5,[],0,l,p),h;s===27&&(l|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=l&15}}},BM=/^([\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})$/,OM=/^[\da-f]+$/;function n0(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=BM.exec(t);if(r){let s=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/s*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/s*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),OM.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,s=[0,0,0];for(let l=0;l<3;++l){let c=parseInt(t.slice(r*l,r*l+r),16);s[l]=r===1?c<<4:r===2?c:r===3?c>>4:c>>8}return s}}function kp(e,t){let r=e.toString(16),s=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function zM(e,t=16){let[r,s,l]=e;return`rgb:${kp(r,t)}/${kp(s,t)}/${kp(l,t)}`}var jM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},As=131072,r0=10;function s0(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 a0=5e3,l0=0,PM=class extends ot{constructor(e,t,r,s,l,c,h,p,g=new LM){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=s,this._optionsService=l,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nD,this._utf8Decoder=new rD,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=vi.clone(),this._eraseAttrDataInternal=vi.clone(),this._onRequestBell=this._register(new xe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new xe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new xe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new xe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new xe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new xe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new xe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new xe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new xe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new xe),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 Fm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:y.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:y,data:b})}),this._parser.setDcsHandlerFallback((f,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:y,payload:b})}),this._parser.setPrintHandler((f,y,b)=>this.print(f,y,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(fe.BEL,()=>this.bell()),this._parser.setExecuteHandler(fe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(fe.BS,()=>this.backspace()),this._parser.setExecuteHandler(fe.HT,()=>this.tab()),this._parser.setExecuteHandler(fe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(fe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(sh.IND,()=>this.index()),this._parser.setExecuteHandler(sh.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(sh.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Bn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Bn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Bn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Bn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Bn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Bn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Bn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Bn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Bn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Bn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Bn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Bn(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Ni)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new i0((f,y)=>this.requestStatusString(f,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),a0))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${a0} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,s=this._activeBuffer.x,l=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;s=this._parseStack.cursorStartX,l=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>As&&(c=this._parseStack.position+As)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<As&&(this._parseBuffer=new Uint32Array(Math.min(e.length,As))),h||this._dirtyRowTracker.clearRange(),e.length>As)for(let f=c;f<e.length;f+=As){let y=f+As<e.length?f+As:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,y),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,l,b,f),this._logSlowResolvingAsync(r),r}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,l,f,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==s||this._activeBuffer.y!==l)&&this._onCursorMove.fire();let p=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(p,this._bufferService.rows-1)})}print(e,t,r){let s,l,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let S=this._parser.precedingJoinState;for(let w=t;w<r;++w){if(s=e[w],s<127&&c){let A=c[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let x=this._unicodeService.charProperties(s,S);l=ka.extractWidth(x);let D=ka.extractShouldJoin(x),L=D?ka.extractWidth(S):0;if(S=x,h&&this._onA11yChar.fire(js(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+l-L>p){if(g){let A=b,B=this._activeBuffer.x-L;for(this._activeBuffer.x=L,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),L>0&&b instanceof Zo&&b.copyCellsFrom(A,B,0,L,!1);B<p;)A.setCellFromCodepoint(B++,0,1,y)}else if(this._activeBuffer.x=p-1,l===2)continue}if(D&&this._activeBuffer.x){let A=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-A,s,l);for(let B=l-L;--B>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(f&&(b.insertCells(this._activeBuffer.x,l-L,this._activeBuffer.getNullCell(y)),b.getWidth(p-1)===2&&b.setCellFromCodepoint(p-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,s,l,y),l>0)for(;--l;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=S,this._activeBuffer.x<p&&r-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,r=>s0(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new i0(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Bn(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,r,s=!1,l=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),l),s&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,l=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(l-1,1),this._activeBuffer.lines.splice(r,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 r=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(vi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,s=ka.extractWidth(t),l=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(l),h=new Uint32Array(c.length*r),p=0;for(let f=0;f<c.length;){let y=c.codePointAt(f)||0;h[p++]=y,f+=y>65535?2:1}let g=p;for(let f=1;f<r;++f)h.copyWithin(g,0,p),g+=p;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(fe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(fe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(fe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(fe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(fe.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,wa),this._charsetService.setgCharset(1,wa),this._charsetService.setgCharset(2,wa),this._charsetService.setgCharset(3,wa);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 r;(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"))(r||={});let s=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:y}=p,b=this._optionsService.rawOptions,S=(D,L)=>(h.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${D};${L}$y`),!0),w=D=>D?1:2,x=e.params[0];return t?x===2?S(x,4):x===4?S(x,w(h.modes.insertMode)):x===12?S(x,3):x===20?S(x,w(b.convertEol)):S(x,0):x===1?S(x,w(s.applicationCursorKeys)):x===3?S(x,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):x===6?S(x,w(s.origin)):x===7?S(x,w(s.wraparound)):x===8?S(x,3):x===9?S(x,w(l==="X10")):x===12?S(x,w(b.cursorBlink)):x===25?S(x,w(!h.isCursorHidden)):x===45?S(x,w(s.reverseWraparound)):x===66?S(x,w(s.applicationKeypad)):x===67?S(x,4):x===1e3?S(x,w(l==="VT200")):x===1002?S(x,w(l==="DRAG")):x===1003?S(x,w(l==="ANY")):x===1004?S(x,w(s.sendFocus)):x===1005?S(x,4):x===1006?S(x,w(c==="SGR")):x===1015?S(x,4):x===1016?S(x,w(c==="SGR_PIXELS")):x===1048?S(x,1):x===47||x===1047||x===1049?S(x,w(f===y)):x===2004?S(x,w(s.bracketedPasteMode)):x===2026?S(x,w(s.synchronizedOutput)):S(x,0)}_updateAttrColor(e,t,r,s,l){return t===2?(e|=50331648,e&=-16777216,e|=Rc.fromColorRGB([r,s,l])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let s=[0,0,-1,0,0,0],l=0,c=0;do{if(s[c+l]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do s[1]===5&&(l=1),s[c+p+1+l]=h[p];while(++p<h.length&&p+c+1+l<s.length);break}if(s[1]===5&&c+l>=2||s[1]===2&&c+l>=5)break;s[1]&&(l=1)}while(++c+t<e.length&&c+l<s.length);for(let h=2;h<s.length;++h)s[h]===-1&&(s[h]=0);switch(s[0]){case 38:r.fg=this._updateAttrColor(r.fg,s[1],s[3],s[4],s[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,s[1],s[3],s[4],s[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,s[1],s[3],s[4],s[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=vi.fg,e.bg=vi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,r,s=this._curAttrData;for(let l=0;l<t;l++)r=e.params[l],r>=30&&r<=37?(s.fg&=-50331904,s.fg|=16777216|r-30):r>=40&&r<=47?(s.bg&=-50331904,s.bg|=16777216|r-40):r>=90&&r<=97?(s.fg&=-50331904,s.fg|=16777216|r-90|8):r>=100&&r<=107?(s.bg&=-50331904,s.bg|=16777216|r-100|8):r===0?this._processSGR0(s):r===1?s.fg|=134217728:r===3?s.bg|=67108864:r===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(l)?e.getSubParams(l)[0]:1,s)):r===5?s.fg|=536870912:r===7?s.fg|=67108864:r===8?s.fg|=1073741824:r===9?s.fg|=2147483648:r===2?s.bg|=134217728:r===21?this._processUnderline(2,s):r===22?(s.fg&=-134217729,s.bg&=-134217729):r===23?s.bg&=-67108865:r===24?(s.fg&=-268435457,this._processUnderline(0,s)):r===25?s.fg&=-536870913:r===27?s.fg&=-67108865:r===28?s.fg&=-1073741825:r===29?s.fg&=2147483647:r===39?(s.fg&=-67108864,s.fg|=vi.fg&16777215):r===49?(s.bg&=-67108864,s.bg|=vi.bg&16777215):r===38||r===48||r===58?l+=this._extractColor(e,l,s):r===53?s.bg|=1073741824:r===55?s.bg&=-1073741825:r===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):r===100?(s.fg&=-67108864,s.fg|=vi.fg&16777215,s.bg&=-67108864,s.bg|=vi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${fe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[?${t};${r}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=vi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!s0(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(`${fe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>r0&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>r0&&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=[],r=e.split(";");for(;r.length>1;){let s=r.shift(),l=r.shift();if(/^\d+$/.exec(s)){let c=parseInt(s);if(o0(c))if(l==="?")t.push({type:0,index:c});else{let h=n0(l);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(r,s):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),s,l=r.findIndex(c=>c.startsWith("id="));return l!==-1&&(s=r[l].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let s=0;s<r.length&&!(t>=this._specialColors.length);++s,++t)if(r[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let l=n0(r[s]);l&&this._onColor.fire([{type:1,index:this._specialColors[t],color:l}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],r=e.split(";");for(let s=0;s<r.length;++s)if(/^\d+$/.exec(r[s])){let l=parseInt(r[s]);o0(l)&&t.push({type:2,index:l})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,wa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(jM[e[0]],Ni[e[1]]||wa),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=vi.clone(),this._eraseAttrDataInternal=vi.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Qn;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 r=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(r);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=h=>(this._coreService.triggerDataEvent(`${fe.ESC}${h}${fe.ESC}\\`),!0),s=this._bufferService.buffer,l=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[l.cursorStyle]-(l.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Fm=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&&(l0=e,e=t,t=l0),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Fm=ai([Ae(0,un)],Fm);function o0(e){return 0<=e&&e<256}var HM=5e7,c0=12,IM=50,UM=class extends ot{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new xe),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 r;for(;r=this._writeBuffer.shift();){this._action(r);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>HM)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 r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],l=this._action(s,t);if(l){let h=p=>performance.now()-r>=c0?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(r,p);l.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-r>=c0)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>IM&&(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()}},qm=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let p=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(g,p)),this._dataByLinkId.set(g.id,g),g.id}let r=e,s=this._getEntryIdKey(r),l=this._entriesWithId.get(s);if(l)return this.addLineToLink(l.id,t.ybase+t.y),l.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);r.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(r,s))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};qm=ai([Ae(0,un)],qm);var u0=!1,KM=class extends ot{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Pl),this._onBinary=this._register(new xe),this.onBinary=this._onBinary.event,this._onData=this._register(new xe),this.onData=this._onData.event,this._onLineFeed=this._register(new xe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new xe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new xe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new xe),this._instantiationService=new dM,this.optionsService=this._register(new wM(e)),this._instantiationService.setService(hn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Im)),this._instantiationService.setService(un,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Hm)),this._instantiationService.setService(i1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Um)),this._instantiationService.setService(za,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Km)),this._instantiationService.setService(t1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ka)),this._instantiationService.setService(oD,this.unicodeService),this._charsetService=this._instantiationService.createInstance(TM),this._instantiationService.setService(lD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qm),this._instantiationService.setService(n1,this._oscLinkService),this._inputHandler=this._register(new PM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Zi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Zi.forward(this._bufferService.onResize,this._onResize)),this._register(Zi.forward(this.coreService.onData,this._onData)),this._register(Zi.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 UM((t,r)=>this._inputHandler.parse(t,r))),this._register(Zi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new xe),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&&!u0&&(this._logService.warn("writeSync is unreliable and will be removed soon."),u0=!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,O1),t=Math.max(t,z1),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(t0.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(t0(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Yt(()=>{for(let t of e)t.dispose()})}}},WM={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 FM(e,t,r,s){let l={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?l.key=fe.ESC+"OA":l.key=fe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?l.key=fe.ESC+"OD":l.key=fe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?l.key=fe.ESC+"OC":l.key=fe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?l.key=fe.ESC+"OB":l.key=fe.ESC+"[B");break;case 8:l.key=e.ctrlKey?"\b":fe.DEL,e.altKey&&(l.key=fe.ESC+l.key);break;case 9:if(e.shiftKey){l.key=fe.ESC+"[Z";break}l.key=fe.HT,l.cancel=!0;break;case 13:l.key=e.altKey?fe.ESC+fe.CR:fe.CR,l.cancel=!0;break;case 27:l.key=fe.ESC,e.altKey&&(l.key=fe.ESC+fe.ESC),l.cancel=!0;break;case 37:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"D":t?l.key=fe.ESC+"OD":l.key=fe.ESC+"[D";break;case 39:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"C":t?l.key=fe.ESC+"OC":l.key=fe.ESC+"[C";break;case 38:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"A":t?l.key=fe.ESC+"OA":l.key=fe.ESC+"[A";break;case 40:if(e.metaKey)break;c?l.key=fe.ESC+"[1;"+(c+1)+"B":t?l.key=fe.ESC+"OB":l.key=fe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(l.key=fe.ESC+"[2~");break;case 46:c?l.key=fe.ESC+"[3;"+(c+1)+"~":l.key=fe.ESC+"[3~";break;case 36:c?l.key=fe.ESC+"[1;"+(c+1)+"H":t?l.key=fe.ESC+"OH":l.key=fe.ESC+"[H";break;case 35:c?l.key=fe.ESC+"[1;"+(c+1)+"F":t?l.key=fe.ESC+"OF":l.key=fe.ESC+"[F";break;case 33:e.shiftKey?l.type=2:e.ctrlKey?l.key=fe.ESC+"[5;"+(c+1)+"~":l.key=fe.ESC+"[5~";break;case 34:e.shiftKey?l.type=3:e.ctrlKey?l.key=fe.ESC+"[6;"+(c+1)+"~":l.key=fe.ESC+"[6~";break;case 112:c?l.key=fe.ESC+"[1;"+(c+1)+"P":l.key=fe.ESC+"OP";break;case 113:c?l.key=fe.ESC+"[1;"+(c+1)+"Q":l.key=fe.ESC+"OQ";break;case 114:c?l.key=fe.ESC+"[1;"+(c+1)+"R":l.key=fe.ESC+"OR";break;case 115:c?l.key=fe.ESC+"[1;"+(c+1)+"S":l.key=fe.ESC+"OS";break;case 116:c?l.key=fe.ESC+"[15;"+(c+1)+"~":l.key=fe.ESC+"[15~";break;case 117:c?l.key=fe.ESC+"[17;"+(c+1)+"~":l.key=fe.ESC+"[17~";break;case 118:c?l.key=fe.ESC+"[18;"+(c+1)+"~":l.key=fe.ESC+"[18~";break;case 119:c?l.key=fe.ESC+"[19;"+(c+1)+"~":l.key=fe.ESC+"[19~";break;case 120:c?l.key=fe.ESC+"[20;"+(c+1)+"~":l.key=fe.ESC+"[20~";break;case 121:c?l.key=fe.ESC+"[21;"+(c+1)+"~":l.key=fe.ESC+"[21~";break;case 122:c?l.key=fe.ESC+"[23;"+(c+1)+"~":l.key=fe.ESC+"[23~";break;case 123:c?l.key=fe.ESC+"[24;"+(c+1)+"~":l.key=fe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?l.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?l.key=fe.NUL:e.keyCode>=51&&e.keyCode<=55?l.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?l.key=fe.DEL:e.keyCode===219?l.key=fe.ESC:e.keyCode===220?l.key=fe.FS:e.keyCode===221&&(l.key=fe.GS);else if((!r||s)&&e.altKey&&!e.metaKey){let h=WM[e.keyCode]?.[e.shiftKey?1:0];if(h)l.key=fe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(p);e.shiftKey&&(g=g.toUpperCase()),l.key=fe.ESC+g}else if(e.keyCode===32)l.key=fe.ESC+(e.ctrlKey?fe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),l.key=fe.ESC+p,l.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(l.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?l.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(l.key=fe.US),e.key==="@"&&(l.key=fe.NUL));break}return l}var di=0,qM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Eh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Eh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((l,c)=>this._getKey(l)-this._getKey(c)),t=0,r=0,s=new Array(this._array.length+this._insertedValues.length);for(let l=0;l<s.length;l++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(s[l]=e[t],t++):s[l]=this._array[r++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(di=this._search(t),di===-1)||this._getKey(this._array[di])!==t)return!1;do if(this._array[di]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(di),!0;while(++di<this._array.length&&this._getKey(this._array[di])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((l,c)=>l-c),t=0,r=new Array(this._array.length-e.length),s=0;for(let l=0;l<this._array.length;l++)e[t]===l?t++:r[s++]=this._array[l];this._array=r,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&&(di=this._search(e),!(di<0||di>=this._array.length)&&this._getKey(this._array[di])===e))do yield this._array[di];while(++di<this._array.length&&this._getKey(this._array[di])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(di=this._search(e),!(di<0||di>=this._array.length)&&this._getKey(this._array[di])===e))do t(this._array[di]);while(++di<this._array.length&&this._getKey(this._array[di])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let s=t+r>>1,l=this._getKey(this._array[s]);if(l>e)r=s-1;else if(l<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Ep=0,h0=0,$M=class extends ot{constructor(){super(),this._decorations=new qM(e=>e?.marker.line),this._onDecorationRegistered=this._register(new xe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new xe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Yt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new VM(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.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,r){let s=0,l=0;for(let c of this._decorations.getKeyIterator(t))s=c.options.x??0,l=s+(c.options.width??1),e>=s&&e<l&&(!r||(c.options.layer??"bottom")===r)&&(yield c)}forEachDecorationAtCell(e,t,r,s){this._decorations.forEachByKey(t,l=>{Ep=l.options.x??0,h0=Ep+(l.options.width??1),e>=Ep&&e<h0&&(!r||(l.options.layer??"bottom")===r)&&s(l)})}},VM=class extends Is{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new xe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new xe),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=ei.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ei.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},YM=1e3,XM=class{constructor(e,t=YM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let l=s-this._lastRefreshMs,c=this._debounceThresholdMS-l;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},d0=20,Th=class extends ot{constructor(e,t,r,s){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let l=this._coreBrowserService.mainDocument;this._accessibilityContainer=l.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=l.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=l.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new XM(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
28
|
+
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ge(l,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Yt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<d0+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===d0+1&&(this._liveRegion.textContent+=hm.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 r=this._terminal.buffer,s=r.lines.length.toString();for(let l=e;l<=t;l++){let c=r.lines.get(r.ydisp+l),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(r.ydisp+l+1).toString(),f=this._rowElements[l];f&&(p.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=p,this._rowColumns.set(f,h)),f.setAttribute("aria-posinset",g),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],l=r.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(l===c||e.relatedTarget!==s)return;let h,p;if(t===0?(h=r,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=r,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),p.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let l=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,y=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(f);if(!b)return console.warn("columns is null. Race condition?"),null;let S=g<b.length?b[g]:b.slice(-1)[0]+1;return S>=this._terminal.cols&&(++y,S=0),{row:y,column:S}},c=l(t),h=l(r);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let s=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Th=ai([Ae(1,Fg),Ae(2,Jr),Ae(3,es)],Th);var $m=class extends ot{constructor(e,t,r,s,l){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=s,this._linkProviderService=l,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new xe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new xe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Yt(()=>{La(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(Ge(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ge(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ge(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ge(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 r=e.composedPath();for(let s=0;s<r.length;s++){let l=r[s];if(l.classList.contains("xterm"))break;if(l.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(l=>{l.link.dispose&&l.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[s,l]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(r=this._checkLinkProviderResult(s,e,r)):l.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(s,h),r=this._checkLinkProviderResult(s,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let s=0;s<t.size;s++){let l=t.get(s);if(l)for(let c=0;c<l.length;c++){let h=l[c],p=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let f=p;f<=g;f++){if(r.has(f)){l.splice(c--,1);break}r.add(f)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let s=this._activeProviderReplies.get(e),l=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(l=!0);if(!l&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(r=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){r=!0,this._handleNewLink(h);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&GM(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,La(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:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let s=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,l=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=l&&(this._clearCurrentLink(s,l),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,r){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(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,s=this._bufferService.buffer.ydisp,l=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-s-1,r.end.x,r.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(l)}_linkLeave(e,t,r){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(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,l=t.y*this._bufferService.cols+t.x;return r<=l&&l<=s}_positionFromMouseEvent(e,t,r){let s=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,s,l){return{x1:e,y1:t,x2:r,y2:s,cols:this._bufferService.cols,fg:l}}};$m=ai([Ae(1,qg),Ae(2,es),Ae(3,un),Ae(4,s1)],$m);function GM(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 ZM=class extends KM{constructor(e={}){super(e),this._linkifier=this._register(new Pl),this.browser=x1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Pl),this._onCursorMove=this._register(new xe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new xe),this.onKey=this._onKey.event,this._onRender=this._register(new xe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new xe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new xe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new xe),this.onBell=this._onBell.event,this._onFocus=this._register(new xe),this._onBlur=this._register(new xe),this._onA11yCharEmitter=this._register(new xe),this._onA11yTabEmitter=this._register(new xe),this._onWillOpen=this._register(new xe),this._setup(),this._decorationService=this._instantiationService.createInstance($M),this._instantiationService.setService(Mc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(IR),this._instantiationService.setService(s1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(fm)),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(Zi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Zi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Zi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Zi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Yt(()=>{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 r,s="";switch(t.index){case 256:r="foreground",s="10";break;case 257:r="background",s="11";break;case 258:r="cursor",s="12";break;default:r="ansi",s="4;"+t.index}switch(t.type){case 0:let l=Wt.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${fe.ESC}]${s};${zM(l)}${w1.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=yi.toColor(...t.color));else{let c=r;this._themeService.modifyColors(h=>h[c]=yi.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(Th,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.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(fe.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 r=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,l=t.getWidth(r),c=this._renderService.dimensions.css.cell.width*l,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=p+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ge(this.element,"copy",t=>{this.hasSelection()&&tD(t,this._selectionService)}));let e=t=>iD(t,this.textarea,this.coreService,this.optionsService);this._register(Ge(this.textarea,"paste",e)),this._register(Ge(this.element,"paste",e)),k1?this._register(Ge(this.element,"mousedown",t=>{t.button===2&&wS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ge(this.element,"contextmenu",t=>{wS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Jg&&this._register(Ge(this.element,"auxclick",t=>{t.button===1&&Gw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ge(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ge(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ge(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ge(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ge(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ge(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ge(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(Ge(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",um.get()),D1||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",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(PR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Jr,this._coreBrowserService),this._register(Ge(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Ge(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bm,this._document,this._helperContainer),this._instantiationService.setService(qh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Pm),this._instantiationService.setService(Fl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(xh),this._instantiationService.setService(r1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(zm,this.rows,this.screenElement)),this._instantiationService.setService(es,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Nm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Om),this._instantiationService.setService(qg,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance($m,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(Rm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jm,this.element,this.screenElement,s)),this._instantiationService.setService(uD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Zi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Mm,this.screenElement)),this._register(Ge(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Th,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ch,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ch,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Lm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let p,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(p=3,c.button!==void 0&&(p=c.button<3?c.button:3)):p=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,p=c.button<3?c.button:3;break;case"mousedown":g=1,p=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let f=c.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=f<0?0:1,p=4;break;default:return!1}return g===void 0||p===void 0||p>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:p,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},l={mouseup:c=>(r(c),c.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(c)),wheel:c=>(r(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&r(c)},mousemove:c=>{c.buttons||r(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?s.mousemove||(t.addEventListener("mousemove",l.mousemove),s.mousemove=l.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),c&16?s.wheel||(t.addEventListener("wheel",l.wheel,{passive:!1}),s.wheel=l.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),c&2?s.mouseup||(s.mouseup=l.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),c&4?s.mousedrag||(s.mousedrag=l.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ge(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return r(c),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(c)})),this._register(Ge(t,"wheel",c=>{if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let h=fe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Xw(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,r){this._selectionService.setSelection(e,t,r)}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 r=FM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let s=this.rows-1;return this.scrollLines(r.type===2?-s:s),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.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((r.key===fe.ETX||r.key===fe.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=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"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(QM(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(vi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(fe.ESC+"[I"):this.coreService.triggerDataEvent(fe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[4;${r};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),l=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[6;${l};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function QM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var JM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;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)}},eN=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 Qn)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},f0=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 eN(t)}getNullCell(){return new Qn}},tN=class extends ot{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new xe),this.onBufferChange=this._onBufferChange.event,this._normal=new f0(this._core.buffers.normal,"normal"),this._alternate=new f0(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)}},iN=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,s)=>t(r,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},nN=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}},rN=["cols","rows"],xr=0,sN=class extends ot{constructor(e){super(),this._core=this._register(new ZM(e)),this._addonManager=this._register(new JM),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],r=(s,l)=>{this._checkReadonlyOptions(s),this._core.options[s]=l};for(let s in this._core.options){let l={get:t.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this._publicOptions,s,l)}}_checkReadonlyOptions(e){if(rN.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 iN(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nN(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 tN(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,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
30
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return um.get()},set promptLabel(e){um.set(e)},get tooMuchOutput(){return hm.get()},set tooMuchOutput(e){hm.set(e)}}}_verifyIntegers(...e){for(xr of e)if(xr===1/0||isNaN(xr)||xr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(xr of e)if(xr&&(xr===1/0||isNaN(xr)||xr%1!==0||xr<0))throw new Error("This API only accepts positive integers")}};class aN{pending=null;accept(t){let r="";for(const s of t)r+=this.acceptChar(s);return r}acceptChar(t){return t===""?this.acceptBackspace():U1.has(t)?this.acceptConsonant(t):K1.has(t)?this.acceptVowel(t):uN(t)&&this.canReplacePendingWith(t)?(this.pending=m0(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const l=this.flushPending();return this.pending={initial:t},l}if(!this.pending.final){if(W1.has(t))return this.pending.final=t,"";const l=this.flushPending();return this.pending={initial:t},l}const r=cN.get(`${this.pending.final}${t}`);if(r)return this.pending.final=r,"";const s=this.flushPending();return this.pending={initial:t},s}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=oN.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const r=p0.get(this.pending.final);if(r){this.pending.final=r[0];const c=this.flushPending();return this.pending={initial:r[1],vowel:t},c}const s=this.pending.final,l=g0({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:s,vowel:t},l}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=p0.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 r=m0(t);return r.initial===this.pending.initial&&(!this.pending.vowel||r.vowel===this.pending.vowel)&&(!this.pending.final||r.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=g0(this.pending);return this.pending=null,t}}const Dh=44032,Rh=21,Ml=28,lN=19*Rh*Ml,P1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],H1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],I1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],U1=e_(P1),K1=e_(H1),W1=e_(I1),oN=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),F1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],cN=new Map(F1),p0=new Map(F1.map(([e,t])=>[t,[e[0],e[1]]]));function e_(e){return new Map(e.map((t,r)=>[t,r]))}function uN(e){const t=e.codePointAt(0);return t!==void 0&&t>=Dh&&t<Dh+lN}function m0(e){const t=e.codePointAt(0)-Dh,r=Math.floor(t/(Rh*Ml)),s=Math.floor(t%(Rh*Ml)/Ml),l=t%Ml,c={initial:P1[r],vowel:H1[s]};return l===0?c:{...c,final:I1[l]}}function g0(e){if(!e.vowel)return e.initial;const t=U1.get(e.initial),r=K1.get(e.vowel),s=e.final?W1.get(e.final):0;return t===void 0||r===void 0||s===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(Dh+(t*Rh+r)*Ml+s)}const hN=[{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 dN({ctrlActive:e,onCtrl:t,onStandaloneKey:r,onPreserveFocus:s,onHide:l}){function c(h){h.preventDefault(),h.stopPropagation(),s()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),hN.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>r(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:l,children:"×"})]})}const fN={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function pN(e){return fN[e]}function mN(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const q1="--nterminal-viewport-height",$1="--nterminal-keyboard-inset-bottom",V1="data-nterminal-keyboard-visible",Yh="data-nterminal-compose-open",Mh="nterminal:viewport-refresh",gN=120;function _N(e=window){const t=e.document.documentElement,r=e.visualViewport,s=CN(e);function l(){t_(e)}return l(),r?.addEventListener("resize",l),r?.addEventListener("scroll",l),s?.addEventListener("geometrychange",l),e.addEventListener("resize",l),e.addEventListener(Mh,l),e.addEventListener("orientationchange",l),e.addEventListener("pageshow",l),e.document.addEventListener("visibilitychange",l),()=>{r?.removeEventListener("resize",l),r?.removeEventListener("scroll",l),s?.removeEventListener("geometrychange",l),e.removeEventListener("resize",l),e.removeEventListener(Mh,l),e.removeEventListener("orientationchange",l),e.removeEventListener("pageshow",l),e.document.removeEventListener("visibilitychange",l),t.style.removeProperty(q1),t.style.removeProperty($1),t.removeAttribute(V1)}}function t_(e=window){const t=e.document.documentElement,{keyboardInsetBottom:r,keyboardVisible:s}=Vm(e),l=vN(e,s);return l!==null&&_0(t,q1,`${l}px`),_0(t,$1,`${r}px`),bN(t,V1,String(s)),{viewportHeight:l,keyboardInsetBottom:r,keyboardVisible:s}}function Vm(e=window){const t=yN(e);return{keyboardInsetBottom:t,keyboardVisible:t>gN}}function vN(e,t){if((e.document.documentElement.hasAttribute(Yh)||t)&&Ra(e.innerHeight))return e.innerHeight;const r=e.visualViewport?.height;return Ra(r)?r:Ra(e.innerHeight)?e.innerHeight:null}function Ra(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function _0(e,t,r){e.style.getPropertyValue(t)!==r&&e.style.setProperty(t,r)}function bN(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function yN(e){return Math.max(SN(e),wN(e))}function SN(e){const t=e.visualViewport?.height;if(!Ra(t)||!Ra(e.innerHeight))return 0;const r=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-r))}function wN(e){if(!Ra(e.innerHeight))return 0;const r=Y1(e)?.boundingRect?.height;return!Ra(r)||r>=e.innerHeight*.8?0:Math.round(r)}function Y1(e){return e.navigator.virtualKeyboard}function CN(e){const t=Y1(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const Lc=new Map,bc=new Map,xN=Object.freeze({open:!1,text:""});function kN(e){let t=bc.get(e);return t||(t=new Set,bc.set(e,t)),t}function X1(e){const t=bc.get(e);if(t)for(const r of Array.from(t))r()}function i_(e){return Lc.get(e)??xN}function EN(e,t){const r=kN(e);return r.add(t),()=>{r.delete(t)}}function TN(e,t){const r=i_(e);r.open!==t&&(Lc.set(e,{...r,open:t}),X1(e))}function DN(e,t){const r=i_(e);r.text!==t&&(Lc.set(e,{...r,text:t}),X1(e))}function Xu(e){Lc.delete(e),bc.delete(e)}function v0(){Lc.clear(),bc.clear()}const G1=120,RN="\x1B[200~",MN="\x1B[201~";function b0(e,t){const r=t.stripTrailingLineBreaks===!1?e:n_(e),s=AN(r);return s?t.bracketedPasteMode?`${RN}${s}${MN}`:s:""}function NN(e){return e==="queue"?" ":"\r"}function n_(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function AN(e){return e.replace(/\r\n/g,`
|
|
31
|
+
`).replace(/\r/g,`
|
|
32
|
+
`).replace(/\n/g,"\r")}const LN=420,BN=3e3,y0=650,ON=80,zN=3,oh=new Set;let Bl=null;function jN({terminalId:e,onSubmit:t,queueAvailable:r=!1,disabled:s=!1}){const l=v.useMemo(()=>B=>EN(e,B),[e]),c=v.useMemo(()=>()=>i_(e),[e]),h=v.useSyncExternalStore(l,c,c),{open:p,text:g}=h,f=v.useRef(null),y=v.useRef(null),b=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!p||!ch()))return HN(e),()=>IN(e)},[p,e]),v.useLayoutEffect(()=>{const B=f.current?.closest(".terminal-pane");if(!B)return;function Y(){B?.removeAttribute("data-compose-open"),B?.style.removeProperty("--compose-drawer-panel-height")}if(!p){Y();return}const P=y.current;B.setAttribute("data-compose-open","true");function q(){const ve=P?.getBoundingClientRect().height??0;ve>0&&B?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}q();const re=[window.setTimeout(q,0),window.setTimeout(q,180),window.setTimeout(q,260)],ne=window.requestAnimationFrame?.(q)??null,he=typeof ResizeObserver=="function"&&P?new ResizeObserver(q):null;return he&&P&&he.observe(P),()=>{for(const ve of re)window.clearTimeout(ve);ne!==null&&window.cancelAnimationFrame?.(ne),he?.disconnect(),Y()}},[p]),v.useEffect(()=>{if(!p){S.current?.(),S.current=null;return}S0(b.current),A()},[p]);function w(B){TN(e,B)}function x(B){DN(e,B)}function D(){PN(f.current),w(!1),w0()}function L(B="send"){if(!(s||!g)){if(t(g,B),x(""),ch()){b.current?.blur(),w0();return}window.setTimeout(()=>b.current?.focus(),G1+20)}}function A(){ch()&&(S.current?.(),S.current=UN())}return m.jsxs("div",{ref:f,className:"compose-drawer","data-open":p?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":p?"true":void 0,tabIndex:p?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":p?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:p?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:D,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:r?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:p?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:B=>x(B.target.value),onFocus:A,onKeyDown:B=>{if(B.key==="Enter"&&(B.metaKey||B.ctrlKey)){if(B.preventDefault(),B.shiftKey){r&&L("queue");return}L("send");return}B.key==="Escape"&&(B.preventDefault(),D())},placeholder:r?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:p?0:-1,onClick:()=>{x(""),S0(b.current),A()},disabled:!g,children:"Clear"}),r?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:p?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>L("queue"),disabled:s||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:p?0:-1,onClick:()=>L("send"),disabled:s||!g,children:"Send"})]})]})]})}function PN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function S0(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function ch(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function w0(){if(!ch())return;const e=Nl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function HN(e){Bl!==null&&(window.clearTimeout(Bl),Bl=null),oh.add(e),document.documentElement.setAttribute(Yh,"true"),Nl()}function IN(e){if(oh.delete(e),oh.size>0||Bl!==null){Nl();return}Bl=window.setTimeout(()=>{if(Bl=null,oh.size>0){Nl();return}document.documentElement.removeAttribute(Yh),Nl()},LN),Nl()}function UN(){let e=!1,t=null,r=null,s=null,l=0;const c=Date.now(),h=window.visualViewport,p=KN();function g(){t!==null&&(window.clearTimeout(t),t=null),r!==null&&(window.cancelAnimationFrame?.(r),r=null)}function f(){e||(e=!0,g(),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b),p?.removeEventListener("geometrychange",b))}function y(S){if(!e){if(S<y0&&typeof window.requestAnimationFrame=="function"){r=window.requestAnimationFrame(b);return}t=window.setTimeout(b,ON)}}function b(){if(e)return;g();const S=t_(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===s?l+=1:(l=S.keyboardInsetBottom>0?1:0,s=S.keyboardInsetBottom),w>=BN||w>=y0&&l>=zN){f();return}y(w)}return h?.addEventListener("resize",b),h?.addEventListener("scroll",b),p?.addEventListener("geometrychange",b),b(),f}function Nl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,t_()}function KN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function WN(e,t){e.attachCustomKeyEventHandler(c=>{if(FN(c)){const h=C0(e);return h?(c.preventDefault(),c.stopPropagation(),x0(h),!1):!0}return qN(c)?(c.preventDefault(),c.stopPropagation(),$N(e,t),!1):!0});const r=e.element;if(!r)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const s=c=>{const h=C0(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),x0(h)}},l=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const p=n_(h);c.preventDefault(),c.stopImmediatePropagation(),Z1(e,p,t)};return r.addEventListener("copy",s,!0),r.addEventListener("paste",l,!0),{dispose(){r.removeEventListener("copy",s,!0),r.removeEventListener("paste",l,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function FN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function qN(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 $N(e,t){if(navigator.clipboard?.readText)try{const r=await navigator.clipboard.readText();if(!r)return;Z1(e,n_(r),t)}catch{}}function Z1(e,t,r){if(t){if(r){r(t);return}e.paste(t)}}function C0(e){return e.hasSelection()?e.getSelection():""}async function x0(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}VN(e)}function VN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",r.style.opacity="0",document.body.appendChild(r),r.focus({preventScroll:!0}),r.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{r.remove(),t?.focus({preventScroll:!0})}}const YN=[4,10,11,12];function XN(e,t){const r=[e.parser.registerCsiHandler({final:"c"},s=>k0(s)),e.parser.registerCsiHandler({prefix:">",final:"c"},s=>k0(s)),e.parser.registerCsiHandler({final:"n"},s=>GN(s)),e.parser.registerCsiHandler({prefix:"?",final:"n"},s=>ZN(s)),e.parser.registerCsiHandler({final:"t"},s=>QN(s)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...YN.map(s=>e.parser.registerOscHandler(s,l=>JN(l)))];return{dispose(){for(const s of r)s.dispose()}}}function k0(e){return Xh(e)===0}function GN(e){const t=Xh(e);return t===5||t===6}function ZN(e){return Xh(e)===6}function QN(e){const t=Xh(e);return t===14||t===16||t===18}function JN(e){return e.split(";").some(t=>t==="?")}function Xh(e){const t=e[0];return typeof t=="number"?t:0}const Oa=new Map,eA=2*1024*1024,tA=1500,iA=25e3;function nA(e,t){let r=Oa.get(e);r||(r=aA(e),Oa.set(e,r),Gh(r)),r.listeners.add(t);const s=c=>dA(r,c),l=()=>{r.listeners.delete(t)};return{status:r.status,snapshot:r.snapshot,output:r.output.slice(),history:r.history,send:s,detach:l}}function ec(e){const t=Oa.get(e);t&&(fA(t),Oa.delete(e))}function rA(e,t={}){const r=Oa.get(e);if(!r)return!1;r.exited=!1,r.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(r.preserveCachedOutputOnNextSnapshot=!0),r.reconnectTimer!==null&&(window.clearTimeout(r.reconnectTimer),r.reconnectTimer=null),Bc(r);const s=r.socket;return r.socket=null,Ca(r,"reconnecting"),s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)&&s.close(),Gh(r),!0}function sA(){for(const e of Oa.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Bc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,Ca(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Gh(e)}}function Tp(){for(const e of Array.from(Oa.keys()))ec(e)}function aA(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function Gh(e){if(!e.reconnectEnabled)return;Ca(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){Ca(e,"connected");for(const r of e.pendingOut)t.send(JSON.stringify(r));e.pendingOut.length=0,e.isAlive=!0,lA(e)}}),t.addEventListener("message",r=>{if(e.socket!==t)return;const s=typeof r.data=="string"?r.data:"";if(!s)return;let l=null;try{l=JSON.parse(s)}catch{return}if(!l||typeof l.type!="string")return;if(l.type==="pong"){e.isAlive=!0;return}const c=cA(e,l);Q1(e,{type:"message",message:c})}),t.addEventListener("close",r=>{if(e.socket===t){if(e.socket=null,Bc(e),r.code===1008){e.reconnectEnabled=!1,Ca(e,oA(r.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){Ca(e,"closed");return}Ca(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Gh(e)},tA)}}),t.addEventListener("error",()=>{})}function lA(e){Bc(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},iA)}function Bc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function oA(e){return e.trim().toLowerCase()==="unauthorized"}function cA(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,uA(e,t.output),Dp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((r,s)=>r+s.length,0),Dp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,Dp(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function uA(e,t){const r=hA(e.output,t);if(r===0)return;const s=t.slice(r);for(const l of s)e.output.push(l),e.outputBytes+=l.length}function hA(e,t){const r=Math.min(e.length,t.length);for(let s=r;s>0;s-=1){let l=!0;for(let c=0;c<s;c+=1)if(e[e.length-s+c]!==t[c]){l=!1;break}if(l)return s}return 0}function Dp(e){for(;e.outputBytes>eA&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function Ca(e,t){e.status!==t&&(e.status=t,Q1(e,{type:"status",status:t}))}function Q1(e,t){for(const r of Array.from(e.listeners))r(t)}function dA(e,t){const r=e.socket;return r&&r.readyState===WebSocket.OPEN?(r.send(JSON.stringify(t)),!0):((t.type==="input"||t.type==="cancel_scrollback")&&e.pendingOut.push(t),!1)}function fA(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),Bc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const pA=[0,50,150,350],mA=2,gA=[300,1200,2500],_A=1e3,vA=1e5,Ym="\x1B[?1049l\x1B[?1047l\x1B[?47l",bA=new Set(["47","1047","1049"]),yA=400,SA=3,wA=3,CA=32,xA=1.42,kA=2,EA=24,TA=240,DA=60,RA=420,MA=6,NA=2,E0=[500,1500,3e3,5e3,8e3],T0=15e3,AA=40,Gu=240,LA=Mi.lazy(()=>Wg(()=>import("./TranscriptMarkdownBody-BaMp6W3l.js"),__vite__mapDeps([2,1])));function D0({terminal:e,serverApi:t,active:r,visible:s=!0,canClose:l,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:y,onAuthClose:b}){const S=v.useSyncExternalStore(Lw,em,()=>Ta),w=v.useSyncExternalStore(Bw,tm,()=>zl),x=v.useSyncExternalStore(Ow,nm,()=>!0),D=v.useSyncExternalStore(th,rm,()=>!0),L=v.useSyncExternalStore(th,sm,()=>!0),A=v.useSyncExternalStore(_g,Us,()=>Ol),B=v.useSyncExternalStore(bh,()=>yh("history.toggle"),()=>"Alt+H"),Y=v.useSyncExternalStore(bh,()=>yh("scrollback.toggle"),()=>"Alt+S"),P=v.useRef(null),q=v.useRef(null),re=v.useRef(null),ne=v.useRef(null),he=v.useRef({onExit:f,onSnapshot:y}),ve=v.useRef(t.createWebSocketUrl),U=v.useRef(b),K=v.useRef(null),W=v.useRef(null),H=v.useRef(null),j=v.useRef(!1),ae=v.useRef(new Map),R=v.useRef([]),X=v.useRef(null),Z=v.useRef(0),Ce=v.useRef(!1),Te=v.useRef(!1),M=v.useRef(!1),Q=v.useRef({terminalId:e.id,enabled:!1}),de=v.useRef([]),me=v.useRef([]),ge=v.useRef(0),Se=v.useRef(!1),Ee=v.useRef(null),De=v.useRef(0),Ke=v.useRef(null),se=v.useRef(null),pe=v.useRef(!1),Le=v.useRef(!1),be=v.useRef(!1),Me=v.useRef(!1),Pe=v.useRef(null),ze=v.useRef(null),ie=v.useRef(!1),ke=v.useRef(!1),Re=v.useRef(!1),Be=v.useRef(!1),je=v.useRef(!1),at=v.useRef(!1),Xt=v.useRef(!1),Ve=v.useRef(r),xt=v.useRef(s),ti=v.useRef(c),kt=v.useRef(S),_e=v.useRef(w),Fe=v.useRef(!1),Je=v.useRef(null),ct=v.useRef(null),Pt=v.useRef(!1),bt=v.useRef(null),[,Nt]=v.useState("connecting"),[Ft,F]=v.useState(!1),[Ue,st]=v.useState(null),[Si,wi]=v.useState(!1),[Ai,St]=v.useState(null),[At,qt]=v.useState(!1),[Gt,Ci]=v.useState(!1),[li,zt]=v.useState(!1),[Wi,Ht]=v.useState(!1),[Et,Zt]=v.useState(null),[oi,Qi]=v.useState(!1),[wn,Li]=v.useState(()=>up(e.id)),Cn=!!Et||tc(e.currentCommand),Fi=!!Et||tc(e.currentCommand),$t=e.capabilities?.tmuxScrollback===!0,ci=$t&&(wn??(Fi?L:D)),[Rr,Ha]=v.useState(!1);v.useLayoutEffect(()=>{Ve.current=r},[r]),v.useLayoutEffect(()=>{xt.current=s},[s]),v.useLayoutEffect(()=>{ti.current=c},[c]),v.useLayoutEffect(()=>{kt.current=S},[S]),v.useLayoutEffect(()=>{_e.current=w},[w]),v.useLayoutEffect(()=>{Fe.current=oi},[oi]),v.useLayoutEffect(()=>{Je.current=Et},[Et]),v.useLayoutEffect(()=>{Pt.current=Cn},[Cn]),v.useLayoutEffect(()=>{const T=Q.current;Te.current=ci,M.current=$t,Q.current={terminalId:e.id,enabled:ci},B0(P.current,ci),T.terminalId===e.id&&T.enabled&&!ci&&ln(),ci||zt(!1)},[e.id,ci,$t]),v.useEffect(()=>{Li(up(e.id)),Z.current=0,Ce.current=!1,zt(!1),tn()},[e.id]),v.useEffect(()=>th(()=>{Li(up(e.id))}),[e.id]),v.useEffect(()=>{s&&r&&e.status==="running"&&($e(),He("auto"))},[r,s,e.status]),v.useEffect(()=>{he.current={onExit:f,onSnapshot:y}},[f,y]),v.useEffect(()=>{ve.current=t.createWebSocketUrl,U.current=b},[t,b]),v.useEffect(()=>{let T=!1,J=null,We=0;const Xe=t3(e.currentCommand),Ze=tc(e.currentCommand);function dt(){J!==null&&(window.clearTimeout(J),J=null)}function ii(Qt){if(T)return;let ki;if(Qt){if(!Ze)return;ki=T0}else if(We<E0.length){if(!Xe)return;ki=E0[We++]}else{if(!Ze)return;ki=T0}J=window.setTimeout(()=>{J=null,nn()},ki)}async function nn(){try{const Qt=await t.getTerminalTranscriptSource(e.id);if(T)return;Zt(ki=>ki&&Qt.source&&ki.provider===Qt.source.provider&&ki.sessionId===Qt.source.sessionId?ki:Qt.source),ii(!!Qt.source)}catch(Qt){if(T)return;Rp(Qt)&&Zt(null),ii(!1)}}return Zt(null),e.status!=="running"?()=>{T=!0,dt()}:(nn(),()=>{T=!0,dt()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const T=Et?`${e.id}:${Et.provider}:${Et.sessionId}`:null,J=ct.current;J!==null&&T!==null&&J!==T&&Fe.current&&Qi(!1),ct.current=T},[e.id,Et?.provider,Et?.sessionId]),v.useEffect(()=>{function T(J){if(!Ve.current||!xt.current||J.isComposing||J.key==="Process"||zA(J.target))return;const We=Hw(J);if(We?.id==="history.toggle"&&Je.current){J.preventDefault(),J.stopPropagation(),Qi(Xe=>!Xe);return}if(We?.id==="scrollback.toggle"&&M.current){J.preventDefault(),J.stopPropagation(),E();return}}return window.addEventListener("keydown",T,!0),()=>window.removeEventListener("keydown",T,!0)},[]),v.useEffect(()=>{const T=q.current;T&&(T.options.disableStdin=e.status==="exited"),e.status==="exited"&&Nt("closed")},[e.status]),v.useEffect(()=>{const T=q.current;T&&(T.options.fontSize=S,cp(S,_e.current).then(()=>{kt.current===S&&$e()}))},[S]),v.useEffect(()=>{const T=q.current;T&&(T.options.fontFamily=Jp(w),cp(kt.current,w).then(()=>{_e.current===w&&$e()}))},[w]),v.useEffect(()=>{const T=q.current;T&&(T.options.theme=R0(A))},[A]),v.useEffect(()=>{const T=P.current;if(!T)return;let J=!1,We=null,Xe=null,Ze=null,dt=null,ii=null,nn=null,Qt=null;K.current=null,je.current=!1,at.current=!1,Me.current=!1,Mr(),ts();const ki=kt.current,ta=_e.current,kn=new sN({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Jp(ta),fontSize:ki,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:vA,theme:{...R0(Us())}}),Gl=new GT;return kn.loadAddon(Gl),dt=XN(kn),q.current=kn,re.current=Gl,cp(ki,ta).then(()=>{if(J)return;kn.open(T),B0(T,Te.current),je.current=!0,We=WN(kn,ye),xt.current&&Ve.current&&e.status==="running"&&He("auto"),$e(),ii=u3(T,kn,()=>kt.current*1.2,mr,vr=>{jn(vr)},dn,xn,()=>Te.current,$i),nn=l3(T,kn,mr,vr=>{jn(vr)},dn,xn,()=>Te.current,$i);const td=new aN;Xe=kn.onData(vr=>{if(Xt.current){const zc=mN(vr);if(zc){jt(!1),te(zc);return}}const Oc=td.accept(vr);Oc&&te(Oc)}),Ze=kn.onScroll(vr=>{if(ke.current||Be.current||Re.current){gt();return}Nr(),cr(kn)&&en({scrollToBottom:!0}),mr(),!Te.current&&vr<=3&&jn()}),Qt=new ResizeObserver(()=>{Pn()}),Qt.observe(T),at.current&&(er(),at.current=!1,$e()),ns()}),()=>{as(ne.current,{updateUi:!1}),J=!0,je.current=!1,at.current=!1,Mr(),W.current=null,H.current=null,j.current=!1,pr(),Ys(),Re.current=!1,ii?.(),nn?.(),Qt?.disconnect(),We?.dispose(),Xe?.dispose(),Ze?.dispose(),dt?.dispose(),kn.dispose(),q.current=null,re.current=null}},[e.id]),v.useEffect(()=>{const T=ve.current(e.id),J=nA(T,Yl);return ne.current=J.send,Nt(J.status),J.status==="connected"&&$e(),J.snapshot&&(he.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),q.current&&($e(),Jn(J.output,J.history),$e())),()=>{as(J.send,{updateUi:!1}),J.detach(),ne.current=null}},[e.id,e.status]);function Yl(T){if(T.type==="status"){Nt(T.status),T.status==="unauthorized"&&U.current?.({source:"terminal-ws-1008",terminalId:e.id}),T.status==="connected"&&$e();return}Ua(T.message)}function ts(T=[],J=null){de.current=[],me.current=Zu(T),ge.current=0,Se.current=!1,Ee.current=null,Re.current=!1,De.current+=1,Ke.current=J,se.current=null,pe.current=!1,Le.current=!1,be.current=!1,at.current=!1,bt.current=null,Pe.current=null,ie.current=!1,F(!1),st(null),wi(!1),St(null),qt(!1),Ci(!1)}function Jn(T=[],J=null){ts(T,J),$s()}function $s(){if(!q.current||!je.current){at.current=!0;return}at.current=!1,er()}async function er(){const T=q.current;if(!T)return;const J=Qu(T,ie.current),We=J?me.current.length:ge.current;await tr(T,{liveOutputLimit:We,scrollToBottom:J}),q.current===T&>()}function tr(T,J={}){return new Promise(We=>{Re.current=!0,Se.current=!1;const Xe=De.current+1;De.current=Xe;const Ze=Math.max(0,Math.min(J.liveOutputLimit??me.current.length,me.current.length)),dt=J.historyPages??de.current,ii=()=>{if(q.current!==T||De.current!==Xe){We(!1);return}try{ge.current=Ze,J.scrollToBottom&&qi(T)}finally{Re.current=!1;const Qt=Xs();Qt?en(Qt):J.applyDeferredSnapshot!==!1&&Qs(),We(!0)}},nn=()=>{if(q.current!==T||De.current!==Xe){We(!1);return}T.clear();const Qt=Zu([...dt,...me.current.slice(0,Ze)]);if(Qt.length===0){ii();return}for(let ki=0;ki<Qt.length;ki+=1){const ta=Qt[ki];ki===Qt.length-1?T.write(ta,ii):T.write(ta)}};if(T.buffer.active.type==="alternate"){T.write(Ym,nn);return}nn()})}async function jn(T=0){const J=q.current;if(be.current||!J)return;if(Gs(J)){gt();return}const We=Ke.current;be.current=!0,F(!0);const Xe=J.buffer.active.viewportY;try{let Ze=!!(We&&!We.hasMore);if(!Ze)try{const dt=await t.getTerminalHistory(e.id,{beforeLine:We?.startLine??0,limit:_A}),ii={startLine:dt.startLine,endLine:dt.endLine,hasMore:dt.hasMore};if(dt.output.length>0){await It(J,dt.output,Xe,T)&&(Ke.current=ii);return}Ke.current=ii,Ze=!dt.hasMore}catch(dt){Ze=Rp(dt)}if(Ze){if(Gs(J)){gt();return}await ir(J,Xe,T)}}catch{}finally{be.current=!1,F(!1)}}async function ir(T,J,We){if(!(pe.current||Le.current))try{const Xe=se.current,Ze=await t.getTerminalTranscriptHistory(e.id,{...Xe?{cursor:Xe}:{},limit:yA}),dt=Ze.output.map(tC);if(!Ze.source)return;if(dt.length===0){Zt(Ze.source),se.current=Ze.cursor,Le.current=!Ze.hasMore||!Ze.cursor;return}await It(T,dt,J,We)&&(Zt(Ze.source),se.current=Ze.cursor,Le.current=!Ze.hasMore||!Ze.cursor)}catch(Xe){Rp(Xe)&&(pe.current=!0)}}async function It(T,J,We,Xe){if(Gs(T))return gt(),!1;const Ze=[...J,...de.current],dt=s3(J);return!await tr(T,{liveOutputLimit:ge.current,scrollToBottom:!1,historyPages:Ze,applyDeferredSnapshot:!1})||q.current!==T?!1:(de.current=Ze,Js(T,Math.max(0,We+dt+Math.min(0,Xe))),ie.current=!cr(T),mr(),!0)}v.useEffect(()=>{const T=window.visualViewport;function J(){document.visibilityState==="visible"&&$e()}function We(){$e()}function Xe(){Pn()}function Ze(){Wa()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",We),window.addEventListener("resize",Xe),window.addEventListener(Mh,Ze),T?.addEventListener("resize",Xe),T?.addEventListener("scroll",Xe),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",We),window.removeEventListener("resize",Xe),window.removeEventListener(Mh,Ze),T?.removeEventListener("resize",Xe),T?.removeEventListener("scroll",Xe)}},[e.id]);function Ia(){const T=ve.current(e.id);Me.current=!0,bt.current=null,Nt("reconnecting"),$e(),rA(T,{preserveCachedOutputOnNextSnapshot:!0})}function Ua(T){if(T.type==="snapshot"&&T.terminal.id===e.id){he.current.onSnapshot(T.terminal,{notifyCompletion:!1});const We=q.current;if(!We)return;$e();const Xe=Me.current;if(Me.current=!1,Xe){Ke.current=T.history??Ke.current,gt(),$e();return}if($a(We,T.terminal)){gr(T.output,T.history??null),gt(),$e();return}Jn(T.output,T.history??null),$e();return}if(T.type==="terminal_updated"&&T.terminal.id===e.id){he.current.onSnapshot(T.terminal,{notifyCompletion:!0});return}if(T.type==="output"&&T.terminalId===e.id){const We=rC(T.data);if(!We)return;me.current.push(We),q.current&&je.current?en({scrollToBottom:!0}):at.current=!0;return}const J=q.current;if(J){if(T.type==="exit"&&T.terminalId===e.id){he.current.onExit(T.exitCode),Nt("closed");return}T.type==="error"&&J.writeln(`\r
|
|
33
|
+
[nterminal] ${T.message}`)}}function nr(T=25){if(document.visibilityState==="hidden"||!xt.current||ae.current.has(T))return;const J=window.setTimeout(()=>{ae.current.delete(T),!Ka()&&Ya()},T);ae.current.set(T,J)}function Pn(){Ka()||ns()}function Ka(){const T=fr();return T&&Fa(T)?(j.current=!0,H.current=T,!0):T&&Xl(T)?(j.current=!1,H.current=null,!0):((!T||!T.composeOpen&&!T.keyboardVisible)&&(j.current=!1,H.current=null),!1)}function Wa(){if(!j.current)return;const T=fr();T&&(T.composeOpen||T.keyboardVisible)||(j.current=!1,H.current=null)}function Fa(T){if(!T.mobileLike||!T.composeOpen&&!T.keyboardVisible)return!1;const J=W.current;return J?Ji(T.windowWidth,J.windowWidth)&&Ji(T.visualViewportWidth,J.visualViewportWidth)&&Ji(T.containerWidth,J.containerWidth):!1}function Xl(T){if(!T.mobileLike||T.composeOpen||T.keyboardVisible)return!1;const J=H.current;return!J||!J.composeOpen&&!J.keyboardVisible?!1:Ji(T.windowWidth,J.windowWidth)&&Ji(T.visualViewportWidth,J.visualViewportWidth)&&Ji(T.containerWidth,J.containerWidth)}function fr(){const T=P.current;if(!T||T.isConnected===!1)return null;const J=T.getBoundingClientRect(),We=xi(window.innerWidth)??0,Xe=xi(window.visualViewport?.width)??We,Ze=xi(J.width)??xi(T.clientWidth)??We;if(We<=0||Xe<=0||Ze<=0)return null;const{keyboardVisible:dt}=Vm(),ii=document.documentElement.hasAttribute(Yh),nn=is()||dt;return{windowWidth:We,visualViewportWidth:Xe,containerWidth:Ze,composeOpen:ii,keyboardVisible:dt,mobileLike:nn}}function is(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function an(){return Vm().keyboardVisible?!0:typeof window.matchMedia=="function"?window.matchMedia("(hover: none) and (pointer: coarse)").matches:navigator.maxTouchPoints>0}function xi(T){return typeof T=="number"&&Number.isFinite(T)&&T>0?T:null}function Ji(T,J){return Math.abs(T-J)<=mA}function ns(){for(const T of pA)nr(T)}function $e(){K.current=null,ns()}function Mr(){for(const T of ae.current.values())window.clearTimeout(T);ae.current.clear()}function pr(){for(const T of R.current)window.clearTimeout(T);R.current=[]}function mr(){if(gt(),!Pe.current){wi(!1);return}wi(!0),Ys(),ze.current=window.setTimeout(()=>{ze.current=null,wi(!1)},1200)}function gt(){const T=q.current,J=T?a3(T):null;if(Pe.current=J,st(J),Ci(!!(T&&J)),qt(!!(T&&J&&!cr(T))),J||!T||!Vs()){St(null);return}St({alternate:T.buffer.active.type==="alternate"})}function Vs(){const T=Ke.current;return de.current.length>0||!!T?.hasMore}function Ys(){ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null)}function Nr(){const T=q.current;T&&(ie.current=!cr(T),gt())}function rr(T){Ee.current=Mp(Ee.current,T)}function qa(T){const J=Ee.current;return Ee.current=null,Mp(J,T)}function Xs(){const T=Ee.current;return Ee.current=null,T}function en(T={}){const J=q.current;if(!J||!je.current){at.current=!0;return}if(Re.current){rr(T);return}if(Se.current){rr(T);return}const We=qa(T);if(!We.force&&!Qu(J,ie.current)){gt();return}Se.current=!0;const Xe=De.current,Ze=()=>{if(q.current!==J||De.current!==Xe){Se.current=!1;return}if(!We.force&&!Qu(J,ie.current)){Se.current=!1,gt();return}const dt=ge.current,ii=me.current[dt];if(ii===void 0){Se.current=!1,We.scrollToBottom&&qi(J),gt();const nn=Xs();nn?en(Mp(We,nn)):Qs();return}J.write(ii,()=>{if(q.current!==J||De.current!==Xe){Se.current=!1;return}ge.current=dt+1,Ze()})};Ze()}function Gs(T){return!cr(T)&&(Zs()||Se.current||Re.current)}function $a(T,J){return(Pt.current||tc(J?.currentCommand))&&!cr(T)}function Zs(){return ge.current<me.current.length}function gr(T,J){bt.current={output:T,history:J,appendFromLiveOutputIndex:ge.current}}function Qs(){const T=q.current,J=bt.current;if(!T||!J||!cr(T)||Zs()||Se.current||Re.current)return;const We=Zu(J.output),Xe=Zu(me.current.slice(J.appendFromLiveOutputIndex));bt.current=null,Jn(r3(We,Xe),J.history),$e()}function dn(){Be.current=!0}function xn(){Nr(),Be.current=!1;const T=q.current;T&&cr(T)&&en({scrollToBottom:!0})}function qi(T){rs(()=>O0(T))&&(ie.current=!1)}function Js(T,J){rs(()=>(T.scrollToLine(J),!0))}function rs(T){ke.current=!0;try{return T()}finally{ke.current=!1}}function _r(){const T=q.current;if(!T)return;const J=()=>{Te.current&&(k(ne.current),zt(!1)),O0(T),ie.current=!1,gt(),en({force:!0,scrollToBottom:!0}),He("scroll-action")};if(T.buffer.active.type==="alternate"){T.write(Ym,J);return}J()}function sr(T){const J=q.current,We=P.current;if(!J||!We)return;const Xe=We.getBoundingClientRect();if(Xe.height<=0)return;const Ze=Math.max(0,Math.min(1,(T-Xe.top)/Xe.height)),dt=Math.round(J.buffer.active.baseY*Ze);dn();try{J.scrollToLine(dt)}finally{xn()}ie.current=!cr(J),gt(),mr(),dt<=3&&jn()}function Va(T){T.preventDefault(),T.stopPropagation(),T.currentTarget.setPointerCapture?.(T.pointerId),sr(T.clientY)}function ea(T){(T.buttons&1)!==0&&(T.preventDefault(),T.stopPropagation(),sr(T.clientY))}function Ya(){const T=q.current,J=re.current;if(!(!T||!J)&&!(document.visibilityState==="hidden"||!xt.current||P.current?.isConnected===!1))try{const We=Qu(T,ie.current),Xe=fr();J.fit(),Xe&&(W.current=Xe),We&&qi(T),T.refresh(0,Math.max(0,T.rows-1)),gt();const Ze={cols:T.cols,rows:T.rows},dt=K.current;if(dt&&dt.cols===Ze.cols&&dt.rows===Ze.rows)return;fn({type:"resize",terminalId:e.id,cols:Ze.cols,rows:Ze.rows})&&(K.current=Ze)}catch{}}function fn(T){const J=ne.current;return J?J(T):!1}function tn(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function ss(){tn();const T=Math.max(-Gu,Math.min(Gu,Z.current));if(Z.current=0,T===0)return!1;const J=fn({type:"scrollback_scroll",terminalId:e.id,lines:T});return J&&(Ce.current=!0,T<0&&zt(!0)),J}function $i(T){if(!Te.current||T===0)return;const J=Z.current+T;Z.current=Math.max(-Gu,Math.min(Gu,J)),X.current===null&&(X.current=window.setTimeout(()=>{X.current=null,ss()},AA))}function ln(){k(ne.current)}function as(T=ne.current,J={}){const We=Ce.current;tn(),Z.current=0,Ce.current=!1,J.updateUi!==!1&&zt(!1),We&&T?.({type:"cancel_scrollback",terminalId:e.id})}function k(T){tn(),Z.current=0,Ce.current=!1,zt(!1),T?.({type:"cancel_scrollback",terminalId:e.id})}function E(){if(!M.current)return;const T=!Te.current;Li(aT(e.id,T)),z()}function z(){const T=q.current;T&&(qi(T),gt())}function te(T){ss();const J=Ce.current;Ce.current=!1,J&&zt(!1),en({force:!0,scrollToBottom:!0}),fn({type:"input",terminalId:e.id,data:T,...J?{cancelScrollbackMode:!0}:{}})&&JA(T)&&we()}function ye(T){const J=b0(T,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&te(J)}function oe(T,J){const We=b0(T,{bracketedPasteMode:q.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});We&&te(We),window.setTimeout(()=>te(NN(J)),G1)}function we(){!ti.current||!Ve.current||(pr(),R.current=gA.map(T=>{const J=window.setTimeout(()=>{R.current=R.current.filter(We=>We!==J),ti.current&&Ve.current&&fn({type:"refresh_cwd",terminalId:e.id})},T);return J}))}function He(T="terminal-interaction"){Fe.current||an()&&(T==="auto"||T==="scroll-action")||q.current?.focus()}const it=v.useCallback(()=>{Qi(!1)},[]);function fi(){Ht(T=>{const J=!T;return Xt.current=J,J}),He("input-action")}function jt(T){Xt.current=T,Ht(T)}function ls(T){Xt.current&&jt(!1),te(pN(T)),He("input-action")}return m.jsxs("section",{className:"terminal-pane","data-active":r,"data-tmux-scrollback":ci?"true":"false",onMouseDown:()=>{r||p()},children:[m.jsx(jA,{terminal:e,canClose:l,tabId:h,transcriptSource:Et,transcriptShortcutLabel:B,scrollbackShortcutLabel:Y,tmuxScrollbackSupported:$t,tmuxScrollbackEnabled:ci,onToggleTmuxScrollback:E,onOpenTranscript:()=>Qi(!0),onReload:Ia,onClose:g}),m.jsx("div",{className:"xterm-container",ref:P}),Ft?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,x&&!ci&&Ue?m.jsxs("div",{className:"terminal-scroll-progress","data-active":Si,"aria-hidden":"true",children:[Ue.current,"/",Ue.total]}):x&&!ci&&Ai?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":Ai.alternate?"alternate":"normal","aria-hidden":"true",children:[Ai.alternate?"alt ":"","0/?"]}):null,At||ci&&li?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:T=>T.stopPropagation(),onMouseDown:T=>T.stopPropagation(),onClick:T=>{T.stopPropagation(),_r()},children:"↓"}):null,Gt&&!ci?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Va,onPointerMove:ea,children:m.jsx("span",{"aria-hidden":"true"})}):null,r&&e.status==="running"?Rr?m.jsx(dN,{ctrlActive:Wi,onCtrl:fi,onStandaloneKey:ls,onPreserveFocus:()=>He("input-action"),onHide:()=>Ha(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:T=>{T.stopPropagation(),He("input-action")},onPointerDown:T=>{T.stopPropagation(),He("input-action")},onClick:()=>Ha(!0),children:"⌨"}):null,m.jsx(jN,{terminalId:e.id,onSubmit:oe,queueAvailable:Et?.provider==="codex"||eC(e.currentCommand),disabled:e.status!=="running"}),oi&&Et?m.jsx(PA,{terminalId:e.id,serverApi:t,source:Et,fontSize:S,onClose:it}):null]})}function R0(e){return Ik(e)}function BA(e,t,r){const s=OA(e,t),l=M0(s*Math.max(1,r),DA,RA);return{limit:M0(Math.ceil(l/kA),EA,TA),maxLines:l}}function OA(e,t){const r=e?.clientHeight??0;if(r<=0)return CA;const s=Math.max(10,t*xA);return Math.max(1,Math.floor(r/s))}function M0(e,t,r){return Math.max(t,Math.min(r,Math.floor(e)))}function zA(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function jA({terminal:e,canClose:t,tabId:r,transcriptSource:s,transcriptShortcutLabel:l,scrollbackShortcutLabel:c,tmuxScrollbackSupported:h,tmuxScrollbackEnabled:p,onToggleTmuxScrollback:g,onOpenTranscript:f,onReload:y,onClose:b}){const S=yw({id:`pane-${e.id}`,disabled:!r,...r?{data:{kind:"pane",sourceTabId:r,terminalId:e.id}}:{}}),w={cursor:r?"grab":"default",opacity:S.isDragging?.5:void 0};return m.jsxs("header",{ref:S.setNodeRef,className:"terminal-pane-header",style:w,"data-dragging":S.isDragging,...S.attributes,...S.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),s?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":s.provider,title:`View ${Nh(s.provider)} transcript history`,"aria-label":`View ${Nh(s.provider)} transcript history`,onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),f()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:l})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),h&&e.status==="running"?m.jsxs("button",{type:"button",className:"terminal-pane-scrollback","data-active":p?"true":"false","aria-pressed":p,"aria-label":`Toggle tmux scrollback (${c})`,title:p?`Scroll input uses tmux scrollback (${c}). Input exits scrollback mode.`:`Scroll input uses NTerminal scrollback (${c}).`,onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),g()},children:[p?m.jsxs("svg",{"data-scrollback-icon":"tmux",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v2.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),m.jsx("path",{d:"M6.2 7.15 8 5.35l1.8 1.8M6.2 9.25 8 11.05l1.8-1.8",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]}):m.jsxs("svg",{"data-scrollback-icon":"nterminal",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[m.jsx("path",{d:"M8 1.75c-2.2 0-4 1.8-4 4v4.5c0 2.2 1.8 4 4 4s4-1.8 4-4v-4.5c0-2.2-1.8-4-4-4Zm0 1.25v3.25",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),m.jsx("path",{d:"M5.5 7.7h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.75"})]}),m.jsx("kbd",{children:c})]}):null,e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),y()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:x=>x.stopPropagation(),onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),b()},children:"x"}):null]})}const PA=Mi.memo(function({terminalId:t,serverApi:r,source:s,fontSize:l,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),y=v.useRef(null),b=v.useRef(""),S=v.useRef(null),w=v.useRef(null),[x,D]=v.useState([]),[L,A]=v.useState(!1),[B,Y]=v.useState(""),[P,q]=v.useState(-1),[re,ne]=v.useState(!1),[he,ve]=v.useState(-1),[U,K]=v.useState(null),[W,H]=v.useState(null),[j,ae]=v.useState(!1),[R,X]=v.useState(!0),[Z,Ce]=v.useState(!1),[Te,M]=v.useState(null);v.useEffect(()=>{function _e(Fe){Fe.key==="Escape"&&(Fe.preventDefault(),Fe.stopPropagation(),c())}return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[c]),v.useEffect(()=>{p.current+=1;const _e=p.current;return g.current=!1,f.current=!0,y.current=null,S.current=null,w.current=null,D([]),H(null),ae(!1),M(null),q(-1),ve(-1),K(null),Be(null,"initial",_e),()=>{p.current===_e&&(p.current+=1)}},[r,L,s.provider,s.sessionId,t]),v.useLayoutEffect(()=>{const _e=h.current;if(!_e)return;if(f.current){if(R||x.length===0)return;f.current=!1;const Je=()=>{_e.scrollTop=_e.scrollHeight};Je(),window.requestAnimationFrame?.(Je);return}const Fe=y.current;Fe!==null&&(y.current=null,_e.scrollTop+=_e.scrollHeight-Fe)},[x,R,L]);const Q=Nh(s.provider),de=L0(x,L),me=UA(de),ge=qA(me),Se=ge.map(_e=>_e.key).join(""),Ee=U?ge.find(_e=>_e.key===U)?.entryIndex??null:null,De=B.trim().length>0,Ke=FA(me,B),se=Ke.length,pe=se>0?P>=0&&P<se?P:0:-1,Le=pe>=0?Ke[pe]?.entryIndex??null:null,be=pe>=0?Ke[pe]??null:null,Me=De?Le:Ee,Pe=De?Le===null?null:"search":Ee===null?null:"prompt",ze=de?de.split(`
|
|
34
|
+
`).length-1:0,ie=ge.length>0&&he>=0&&he<ge.length?he:ge.length-1,ke=U??(ie>=0?ge[ie]?.key??null:null),Re=De?se>0?`${pe+1}/${se} ${se===1?"match":"matches"} · ${ze} ${ze===1?"line":"lines"}`:`0 matches · ${ze} ${ze===1?"line":"lines"}`:ge.length>0?`${ie+1}/${ge.length} prompts · ${ze} ${ze===1?"line":"lines"}`:`0 prompts · ${ze} ${ze===1?"line":"lines"}`;v.useEffect(()=>{const _e=B.trim().toLowerCase();q(Fe=>!_e||se===0?-1:b.current!==_e?0:Fe>=0&&Fe<se?Fe:0),b.current=_e},[B,se]),v.useEffect(()=>{if(De){K(null);return}U&&!ge.some(_e=>_e.key===U)&&K(null),ve(_e=>{if(ge.length===0)return w.current=null,-1;const Fe=w.current?ge.findIndex(ct=>ct.key===w.current):-1,Je=Fe>=0?Fe:_e>=0&&_e<ge.length?_e:ge.length-1;return w.current=ge[Je]?.key??null,Je})},[U,De,Se]),v.useEffect(()=>{const _e=S.current;if(!_e||ge.length===0)return;S.current=null;const Fe=_e.anchorKey?ge.findIndex(ct=>ct.key===_e.anchorKey):-1,Je=Fe>0?Fe-1:0;xt(Je)},[Se]);async function Be(_e,Fe,Je=p.current){if(!g.current){g.current=!0,Fe==="initial"?X(!0):(Ce(!0),y.current=h.current?.scrollHeight??null),M(null);try{await je(_e,Fe,Je)}catch(ct){if(p.current!==Je)return;M(ct instanceof Error?ct.message:"Failed to load transcript history.")}finally{p.current===Je&&(g.current=!1,X(!1),Ce(!1))}}}async function je(_e,Fe,Je){let ct=_e,Pt=0,bt=[];const Nt=Fe==="initial"&&s.provider!=="claude"?NA:MA;for(;p.current===Je;){const Ft=await r.getTerminalTranscriptHistory(t,{...ct?{cursor:ct}:{},...BA(h.current,l,Fe==="initial"?SA:wA),includeTools:L});if(p.current!==Je)return;const F=A0(Ft.output,s.provider,{includeTools:L}),Ue=at(Ft,Fe,bt,F);if(F&&(bt=[F,...bt],Ue))return;if(!Ft.hasMore||!Ft.cursor||Pt>=Nt){bt.length>0&&D(st=>Fe==="older"?[...bt,...st]:bt);return}ct=Ft.cursor,Pt+=1}}function at(_e,Fe,Je,ct=A0(_e.output,s.provider,{includeTools:L})){if(H(_e.cursor),ae(!!(_e.hasMore&&_e.cursor)),!ct)return!1;const Pt=[ct,...Je];return L0(Pt,L)?(D(bt=>Fe==="older"?[...Pt,...bt]:Pt),!0):!1}function Xt(){const _e=h.current;_e&&(kt(),!(_e.scrollTop>72||!j||!W||g.current)&&Be(W,"older"))}function Ve(_e){se!==0&&q(Fe=>{const Je=pe>=0?pe:_e>0?-1:0;return((Fe>=0&&Fe<se?Fe:Je)+_e+se)%se})}function xt(_e){const Fe=ge[_e];Fe&&(w.current=Fe.key,ve(_e),K(Fe.key))}async function ti(_e){if(ge.length===0){_e<0&&j&&W&&!g.current&&(S.current={anchorKey:null},await Be(W,"older"));return}const Je=(he>=0&&he<ge.length?he:_e<0?ge.length-1:-1)+_e;if(Je>=0&&Je<ge.length){xt(Je);return}_e<0&&Je<0&&j&&W&&!g.current&&(S.current={anchorKey:ge[0]?.key??null},await Be(W,"older"))}function kt(){if(De)return;const _e=h.current;if(!_e)return;const Je=_e.getBoundingClientRect().top+Math.min(140,Math.max(48,_e.clientHeight*.28));let ct=null;for(const Pt of GA(_e)){const bt=ZA(Pt);if(bt!==null)if(Pt.getBoundingClientRect().top<=Je)ct=bt;else break}if(ct!==null){const Pt=ge[ct]?.key??null;w.current=Pt,ve(ct),U&&U!==Pt&&K(null)}}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>_e.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[Q," JSONL"]}),m.jsx("span",{title:s.sessionId,children:s.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:L,onChange:_e=>A(_e.currentTarget.checked)}),"Show tool output"]}),m.jsx("label",{className:"transcript-search",children:m.jsx("input",{type:"search",value:B,"aria-label":"Search JSONL transcript",placeholder:"Search history",onChange:_e=>Y(_e.currentTarget.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),De?Ve(_e.shiftKey?-1:1):ti(_e.shiftKey?-1:1))}})}),m.jsx("button",{type:"button",className:"transcript-prompts-toggle","aria-pressed":re,"aria-label":"Toggle prompt list",onClick:()=>ne(_e=>!_e),disabled:ge.length===0,children:"List"}),m.jsxs("div",{className:"transcript-search-actions","aria-label":De?"Search result navigation":"Prompt navigation",children:[m.jsx("button",{type:"button",onClick:()=>De?Ve(-1):void ti(-1),disabled:De?se===0:ge.length===0&&!j,"aria-label":De?"Previous search match":"Previous user prompt",title:De?"Previous search match":"Previous user prompt",children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>De?Ve(1):void ti(1),disabled:De?se===0:ge.length===0,"aria-label":De?"Next search match":"Next user prompt",title:De?"Next search match":"Next user prompt",children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:Re})]}),re?m.jsx("div",{className:"transcript-prompt-index","aria-label":"User prompts",children:ge.length>0?ge.map((_e,Fe)=>m.jsxs("button",{type:"button",className:ke===_e.key?"transcript-prompt-index-item transcript-prompt-index-item-active":"transcript-prompt-index-item",onClick:()=>xt(Fe),children:[m.jsx("span",{children:_e.timestampLabel}),m.jsx("strong",{children:_e.snippet})]},`${_e.key}:${Fe}`)):m.jsx("span",{className:"transcript-prompt-index-empty",children:"No user prompts loaded."})}):null,m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Xt,children:[Z?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!R&&j?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,de?m.jsx(HA,{entries:me,searchQuery:B,activeEntryIndex:Me,activeEntryMode:Pe,activeSearchMatch:be,fontSize:l}):null,R?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!R&&!de&&!Te?j&&W?m.jsxs("div",{className:"transcript-dialog-status",children:[L?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{Be(W,"older")},disabled:Z,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,Te?m.jsx("div",{className:"transcript-dialog-error",children:Te}):null]})]})})});function HA({entries:e,searchQuery:t,activeEntryIndex:r,activeEntryMode:s,activeSearchMatch:l,fontSize:c}){const h=v.useRef(new Map);v.useEffect(()=>{if(r===null)return;const g=h.current.get(r);if(!g||typeof g.scrollIntoView!="function")return;if(s==="prompt"){g.scrollIntoView({block:"start",inline:"nearest"});return}const f=g.querySelectorAll(".transcript-search-hit");((l?.entryIndex===r?f[l.matchIndexInEntry]:null)??g).scrollIntoView({block:"center",inline:"nearest"})},[r,s,l,t]);let p=-1;return m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:c},children:e.map((g,f)=>{const y=g.kind==="user"?++p:null,b=r===f?s==="prompt"?" transcript-entry-prompt-active":" transcript-entry-search-active":"";return m.jsxs("section",{ref:S=>{S?h.current.set(f,S):h.current.delete(f)},className:`transcript-entry transcript-entry-${g.kind}${b}`,"data-transcript-kind":g.kind,"data-transcript-entry-index":f,...y!==null?{"data-transcript-prompt-position":y}:{},children:[g.header?m.jsx("div",{className:"transcript-entry-header",children:J1(g.header,t)}):null,g.body?m.jsx("div",{className:"transcript-entry-body",children:g.kind==="tool"?m.jsx(N0,{text:g.body,searchQuery:t}):m.jsx(Mi.Suspense,{fallback:m.jsx(N0,{text:g.body,searchQuery:t}),children:m.jsx(LA,{text:g.body,searchQuery:t})})}):null]},`${g.header??"plain"}-${f}`)})})}function N0({text:e,searchQuery:t}){const r=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1).split(`
|
|
36
|
+
`):e.split(`
|
|
37
|
+
`);return m.jsx("pre",{className:"transcript-entry-pre",children:r.map((s,l)=>m.jsx("span",{className:`transcript-line transcript-line-${QA(s,l===0||r[l-1]?.trim()==="")}`,children:J1(s,t)},l))})}function J1(e,t){const r=t.trim();if(!r)return e||" ";const s=e.toLowerCase(),l=r.toLowerCase(),c=[];let h=0,p=s.indexOf(l);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+r.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=s.indexOf(l,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function IA(e,t){const r=t.trim().toLowerCase();if(!r)return 0;const s=e.toLowerCase();let l=0,c=s.indexOf(r);for(;c!==-1;)l+=1,c=s.indexOf(r,c+r.length);return l}function UA(e){const t=e.endsWith(`
|
|
38
|
+
`)?e.slice(0,-1):e;if(!t)return[];const r=[];let s=null,l="plain",c=[];function h(){const p=KA(c).join(`
|
|
39
|
+
`);(s||p)&&r.push({header:s,body:p,kind:l}),s=null,l="plain",c=[]}for(const p of t.split(`
|
|
40
|
+
`)){const g=WA(p);g?(h(),s=p,l=g):c.push(p)}return h(),r}function KA(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function WA(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const r=t[1]??"";return r==="User"?"user":r==="Codex"||r==="Claude"?"assistant":r==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(r)?"tool":null}function FA(e,t){const r=[];for(let s=0;s<e.length;s+=1){const l=e[s];if(!l)continue;const c=l.header?`${l.header}
|
|
41
|
+
${l.body}`:l.body,h=IA(c,t);for(let p=0;p<h;p+=1)r.push({entryIndex:s,matchIndexInEntry:p})}return r}function qA(e){const t=[];for(let l=0;l<e.length;l+=1){const c=e[l];!c||c.kind!=="user"||t.push({contentKey:$A(c),entry:c,entryIndex:l})}const r=new Map,s=new Map;for(let l=t.length-1;l>=0;l-=1){const c=t[l];if(!c)continue;const h=r.get(c.contentKey)??0;r.set(c.contentKey,h+1),s.set(l,JSON.stringify([c.contentKey,h]))}return t.map((l,c)=>({entryIndex:l.entryIndex,key:s.get(c)??JSON.stringify([l.contentKey,0]),snippet:YA(l.entry.body),timestampLabel:XA(l.entry.header)}))}function $A(e){return JSON.stringify([e.header??"",e.body.length,VA(e.body)])}function VA(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function YA(e){return(e.replace(/```[\s\S]*?```/g,"[code]").replace(/\s+/g," ").trim()||"(empty prompt)").slice(0,240)}function XA(e){return e?/^\[([^\]]+)\]/.exec(e)?.[1]??"User":"User"}function GA(e){return Array.from(e.querySelectorAll('[data-transcript-kind="user"][data-transcript-prompt-position]'))}function ZA(e){const t=e.dataset.transcriptPromptPosition;if(t===void 0)return null;const r=Number(t);return Number.isInteger(r)&&r>=0?r:null}function QA(e,t){const r=e.trim();if(!r)return"blank";const s=r.replace(/^\[[^\]]+\]\s+/,""),l=/^\[[^\]]+\]\s+/.test(r);return(l||t)&&/^User$/.test(s)?"user":(l||t)&&/^(?:Codex|Claude)$/.test(s)?"assistant":(l||t)&&/^System$/.test(s)?"system":(l||t)&&(/^Tool (?:call(?::|$)|output$)/.test(s)||nC(r))?"tool":/^(?:\$|>|❯|➜)\s+/.test(r)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(r)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(r)?"error":/^\[[^\]]+\]/.test(r)||/^(?:info|debug|warn)\b/i.test(r)?"dim":"plain"}function JA(e){return e.includes("\r")||e.includes(`
|
|
42
|
+
`)}function Rp(e){return e instanceof ur&&e.status===404}function tc(e){return eC(e)||e3(e)}function eC(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function e3(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function t3(e){if(tc(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function Nh(e){return e==="codex"?"Codex":"Claude"}function A0(e,t,r={}){const s=`[nterminal] ${Nh(t)} transcript archive ends here. Live terminal screen continues below.`,l=e.join("").replace(/\r\n/g,`
|
|
43
|
+
`).replace(/\r/g,`
|
|
44
|
+
`).replace(s,"").replace(/\n{3,}/g,`
|
|
45
|
+
|
|
46
|
+
`).trimEnd(),c=tC(l),h=r.includeTools?c:iC(c);return h?`${h}
|
|
47
|
+
`:""}function tC(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,r)=>{const s=i3(r);return s?`[${s}]`:t})}function i3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const r=t.getFullYear(),s=Wo(t.getMonth()+1),l=Wo(t.getDate()),c=Wo(t.getHours()),h=Wo(t.getMinutes()),p=Wo(t.getSeconds());return`${r}-${s}-${l} ${c}:${h}:${p}`}function Wo(e){return e.toString().padStart(2,"0")}function L0(e,t){return e.map(r=>t?r:iC(r)).filter(Boolean).map(r=>r.endsWith(`
|
|
48
|
+
`)?r:`${r}
|
|
49
|
+
`).join("")}function iC(e){if(!e)return"";const t=e.split(`
|
|
50
|
+
`),r=[];let s=!1,l=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?n3(h):null;if(g&&(s=g==="tool",l=!1),nC(h)){l=!0,c=!1;continue}if(l){p?(l=!1,s||r.push(h),c=!0):c=!1;continue}s||r.push(h),c=p}return r.join(`
|
|
51
|
+
`).replace(/\n{3,}/g,`
|
|
52
|
+
|
|
53
|
+
`).trimEnd()}function n3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function nC(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function r3(e,t){if(t.length===0)return e;let r=0;const s=Math.min(e.length,t.length);for(let l=s;l>0;l-=1){let c=!0;for(let h=0;h<l;h+=1)if(e[e.length-l+h]!==t[h]){c=!1;break}if(c){r=l;break}}return[...e,...t.slice(r)]}function s3(e){let t=0;for(const r of e){if(!r)continue;const s=r.match(/\r\n|\r|\n/g);t+=s?.length??1}return Math.max(1,t)}function Zu(e){const t=[];for(const r of e){const s=rC(r);s&&t.push(s)}return t}function rC(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,r,s)=>{const l=r.split(";").filter(Boolean).filter(c=>!bA.has(c.split(":")[0]??""));return l.length>0?`\x1B[?${l.join(";")}${s}`:""})}function Mp(e,t={}){const r={};return(e?.force||t.force)&&(r.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(r.scrollToBottom=!0),r}function a3(e){const t=e.buffer.active,r=t.baseY+e.rows;return r<=e.rows?null:{current:Math.max(1,Math.min(r,t.viewportY+1)),total:r}}function B0(e,t){const r=e?.querySelector(".xterm .xterm-viewport");if(r){if(t){r.dataset.nterminalTmuxScrollHidden="true",r.style.setProperty("overflow-y","hidden","important"),r.style.setProperty("scrollbar-color","transparent transparent","important"),r.style.setProperty("scrollbar-width","none","important"),r.style.setProperty("-ms-overflow-style","none");return}r.dataset.nterminalTmuxScrollHidden==="true"&&(delete r.dataset.nterminalTmuxScrollHidden,r.style.removeProperty("overflow-y"),r.style.removeProperty("scrollbar-color"),r.style.removeProperty("scrollbar-width"),r.style.removeProperty("-ms-overflow-style"))}}function cr(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Qu(e,t){return!t||cr(e)}function O0(e){return cr(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function l3(e,t,r,s,l,c,h,p){const g=f=>{const y=c3(f);if(y!==0){if(h()){if(d3(t))return;f.cancelable&&f.preventDefault(),f.stopPropagation(),p(y);return}f.cancelable&&f.preventDefault(),f.stopPropagation(),o3(t,y,r,s,l,c)}};return e.addEventListener("wheel",g,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",g,{capture:!0})}}function o3(e,t,r,s,l,c){const h=()=>{l();try{e.scrollLines(t)}finally{c()}r(),t<0&&e.buffer.active.viewportY<=3&&s(t)};if(e.buffer.active.type==="alternate"){e.write(Ym,h);return}h()}function c3(e){const r=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(r===0)return 0;const s=r<0?Math.floor(r):Math.ceil(r);return Math.max(-30,Math.min(30,s))}function u3(e,t,r,s,l,c,h,p,g){let f=null,y=0;const b={passive:!1};function S(D){f=Np(D),y=0}function w(D){const L=Np(D);if(L===null){f=null,y=0;return}if(f===null){f=L;return}const A=L.clientY-f.clientY;if(f=L,D.cancelable&&D.preventDefault(),A===0)return;if(h3(t)&&f3(t,L,-A)){y=0;return}y-=A/r();const B=y<0?Math.ceil(y):Math.floor(y);if(B!==0){if(y-=B,p()){g(B);return}c();try{t.scrollLines(B)}finally{h()}s(),B<0&&t.buffer.active.viewportY<=3&&l(B)}}function x(D){if(D.touches.length>0){f=Np(D);return}f=null,y=0}return e.addEventListener("touchstart",S,b),e.addEventListener("touchmove",w,b),e.addEventListener("touchend",x),e.addEventListener("touchcancel",x),()=>{e.removeEventListener("touchstart",S,b),e.removeEventListener("touchmove",w,b),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}}function Np(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function h3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function d3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function f3(e,t,r){const s=e.element;return s?(s.dispatchEvent(p3(t,r)),!0):!1}function p3(e,t){const r=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,s={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:r};if(typeof WheelEvent=="function")return new WheelEvent("wheel",s);const l=new Event("wheel",s);return Object.defineProperties(l,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),l}function Xm({node:e,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:y=null,path:b=[],totalPanes:S,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,onAuthClose:Y}){const P=S??Gm(e);if(b.length===0&&y){const he=Zm(e),ve=he.some(U=>U.key===y)?y:he[0]?.key;if(he.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:he.map(U=>{const K=U.key===ve;if(U.type==="editor"){const H=r[U.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:H?m.jsx(bS,{api:s,editor:H,canClose:P>1,onClose:()=>B(U.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},U.key)}const W=t[U.terminalId];return W?m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx(D0,{terminal:W,serverApi:s,active:K,visible:c&&K,canClose:P>1,refreshCwdOnEnter:h&&K,tabId:p,onSelect:()=>w(U.terminalId),onClose:()=>x(U.terminalId),onExit:H=>L(U.terminalId,H),onSnapshot:A,...Y?{onAuthClose:Y}:{}})},U.key):m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},U.key)})})}if(e.type==="pane"){const he=t[e.terminalId];if(!he)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(D0,{terminal:he,serverApi:s,active:e.terminalId===l,visible:c,canClose:P>1,refreshCwdOnEnter:h&&e.terminalId===l,tabId:p,onSelect:()=>w(e.terminalId),onClose:()=>x(e.terminalId),onExit:K=>L(e.terminalId,K),onSnapshot:A,...Y?{onAuthClose:Y}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(Ju,{terminalId:e.terminalId,side:"top"}),m.jsx(Ju,{terminalId:e.terminalId,side:"right"}),m.jsx(Ju,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Ju,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const he=r[e.editorId];return he?m.jsx(bS,{api:s,editor:he,canClose:P>1,onClose:()=>B(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const q=Math.max(.1,Math.min(.9,e.ratio)),re=1-q,ne=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`}:{gridTemplateRows:`minmax(0, ${q}fr) 1px minmax(0, ${re}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ne,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Xm,{node:e.first,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:y,path:[...b,0],totalPanes:P,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,...Y?{onAuthClose:Y}:{}})}),m.jsx(m3,{direction:e.direction,path:b,onResize:D}),m.jsx("div",{className:"split-cell",children:m.jsx(Xm,{node:e.second,terminals:t,editors:r,api:s,activeTerminalId:l,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:y,path:[...b,1],totalPanes:P,onSelect:w,onClose:x,onResize:D,onExit:L,onSnapshot:A,onCloseEditor:B,...Y?{onAuthClose:Y}:{}})})]})}function Ju({terminalId:e,side:t}){const{setNodeRef:r,isOver:s}=xg({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:r,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":s,"aria-hidden":"true"})}function m3({direction:e,path:t,onResize:r}){function s(l){l.preventDefault(),l.stopPropagation();const c=l.currentTarget;c.setPointerCapture?.(l.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-p.left)/p.width:(y.clientY-p.top)/p.height;r(t,Math.min(.9,Math.max(.1,b)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",f),c.removeEventListener("lostpointercapture",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f),window.addEventListener("pointercancel",f),c.addEventListener("lostpointercapture",f)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:s,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Gm(e){return e.type==="pane"||e.type==="editor"?1:Gm(e.first)+Gm(e.second)}function Zm(e){return e.type==="pane"?[{key:g3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:_3(e.editorId),type:"editor",editorId:e.editorId}]:[...Zm(e.first),...Zm(e.second)]}function g3(e){return`terminal:${e}`}function _3(e){return`editor:${e}`}const Zh="workspace-default",v3="NTerminal";function b3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function y3(e,t){switch(t.type){case"workspace.hydrated":return Qm(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return S3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return k3(e,t.workspaceId);case"workspace.selected":return sC(e,t.workspaceId);case"workspace.renamed":return w3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return C3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return x3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return aC(e,t.terminal);case"terminal.split":return E3(e,t.terminal,t.direction);case"terminal.updated":return j3(e,t.terminal);case"terminal.exited":return P3(e,t.terminalId,t.exitCode);case"terminal.closed":return cC(e,t.terminalId);case"terminal.detached":return H3(e,t.terminalId,t.workspaceId);case"editor.split":return T3(e,t.editorId,t.title,t.direction);case"editor.closed":return I3(e,t.editorId);case"pane.selected":return O3(e,t.terminalId);case"pane.resized":return z3(e,t.path,t.ratio);case"tab.selected":return R3(e,t.tabId);case"tab.renamed":return B3(e,t.tabId,t.title);case"tab.reordered":return r_(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return M3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return lC(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return oC(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return N3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return D3(e);default:return e}}function S3(e,t){if(e.workspaces.some(s=>s.id===t.id))return sC(e,t.id);const r={id:t.id,title:t.title,defaultCwd:dr(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,r],activeWorkspaceId:r.id}}function sC(e,t){return e.workspaces.some(r=>r.id===t)?{...e,activeWorkspaceId:t}:e}function w3(e,t,r){const s=r.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===s?h:(l=!0,{...h,title:s}));return l?{...e,workspaces:c}:e}function C3(e,t,r){const s=dr(r);let l=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===s?h:(l=!0,{...h,defaultCwd:s}));return l?{...e,workspaces:c}:e}function x3(e,t,r,s){if(t===r)return e;const l=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===r);if(l<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(l,1);if(!p)return e;const g=h.findIndex(b=>b.id===r);if(g<0)return e;const f=s==="before"?g:g+1,y=h.slice();return y.splice(f,0,p),L3(e.workspaces,y)?e:{...e,workspaces:y}}function k3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const r=e.workspaces.find(p=>p.id===t),s=new Set(r?Ah(r):[]),l={...e.terminals};for(const p of s)delete l[p];const c=e.workspaces.filter(p=>p.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:l}}function aC(e,t){const r=hC(e),s=ja(r)??Jh(),l=gC(t);return{...r,activeWorkspaceId:s.id,terminals:{...r.terminals,[t.id]:t},workspaces:r.workspaces.map(c=>c.id===s.id?{...c,defaultCwd:c.defaultCwd??dr(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,l],activeTabId:l.id}:mC(c,t.id))}}function E3(e,t,r){const s=ja(e),l=s?Qh(s):void 0;if(!s||!l)return aC(e,t);const c=l.activeTerminalId,h=Sc(l.root,c,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(p=>p.id===s.id?{...p,defaultCwd:p.defaultCwd??dr(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===l.id?{...g,root:h,activeTerminalId:t.id}:g)}:mC(p,t.id))}}function T3(e,t,r,s){const l=ja(e),c=l?Qh(l):void 0;if(!l||!c)return e;const h=c.activeTerminalId,p=Sc(c.root,h,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:r}});return{...e,workspaces:e.workspaces.map(g=>g.id===l.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function D3(e){const t=ja(e),r=t?Qh(t):void 0;return r?cC(e,r.activeTerminalId):e}function R3(e,t){const r=ja(e);return!r||!r.tabs.some(s=>s.id===t)?e:{...e,workspaces:e.workspaces.map(s=>s.id===r.id?{...s,activeTabId:t}:s)}}function r_(e,t,r){const s=e.workspaces.map(l=>{const c=l.tabs.findIndex(y=>y.id===t);if(c<0)return l;const h=l.tabs.slice(),[p]=h.splice(c,1);if(!p)return l;const g=Math.max(0,Math.min(h.length,r)),f=h.slice();return f.splice(g,0,p),A3(l.tabs,f)?l:{...l,tabs:f}});return s.every((l,c)=>l===e.workspaces[c])?e:{...e,workspaces:s}}function M3(e,t,r,s,l){if(r===s||!e.terminals[r]||!e.terminals[s])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(x=>x.id===t);if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b=Hl(y.root,r);if(!b){const x=g.tabs.filter((D,L)=>L!==f);return{...g,tabs:x}}const S={...y,root:b,activeTerminalId:Ui(b)[0]??y.activeTerminalId},w=g.tabs.slice();return w[f]=S,{...g,tabs:w}});const h=l==="left"||l==="right"?"vertical":"horizontal",p=l==="left"||l==="top";return c=c.map(g=>{const f=g.tabs.findIndex(D=>Ui(D.root).includes(s));if(f<0)return g;const y=g.tabs[f];if(!y)return g;const b={type:"pane",terminalId:r},S={type:"split",direction:h,ratio:.5,first:p?b:{type:"pane",terminalId:s},second:p?{type:"pane",terminalId:s}:b},w=Sc(y.root,s,S),x=g.tabs.slice();return x[f]={...y,root:w,activeTerminalId:r},{...g,tabs:x,activeTabId:y.id}}),hC({...e,workspaces:c})}function lC(e,t,r,s){let l=-1,c=-1;for(let L=0;L<e.workspaces.length;L+=1){const A=e.workspaces[L].tabs.findIndex(B=>B.id===t);if(A>=0){l=L,c=A;break}}if(l<0)return e;const h=e.workspaces[l],p=h.tabs[c],g=Ui(p.root);if(!g.includes(r))return e;if(g.length===1)return r_(e,t,s);const f=Hl(p.root,r);if(!f)return e;const y={...p,root:f,activeTerminalId:Ui(f)[0]??p.activeTerminalId},b=e.terminals[r],S={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:b?.title??"",activeTerminalId:r,root:{type:"pane",terminalId:r}},w=h.tabs.slice();w[c]=y;const x=Math.max(0,Math.min(w.length,s));w.splice(x,0,S);const D=e.workspaces.slice();return D[l]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:D}}function oC(e,t,r,s=Number.MAX_SAFE_INTEGER){const l=dC(e.workspaces,t),c=e.workspaces.find(f=>f.id===r);if(!l||!c)return e;if(l.workspace.id===r)return s===Number.MAX_SAFE_INTEGER?e:r_(e,t,s);const h=Ui(l.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===l.workspace.id)return Pa({...f,tabs:f.tabs.filter(y=>y.id!==t)});if(f.id===r){const y=f.tabs.slice(),b=Math.max(0,Math.min(y.length,s));return y.splice(b,0,l.tab),{...f,defaultCwd:f.defaultCwd??dr(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:y,activeTabId:l.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:r}}function N3(e,t,r,s,l=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===s),h=dC(e.workspaces,t);if(!c||!h||!e.terminals[r]||!Ui(h.tab.root).includes(r))return e;if(h.workspace.id===s)return lC(e,t,r,l);if(Ui(h.tab.root).length===1)return oC(e,t,s,l);const g=Hl(h.tab.root,r);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Ui(g)[0]??h.tab.activeTerminalId},y=e.terminals[r],b={id:`tab-${Date.now().toString(36)}-${r.slice(0,8)}`,title:y.title??r,activeTerminalId:r,root:{type:"pane",terminalId:r}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return Pa({...w,tabs:w.tabs.map(x=>x.id===t?f:x)});if(w.id===s){const x=w.tabs.slice(),D=Math.max(0,Math.min(x.length,l));return x.splice(D,0,b),{...w,defaultCwd:w.defaultCwd??dr(y.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(L=>L!==r),tabs:x,activeTabId:b.id}}return w});return{...e,workspaces:S,activeWorkspaceId:s}}function A3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function L3(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]?.id!==t[r]?.id)return!1;return!0}function B3(e,t,r){const s=r.trim();if(!s)return e;let l=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===s?f:(l=!0,p=!0,{...f,title:s}));return p?{...h,tabs:g}:h});return l?{...e,workspaces:c}:e}function O3(e,t){const r=e.workspaces.find(l=>l.tabs.some(c=>Il(c.root,t))),s=r?.tabs.find(l=>Il(l.root,t));return!r||!s?e:{...e,activeWorkspaceId:r.id,workspaces:e.workspaces.map(l=>l.id===r.id?{...l,activeTabId:s.id,tabs:l.tabs.map(c=>c.id===s.id?{...c,activeTerminalId:t}:c)}:l)}}function z3(e,t,r){const s=ja(e),l=s?Qh(s):void 0;if(!s||!l)return e;const c=rg(l.root,t,bC(r));return c===l.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===s.id?{...h,tabs:h.tabs.map(p=>p.id===l.id?{...p,root:c}:p)}:h)}}function Qm(e,t,r,s){const l=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),h=new Set,p=!!(r&&r.some(b=>_C(b))||t&&t.some(b=>vC(b)));let g=U3(t,r,c,h);g.length===0&&(g=[Jh()]);const f=typeof s=="string"&&g.some(b=>b.id===s)?s:g[0]?.id??null,y=f??g[0]?.id??Zh;for(const b of e)if(!h.has(b.id)){if(p)g=F3(g,y,b.id,b);else{const S=gC(b);g=$3(g,y,S,b)}h.add(b.id)}return{workspaces:g.map(b=>Pa(q3(b,l))),activeWorkspaceId:f,terminals:l}}function yc(e){return Ui(e.root)}function Jm(e){return sg(e.root)}function Ah(e){return s_([...e.tabs.flatMap(t=>Ui(t.root)),...e.detachedTerminalIds])}function Ap(e){const t=e.workspaces.map(r=>{const s=r.tabs.flatMap(l=>{const c=ig(l.root);return c?[{...l,root:c}]:[]});return Pa({...r,tabs:s})});return{activeWorkspaceId:t.some(r=>r.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function j3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(r=>({...r,tabs:r.tabs.map(s=>Il(s.root,t.id)?{...s,title:s.title||t.title}:s)}))}}function P3(e,t,r){const s=e.terminals[t];return s?{...e,terminals:{...e.terminals,[t]:{...s,status:"exited",exitCode:r}}}:e}function cC(e,t){const r={...e.terminals};return delete r[t],uC(e,t,r)}function H3(e,t,r){if(!e.terminals[t])return e;const s=(r&&e.workspaces.some(c=>c.id===r)?r:null)??K3(e,t)?.id??W3(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Zh,l=e.workspaces.find(c=>c.id===s);return!l||!pC(l,t)?e:uC(e,t,{...e.terminals},{detachToWorkspaceId:s})}function uC(e,t,r,s={}){let l=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=Hl(g.root,t);if(!f)continue;const y=Ui(f),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&p.push({...g,root:f,activeTerminalId:b})}return Pa({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});s.detachToWorkspaceId&&r[t]&&(l=l.map(h=>h.id===s.detachToWorkspaceId?fC(h,t,r[t]):h));const c=l.some(h=>h.id===e.activeWorkspaceId);return{workspaces:l,activeWorkspaceId:c?e.activeWorkspaceId:l[0]?.id??null,terminals:r}}function I3(e,t){const r=e.workspaces.map(l=>{const c=[];for(const h of l.tabs){const p=eg(h.root,t);if(!p)continue;const g=Ui(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return Pa({...l,tabs:c})}),s=r.some(l=>l.id===e.activeWorkspaceId);return{...e,workspaces:r,activeWorkspaceId:s?e.activeWorkspaceId:r[0]?.id??null}}function U3(e,t,r,s){if(t&&t.length>0){const l=[];for(const c of t)_C(c)&&l.push(z0(c,r,s));if(l.length>0)return l}return[z0({...Jh(),tabs:e??[]},r,s)]}function z0(e,t,r){const s=[];for(const c of e.tabs){if(!vC(c))continue;const h=tg(c.root,t);if(!h)continue;const p=Ui(h);for(const f of p)r.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&s.push({...c,root:h,activeTerminalId:g})}const l=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||r.has(c)||(r.add(c),l.push(c));return Pa({...e,defaultCwd:dr(e.defaultCwd),detachedTerminalIds:l,tabs:s})}function hC(e){return ja(e)?e:{...e,workspaces:[Jh()],activeWorkspaceId:Zh}}function ja(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Qh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function dC(e,t){for(const r of e){const s=r.tabs.findIndex(l=>l.id===t);if(s>=0)return{workspace:r,tab:r.tabs[s],tabIndex:s}}return null}function K3(e,t){return e.workspaces.find(r=>r.tabs.some(s=>Il(s.root,t)))}function W3(e,t){return e.workspaces.find(r=>r.detachedTerminalIds.includes(t))}function F3(e,t,r,s){return e.map(l=>l.id===t?fC(l,r,s):l)}function fC(e,t,r){return pC(e,t)?{...e,defaultCwd:e.defaultCwd??dr(r?.cwd),detachedTerminalIds:s_([...e.detachedTerminalIds.filter(s=>s!==t),t])}:e}function pC(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Wl}function mC(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(r=>r!==t)}:e}function q3(e,t){if(e.defaultCwd)return e;const r=Ah(e).find(l=>!!t[l]),s=r?dr(t[r]?.cwd):null;return s?{...e,defaultCwd:s}:e}function Jh(){return{id:Zh,title:v3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Pa(e){const t=e.tabs.some(r=>r.id===e.activeTabId);return{...e,defaultCwd:dr(e.defaultCwd),detachedTerminalIds:s_(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function $3(e,t,r,s){const l=Ui(r.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??dr(s?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!l.includes(h)),tabs:[...c.tabs,r],activeTabId:c.activeTabId??r.id}:c)}function gC(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function Sc(e,t,r){return e.type==="pane"?e.terminalId===t?r:e:e.type==="editor"?e:{...e,first:Sc(e.first,t,r),second:Sc(e.second,t,r)}}function Hl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const r=Hl(e.first,t),s=Hl(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function eg(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const r=eg(e.first,t),s=eg(e.second,t);return r&&s?{...e,first:r,second:s}:r??s}function tg(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const r=tg(e.first,t),s=tg(e.second,t);return r&&s?{...e,ratio:bC(e.ratio),first:r,second:s}:r??s}function ig(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=ig(e.first),r=ig(e.second);return t&&r?{...e,first:t,second:r}:t??r}function _C(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 vC(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&ng(t.root)}function ng(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")&&ng(t.first)&&ng(t.second):!1}function rg(e,t,r){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===r?e:{...e,ratio:r};const[s,...l]=t;if(s===0){const c=rg(e.first,l,r);return c===e.first?e:{...e,first:c}}if(s===1){const c=rg(e.second,l,r);return c===e.second?e:{...e,second:c}}return e}function bC(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function dr(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function s_(e){const t=new Set,r=[];for(const s of e)!s||t.has(s)||(t.add(s),r.push(s));return r}function Il(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Il(e.first,t)||Il(e.second,t)}function Ui(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Ui(e.first),...Ui(e.second)]}function sg(e){return e.type==="pane"||e.type==="editor"?1:sg(e.first)+sg(e.second)}const qs=new Map,wc=new Map,Cc=new Map,xc=new Map;function $l(e){return e??"__local__"}function V3(e){return{agentId:e,state:b3(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Bt(e){const t=$l(e);let r=qs.get(t);return r||(r=V3(e),qs.set(t,r)),r}function yC(e,t){const r=$l(e);let s=wc.get(r);return s||(s=new Set,wc.set(r,s)),s.add(t),()=>{s.delete(t)}}function Y3(e){const t=$l(e),r=wc.get(t);if(r)for(const s of Array.from(r))s()}function Vl(e,t){qs.set($l(e),t),Y3(e)}const ag=new Set;function X3(e){return ag.add(e),()=>{ag.delete(e)}}function Fo(e,t){const r=Bt(e),s=$l(e);t.type==="workspace.hydrated"&&(Cc.delete(s),xc.delete(s));const l=y3(r.state,t);let c=r.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=r.state.terminals[t.terminal.id],y=i5(s),b=n5(s);if(t.notifyCompletion===!0&&t.terminal.agentStatus)t.terminal.agentStatus.state==="working"&&b.add(t.terminal.id),t.terminal.agentStatus.state==="done"&&b.has(t.terminal.id)&&(h=P0(l,t.terminal.id,f?.currentCommand??null),b.delete(t.terminal.id)),t.terminal.agentStatus.state==="idle"&&b.delete(t.terminal.id),y.delete(t.terminal.id);else{const S=f?.activity==="busy",w=t.terminal.activity==="busy",x=t.terminal.activity==="idle";t.notifyCompletion===!0&&w&&y.add(t.terminal.id),t.notifyCompletion===!0&&S&&x&&y.has(t.terminal.id)&&(h=P0(l,t.terminal.id,f?.currentCommand??null)),(x||t.terminal.status==="exited")&&y.delete(t.terminal.id)}if(h){const S=SC(l,t.terminal.id);S&&(S.workspace.activeTabId!==S.tab.id||S.workspace.id!==l.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id)))}t.terminal.status==="exited"&&(y.delete(t.terminal.id),b.delete(t.terminal.id))}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=G3(l,t.tabId)?.tab??null;else{const b=l.workspaces.find(S=>S.id===t.workspaceId);f=b?.tabs.find(S=>S.id===b.activeTabId)??null}const y=f?Ui(f.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const S of y)b.delete(S);c=b}}const p=l!==r.state,g=c!==r.unreadCompletions;if((p||g)&&Vl(e,{...r,state:l,unreadCompletions:c}),g&&a_(),h)for(const f of Array.from(ag))f({agentId:e,...h})}function SC(e,t){for(const r of e.workspaces)for(const s of r.tabs)if(Ui(s.root).includes(t))return{workspace:r,tab:s};return null}function G3(e,t){for(const r of e.workspaces){const s=r.tabs.find(l=>l.id===t);if(s)return{workspace:r,tab:s}}return null}const lg=new Set;function Z3(e){return lg.add(e),()=>{lg.delete(e)}}function Q3(){let e=0;for(const t of qs.values())e+=t.unreadCompletions.size;return e}function a_(){for(const e of Array.from(lg))e()}function J3(e,t){const r=Bt(e);if(!r.unreadCompletions.has(t))return;const s=new Set(r.unreadCompletions);s.delete(t),Vl(e,{...r,unreadCompletions:s}),a_()}function j0(e,t){const r=Bt(e);t!==r.state&&Vl(e,{...r,state:t})}function Lp(e,t){const r=Bt(e),s=t(r.editors);s!==r.editors&&Vl(e,{...r,editors:s})}function Ls(e,t,r){const s=Bt(e);s.loaded===t&&s.error===r||Vl(e,{...s,loaded:t,error:r})}function qo(e,t,r){const s=Bt(e);s.layoutRevision===t&&s.lastPersistedLayoutJson===r||Vl(e,{...s,layoutRevision:t,lastPersistedLayoutJson:r})}function e5(e){const t=Bt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function t5(e){const t=$l(e),r=qs.get(t);r&&r.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(r.mutable.saveCoord.saveTimer);const s=r?r.unreadCompletions.size>0:!1;qs.delete(t),wc.delete(t),Cc.delete(t),xc.delete(t),s&&a_()}function Bp(){for(const e of qs.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}qs.clear(),wc.clear(),Cc.clear(),xc.clear()}function i5(e){let t=Cc.get(e);return t||(t=new Set,Cc.set(e,t)),t}function n5(e){let t=xc.get(e);return t||(t=new Set,xc.set(e,t)),t}function P0(e,t,r){const s=SC(e,t);return s?{terminalId:t,tabId:s.tab.id,commandName:r}:null}function og(e,t){let r=!1,s=!1,l=null,c=!1;for(const h of yc(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,r=!0;continue}p.activity==="busy"?(s=!0,r=!0,!l&&p.currentCommand&&(l=p.currentCommand)):p.activity==="idle"&&(r=!0)}}return r?c?{state:"exited",commandName:null}:s?{state:"busy",commandName:l}:{state:"idle",commandName:null}:null}function l_(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function cg(e,t){const r=t[e.activeTerminalId];return e.title||r?.title||e.activeTerminalId}function r5(e,t,r,s){return s?.state==="busy"?s.commandName?`running: ${s.commandName}`:"running":s?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${r} pane${r===1?"":"s"}`}function s5({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:x}){const[D,L]=v.useState(null),[A,B]=v.useState(!1),[Y,P]=v.useState(null),q=v.useRef(null),re=e.findIndex(j=>j.id===t),ne=re>=0?e[re]:e[0]??null,he=ne?og(ne,r):null,ve=ne?Jm(ne):0,U=ne?cg(ne,r):"No tab";v.useEffect(()=>{q.current?.focus(),q.current?.select()},[D?.tabId]),v.useEffect(()=>{if(!A)return;const j=ae=>{ae.key==="Escape"&&B(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[A]),v.useEffect(()=>{A&&e.length===0&&B(!1)},[A,e.length]);function K(j,ae){L({tabId:j,title:ae})}function W(){if(!D)return;const j=D.title.trim();j&&w(D.tabId,j),L(null)}function H(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${dT()}`,onClick:b,disabled:!x,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${fT()}`,onClick:S,disabled:!x,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:p,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:U,onClick:()=>B(!0),disabled:e.length===0,children:[he?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":he.state,"aria-hidden":"true",title:l_(he)}):null,m.jsx("span",{children:U}),m.jsxs("small",{children:[re>=0?re+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,ae)=>{const R=yc(j),X=Jm(j),Z=cg(j,r),Ce=j.id===t,Te=D?.tabId===j.id,M=og(j,r),Q=s?.has(j.id)??!1;return m.jsxs(Mi.Fragment,{children:[m.jsx(H0,{index:ae}),m.jsx(a5,{tab:j,active:Ce,editing:Te,title:Z,paneCount:X,terminalIds:R,canClose:e.length>1,editValue:Te?D.title:null,editInputRef:Te?q:null,activity:M,unread:Q,onSelect:()=>c(j.id),onBeginRename:()=>K(j.id,Z),onCloseAll:()=>g(R),onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:de=>L({tabId:j.id,title:de})})]},j.id)}),m.jsx(H0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(l?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(l??[]).map(j=>m.jsx(o5,{terminal:j,onReattach:()=>f?.(j.id),onDelete:()=>P(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),x?H():null]}),A?m.jsx(l5,{tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:D,editInputRef:q,onClose:()=>B(!1),onSelectTab:j=>{c(j),B(!1)},onCreateTab:()=>{h(),B(!1)},onBeginRename:K,onCloseTerminals:j=>{g(j),B(!1)},onCommitRename:W,onCancelRename:()=>L(null),onRenameChange:(j,ae)=>L({tabId:j,title:ae}),onReattachTerminal:j=>{f?.(j),B(!1)},onDeleteTerminal:j=>{P(j),B(!1)}}):null,Y?m.jsx(c5,{terminal:Y,onCancel:()=>P(null),onConfirm:()=>{y?.(Y.id),P(null)}}):null]})}function a5({tab:e,active:t,editing:r,title:s,paneCount:l,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:y,onBeginRename:b,onCloseAll:S,onCommitRename:w,onCancelRename:x,onRenameChange:D}){const{attributes:L,listeners:A,setNodeRef:B,transform:Y,isDragging:P}=yw({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:r}),q={transform:Hp.Translate.toString(Y),opacity:P?.4:void 0,zIndex:P?2:void 0};return m.jsxs("div",{ref:B,className:"terminal-tab","data-active":t,"data-dragging":P,"data-unread":f?"true":void 0,style:q,...L,...A,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:l_(g)}):null,r&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:re=>{re.preventDefault(),w()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${s}`,value:h,onBlur:w,onChange:re=>D(re.target.value),onKeyDown:re=>{if(re.key==="Enter"){re.preventDefault(),w();return}re.key==="Escape"&&(re.preventDefault(),x())}}),m.jsx("small",{children:l})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${s}`,title:s,onClick:y,onDoubleClick:re=>{re.preventDefault(),b()},children:[m.jsx("span",{children:s}),m.jsxs("small",{children:[l," pane",l===1?"":"s"]})]}),c&&!r?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${s}`,title:`Close ${s}`,onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),S()},children:"x"}):null]})}function l5({tabs:e,activeTabId:t,terminals:r,unreadCompletionTabIds:s,detachedTerminals:l,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:y,onCloseTerminals:b,onCommitRename:S,onCancelRename:w,onRenameChange:x,onReattachTerminal:D,onDeleteTerminal:L}){const A=v.useRef(null);return v.useEffect(()=>{A.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:p,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:B=>B.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:f,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:p,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((B,Y)=>{const P=yc(B),q=Jm(B),re=cg(B,r),ne=B.id===t,he=c?.tabId===B.id,ve=og(B,r),U=s?.has(B.id)??!1;return m.jsxs("div",{ref:ne?A:null,className:"mobile-tab-sheet-row","data-active":ne,"data-unread":U?"true":void 0,children:[he&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:K=>{K.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${re}`,value:c.title,onBlur:S,onChange:K=>x(B.id,K.target.value),onKeyDown:K=>{if(K.key==="Enter"){K.preventDefault(),S();return}K.key==="Escape"&&(K.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${re}`,onClick:()=>g(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:Y+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:re}),m.jsx("small",{children:r5(B,r,q,ve)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ve?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:l_(ve)}):null,m.jsx("span",{children:q})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[he?m.jsx("button",{type:"button","aria-label":`Done renaming ${re}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${re}`,onClick:()=>y(B.id,re),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${re}`,onClick:()=>b(P),children:"×"}):null]})]},B.id)}),(l?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(l??[]).map(B=>{const Y=B.title||B.cwd||B.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${Y}`,onClick:()=>D(B.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:Y}),m.jsx("small",{children:B.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${Y}`,onClick:()=>L(B),children:"×"})})]},B.id)})]}):null]})]})})}function H0({index:e}){const{setNodeRef:t,isOver:r}=xg({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":r,"aria-hidden":"true"})}function o5({terminal:e,onReattach:t,onDelete:r}){const s=e.title||e.cwd||e.id.slice(0,8),l=`${e.title||"Terminal"}
|
|
54
|
+
${e.cwd}
|
|
55
|
+
(detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:l,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${s}`,onClick:t,children:s}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${s}`,title:`Delete ${s} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),r()},children:"×"})]})}function c5({terminal:e,onCancel:t,onConfirm:r}){const s=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:l=>l.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:s}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:r,children:"Delete"})]})]})})}function u5({uploads:e,onDismiss:t,onDismissAll:r,onRetry:s,onCancel:l}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",p=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${m5(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?uh(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:r,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(h5,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>s(g.id),onCancel:()=>l(g.id)},g.id))})]})}function h5({upload:e,compact:t,onDismiss:r,onRetry:s,onCancel:l}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":uh(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:uh(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:l,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:s,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${uh(e)}`,onClick:r,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(d5,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(f5,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function d5({toast:e}){const t=e.percent===null?g5(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function f5({response:e,compact:t}){const r=e.results.filter(h=>h.status==="failed"),s=e.results.filter(h=>h.status==="uploaded"),l=t?3:6,c=[...r,...s].slice(0,l);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,p)=>m.jsx(p5,{result:h},`${h.relativePath}-${p}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function p5({result:e}){const t=e.savedRelativePath??e.relativePath,r=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),r?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function uh(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,r=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${r} files`}return"Upload failed"}function m5(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 g5(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function _5({toast:e,onActivate:t,onDismiss:r}){if(!e)return null;const s=e,l=s.commandName?`${s.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),r()}function h(p){p.target===p.currentTarget&&(p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(s)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(s),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:s.tabTitle}),m.jsx("span",{children:l})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:p=>p.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:s.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const v5=nc(0,0,1,1),Gr=1e-6;function b5(e){return wC(e).map(t=>t.terminalId)}function wC(e){return ic(e,v5).sort(C5).map((t,r)=>({...t,index:r+1}))}function y5(e,t,r){const s=wC(e),l=s.find(h=>h.terminalId===t);return l?s.filter(h=>h.terminalId!==t).map(h=>w5(l,h,r)).filter(h=>h!==null).sort(x5)[0]?.entry.terminalId??null:null}function S5(e,t){return!Number.isInteger(t)||t<1?null:b5(e)[t-1]??null}function ic(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const r=k5(e.ratio);if(e.direction==="vertical"){const l=t.left+(t.right-t.left)*r;return[...ic(e.first,nc(t.left,t.top,l,t.bottom)),...ic(e.second,nc(l,t.top,t.right,t.bottom))]}const s=t.top+(t.bottom-t.top)*r;return[...ic(e.first,nc(t.left,t.top,t.right,s)),...ic(e.second,nc(t.left,s,t.right,t.bottom))]}function w5(e,t,r){const s=e.bounds,l=t.bounds,c=I0(s.left,s.right,l.left,l.right),h=I0(s.top,s.bottom,l.top,l.bottom);switch(r){case"left":return l.centerX>=s.centerX-Gr||h<=Gr?null:{entry:t,primaryDistance:Math.max(0,s.left-l.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"right":return l.centerX<=s.centerX+Gr||h<=Gr?null:{entry:t,primaryDistance:Math.max(0,l.left-s.right),perpendicularDistance:Math.abs(s.centerY-l.centerY),overlap:h};case"up":return l.centerY>=s.centerY-Gr||c<=Gr?null:{entry:t,primaryDistance:Math.max(0,s.top-l.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};case"down":return l.centerY<=s.centerY+Gr||c<=Gr?null:{entry:t,primaryDistance:Math.max(0,l.top-s.bottom),perpendicularDistance:Math.abs(s.centerX-l.centerX),overlap:c};default:return null}}function C5(e,t){return Al(e.bounds.top,t.bounds.top)||Al(e.bounds.left,t.bounds.left)}function x5(e,t){return Al(e.primaryDistance,t.primaryDistance)||Al(e.perpendicularDistance,t.perpendicularDistance)||Al(t.overlap,e.overlap)||Al(e.entry.index,t.entry.index)}function Al(e,t){const r=e-t;return Math.abs(r)<=Gr?0:r}function I0(e,t,r,s){return Math.max(0,Math.min(t,s)-Math.max(e,r))}function nc(e,t,r,s){return{left:e,top:t,right:r,bottom:s,centerX:e+(r-e)/2,centerY:t+(s-t)/2}}function k5(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class E5 extends Error{constructor(t){super(t),this.name="UploadDropError"}}function U0(e){return e?Array.from(e.types??[]).includes("Files")||EC(e.items).some(r=>r.kind==="file")?!0:TC(e.files).length>0:!1}async function T5(e){const t=EC(e.items).filter(r=>r.kind==="file");return t.length>0?D5(t):R5(e.files)}async function D5(e){const t=[];for(const r of e){const s=L5(r);if(s){await CC(s,"",t);continue}const l=r.getAsFile();if(l){t.push({relativePath:xC(l),file:l});continue}throw new E5("Folder upload is not supported by this browser.")}return t}function R5(e){return TC(e).map(t=>({relativePath:xC(t),file:t}))}async function CC(e,t,r){const s=O5(t,e.name);if(e.isFile){const h=await M5(e);r.push({relativePath:s,file:h});return}if(!e.isDirectory)return;const l=e.createReader(),c=await N5(l);for(const h of c)await CC(h,s,r)}function M5(e){return new Promise((t,r)=>{e.file(t,s=>r(s))})}async function N5(e){const t=[];for(;;){const r=await A5(e);if(r.length===0)return t;t.push(...r)}}function A5(e){return new Promise((t,r)=>{e.readEntries(t,s=>r(s))})}function xC(e){const t=e.webkitRelativePath;return kC(typeof t=="string"&&t?t:e.name)}function L5(e){const t=e.webkitGetAsEntry?.();return B5(t)?t:null}function B5(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 O5(e,t){return kC(e?`${e}/${t}`:t)}function kC(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function EC(e){return e?Array.from(e):[]}function TC(e){return e?Array.from(e):[]}const K0="nterminal.terminalWorkspaces.v2",DC="nterminal.sidebarCollapsed.v1",z5=75,W0=Cw.map(e=>e.url),j5=Cw[0].url,P5=6;function H5({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s,sessionExpiresAt:l=null,previewMode:c=!1,onLogout:h=async()=>{},onSessionInvalid:p}){const g=v.useMemo(()=>e??zh(),[e]),f=v.useMemo(()=>t??hc(null),[t]),y=v.useMemo(()=>nL(r),[r]),b=v.useMemo(()=>k=>yC(r,k),[r]),S=v.useMemo(()=>()=>Bt(r),[r]),w=v.useSyncExternalStore(b,S,S),x=w.state,D=w.editors,L=!w.loaded,A=w.error,[B,Y]=v.useState(!1),[P,q]=v.useState(()=>uL()),[re,ne]=v.useState("servers"),[he,ve]=v.useState(!1),U=v.useSyncExternalStore(CT,fS,fS);v.useSyncExternalStore(bh,dS,dS);const[K,W]=v.useState(0),[H,j]=v.useState(null),[ae,R]=v.useState(()=>[null]),[X,Z]=v.useState(0),[Ce,Te]=v.useState(()=>[r]),[M,Q]=v.useState(()=>new Set),[de,me]=v.useState({}),[ge,Se]=v.useState(null),Ee=v.useRef(0),De=v.useRef(0),[Ke,se]=v.useState(null),[pe,Le]=v.useState(null),be=v.useRef(null),Me=v.useRef(0),Pe=v.useRef(null),ze=v.useRef(null),ie=v.useRef(null),[ke,Re]=v.useState(null),Be=nE(Yy(mw,{activationConstraint:{distance:8}}),Yy(gw,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>xT(g),[g]);function je(k){const E=k.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Re({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Re({tabId:E.sourceTabId,terminalId:E.terminalId})}}function at(k){Re(null);const E=k.active.data.current,z=k.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"){$e({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){$e({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")&&$e({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"){$e({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){$e({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")&&$e({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function Xt(){Re(null)}const Ve=x.workspaces.find(k=>k.id===x.activeWorkspaceId)??x.workspaces[0],xt=Ve?.tabs.find(k=>k.id===Ve.activeTabId)??Ve?.tabs[0],ti=xt?.activeTerminalId??null,kt=ti?x.terminals[ti]:void 0,_e=eL("(max-width: 760px)"),Fe=v.useMemo(()=>xt?Lh(xt.root):[],[xt]),Je=Ve&&xt?rc(r,Ve.id,xt.id):null,ct=xt?RC(Fe,xt.activeTerminalId,Je?de[Je]:void 0):null,Pt=_e&&Fe.length>1,bt=v.useMemo(()=>(Ve?.detachedTerminalIds??[]).flatMap(k=>{const E=x.terminals[k];return E?[E]:[]}),[Ve?.detachedTerminalIds,x.terminals]),Nt=v.useMemo(()=>{const k=new Set;for(const E of Ve?.tabs??[])yc(E).some(z=>w.unreadCompletions.has(z))&&k.add(E.id);return k},[Ve?.tabs,w.unreadCompletions]),[Ft,F]=v.useState([]),Ue=v.useRef([]),st=v.useRef(null),[Si,wi]=v.useState(null),[Ai,St]=v.useState(null),[At,qt]=v.useState([]),[Gt,Ci]=v.useState(()=>Na()),li=v.useRef(0),zt=v.useRef(r),Wi=v.useRef(W0),Ht=v.useRef(Gt),Et=v.useRef(()=>{});Et.current=Ys;const Zt=v.useCallback(async()=>{try{const k=await g.listNotificationAssets();qt(k.assets.filter(E=>E.enabled).map(E=>E.url))}catch{qt([])}},[g]);v.useEffect(()=>{Te(k=>k.some(E=>yn(E,r))?k:[...k,r])},[r]);const oi=v.useCallback(k=>{const E=Bt(k),z=hc(k);for(const te of Object.keys(E.state.terminals))ec(z.createWebSocketUrl(te)),Xu(te);t5(k),Te(te=>te.filter(ye=>!yn(ye,k))),Q(te=>{const ye=`${dh(k)}:`;let oe=!1;const we=new Set;for(const He of te){if(He.startsWith(ye)){oe=!0;continue}we.add(He)}return oe?we:te}),me(te=>{const ye=`${dh(k)}:`;let oe=!1;const we={};for(const[He,it]of Object.entries(te)){if(He.startsWith(ye)){oe=!0;continue}we[He]=it}return oe?we:te})},[]);v.useEffect(()=>{let k=!1;return g.listAgents().then(E=>{if(!k){const z=E.agents.map(ye=>ye.id),te=[null,...z];r!==null&&!z.includes(r)&&(oi(r),s?.(null)),R(te)}}).catch(()=>{}),()=>{k=!0}},[r,g,oi,s,X]);const Qi=v.useCallback(k=>{oi(k),Z(E=>E+1),yn(k,zt.current)&&s?.(null)},[oi,s]);v.useEffect(()=>{R(k=>k.some(E=>yn(E,r))?k:[...k,r])},[r]),v.useEffect(()=>{zt.current=r},[r]),v.useEffect(()=>{j(null)},[r]),v.useEffect(()=>{const k=Pe.current;if(!k)return;if(!yn(k.agentId,r)){Pe.current=null;return}if(!w.loaded||x.workspaces.length===0)return;Pe.current=null;const E=k.edge==="first"?x.workspaces[0]:x.workspaces[x.workspaces.length-1];E&&E.id!==x.activeWorkspaceId&&$e({type:"workspace.selected",workspaceId:E.id})},[r,w.loaded,x.activeWorkspaceId,x.workspaces]),v.useEffect(()=>{const k=ze.current;if(k){if(!yn(k.agentId,r)){ze.current=null;return}w.loaded&&(ze.current=null,x.workspaces.some(E=>E.id===k.workspaceId)&&$e({type:"workspace.selected",workspaceId:k.workspaceId}))}},[r,w.loaded,x.workspaces]),v.useEffect(()=>{const k=ie.current;if(k){if(!yn(k.agentId,r)){ie.current=null;return}w.loaded&&(ie.current=null,w.error||Fi())}},[r,w.error,w.loaded]),v.useEffect(()=>{Zt()},[Zt]),v.useEffect(()=>kw(()=>Ci(Na())),[]),v.useEffect(()=>{const k=E=>{Et.current(E)};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[]),v.useEffect(()=>{Wi.current=At.length>0?At:W0},[At]),v.useEffect(()=>{Ht.current=Gt},[Gt]),v.useEffect(()=>{if(!w.loaded||!Ve||!xt)return;const k=rc(r,Ve.id,xt.id);Q(E=>{if(E.has(k))return E;const z=new Set(E);return z.add(k),z})},[r,w.loaded,Ve?.id,xt?.id]),v.useEffect(()=>()=>{Ya()},[]),v.useEffect(()=>M2(g),[g]),v.useEffect(()=>X3(k=>{const E=Bt(k.agentId).state,z=E.workspaces.flatMap(we=>we.tabs).find(we=>we.id===k.tabId),te=E.terminals[k.terminalId],ye=z?.title?.trim()||te?.title||k.commandName||"terminal",oe=document.visibilityState==="visible"&&yn(k.agentId,zt.current)&&k.tabId===iL(E);if(oe||x2({tabTitle:ye,commandName:k.commandName,terminalId:k.terminalId}),!oe&&document.visibilityState==="visible"&&Ht.current.enabled){const we=li.current+1;li.current=we;const He=Wi.current;wi({id:we,agentId:k.agentId,terminalId:k.terminalId,tabId:k.tabId,tabTitle:ye,commandName:k.commandName,assetSrc:He[Math.floor(Math.random()*He.length)]??j5})}}),[]),v.useEffect(()=>{if(!Si||Gt.persistUntilDismissed)return;const k=window.setTimeout(()=>{wi(E=>E?.id===Si.id?null:E)},Gt.durationSeconds*1e3);return()=>window.clearTimeout(k)},[Si,Gt]),v.useEffect(()=>{hL(P),P&&Li()},[P]),v.useEffect(()=>{let k=!1;async function E(){if(!Bt(r).loaded){Ls(r,!1,null);try{let te=null,ye=null;try{te=rL(y)}catch(it){if(!(it instanceof Oh))throw it;ye=it}const[oe,we]=await Promise.all([f.listTerminals(),f.getTerminalLayout()]),He=oe.terminals.length>0?oe.terminals:[(await f.createTerminal({cols:80,rows:24})).terminal];if(!k){const it=we.layout?NC(we.layout):null;if(!it&&ye)throw ye;const fi=it??te??{},jt=Qm(He,void 0,fi.savedWorkspaces,fi.savedActiveWorkspaceId),ls=Ap(jt);j0(r,jt),qo(r,we.revision,JSON.stringify(ls)),Ls(r,!0,null),!it&&te&&fn(ls,{baseRevision:we.revision})}}catch(te){!k&&!ns(te)&&Ls(r,!0,Bs(te))}}}return E(),()=>{k=!0}},[r,f,K]);function wn(){Ls(r,!1,null),W(k=>k+1)}function Li(){Ee.current+=1,De.current+=1,Se(null)}function Cn(k){Ee.current+=1,De.current+=1,Se(E=>E&&{...E,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function Fi(){Ee.current+=1,De.current+=1;const k=x.workspaces.length+1,E=ci();Se({mode:"create",workspaceId:null,title:`Workspace ${k}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Rr(E)}function $t(k){if(yn(k,r)){Fi();return}ie.current={agentId:k},s?.(k)}function Bi(k){if(P&&!B)return;const E=x.workspaces.find(te=>te.id===k);if(!E)return;Ee.current+=1,De.current+=1;const z=E.defaultCwd??kt?.cwd??"";Se({mode:"edit",workspaceId:k,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Rr(z)}function ci(){return Ve?.defaultCwd??kt?.cwd??""}async function Rr(k){const E=Ee.current+1;Ee.current=E;const z=k.trim();if(Se(te=>te&&{...te,cwd:k,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const te=await f.createFileRoot({path:z}),ye=await f.listFiles({rootToken:te.rootToken,path:""});if(Ee.current!==E)return;Se(oe=>oe&&{...oe,cwd:te.rootPath,browseRoot:{rootToken:te.rootToken,rootPath:te.rootPath},browseEntries:ye.entries.filter(we=>we.kind==="directory"),browseStatus:"idle",error:null})}catch(te){if(Ee.current!==E)return;Se(ye=>ye&&{...ye,browseStatus:"idle",error:Bs(te)})}}async function Ha(){const k=ge;if(!k)return;const E=k.title.trim(),z=k.cwd.trim();if(!E||!z){Se({...k,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const te=De.current+1;De.current=te,Se({...k,submitStatus:"submitting",error:null});try{const ye=await f.createFileRoot({path:z});if(De.current!==te)return;if(k.mode==="create"){const oe=x.workspaces.length+1;$e({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${oe}`,title:E,defaultCwd:ye.rootPath})}else k.workspaceId&&($e({type:"workspace.renamed",workspaceId:k.workspaceId,title:E}),$e({type:"workspace.defaultCwdChanged",workspaceId:k.workspaceId,defaultCwd:ye.rootPath}));Se(null)}catch(ye){if(De.current!==te)return;Se(oe=>oe&&{...oe,submitStatus:"idle",error:Bs(ye)})}}function Yl(k){De.current+=1,Se(k)}function ts(k,E,z){if(k===E)return;const te=x.workspaces.some(oe=>oe.id===k),ye=x.workspaces.some(oe=>oe.id===E);!te||!ye||$e({type:"workspace.reordered",sourceWorkspaceId:k,targetWorkspaceId:E,placement:z})}function Jn(k,E){const z=x.workspaces.findIndex(ye=>ye.id===k),te=x.workspaces[z+E];z<0||!te||ts(k,te.id,E<0?"before":"after")}function $s(k,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),be.current={sourceId:k,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function er(k){const E=be.current;if(!E||E.pointerId!==k.pointerId)return;const z=Math.hypot(k.clientX-E.startX,k.clientY-E.startY);if(!E.active){if(z<P5)return;E.active=!0,se(E.sourceId)}const ye=document.elementFromPoint(k.clientX,k.clientY)?.closest("[data-workspace-id]"),oe=ye?.dataset.workspaceId??null;if(!ye||!oe||oe===E.sourceId||!x.workspaces.some(it=>it.id===oe)){E.targetId=null,Le(null);return}const we=ye.getBoundingClientRect(),He=k.clientY<we.top+we.height/2?"before":"after";E.targetId=oe,E.placement=He,Le({workspaceId:oe,placement:He})}function tr(k){const E=be.current;!E||E.pointerId!==k.pointerId||(k.preventDefault(),k.stopPropagation(),k.currentTarget.releasePointerCapture?.(k.pointerId),be.current=null,se(null),Le(null),E.active&&E.targetId&&ts(E.sourceId,E.targetId,E.placement))}function jn(k){const E=be.current;E&&E.pointerId===k.pointerId&&k.currentTarget.releasePointerCapture?.(k.pointerId),be.current=null,se(null),Le(null)}async function ir(){await Ji(async()=>{const k=Ve?.defaultCwd?{cols:80,rows:24,cwd:Ve.defaultCwd}:{cols:80,rows:24},E=await f.createTerminal(k);$e({type:"terminal.created",terminal:E.terminal})})}async function It(k){await Ji(async()=>{const E=ti?{parentTerminalId:ti,cols:80,rows:24}:Ve?.defaultCwd?{cols:80,rows:24,cwd:Ve.defaultCwd}:{cols:80,rows:24},z=await f.createTerminal(E);$e({type:"terminal.split",terminal:z.terminal,direction:k})})}async function Ia(k){let E=ti,z=Je;const te=Ve?.defaultCwd?.trim();if(!E&&!te)throw new Error("No active pane is available.");const ye=await f.readFile(k);if(!E&&te){const He=await f.createTerminal({cols:80,rows:24,cwd:te});E=He.terminal.id,$e({type:"terminal.created",terminal:He.terminal})}if(E){$e({type:"pane.selected",terminalId:E});const He=Bt(r).state,it=He.workspaces.find(jt=>jt.id===He.activeWorkspaceId)??He.workspaces[0],fi=it?.tabs.find(jt=>jt.id===it.activeTabId)??it?.tabs[0];z=it&&fi?rc(r,it.id,fi.id):null}const oe=`editor-${Date.now().toString(36)}-${e5(r)}`,we=cL(ye.path);Lp(r,He=>({...He,[oe]:{id:oe,title:we,rootToken:k.rootToken,path:ye.path,read:ye}})),z&&me(He=>({...He,[z]:MC(oe)})),$e({type:"editor.split",editorId:oe,title:we,direction:"vertical"})}function Ua(k){Lp(r,E=>{const z={...E};return delete z[k],z}),$e({type:"editor.closed",editorId:k})}function nr(k){Pn([k])}function Pn(k){const E=[...new Set(k)].filter(te=>x.terminals[te]);if(E.length===0)return;const z=E.length===1?x.terminals[E[0]]?.title||x.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;j(null),St({terminalIds:E,label:z,workspaceId:Ve?.id??x.activeWorkspaceId??null})}function Ka(k,E){const z=Xs(k,E);if(!z)return!1;const te=k.filter(ye=>!z.detachedTerminalIds.includes(ye));if(z.detachedTerminalIds.length+te.length>Wl)return j(aL(z.detachedTerminalIds.length)),!1;j(null);for(const ye of k)$e(z.id?{type:"terminal.detached",terminalId:ye,workspaceId:z.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Wa(k){await Ji(async()=>{for(const E of k)await an(E),ec(f.createWebSocketUrl(E)),Xu(E),$e({type:"terminal.closed",terminalId:E})})}async function Fa(k){const E=x.workspaces.find(z=>z.id===k);!E||x.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Ji(async()=>{const z=Ah(E),te=[];let ye=null;for(const we of z)try{await an(we)}catch(He){te.push(Bs(He)),He instanceof ur&&He.status===401&&!f.isAgent&&(ye=He)}finally{ec(f.createWebSocketUrl(we)),Xu(we)}const oe=E.tabs.flatMap(we=>ug(we.root));if(oe.length>0){const we=new Set(oe);Lp(r,He=>{const it={...He};for(const fi of we)delete it[fi];return it})}if($e({type:"workspace.closed",workspaceId:k}),ye)throw ye;if(te.length>0)throw new Error(`Workspace was removed, but ${te.length} terminal session${te.length===1?"":"s"} may still be running. ${te[0]}`)})}async function Xl(k){await Ji(async()=>{await an(k),ec(f.createWebSocketUrl(k)),Xu(k),$e({type:"terminal.closed",terminalId:k})})}async function fr(k,E){const z=E.trim();if(!z)return;let te=null;for(const ye of x.workspaces){const oe=ye.tabs.find(we=>we.id===k);if(oe){te=oe.activeTerminalId;break}}if($e({type:"tab.renamed",tabId:k,title:z}),!!te)try{const ye=await f.renameTerminal(te,z);Mr({type:"terminal.updated",terminal:ye.terminal})}catch(ye){Ls(r,!0,Bs(ye))}}function is(k){const E=x.terminals[k];E&&$e({type:"terminal.created",terminal:E})}async function an(k){try{await f.closeTerminal(k)}catch(E){if(E instanceof ur&&E.status===404)return;throw E}}async function xi(){await Ji(async()=>{await h()})}async function Ji(k){Ls(r,!0,null);try{await k()}catch(E){if(ns(E))return;Ls(r,!0,Bs(E))}}function ns(k){return k instanceof ur&&k.status===401&&!f.isAgent&&p?(p({source:"workspace-api-401",status:401,activeAgentId:r}),!0):!1}function $e(k){Fo(r,k);const E=Bt(r),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const te=Ap(z);JSON.stringify(te)!==E.lastPersistedLayoutJson&&ea(te)}function Mr(k){Fo(r,k)}function pr(k,E,z,te){const ye=rc(k,E,z);me(oe=>({...oe,[ye]:te}))}function mr(k){Je&&me(E=>({...E,[Je]:k}))}function gt(k,E){const z=Bh(k);E?pr(r,E.workspaceId,E.tabId,z):mr(z),$e({type:"pane.selected",terminalId:k})}function Vs(k){mr(k.key),k.type==="terminal"&&$e({type:"pane.selected",terminalId:k.terminalId})}function Ys(k){if(he||Ai||k.isComposing||k.key==="Process"||q5(k.target))return;const E=U5(k);if(!E)return;if(k.preventDefault(),k.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){rr(E.type==="server.next"?1:-1);return}const z=Bt(r).state,te=z.workspaces.find(we=>we.id===z.activeWorkspaceId)??z.workspaces[0],ye=te?.tabs.find(we=>we.id===te.activeTabId)??te?.tabs[0];if(E.type==="split"){if(!ye)return;It(E.direction);return}if(!te||!ye)return;if(E.type==="tab.previous"||E.type==="tab.next"){const we=F5(te.tabs,ye.id,E.type==="tab.next"?1:-1);we&&$e({type:"tab.selected",tabId:we.id});return}if(E.type==="tab.index"){const we=te.tabs[E.index-1];we&&$e({type:"tab.selected",tabId:we.id});return}const oe=K5(ye.root,ye.activeTerminalId,E);oe&>(oe,{workspaceId:te.id,tabId:ye.id})}function Nr(k,E){if(!s||ae.length===0)return;const z=ae.findIndex(we=>yn(we,r)),ye=((z===-1?0:z)+k+ae.length)%ae.length,oe=ae[ye]??null;yn(oe,r)||(E&&(Pe.current={agentId:oe,edge:E}),s(oe))}function rr(k){const E=Bt(r).state,z=E.workspaces;if(z.length===0){Nr(k,k===1?"first":"last");return}const te=z.findIndex(we=>we.id===E.activeWorkspaceId),oe=(te===-1?0:te)+k;if(oe>=0&&oe<z.length){$e({type:"workspace.selected",workspaceId:z[oe].id});return}Nr(k,k===1?"first":"last")}function qa(k,E){if(yn(k,r)){$e({type:"workspace.selected",workspaceId:E});return}ze.current={agentId:k,workspaceId:E},s?.(k)}function Xs(k,E){if(E)return x.workspaces.find(z=>z.id===E)??null;for(const z of k){const te=x.workspaces.find(oe=>oe.tabs.some(we=>yc(we).includes(z)));if(te)return te;const ye=x.workspaces.find(oe=>oe.detachedTerminalIds.includes(z));if(ye)return ye}return x.workspaces.find(z=>z.id===x.activeWorkspaceId)??x.workspaces[0]??null}function en(k){U0(k.dataTransfer)&&(k.preventDefault(),k.dataTransfer.dropEffect="copy")}function Gs(k){if(!U0(k.dataTransfer))return;k.preventDefault();const E=lL(Bt(r).state),z=Me.current+1;if(Me.current=z,!E){Qs({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}Qs({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),$a(z,E.id,k.dataTransfer)}async function $a(k,E,z){try{const te=await T5(z);if(te.length===0)throw new Error("No files were found in the drop.");dn(k,{id:k,status:"queued",fileCount:te.length,message:"Queued"},{terminalId:E,files:te})}catch(te){dn(k,{id:k,status:"failed",fileCount:0,message:Bs(te)},{terminalId:E})}finally{gr()}}async function Zs(k){const E=Ue.current.find(oe=>oe.id===k);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,te=E.files,ye=new AbortController;st.current=k,dn(k,{id:k,status:"uploading",fileCount:te.length,loaded:0,total:null,percent:null},{terminalId:z,files:te,abortController:ye});try{const oe=await zT({terminalId:z,files:te,signal:ye.signal,onProgress:fi=>{dn(k,{id:k,status:"uploading",fileCount:te.length,loaded:fi.loaded,total:fi.total,percent:fi.percent},{terminalId:z,files:te,abortController:ye})}}),we=oe.failed>0?oe.uploaded>0?"partial":"failed":"success",He=oe.failed>0?oL(oe):void 0,it={id:k,status:we,fileCount:te.length,response:oe};He&&(it.message=He),dn(k,it,{terminalId:z,files:te})}catch(oe){dn(k,{id:k,status:"failed",fileCount:te.length,message:ye.signal.aborted?"Upload canceled.":Bs(oe)},{terminalId:z,files:te})}finally{st.current===k&&(st.current=null),gr()}}function gr(){if(st.current!==null)return;const k=Ue.current.find(E=>E.status==="queued");k?.terminalId&&k.files&&k.files.length>0&&Zs(k.id)}function Qs(k){xn(E=>[...E,k])}function dn(k,E,z={}){xn(te=>te.map(ye=>{if(ye.id!==k)return ye;const oe={...E},we=z.terminalId??ye.terminalId,He=z.files??ye.files;return we!==void 0&&(oe.terminalId=we),He!==void 0&&(oe.files=He),z.abortController!==void 0&&(oe.abortController=z.abortController),oe}))}function xn(k){const E=k(Ue.current);Ue.current=E,F(E)}function qi(k){Ue.current.find(z=>z.id===k)?.abortController?.abort(),st.current===k&&(st.current=null),xn(z=>z.filter(te=>te.id!==k)),gr()}function Js(){for(const k of Ue.current)k.abortController?.abort();st.current=null,xn(()=>[])}function rs(k){const E=Ue.current.find(z=>z.id===k);if(E){if(E.status==="queued"){qi(k);return}E.abortController?.abort()}}function _r(k){const E=Ue.current.find(te=>te.id===k);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=sr(E);if(z.length===0){dn(k,{id:k,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}dn(k,{id:k,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),gr()}function sr(k){const E=k.files??[],z="response"in k?k.response:void 0;if(!z)return E;const te=z.results.filter(we=>we.status==="failed").map(we=>we.relativePath);if(te.length===0)return[];const ye=new Map;for(const we of E){const He=ye.get(we.relativePath)??[];He.push(we),ye.set(we.relativePath,He)}const oe=[];for(const we of te){const it=ye.get(we)?.shift();it&&oe.push(it)}return oe}function Va(k){const z=Bt(k.agentId).state.workspaces.find(te=>te.tabs.some(ye=>ye.id===k.tabId));z&&pr(k.agentId,z.id,k.tabId,Bh(k.terminalId)),Fo(k.agentId,{type:"pane.selected",terminalId:k.terminalId}),J3(k.agentId,k.terminalId),yn(k.agentId,r)||s?.(k.agentId),wi(null)}function ea(k){const E=Bt(r).mutable.saveCoord;E.pendingLayoutSave=k,$o(k,y),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&fn(z)},z5)}function Ya(){const k=Bt(r).mutable.saveCoord;k.saveTimer!==null&&(window.clearTimeout(k.saveTimer),k.saveTimer=null);const E=k.pendingLayoutSave;k.pendingLayoutSave=null,E&&($o(E,y),fn(E))}function fn(k,E={}){const z=Bt(r).mutable.saveCoord;z.nextPersistLayout=k,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const te=z.nextPersistLayout,ye=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,te&&await tn(te,ye!==void 0?{baseRevision:ye}:{})}))}async function tn(k,E={}){const z=Bt(r),te=E.baseRevision??z.layoutRevision,ye={layout:k,...typeof te=="number"?{baseRevision:te}:{}};try{const oe=await f.saveTerminalLayout(ye),we=oe.layout??k;qo(r,oe.revision,JSON.stringify(we)),$o(we,y);return}catch(oe){if(oe instanceof ur&&oe.status===400&&oe.message===u2){sL(r,y),Ls(r,!0,AC());return}if(oe instanceof ur&&oe.status===409)try{const we=await f.getTerminalLayout(),He=Bt(r).mutable.saveCoord;if(He.nextPersistLayout||He.pendingLayoutSave){const it=we.layout?JSON.stringify(we.layout):Bt(r).lastPersistedLayoutJson;qo(r,we.revision,it);return}if(we.layout){const it=Bt(r).state,fi=Qm(Object.values(it.terminals),void 0,we.layout.workspaces,we.layout.activeWorkspaceId),jt=Ap(fi);j0(r,fi),qo(r,we.revision,JSON.stringify(jt)),$o(jt,y)}else qo(r,we.revision,z.lastPersistedLayoutJson);return}catch{}$o(k,y)}}const ss=dL(l),$i=!P||B,ln=$i?re:"servers";function as(k){const E=k.active?w:Bt(k.agentId),z=k.active?x:E.state,te=k.active?w.loaded:E.loaded,ye=k.active?A:E.error;return m.jsxs("div",{className:`workspace-list-panel${k.active?" workspace-list-panel--active-server":""}`,"aria-label":`${k.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${k.label}`,title:"New workspace",onClick:()=>$t(k.agentId),children:"+"})]}),te?ye?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>s?.(k.agentId),children:ye}):m.jsx("div",{className:"workspace-list-items",children:z.workspaces.map(oe=>{const we=k.active&&oe.id===Ve?.id,He=Ah(oe).length,it=k.active&&z.workspaces.length>1,fi=pe?.workspaceId===oe.id&&Ke!==oe.id?pe.placement:null;return m.jsxs(G5,{workspaceId:oe.id,active:we,disabled:!k.active,reorderable:it,dragging:Ke===oe.id,dropPlacement:fi,children:[it?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":oe.id,title:"Drag to reorder","aria-label":`Reorder ${oe.title}`,"aria-grabbed":Ke===oe.id,onPointerDown:jt=>$s(oe.id,jt),onPointerMove:er,onPointerUp:tr,onPointerCancel:jn,onKeyDown:jt=>{(jt.key==="ArrowUp"||jt.key==="ArrowDown")&&(jt.preventDefault(),jt.stopPropagation(),Jn(oe.id,jt.key==="ArrowUp"?-1:1))},onClick:jt=>jt.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":we?"page":void 0,title:oe.defaultCwd??void 0,onClick:()=>qa(k.agentId,oe.id),onDoubleClick:()=>{k.active&&Bi(oe.id)},children:[m.jsx("span",{className:"workspace-list-name",children:oe.title}),m.jsxs("small",{children:[oe.defaultCwd??"No folder"," · ",He," ",He===1?"session":"sessions"]})]}),k.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${oe.title}`,title:"Edit workspace",onClick:()=>Bi(oe.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${oe.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Fa(oe.id)},children:"x"})]}):null]},oe.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>s?.(k.agentId),children:"Open server to load workspaces"})]})}return m.jsx(n2,{sensors:Be,onDragStart:je,onDragEnd:at,onDragCancel:Xt,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":P,"data-sidebar-open":B,onDragOver:en,onDrop:Gs,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>Y(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[m.jsxs("div",{className:"workspace-brand-lockup",children:[$i?m.jsx(ew,{height:20}):m.jsx(J0,{size:24}),c&&$i?m.jsx("span",{className:"workspace-preview-badge",children:"Preview"}):null]}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":P?"Expand sidebar":"Collapse sidebar",title:P?"Expand sidebar":"Collapse sidebar",onClick:()=>q(k=>!k),children:P?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>Y(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${ln==="files"?"files":"servers"}`,children:[$i?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":re==="servers",onClick:()=>{ne("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":re==="files",onClick:()=>{ne("files")},children:"Files"})]}):null,ln==="servers"&&$i?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(hS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,renderServerChildren:as})}):null,$i?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(hS,{api:g,activeAgentId:r,onSelectServer:s??(()=>{}),onSessionInvalid:p,refreshToken:X,compact:!0})}),ln==="files"?m.jsx(UT,{api:f,activeTerminalId:ti,activeTerminalCwd:kt?.cwd??null,workspaceRootPath:Ve?.defaultCwd??kt?.cwd??null,onOpenFile:Ia}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[$i?m.jsx("span",{children:ss}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ve(!0),children:[m.jsx(q0,{name:"settings"}),U.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),$i?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{xi()},children:m.jsx(q0,{name:"logout"})}):null]})]})]}),he?m.jsx(LT,{api:g,onClose:()=>ve(!1),updateAvailable:U.hasUpdates,onNotificationAssetsChanged:()=>{Zt()},onAgentRemoved:Qi}):null,ge?m.jsx($5,{dialog:ge,activePaneCwd:kt?.cwd??null,activeWorkspaceCwd:Ve?.defaultCwd??null,onChange:Yl,onManualCwdChange:Cn,onBrowse:Rr,onCancel:Li,onSubmit:()=>{Ha()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":Pt?"true":void 0,children:[m.jsx(s5,{tabs:Ve?.tabs??[],activeTabId:Ve?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:Nt,detachedTerminals:bt,onSelectTab:k=>$e({type:"tab.selected",tabId:k}),onCreateTab:()=>{ir()},onToggleWorkspaces:()=>Y(k=>!k),onCloseTerminals:k=>Pn(k),onReattachTerminal:k=>is(k),onDeleteTerminal:k=>{Xl(k)},onSplitVertical:()=>{It("vertical")},onSplitHorizontal:()=>{It("horizontal")},onRenameTab:(k,E)=>{fr(k,E)},activePaneAvailable:!!ti}),Pt?m.jsx(Q5,{targets:Fe,activeLeafKey:ct,terminals:x.terminals,editors:D,onSelect:Vs}):null,A?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:A}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:wn,children:"Retry"}),r!==null&&s?m.jsx("button",{type:"button",onClick:()=>s(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":L,children:[L?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!L&&!xt?m.jsx(X5,{onCreate:()=>{ir()}}):null,Ce.map(k=>{const E=yn(k,r);return m.jsx(I5,{agentId:k,active:E,activeServerApi:E?f:void 0,visitedTabKeys:M,refreshCwdOnEnter:E&&ln==="files",draggingTab:E?ke:null,mobileSplitFocus:_e,mobileFocusedLeafByTabKey:de,onSelect:z=>{E&>(z)},onClose:z=>{E&&nr(z)},onCloseEditor:z=>{E&&Ua(z)},onResize:(z,te)=>{E&&$e({type:"pane.resized",path:z,ratio:te})},onExit:(z,te)=>{E?Mr({type:"terminal.exited",terminalId:z,exitCode:te}):Fo(k,{type:"terminal.exited",terminalId:z,exitCode:te})},onSnapshot:(z,te)=>{const ye={type:"terminal.updated",terminal:z,notifyCompletion:te?.notifyCompletion===!0};E?Mr(ye):Fo(k,ye)},...k===null&&p?{onAuthClose:z=>p({...z,source:z?.source??"terminal-ws-1008",activeAgentId:k})}:{}},dh(k))})]}),Ai?m.jsx(Z5,{label:Ai.label,count:Ai.terminalIds.length,warning:H,onCancel:()=>{j(null),St(null)},onHide:()=>{Ka(Ai.terminalIds,Ai.workspaceId)&&St(null)},onDelete:()=>{const k=Ai.terminalIds;j(null),St(null),Wa(k)}}):null,m.jsx(_5,{toast:Si,onActivate:Va,onDismiss:()=>wi(null)}),m.jsx(u5,{uploads:Ft,onDismiss:qi,onDismissAll:Js,onRetry:_r,onCancel:rs})]})]})})}function I5({agentId:e,active:t,activeServerApi:r,visitedTabKeys:s,refreshCwdOnEnter:l,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:y,onResize:b,onExit:S,onSnapshot:w,onAuthClose:x}){const D=v.useMemo(()=>ve=>yC(e,ve),[e]),L=v.useMemo(()=>()=>Bt(e),[e]),A=v.useSyncExternalStore(D,L,L),B=v.useMemo(()=>hc(e),[e]),Y=r??B,P=A.state,q=P.workspaces.find(ve=>ve.id===P.activeWorkspaceId)??P.workspaces[0],re=q?.id??null,he=(q?.tabs.find(ve=>ve.id===q.activeTabId)??q?.tabs[0])?.id??null;return!A.loaded||P.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:P.workspaces.flatMap(ve=>ve.tabs.map(U=>{const K=t&&ve.id===re&&U.id===he,W=rc(e,ve.id,U.id),H=Lh(U.root),j=h&&H.length>1?RC(H,U.activeTerminalId,p[W]):null;return!K&&!s.has(W)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":K,"aria-hidden":!K,children:m.jsx(Xm,{node:U.root,terminals:P.terminals,editors:A.editors,api:Y,activeTerminalId:U.activeTerminalId,visible:K,refreshCwdOnEnter:K&&l,tabId:U.id,dropZoneActive:K&&c!==null,draggingTerminalId:K?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:f,onCloseEditor:y,onResize:b,onExit:S,onSnapshot:w,...x?{onAuthClose:x}:{}})},`${ve.id}:${U.id}`)}))})}function U5(e){const t=Hw(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 r=W5(e.key);return r?{type:"pane.direction",direction:r}:null}return null}function K5(e,t,r){switch(r.type){case"pane.direction":return y5(e,t,r.direction);case"pane.index":return S5(e,r.index);default:return null}}function W5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function F5(e,t,r){if(e.length===0)return null;const s=e.findIndex(c=>c.id===t);return e[((s===-1?0:s)+r+e.length)%e.length]??null}function Lh(e){return e.type==="pane"?[{key:Bh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:MC(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...Lh(e.first),...Lh(e.second)]}function ug(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...ug(e.first),...ug(e.second)]}function RC(e,t,r){if(r&&e.some(l=>l.key===r))return r;const s=t?Bh(t):null;return s&&e.some(l=>l.key===s)?s:e[0]?.key??null}function Bh(e){return`terminal:${e}`}function MC(e){return`editor:${e}`}function q5(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 $5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:r,onChange:s,onManualCwdChange:l,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(w=>w.kind==="directory"),y=e.submitStatus==="submitting";function b(w){s(x=>x&&{...x,...w})}function S(w){w&&(b({cwd:w,error:null}),c(w))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),y||p()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:w=>b({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:y,onChange:w=>l(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:y||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(r),disabled:y||!r,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(Y5(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:y,onClick:()=>{c(V5(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function V5(e,t){return t?t.startsWith("/")?hh(t):hh(`${e||"/"}/${t}`):hh(e)}function Y5(e){const t=hh(e);if(!t||t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function hh(e){const t=e.trim();if(!t)return"";const r=t.replace(/\/+/g,"/");return r==="/"?"/":r.endsWith("/")?r.slice(0,-1):r}function X5({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function G5({workspaceId:e,active:t,disabled:r=!1,reorderable:s=!1,dragging:l=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=xg({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:r}),f=["workspace-list-item",t?"workspace-list-item--active":"",s?"workspace-list-item--reorderable":"",l?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function Z5({label:e,count:t,warning:r,onCancel:s,onHide:l,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:s,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:s,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),r?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:r}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:s,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:l,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function Q5({targets:e,activeLeafKey:t,terminals:r,editors:s,onSelect:l}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(S=>S.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],y=F0(f,r,s);function b(S){const w=(g+S+e.length)%e.length,x=e[w];x&&l(x)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const x=F0(S,r,s),D=J5(S,r,s),L=S.key===f.key;return m.jsxs("button",{type:"button","data-active":L,onClick:()=>{l(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:x}),m.jsx("small",{children:D})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function F0(e,t,r){if(e.type==="editor")return r[e.editorId]?.title||e.title||e.editorId;const s=t[e.terminalId];return s?.title||s?.cwd||e.terminalId}function J5(e,t,r){if(e.type==="editor"){const c=r[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const s=t[e.terminalId];return s?`${s.activity==="busy"?`busy${s.currentCommand?`: ${s.currentCommand}`:""}`:s.activity==="idle"?"idle":s.status} | ${s.cwd}`:"terminal"}function eL(e){const[t,r]=v.useState(()=>tL(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){r(!1);return}const s=window.matchMedia(e),l=()=>r(s.matches);return l(),typeof s.addEventListener=="function"?(s.addEventListener("change",l),()=>s.removeEventListener("change",l)):(s.addListener(l),()=>s.removeListener(l))},[e]),t}function tL(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function yn(e,t){return e===t}function iL(e){const t=e.workspaces.find(s=>s.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(s=>s.id===t.activeTabId)??t?.tabs[0])?.id??null}function dh(e){return e??"__local__"}function rc(e,t,r){return`${dh(e)}:${t}:${r}`}class Oh extends Error{constructor(){super(AC())}}function nL(e){return e?{workspaceKey:`${K0}:${e}`}:{workspaceKey:K0}}function rL(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const r=JSON.parse(t);if(ww(r))throw new Oh;const s=Sw(r);return s?NC(s):null}catch(r){if(r instanceof Oh)throw r;return null}}function NC(e){if(ww(e))throw new Oh;const t=Sw(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function $o(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function sL(e,t){const r=Bt(e).lastPersistedLayoutJson;if(r){localStorage.setItem(t.workspaceKey,r);return}localStorage.removeItem(t.workspaceKey)}function aL(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 AC(){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 lL(e){const t=e.workspaces.find(l=>l.id===e.activeWorkspaceId)??e.workspaces[0],r=t?.tabs.find(l=>l.id===t.activeTabId)??t?.tabs[0],s=r?e.terminals[r.activeTerminalId]:void 0;return s?.status==="running"?s:null}function oL(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function cL(e){return e.split("/").filter(Boolean).pop()??e}function uL(){try{return localStorage.getItem(DC)==="true"}catch{return!1}}function hL(e){try{localStorage.setItem(DC,e?"true":"false")}catch{}}function dL(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const r=t-Date.now();if(r<=0)return"session · expired";const s=Math.max(1,Math.floor(r/6e4));return s<60?`session · ${s}m left`:`session · ${Math.floor(s/60)}h left`}function q0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function Bs(e){return e instanceof Error?e.message:"Request failed"}function fL({api:e,onDone:t}){const[r,s]=v.useState(null),[l,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let D=!1;return e.setupTotp().then(L=>{D||(s(L.qrDataUrl),c(L.secret))}).catch(L=>{D||w(L instanceof Error?L.message:"Failed to generate QR code")}),()=>{D=!0}},[e]);async function x(D){if(D.preventDefault(),!!l){f(!0),b(null);try{await e.activateTotp({secret:l,otp:h}),t()}catch(L){b(L instanceof Error?L.message:"Verification failed")}finally{f(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!r||!l?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:r,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:l})]}),m.jsxs("form",{className:"auth-form",onSubmit:x,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:D=>p(D.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?m.jsx("p",{className:"form-error",children:y}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}const LC="nterminal.clientDiagnostics.v1",BC=150,pL=24,mL=160;let $0=!1,Vo=null;function gL(){$0||typeof window>"u"||($0=!0,On("page.load",{navigation:EL(),visibility:document.visibilityState,online:navigator.onLine,viewport:jC(),standalone:kL()}),document.addEventListener("visibilitychange",()=>{On("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{On("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{On("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>On("network.online")),window.addEventListener("offline",()=>On("network.offline")),window.addEventListener("focus",()=>On("window.focus")),window.addEventListener("blur",()=>On("window.blur")),window.addEventListener("error",e=>{On("runtime.error",{message:e.message,source:TL(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{On("runtime.unhandledrejection",{reason:DL(e.reason)})}))}function On(e,t={}){const r={at:new Date().toISOString(),event:ed(e,80),data:zC({...t,visibility:t.visibility??CL(),online:t.online??xL(),viewport:t.viewport??jC()})},s=OC();return s.push(r),_L(s.slice(-BC)),r}function OC(){try{const e=window.localStorage.getItem(LC);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(vL).filter(r=>r!==null).slice(-BC):[]}catch{return[]}}async function o_(e,t=fetch){if(Vo)return Vo;const r=OC(),s={reason:ed(e,80),events:r},l=JSON.stringify(s);Vo=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:l.length<48e3,body:l});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await Vo}finally{Vo=null}}function _L(e){try{window.localStorage.setItem(LC,JSON.stringify(e))}catch{}}function vL(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:ed(t.event,80),...t.data&&typeof t.data=="object"?{data:zC(t.data)}:{}}}function zC(e){const t={};for(const[r,s]of Object.entries(e).slice(0,pL)){const l=ed(r,64);if(!l||bL(l))continue;const c=yL(s);c!==void 0&&(t[l]=c)}return t}function bL(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function yL(e){if(typeof e=="string")return SL(e,mL);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function ed(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function SL(e,t){return wL(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function wL(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 CL(){return typeof document>"u"?void 0:document.visibilityState}function xL(){return typeof navigator>"u"?void 0:navigator.onLine}function jC(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function kL(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function EL(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function TL(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 DL(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function RL(e){return{source:Op(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:Op(e.terminalId)}:{},...e?.detail?{detail:Op(e.detail)}:{}}}function ML(e){return{invalidationSource:e.source}}function NL(e){On("auth.session_invalid.request",PC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),o_("session-invalid-request").catch(()=>{}))}function AL(e,t){On("auth.session_invalid.result",{...PC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),o_("session-invalid-result").catch(()=>{}))}function PC(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 Op(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function LL({api:e,serverApi:t,activeAgentId:r=null,onSelectServer:s}){const l=v.useMemo(()=>e??zh(),[e]),c=v.useMemo(()=>t??hc(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let A=!1;return l.getSession().then(B=>{A||(p(B),f(null))}).catch(B=>{A||(f(Ma(B)),p(null))}),()=>{A=!0}},[l]);const S=jL(h);v.useEffect(()=>{const A=b.current;On("auth.view",{view:S,previousView:A,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),A==="workspace"&&S!=="workspace"&&o_(`auth-left-workspace-${S}`).catch(()=>{}),b.current=S},[h,S]);async function w(){const A=await l.getSession();p(A),f(null)}async function x(){Tp(),Bp(),v0(),f(null),p(null);try{await w()}catch(A){f(Ma(A))}}function D(A){const B=RL(A);if(NL(B),y.current)return y.current;const Y=(async()=>{f(null);try{const P=await l.getSession(ML(B));if(AL(B,P.authenticated),p(P),P.authenticated){sA();return}Tp(),Bp(),v0()}catch(P){f(Ma(P))}finally{y.current=null}})();return y.current=Y,Y}if(S==="workspace")return m.jsx(H5,{api:l,serverApi:c,activeAgentId:r,onSelectServer:s,sessionExpiresAt:h?.expiresAt??null,previewMode:h?.previewMode===!0,onSessionInvalid:A=>{D(A)},onLogout:async()=>{Tp(),Bp();const A=await l.logout();p(A)}});const L={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(J0,{size:26}),m.jsxs("div",{children:[m.jsx(ew,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:L[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{x()},children:"Retry"}):null,S==="setup_password"?m.jsx(BL,{api:l,onSession:A=>{p(A)}}):null,S==="setup_totp"?m.jsx(fL,{api:l,onDone:()=>{w()}}):null,S==="login"?m.jsx(OL,{api:l,session:h,onSession:p,onRefresh:w}):null,S==="reauth"?m.jsx(zL,{api:l,session:h,onSession:p,onFullLogin:()=>p(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function BL({api:e,onSession:t}){const[r,s]=v.useState(""),[l,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function y(b){b.preventDefault(),p(!0),f(null);try{if(r!==l){f("Passwords do not match");return}t(await e.setupPassword({password:r}))}catch(S){f(Ma(S))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:y,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:r,onChange:b=>s(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:l,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||r.length<8||l.length<8,children:"Set password"})]})}function OL({api:e,session:t,onSession:r,onRefresh:s}){const[l,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[y,b]=v.useState(!1),[S,w]=v.useState(null),x=t?.totpEnabled??!1,D=t?.currentIpWhitelisted??!1;async function L(A){A.preventDefault(),b(!0),w(null);try{r(await e.login({password:l,...x?{otp:h}:{},rememberNetwork:g}))}catch(B){w(Ma(B))}finally{b(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:L,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:l,onChange:A=>c(A.currentTarget.value),required:!0})]}),x?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:A=>p(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,D?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:y||l.length===0||x&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{s()},disabled:y,children:"Refresh"})]})]})}function zL({api:e,session:t,onSession:r,onFullLogin:s}){const l=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,y]=v.useState(!1),[b,S]=v.useState(!1),[w,x]=v.useState(!1),[D,L]=v.useState(null),A=Mi.useCallback(async(Y,P)=>{y(!0),L(null);try{r(await e.reauth({...Y?{otp:Y}:{},rememberNetwork:P}))}catch(q){L(Ma(q))}finally{y(!1)}},[e,r]);v.useEffect(()=>{if(l){let Y=!1;S(!0),x(!1),L(null);const P=window.setTimeout(()=>{Y||x(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(q=>{Y||r(q)}).catch(q=>{Y||(L(Ma(q)),x(!0))}).finally(()=>{window.clearTimeout(P),Y||S(!1)}),()=>{Y=!0,window.clearTimeout(P)}}},[e,l,r]);async function B(Y){Y.preventDefault(),await A(c,p)}return l&&b&&!w&&!D?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:B,children:[l&&w&&!D?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:Y=>h(Y.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:Y=>g(Y.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),D?m.jsx("p",{className:"form-error",children:D}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:s,disabled:f,children:"Use password instead"})]})]})}function jL(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function Ma(e){return e instanceof Error?e.message:"Request failed"}const V0="NTerminal",hg="nterminal.activeAgentId";function PL(){const[e,t]=v.useState(()=>HL()),r=v.useMemo(()=>zh(),[]),s=v.useMemo(()=>hc(e),[e]);v.useEffect(()=>{const c=()=>{const h=Q3();document.title=h>0?`(${h}) ${V0}`:V0};return c(),Z3(c)},[]);function l(c){IL(c),t(c)}return m.jsx(LL,{api:r,activeAgentId:e,serverApi:s,onSelectServer:l})}function HL(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hg);return e&&e.trim()?e:null}catch{return null}}function IL(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(hg,e);return}window.localStorage.removeItem(hg)}catch{}}const Y0=["gesturestart","gesturechange","gestureend"],UL=[".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 KL(e=window){if(!FL(e))return()=>{};const t={passive:!1},r=e.document;function s(c){c.cancelable&&c.preventDefault()}function l(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!WL(c.target))&&s(c)}for(const c of Y0)r.addEventListener(c,s,t);return r.addEventListener("touchmove",l,t),r.addEventListener("dblclick",s,t),()=>{for(const c of Y0)r.removeEventListener(c,s,t);r.removeEventListener("touchmove",l,t),r.removeEventListener("dblclick",s,t)}}function WL(e){return e instanceof Element&&e.closest(UL)!==null}function FL(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}gL();_N();KL();gg();jk.createRoot(document.getElementById("root")).render(m.jsx(Mi.StrictMode,{children:m.jsx(PL,{})}));export{Mi as R,Dk as g,m as j};
|