nterminal 1.2.55 → 1.2.57
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-D-oOD4FK.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-CZrc3zaR.js → TranscriptMarkdownBody-BDE5VmlN.js} +1 -1
- package/dist/client/assets/index-1p5j5ZUZ.js +54 -0
- package/dist/client/assets/index-BIczcK4f.css +1 -0
- package/dist/client/assets/{index-WieImnbS.js → index-DLVKSDlo.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/terminal/TmuxPtyAdapter.d.ts +28 -2
- package/dist/server/terminal/TmuxPtyAdapter.js +295 -122
- package/dist/server/terminal/TmuxPtyAdapter.js.map +1 -1
- package/dist/server/terminal/codexTranscriptSource.d.ts +5 -0
- package/dist/server/terminal/codexTranscriptSource.js +140 -82
- package/dist/server/terminal/codexTranscriptSource.js.map +1 -1
- package/dist/server/terminal/procfs.d.ts +8 -0
- package/dist/server/terminal/procfs.js +113 -0
- package/dist/server/terminal/procfs.js.map +1 -0
- package/dist/server/terminal/sessionId.d.ts +3 -0
- package/dist/server/terminal/sessionId.js +10 -0
- package/dist/server/terminal/sessionId.js.map +1 -0
- package/dist/server/terminal/ttlCache.d.ts +8 -0
- package/dist/server/terminal/ttlCache.js +33 -0
- package/dist/server/terminal/ttlCache.js.map +1 -0
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-CCE_ITdh.js +0 -1
- package/dist/client/assets/index-EhJZer0I.css +0 -1
- package/dist/client/assets/index-LXA2msdF.js +0 -54
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-D-oOD4FK.js","assets/index-DLVKSDlo.js","assets/TranscriptMarkdownBody-BDE5VmlN.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();function Zx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rf={exports:{}},vo={};var lb;function Qx(){if(lb)return vo;lb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,o,c){var h=null;if(c!==void 0&&(h=""+c),o.key!==void 0&&(h=""+o.key),"key"in o){c={};for(var p in o)p!=="key"&&(c[p]=o[p])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:h,ref:o!==void 0?o:null,props:c}}return vo.Fragment=t,vo.jsx=s,vo.jsxs=s,vo}var ob;function Jx(){return ob||(ob=1,Rf.exports=Qx()),Rf.exports}var m=Jx(),Mf={exports:{}},$e={};var cb;function eE(){if(cb)return $e;cb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),w=Symbol.iterator;function S(R){return R===null||typeof R!="object"?null:(R=w&&R[w]||R["@@iterator"],typeof R=="function"?R:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,B={};function A(R,H,ee){this.props=R,this.context=H,this.refs=B,this.updater=ee||E}A.prototype.isReactComponent={},A.prototype.setState=function(R,H){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,H,"setState")},A.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=A.prototype;function I(R,H,ee){this.props=R,this.context=H,this.refs=B,this.updater=ee||E}var P=I.prototype=new N;P.constructor=I,T(P,A.prototype),P.isPureReactComponent=!0;var te=Array.isArray;function Q(){}var le={H:null,A:null,T:null,S:null},oe=Object.prototype.hasOwnProperty;function ve(R,H,ee){var he=ee.ref;return{$$typeof:e,type:R,key:H,ref:he!==void 0?he:null,props:ee}}function Ce(R,H){return ve(R.type,H,R.props)}function ie(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function J(R){var H={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ee){return H[ee]})}var F=/\/+/g;function K(R,H){return typeof R=="object"&&R!==null&&R.key!=null?J(""+R.key):H.toString(36)}function se(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(Q,Q):(R.status="pending",R.then(function(H){R.status==="pending"&&(R.status="fulfilled",R.value=H)},function(H){R.status==="pending"&&(R.status="rejected",R.reason=H)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function L(R,H,ee,he,we){var xe=typeof R;(xe==="undefined"||xe==="boolean")&&(R=null);var Re=!1;if(R===null)Re=!0;else switch(xe){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(R.$$typeof){case e:case t:Re=!0;break;case b:return Re=R._init,L(Re(R._payload),H,ee,he,we)}}if(Re)return we=we(R),Re=he===""?"."+K(R,0):he,te(we)?(ee="",Re!=null&&(ee=Re.replace(F,"$&/")+"/"),L(we,H,ee,"",function(X){return X})):we!=null&&(ie(we)&&(we=Ce(we,ee+(we.key==null||R&&R.key===we.key?"":(""+we.key).replace(F,"$&/")+"/")+Re)),H.push(we)),1;Re=0;var Ye=he===""?".":he+":";if(te(R))for(var _e=0;_e<R.length;_e++)he=R[_e],xe=Ye+K(he,_e),Re+=L(he,H,ee,xe,we);else if(_e=S(R),typeof _e=="function")for(R=_e.call(R),_e=0;!(he=R.next()).done;)he=he.value,xe=Ye+K(he,_e++),Re+=L(he,H,ee,xe,we);else if(xe==="object"){if(typeof R.then=="function")return L(se(R),H,ee,he,we);throw H=String(R),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return Re}function Y(R,H,ee){if(R==null)return R;var he=[],we=0;return L(R,he,"","",function(xe){return H.call(ee,xe,we++)}),he}function D(R){if(R._status===-1){var H=R._result;H=H(),H.then(function(ee){(R._status===0||R._status===-1)&&(R._status=1,R._result=ee)},function(ee){(R._status===0||R._status===-1)&&(R._status=2,R._result=ee)}),R._status===-1&&(R._status=0,R._result=H)}if(R._status===1)return R._result.default;throw R._result}var Z=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},ge={map:Y,forEach:function(R,H,ee){Y(R,function(){H.apply(this,arguments)},ee)},count:function(R){var H=0;return Y(R,function(){H++}),H},toArray:function(R){return Y(R,function(H){return H})||[]},only:function(R){if(!ie(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return $e.Activity=y,$e.Children=ge,$e.Component=A,$e.Fragment=s,$e.Profiler=o,$e.PureComponent=I,$e.StrictMode=r,$e.Suspense=g,$e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=le,$e.__COMPILER_RUNTIME={__proto__:null,c:function(R){return le.H.useMemoCache(R)}},$e.cache=function(R){return function(){return R.apply(null,arguments)}},$e.cacheSignal=function(){return null},$e.cloneElement=function(R,H,ee){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var he=T({},R.props),we=R.key;if(H!=null)for(xe in H.key!==void 0&&(we=""+H.key),H)!oe.call(H,xe)||xe==="key"||xe==="__self"||xe==="__source"||xe==="ref"&&H.ref===void 0||(he[xe]=H[xe]);var xe=arguments.length-2;if(xe===1)he.children=ee;else if(1<xe){for(var Re=Array(xe),Ye=0;Ye<xe;Ye++)Re[Ye]=arguments[Ye+2];he.children=Re}return ve(R.type,we,he)},$e.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},$e.createElement=function(R,H,ee){var he,we={},xe=null;if(H!=null)for(he in H.key!==void 0&&(xe=""+H.key),H)oe.call(H,he)&&he!=="key"&&he!=="__self"&&he!=="__source"&&(we[he]=H[he]);var Re=arguments.length-2;if(Re===1)we.children=ee;else if(1<Re){for(var Ye=Array(Re),_e=0;_e<Re;_e++)Ye[_e]=arguments[_e+2];we.children=Ye}if(R&&R.defaultProps)for(he in Re=R.defaultProps,Re)we[he]===void 0&&(we[he]=Re[he]);return ve(R,xe,we)},$e.createRef=function(){return{current:null}},$e.forwardRef=function(R){return{$$typeof:p,render:R}},$e.isValidElement=ie,$e.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:D}},$e.memo=function(R,H){return{$$typeof:f,type:R,compare:H===void 0?null:H}},$e.startTransition=function(R){var H=le.T,ee={};le.T=ee;try{var he=R(),we=le.S;we!==null&&we(ee,he),typeof he=="object"&&he!==null&&typeof he.then=="function"&&he.then(Q,Z)}catch(xe){Z(xe)}finally{H!==null&&ee.types!==null&&(H.types=ee.types),le.T=H}},$e.unstable_useCacheRefresh=function(){return le.H.useCacheRefresh()},$e.use=function(R){return le.H.use(R)},$e.useActionState=function(R,H,ee){return le.H.useActionState(R,H,ee)},$e.useCallback=function(R,H){return le.H.useCallback(R,H)},$e.useContext=function(R){return le.H.useContext(R)},$e.useDebugValue=function(){},$e.useDeferredValue=function(R,H){return le.H.useDeferredValue(R,H)},$e.useEffect=function(R,H){return le.H.useEffect(R,H)},$e.useEffectEvent=function(R){return le.H.useEffectEvent(R)},$e.useId=function(){return le.H.useId()},$e.useImperativeHandle=function(R,H,ee){return le.H.useImperativeHandle(R,H,ee)},$e.useInsertionEffect=function(R,H){return le.H.useInsertionEffect(R,H)},$e.useLayoutEffect=function(R,H){return le.H.useLayoutEffect(R,H)},$e.useMemo=function(R,H){return le.H.useMemo(R,H)},$e.useOptimistic=function(R,H){return le.H.useOptimistic(R,H)},$e.useReducer=function(R,H,ee){return le.H.useReducer(R,H,ee)},$e.useRef=function(R){return le.H.useRef(R)},$e.useState=function(R){return le.H.useState(R)},$e.useSyncExternalStore=function(R,H,ee){return le.H.useSyncExternalStore(R,H,ee)},$e.useTransition=function(){return le.H.useTransition()},$e.version="19.2.6",$e}var ub;function Um(){return ub||(ub=1,Mf.exports=eE()),Mf.exports}var v=Um();const Ei=Zx(v);var Nf={exports:{}},yo={},Af={exports:{}},Lf={};var hb;function tE(){return hb||(hb=1,(function(e){function t(L,Y){var D=L.length;L.push(Y);e:for(;0<D;){var Z=D-1>>>1,ge=L[Z];if(0<o(ge,Y))L[Z]=Y,L[D]=ge,D=Z;else break e}}function s(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var Y=L[0],D=L.pop();if(D!==Y){L[0]=D;e:for(var Z=0,ge=L.length,R=ge>>>1;Z<R;){var H=2*(Z+1)-1,ee=L[H],he=H+1,we=L[he];if(0>o(ee,D))he<ge&&0>o(we,ee)?(L[Z]=we,L[he]=D,Z=he):(L[Z]=ee,L[H]=D,Z=H);else if(he<ge&&0>o(we,D))L[Z]=we,L[he]=D,Z=he;else break e}}return Y}function o(L,Y){var D=L.sortIndex-Y.sortIndex;return D!==0?D:L.id-Y.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var h=Date,p=h.now();e.unstable_now=function(){return h.now()-p}}var g=[],f=[],b=1,y=null,w=3,S=!1,E=!1,T=!1,B=!1,A=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function P(L){for(var Y=s(f);Y!==null;){if(Y.callback===null)r(f);else if(Y.startTime<=L)r(f),Y.sortIndex=Y.expirationTime,t(g,Y);else break;Y=s(f)}}function te(L){if(T=!1,P(L),!E)if(s(g)!==null)E=!0,Q||(Q=!0,J());else{var Y=s(f);Y!==null&&se(te,Y.startTime-L)}}var Q=!1,le=-1,oe=5,ve=-1;function Ce(){return B?!0:!(e.unstable_now()-ve<oe)}function ie(){if(B=!1,Q){var L=e.unstable_now();ve=L;var Y=!0;try{e:{E=!1,T&&(T=!1,N(le),le=-1),S=!0;var D=w;try{t:{for(P(L),y=s(g);y!==null&&!(y.expirationTime>L&&Ce());){var Z=y.callback;if(typeof Z=="function"){y.callback=null,w=y.priorityLevel;var ge=Z(y.expirationTime<=L);if(L=e.unstable_now(),typeof ge=="function"){y.callback=ge,P(L),Y=!0;break t}y===s(g)&&r(g),P(L)}else r(g);y=s(g)}if(y!==null)Y=!0;else{var R=s(f);R!==null&&se(te,R.startTime-L),Y=!1}}break e}finally{y=null,w=D,S=!1}Y=void 0}}finally{Y?J():Q=!1}}}var J;if(typeof I=="function")J=function(){I(ie)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,K=F.port2;F.port1.onmessage=ie,J=function(){K.postMessage(null)}}else J=function(){A(ie,0)};function se(L,Y){le=A(function(){L(e.unstable_now())},Y)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):oe=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(L){switch(w){case 1:case 2:case 3:var Y=3;break;default:Y=w}var D=w;w=Y;try{return L()}finally{w=D}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(L,Y){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var D=w;w=L;try{return Y()}finally{w=D}},e.unstable_scheduleCallback=function(L,Y,D){var Z=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?Z+D:Z):D=Z,L){case 1:var ge=-1;break;case 2:ge=250;break;case 5:ge=1073741823;break;case 4:ge=1e4;break;default:ge=5e3}return ge=D+ge,L={id:b++,callback:Y,priorityLevel:L,startTime:D,expirationTime:ge,sortIndex:-1},D>Z?(L.sortIndex=D,t(f,L),s(g)===null&&L===s(f)&&(T?(N(le),le=-1):T=!0,se(te,D-Z))):(L.sortIndex=ge,t(g,L),E||S||(E=!0,Q||(Q=!0,J()))),L},e.unstable_shouldYield=Ce,e.unstable_wrapCallback=function(L){var Y=w;return function(){var D=w;w=Y;try{return L.apply(this,arguments)}finally{w=D}}}})(Lf)),Lf}var db;function iE(){return db||(db=1,Af.exports=tE()),Af.exports}var Bf={exports:{}},Zi={};var fb;function nE(){if(fb)return Zi;fb=1;var e=Um();function t(g){var f="https://react.dev/errors/"+g;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)f+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var r={d:{f:s,r:function(){throw Error(t(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,f,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:g,containerInfo:f,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(g,f){if(g==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Zi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Zi.createPortal=function(g,f){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return c(g,f,null,b)},Zi.flushSync=function(g){var f=h.T,b=r.p;try{if(h.T=null,r.p=2,g)return g()}finally{h.T=f,r.p=b,r.d.f()}},Zi.preconnect=function(g,f){typeof g=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(g,f))},Zi.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Zi.preinit=function(g,f){if(typeof g=="string"&&f&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin),w=typeof f.integrity=="string"?f.integrity:void 0,S=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;b==="style"?r.d.S(g,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:y,integrity:w,fetchPriority:S}):b==="script"&&r.d.X(g,{crossOrigin:y,integrity:w,fetchPriority:S,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Zi.preinitModule=function(g,f){if(typeof g=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var b=p(f.as,f.crossOrigin);r.d.M(g,{crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(g)},Zi.preload=function(g,f){if(typeof g=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var b=f.as,y=p(b,f.crossOrigin);r.d.L(g,b,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Zi.preloadModule=function(g,f){if(typeof g=="string")if(f){var b=p(f.as,f.crossOrigin);r.d.m(g,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:b,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(g)},Zi.requestFormReset=function(g){r.d.r(g)},Zi.unstable_batchedUpdates=function(g,f){return g(f)},Zi.useFormState=function(g,f,b){return h.H.useFormState(g,f,b)},Zi.useFormStatus=function(){return h.H.useHostTransitionStatus()},Zi.version="19.2.6",Zi}var pb;function _0(){if(pb)return Bf.exports;pb=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(),Bf.exports=nE(),Bf.exports}var mb;function sE(){if(mb)return yo;mb=1;var e=iE(),t=Um(),s=_0();function r(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 o(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(r(188))}function f(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(r(188));return n!==i?null:i}for(var a=i,l=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===l)return g(u),n;d=d.sibling}throw Error(r(188))}if(a.return!==l.return)a=u,l=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,l=d;break}if(C===l){_=!0,l=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,l=u;break}if(C===l){_=!0,l=d,a=u;break}C=C.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:n}function b(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=b(i),n!==null)return n;i=i.sibling}return null}var y=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),oe=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),Ce=Symbol.for("react.memo_cache_sentinel"),ie=Symbol.iterator;function J(i){return i===null||typeof i!="object"?null:(i=ie&&i[ie]||i["@@iterator"],typeof i=="function"?i:null)}var F=Symbol.for("react.client.reference");function K(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===F?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case A:return"Profiler";case B:return"StrictMode";case te:return"Suspense";case Q:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case E:return"Portal";case I:return i.displayName||"Context";case N: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 le:return n=i.displayName||null,n!==null?n:K(i.type)||"Memo";case oe:n=i._payload,i=i._init;try{return K(i(n))}catch{}}return null}var se=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},Z=[],ge=-1;function R(i){return{current:i}}function H(i){0>ge||(i.current=Z[ge],Z[ge]=null,ge--)}function ee(i,n){ge++,Z[ge]=i.current,i.current=n}var he=R(null),we=R(null),xe=R(null),Re=R(null);function Ye(i,n){switch(ee(xe,n),ee(we,i),ee(he,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?My(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=My(n),i=Ny(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}H(he),ee(he,i)}function _e(){H(he),H(we),H(xe)}function X(i){i.memoizedState!==null&&ee(Re,i);var n=he.current,a=Ny(n,i.type);n!==a&&(ee(we,i),ee(he,a))}function ce(i){we.current===i&&(H(he),H(we)),Re.current===i&&(H(Re),po._currentValue=D)}var Ee,be;function De(i){if(Ee===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Ee=n&&n[1]||"",be=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Ee+i+be}var Be=!1;function Ie(i,n){if(!i||Be)return"";Be=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(G){var V=G}Reflect.construct(i,[],de)}else{try{de.call()}catch(G){V=G}i.call(de.prototype)}}else{try{throw Error()}catch(G){V=G}(de=i())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(G){if(G&&V&&typeof G.stack=="string")return[G.stack,V.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=l.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var M=_.split(`
|
|
5
|
+
`),$=C.split(`
|
|
6
|
+
`);for(u=l=0;l<M.length&&!M[l].includes("DetermineComponentFrameRoot");)l++;for(;u<$.length&&!$[u].includes("DetermineComponentFrameRoot");)u++;if(l===M.length||u===$.length)for(l=M.length-1,u=$.length-1;1<=l&&0<=u&&M[l]!==$[u];)u--;for(;1<=l&&0<=u;l--,u--)if(M[l]!==$[u]){if(l!==1||u!==1)do if(l--,u--,0>u||M[l]!==$[u]){var re=`
|
|
7
|
+
`+M[l].replace(" at new "," at ");return i.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",i.displayName)),re}while(1<=l&&0<=u);break}}}finally{Be=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?De(a):""}function ae(i,n){switch(i.tag){case 26:case 27:case 5:return De(i.type);case 16:return De("Lazy");case 13:return i.child!==n&&n!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Ie(i.type,!1);case 11:return Ie(i.type.render,!1);case 1:return Ie(i.type,!0);case 31:return De("Activity");default:return""}}function Te(i){try{var n="",a=null;do n+=ae(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var Le=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,ze=e.unstable_cancelCallback,ht=e.unstable_shouldYield,Xe=e.unstable_requestPaint,ot=e.unstable_now,gi=e.unstable_getCurrentPriorityLevel,Ji=e.unstable_ImmediatePriority,qi=e.unstable_UserBlockingPriority,$t=e.unstable_NormalPriority,_i=e.unstable_LowPriority,_n=e.unstable_IdlePriority,W=e.log,We=e.unstable_setDisableYieldValue,ut=null,gt=null;function vi(i){if(typeof W=="function"&&We(i),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(ut,i)}catch{}}var bt=Math.clz32?Math.clz32:An,It=Math.log,en=Math.LN2;function An(i){return i>>>=0,i===0?32:31-(It(i)/en|0)|0}var yi=256,ln=262144,Et=4194304;function kt(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 Tt(i,n,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=l&134217727;return C!==0?(l=C&~d,l!==0?u=kt(l):(_&=C,_!==0?u=kt(_):a||(a=C&~i,a!==0&&(u=kt(a))))):(C=l&~d,C!==0?u=kt(C):_!==0?u=kt(_):a||(a=l&~i,a!==0&&(u=kt(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 bi(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function ii(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 Yt(){var i=Et;return Et<<=1,(Et&62914560)===0&&(Et=4194304),i}function oi(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function Ti(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Dt(i,n,a,l,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,M=i.expirationTimes,$=i.hiddenUpdates;for(a=_&~a;0<a;){var re=31-bt(a),de=1<<re;C[re]=0,M[re]=-1;var V=$[re];if(V!==null)for($[re]=null,re=0;re<V.length;re++){var G=V[re];G!==null&&(G.lane&=-536870913)}a&=~de}l!==0&&ji(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function ji(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-bt(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ni(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-bt(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function $i(i,n){var a=n&-n;return a=(a&42)!==0?1:vn(a),(a&(i.suspendedLanes|n))!==0?0:a}function vn(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function tn(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Hi(){var i=Y.p;return i!==0?i:(i=window.event,i===void 0?32:eb(i.type))}function _t(i,n){var a=Y.p;try{return Y.p=i,n()}finally{Y.p=a}}var Ui=Math.random().toString(36).slice(2),Kt="__reactFiber$"+Ui,Vt="__reactProps$"+Ui,At="__reactContainer$"+Ui,Ur="__reactEvents$"+Ui,Da="__reactListeners$"+Ui,Pr="__reactHandles$"+Ui,Ir="__reactResources$"+Ui,bs="__reactMarker$"+Ui;function Ys(i){delete i[Kt],delete i[Vt],delete i[Ur],delete i[Da],delete i[Pr]}function Yi(i){var n=i[Kt];if(n)return n;for(var a=i.parentNode;a;){if(n=a[At]||a[Kt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=Hy(i);i!==null;){if(a=i[Kt])return a;i=Hy(i)}return n}i=a,a=i.parentNode}return null}function Ln(i){if(i=i[Kt]||i[At]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function rs(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(r(33))}function yn(i){var n=i[Ir];return n||(n=i[Ir]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Xt(i){i[bs]=!0}var Kr=new Set,Vs={};function on(i,n){Bn(i,n),Bn(i+"Capture",n)}function Bn(i,n){for(Vs[i]=n,i=0;i<n.length;i++)Kr.add(n[i])}var Nl=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Fr={},Ra={};function Ma(i){return Le.call(Ra,i)?!0:Le.call(Fr,i)?!1:Nl.test(i)?Ra[i]=!0:(Fr[i]=!0,!1)}function Xs(i,n,a){if(Ma(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function as(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 bn(i,n,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+l)}}function Ft(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ls(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function rt(i,n,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,d=l.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:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function Vi(i){if(!i._valueTracker){var n=ls(i)?"checked":"value";i._valueTracker=rt(i,n,""+i[n])}}function Wr(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=ls(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function Ss(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 qr=/[\n"\\]/g;function Xi(i){return i.replace(qr,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function O(i,n,a,l,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=""+Ft(n)):i.value!==""+Ft(n)&&(i.value=""+Ft(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?Fe(i,_,Ft(n)):a!=null?Fe(i,_,Ft(a)):l!=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=""+Ft(C):i.removeAttribute("name")}function pe(i,n,a,l,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)){Vi(i);return}a=a!=null?""+Ft(a):"",n=n!=null?""+Ft(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=C?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),Vi(i)}function Fe(i,n,a){n==="number"&&Ss(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function Pe(i,n,a,l){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&&l&&(i[a].defaultSelected=!0)}else{for(a=""+Ft(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function Ge(i,n,a){if(n!=null&&(n=""+Ft(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+Ft(a):""}function dt(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(r(92));if(se(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=Ft(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),Vi(i)}function Bt(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Gi=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 Lt(i,n,a){var l=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":l?i.setProperty(n,a):typeof a!="number"||a===0||Gi.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Ot(i,n,a){if(n!=null&&typeof n!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in n)l=n[u],n.hasOwnProperty(u)&&a[u]!==l&&Lt(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&Lt(i,d,n[d])}function On(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 Gt=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"]]),ws=/^[\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 Cs(i){return ws.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function ci(){}var Gs=null;function Zs(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Qs=null,Js=null;function gc(i){var n=Ln(i);if(n&&(i=n.stateNode)){var a=i[Vt]||null;e:switch(i=n.stateNode,n.type){case"input":if(O(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="'+Xi(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[Vt]||null;if(!u)throw Error(r(90));O(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)l=a[n],l.form===i.form&&Wr(l)}break e;case"textarea":Ge(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&Pe(i,!!a.multiple,n,!1)}}}var Al=!1;function Na(i,n,a){if(Al)return i(n,a);Al=!0;try{var l=i(n);return l}finally{if(Al=!1,(Qs!==null||Js!==null)&&(Jc(),Qs&&(n=Qs,i=Js,Js=Qs=null,gc(n),i)))for(n=0;n<i.length;n++)gc(i[n])}}function $r(i,n){var a=i.stateNode;if(a===null)return null;var l=a[Vt]||null;if(l===null)return null;a=l[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":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,n,typeof a));return a}var Gn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zn=!1;if(Gn)try{var os={};Object.defineProperty(os,"passive",{get:function(){Zn=!0}}),window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Zn=!1}var cs=null,x=null,k=null;function j(){if(k)return k;var i,n=x,a=n.length,l,u="value"in cs?cs.value:cs.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&n[a-l]===u[d-l];l++);return k=u.slice(i,1<l?1-l:void 0)}function ne(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 ye(){return!0}function me(){return!1}function Se(i){function n(a,l,u,d,_){this._reactName=a,this._targetInst=u,this.type=l,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)?ye:me,this.isPropagationStopped=me,this}return y(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=ye)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ye)},persist:function(){},isPersistent:ye}),n}var He={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tt=Se(He),Zt=y({},He,{view:0,detail:0}),si=Se(Zt),Aa,Nh,Ll,_c=y({},Zt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lh,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!==Ll&&(Ll&&i.type==="mousemove"?(Aa=i.screenX-Ll.screenX,Nh=i.screenY-Ll.screenY):Nh=Aa=0,Ll=i),Aa)},movementY:function(i){return"movementY"in i?i.movementY:Nh}}),Lg=Se(_c),G1=y({},_c,{dataTransfer:0}),Z1=Se(G1),Q1=y({},Zt,{relatedTarget:0}),Ah=Se(Q1),J1=y({},He,{animationName:0,elapsedTime:0,pseudoElement:0}),eC=Se(J1),tC=y({},He,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),iC=Se(tC),nC=y({},He,{data:0}),Bg=Se(nC),sC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rC={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"},aC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function lC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=aC[i])?!!n[i]:!1}function Lh(){return lC}var oC=y({},Zt,{key:function(i){if(i.key){var n=sC[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=ne(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?rC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lh,charCode:function(i){return i.type==="keypress"?ne(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ne(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),cC=Se(oC),uC=y({},_c,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Og=Se(uC),hC=y({},Zt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lh}),dC=Se(hC),fC=y({},He,{propertyName:0,elapsedTime:0,pseudoElement:0}),pC=Se(fC),mC=y({},_c,{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}),gC=Se(mC),_C=y({},He,{newState:0,oldState:0}),vC=Se(_C),yC=[9,13,27,32],Bh=Gn&&"CompositionEvent"in window,Bl=null;Gn&&"documentMode"in document&&(Bl=document.documentMode);var bC=Gn&&"TextEvent"in window&&!Bl,zg=Gn&&(!Bh||Bl&&8<Bl&&11>=Bl),jg=" ",Hg=!1;function Ug(i,n){switch(i){case"keyup":return yC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pg(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var La=!1;function SC(i,n){switch(i){case"compositionend":return Pg(n);case"keypress":return n.which!==32?null:(Hg=!0,jg);case"textInput":return i=n.data,i===jg&&Hg?null:i;default:return null}}function wC(i,n){if(La)return i==="compositionend"||!Bh&&Ug(i,n)?(i=j(),k=x=cs=null,La=!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 zg&&n.locale!=="ko"?null:n.data;default:return null}}var CC={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 Ig(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!CC[i.type]:n==="textarea"}function Kg(i,n,a,l){Qs?Js?Js.push(l):Js=[l]:Qs=l,n=au(n,"onChange"),0<n.length&&(a=new tt("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var Ol=null,zl=null;function xC(i){xy(i,0)}function vc(i){var n=rs(i);if(Wr(n))return i}function Fg(i,n){if(i==="change")return n}var Wg=!1;if(Gn){var Oh;if(Gn){var zh="oninput"in document;if(!zh){var qg=document.createElement("div");qg.setAttribute("oninput","return;"),zh=typeof qg.oninput=="function"}Oh=zh}else Oh=!1;Wg=Oh&&(!document.documentMode||9<document.documentMode)}function $g(){Ol&&(Ol.detachEvent("onpropertychange",Yg),zl=Ol=null)}function Yg(i){if(i.propertyName==="value"&&vc(zl)){var n=[];Kg(n,zl,i,Zs(i)),Na(xC,n)}}function EC(i,n,a){i==="focusin"?($g(),Ol=n,zl=a,Ol.attachEvent("onpropertychange",Yg)):i==="focusout"&&$g()}function kC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return vc(zl)}function TC(i,n){if(i==="click")return vc(n)}function DC(i,n){if(i==="input"||i==="change")return vc(n)}function RC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var Sn=typeof Object.is=="function"?Object.is:RC;function jl(i,n){if(Sn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),l=Object.keys(n);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!Le.call(n,u)||!Sn(i[u],n[u]))return!1}return!0}function Vg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Xg(i,n){var a=Vg(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=n&&l>=n)return{node:a,offset:n-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Vg(a)}}function Gg(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?Gg(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function Zg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=Ss(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=Ss(i.document)}return n}function jh(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 MC=Gn&&"documentMode"in document&&11>=document.documentMode,Ba=null,Hh=null,Hl=null,Uh=!1;function Qg(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Uh||Ba==null||Ba!==Ss(l)||(l=Ba,"selectionStart"in l&&jh(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Hl&&jl(Hl,l)||(Hl=l,l=au(Hh,"onSelect"),0<l.length&&(n=new tt("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=Ba)))}function Yr(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var Oa={animationend:Yr("Animation","AnimationEnd"),animationiteration:Yr("Animation","AnimationIteration"),animationstart:Yr("Animation","AnimationStart"),transitionrun:Yr("Transition","TransitionRun"),transitionstart:Yr("Transition","TransitionStart"),transitioncancel:Yr("Transition","TransitionCancel"),transitionend:Yr("Transition","TransitionEnd")},Ph={},Jg={};Gn&&(Jg=document.createElement("div").style,"AnimationEvent"in window||(delete Oa.animationend.animation,delete Oa.animationiteration.animation,delete Oa.animationstart.animation),"TransitionEvent"in window||delete Oa.transitionend.transition);function Vr(i){if(Ph[i])return Ph[i];if(!Oa[i])return i;var n=Oa[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in Jg)return Ph[i]=n[a];return i}var e_=Vr("animationend"),t_=Vr("animationiteration"),i_=Vr("animationstart"),NC=Vr("transitionrun"),AC=Vr("transitionstart"),LC=Vr("transitioncancel"),n_=Vr("transitionend"),s_=new Map,Ih="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(" ");Ih.push("scrollEnd");function Qn(i,n){s_.set(i,n),on(n,[i])}var yc=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)},zn=[],za=0,Kh=0;function bc(){for(var i=za,n=Kh=za=0;n<i;){var a=zn[n];zn[n++]=null;var l=zn[n];zn[n++]=null;var u=zn[n];zn[n++]=null;var d=zn[n];if(zn[n++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}d!==0&&r_(a,u,d)}}function Sc(i,n,a,l){zn[za++]=i,zn[za++]=n,zn[za++]=a,zn[za++]=l,Kh|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function Fh(i,n,a,l){return Sc(i,n,a,l),wc(i)}function Xr(i,n){return Sc(i,null,null,n),wc(i)}function r_(i,n,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,l=d.alternate,l!==null&&(l.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-bt(a),i=d.hiddenUpdates,l=i[u],l===null?i[u]=[n]:l.push(n),n.lane=a|536870912),d):null}function wc(i){if(50<ao)throw ao=0,Qd=null,Error(r(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var ja={};function BC(i,n,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wn(i,n,a,l){return new BC(i,n,a,l)}function Wh(i){return i=i.prototype,!(!i||!i.isReactComponent)}function xs(i,n){var a=i.alternate;return a===null?(a=wn(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 a_(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 Cc(i,n,a,l,u,d){var _=0;if(l=i,typeof i=="function")Wh(i)&&(_=1);else if(typeof i=="string")_=Ux(i,a,he.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=wn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case T:return Gr(a.children,u,d,n);case B:_=8,u|=24;break;case A:return i=wn(12,a,n,u|2),i.elementType=A,i.lanes=d,i;case te:return i=wn(13,a,n,u),i.elementType=te,i.lanes=d,i;case Q:return i=wn(19,a,n,u),i.elementType=Q,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case I:_=10;break e;case N:_=9;break e;case P:_=11;break e;case le:_=14;break e;case oe:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return n=wn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function Gr(i,n,a,l){return i=wn(7,i,l,n),i.lanes=a,i}function qh(i,n,a){return i=wn(6,i,null,n),i.lanes=a,i}function l_(i){var n=wn(18,null,null,0);return n.stateNode=i,n}function $h(i,n,a){return n=wn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var o_=new WeakMap;function jn(i,n){if(typeof i=="object"&&i!==null){var a=o_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:Te(n)},o_.set(i,n),n)}return{value:i,source:n,stack:Te(n)}}var Ha=[],Ua=0,xc=null,Ul=0,Hn=[],Un=0,er=null,us=1,hs="";function Es(i,n){Ha[Ua++]=Ul,Ha[Ua++]=xc,xc=i,Ul=n}function c_(i,n,a){Hn[Un++]=us,Hn[Un++]=hs,Hn[Un++]=er,er=i;var l=us;i=hs;var u=32-bt(l)-1;l&=~(1<<u),a+=1;var d=32-bt(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,us=1<<32-bt(n)+u|a<<u|l,hs=d+i}else us=1<<d|a<<u|l,hs=i}function Yh(i){i.return!==null&&(Es(i,1),c_(i,1,0))}function Vh(i){for(;i===xc;)xc=Ha[--Ua],Ha[Ua]=null,Ul=Ha[--Ua],Ha[Ua]=null;for(;i===er;)er=Hn[--Un],Hn[Un]=null,hs=Hn[--Un],Hn[Un]=null,us=Hn[--Un],Hn[Un]=null}function u_(i,n){Hn[Un++]=us,Hn[Un++]=hs,Hn[Un++]=er,us=n.id,hs=n.overflow,er=i}var Pi=null,zt=null,ct=!1,tr=null,Pn=!1,Xh=Error(r(519));function ir(i){var n=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Pl(jn(n,i)),Xh}function h_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[Kt]=i,n[Vt]=l,a){case"dialog":st("cancel",n),st("close",n);break;case"iframe":case"object":case"embed":st("load",n);break;case"video":case"audio":for(a=0;a<oo.length;a++)st(oo[a],n);break;case"source":st("error",n);break;case"img":case"image":case"link":st("error",n),st("load",n);break;case"details":st("toggle",n);break;case"input":st("invalid",n),pe(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":st("invalid",n);break;case"textarea":st("invalid",n),dt(n,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||l.suppressHydrationWarning===!0||Dy(n.textContent,a)?(l.popover!=null&&(st("beforetoggle",n),st("toggle",n)),l.onScroll!=null&&st("scroll",n),l.onScrollEnd!=null&&st("scrollend",n),l.onClick!=null&&(n.onclick=ci),n=!0):n=!1,n||ir(i,!0)}function d_(i){for(Pi=i.return;Pi;)switch(Pi.tag){case 5:case 31:case 13:Pn=!1;return;case 27:case 3:Pn=!0;return;default:Pi=Pi.return}}function Pa(i){if(i!==Pi)return!1;if(!ct)return d_(i),ct=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||pf(i.type,i.memoizedProps)),a=!a),a&&zt&&ir(i),d_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));zt=jy(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));zt=jy(i)}else n===27?(n=zt,gr(i.type)?(i=yf,yf=null,zt=i):zt=n):zt=Pi?Kn(i.stateNode.nextSibling):null;return!0}function Zr(){zt=Pi=null,ct=!1}function Gh(){var i=tr;return i!==null&&(dn===null?dn=i:dn.push.apply(dn,i),tr=null),i}function Pl(i){tr===null?tr=[i]:tr.push(i)}var Zh=R(null),Qr=null,ks=null;function nr(i,n,a){ee(Zh,n._currentValue),n._currentValue=a}function Ts(i){i._currentValue=Zh.current,H(Zh)}function Qh(i,n,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),i===a)break;i=i.return}}function Jh(i,n,a,l){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 M=0;M<n.length;M++)if(C.context===n[M]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),Qh(d.return,a,i),l||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(r(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),Qh(_,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 Ia(i,n,a,l){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(r(387));if(_=_.memoizedProps,_!==null){var C=u.type;Sn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Re.current){if(_=u.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(po):i=[po])}u=u.return}i!==null&&Jh(n,i,a,l),n.flags|=262144}function Ec(i){for(i=i.firstContext;i!==null;){if(!Sn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Jr(i){Qr=i,ks=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ii(i){return f_(Qr,i)}function kc(i,n){return Qr===null&&Jr(i),f_(i,n)}function f_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},ks===null){if(i===null)throw Error(r(308));ks=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else ks=ks.next=n;return a}var OC=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},zC=e.unstable_scheduleCallback,jC=e.unstable_NormalPriority,ui={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ed(){return{controller:new OC,data:new Map,refCount:0}}function Il(i){i.refCount--,i.refCount===0&&zC(jC,function(){i.controller.abort()})}var Kl=null,td=0,Ka=0,Fa=null;function HC(i,n){if(Kl===null){var a=Kl=[];td=0,Ka=rf(),Fa={status:"pending",value:void 0,then:function(l){a.push(l)}}}return td++,n.then(p_,p_),n}function p_(){if(--td===0&&Kl!==null){Fa!==null&&(Fa.status="fulfilled");var i=Kl;Kl=null,Ka=0,Fa=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function UC(i,n){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var m_=L.S;L.S=function(i,n){Qv=ot(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&HC(i,n),m_!==null&&m_(i,n)};var ea=R(null);function id(){var i=ea.current;return i!==null?i:Rt.pooledCache}function Tc(i,n){n===null?ee(ea,ea.current):ee(ea,n.pool)}function g_(){var i=id();return i===null?null:{parent:ui._currentValue,pool:i}}var Wa=Error(r(460)),nd=Error(r(474)),Dc=Error(r(542)),Rc={then:function(){}};function __(i){return i=i.status,i==="fulfilled"||i==="rejected"}function v_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(ci,ci),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,b_(i),i;default:if(typeof n.status=="string")n.then(ci,ci);else{if(i=Rt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=n,i.status="pending",i.then(function(l){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=l}},function(l){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,b_(i),i}throw ia=n,Wa}}function ta(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ia=a,Wa):a}}var ia=null;function y_(){if(ia===null)throw Error(r(459));var i=ia;return ia=null,i}function b_(i){if(i===Wa||i===Dc)throw Error(r(483))}var qa=null,Fl=0;function Mc(i){var n=Fl;return Fl+=1,qa===null&&(qa=[]),v_(qa,i,n)}function Wl(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Nc(i,n){throw n.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(n),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function S_(i){function n(U,z){if(i){var q=U.deletions;q===null?(U.deletions=[z],U.flags|=16):q.push(z)}}function a(U,z){if(!i)return null;for(;z!==null;)n(U,z),z=z.sibling;return null}function l(U){for(var z=new Map;U!==null;)U.key!==null?z.set(U.key,U):z.set(U.index,U),U=U.sibling;return z}function u(U,z){return U=xs(U,z),U.index=0,U.sibling=null,U}function d(U,z,q){return U.index=q,i?(q=U.alternate,q!==null?(q=q.index,q<z?(U.flags|=67108866,z):q):(U.flags|=67108866,z)):(U.flags|=1048576,z)}function _(U){return i&&U.alternate===null&&(U.flags|=67108866),U}function C(U,z,q,ue){return z===null||z.tag!==6?(z=qh(q,U.mode,ue),z.return=U,z):(z=u(z,q),z.return=U,z)}function M(U,z,q,ue){var Ue=q.type;return Ue===T?re(U,z,q.props.children,ue,q.key):z!==null&&(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===oe&&ta(Ue)===z.type)?(z=u(z,q.props),Wl(z,q),z.return=U,z):(z=Cc(q.type,q.key,q.props,null,U.mode,ue),Wl(z,q),z.return=U,z)}function $(U,z,q,ue){return z===null||z.tag!==4||z.stateNode.containerInfo!==q.containerInfo||z.stateNode.implementation!==q.implementation?(z=$h(q,U.mode,ue),z.return=U,z):(z=u(z,q.children||[]),z.return=U,z)}function re(U,z,q,ue,Ue){return z===null||z.tag!==7?(z=Gr(q,U.mode,ue,Ue),z.return=U,z):(z=u(z,q),z.return=U,z)}function de(U,z,q){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=qh(""+z,U.mode,q),z.return=U,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case S:return q=Cc(z.type,z.key,z.props,null,U.mode,q),Wl(q,z),q.return=U,q;case E:return z=$h(z,U.mode,q),z.return=U,z;case oe:return z=ta(z),de(U,z,q)}if(se(z)||J(z))return z=Gr(z,U.mode,q,null),z.return=U,z;if(typeof z.then=="function")return de(U,Mc(z),q);if(z.$$typeof===I)return de(U,kc(U,z),q);Nc(U,z)}return null}function V(U,z,q,ue){var Ue=z!==null?z.key:null;if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return Ue!==null?null:C(U,z,""+q,ue);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case S:return q.key===Ue?M(U,z,q,ue):null;case E:return q.key===Ue?$(U,z,q,ue):null;case oe:return q=ta(q),V(U,z,q,ue)}if(se(q)||J(q))return Ue!==null?null:re(U,z,q,ue,null);if(typeof q.then=="function")return V(U,z,Mc(q),ue);if(q.$$typeof===I)return V(U,z,kc(U,q),ue);Nc(U,q)}return null}function G(U,z,q,ue,Ue){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return U=U.get(q)||null,C(z,U,""+ue,Ue);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case S:return U=U.get(ue.key===null?q:ue.key)||null,M(z,U,ue,Ue);case E:return U=U.get(ue.key===null?q:ue.key)||null,$(z,U,ue,Ue);case oe:return ue=ta(ue),G(U,z,q,ue,Ue)}if(se(ue)||J(ue))return U=U.get(q)||null,re(z,U,ue,Ue,null);if(typeof ue.then=="function")return G(U,z,q,Mc(ue),Ue);if(ue.$$typeof===I)return G(U,z,q,kc(z,ue),Ue);Nc(z,ue)}return null}function Ae(U,z,q,ue){for(var Ue=null,ft=null,je=z,Ze=z=0,lt=null;je!==null&&Ze<q.length;Ze++){je.index>Ze?(lt=je,je=null):lt=je.sibling;var pt=V(U,je,q[Ze],ue);if(pt===null){je===null&&(je=lt);break}i&&je&&pt.alternate===null&&n(U,je),z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt,je=lt}if(Ze===q.length)return a(U,je),ct&&Es(U,Ze),Ue;if(je===null){for(;Ze<q.length;Ze++)je=de(U,q[Ze],ue),je!==null&&(z=d(je,z,Ze),ft===null?Ue=je:ft.sibling=je,ft=je);return ct&&Es(U,Ze),Ue}for(je=l(je);Ze<q.length;Ze++)lt=G(je,U,Ze,q[Ze],ue),lt!==null&&(i&<.alternate!==null&&je.delete(lt.key===null?Ze:lt.key),z=d(lt,z,Ze),ft===null?Ue=lt:ft.sibling=lt,ft=lt);return i&&je.forEach(function(Sr){return n(U,Sr)}),ct&&Es(U,Ze),Ue}function Ke(U,z,q,ue){if(q==null)throw Error(r(151));for(var Ue=null,ft=null,je=z,Ze=z=0,lt=null,pt=q.next();je!==null&&!pt.done;Ze++,pt=q.next()){je.index>Ze?(lt=je,je=null):lt=je.sibling;var Sr=V(U,je,pt.value,ue);if(Sr===null){je===null&&(je=lt);break}i&&je&&Sr.alternate===null&&n(U,je),z=d(Sr,z,Ze),ft===null?Ue=Sr:ft.sibling=Sr,ft=Sr,je=lt}if(pt.done)return a(U,je),ct&&Es(U,Ze),Ue;if(je===null){for(;!pt.done;Ze++,pt=q.next())pt=de(U,pt.value,ue),pt!==null&&(z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return ct&&Es(U,Ze),Ue}for(je=l(je);!pt.done;Ze++,pt=q.next())pt=G(je,U,Ze,pt.value,ue),pt!==null&&(i&&pt.alternate!==null&&je.delete(pt.key===null?Ze:pt.key),z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return i&&je.forEach(function(Gx){return n(U,Gx)}),ct&&Es(U,Ze),Ue}function Ct(U,z,q,ue){if(typeof q=="object"&&q!==null&&q.type===T&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case S:e:{for(var Ue=q.key;z!==null;){if(z.key===Ue){if(Ue=q.type,Ue===T){if(z.tag===7){a(U,z.sibling),ue=u(z,q.props.children),ue.return=U,U=ue;break e}}else if(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===oe&&ta(Ue)===z.type){a(U,z.sibling),ue=u(z,q.props),Wl(ue,q),ue.return=U,U=ue;break e}a(U,z);break}else n(U,z);z=z.sibling}q.type===T?(ue=Gr(q.props.children,U.mode,ue,q.key),ue.return=U,U=ue):(ue=Cc(q.type,q.key,q.props,null,U.mode,ue),Wl(ue,q),ue.return=U,U=ue)}return _(U);case E:e:{for(Ue=q.key;z!==null;){if(z.key===Ue)if(z.tag===4&&z.stateNode.containerInfo===q.containerInfo&&z.stateNode.implementation===q.implementation){a(U,z.sibling),ue=u(z,q.children||[]),ue.return=U,U=ue;break e}else{a(U,z);break}else n(U,z);z=z.sibling}ue=$h(q,U.mode,ue),ue.return=U,U=ue}return _(U);case oe:return q=ta(q),Ct(U,z,q,ue)}if(se(q))return Ae(U,z,q,ue);if(J(q)){if(Ue=J(q),typeof Ue!="function")throw Error(r(150));return q=Ue.call(q),Ke(U,z,q,ue)}if(typeof q.then=="function")return Ct(U,z,Mc(q),ue);if(q.$$typeof===I)return Ct(U,z,kc(U,q),ue);Nc(U,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,z!==null&&z.tag===6?(a(U,z.sibling),ue=u(z,q),ue.return=U,U=ue):(a(U,z),ue=qh(q,U.mode,ue),ue.return=U,U=ue),_(U)):a(U,z)}return function(U,z,q,ue){try{Fl=0;var Ue=Ct(U,z,q,ue);return qa=null,Ue}catch(je){if(je===Wa||je===Dc)throw je;var ft=wn(29,je,null,U.mode);return ft.lanes=ue,ft.return=U,ft}}}var na=S_(!0),w_=S_(!1),sr=!1;function sd(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rd(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 rr(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ar(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(mt&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,n=wc(i),r_(i,null,a),n}return Sc(i,l,n,a),wc(i)}function ql(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ni(i,a)}}function ad(i,n){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){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:l.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var ld=!1;function $l(){if(ld){var i=Fa;if(i!==null)throw i}}function Yl(i,n,a,l){ld=!1;var u=i.updateQueue;sr=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var M=C,$=M.next;M.next=null,_===null?d=$:_.next=$,_=M;var re=i.alternate;re!==null&&(re=re.updateQueue,C=re.lastBaseUpdate,C!==_&&(C===null?re.firstBaseUpdate=$:C.next=$,re.lastBaseUpdate=M))}if(d!==null){var de=u.baseState;_=0,re=$=M=null,C=d;do{var V=C.lane&-536870913,G=V!==C.lane;if(G?(at&V)===V:(l&V)===V){V!==0&&V===Ka&&(ld=!0),re!==null&&(re=re.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Ae=i,Ke=C;V=n;var Ct=a;switch(Ke.tag){case 1:if(Ae=Ke.payload,typeof Ae=="function"){de=Ae.call(Ct,de,V);break e}de=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=Ke.payload,V=typeof Ae=="function"?Ae.call(Ct,de,V):Ae,V==null)break e;de=y({},de,V);break e;case 2:sr=!0}}V=C.callback,V!==null&&(i.flags|=64,G&&(i.flags|=8192),G=u.callbacks,G===null?u.callbacks=[V]:G.push(V))}else G={lane:V,tag:C.tag,payload:C.payload,callback:C.callback,next:null},re===null?($=re=G,M=de):re=re.next=G,_|=V;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;G=C,C=G.next,G.next=null,u.lastBaseUpdate=G,u.shared.pending=null}}while(!0);re===null&&(M=de),u.baseState=M,u.firstBaseUpdate=$,u.lastBaseUpdate=re,d===null&&(u.shared.lanes=0),hr|=_,i.lanes=_,i.memoizedState=de}}function C_(i,n){if(typeof i!="function")throw Error(r(191,i));i.call(n)}function x_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)C_(a[i],n)}var $a=R(null),Ac=R(0);function E_(i,n){i=zs,ee(Ac,i),ee($a,n),zs=i|n.baseLanes}function od(){ee(Ac,zs),ee($a,$a.current)}function cd(){zs=Ac.current,H($a),H(Ac)}var Cn=R(null),In=null;function lr(i){var n=i.alternate;ee(ri,ri.current&1),ee(Cn,i),In===null&&(n===null||$a.current!==null||n.memoizedState!==null)&&(In=i)}function ud(i){ee(ri,ri.current),ee(Cn,i),In===null&&(In=i)}function k_(i){i.tag===22?(ee(ri,ri.current),ee(Cn,i),In===null&&(In=i)):or()}function or(){ee(ri,ri.current),ee(Cn,Cn.current)}function xn(i){H(Cn),In===i&&(In=null),H(ri)}var ri=R(0);function Lc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||_f(a)||vf(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 Ds=0,Ve=null,St=null,hi=null,Bc=!1,Ya=!1,sa=!1,Oc=0,Vl=0,Va=null,PC=0;function Qt(){throw Error(r(321))}function hd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!Sn(i[a],n[a]))return!1;return!0}function dd(i,n,a,l,u,d){return Ds=d,Ve=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,L.H=i===null||i.memoizedState===null?cv:Td,sa=!1,d=a(l,u),sa=!1,Ya&&(d=D_(n,a,l,u)),T_(i),d}function T_(i){L.H=Zl;var n=St!==null&&St.next!==null;if(Ds=0,hi=St=Ve=null,Bc=!1,Vl=0,Va=null,n)throw Error(r(300));i===null||di||(i=i.dependencies,i!==null&&Ec(i)&&(di=!0))}function D_(i,n,a,l){Ve=i;var u=0;do{if(Ya&&(Va=null),Vl=0,Ya=!1,25<=u)throw Error(r(301));if(u+=1,hi=St=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}L.H=uv,d=n(a,l)}while(Ya);return d}function IC(){var i=L.H,n=i.useState()[0];return n=typeof n.then=="function"?Xl(n):n,i=i.useState()[0],(St!==null?St.memoizedState:null)!==i&&(Ve.flags|=1024),n}function fd(){var i=Oc!==0;return Oc=0,i}function pd(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function md(i){if(Bc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Bc=!1}Ds=0,hi=St=Ve=null,Ya=!1,Vl=Oc=0,Va=null}function nn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return hi===null?Ve.memoizedState=hi=i:hi=hi.next=i,hi}function ai(){if(St===null){var i=Ve.alternate;i=i!==null?i.memoizedState:null}else i=St.next;var n=hi===null?Ve.memoizedState:hi.next;if(n!==null)hi=n,St=i;else{if(i===null)throw Ve.alternate===null?Error(r(467)):Error(r(310));St=i,i={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},hi===null?Ve.memoizedState=hi=i:hi=hi.next=i}return hi}function zc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Xl(i){var n=Vl;return Vl+=1,Va===null&&(Va=[]),i=v_(Va,i,n),n=Ve,(hi===null?n.memoizedState:hi.next)===null&&(n=n.alternate,L.H=n===null||n.memoizedState===null?cv:Td),i}function jc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Xl(i);if(i.$$typeof===I)return Ii(i)}throw Error(r(438,String(i)))}function gd(i){var n=null,a=Ve.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Ve.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=zc(),Ve.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),l=0;l<i;l++)a[l]=Ce;return n.index++,a}function Rs(i,n){return typeof n=="function"?n(i):n}function Hc(i){var n=ai();return _d(n,St,i)}function _d(i,n,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var u=i.baseQueue,d=l.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,l.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,M=null,$=n,re=!1;do{var de=$.lane&-536870913;if(de!==$.lane?(at&de)===de:(Ds&de)===de){var V=$.revertLane;if(V===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),de===Ka&&(re=!0);else if((Ds&V)===V){$=$.next,V===Ka&&(re=!0);continue}else de={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},M===null?(C=M=de,_=d):M=M.next=de,Ve.lanes|=V,hr|=V;de=$.action,sa&&a(d,de),d=$.hasEagerState?$.eagerState:a(d,de)}else V={lane:de,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},M===null?(C=M=V,_=d):M=M.next=V,Ve.lanes|=de,hr|=de;$=$.next}while($!==null&&$!==n);if(M===null?_=d:M.next=C,!Sn(d,i.memoizedState)&&(di=!0,re&&(a=Fa,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=M,l.lastRenderedState=d}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function vd(i){var n=ai(),a=n.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=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);Sn(d,n.memoizedState)||(di=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function R_(i,n,a){var l=Ve,u=ai(),d=ct;if(d){if(a===void 0)throw Error(r(407));a=a()}else a=n();var _=!Sn((St||u).memoizedState,a);if(_&&(u.memoizedState=a,di=!0),u=u.queue,Sd(A_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||hi!==null&&hi.memoizedState.tag&1){if(l.flags|=2048,Xa(9,{destroy:void 0},N_.bind(null,l,u,a,n),null),Rt===null)throw Error(r(349));d||(Ds&127)!==0||M_(l,n,a)}return a}function M_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Ve.updateQueue,n===null?(n=zc(),Ve.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function N_(i,n,a,l){n.value=a,n.getSnapshot=l,L_(n)&&B_(i)}function A_(i,n,a){return a(function(){L_(n)&&B_(i)})}function L_(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!Sn(i,a)}catch{return!0}}function B_(i){var n=Xr(i,2);n!==null&&fn(n,i,2)}function yd(i){var n=nn();if(typeof i=="function"){var a=i;if(i=a(),sa){vi(!0);try{a()}finally{vi(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:i},n}function O_(i,n,a,l){return i.baseState=a,_d(i,St,typeof l=="function"?l:Rs)}function KC(i,n,a,l,u){if(Ic(i))throw Error(r(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(_)}};L.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,z_(n,d)):(d.next=a.next,n.pending=a.next=d)}}function z_(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=L.T,_={};L.T=_;try{var C=a(u,l),M=L.S;M!==null&&M(_,C),j_(i,n,C)}catch($){bd(i,n,$)}finally{d!==null&&_.types!==null&&(d.types=_.types),L.T=d}}else try{d=a(u,l),j_(i,n,d)}catch($){bd(i,n,$)}}function j_(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){H_(i,n,l)},function(l){return bd(i,n,l)}):H_(i,n,a)}function H_(i,n,a){n.status="fulfilled",n.value=a,U_(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,z_(i,a)))}function bd(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,U_(n),n=n.next;while(n!==l)}i.action=null}function U_(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function P_(i,n){return n}function I_(i,n){if(ct){var a=Rt.formState;if(a!==null){e:{var l=Ve;if(ct){if(zt){t:{for(var u=zt,d=Pn;u.nodeType!==8;){if(!d){u=null;break t}if(u=Kn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){zt=Kn(u.nextSibling),l=u.data==="F!";break e}}ir(l)}l=!1}l&&(n=a[0])}}return a=nn(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:P_,lastRenderedState:n},a.queue=l,a=av.bind(null,Ve,l),l.dispatch=a,l=yd(!1),d=kd.bind(null,Ve,!1,l.queue),l=nn(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=KC.bind(null,Ve,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function K_(i){var n=ai();return F_(n,St,i)}function F_(i,n,a){if(n=_d(i,n,P_)[0],i=Hc(Rs)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=Xl(n)}catch(_){throw _===Wa?Dc:_}else l=n;n=ai();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Ve.flags|=2048,Xa(9,{destroy:void 0},FC.bind(null,u,a),null)),[l,d,i]}function FC(i,n){i.action=n}function W_(i){var n=ai(),a=St;if(a!==null)return F_(n,a,i);ai(),n=n.memoizedState,a=ai();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function Xa(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Ve.updateQueue,n===null&&(n=zc(),Ve.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,n.lastEffect=i),i}function q_(){return ai().memoizedState}function Uc(i,n,a,l){var u=nn();Ve.flags|=i,u.memoizedState=Xa(1|n,{destroy:void 0},a,l===void 0?null:l)}function Pc(i,n,a,l){var u=ai();l=l===void 0?null:l;var d=u.memoizedState.inst;St!==null&&l!==null&&hd(l,St.memoizedState.deps)?u.memoizedState=Xa(n,d,a,l):(Ve.flags|=i,u.memoizedState=Xa(1|n,d,a,l))}function $_(i,n){Uc(8390656,8,i,n)}function Sd(i,n){Pc(2048,8,i,n)}function WC(i){Ve.flags|=4;var n=Ve.updateQueue;if(n===null)n=zc(),Ve.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function Y_(i){var n=ai().memoizedState;return WC({ref:n,nextImpl:i}),function(){if((mt&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}function V_(i,n){return Pc(4,2,i,n)}function X_(i,n){return Pc(4,4,i,n)}function G_(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 Z_(i,n,a){a=a!=null?a.concat([i]):null,Pc(4,4,G_.bind(null,n,i),a)}function wd(){}function Q_(i,n){var a=ai();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&hd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function J_(i,n){var a=ai();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&hd(n,l[1]))return l[0];if(l=i(),sa){vi(!0);try{i()}finally{vi(!1)}}return a.memoizedState=[l,n],l}function Cd(i,n,a){return a===void 0||(Ds&1073741824)!==0&&(at&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=ey(),Ve.lanes|=i,hr|=i,a)}function ev(i,n,a,l){return Sn(a,n)?a:$a.current!==null?(i=Cd(i,a,l),Sn(i,n)||(di=!0),i):(Ds&42)===0||(Ds&1073741824)!==0&&(at&261930)===0?(di=!0,i.memoizedState=a):(i=ey(),Ve.lanes|=i,hr|=i,n)}function tv(i,n,a,l,u){var d=Y.p;Y.p=d!==0&&8>d?d:8;var _=L.T,C={};L.T=C,kd(i,!1,n,a);try{var M=u(),$=L.S;if($!==null&&$(C,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var re=UC(M,l);Gl(i,n,re,Tn(i))}else Gl(i,n,l,Tn(i))}catch(de){Gl(i,n,{then:function(){},status:"rejected",reason:de},Tn())}finally{Y.p=d,_!==null&&C.types!==null&&(_.types=C.types),L.T=_}}function qC(){}function xd(i,n,a,l){if(i.tag!==5)throw Error(r(476));var u=iv(i).queue;tv(i,u,n,D,a===null?qC:function(){return nv(i),a(l)})}function iv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:D,baseState:D,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:D},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rs,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function nv(i){var n=iv(i);n.next===null&&(n=i.alternate.memoizedState),Gl(i,n.next.queue,{},Tn())}function Ed(){return Ii(po)}function sv(){return ai().memoizedState}function rv(){return ai().memoizedState}function $C(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Tn();i=rr(a);var l=ar(n,i,a);l!==null&&(fn(l,n,a),ql(l,n,a)),n={cache:ed()},i.payload=n;return}n=n.return}}function YC(i,n,a){var l=Tn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ic(i)?lv(n,a):(a=Fh(i,n,a,l),a!==null&&(fn(a,i,l),ov(a,n,l)))}function av(i,n,a){var l=Tn();Gl(i,n,a,l)}function Gl(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ic(i))lv(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,Sn(C,_))return Sc(i,n,u,0),Rt===null&&bc(),!1}catch{}if(a=Fh(i,n,u,l),a!==null)return fn(a,i,l),ov(a,n,l),!0}return!1}function kd(i,n,a,l){if(l={lane:2,revertLane:rf(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ic(i)){if(n)throw Error(r(479))}else n=Fh(i,a,l,2),n!==null&&fn(n,i,2)}function Ic(i){var n=i.alternate;return i===Ve||n!==null&&n===Ve}function lv(i,n){Ya=Bc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function ov(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ni(i,a)}}var Zl={readContext:Ii,use:jc,useCallback:Qt,useContext:Qt,useEffect:Qt,useImperativeHandle:Qt,useLayoutEffect:Qt,useInsertionEffect:Qt,useMemo:Qt,useReducer:Qt,useRef:Qt,useState:Qt,useDebugValue:Qt,useDeferredValue:Qt,useTransition:Qt,useSyncExternalStore:Qt,useId:Qt,useHostTransitionStatus:Qt,useFormState:Qt,useActionState:Qt,useOptimistic:Qt,useMemoCache:Qt,useCacheRefresh:Qt};Zl.useEffectEvent=Qt;var cv={readContext:Ii,use:jc,useCallback:function(i,n){return nn().memoizedState=[i,n===void 0?null:n],i},useContext:Ii,useEffect:$_,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,Uc(4194308,4,G_.bind(null,n,i),a)},useLayoutEffect:function(i,n){return Uc(4194308,4,i,n)},useInsertionEffect:function(i,n){Uc(4,2,i,n)},useMemo:function(i,n){var a=nn();n=n===void 0?null:n;var l=i();if(sa){vi(!0);try{i()}finally{vi(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=nn();if(a!==void 0){var u=a(n);if(sa){vi(!0);try{a(n)}finally{vi(!1)}}}else u=n;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=YC.bind(null,Ve,i),[l.memoizedState,i]},useRef:function(i){var n=nn();return i={current:i},n.memoizedState=i},useState:function(i){i=yd(i);var n=i.queue,a=av.bind(null,Ve,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:wd,useDeferredValue:function(i,n){var a=nn();return Cd(a,i,n)},useTransition:function(){var i=yd(!1);return i=tv.bind(null,Ve,i.queue,!0,!1),nn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Ve,u=nn();if(ct){if(a===void 0)throw Error(r(407));a=a()}else{if(a=n(),Rt===null)throw Error(r(349));(at&127)!==0||M_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,$_(A_.bind(null,l,d,i),[i]),l.flags|=2048,Xa(9,{destroy:void 0},N_.bind(null,l,d,a,n),null),a},useId:function(){var i=nn(),n=Rt.identifierPrefix;if(ct){var a=hs,l=us;a=(l&~(1<<32-bt(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Oc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=PC++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Ed,useFormState:I_,useActionState:I_,useOptimistic:function(i){var n=nn();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=kd.bind(null,Ve,!0,a),a.dispatch=n,[i,n]},useMemoCache:gd,useCacheRefresh:function(){return nn().memoizedState=$C.bind(null,Ve)},useEffectEvent:function(i){var n=nn(),a={impl:i};return n.memoizedState=a,function(){if((mt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Td={readContext:Ii,use:jc,useCallback:Q_,useContext:Ii,useEffect:Sd,useImperativeHandle:Z_,useInsertionEffect:V_,useLayoutEffect:X_,useMemo:J_,useReducer:Hc,useRef:q_,useState:function(){return Hc(Rs)},useDebugValue:wd,useDeferredValue:function(i,n){var a=ai();return ev(a,St.memoizedState,i,n)},useTransition:function(){var i=Hc(Rs)[0],n=ai().memoizedState;return[typeof i=="boolean"?i:Xl(i),n]},useSyncExternalStore:R_,useId:sv,useHostTransitionStatus:Ed,useFormState:K_,useActionState:K_,useOptimistic:function(i,n){var a=ai();return O_(a,St,i,n)},useMemoCache:gd,useCacheRefresh:rv};Td.useEffectEvent=Y_;var uv={readContext:Ii,use:jc,useCallback:Q_,useContext:Ii,useEffect:Sd,useImperativeHandle:Z_,useInsertionEffect:V_,useLayoutEffect:X_,useMemo:J_,useReducer:vd,useRef:q_,useState:function(){return vd(Rs)},useDebugValue:wd,useDeferredValue:function(i,n){var a=ai();return St===null?Cd(a,i,n):ev(a,St.memoizedState,i,n)},useTransition:function(){var i=vd(Rs)[0],n=ai().memoizedState;return[typeof i=="boolean"?i:Xl(i),n]},useSyncExternalStore:R_,useId:sv,useHostTransitionStatus:Ed,useFormState:W_,useActionState:W_,useOptimistic:function(i,n){var a=ai();return St!==null?O_(a,St,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:gd,useCacheRefresh:rv};uv.useEffectEvent=Y_;function Dd(i,n,a,l){n=i.memoizedState,a=a(l,n),a=a==null?n:y({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Rd={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=Tn(),u=rr(l);u.payload=n,a!=null&&(u.callback=a),n=ar(i,u,l),n!==null&&(fn(n,i,l),ql(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=Tn(),u=rr(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=ar(i,u,l),n!==null&&(fn(n,i,l),ql(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Tn(),l=rr(a);l.tag=2,n!=null&&(l.callback=n),n=ar(i,l,a),n!==null&&(fn(n,i,a),ql(n,i,a))}};function hv(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!jl(a,l)||!jl(u,d):!0}function dv(i,n,a,l){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,l),n.state!==i&&Rd.enqueueReplaceState(n,n.state,null)}function ra(i,n){var a=n;if("ref"in n){a={};for(var l in n)l!=="ref"&&(a[l]=n[l])}if(i=i.defaultProps){a===n&&(a=y({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function fv(i){yc(i)}function pv(i){console.error(i)}function mv(i){yc(i)}function Kc(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function gv(i,n,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Md(i,n,a){return a=rr(a),a.tag=3,a.payload={element:null},a.callback=function(){Kc(i,n)},a}function _v(i){return i=rr(i),i.tag=3,i}function vv(i,n,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=l.value;i.payload=function(){return u(d)},i.callback=function(){gv(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){gv(n,a,l),typeof u!="function"&&(dr===null?dr=new Set([this]):dr.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function VC(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&Ia(n,a,u,!0),a=Cn.current,a!==null){switch(a.tag){case 31:case 13:return In===null?eu():a.alternate===null&&Jt===0&&(Jt=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Rc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([l]):n.add(l),tf(i,l,u)),!1;case 22:return a.flags|=65536,l===Rc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([l]):a.add(l)),tf(i,l,u)),!1}throw Error(r(435,a.tag))}return tf(i,l,u),eu(),!1}if(ct)return n=Cn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==Xh&&(i=Error(r(422),{cause:l}),Pl(jn(i,a)))):(l!==Xh&&(n=Error(r(423),{cause:l}),Pl(jn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=jn(l,a),u=Md(i.stateNode,l,u),ad(i,u),Jt!==4&&(Jt=2)),!1;var d=Error(r(520),{cause:l});if(d=jn(d,a),ro===null?ro=[d]:ro.push(d),Jt!==4&&(Jt=2),n===null)return!0;l=jn(l,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Md(a.stateNode,l,i),ad(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"&&(dr===null||!dr.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=_v(u),vv(u,i,a,l),ad(a,u),!1}a=a.return}while(a!==null);return!1}var Nd=Error(r(461)),di=!1;function Ki(i,n,a,l){n.child=i===null?w_(n,null,a,l):na(n,i.child,a,l)}function yv(i,n,a,l,u){a=a.render;var d=n.ref;if("ref"in l){var _={};for(var C in l)C!=="ref"&&(_[C]=l[C])}else _=l;return Jr(n),l=dd(i,n,a,_,d,u),C=fd(),i!==null&&!di?(pd(i,n,u),Ms(i,n,u)):(ct&&C&&Yh(n),n.flags|=1,Ki(i,n,l,u),n.child)}function bv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!Wh(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Sv(i,n,d,l,u)):(i=Cc(a.type,null,l,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!Ud(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:jl,a(_,l)&&i.ref===n.ref)return Ms(i,n,u)}return n.flags|=1,i=xs(d,l),i.ref=n.ref,i.return=n,n.child=i}function Sv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(jl(d,l)&&i.ref===n.ref)if(di=!1,n.pendingProps=l=d,Ud(i,u))(i.flags&131072)!==0&&(di=!0);else return n.lanes=i.lanes,Ms(i,n,u)}return Ad(i,n,a,l,u)}function wv(i,n,a,l){var u=l.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(l=n.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~d}else l=0,n.child=null;return Cv(i,n,d,a,l)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Tc(n,d!==null?d.cachePool:null),d!==null?E_(n,d):od(),k_(n);else return l=n.lanes=536870912,Cv(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Tc(n,d.cachePool),E_(n,d),or(),n.memoizedState=null):(i!==null&&Tc(n,null),od(),or());return Ki(i,n,u,a),n.child}function Ql(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Cv(i,n,a,l,u){var d=id();return d=d===null?null:{parent:ui._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Tc(n,null),od(),k_(n),i!==null&&Ia(i,n,l,!0),n.childLanes=u,null}function Fc(i,n){return n=qc({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function xv(i,n,a){return na(n,i.child,null,a),i=Fc(n,n.pendingProps),i.flags|=2,xn(n),n.memoizedState=null,i}function XC(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(ct){if(l.mode==="hidden")return i=Fc(n,l),n.lanes=536870912,Ql(null,i);if(ud(n),(i=zt)?(i=zy(i,Pn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:er!==null?{id:us,overflow:hs}:null,retryLane:536870912,hydrationErrors:null},a=l_(i),a.return=n,n.child=a,Pi=n,zt=null)):i=null,i===null)throw ir(n);return n.lanes=536870912,null}return Fc(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(ud(n),u)if(n.flags&256)n.flags&=-257,n=xv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(r(558));else if(di||Ia(i,n,a,!1),u=(a&i.childLanes)!==0,di||u){if(l=Rt,l!==null&&(_=$i(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,Xr(i,_),fn(l,i,_),Nd;eu(),n=xv(i,n,a)}else i=d.treeContext,zt=Kn(_.nextSibling),Pi=n,ct=!0,tr=null,Pn=!1,i!==null&&u_(n,i),n=Fc(n,l),n.flags|=4096;return n}return i=xs(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function Wc(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(r(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function Ad(i,n,a,l,u){return Jr(n),a=dd(i,n,a,l,void 0,u),l=fd(),i!==null&&!di?(pd(i,n,u),Ms(i,n,u)):(ct&&l&&Yh(n),n.flags|=1,Ki(i,n,a,u),n.child)}function Ev(i,n,a,l,u,d){return Jr(n),n.updateQueue=null,a=D_(n,l,a,u),T_(i),l=fd(),i!==null&&!di?(pd(i,n,d),Ms(i,n,d)):(ct&&l&&Yh(n),n.flags|=1,Ki(i,n,a,d),n.child)}function kv(i,n,a,l,u){if(Jr(n),n.stateNode===null){var d=ja,_=a.contextType;typeof _=="object"&&_!==null&&(d=Ii(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Rd,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},sd(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Ii(_):ja,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Dd(n,a,_,l),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&&Rd.enqueueReplaceState(d,d.state,null),Yl(n,l,d,u),$l(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,M=ra(a,C);d.props=M;var $=d.context,re=a.contextType;_=ja,typeof re=="object"&&re!==null&&(_=Ii(re));var de=a.getDerivedStateFromProps;re=typeof de=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,re||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||$!==_)&&dv(n,d,l,_),sr=!1;var V=n.memoizedState;d.state=V,Yl(n,l,d,u),$l(),$=n.memoizedState,C||V!==$||sr?(typeof de=="function"&&(Dd(n,a,de,l),$=n.memoizedState),(M=sr||hv(n,a,M,l,V,$,_))?(re||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=l,n.memoizedState=$),d.props=l,d.state=$,d.context=_,l=M):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,rd(i,n),_=n.memoizedProps,re=ra(a,_),d.props=re,de=n.pendingProps,V=d.context,$=a.contextType,M=ja,typeof $=="object"&&$!==null&&(M=Ii($)),C=a.getDerivedStateFromProps,($=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==de||V!==M)&&dv(n,d,l,M),sr=!1,V=n.memoizedState,d.state=V,Yl(n,l,d,u),$l();var G=n.memoizedState;_!==de||V!==G||sr||i!==null&&i.dependencies!==null&&Ec(i.dependencies)?(typeof C=="function"&&(Dd(n,a,C,l),G=n.memoizedState),(re=sr||hv(n,a,re,l,V,G,M)||i!==null&&i.dependencies!==null&&Ec(i.dependencies))?($||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,G,M),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,G,M)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=G),d.props=l,d.state=G,d.context=M,l=re):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&V===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,Wc(i,n),l=(n.flags&128)!==0,d||l?(d=n.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&l?(n.child=na(n,i.child,null,u),n.child=na(n,null,a,u)):Ki(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Ms(i,n,u),i}function Tv(i,n,a,l){return Zr(),n.flags|=256,Ki(i,n,a,l),n.child}var Ld={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bd(i){return{baseLanes:i,cachePool:g_()}}function Od(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=kn),i}function Dv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(ri.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(ct){if(u?lr(n):or(),(i=zt)?(i=zy(i,Pn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:er!==null?{id:us,overflow:hs}:null,retryLane:536870912,hydrationErrors:null},a=l_(i),a.return=n,n.child=a,Pi=n,zt=null)):i=null,i===null)throw ir(n);return vf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(or(),u=n.mode,C=qc({mode:"hidden",children:C},u),l=Gr(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=Bd(a),l.childLanes=Od(i,_,a),n.memoizedState=Ld,Ql(null,l)):(lr(n),zd(n,C))}var M=i.memoizedState;if(M!==null&&(C=M.dehydrated,C!==null)){if(d)n.flags&256?(lr(n),n.flags&=-257,n=jd(i,n,a)):n.memoizedState!==null?(or(),n.child=i.child,n.flags|=128,n=null):(or(),C=l.fallback,u=n.mode,l=qc({mode:"visible",children:l.children},u),C=Gr(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,na(n,i.child,null,a),l=n.child,l.memoizedState=Bd(a),l.childLanes=Od(i,_,a),n.memoizedState=Ld,n=Ql(null,l));else if(lr(n),vf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var $=_.dgst;_=$,l=Error(r(419)),l.stack="",l.digest=_,Pl({value:l,source:null,stack:null}),n=jd(i,n,a)}else if(di||Ia(i,n,a,!1),_=(a&i.childLanes)!==0,di||_){if(_=Rt,_!==null&&(l=$i(_,a),l!==0&&l!==M.retryLane))throw M.retryLane=l,Xr(i,l),fn(_,i,l),Nd;_f(C)||eu(),n=jd(i,n,a)}else _f(C)?(n.flags|=192,n.child=i.child,n=null):(i=M.treeContext,zt=Kn(C.nextSibling),Pi=n,ct=!0,tr=null,Pn=!1,i!==null&&u_(n,i),n=zd(n,l.children),n.flags|=4096);return n}return u?(or(),C=l.fallback,u=n.mode,M=i.child,$=M.sibling,l=xs(M,{mode:"hidden",children:l.children}),l.subtreeFlags=M.subtreeFlags&65011712,$!==null?C=xs($,C):(C=Gr(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,Ql(null,l),l=n.child,C=i.child.memoizedState,C===null?C=Bd(a):(u=C.cachePool,u!==null?(M=ui._currentValue,u=u.parent!==M?{parent:M,pool:M}:u):u=g_(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=Od(i,_,a),n.memoizedState=Ld,Ql(i.child,l)):(lr(n),a=i.child,i=a.sibling,a=xs(a,{mode:"visible",children:l.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 zd(i,n){return n=qc({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function qc(i,n){return i=wn(22,i,null,n),i.lanes=0,i}function jd(i,n,a){return na(n,i.child,null,a),i=zd(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Rv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),Qh(i.return,n,a)}function Hd(i,n,a,l,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function Mv(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=ri.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,ee(ri,_),Ki(i,n,l,a),l=ct?Ul:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Rv(i,a,n);else if(i.tag===19)Rv(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&&Lc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),Hd(n,!1,u,a,d,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Lc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Hd(n,!0,a,null,d,l);break;case"together":Hd(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Ms(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),hr|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(Ia(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(r(153));if(n.child!==null){for(i=n.child,a=xs(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=xs(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function Ud(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Ec(i)))}function GC(i,n,a){switch(n.tag){case 3:Ye(n,n.stateNode.containerInfo),nr(n,ui,i.memoizedState.cache),Zr();break;case 27:case 5:X(n);break;case 4:Ye(n,n.stateNode.containerInfo);break;case 10:nr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,ud(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(lr(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Dv(i,n,a):(lr(n),i=Ms(i,n,a),i!==null?i.sibling:null);lr(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(Ia(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Mv(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ee(ri,ri.current),l)break;return null;case 22:return n.lanes=0,wv(i,n,a,n.pendingProps);case 24:nr(n,ui,i.memoizedState.cache)}return Ms(i,n,a)}function Nv(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)di=!0;else{if(!Ud(i,a)&&(n.flags&128)===0)return di=!1,GC(i,n,a);di=(i.flags&131072)!==0}else di=!1,ct&&(n.flags&1048576)!==0&&c_(n,Ul,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=ta(n.elementType),n.type=i,typeof i=="function")Wh(i)?(l=ra(i,l),n.tag=1,n=kv(null,n,i,l,a)):(n.tag=0,n=Ad(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===P){n.tag=11,n=yv(null,n,i,l,a);break e}else if(u===le){n.tag=14,n=bv(null,n,i,l,a);break e}}throw n=K(i)||i,Error(r(306,n,""))}}return n;case 0:return Ad(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=ra(l,n.pendingProps),kv(i,n,l,u,a);case 3:e:{if(Ye(n,n.stateNode.containerInfo),i===null)throw Error(r(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,rd(i,n),Yl(n,l,null,a);var _=n.memoizedState;if(l=_.cache,nr(n,ui,l),l!==d.cache&&Jh(n,[ui],a,!0),$l(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Tv(i,n,l,a);break e}else if(l!==u){u=jn(Error(r(424)),n),Pl(u),n=Tv(i,n,l,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,zt=Kn(i.firstChild),Pi=n,ct=!0,tr=null,Pn=!0,a=w_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Zr(),l===u){n=Ms(i,n,a);break e}Ki(i,n,l,a)}n=n.child}return n;case 26:return Wc(i,n),i===null?(a=Ky(n.type,null,n.pendingProps,null))?n.memoizedState=a:ct||(a=n.type,i=n.pendingProps,l=lu(xe.current).createElement(a),l[Kt]=n,l[Vt]=i,Fi(l,a,i),Xt(l),n.stateNode=l):n.memoizedState=Ky(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return X(n),i===null&&ct&&(l=n.stateNode=Uy(n.type,n.pendingProps,xe.current),Pi=n,Pn=!0,u=zt,gr(n.type)?(yf=u,zt=Kn(l.firstChild)):zt=u),Ki(i,n,n.pendingProps.children,a),Wc(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&ct&&((u=l=zt)&&(l=kx(l,n.type,n.pendingProps,Pn),l!==null?(n.stateNode=l,Pi=n,zt=Kn(l.firstChild),Pn=!1,u=!0):u=!1),u||ir(n)),X(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,pf(u,d)?l=null:_!==null&&pf(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=dd(i,n,IC,null,null,a),po._currentValue=u),Wc(i,n),Ki(i,n,l,a),n.child;case 6:return i===null&&ct&&((i=a=zt)&&(a=Tx(a,n.pendingProps,Pn),a!==null?(n.stateNode=a,Pi=n,zt=null,i=!0):i=!1),i||ir(n)),null;case 13:return Dv(i,n,a);case 4:return Ye(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=na(n,null,l,a):Ki(i,n,l,a),n.child;case 11:return yv(i,n,n.type,n.pendingProps,a);case 7:return Ki(i,n,n.pendingProps,a),n.child;case 8:return Ki(i,n,n.pendingProps.children,a),n.child;case 12:return Ki(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,nr(n,n.type,l.value),Ki(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,Jr(n),u=Ii(u),l=l(u),n.flags|=1,Ki(i,n,l,a),n.child;case 14:return bv(i,n,n.type,n.pendingProps,a);case 15:return Sv(i,n,n.type,n.pendingProps,a);case 19:return Mv(i,n,a);case 31:return XC(i,n,a);case 22:return wv(i,n,a,n.pendingProps);case 24:return Jr(n),l=Ii(ui),i===null?(u=id(),u===null&&(u=Rt,d=ed(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},sd(n),nr(n,ui,u)):((i.lanes&a)!==0&&(rd(i,n),Yl(n,null,null,a),$l()),u=i.memoizedState,d=n.memoizedState,u.parent!==l?(u={parent:l,cache:l},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),nr(n,ui,l)):(l=d.cache,nr(n,ui,l),l!==u.cache&&Jh(n,[ui],a,!0))),Ki(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(r(156,n.tag))}function Ns(i){i.flags|=4}function Pd(i,n,a,l,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(sy())i.flags|=8192;else throw ia=Rc,nd}else i.flags&=-16777217}function Av(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Yy(n))if(sy())i.flags|=8192;else throw ia=Rc,nd}function $c(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?Yt():536870912,i.lanes|=n,Ja|=n)}function Jl(i,n){if(!ct)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 l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function jt(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,n}function ZC(i,n,a){var l=n.pendingProps;switch(Vh(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jt(n),null;case 1:return jt(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Ts(ui),_e(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Pa(n)?Ns(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Gh())),jt(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(Ns(n),d!==null?(jt(n),Av(n,d)):(jt(n),Pd(n,u,null,l,a))):d?d!==i.memoizedState?(Ns(n),jt(n),Av(n,d)):(jt(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&Ns(n),jt(n),Pd(n,u,i,l,a)),null;case 27:if(ce(n),a=xe.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Ns(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return jt(n),null}i=he.current,Pa(n)?h_(n):(i=Uy(u,l,a),n.stateNode=i,Ns(n))}return jt(n),null;case 5:if(ce(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Ns(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return jt(n),null}if(d=he.current,Pa(n))h_(n);else{var _=lu(xe.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 l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?d.multiple=!0:l.size&&(d.size=l.size);break;default:d=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}d[Kt]=n,d[Vt]=l;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(Fi(d,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Ns(n)}}return jt(n),Pd(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&Ns(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(r(166));if(i=xe.current,Pa(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Pi,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[Kt]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Dy(i.nodeValue,a)),i||ir(n,!0)}else i=lu(i).createTextNode(l),i[Kt]=n,n.stateNode=i}return jt(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Pa(n),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Kt]=n}else Zr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;jt(n),i=!1}else a=Gh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(xn(n),n):(xn(n),null);if((n.flags&128)!==0)throw Error(r(558))}return jt(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Pa(n),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(r(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[Kt]=n}else Zr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;jt(n),u=!1}else u=Gh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(xn(n),n):(xn(n),null)}return xn(n),(n.flags&128)!==0?(n.lanes=a,n):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=n.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==u&&(l.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),$c(n,n.updateQueue),jt(n),null);case 4:return _e(),i===null&&cf(n.stateNode.containerInfo),jt(n),null;case 10:return Ts(n.type),jt(n),null;case 19:if(H(ri),l=n.memoizedState,l===null)return jt(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)Jl(l,!1);else{if(Jt!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Lc(i),d!==null){for(n.flags|=128,Jl(l,!1),i=d.updateQueue,n.updateQueue=i,$c(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)a_(a,i),a=a.sibling;return ee(ri,ri.current&1|2),ct&&Es(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&ot()>Zc&&(n.flags|=128,u=!0,Jl(l,!1),n.lanes=4194304)}else{if(!u)if(i=Lc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,$c(n,i),Jl(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!ct)return jt(n),null}else 2*ot()-l.renderingStartTime>Zc&&a!==536870912&&(n.flags|=128,u=!0,Jl(l,!1),n.lanes=4194304);l.isBackwards?(d.sibling=n.child,n.child=d):(i=l.last,i!==null?i.sibling=d:n.child=d,l.last=d)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=ot(),i.sibling=null,a=ri.current,ee(ri,u?a&1|2:a&1),ct&&Es(n,l.treeForkCount),i):(jt(n),null);case 22:case 23:return xn(n),cd(),l=n.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(a&536870912)!==0&&(n.flags&128)===0&&(jt(n),n.subtreeFlags&6&&(n.flags|=8192)):jt(n),a=n.updateQueue,a!==null&&$c(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==a&&(n.flags|=2048),i!==null&&H(ea),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Ts(ui),jt(n),null;case 25:return null;case 30:return null}throw Error(r(156,n.tag))}function QC(i,n){switch(Vh(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Ts(ui),_e(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return ce(n),null;case 31:if(n.memoizedState!==null){if(xn(n),n.alternate===null)throw Error(r(340));Zr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(xn(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(r(340));Zr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return H(ri),null;case 4:return _e(),null;case 10:return Ts(n.type),null;case 22:case 23:return xn(n),cd(),i!==null&&H(ea),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Ts(ui),null;case 25:return null;default:return null}}function Lv(i,n){switch(Vh(n),n.tag){case 3:Ts(ui),_e();break;case 26:case 27:case 5:ce(n);break;case 4:_e();break;case 31:n.memoizedState!==null&&xn(n);break;case 13:xn(n);break;case 19:H(ri);break;case 10:Ts(n.type);break;case 22:case 23:xn(n),cd(),i!==null&&H(ea);break;case 24:Ts(ui)}}function eo(i,n){try{var a=n.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var d=a.create,_=a.inst;l=d(),_.destroy=l}a=a.next}while(a!==u)}}catch(C){yt(n,n.return,C)}}function cr(i,n,a){try{var l=n.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){var _=l.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var M=a,$=C;try{$()}catch(re){yt(u,M,re)}}}l=l.next}while(l!==d)}}catch(re){yt(n,n.return,re)}}function Bv(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{x_(n,a)}catch(l){yt(i,i.return,l)}}}function Ov(i,n,a){a.props=ra(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){yt(i,n,l)}}function to(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){yt(i,n,u)}}function ds(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){yt(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){yt(i,n,u)}else a.current=null}function zv(i){var n=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){yt(i,i.return,u)}}function Id(i,n,a){try{var l=i.stateNode;bx(l,i.type,a,n),l[Vt]=n}catch(u){yt(i,i.return,u)}}function jv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&gr(i.type)||i.tag===4}function Kd(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||jv(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&&gr(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 Fd(i,n,a){var l=i.tag;if(l===5||l===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=ci));else if(l!==4&&(l===27&&gr(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for(Fd(i,n,a),i=i.sibling;i!==null;)Fd(i,n,a),i=i.sibling}function Yc(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(l!==4&&(l===27&&gr(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Yc(i,n,a),i=i.sibling;i!==null;)Yc(i,n,a),i=i.sibling}function Hv(i){var n=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Fi(n,l,a),n[Kt]=i,n[Vt]=a}catch(d){yt(i,i.return,d)}}var As=!1,fi=!1,Wd=!1,Uv=typeof WeakSet=="function"?WeakSet:Set,Di=null;function JC(i,n){if(i=i.containerInfo,df=pu,i=Zg(i),jh(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,d=l.focusNode;l=l.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,M=-1,$=0,re=0,de=i,V=null;t:for(;;){for(var G;de!==a||u!==0&&de.nodeType!==3||(C=_+u),de!==d||l!==0&&de.nodeType!==3||(M=_+l),de.nodeType===3&&(_+=de.nodeValue.length),(G=de.firstChild)!==null;)V=de,de=G;for(;;){if(de===i)break t;if(V===a&&++$===u&&(C=_),V===d&&++re===l&&(M=_),(G=de.nextSibling)!==null)break;de=V,V=de.parentNode}de=G}a=C===-1||M===-1?null:{start:C,end:M}}else a=null}a=a||{start:0,end:0}}else a=null;for(ff={focusedElem:i,selectionRange:a},pu=!1,Di=n;Di!==null;)if(n=Di,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Di=i;else for(;Di!==null;){switch(n=Di,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,l=a.stateNode;try{var Ae=ra(a.type,u);i=l.getSnapshotBeforeUpdate(Ae,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(Ke){yt(a,a.return,Ke)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)gf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":gf(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=n.sibling,i!==null){i.return=n.return,Di=i;break}Di=n.return}}function Pv(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Bs(i,a),l&4&&eo(5,a);break;case 1:if(Bs(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){yt(a,a.return,_)}else{var u=ra(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){yt(a,a.return,_)}}l&64&&Bv(a),l&512&&to(a,a.return);break;case 3:if(Bs(i,a),l&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{x_(i,n)}catch(_){yt(a,a.return,_)}}break;case 27:n===null&&l&4&&Hv(a);case 26:case 5:Bs(i,a),n===null&&l&4&&zv(a),l&512&&to(a,a.return);break;case 12:Bs(i,a);break;case 31:Bs(i,a),l&4&&Fv(i,a);break;case 13:Bs(i,a),l&4&&Wv(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=ox.bind(null,a),Dx(i,a))));break;case 22:if(l=a.memoizedState!==null||As,!l){n=n!==null&&n.memoizedState!==null||fi,u=As;var d=fi;As=l,(fi=n)&&!d?Os(i,a,(a.subtreeFlags&8772)!==0):Bs(i,a),As=u,fi=d}break;case 30:break;default:Bs(i,a)}}function Iv(i){var n=i.alternate;n!==null&&(i.alternate=null,Iv(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&Ys(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 Ut=null,cn=!1;function Ls(i,n,a){for(a=a.child;a!==null;)Kv(i,n,a),a=a.sibling}function Kv(i,n,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(ut,a)}catch{}switch(a.tag){case 26:fi||ds(a,n),Ls(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:fi||ds(a,n);var l=Ut,u=cn;gr(a.type)&&(Ut=a.stateNode,cn=!1),Ls(i,n,a),uo(a.stateNode),Ut=l,cn=u;break;case 5:fi||ds(a,n);case 6:if(l=Ut,u=cn,Ut=null,Ls(i,n,a),Ut=l,cn=u,Ut!==null)if(cn)try{(Ut.nodeType===9?Ut.body:Ut.nodeName==="HTML"?Ut.ownerDocument.body:Ut).removeChild(a.stateNode)}catch(d){yt(a,n,d)}else try{Ut.removeChild(a.stateNode)}catch(d){yt(a,n,d)}break;case 18:Ut!==null&&(cn?(i=Ut,By(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),ll(i)):By(Ut,a.stateNode));break;case 4:l=Ut,u=cn,Ut=a.stateNode.containerInfo,cn=!0,Ls(i,n,a),Ut=l,cn=u;break;case 0:case 11:case 14:case 15:cr(2,a,n),fi||cr(4,a,n),Ls(i,n,a);break;case 1:fi||(ds(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Ov(a,n,l)),Ls(i,n,a);break;case 21:Ls(i,n,a);break;case 22:fi=(l=fi)||a.memoizedState!==null,Ls(i,n,a),fi=l;break;default:Ls(i,n,a)}}function Fv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{ll(i)}catch(a){yt(n,n.return,a)}}}function Wv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{ll(i)}catch(a){yt(n,n.return,a)}}function ex(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new Uv),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new Uv),n;default:throw Error(r(435,i.tag))}}function Vc(i,n){var a=ex(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=cx.bind(null,i,l);l.then(u,u)}})}function un(i,n){var a=n.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(gr(C.type)){Ut=C.stateNode,cn=!1;break e}break;case 5:Ut=C.stateNode,cn=!1;break e;case 3:case 4:Ut=C.stateNode.containerInfo,cn=!0;break e}C=C.return}if(Ut===null)throw Error(r(160));Kv(d,_,u),Ut=null,cn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)qv(n,i),n=n.sibling}var Jn=null;function qv(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:un(n,i),hn(i),l&4&&(cr(3,i,i.return),eo(3,i),cr(5,i,i.return));break;case 1:un(n,i),hn(i),l&512&&(fi||a===null||ds(a,a.return)),l&64&&As&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=Jn;if(un(n,i),hn(i),l&512&&(fi||a===null||ds(a,a.return)),l&4){var d=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":d=u.getElementsByTagName("title")[0],(!d||d[bs]||d[Kt]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(l),u.head.insertBefore(d,u.querySelector("head > title"))),Fi(d,l,a),d[Kt]=i,Xt(d),l=d;break e;case"link":var _=qy("link","href",u).get(l+(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(l),Fi(d,l,a),u.head.appendChild(d);break;case"meta":if(_=qy("meta","content",u).get(l+(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(l),Fi(d,l,a),u.head.appendChild(d);break;default:throw Error(r(468,l))}d[Kt]=i,Xt(d),l=d}i.stateNode=l}else $y(u,i.type,i.stateNode);else i.stateNode=Wy(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?$y(u,i.type,i.stateNode):Wy(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Id(i,i.memoizedProps,a.memoizedProps)}break;case 27:un(n,i),hn(i),l&512&&(fi||a===null||ds(a,a.return)),a!==null&&l&4&&Id(i,i.memoizedProps,a.memoizedProps);break;case 5:if(un(n,i),hn(i),l&512&&(fi||a===null||ds(a,a.return)),i.flags&32){u=i.stateNode;try{Bt(u,"")}catch(Ae){yt(i,i.return,Ae)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Id(i,u,a!==null?a.memoizedProps:u)),l&1024&&(Wd=!0);break;case 6:if(un(n,i),hn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ae){yt(i,i.return,Ae)}}break;case 3:if(uu=null,u=Jn,Jn=ou(n.containerInfo),un(n,i),Jn=u,hn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{ll(n.containerInfo)}catch(Ae){yt(i,i.return,Ae)}Wd&&(Wd=!1,$v(i));break;case 4:l=Jn,Jn=ou(i.stateNode.containerInfo),un(n,i),hn(i),Jn=l;break;case 12:un(n,i),hn(i);break;case 31:un(n,i),hn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Vc(i,l)));break;case 13:un(n,i),hn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Gc=ot()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Vc(i,l)));break;case 22:u=i.memoizedState!==null;var M=a!==null&&a.memoizedState!==null,$=As,re=fi;if(As=$||u,fi=re||M,un(n,i),fi=re,As=$,hn(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||M||As||fi||aa(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){M=a=n;try{if(d=M.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=M.stateNode;var de=M.memoizedProps.style,V=de!=null&&de.hasOwnProperty("display")?de.display:null;C.style.display=V==null||typeof V=="boolean"?"":(""+V).trim()}}catch(Ae){yt(M,M.return,Ae)}}}else if(n.tag===6){if(a===null){M=n;try{M.stateNode.nodeValue=u?"":M.memoizedProps}catch(Ae){yt(M,M.return,Ae)}}}else if(n.tag===18){if(a===null){M=n;try{var G=M.stateNode;u?Oy(G,!0):Oy(M.stateNode,!1)}catch(Ae){yt(M,M.return,Ae)}}}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}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Vc(i,a))));break;case 19:un(n,i),hn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Vc(i,l)));break;case 30:break;case 21:break;default:un(n,i),hn(i)}}function hn(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(jv(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var u=a.stateNode,d=Kd(i);Yc(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(Bt(_,""),a.flags&=-33);var C=Kd(i);Yc(i,C,_);break;case 3:case 4:var M=a.stateNode.containerInfo,$=Kd(i);Fd(i,$,M);break;default:throw Error(r(161))}}catch(re){yt(i,i.return,re)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function $v(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;$v(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Bs(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Pv(i,n.alternate,n),n=n.sibling}function aa(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:cr(4,n,n.return),aa(n);break;case 1:ds(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&Ov(n,n.return,a),aa(n);break;case 27:uo(n.stateNode);case 26:case 5:ds(n,n.return),aa(n);break;case 22:n.memoizedState===null&&aa(n);break;case 30:aa(n);break;default:aa(n)}i=i.sibling}}function Os(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Os(u,d,a),eo(4,d);break;case 1:if(Os(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch($){yt(l,l.return,$)}if(l=d,u=l.updateQueue,u!==null){var C=l.stateNode;try{var M=u.shared.hiddenCallbacks;if(M!==null)for(u.shared.hiddenCallbacks=null,u=0;u<M.length;u++)C_(M[u],C)}catch($){yt(l,l.return,$)}}a&&_&64&&Bv(d),to(d,d.return);break;case 27:Hv(d);case 26:case 5:Os(u,d,a),a&&l===null&&_&4&&zv(d),to(d,d.return);break;case 12:Os(u,d,a);break;case 31:Os(u,d,a),a&&_&4&&Fv(u,d);break;case 13:Os(u,d,a),a&&_&4&&Wv(u,d);break;case 22:d.memoizedState===null&&Os(u,d,a),to(d,d.return);break;case 30:break;default:Os(u,d,a)}n=n.sibling}}function qd(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&&Il(a))}function $d(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Il(i))}function es(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Yv(i,n,a,l),n=n.sibling}function Yv(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:es(i,n,a,l),u&2048&&eo(9,n);break;case 1:es(i,n,a,l);break;case 3:es(i,n,a,l),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Il(i)));break;case 12:if(u&2048){es(i,n,a,l),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(M){yt(n,n.return,M)}}else es(i,n,a,l);break;case 31:es(i,n,a,l);break;case 13:es(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?es(i,n,a,l):io(i,n):d._visibility&2?es(i,n,a,l):(d._visibility|=2,Ga(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&qd(_,n);break;case 24:es(i,n,a,l),u&2048&&$d(n.alternate,n);break;default:es(i,n,a,l)}}function Ga(i,n,a,l,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,M=l,$=_.flags;switch(_.tag){case 0:case 11:case 15:Ga(d,_,C,M,u),eo(8,_);break;case 23:break;case 22:var re=_.stateNode;_.memoizedState!==null?re._visibility&2?Ga(d,_,C,M,u):io(d,_):(re._visibility|=2,Ga(d,_,C,M,u)),u&&$&2048&&qd(_.alternate,_);break;case 24:Ga(d,_,C,M,u),u&&$&2048&&$d(_.alternate,_);break;default:Ga(d,_,C,M,u)}n=n.sibling}}function io(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,l=n,u=l.flags;switch(l.tag){case 22:io(a,l),u&2048&&qd(l.alternate,l);break;case 24:io(a,l),u&2048&&$d(l.alternate,l);break;default:io(a,l)}n=n.sibling}}var no=8192;function Za(i,n,a){if(i.subtreeFlags&no)for(i=i.child;i!==null;)Vv(i,n,a),i=i.sibling}function Vv(i,n,a){switch(i.tag){case 26:Za(i,n,a),i.flags&no&&i.memoizedState!==null&&Px(a,Jn,i.memoizedState,i.memoizedProps);break;case 5:Za(i,n,a);break;case 3:case 4:var l=Jn;Jn=ou(i.stateNode.containerInfo),Za(i,n,a),Jn=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=no,no=16777216,Za(i,n,a),no=l):Za(i,n,a));break;default:Za(i,n,a)}}function Xv(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 so(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Di=l,Zv(l,i)}Xv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Gv(i),i=i.sibling}function Gv(i){switch(i.tag){case 0:case 11:case 15:so(i),i.flags&2048&&cr(9,i,i.return);break;case 3:so(i);break;case 12:so(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,Xc(i)):so(i);break;default:so(i)}}function Xc(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Di=l,Zv(l,i)}Xv(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:cr(8,n,n.return),Xc(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Xc(n));break;default:Xc(n)}i=i.sibling}}function Zv(i,n){for(;Di!==null;){var a=Di;switch(a.tag){case 0:case 11:case 15:cr(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Il(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Di=l;else e:for(a=i;Di!==null;){l=Di;var u=l.sibling,d=l.return;if(Iv(l),l===a){Di=null;break e}if(u!==null){u.return=d,Di=u;break e}Di=d}}}var tx={getCacheForType:function(i){var n=Ii(ui),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Ii(ui).controller.signal}},ix=typeof WeakMap=="function"?WeakMap:Map,mt=0,Rt=null,nt=null,at=0,vt=0,En=null,ur=!1,Qa=!1,Yd=!1,zs=0,Jt=0,hr=0,la=0,Vd=0,kn=0,Ja=0,ro=null,dn=null,Xd=!1,Gc=0,Qv=0,Zc=1/0,Qc=null,dr=null,Si=0,fr=null,el=null,js=0,Gd=0,Zd=null,Jv=null,ao=0,Qd=null;function Tn(){return(mt&2)!==0&&at!==0?at&-at:L.T!==null?rf():Hi()}function ey(){if(kn===0)if((at&536870912)===0||ct){var i=ln;ln<<=1,(ln&3932160)===0&&(ln=262144),kn=i}else kn=536870912;return i=Cn.current,i!==null&&(i.flags|=32),kn}function fn(i,n,a){(i===Rt&&(vt===2||vt===9)||i.cancelPendingCommit!==null)&&(tl(i,0),pr(i,at,kn,!1)),Ti(i,a),((mt&2)===0||i!==Rt)&&(i===Rt&&((mt&2)===0&&(la|=a),Jt===4&&pr(i,at,kn,!1)),fs(i))}function ty(i,n,a){if((mt&6)!==0)throw Error(r(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||bi(i,n),u=l?rx(i,n):ef(i,n,!0),d=l;do{if(u===0){Qa&&!l&&pr(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!nx(a)){u=ef(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=ro;var M=C.current.memoizedState.isDehydrated;if(M&&(tl(C,_).flags|=256),_=ef(C,_,!1),_!==2){if(Yd&&!M){C.errorRecoveryDisabledLanes|=d,la|=d,u=4;break e}d=dn,dn=u,d!==null&&(dn===null?dn=d:dn.push.apply(dn,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){tl(i,0),pr(i,n,0,!0);break}e:{switch(l=i,d=u,d){case 0:case 1:throw Error(r(345));case 4:if((n&4194048)!==n)break;case 6:pr(l,n,kn,!ur);break e;case 2:dn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((n&62914560)===n&&(u=Gc+300-ot(),10<u)){if(pr(l,n,kn,!ur),Tt(l,0,!0)!==0)break e;js=n,l.timeoutHandle=Ay(iy.bind(null,l,a,dn,Qc,Xd,n,kn,la,Ja,ur,d,"Throttled",-0,0),u);break e}iy(l,a,dn,Qc,Xd,n,kn,la,Ja,ur,d,null,-0,0)}}break}while(!0);fs(i)}function iy(i,n,a,l,u,d,_,C,M,$,re,de,V,G){if(i.timeoutHandle=-1,de=n.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ci},Vv(n,d,de);var Ae=(d&62914560)===d?Gc-ot():(d&4194048)===d?Qv-ot():0;if(Ae=Ix(de,Ae),Ae!==null){js=d,i.cancelPendingCommit=Ae(uy.bind(null,i,n,d,a,l,u,_,C,M,re,de,null,V,G)),pr(i,d,_,!$);return}}uy(i,n,d,a,l,u,_,C,M)}function nx(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 l=0;l<a.length;l++){var u=a[l],d=u.getSnapshot;u=u.value;try{if(!Sn(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 pr(i,n,a,l){n&=~Vd,n&=~la,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-bt(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&ji(i,a,n)}function Jc(){return(mt&6)===0?(lo(0),!1):!0}function Jd(){if(nt!==null){if(vt===0)var i=nt.return;else i=nt,ks=Qr=null,md(i),qa=null,Fl=0,i=nt;for(;i!==null;)Lv(i.alternate,i),i=i.return;nt=null}}function tl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Cx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),js=0,Jd(),Rt=i,nt=a=xs(i.current,null),at=n,vt=0,En=null,ur=!1,Qa=bi(i,n),Yd=!1,Ja=kn=Vd=la=hr=Jt=0,dn=ro=null,Xd=!1,(n&8)!==0&&(n|=n&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=n;0<l;){var u=31-bt(l),d=1<<u;n|=i[u],l&=~d}return zs=n,bc(),a}function ny(i,n){Ve=null,L.H=Zl,n===Wa||n===Dc?(n=y_(),vt=3):n===nd?(n=y_(),vt=4):vt=n===Nd?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,En=n,nt===null&&(Jt=1,Kc(i,jn(n,i.current)))}function sy(){var i=Cn.current;return i===null?!0:(at&4194048)===at?In===null:(at&62914560)===at||(at&536870912)!==0?i===In:!1}function ry(){var i=L.H;return L.H=Zl,i===null?Zl:i}function ay(){var i=L.A;return L.A=tx,i}function eu(){Jt=4,ur||(at&4194048)!==at&&Cn.current!==null||(Qa=!0),(hr&134217727)===0&&(la&134217727)===0||Rt===null||pr(Rt,at,kn,!1)}function ef(i,n,a){var l=mt;mt|=2;var u=ry(),d=ay();(Rt!==i||at!==n)&&(Qc=null,tl(i,n)),n=!1;var _=Jt;e:do try{if(vt!==0&&nt!==null){var C=nt,M=En;switch(vt){case 8:Jd(),_=6;break e;case 3:case 2:case 9:case 6:Cn.current===null&&(n=!0);var $=vt;if(vt=0,En=null,il(i,C,M,$),a&&Qa){_=0;break e}break;default:$=vt,vt=0,En=null,il(i,C,M,$)}}sx(),_=Jt;break}catch(re){ny(i,re)}while(!0);return n&&i.shellSuspendCounter++,ks=Qr=null,mt=l,L.H=u,L.A=d,nt===null&&(Rt=null,at=0,bc()),_}function sx(){for(;nt!==null;)ly(nt)}function rx(i,n){var a=mt;mt|=2;var l=ry(),u=ay();Rt!==i||at!==n?(Qc=null,Zc=ot()+500,tl(i,n)):Qa=bi(i,n);e:do try{if(vt!==0&&nt!==null){n=nt;var d=En;t:switch(vt){case 1:vt=0,En=null,il(i,n,d,1);break;case 2:case 9:if(__(d)){vt=0,En=null,oy(n);break}n=function(){vt!==2&&vt!==9||Rt!==i||(vt=7),fs(i)},d.then(n,n);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:__(d)?(vt=0,En=null,oy(n)):(vt=0,En=null,il(i,n,d,7));break;case 5:var _=null;switch(nt.tag){case 26:_=nt.memoizedState;case 5:case 27:var C=nt;if(_?Yy(_):C.stateNode.complete){vt=0,En=null;var M=C.sibling;if(M!==null)nt=M;else{var $=C.return;$!==null?(nt=$,tu($)):nt=null}break t}}vt=0,En=null,il(i,n,d,5);break;case 6:vt=0,En=null,il(i,n,d,6);break;case 8:Jd(),Jt=6;break e;default:throw Error(r(462))}}ax();break}catch(re){ny(i,re)}while(!0);return ks=Qr=null,L.H=l,L.A=u,mt=a,nt!==null?0:(Rt=null,at=0,bc(),Jt)}function ax(){for(;nt!==null&&!ht();)ly(nt)}function ly(i){var n=Nv(i.alternate,i,zs);i.memoizedProps=i.pendingProps,n===null?tu(i):nt=n}function oy(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=Ev(a,n,n.pendingProps,n.type,void 0,at);break;case 11:n=Ev(a,n,n.pendingProps,n.type.render,n.ref,at);break;case 5:md(n);default:Lv(a,n),n=nt=a_(n,zs),n=Nv(a,n,zs)}i.memoizedProps=i.pendingProps,n===null?tu(i):nt=n}function il(i,n,a,l){ks=Qr=null,md(n),qa=null,Fl=0;var u=n.return;try{if(VC(i,u,n,a,at)){Jt=1,Kc(i,jn(a,i.current)),nt=null;return}}catch(d){if(u!==null)throw nt=u,d;Jt=1,Kc(i,jn(a,i.current)),nt=null;return}n.flags&32768?(ct||l===1?i=!0:Qa||(at&536870912)!==0?i=!1:(ur=i=!0,(l===2||l===9||l===3||l===6)&&(l=Cn.current,l!==null&&l.tag===13&&(l.flags|=16384))),cy(n,i)):tu(n)}function tu(i){var n=i;do{if((n.flags&32768)!==0){cy(n,ur);return}i=n.return;var a=ZC(n.alternate,n,zs);if(a!==null){nt=a;return}if(n=n.sibling,n!==null){nt=n;return}nt=n=i}while(n!==null);Jt===0&&(Jt=5)}function cy(i,n){do{var a=QC(i.alternate,i);if(a!==null){a.flags&=32767,nt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){nt=i;return}nt=i=a}while(i!==null);Jt=6,nt=null}function uy(i,n,a,l,u,d,_,C,M){i.cancelPendingCommit=null;do iu();while(Si!==0);if((mt&6)!==0)throw Error(r(327));if(n!==null){if(n===i.current)throw Error(r(177));if(d=n.lanes|n.childLanes,d|=Kh,Dt(i,a,d,_,C,M),i===Rt&&(nt=Rt=null,at=0),el=n,fr=i,js=a,Gd=d,Zd=u,Jv=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,ux($t,function(){return my(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=L.T,L.T=null,u=Y.p,Y.p=2,_=mt,mt|=4;try{JC(i,n,a)}finally{mt=_,Y.p=u,L.T=l}}Si=1,hy(),dy(),fy()}}function hy(){if(Si===1){Si=0;var i=fr,n=el,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=L.T,L.T=null;var l=Y.p;Y.p=2;var u=mt;mt|=4;try{qv(n,i);var d=ff,_=Zg(i.containerInfo),C=d.focusedElem,M=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&Gg(C.ownerDocument.documentElement,C)){if(M!==null&&jh(C)){var $=M.start,re=M.end;if(re===void 0&&(re=$),"selectionStart"in C)C.selectionStart=$,C.selectionEnd=Math.min(re,C.value.length);else{var de=C.ownerDocument||document,V=de&&de.defaultView||window;if(V.getSelection){var G=V.getSelection(),Ae=C.textContent.length,Ke=Math.min(M.start,Ae),Ct=M.end===void 0?Ke:Math.min(M.end,Ae);!G.extend&&Ke>Ct&&(_=Ct,Ct=Ke,Ke=_);var U=Xg(C,Ke),z=Xg(C,Ct);if(U&&z&&(G.rangeCount!==1||G.anchorNode!==U.node||G.anchorOffset!==U.offset||G.focusNode!==z.node||G.focusOffset!==z.offset)){var q=de.createRange();q.setStart(U.node,U.offset),G.removeAllRanges(),Ke>Ct?(G.addRange(q),G.extend(z.node,z.offset)):(q.setEnd(z.node,z.offset),G.addRange(q))}}}}for(de=[],G=C;G=G.parentNode;)G.nodeType===1&&de.push({element:G,left:G.scrollLeft,top:G.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<de.length;C++){var ue=de[C];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}pu=!!df,ff=df=null}finally{mt=u,Y.p=l,L.T=a}}i.current=n,Si=2}}function dy(){if(Si===2){Si=0;var i=fr,n=el,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=L.T,L.T=null;var l=Y.p;Y.p=2;var u=mt;mt|=4;try{Pv(i,n.alternate,n)}finally{mt=u,Y.p=l,L.T=a}}Si=3}}function fy(){if(Si===4||Si===3){Si=0,Xe();var i=fr,n=el,a=js,l=Jv;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Si=5:(Si=0,el=fr=null,py(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(dr=null),tn(a),n=n.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(ut,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=L.T,u=Y.p,Y.p=2,L.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{L.T=n,Y.p=u}}(js&3)!==0&&iu(),fs(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===Qd?ao++:(ao=0,Qd=i):ao=0,lo(0)}}function py(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Il(n)))}function iu(){return hy(),dy(),fy(),my()}function my(){if(Si!==5)return!1;var i=fr,n=Gd;Gd=0;var a=tn(js),l=L.T,u=Y.p;try{Y.p=32>a?32:a,L.T=null,a=Zd,Zd=null;var d=fr,_=js;if(Si=0,el=fr=null,js=0,(mt&6)!==0)throw Error(r(331));var C=mt;if(mt|=4,Gv(d.current),Yv(d,d.current,_,a),mt=C,lo(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(ut,d)}catch{}return!0}finally{Y.p=u,L.T=l,py(i,n)}}function gy(i,n,a){n=jn(a,n),n=Md(i.stateNode,n,2),i=ar(i,n,2),i!==null&&(Ti(i,2),fs(i))}function yt(i,n,a){if(i.tag===3)gy(i,i,a);else for(;n!==null;){if(n.tag===3){gy(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(dr===null||!dr.has(l))){i=jn(a,i),a=_v(2),l=ar(n,a,2),l!==null&&(vv(a,l,n,i),Ti(l,2),fs(l));break}}n=n.return}}function tf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new ix;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(a)||(Yd=!0,u.add(a),i=lx.bind(null,i,n,a),n.then(i,i))}function lx(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Rt===i&&(at&a)===a&&(Jt===4||Jt===3&&(at&62914560)===at&&300>ot()-Gc?(mt&2)===0&&tl(i,0):Vd|=a,Ja===at&&(Ja=0)),fs(i)}function _y(i,n){n===0&&(n=Yt()),i=Xr(i,n),i!==null&&(Ti(i,n),fs(i))}function ox(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),_y(i,a)}function cx(i,n){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(n),_y(i,a)}function ux(i,n){return Oe(i,n)}var nu=null,nl=null,nf=!1,su=!1,sf=!1,mr=0;function fs(i){i!==nl&&i.next===null&&(nl===null?nu=nl=i:nl=nl.next=i),su=!0,nf||(nf=!0,dx())}function lo(i,n){if(!sf&&su){sf=!0;do for(var a=!1,l=nu;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var d=0;else{var _=l.suspendedLanes,C=l.pingedLanes;d=(1<<31-bt(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Sy(l,d))}else d=at,d=Tt(l,l===Rt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||bi(l,d)||(a=!0,Sy(l,d));l=l.next}while(a);sf=!1}}function hx(){vy()}function vy(){su=nf=!1;var i=0;mr!==0&&wx()&&(i=mr);for(var n=ot(),a=null,l=nu;l!==null;){var u=l.next,d=yy(l,n);d===0?(l.next=null,a===null?nu=u:a.next=u,u===null&&(nl=a)):(a=l,(i!==0||(d&3)!==0)&&(su=!0)),l=u}Si!==0&&Si!==5||lo(i),mr!==0&&(mr=0)}function yy(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-bt(d),C=1<<_,M=u[_];M===-1?((C&a)===0||(C&l)!==0)&&(u[_]=ii(C,n)):M<=n&&(i.expiredLanes|=C),d&=~C}if(n=Rt,a=at,a=Tt(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(vt===2||vt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&ze(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||bi(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&ze(l),tn(a)){case 2:case 8:a=qi;break;case 32:a=$t;break;case 268435456:a=_n;break;default:a=$t}return l=by.bind(null,i),a=Oe(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&ze(l),i.callbackPriority=2,i.callbackNode=null,2}function by(i,n){if(Si!==0&&Si!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(iu()&&i.callbackNode!==a)return null;var l=at;return l=Tt(i,i===Rt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(ty(i,l,n),yy(i,ot()),i.callbackNode!=null&&i.callbackNode===a?by.bind(null,i):null)}function Sy(i,n){if(iu())return null;ty(i,n,!0)}function dx(){xx(function(){(mt&6)!==0?Oe(Ji,hx):vy()})}function rf(){if(mr===0){var i=Ka;i===0&&(i=yi,yi<<=1,(yi&261888)===0&&(yi=256)),mr=i}return mr}function wy(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Cs(""+i)}function Cy(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,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=wy((u[Vt]||null).action),_=l.submitter;_&&(n=(n=_[Vt]||null)?wy(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new tt("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(mr!==0){var M=_?Cy(u,_):new FormData(u);xd(a,{pending:!0,data:M,method:u.method,action:d},null,M)}}else typeof d=="function"&&(C.preventDefault(),M=_?Cy(u,_):new FormData(u),xd(a,{pending:!0,data:M,method:u.method,action:d},d,M))},currentTarget:u}]})}}for(var af=0;af<Ih.length;af++){var lf=Ih[af],px=lf.toLowerCase(),mx=lf[0].toUpperCase()+lf.slice(1);Qn(px,"on"+mx)}Qn(e_,"onAnimationEnd"),Qn(t_,"onAnimationIteration"),Qn(i_,"onAnimationStart"),Qn("dblclick","onDoubleClick"),Qn("focusin","onFocus"),Qn("focusout","onBlur"),Qn(NC,"onTransitionRun"),Qn(AC,"onTransitionStart"),Qn(LC,"onTransitionCancel"),Qn(n_,"onTransitionEnd"),Bn("onMouseEnter",["mouseout","mouseover"]),Bn("onMouseLeave",["mouseout","mouseover"]),Bn("onPointerEnter",["pointerout","pointerover"]),Bn("onPointerLeave",["pointerout","pointerover"]),on("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),on("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),on("onBeforeInput",["compositionend","keypress","textInput","paste"]),on("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),on("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),on("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var oo="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(" "),gx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(oo));function xy(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var d=void 0;if(n)for(var _=l.length-1;0<=_;_--){var C=l[_],M=C.instance,$=C.currentTarget;if(C=C.listener,M!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(re){yc(re)}u.currentTarget=null,d=M}else for(_=0;_<l.length;_++){if(C=l[_],M=C.instance,$=C.currentTarget,C=C.listener,M!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(re){yc(re)}u.currentTarget=null,d=M}}}}function st(i,n){var a=n[Ur];a===void 0&&(a=n[Ur]=new Set);var l=i+"__bubble";a.has(l)||(Ey(n,i,2,!1),a.add(l))}function of(i,n,a){var l=0;n&&(l|=4),Ey(a,i,l,n)}var ru="_reactListening"+Math.random().toString(36).slice(2);function cf(i){if(!i[ru]){i[ru]=!0,Kr.forEach(function(a){a!=="selectionchange"&&(gx.has(a)||of(a,!1,i),of(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[ru]||(n[ru]=!0,of("selectionchange",!1,n))}}function Ey(i,n,a,l){switch(eb(n)){case 2:var u=Wx;break;case 8:u=qx;break;default:u=xf}a=u.bind(null,n,a,i),u=void 0,!Zn||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?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 uf(i,n,a,l,u){var d=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var C=l.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=l.return;_!==null;){var M=_.tag;if((M===3||M===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=Yi(C),_===null)return;if(M=_.tag,M===5||M===6||M===26||M===27){l=d=_;continue e}C=C.parentNode}}l=l.return}Na(function(){var $=d,re=Zs(a),de=[];e:{var V=s_.get(i);if(V!==void 0){var G=tt,Ae=i;switch(i){case"keypress":if(ne(a)===0)break e;case"keydown":case"keyup":G=cC;break;case"focusin":Ae="focus",G=Ah;break;case"focusout":Ae="blur",G=Ah;break;case"beforeblur":case"afterblur":G=Ah;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":G=Lg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":G=Z1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":G=dC;break;case e_:case t_:case i_:G=eC;break;case n_:G=pC;break;case"scroll":case"scrollend":G=si;break;case"wheel":G=gC;break;case"copy":case"cut":case"paste":G=iC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":G=Og;break;case"toggle":case"beforetoggle":G=vC}var Ke=(n&4)!==0,Ct=!Ke&&(i==="scroll"||i==="scrollend"),U=Ke?V!==null?V+"Capture":null:V;Ke=[];for(var z=$,q;z!==null;){var ue=z;if(q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||q===null||U===null||(ue=$r(z,U),ue!=null&&Ke.push(co(z,ue,q))),Ct)break;z=z.return}0<Ke.length&&(V=new G(V,Ae,null,a,re),de.push({event:V,listeners:Ke}))}}if((n&7)===0){e:{if(V=i==="mouseover"||i==="pointerover",G=i==="mouseout"||i==="pointerout",V&&a!==Gs&&(Ae=a.relatedTarget||a.fromElement)&&(Yi(Ae)||Ae[At]))break e;if((G||V)&&(V=re.window===re?re:(V=re.ownerDocument)?V.defaultView||V.parentWindow:window,G?(Ae=a.relatedTarget||a.toElement,G=$,Ae=Ae?Yi(Ae):null,Ae!==null&&(Ct=c(Ae),Ke=Ae.tag,Ae!==Ct||Ke!==5&&Ke!==27&&Ke!==6)&&(Ae=null)):(G=null,Ae=$),G!==Ae)){if(Ke=Lg,ue="onMouseLeave",U="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(Ke=Og,ue="onPointerLeave",U="onPointerEnter",z="pointer"),Ct=G==null?V:rs(G),q=Ae==null?V:rs(Ae),V=new Ke(ue,z+"leave",G,a,re),V.target=Ct,V.relatedTarget=q,ue=null,Yi(re)===$&&(Ke=new Ke(U,z+"enter",Ae,a,re),Ke.target=q,Ke.relatedTarget=Ct,ue=Ke),Ct=ue,G&&Ae)t:{for(Ke=_x,U=G,z=Ae,q=0,ue=U;ue;ue=Ke(ue))q++;ue=0;for(var Ue=z;Ue;Ue=Ke(Ue))ue++;for(;0<q-ue;)U=Ke(U),q--;for(;0<ue-q;)z=Ke(z),ue--;for(;q--;){if(U===z||z!==null&&U===z.alternate){Ke=U;break t}U=Ke(U),z=Ke(z)}Ke=null}else Ke=null;G!==null&&ky(de,V,G,Ke,!1),Ae!==null&&Ct!==null&&ky(de,Ct,Ae,Ke,!0)}}e:{if(V=$?rs($):window,G=V.nodeName&&V.nodeName.toLowerCase(),G==="select"||G==="input"&&V.type==="file")var ft=Fg;else if(Ig(V))if(Wg)ft=DC;else{ft=kC;var je=EC}else G=V.nodeName,!G||G.toLowerCase()!=="input"||V.type!=="checkbox"&&V.type!=="radio"?$&&On($.elementType)&&(ft=Fg):ft=TC;if(ft&&(ft=ft(i,$))){Kg(de,ft,a,re);break e}je&&je(i,V,$),i==="focusout"&&$&&V.type==="number"&&$.memoizedProps.value!=null&&Fe(V,"number",V.value)}switch(je=$?rs($):window,i){case"focusin":(Ig(je)||je.contentEditable==="true")&&(Ba=je,Hh=$,Hl=null);break;case"focusout":Hl=Hh=Ba=null;break;case"mousedown":Uh=!0;break;case"contextmenu":case"mouseup":case"dragend":Uh=!1,Qg(de,a,re);break;case"selectionchange":if(MC)break;case"keydown":case"keyup":Qg(de,a,re)}var Ze;if(Bh)e:{switch(i){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else La?Ug(i,a)&&(lt="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(lt="onCompositionStart");lt&&(zg&&a.locale!=="ko"&&(La||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&La&&(Ze=j()):(cs=re,x="value"in cs?cs.value:cs.textContent,La=!0)),je=au($,lt),0<je.length&&(lt=new Bg(lt,i,null,a,re),de.push({event:lt,listeners:je}),Ze?lt.data=Ze:(Ze=Pg(a),Ze!==null&&(lt.data=Ze)))),(Ze=bC?SC(i,a):wC(i,a))&&(lt=au($,"onBeforeInput"),0<lt.length&&(je=new Bg("onBeforeInput","beforeinput",null,a,re),de.push({event:je,listeners:lt}),je.data=Ze)),fx(de,i,$,a,re)}xy(de,n)})}function co(i,n,a){return{instance:i,listener:n,currentTarget:a}}function au(i,n){for(var a=n+"Capture",l=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=$r(i,a),u!=null&&l.unshift(co(i,u,d)),u=$r(i,n),u!=null&&l.push(co(i,u,d))),i.tag===3)return l;i=i.return}return[]}function _x(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function ky(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,M=C.alternate,$=C.stateNode;if(C=C.tag,M!==null&&M===l)break;C!==5&&C!==26&&C!==27||$===null||(M=$,u?($=$r(a,d),$!=null&&_.unshift(co(a,$,M))):u||($=$r(a,d),$!=null&&_.push(co(a,$,M)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var vx=/\r\n?/g,yx=/\u0000|\uFFFD/g;function Ty(i){return(typeof i=="string"?i:""+i).replace(vx,`
|
|
10
|
+
`).replace(yx,"")}function Dy(i,n){return n=Ty(n),Ty(i)===n}function wt(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||Bt(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&Bt(i,""+l);break;case"className":as(i,"class",l);break;case"tabIndex":as(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":as(i,a,l);break;case"style":Ot(i,l,d);break;case"data":if(n!=="object"){as(i,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Cs(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="formAction"?(n!=="input"&&wt(i,n,"name",u.name,u,null),wt(i,n,"formEncType",u.formEncType,u,null),wt(i,n,"formMethod",u.formMethod,u,null),wt(i,n,"formTarget",u.formTarget,u,null)):(wt(i,n,"encType",u.encType,u,null),wt(i,n,"method",u.method,u,null),wt(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Cs(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=ci);break;case"onScroll":l!=null&&st("scroll",i);break;case"onScrollEnd":l!=null&&st("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=Cs(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":st("beforetoggle",i),st("toggle",i),Xs(i,"popover",l);break;case"xlinkActuate":bn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":bn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":bn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":bn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":bn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":bn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":bn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":bn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":bn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":Xs(i,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Gt.get(a)||a,Xs(i,a,l))}}function hf(i,n,a,l,u,d){switch(a){case"style":Ot(i,l,d);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Bt(i,l):(typeof l=="number"||typeof l=="bigint")&&Bt(i,""+l);break;case"onScroll":l!=null&&st("scroll",i);break;case"onScrollEnd":l!=null&&st("scrollend",i);break;case"onClick":l!=null&&(i.onclick=ci);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Vs.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[Vt]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof l=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):Xs(i,a,l)}}}function Fi(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":st("error",i),st("load",i);var l=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:wt(i,n,d,_,a,null)}}u&&wt(i,n,"srcSet",a.srcSet,a,null),l&&wt(i,n,"src",a.src,a,null);return;case"input":st("invalid",i);var C=d=_=u=null,M=null,$=null;for(l in a)if(a.hasOwnProperty(l)){var re=a[l];if(re!=null)switch(l){case"name":u=re;break;case"type":_=re;break;case"checked":M=re;break;case"defaultChecked":$=re;break;case"value":d=re;break;case"defaultValue":C=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,n));break;default:wt(i,n,l,re,a,null)}}pe(i,d,C,M,$,_,u,!1);return;case"select":st("invalid",i),l=_=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":l=C;default:wt(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?Pe(i,!!l,n,!1):a!=null&&Pe(i,!!l,a,!0);return;case"textarea":st("invalid",i),d=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":l=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(r(91));break;default:wt(i,n,_,C,a,null)}dt(i,l,u,d);return;case"option":for(M in a)a.hasOwnProperty(M)&&(l=a[M],l!=null)&&(M==="selected"?i.selected=l&&typeof l!="function"&&typeof l!="symbol":wt(i,n,M,l,a,null));return;case"dialog":st("beforetoggle",i),st("toggle",i),st("cancel",i),st("close",i);break;case"iframe":case"object":st("load",i);break;case"video":case"audio":for(l=0;l<oo.length;l++)st(oo[l],i);break;case"image":st("error",i),st("load",i);break;case"details":st("toggle",i);break;case"embed":case"source":case"link":st("error",i),st("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($ in a)if(a.hasOwnProperty($)&&(l=a[$],l!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:wt(i,n,$,l,a,null)}return;default:if(On(n)){for(re in a)a.hasOwnProperty(re)&&(l=a[re],l!==void 0&&hf(i,n,re,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&wt(i,n,C,l,a,null))}function bx(i,n,a,l){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,M=null,$=null,re=null;for(G in a){var de=a[G];if(a.hasOwnProperty(G)&&de!=null)switch(G){case"checked":break;case"value":break;case"defaultValue":M=de;default:l.hasOwnProperty(G)||wt(i,n,G,null,l,de)}}for(var V in l){var G=l[V];if(de=a[V],l.hasOwnProperty(V)&&(G!=null||de!=null))switch(V){case"type":d=G;break;case"name":u=G;break;case"checked":$=G;break;case"defaultChecked":re=G;break;case"value":_=G;break;case"defaultValue":C=G;break;case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(r(137,n));break;default:G!==de&&wt(i,n,V,G,l,de)}}O(i,_,C,M,$,re,d,u);return;case"select":G=_=C=V=null;for(d in a)if(M=a[d],a.hasOwnProperty(d)&&M!=null)switch(d){case"value":break;case"multiple":G=M;default:l.hasOwnProperty(d)||wt(i,n,d,null,l,M)}for(u in l)if(d=l[u],M=a[u],l.hasOwnProperty(u)&&(d!=null||M!=null))switch(u){case"value":V=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==M&&wt(i,n,u,d,l,M)}n=C,a=_,l=G,V!=null?Pe(i,!!a,V,!1):!!l!=!!a&&(n!=null?Pe(i,!!a,n,!0):Pe(i,!!a,a?[]:"",!1));return;case"textarea":G=V=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!l.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:wt(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":V=u;break;case"defaultValue":G=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==d&&wt(i,n,_,u,l,d)}Ge(i,V,G);return;case"option":for(var Ae in a)V=a[Ae],a.hasOwnProperty(Ae)&&V!=null&&!l.hasOwnProperty(Ae)&&(Ae==="selected"?i.selected=!1:wt(i,n,Ae,null,l,V));for(M in l)V=l[M],G=a[M],l.hasOwnProperty(M)&&V!==G&&(V!=null||G!=null)&&(M==="selected"?i.selected=V&&typeof V!="function"&&typeof V!="symbol":wt(i,n,M,V,l,G));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 Ke in a)V=a[Ke],a.hasOwnProperty(Ke)&&V!=null&&!l.hasOwnProperty(Ke)&&wt(i,n,Ke,null,l,V);for($ in l)if(V=l[$],G=a[$],l.hasOwnProperty($)&&V!==G&&(V!=null||G!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(r(137,n));break;default:wt(i,n,$,V,l,G)}return;default:if(On(n)){for(var Ct in a)V=a[Ct],a.hasOwnProperty(Ct)&&V!==void 0&&!l.hasOwnProperty(Ct)&&hf(i,n,Ct,void 0,l,V);for(re in l)V=l[re],G=a[re],!l.hasOwnProperty(re)||V===G||V===void 0&&G===void 0||hf(i,n,re,V,l,G);return}}for(var U in a)V=a[U],a.hasOwnProperty(U)&&V!=null&&!l.hasOwnProperty(U)&&wt(i,n,U,null,l,V);for(de in l)V=l[de],G=a[de],!l.hasOwnProperty(de)||V===G||V==null&&G==null||wt(i,n,de,V,l,G)}function Ry(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Sx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&Ry(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var M=a[l],$=M.startTime;if($>C)break;var re=M.transferSize,de=M.initiatorType;re&&Ry(de)&&(M=M.responseEnd,_+=re*(M<C?1:(C-$)/(M-$)))}if(--l,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 df=null,ff=null;function lu(i){return i.nodeType===9?i:i.ownerDocument}function My(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 Ny(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 pf(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 mf=null;function wx(){var i=window.event;return i&&i.type==="popstate"?i===mf?!1:(mf=i,!0):(mf=null,!1)}var Ay=typeof setTimeout=="function"?setTimeout:void 0,Cx=typeof clearTimeout=="function"?clearTimeout:void 0,Ly=typeof Promise=="function"?Promise:void 0,xx=typeof queueMicrotask=="function"?queueMicrotask:typeof Ly<"u"?function(i){return Ly.resolve(null).then(i).catch(Ex)}:Ay;function Ex(i){setTimeout(function(){throw i})}function gr(i){return i==="head"}function By(i,n){var a=n,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),ll(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")uo(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,uo(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[bs]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&uo(i.ownerDocument.body);a=u}while(a);ll(n)}function Oy(i,n){var a=i;i=0;do{var l=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||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function gf(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":gf(a),Ys(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function kx(i,n,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[bs])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=Kn(i.nextSibling),i===null)break}return null}function Tx(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=Kn(i.nextSibling),i===null))return null;return i}function zy(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=Kn(i.nextSibling),i===null))return null;return i}function _f(i){return i.data==="$?"||i.data==="$~"}function vf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Dx(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var l=function(){n(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function Kn(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 yf=null;function jy(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return Kn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function Hy(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 Uy(i,n,a){switch(n=lu(a),i){case"html":if(i=n.documentElement,!i)throw Error(r(452));return i;case"head":if(i=n.head,!i)throw Error(r(453));return i;case"body":if(i=n.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function uo(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);Ys(i)}var Fn=new Map,Py=new Set;function ou(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Hs=Y.d;Y.d={f:Rx,r:Mx,D:Nx,C:Ax,L:Lx,m:Bx,X:zx,S:Ox,M:jx};function Rx(){var i=Hs.f(),n=Jc();return i||n}function Mx(i){var n=Ln(i);n!==null&&n.tag===5&&n.type==="form"?nv(n):Hs.r(i)}var sl=typeof document>"u"?null:document;function Iy(i,n,a){var l=sl;if(l&&typeof n=="string"&&n){var u=Xi(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},l.querySelector(u)===null&&(n=l.createElement("link"),Fi(n,"link",i),Xt(n),l.head.appendChild(n)))}}function Nx(i){Hs.D(i),Iy("dns-prefetch",i,null)}function Ax(i,n){Hs.C(i,n),Iy("preconnect",i,n)}function Lx(i,n,a){Hs.L(i,n,a);var l=sl;if(l&&i&&n){var u='link[rel="preload"][as="'+Xi(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Xi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Xi(a.imageSizes)+'"]')):u+='[href="'+Xi(i)+'"]';var d=u;switch(n){case"style":d=rl(i);break;case"script":d=al(i)}Fn.has(d)||(i=y({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),Fn.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(ho(d))||n==="script"&&l.querySelector(fo(d))||(n=l.createElement("link"),Fi(n,"link",i),Xt(n),l.head.appendChild(n)))}}function Bx(i,n){Hs.m(i,n);var a=sl;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Xi(l)+'"][href="'+Xi(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=al(i)}if(!Fn.has(d)&&(i=y({rel:"modulepreload",href:i},n),Fn.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(fo(d)))return}l=a.createElement("link"),Fi(l,"link",i),Xt(l),a.head.appendChild(l)}}}function Ox(i,n,a){Hs.S(i,n,a);var l=sl;if(l&&i){var u=yn(l).hoistableStyles,d=rl(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(ho(d)))C.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":n},a),(a=Fn.get(d))&&bf(i,a);var M=_=l.createElement("link");Xt(M),Fi(M,"link",i),M._p=new Promise(function($,re){M.onload=$,M.onerror=re}),M.addEventListener("load",function(){C.loading|=1}),M.addEventListener("error",function(){C.loading|=2}),C.loading|=4,cu(_,n,l)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function zx(i,n){Hs.X(i,n);var a=sl;if(a&&i){var l=yn(a).hoistableScripts,u=al(i),d=l.get(u);d||(d=a.querySelector(fo(u)),d||(i=y({src:i,async:!0},n),(n=Fn.get(u))&&Sf(i,n),d=a.createElement("script"),Xt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function jx(i,n){Hs.M(i,n);var a=sl;if(a&&i){var l=yn(a).hoistableScripts,u=al(i),d=l.get(u);d||(d=a.querySelector(fo(u)),d||(i=y({src:i,async:!0,type:"module"},n),(n=Fn.get(u))&&Sf(i,n),d=a.createElement("script"),Xt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Ky(i,n,a,l){var u=(u=xe.current)?ou(u):null;if(!u)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=rl(a.href),a=yn(u).hoistableStyles,l=a.get(n),l||(l={type:"style",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=rl(a.href);var d=yn(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(ho(i)))&&!d._p&&(_.instance=d,_.state.loading=5),Fn.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},Fn.set(i,a),d||Hx(u,i,a,_.state))),n&&l===null)throw Error(r(528,""));return _}if(n&&l!==null)throw Error(r(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=al(a),a=yn(u).hoistableScripts,l=a.get(n),l||(l={type:"script",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function rl(i){return'href="'+Xi(i)+'"'}function ho(i){return'link[rel="stylesheet"]['+i+"]"}function Fy(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function Hx(i,n,a,l){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=i.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Fi(n,"link",a),Xt(n),i.head.appendChild(n))}function al(i){return'[src="'+Xi(i)+'"]'}function fo(i){return"script[async]"+i}function Wy(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+Xi(a.href)+'"]');if(l)return n.instance=l,Xt(l),l;var u=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Xt(l),Fi(l,"style",u),cu(l,a.precedence,i),n.instance=l;case"stylesheet":u=rl(a.href);var d=i.querySelector(ho(u));if(d)return n.state.loading|=4,n.instance=d,Xt(d),d;l=Fy(a),(u=Fn.get(u))&&bf(l,u),d=(i.ownerDocument||i).createElement("link"),Xt(d);var _=d;return _._p=new Promise(function(C,M){_.onload=C,_.onerror=M}),Fi(d,"link",l),n.state.loading|=4,cu(d,a.precedence,i),n.instance=d;case"script":return d=al(a.src),(u=i.querySelector(fo(d)))?(n.instance=u,Xt(u),u):(l=a,(u=Fn.get(d))&&(l=y({},a),Sf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),Xt(u),Fi(u,"link",l),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(r(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,cu(l,a.precedence,i));return n.instance}function cu(i,n,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,d=u,_=0;_<l.length;_++){var C=l[_];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 bf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function Sf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var uu=null;function qy(i,n,a){if(uu===null){var l=new Map,u=uu=new Map;u.set(a,l)}else u=uu,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[bs]||d[Kt]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=l.get(_);C?C.push(d):l.set(_,[d])}}return l}function $y(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function Ux(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 Yy(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Px(i,n,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=rl(l.href),d=n.querySelector(ho(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=hu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,Xt(d);return}d=n.ownerDocument||n,l=Fy(l),(u=Fn.get(u))&&bf(l,u),d=d.createElement("link"),Xt(d);var _=d;_._p=new Promise(function(C,M){_.onload=C,_.onerror=M}),Fi(d,"link",l),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=hu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var wf=0;function Ix(i,n){return i.stylesheets&&i.count===0&&fu(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&fu(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&wf===0&&(wf=62500*Sx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&fu(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>wf?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function hu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var du=null;function fu(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,du=new Map,n.forEach(Kx,i),du=null,hu.call(i))}function Kx(i,n){if(!(n.state.loading&4)){var a=du.get(i);if(a)var l=a.get(null);else{a=new Map,du.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,_),l=_)}l&&a.set(null,l)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||l,d===l&&a.set(null,u),a.set(_,u),this.count++,l=hu.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var po={$$typeof:I,Provider:null,Consumer:null,_currentValue:D,_currentValue2:D,_threadCount:0};function Fx(i,n,a,l,u,d,_,C,M){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=oi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oi(0),this.hiddenUpdates=oi(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function Vy(i,n,a,l,u,d,_,C,M,$,re,de){return i=new Fx(i,n,a,_,M,$,re,de,C),n=1,d===!0&&(n|=24),d=wn(3,null,null,n),i.current=d,d.stateNode=i,n=ed(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},sd(d),i}function Xy(i){return i?(i=ja,i):ja}function Gy(i,n,a,l,u,d){u=Xy(u),l.context===null?l.context=u:l.pendingContext=u,l=rr(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=ar(i,l,n),a!==null&&(fn(a,i,n),ql(a,i,n))}function Zy(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function Cf(i,n){Zy(i,n),(i=i.alternate)&&Zy(i,n)}function Qy(i){if(i.tag===13||i.tag===31){var n=Xr(i,67108864);n!==null&&fn(n,i,67108864),Cf(i,67108864)}}function Jy(i){if(i.tag===13||i.tag===31){var n=Tn();n=vn(n);var a=Xr(i,n);a!==null&&fn(a,i,n),Cf(i,n)}}var pu=!0;function Wx(i,n,a,l){var u=L.T;L.T=null;var d=Y.p;try{Y.p=2,xf(i,n,a,l)}finally{Y.p=d,L.T=u}}function qx(i,n,a,l){var u=L.T;L.T=null;var d=Y.p;try{Y.p=8,xf(i,n,a,l)}finally{Y.p=d,L.T=u}}function xf(i,n,a,l){if(pu){var u=Ef(l);if(u===null)uf(i,n,l,mu,a),tb(i,l);else if(Yx(u,i,n,a,l))l.stopPropagation();else if(tb(i,l),n&4&&-1<$x.indexOf(i)){for(;u!==null;){var d=Ln(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=kt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var M=1<<31-bt(_);C.entanglements[1]|=M,_&=~M}fs(d),(mt&6)===0&&(Zc=ot()+500,lo(0))}}break;case 31:case 13:C=Xr(d,2),C!==null&&fn(C,d,2),Jc(),Cf(d,2)}if(d=Ef(l),d===null&&uf(i,n,l,mu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else uf(i,n,l,null,a)}}function Ef(i){return i=Zs(i),kf(i)}var mu=null;function kf(i){if(mu=null,i=Yi(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 mu=i,null}function eb(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(gi()){case Ji:return 2;case qi:return 8;case $t:case _i:return 32;case _n:return 268435456;default:return 32}default:return 32}}var Tf=!1,_r=null,vr=null,yr=null,mo=new Map,go=new Map,br=[],$x="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 tb(i,n){switch(i){case"focusin":case"focusout":_r=null;break;case"dragenter":case"dragleave":vr=null;break;case"mouseover":case"mouseout":yr=null;break;case"pointerover":case"pointerout":mo.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":go.delete(n.pointerId)}}function _o(i,n,a,l,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:l,nativeEvent:d,targetContainers:[u]},n!==null&&(n=Ln(n),n!==null&&Qy(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function Yx(i,n,a,l,u){switch(n){case"focusin":return _r=_o(_r,i,n,a,l,u),!0;case"dragenter":return vr=_o(vr,i,n,a,l,u),!0;case"mouseover":return yr=_o(yr,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return mo.set(d,_o(mo.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,go.set(d,_o(go.get(d)||null,i,n,a,l,u)),!0}return!1}function ib(i){var n=Yi(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,_t(i.priority,function(){Jy(a)});return}}else if(n===31){if(n=p(a),n!==null){i.blockedOn=n,_t(i.priority,function(){Jy(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 gu(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=Ef(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);Gs=l,a.target.dispatchEvent(l),Gs=null}else return n=Ln(a),n!==null&&Qy(n),i.blockedOn=a,!1;n.shift()}return!0}function nb(i,n,a){gu(i)&&a.delete(n)}function Vx(){Tf=!1,_r!==null&&gu(_r)&&(_r=null),vr!==null&&gu(vr)&&(vr=null),yr!==null&&gu(yr)&&(yr=null),mo.forEach(nb),go.forEach(nb)}function _u(i,n){i.blockedOn===n&&(i.blockedOn=null,Tf||(Tf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Vx)))}var vu=null;function sb(i){vu!==i&&(vu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){vu===i&&(vu=null);for(var n=0;n<i.length;n+=3){var a=i[n],l=i[n+1],u=i[n+2];if(typeof l!="function"){if(kf(l||a)===null)continue;break}var d=Ln(a);d!==null&&(i.splice(n,3),n-=3,xd(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function ll(i){function n(M){return _u(M,i)}_r!==null&&_u(_r,i),vr!==null&&_u(vr,i),yr!==null&&_u(yr,i),mo.forEach(n),go.forEach(n);for(var a=0;a<br.length;a++){var l=br[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<br.length&&(a=br[0],a.blockedOn===null);)ib(a),a.blockedOn===null&&br.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],d=a[l+1],_=u[Vt]||null;if(typeof d=="function")_||sb(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[Vt]||null)C=_.formAction;else if(kf(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),sb(a)}}}function rb(){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),l||setTimeout(a,20)}function a(){if(!l&&!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 l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Df(i){this._internalRoot=i}yu.prototype.render=Df.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(r(409));var a=n.current,l=Tn();Gy(a,l,i,n,null,null)},yu.prototype.unmount=Df.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Gy(i.current,2,null,i,null,null),Jc(),n[At]=null}};function yu(i){this._internalRoot=i}yu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Hi();i={blockedOn:null,target:i,priority:n};for(var a=0;a<br.length&&n!==0&&n<br[a].priority;a++);br.splice(a,0,i),a===0&&ib(i)}};var ab=t.version;if(ab!=="19.2.6")throw Error(r(527,ab,"19.2.6"));Y.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=f(n),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var Xx={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var bu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bu.isDisabled&&bu.supportsFiber)try{ut=bu.inject(Xx),gt=bu}catch{}}return yo.createRoot=function(i,n){if(!o(i))throw Error(r(299));var a=!1,l="",u=fv,d=pv,_=mv;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=Vy(i,1,!1,null,null,a,l,null,u,d,_,rb),i[At]=n.current,cf(i),new Df(n)},yo.hydrateRoot=function(i,n,a){if(!o(i))throw Error(r(299));var l=!1,u="",d=fv,_=pv,C=mv,M=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!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&&(M=a.formState)),n=Vy(i,1,!0,n,a??null,l,u,M,d,_,C,rb),n.context=Xy(null),a=n.current,l=Tn(),l=vn(l),u=rr(l),u.callback=null,ar(a,u,l),a=l,n.current.lanes=a,Ti(n,a),fs(n),i[At]=n.current,cf(i),new yu(n)},yo.version="19.2.6",yo}var gb;function rE(){if(gb)return Nf.exports;gb=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Nf.exports=sE(),Nf.exports}var aE=rE();class is extends Error{constructor(t,s){super(s),this.status=t,this.name="ApiError"}status}function dh(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Io(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",it("POST",t)),login:t=>Ne(e,"/api/auth/login",it("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",it("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",it("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",it("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await hl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",it("POST",t)),removeNetwork:async t=>{await hl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),getDistributedCallSettings:()=>Ne(e,"/api/distcalls/settings"),updateDistributedCallSettings:t=>Ne(e,"/api/distcalls/settings",it("PUT",t)),addAgent:t=>Ne(e,"/api/agents",it("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",it("PUT",{serverIds:t})),renameAgent:(t,s)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,it("PATCH",{name:s})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",it("PATCH",{name:t})),removeAgent:async t=>{await hl(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",it("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",it("POST",t)),listFiles:t=>Ne(e,"/api/files/list",it("POST",t)),readFile:t=>Ne(e,"/api/files/read",it("POST",t)),writeFile:t=>Ne(e,"/api/files/write",it("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",it("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",it("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",it("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",it("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",it("POST",t)),previewFile:t=>v0(e,"/api/files/preview",it("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",it("POST",t)),closeTerminal:async t=>{await hl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,s)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,it("PATCH",{title:s})),getTerminalHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Io(s)}`),getTerminalTranscriptHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Io(s)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const s=new FormData;return s.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:s})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",it("PUT",t)),deleteNotificationAsset:async t=>{await hl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function Xo(e,t=fetch){const s=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,s("terminals")),createTerminal:(r={})=>Ne(t,s("terminals"),it("POST",r)),closeTerminal:async r=>{await hl(t,s(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ne(t,s(`terminals/${encodeURIComponent(r)}`),it("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/history`)}${Io(o)}`),getTerminalTranscriptHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Io(o)}`),getTerminalTranscriptSource:r=>Ne(t,s(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalLayout:()=>Ne(t,s("terminal-layout")),saveTerminalLayout:r=>Ne(t,s("terminal-layout"),it("PUT",r)),createFileRoot:r=>Ne(t,s("files/root"),it("POST",r)),listFiles:r=>Ne(t,s("files/list"),it("POST",r)),readFile:r=>Ne(t,s("files/read"),it("POST",r)),writeFile:r=>Ne(t,s("files/write"),it("POST",r)),createFileEntry:r=>Ne(t,s("files/create"),it("POST",r)),moveFileEntry:r=>Ne(t,s("files/move"),it("POST",r)),previewDeleteFileEntry:r=>Ne(t,s("files/delete-preview"),it("POST",r)),deleteFileEntry:r=>Ne(t,s("files/delete"),it("POST",r)),openFileInTerminal:r=>Ne(t,s("files/open"),it("POST",r)),previewFile:r=>v0(t,s("files/preview"),it("POST",r)),createWebSocketUrl:(r,o=window.location.href)=>lE(s(`terminals/${encodeURIComponent(r)}/ws`),o)}}function lE(e,t){const s=new URL(t);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.pathname=e,s.search="",s.hash="",s.toString()}function it(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Io(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);const s=t.toString();return s?`?${s}`:""}async function Ne(e,t,s){const r=await e(t,s??{credentials:"same-origin"});await Pm(r);try{return await r.json()}catch{throw new is(r.status,"invalid_json_response")}}async function hl(e,t,s){const r=await e(t,s);await Pm(r)}async function v0(e,t,s){const r=await e(t,s);return await Pm(r),r.blob()}async function Pm(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const s=await e.json(),r=typeof s.error=="string"?s.error:s.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new is(e.status,t)}const Im="nterminal.theme.id",y0="nterminal.theme.accent",dp="nterminal:theme",$u=[{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",..._b({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",..._b({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],vl="midnight";function fh(e){return $u.some(t=>t.id===e)?e:vl}function Km(e){return $u.find(t=>t.id===e)??$u[0]}function Br(){if(typeof window>"u")return vl;try{const e=window.localStorage.getItem(Im);return e?fh(e):dE(window.localStorage.getItem(y0))}catch{return vl}}function oE(e){const t=fh(e);if(typeof window<"u"){try{window.localStorage.setItem(Im,t)}catch{}Fm(t),window.dispatchEvent(new CustomEvent(dp,{detail:t}))}return t}function Fm(e=Br()){if(typeof document>"u")return;const t=Km(fh(e)),s=document.documentElement;s.dataset.ntTheme=t.id,s.style.setProperty("color-scheme",t.mode),Qe(s,"--nt-bg",t.tokens.bg),Qe(s,"--nt-bg-2",t.tokens.bg2),Qe(s,"--nt-bg-sidebar",t.tokens.bgSidebar),Qe(s,"--nt-line",t.tokens.line),Qe(s,"--nt-line-2",t.tokens.line2),Qe(s,"--nt-fg",t.tokens.fg),Qe(s,"--nt-fg-2",t.tokens.fg2),Qe(s,"--nt-fg-3",t.tokens.fg3),Qe(s,"--nt-fg-4",t.tokens.fg4),Qe(s,"--nt-accent",t.tokens.accent),Qe(s,"--nt-accent-soft",t.tokens.accentSoft),Qe(s,"--nt-accent-glow",t.tokens.accentGlow),Qe(s,"--nt-on-accent",t.tokens.onAccent),Qe(s,"--nt-ok",t.tokens.ok),Qe(s,"--nt-danger",t.tokens.danger),Qe(s,"--nt-on-danger",t.tokens.onDanger),Qe(s,"--nt-danger-soft",t.tokens.dangerSoft),Qe(s,"--nt-danger-line",t.tokens.dangerLine),Qe(s,"--nt-warning",t.tokens.warning),Qe(s,"--nt-warn",t.tokens.warning),Qe(s,"--nt-warning-soft",t.tokens.warningSoft),Qe(s,"--nt-warning-glow",t.tokens.warningGlow),Qe(s,"--nt-scrim",t.tokens.scrim),Qe(s,"--nt-scrim-soft",t.tokens.scrimSoft),Qe(s,"--nt-shadow",t.tokens.shadow),Qe(s,"--nt-shadow-strong",t.tokens.shadowStrong),Qe(s,"--nt-floating-bg",t.tokens.floatingBg),Qe(s,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),Qe(s,"--nt-floating-bg-hover",t.tokens.floatingBgHover),Qe(s,"--nt-subtle-fill",t.tokens.subtleFill),Qe(s,"--nt-hover-fill",t.tokens.hoverFill),Qe(s,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),Qe(s,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),Qe(s,"--nt-transcript-user",t.tokens.transcriptUser),Qe(s,"--nt-transcript-assistant",t.tokens.transcriptAssistant),Qe(s,"--nt-transcript-tool",t.tokens.transcriptTool),Qe(s,"--nt-transcript-command",t.tokens.transcriptCommand),Qe(s,"--nt-transcript-code",t.tokens.transcriptCode),Qe(s,"--nt-transcript-search",t.tokens.transcriptSearch),Qe(s,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),Qe(s,"--nt-qr-bg",t.tokens.qrBg)}function cE(e=Br()){return Km(fh(e)).xterm}function Wm(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===Im||s.key===y0)&&(Fm(Br()),e())};return window.addEventListener(dp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(dp,e),window.removeEventListener("storage",t)}}function Qe(e,t,s){e.style.setProperty(t,s)}function _b(e){const t=uE(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 uE(e){const t=[];for(let s=16;s<=e;s+=1)t.push(hE(s));return t}function hE(e){if(e>=16&&e<=231){const t=e-16,s=[0,95,135,175,215,255],r=s[Math.floor(t/36)%6],o=s[Math.floor(t/6)%6],c=s[t%6];return vb(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return vb(t,t,t)}return"#000000"}function vb(e,t,s){return`#${Of(e)}${Of(t)}${Of(s)}`}function Of(e){return e.toString(16).padStart(2,"0")}function dE(e){return e==="signal-red"?"signal-red":vl}function b0(){const e=v.useSyncExternalStore(Wm,Br,()=>vl);return Km(e).mode==="light"?"-light":""}function S0({size:e=22}){const t=b0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function w0({height:e=18}){const t=b0(),s=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:s,height:e,alt:"NTerminal"})}var No=_0();const ph=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function qm(e){return"nodeType"in e}function gn(e){var t,s;return e?xl(e)?e:qm(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function $m(e){const{Document:t}=gn(e);return e instanceof t}function lc(e){return xl(e)?!1:e instanceof gn(e).HTMLElement}function C0(e){return e instanceof gn(e).SVGElement}function El(e){return e?xl(e)?e.document:qm(e)?$m(e)?e:lc(e)||C0(e)?e.ownerDocument:document:document:document}const Or=ph?v.useLayoutEffect:v.useEffect;function Ym(e){const t=v.useRef(e);return Or(()=>{t.current=e}),v.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function fE(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),s=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Go(e,t){t===void 0&&(t=[e]);const s=v.useRef(e);return Or(()=>{s.current!==e&&(s.current=e)},t),s}function oc(e,t){const s=v.useRef();return v.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...t])}function Yu(e){const t=Ym(e),s=v.useRef(null),r=v.useCallback(o=>{o!==s.current&&t?.(o,s.current),s.current=o},[]);return[s,r]}function fp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let zf={};function mh(e,t){return v.useMemo(()=>{if(t)return t;const s=zf[e]==null?0:zf[e]+1;return zf[e]=s,e+"-"+s},[e,t])}function x0(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return r.reduce((c,h)=>{const p=Object.entries(h);for(const[g,f]of p){const b=c[g];b!=null&&(c[g]=b+e*f)}return c},{...t})}}const gl=x0(1),Vu=x0(-1);function pE(e){return"clientX"in e&&"clientY"in e}function E0(e){if(!e)return!1;const{KeyboardEvent:t}=gn(e.target);return t&&e instanceof t}function mE(e){if(!e)return!1;const{TouchEvent:t}=gn(e.target);return t&&e instanceof t}function pp(e){if(mE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return pE(e)?{x:e.clientX,y:e.clientY}:null}const mp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[mp.Translate.toString(e),mp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:r}=e;return t+" "+s+"ms "+r}}}),yb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function gE(e){return e.matches(yb)?e:e.querySelector(yb)}const _E={display:"none"};function vE(e){let{id:t,value:s}=e;return Ei.createElement("div",{id:t,style:_E},s)}function yE(e){let{id:t,announcement:s,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ei.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},s)}function bE(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const k0=v.createContext(null);function SE(e){const t=v.useContext(k0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function wE(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(h=>{var p;return(p=h[o])==null?void 0:p.call(h,c)})},[e]),t]}const CE={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
|
+
`},xE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function EE(e){let{announcements:t=xE,container:s,hiddenTextDescribedById:r,screenReaderInstructions:o=CE}=e;const{announce:c,announcement:h}=bE(),p=mh("DndLiveRegion"),[g,f]=v.useState(!1);if(v.useEffect(()=>{f(!0)},[]),SE(v.useMemo(()=>({onDragStart(y){let{active:w}=y;c(t.onDragStart({active:w}))},onDragMove(y){let{active:w,over:S}=y;t.onDragMove&&c(t.onDragMove({active:w,over:S}))},onDragOver(y){let{active:w,over:S}=y;c(t.onDragOver({active:w,over:S}))},onDragEnd(y){let{active:w,over:S}=y;c(t.onDragEnd({active:w,over:S}))},onDragCancel(y){let{active:w,over:S}=y;c(t.onDragCancel({active:w,over:S}))}}),[c,t])),!g)return null;const b=Ei.createElement(Ei.Fragment,null,Ei.createElement(vE,{id:r,value:o.draggable}),Ei.createElement(yE,{id:p,announcement:h}));return s?No.createPortal(b,s):b}var xi;(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"})(xi||(xi={}));function Xu(){}function bb(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function kE(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ns=Object.freeze({x:0,y:0});function TE(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return r-s}function DE(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function RE(e,t){const s=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=o-r,p=c-s;if(r<o&&s<c){const g=t.width*t.height,f=e.width*e.height,b=h*p,y=b/(g+f-b);return Number(y.toFixed(4))}return 0}const ME=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const o=[];for(const c of r){const{id:h}=c,p=s.get(h);if(p){const g=RE(p,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(TE)};function NE(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function T0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ns}function AE(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((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}),{...s})}}const LE=AE(1);function BE(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 OE(e,t,s){const r=BE(t);if(!r)return e;const{scaleX:o,scaleY:c,x:h,y:p}=r,g=e.left-h-(1-o)*parseFloat(s),f=e.top-p-(1-c)*parseFloat(s.slice(s.indexOf(" ")+1)),b=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:b,height:y,top:f,right:g+b,bottom:f+y,left:g}}const zE={ignoreTransform:!1};function cc(e,t){t===void 0&&(t=zE);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:b}=gn(e).getComputedStyle(e);f&&(s=OE(s,f,b))}const{top:r,left:o,width:c,height:h,bottom:p,right:g}=s;return{top:r,left:o,width:c,height:h,bottom:p,right:g}}function Sb(e){return cc(e,{ignoreTransform:!0})}function jE(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function HE(e,t){return t===void 0&&(t=gn(e).getComputedStyle(e)),t.position==="fixed"}function UE(e,t){t===void 0&&(t=gn(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?s.test(c):!1})}function Vm(e,t){const s=[];function r(o){if(t!=null&&s.length>=t||!o)return s;if($m(o)&&o.scrollingElement!=null&&!s.includes(o.scrollingElement))return s.push(o.scrollingElement),s;if(!lc(o)||C0(o)||s.includes(o))return s;const c=gn(e).getComputedStyle(o);return o!==e&&UE(o,c)&&s.push(o),HE(o,c)?s:r(o.parentNode)}return e?r(e):s}function D0(e){const[t]=Vm(e,1);return t??null}function jf(e){return!ph||!e?null:xl(e)?e:qm(e)?$m(e)||e===El(e).scrollingElement?window:lc(e)?e:null:null}function R0(e){return xl(e)?e.scrollX:e.scrollLeft}function M0(e){return xl(e)?e.scrollY:e.scrollTop}function gp(e){return{x:R0(e),y:M0(e)}}var Ni;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ni||(Ni={}));function N0(e){return!ph||!e?!1:e===document.scrollingElement}function A0(e){const t={x:0,y:0},s=N0(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=r.y,p=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:h,isRight:p,maxScroll:r,minScroll:t}}const PE={x:.2,y:.2};function IE(e,t,s,r,o){let{top:c,left:h,right:p,bottom:g}=s;r===void 0&&(r=10),o===void 0&&(o=PE);const{isTop:f,isBottom:b,isLeft:y,isRight:w}=A0(e),S={x:0,y:0},E={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+T.height?(S.y=Ni.Backward,E.y=r*Math.abs((t.top+T.height-c)/T.height)):!b&&g>=t.bottom-T.height&&(S.y=Ni.Forward,E.y=r*Math.abs((t.bottom-T.height-g)/T.height)),!w&&p>=t.right-T.width?(S.x=Ni.Forward,E.x=r*Math.abs((t.right-T.width-p)/T.width)):!y&&h<=t.left+T.width&&(S.x=Ni.Backward,E.x=r*Math.abs((t.left+T.width-h)/T.width)),{direction:S,speed:E}}function KE(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:s,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:s,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function L0(e){return e.reduce((t,s)=>gl(t,gp(s)),ns)}function FE(e){return e.reduce((t,s)=>t+R0(s),0)}function WE(e){return e.reduce((t,s)=>t+M0(s),0)}function qE(e,t){if(t===void 0&&(t=cc),!e)return;const{top:s,left:r,bottom:o,right:c}=t(e);D0(e)&&(o<=0||c<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const $E=[["x",["left","right"],FE],["y",["top","bottom"],WE]];class Xm{constructor(t,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Vm(s),o=L0(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,p]of $E)for(const g of h)Object.defineProperty(this,g,{get:()=>{const f=p(r),b=o[c]-f;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ko{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=t}add(t,s,r){var o;(o=this.target)==null||o.addEventListener(t,s,r),this.listeners.push([t,s,r])}}function YE(e){const{EventTarget:t}=gn(e);return e instanceof t?e:El(e)}function Hf(e,t){const s=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+r**2)>t:"x"in t&&"y"in t?s>t.x&&r>t.y:"x"in t?s>t.x:"y"in t?r>t.y:!1}var $n;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})($n||($n={}));function wb(e){e.preventDefault()}function VE(e){e.stopPropagation()}var Nt;(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"})(Nt||(Nt={}));const B0={start:[Nt.Space,Nt.Enter],cancel:[Nt.Esc],end:[Nt.Space,Nt.Enter,Nt.Tab]},XE=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case Nt.Right:return{...s,x:s.x+25};case Nt.Left:return{...s,x:s.x-25};case Nt.Down:return{...s,y:s.y+25};case Nt.Up:return{...s,y:s.y-25}}};class O0{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:s}}=t;this.props=t,this.listeners=new Ko(El(s)),this.windowListeners=new Ko(gn(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($n.Resize,this.handleCancel),this.windowListeners.add($n.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($n.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,r=t.node.current;r&&qE(r),s(ns)}handleKeyDown(t){if(E0(t)){const{active:s,context:r,options:o}=this.props,{keyboardCodes:c=B0,coordinateGetter:h=XE,scrollBehavior:p="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:f}=r.current,b=f?{x:f.left,y:f.top}:ns;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:s,context:r.current,currentCoordinates:b});if(y){const w=Vu(y,b),S={x:0,y:0},{scrollableAncestors:E}=r.current;for(const T of E){const B=t.code,{isTop:A,isRight:N,isLeft:I,isBottom:P,maxScroll:te,minScroll:Q}=A0(T),le=KE(T),oe={x:Math.min(B===Nt.Right?le.right-le.width/2:le.right,Math.max(B===Nt.Right?le.left:le.left+le.width/2,y.x)),y:Math.min(B===Nt.Down?le.bottom-le.height/2:le.bottom,Math.max(B===Nt.Down?le.top:le.top+le.height/2,y.y))},ve=B===Nt.Right&&!N||B===Nt.Left&&!I,Ce=B===Nt.Down&&!P||B===Nt.Up&&!A;if(ve&&oe.x!==y.x){const ie=T.scrollLeft+w.x,J=B===Nt.Right&&ie<=te.x||B===Nt.Left&&ie>=Q.x;if(J&&!w.y){T.scrollTo({left:ie,behavior:p});return}J?S.x=T.scrollLeft-ie:S.x=B===Nt.Right?T.scrollLeft-te.x:T.scrollLeft-Q.x,S.x&&T.scrollBy({left:-S.x,behavior:p});break}else if(Ce&&oe.y!==y.y){const ie=T.scrollTop+w.y,J=B===Nt.Down&&ie<=te.y||B===Nt.Up&&ie>=Q.y;if(J&&!w.x){T.scrollTo({top:ie,behavior:p});return}J?S.y=T.scrollTop-ie:S.y=B===Nt.Down?T.scrollTop-te.y:T.scrollTop-Q.y,S.y&&T.scrollBy({top:-S.y,behavior:p});break}}this.handleMove(t,gl(Vu(y,this.referenceCoordinates),S))}}}handleMove(t,s){const{onMove:r}=this.props;t.preventDefault(),r(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}O0.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:r=B0,onActivation:o}=t,{active:c}=s;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Cb(e){return!!(e&&"distance"in e)}function xb(e){return!!(e&&"delay"in e)}class Gm{constructor(t,s,r){var o;r===void 0&&(r=YE(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=s;const{event:c}=t,{target:h}=c;this.props=t,this.events=s,this.document=El(h),this.documentListeners=new Ko(this.document),this.listeners=new Ko(r),this.windowListeners=new Ko(gn(h)),this.initialCoordinates=(o=pp(c))!=null?o:ns,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:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add($n.Resize,this.handleCancel),this.windowListeners.add($n.DragStart,wb),this.windowListeners.add($n.VisibilityChange,this.handleCancel),this.windowListeners.add($n.ContextMenu,wb),this.documentListeners.add($n.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(xb(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Cb(s)){this.handlePending(s);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,s){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add($n.Click,VE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($n.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:h,options:{activationConstraint:p}}=c;if(!o)return;const g=(s=pp(t))!=null?s:ns,f=Vu(o,g);if(!r&&p){if(Cb(p)){if(p.tolerance!=null&&Hf(f,p.tolerance))return this.handleCancel();if(Hf(f,p.distance))return this.handleStart()}if(xb(p)&&Hf(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===Nt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const GE={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class z0 extends Gm{constructor(t){const{event:s}=t,r=El(s.target);super(t,GE,r)}}z0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return!s.isPrimary||s.button!==0?!1:(r?.({event:s}),!0)}}];const ZE={move:{name:"mousemove"},end:{name:"mouseup"}};var _p;(function(e){e[e.RightClick=2]="RightClick"})(_p||(_p={}));class j0 extends Gm{constructor(t){super(t,ZE,El(t.event.target))}}j0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return s.button===_p.RightClick?!1:(r?.({event:s}),!0)}}];const Uf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class H0 extends Gm{constructor(t){super(t,Uf)}static setup(){return window.addEventListener(Uf.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Uf.move.name,t)};function t(){}}}H0.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;const{touches:o}=s;return o.length>1?!1:(r?.({event:s}),!0)}}];var Fo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Fo||(Fo={}));var Gu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Gu||(Gu={}));function QE(e){let{acceleration:t,activator:s=Fo.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:h=5,order:p=Gu.TreeOrder,pointerCoordinates:g,scrollableAncestors:f,scrollableAncestorRects:b,delta:y,threshold:w}=e;const S=e2({delta:y,disabled:!c}),[E,T]=fE(),B=v.useRef({x:0,y:0}),A=v.useRef({x:0,y:0}),N=v.useMemo(()=>{switch(s){case Fo.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case Fo.DraggableRect:return o}},[s,o,g]),I=v.useRef(null),P=v.useCallback(()=>{const Q=I.current;if(!Q)return;const le=B.current.x*A.current.x,oe=B.current.y*A.current.y;Q.scrollBy(le,oe)},[]),te=v.useMemo(()=>p===Gu.TreeOrder?[...f].reverse():f,[p,f]);v.useEffect(()=>{if(!c||!f.length||!N){T();return}for(const Q of te){if(r?.(Q)===!1)continue;const le=f.indexOf(Q),oe=b[le];if(!oe)continue;const{direction:ve,speed:Ce}=IE(Q,oe,N,t,w);for(const ie of["x","y"])S[ie][ve[ie]]||(Ce[ie]=0,ve[ie]=0);if(Ce.x>0||Ce.y>0){T(),I.current=Q,E(P,h),B.current=Ce,A.current=ve;return}}B.current={x:0,y:0},A.current={x:0,y:0},T()},[t,P,r,T,c,h,JSON.stringify(N),JSON.stringify(S),E,f,te,b,JSON.stringify(w)])}const JE={x:{[Ni.Backward]:!1,[Ni.Forward]:!1},y:{[Ni.Backward]:!1,[Ni.Forward]:!1}};function e2(e){let{delta:t,disabled:s}=e;const r=fp(t);return oc(o=>{if(s||!r||!o)return JE;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Ni.Backward]:o.x[Ni.Backward]||c.x===-1,[Ni.Forward]:o.x[Ni.Forward]||c.x===1},y:{[Ni.Backward]:o.y[Ni.Backward]||c.y===-1,[Ni.Forward]:o.y[Ni.Forward]||c.y===1}}},[s,t,r])}function t2(e,t){const s=t!=null?e.get(t):void 0,r=s?s.node.current:null;return oc(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function i2(e,t){return v.useMemo(()=>e.reduce((s,r)=>{const{sensor:o}=r,c=o.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,r)}));return[...s,...c]},[]),[e,t])}var Zo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Zo||(Zo={}));var vp;(function(e){e.Optimized="optimized"})(vp||(vp={}));const Eb=new Map;function n2(e,t){let{dragging:s,dependencies:r,config:o}=t;const[c,h]=v.useState(null),{frequency:p,measure:g,strategy:f}=o,b=v.useRef(e),y=B(),w=Go(y),S=v.useCallback(function(A){A===void 0&&(A=[]),!w.current&&h(N=>N===null?A:N.concat(A.filter(I=>!N.includes(I))))},[w]),E=v.useRef(null),T=oc(A=>{if(y&&!s)return Eb;if(!A||A===Eb||b.current!==e||c!=null){const N=new Map;for(let I of e){if(!I)continue;if(c&&c.length>0&&!c.includes(I.id)&&I.rect.current){N.set(I.id,I.rect.current);continue}const P=I.node.current,te=P?new Xm(g(P),P):null;I.rect.current=te,te&&N.set(I.id,te)}return N}return A},[e,c,s,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||S()},[s,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof p!="number"||E.current!==null||(E.current=setTimeout(()=>{S(),E.current=null},p))},[p,y,S,...r]),{droppableRects:T,measureDroppableContainers:S,measuringScheduled:c!=null};function B(){switch(f){case Zo.Always:return!1;case Zo.BeforeDragging:return s;default:return!s}}}function U0(e,t){return oc(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function s2(e,t){return U0(e,t)}function r2(e){let{callback:t,disabled:s}=e;const r=Ym(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function gh(e){let{callback:t,disabled:s}=e;const r=Ym(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function a2(e){return new Xm(cc(e),e)}function kb(e,t,s){t===void 0&&(t=a2);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=g??s)!=null?f:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=r2({callback(g){if(e)for(const f of g){const{type:b,target:y}=f;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=gh({callback:c});return Or(()=>{c(),e?(p?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),h?.disconnect())},[e]),r}function l2(e){const t=U0(e);return T0(e,t)}const Tb=[];function o2(e){const t=v.useRef(e),s=oc(r=>e?r&&r!==Tb&&e&&t.current&&e.parentNode===t.current.parentNode?r:Vm(e):Tb,[e]);return v.useEffect(()=>{t.current=e},[e]),s}function c2(e){const[t,s]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const h=jf(c.target);h&&s(p=>p?(p.set(h,gp(h)),new Map(p)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){h(c);const p=e.map(g=>{const f=jf(g);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,gp(f)]):null}).filter(g=>g!=null);s(p.length?new Map(p):null),r.current=e}return()=>{h(e),h(c)};function h(p){p.forEach(g=>{const f=jf(g);f?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>gl(c,h),ns):L0(e):ns,[e,t])}function Db(e,t){t===void 0&&(t=[]);const s=v.useRef(null);return v.useEffect(()=>{s.current=null},t),v.useEffect(()=>{const r=e!==ns;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Vu(e,s.current):ns}function u2(e){v.useEffect(()=>{if(!ph)return;const t=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function h2(e,t){return v.useMemo(()=>e.reduce((s,r)=>{let{eventName:o,handler:c}=r;return s[o]=h=>{c(h,t)},s},{}),[e,t])}function P0(e){return v.useMemo(()=>e?jE(e):null,[e])}const Rb=[];function d2(e,t){t===void 0&&(t=cc);const[s]=e,r=P0(s?gn(s):null),[o,c]=v.useState(Rb);function h(){c(()=>e.length?e.map(g=>N0(g)?r:new Xm(t(g),g)):Rb)}const p=gh({callback:h});return Or(()=>{p?.disconnect(),h(),e.forEach(g=>p?.observe(g))},[e]),o}function f2(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return lc(t)?t:e}function p2(e){let{measure:t}=e;const[s,r]=v.useState(null),o=v.useCallback(f=>{for(const{target:b}of f)if(lc(b)){r(y=>{const w=t(b);return y?{...y,width:w.width,height:w.height}:w});break}},[t]),c=gh({callback:o}),h=v.useCallback(f=>{const b=f2(f);c?.disconnect(),b&&c?.observe(b),r(b?t(b):null)},[t,c]),[p,g]=Yu(h);return v.useMemo(()=>({nodeRef:p,rect:s,setRef:g}),[s,p,g])}const m2=[{sensor:z0,options:{}},{sensor:O0,options:{}}],g2={current:{}},Bu={draggable:{measure:Sb},droppable:{measure:Sb,strategy:Zo.WhileDragging,frequency:vp.Optimized},dragOverlay:{measure:cc}};class Wo extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,r;return(s=(r=this.get(t))==null?void 0:r.node.current)!=null?s:void 0}}const _2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Wo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Xu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bu,measureDroppableContainers:Xu,windowRect:null,measuringScheduled:!1},v2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Xu,draggableNodes:new Map,over:null,measureDroppableContainers:Xu},_h=v.createContext(v2),y2=v.createContext(_2);function b2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Wo}}}function S2(e,t){switch(t.type){case xi.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case xi.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 xi.DragEnd:case xi.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case xi.RegisterDroppable:{const{element:s}=t,{id:r}=s,o=new Wo(e.droppable.containers);return o.set(r,s),{...e,droppable:{...e.droppable,containers:o}}}case xi.SetDroppableDisabled:{const{id:s,key:r,disabled:o}=t,c=e.droppable.containers.get(s);if(!c||r!==c.key)return e;const h=new Wo(e.droppable.containers);return h.set(s,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case xi.UnregisterDroppable:{const{id:s,key:r}=t,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const c=new Wo(e.droppable.containers);return c.delete(s),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function w2(e){let{disabled:t}=e;const{active:s,activatorEvent:r,draggableNodes:o}=v.useContext(_h),c=fp(r),h=fp(s?.id);return v.useEffect(()=>{if(!t&&!r&&c&&h!=null){if(!E0(c)||document.activeElement===c.target)return;const p=o.get(h);if(!p)return;const{activatorNode:g,node:f}=p;if(!g.current&&!f.current)return;requestAnimationFrame(()=>{for(const b of[g.current,f.current]){if(!b)continue;const y=gE(b);if(y){y.focus();break}}})}},[r,t,o,h,c]),null}function C2(e,t){let{transform:s,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),s):s}function x2(e){return v.useMemo(()=>({draggable:{...Bu.draggable,...e?.draggable},droppable:{...Bu.droppable,...e?.droppable},dragOverlay:{...Bu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function E2(e){let{activeNode:t,measure:s,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:p}=typeof o=="boolean"?{x:o,y:o}:o;Or(()=>{if(!h&&!p||!t){c.current=!1;return}if(c.current||!r)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const b=s(f),y=T0(b,r);if(h||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const w=D0(f);w&&w.scrollBy({top:y.y,left:y.x})}},[t,h,p,r,s])}const I0=v.createContext({...ns,scaleX:1,scaleY:1});var Dr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Dr||(Dr={}));const k2=v.memo(function(t){var s,r,o,c;let{id:h,accessibility:p,autoScroll:g=!0,children:f,sensors:b=m2,collisionDetection:y=ME,measuring:w,modifiers:S,...E}=t;const T=v.useReducer(S2,void 0,b2),[B,A]=T,[N,I]=wE(),[P,te]=v.useState(Dr.Uninitialized),Q=P===Dr.Initialized,{draggable:{active:le,nodes:oe,translate:ve},droppable:{containers:Ce}}=B,ie=le!=null?oe.get(le):null,J=v.useRef({initial:null,translated:null}),F=v.useMemo(()=>{var Et;return le!=null?{id:le,data:(Et=ie?.data)!=null?Et:g2,rect:J}:null},[le,ie]),K=v.useRef(null),[se,L]=v.useState(null),[Y,D]=v.useState(null),Z=Go(E,Object.values(E)),ge=mh("DndDescribedBy",h),R=v.useMemo(()=>Ce.getEnabled(),[Ce]),H=x2(w),{droppableRects:ee,measureDroppableContainers:he,measuringScheduled:we}=n2(R,{dragging:Q,dependencies:[ve.x,ve.y],config:H.droppable}),xe=t2(oe,le),Re=v.useMemo(()=>Y?pp(Y):null,[Y]),Ye=ln(),_e=s2(xe,H.draggable.measure);E2({activeNode:le!=null?oe.get(le):null,config:Ye.layoutShiftCompensation,initialRect:_e,measure:H.draggable.measure});const X=kb(xe,H.draggable.measure,_e),ce=kb(xe?xe.parentElement:null),Ee=v.useRef({activatorEvent:null,active:null,activeNode:xe,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:oe,draggingNode:null,draggingNodeRect:null,droppableContainers:Ce,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=Ce.getNodeFor((s=Ee.current.over)==null?void 0:s.id),De=p2({measure:H.dragOverlay.measure}),Be=(r=De.nodeRef.current)!=null?r:xe,Ie=Q?(o=De.rect)!=null?o:X:null,ae=!!(De.nodeRef.current&&De.rect),Te=l2(ae?null:X),Le=P0(Be?gn(Be):null),Oe=o2(Q?be??xe:null),ze=d2(Oe),ht=C2(S,{transform:{x:ve.x-Te.x,y:ve.y-Te.y,scaleX:1,scaleY:1},activatorEvent:Y,active:F,activeNodeRect:X,containerNodeRect:ce,draggingNodeRect:Ie,over:Ee.current.over,overlayNodeRect:De.rect,scrollableAncestors:Oe,scrollableAncestorRects:ze,windowRect:Le}),Xe=Re?gl(Re,ve):null,ot=c2(Oe),gi=Db(ot),Ji=Db(ot,[X]),qi=gl(ht,gi),$t=Ie?LE(Ie,ht):null,_i=F&&$t?y({active:F,collisionRect:$t,droppableRects:ee,droppableContainers:R,pointerCoordinates:Xe}):null,_n=DE(_i,"id"),[W,We]=v.useState(null),ut=ae?ht:gl(ht,Ji),gt=NE(ut,(c=W?.rect)!=null?c:null,X),vi=v.useRef(null),bt=v.useCallback((Et,kt)=>{let{sensor:Tt,options:bi}=kt;if(K.current==null)return;const ii=oe.get(K.current);if(!ii)return;const Yt=Et.nativeEvent,oi=new Tt({active:K.current,activeNode:ii,event:Yt,options:bi,context:Ee,onAbort(Dt){if(!oe.get(Dt))return;const{onDragAbort:ni}=Z.current,$i={id:Dt};ni?.($i),N({type:"onDragAbort",event:$i})},onPending(Dt,ji,ni,$i){if(!oe.get(Dt))return;const{onDragPending:tn}=Z.current,Hi={id:Dt,constraint:ji,initialCoordinates:ni,offset:$i};tn?.(Hi),N({type:"onDragPending",event:Hi})},onStart(Dt){const ji=K.current;if(ji==null)return;const ni=oe.get(ji);if(!ni)return;const{onDragStart:$i}=Z.current,vn={activatorEvent:Yt,active:{id:ji,data:ni.data,rect:J}};No.unstable_batchedUpdates(()=>{$i?.(vn),te(Dr.Initializing),A({type:xi.DragStart,initialCoordinates:Dt,active:ji}),N({type:"onDragStart",event:vn}),L(vi.current),D(Yt)})},onMove(Dt){A({type:xi.DragMove,coordinates:Dt})},onEnd:Ti(xi.DragEnd),onCancel:Ti(xi.DragCancel)});vi.current=oi;function Ti(Dt){return async function(){const{active:ni,collisions:$i,over:vn,scrollAdjustedTranslate:tn}=Ee.current;let Hi=null;if(ni&&tn){const{cancelDrop:_t}=Z.current;Hi={activatorEvent:Yt,active:ni,collisions:$i,delta:tn,over:vn},Dt===xi.DragEnd&&typeof _t=="function"&&await Promise.resolve(_t(Hi))&&(Dt=xi.DragCancel)}K.current=null,No.unstable_batchedUpdates(()=>{A({type:Dt}),te(Dr.Uninitialized),We(null),L(null),D(null),vi.current=null;const _t=Dt===xi.DragEnd?"onDragEnd":"onDragCancel";if(Hi){const Ui=Z.current[_t];Ui?.(Hi),N({type:_t,event:Hi})}})}}},[oe]),It=v.useCallback((Et,kt)=>(Tt,bi)=>{const ii=Tt.nativeEvent,Yt=oe.get(bi);if(K.current!==null||!Yt||ii.dndKit||ii.defaultPrevented)return;const oi={active:Yt};Et(Tt,kt.options,oi)===!0&&(ii.dndKit={capturedBy:kt.sensor},K.current=bi,bt(Tt,kt))},[oe,bt]),en=i2(b,It);u2(b),Or(()=>{X&&P===Dr.Initializing&&te(Dr.Initialized)},[X,P]),v.useEffect(()=>{const{onDragMove:Et}=Z.current,{active:kt,activatorEvent:Tt,collisions:bi,over:ii}=Ee.current;if(!kt||!Tt)return;const Yt={active:kt,activatorEvent:Tt,collisions:bi,delta:{x:qi.x,y:qi.y},over:ii};No.unstable_batchedUpdates(()=>{Et?.(Yt),N({type:"onDragMove",event:Yt})})},[qi.x,qi.y]),v.useEffect(()=>{const{active:Et,activatorEvent:kt,collisions:Tt,droppableContainers:bi,scrollAdjustedTranslate:ii}=Ee.current;if(!Et||K.current==null||!kt||!ii)return;const{onDragOver:Yt}=Z.current,oi=bi.get(_n),Ti=oi&&oi.rect.current?{id:oi.id,rect:oi.rect.current,data:oi.data,disabled:oi.disabled}:null,Dt={active:Et,activatorEvent:kt,collisions:Tt,delta:{x:ii.x,y:ii.y},over:Ti};No.unstable_batchedUpdates(()=>{We(Ti),Yt?.(Dt),N({type:"onDragOver",event:Dt})})},[_n]),Or(()=>{Ee.current={activatorEvent:Y,active:F,activeNode:xe,collisionRect:$t,collisions:_i,droppableRects:ee,draggableNodes:oe,draggingNode:Be,draggingNodeRect:Ie,droppableContainers:Ce,over:W,scrollableAncestors:Oe,scrollAdjustedTranslate:qi},J.current={initial:Ie,translated:$t}},[F,xe,_i,$t,oe,Be,Ie,ee,Ce,W,Oe,qi]),QE({...Ye,delta:ve,draggingRect:$t,pointerCoordinates:Xe,scrollableAncestors:Oe,scrollableAncestorRects:ze});const An=v.useMemo(()=>({active:F,activeNode:xe,activeNodeRect:X,activatorEvent:Y,collisions:_i,containerNodeRect:ce,dragOverlay:De,draggableNodes:oe,droppableContainers:Ce,droppableRects:ee,over:W,measureDroppableContainers:he,scrollableAncestors:Oe,scrollableAncestorRects:ze,measuringConfiguration:H,measuringScheduled:we,windowRect:Le}),[F,xe,X,Y,_i,ce,De,oe,Ce,ee,W,he,Oe,ze,H,we,Le]),yi=v.useMemo(()=>({activatorEvent:Y,activators:en,active:F,activeNodeRect:X,ariaDescribedById:{draggable:ge},dispatch:A,draggableNodes:oe,over:W,measureDroppableContainers:he}),[Y,en,F,X,A,ge,oe,W,he]);return Ei.createElement(k0.Provider,{value:I},Ei.createElement(_h.Provider,{value:yi},Ei.createElement(y2.Provider,{value:An},Ei.createElement(I0.Provider,{value:gt},f)),Ei.createElement(w2,{disabled:p?.restoreFocus===!1})),Ei.createElement(EE,{...p,hiddenTextDescribedById:ge}));function ln(){const Et=se?.autoScrollEnabled===!1,kt=typeof g=="object"?g.enabled===!1:g===!1,Tt=Q&&!Et&&!kt;return typeof g=="object"?{...g,enabled:Tt}:{enabled:Tt}}}),T2=v.createContext(null),Mb="button",D2="Draggable";function K0(e){let{id:t,data:s,disabled:r=!1,attributes:o}=e;const c=mh(D2),{activators:h,activatorEvent:p,active:g,activeNodeRect:f,ariaDescribedById:b,draggableNodes:y,over:w}=v.useContext(_h),{role:S=Mb,roleDescription:E="draggable",tabIndex:T=0}=o??{},B=g?.id===t,A=v.useContext(B?I0:T2),[N,I]=Yu(),[P,te]=Yu(),Q=h2(h,t),le=Go(s);Or(()=>(y.set(t,{id:t,key:c,node:N,activatorNode:P,data:le}),()=>{const ve=y.get(t);ve&&ve.key===c&&y.delete(t)}),[y,t]);const oe=v.useMemo(()=>({role:S,tabIndex:T,"aria-disabled":r,"aria-pressed":B&&S===Mb?!0:void 0,"aria-roledescription":E,"aria-describedby":b.draggable}),[r,S,T,B,E,b.draggable]);return{active:g,activatorEvent:p,activeNodeRect:f,attributes:oe,isDragging:B,listeners:r?void 0:Q,node:N,over:w,setNodeRef:I,setActivatorNodeRef:te,transform:A}}const R2="Droppable",M2={timeout:25};function Zm(e){let{data:t,disabled:s=!1,id:r,resizeObserverConfig:o}=e;const c=mh(R2),{active:h,dispatch:p,over:g,measureDroppableContainers:f}=v.useContext(_h),b=v.useRef({disabled:s}),y=v.useRef(!1),w=v.useRef(null),S=v.useRef(null),{disabled:E,updateMeasurementsFor:T,timeout:B}={...M2,...o},A=Go(T??r),N=v.useCallback(()=>{if(!y.current){y.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{f(Array.isArray(A.current)?A.current:[A.current]),S.current=null},B)},[B]),I=gh({callback:N,disabled:E||!h}),P=v.useCallback((oe,ve)=>{I&&(ve&&(I.unobserve(ve),y.current=!1),oe&&I.observe(oe))},[I]),[te,Q]=Yu(P),le=Go(t);return v.useEffect(()=>{!I||!te.current||(I.disconnect(),y.current=!1,I.observe(te.current))},[te,I]),v.useEffect(()=>(p({type:xi.RegisterDroppable,element:{id:r,key:c,disabled:s,node:te,rect:w,data:le}}),()=>p({type:xi.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{s!==b.current.disabled&&(p({type:xi.SetDroppableDisabled,id:r,key:c,disabled:s}),b.current.disabled=s)},[r,c,s,p]),{active:h,rect:w,isOver:g?.id===r,node:te,over:g,setNodeRef:Q}}const N2=128,A2=512,kl=100,L2="too_many_detached_terminals",B2=64,O2=4096;function F0(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>N2)return null;const s=t.workspaces.map(z2);return s.some(r=>r===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}function W0(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(s=>{if(!s||typeof s!="object")return!1;const r=s.detachedTerminalIds;return Array.isArray(r)&&r.length>kl}):!1}function z2(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>A2)return null;const s=t.tabs.map(j2);if(s.some(o=>o===null))return null;const r=I2(t.detachedTerminalIds,kl);return r===null?null:{id:t.id,title:t.title,defaultCwd:P2(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:s}}function j2(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 s=H2(t.root);return s?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:s}:null}function H2(e){if(!e||typeof e!="object")return null;let t=0;return yp(e,1,()=>(t+=1,t<=O2))}function yp(e,t,s){if(!e||typeof e!="object"||t>B2||!s())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=yp(r.first,t+1,s),c=yp(r.second,t+1,s);return!o||!c?null:{type:"split",direction:r.direction,ratio:U2(r.ratio),first:o,second:c}}function U2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function P2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function I2(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const s=new Set,r=[];for(const o of e)typeof o!="string"||!o||s.has(o)||(s.add(o),r.push(o));return r}const q0=[{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"}],Mr="__main__";function K2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function F2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Nb="Local",W2=3e4,q2=2,$2=6,$0="nterminal.serverList.viewMode.v1";function Y2(){try{return window.localStorage.getItem($0)==="list"?"list":"stats"}catch{return"stats"}}function V2(e){try{window.localStorage.setItem($0,e)}catch{}}function ha(e,t){const s=[Mr,...t.map(h=>h.id)],r=new Set(s),o=new Set,c=[];for(const h of e??[])!r.has(h)||o.has(h)||(o.add(h),c.push(h));for(const h of s)o.has(h)||c.push(h);return c}function X2(e,t){const s=new Map(e.map(r=>[r.id,r]));return ha(t,e).flatMap(r=>{if(r===Mr)return[{kind:"main",id:Mr}];const o=s.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Ab(e,t){return e.length===t.length&&e.every((s,r)=>s===t[r])}function Y0(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Vn(e.cpuPercent)} ${Qm(e)}`,`MEM ${Vn(e.memoryPercent)} ${Ws(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Vn(e.diskPercent)} ${Ws(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Vn(e.swapPercent)} ${Ws(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function G2(e){if(!(e===void 0||e==="error"))return[`CPU ${Vn(e.cpuPercent)} (${Qm(e)})`,`RAM ${Vn(e.memoryPercent)} (${Ws(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Vn(e.diskPercent)} (${Ws(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Vn(e.swapPercent)} (${Ws(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Z2(e,t){const s=Y0(t);return`${e}${s?` — ${s}`:""}. Double-click to rename.`}function Vn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Qm(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`:`${bp(e.cpuPercent/100*t)}/${t} cores`}function Ws(e,t){return!Lb(e)||!Lb(t)?"–/–":Q2(e,t)}function Q2(e,t){const s=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=s==="GB"?1024**3:s==="MB"?1024**2:1024;return`${bp(e/r)}/${bp(t/r)} ${s}`}function bp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Lb(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Su(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function J2(e){return[{label:"CPU",percent:Vn(e.cpuPercent),detail:Qm(e),tone:Su(e.cpuPercent)},{label:"MEM",percent:Vn(e.memoryPercent),detail:Ws(e.memoryUsedBytes,e.memoryTotalBytes),tone:Su(e.memoryPercent)},{label:"DISK",percent:Vn(e.diskPercent),detail:Ws(e.diskUsedBytes,e.diskTotalBytes),tone:Su(e.diskPercent)},{label:"SWAP",percent:Vn(e.swapPercent),detail:Ws(e.swapUsedBytes,e.swapTotalBytes),tone:Su(e.swapPercent)}]}function ek({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:G2(e),children:J2(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 Bb({api:e,activeAgentId:t,onSelectServer:s,onSessionInvalid:r,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[p,g]=v.useState([]),[f,b]=v.useState([Mr]),[y,w]=v.useState(null),[S,E]=v.useState(null),[T,B]=v.useState(""),A=v.useRef(null),[N,I]=v.useState(()=>Y2()),[P,te]=v.useState(null),[Q,le]=v.useState(null),[oe,ve]=v.useState({}),Ce=v.useRef({}),ie=v.useRef(0),J=v.useRef([]),F=v.useRef([Mr]),K=v.useRef(null);v.useEffect(()=>{J.current=p},[p]),v.useEffect(()=>{const X=ha(f,p);F.current=X,Ab(X,f)||b(X)},[p,f]),v.useEffect(()=>{let X=!1;return e.listAgents().then(ce=>{X||(g(ce.agents),b(ha(ce.serverOrder,ce.agents)))}).catch(()=>{}),e.getMainInfo().then(ce=>{X||w(ce.name)}).catch(()=>{}),()=>{X=!0}},[e,o]),v.useEffect(()=>{S&&(A.current?.focus(),A.current?.select())},[S]),v.useEffect(()=>{let X=!1;function ce(){const be=[{key:"__main__",load:()=>e.getMainStats()},...p.map(Be=>({key:Be.id,load:()=>e.getAgentStats(Be.id)}))],De=new Set(be.map(Be=>Be.key));for(const Be of Object.keys(Ce.current))De.has(Be)||delete Ce.current[Be];ve(Be=>{const Ie={};for(const ae of De)ae in Be&&(Ie[ae]=Be[ae]);return Ie});for(const Be of be)Be.load().then(Ie=>{X||(Ce.current[Be.key]=0,ve(ae=>De.has(Be.key)?{...ae,[Be.key]:Ie}:ae))}).catch(Ie=>{if(X)return;if(Ie instanceof is&&Ie.status===401&&Be.key==="__main__"){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}const ae=(Ce.current[Be.key]??0)+1;Ce.current[Be.key]=ae,ae>=q2&&ve(Te=>De.has(Be.key)?{...Te,[Be.key]:"error"}:Te)})}ce();const Ee=window.setInterval(ce,W2);return()=>{X=!0,window.clearInterval(Ee)}},[e,p,r]);function se(X){X==="main"?(B(y??""),E({kind:"main"})):(B(X.name),E({kind:"agent",id:X.id}))}async function L(){if(!S)return;const X=T.trim(),ce=S;if(E(null),ce.kind==="main"){const Ee=X||"";try{const be=await e.renameMain(Ee);w(be.name)}catch{}}else{if(!X)return;const Ee=p.find(be=>be.id===ce.id)?.name;g(be=>be.map(De=>De.id===ce.id?{...De,name:X}:De));try{await e.renameAgent(ce.id,X)}catch{Ee!==void 0&&g(be=>be.map(De=>De.id===ce.id?{...De,name:Ee}:De))}}}function Y(){E(null)}function D(X){I(X),V2(X)}function Z(X,ce,Ee){if(X===ce)return;const be=ha(F.current,J.current),De=be.findIndex(ze=>ze===X),Be=be.findIndex(ze=>ze===ce);if(De<0||Be<0)return;const Ie=[...be],[ae]=Ie.splice(De,1);if(!ae)return;const Te=Ie.findIndex(ze=>ze===ce);if(Te<0)return;const Le=Ee==="before"?Te:Te+1;if(Ie.splice(Le,0,ae),Ab(Ie,be))return;const Oe=ie.current+1;ie.current=Oe,F.current=Ie,b(Ie),e.reorderAgents(Ie).then(ze=>{if(ie.current===Oe){J.current=ze.agents;const ht=ha(ze.serverOrder,ze.agents);F.current=ht,g(ze.agents),b(ht)}}).catch(async()=>{if(ie.current===Oe)try{const ze=await e.listAgents();if(ie.current===Oe){J.current=ze.agents;const ht=ha(ze.serverOrder,ze.agents);F.current=ht,g(ze.agents),b(ht)}}catch{ie.current===Oe&&(F.current=be,b(be))}})}function ge(X,ce){const Ee=ha(F.current,J.current),be=Ee.findIndex(Be=>Be===X),De=Ee[be+ce];be<0||!De||Z(X,De,ce<0?"before":"after")}function R(X,ce){ce.pointerType==="mouse"&&ce.button!==0||(ce.stopPropagation(),K.current={sourceId:X,pointerId:ce.pointerId,startX:ce.clientX,startY:ce.clientY,active:!1,targetId:null,placement:"after"},ce.currentTarget.setPointerCapture?.(ce.pointerId))}function H(X){const ce=K.current;if(!ce||ce.pointerId!==X.pointerId)return;const Ee=Math.hypot(X.clientX-ce.startX,X.clientY-ce.startY);if(!ce.active){if(Ee<$2)return;ce.active=!0,te(ce.sourceId)}const De=document.elementFromPoint(X.clientX,X.clientY)?.closest("[data-server-id]"),Be=De?.dataset.serverId??null;if(!De||!Be||Be===ce.sourceId){ce.targetId=null,le(null);return}const Ie=De.getBoundingClientRect(),ae=X.clientY<Ie.top+Ie.height/2?"before":"after";ce.targetId=Be,ce.placement=ae,le({serverId:Be,placement:ae})}function ee(X){const ce=K.current;!ce||ce.pointerId!==X.pointerId||(X.stopPropagation(),X.currentTarget.releasePointerCapture?.(X.pointerId),K.current=null,te(null),le(null),ce.active&&ce.targetId&&Z(ce.sourceId,ce.targetId,ce.placement))}function he(X){const ce=K.current;ce&&ce.pointerId===X.pointerId&&X.currentTarget.releasePointerCapture?.(X.pointerId),K.current=null,te(null),le(null)}const we=y?.trim()||Nb,xe=S?.kind==="main",Re=N==="stats",Ye=X2(p,f),_e=Ye.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:Ye.map(X=>{const ce=X.kind==="main",Ee=ce?we:X.agent.name,be=ce?Mr:X.id,De=oe[be],Be=Y0(De);return m.jsxs("button",{type:"button",className:`server-list-chip${(ce?t===null:t===X.id)?" server-list-chip--active":""}`,onClick:()=>s(ce?null:X.id),"aria-label":Ee,title:`${Ee}${Be?` — ${Be}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:F2(Ee)}),m.jsx("span",{className:"server-list-chip-pip","data-status":K2(De)})]},X.id)})}):m.jsxs("div",{className:`server-list server-list--${N}`,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":N==="list",onClick:()=>D("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":N==="stats",onClick:()=>D("stats"),title:"Show resource usage",children:"Stats"})]}),Ye.map(X=>{const ce=X.kind==="main",Ee=ce?we:X.agent.name,be=ce?Mr:X.id,De=ce?t===null:t===X.id,Be=ce?xe:S?.kind==="agent"&&S.id===X.id,Ie=c?.({agentId:ce?null:X.id,serverId:X.id,label:Ee,active:De}),ae=Q?.serverId===X.id&&P!==X.id?` server-list-section--drop-target server-list-section--drop-${Q.placement}`:"";return m.jsxs("section",{className:`server-list-section${ae}`,"aria-label":`${Ee} server`,children:[m.jsx("div",{className:["server-list-row",P===X.id?"server-list-row--dragging":"",Q?.serverId===X.id&&P!==X.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":X.id,children:Be?m.jsxs(m.Fragment,{children:[_e?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:Te=>{Te.preventDefault(),L()},children:m.jsx("input",{ref:A,"aria-label":ce?"Rename main server":`Rename ${Ee}`,value:T,onChange:Te=>B(Te.target.value),onBlur:()=>{L()},onKeyDown:Te=>{Te.key==="Escape"&&(Te.preventDefault(),Y())},placeholder:ce?Nb:void 0})})]}):m.jsxs(m.Fragment,{children:[_e?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":X.id,title:"Drag to reorder","aria-label":`Reorder ${Ee}`,"aria-grabbed":P===X.id,onPointerDown:Te=>R(X.id,Te),onPointerMove:H,onPointerUp:ee,onPointerCancel:he,onKeyDown:Te=>{(Te.key==="ArrowUp"||Te.key==="ArrowDown")&&(Te.preventDefault(),Te.stopPropagation(),ge(X.id,Te.key==="ArrowUp"?-1:1))},onClick:Te=>Te.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${De?" server-list-item--active":""}`,onClick:()=>s(ce?null:X.id),onDoubleClick:Te=>{Te.preventDefault(),se(ce?"main":{id:X.id,name:Ee})},title:Z2(Ee,oe[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:ce?void 0:X.agent.url,children:Ee})]}),Re?m.jsx(ek,{entry:oe[be]}):null]})]})}),Ie?m.jsx("div",{className:"server-list-children",children:Ie}):null]},X.id)})]})}function tk({api:e}){const[t,s]=v.useState([]),[r,o]=v.useState([]),[c,h]=v.useState(!1),[p,g]=v.useState(null),[f,b]=v.useState(""),[y,w]=v.useState("");async function S(){try{const[A,N,I]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);s(A.devices),o(N.networks),h(I.totpEnabled),g(null)}catch(A){g(A instanceof Error?A.message:"Failed to load")}}v.useEffect(()=>{S()},[]);async function E(A){await e.revokeDevice(A),await S()}async function T(A){await e.removeNetwork(A),await S()}async function B(A){A.preventDefault(),g(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),b(""),w(""),await S()}catch(N){g(N instanceof Error?N.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:()=>{E(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."}),r.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:r.map(A=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:A.value}),A.label!==A.value?m.jsx("span",{className:"security-item-meta",children:A.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(A.id)},children:"remove"})]},A.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:B,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:A=>b(A.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:A=>w(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 S()},children:"Disable 2FA"})]}):null]})}const Jm="nterminal.clientDiagnostics.v1",V0=150,ik=24,nk=160;let Ob=!1,bo=null;function sk(){Ob||typeof window>"u"||(Ob=!0,Mn("page.load",{navigation:_k(),visibility:document.visibilityState,online:navigator.onLine,viewport:G0(),standalone:gk()}),document.addEventListener("visibilitychange",()=>{Mn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Mn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Mn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Mn("network.online")),window.addEventListener("offline",()=>Mn("network.offline")),window.addEventListener("focus",()=>Mn("window.focus")),window.addEventListener("blur",()=>Mn("window.blur")),window.addEventListener("error",e=>{Mn("runtime.error",{message:e.message,source:vk(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Mn("runtime.unhandledrejection",{reason:yk(e.reason)})}))}function Mn(e,t={}){const s={at:new Date().toISOString(),event:yh(e,80),data:X0({...t,visibility:t.visibility??pk(),online:t.online??mk(),viewport:t.viewport??G0()})},r=ma();return r.push(s),ok(r.slice(-V0)),s}function ma(){try{const e=window.localStorage.getItem(Jm);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(ck).filter(s=>s!==null).slice(-V0):[]}catch{return[]}}function rk(){try{window.localStorage.removeItem(Jm)}catch{}}function ak(){const e=ma();return JSON.stringify({generatedAt:new Date().toISOString(),eventCount:e.length,events:e},null,2)}async function lk(){const e=ak();return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):bk(e)}async function vh(e,t=fetch){if(bo)return bo;const s=ma(),r={reason:yh(e,80),events:s},o=JSON.stringify(r);bo=(async()=>{const c=await t("/api/client-diagnostics",{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",keepalive:o.length<48e3,body:o});if(!c.ok)throw new Error(`diagnostics_send_failed_${c.status}`);return c.json()})();try{return await bo}finally{bo=null}}function ok(e){try{window.localStorage.setItem(Jm,JSON.stringify(e))}catch{}}function ck(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:yh(t.event,80),...t.data&&typeof t.data=="object"?{data:X0(t.data)}:{}}}function X0(e){const t={};for(const[s,r]of Object.entries(e).slice(0,ik)){const o=yh(s,64);if(!o||uk(o))continue;const c=hk(r);c!==void 0&&(t[o]=c)}return t}function uk(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function hk(e){if(typeof e=="string")return dk(e,nk);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function yh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function dk(e,t){return fk(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function fk(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 pk(){return typeof document>"u"?void 0:document.visibilityState}function mk(){return typeof navigator>"u"?void 0:navigator.onLine}function G0(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function gk(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function _k(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function vk(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 yk(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function bk(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();let s=!1;try{s=document.execCommand("copy")}finally{document.body.removeChild(t)}return s}const Z0="nterminal.notifications.completionEnabled",eg="nterminal.notifications.completionToastEnabled",tg="nterminal.notifications.completionToastDurationSeconds",ig="nterminal.notifications.completionToastPersistent",Sp="nterminal:completion-toast-display",qo=6.5,wp=2,Cp=60;function bh(){return typeof window<"u"&&"Notification"in window}function Q0(){try{return window.localStorage.getItem(Z0)==="true"}catch{return!1}}function zb(e){try{window.localStorage.setItem(Z0,e?"true":"false")}catch{}}function ba(){return{enabled:xk(),durationSeconds:Ck(),persistUntilDismissed:Ek()}}function Sk(e){if(typeof window<"u"){try{window.localStorage.setItem(eg,e?"true":"false")}catch{}sg()}return ba()}function jb(e){const t=ew(e);if(typeof window<"u"){try{window.localStorage.setItem(tg,String(t))}catch{}sg()}return ba()}function wk(e){if(typeof window<"u"){try{window.localStorage.setItem(ig,e?"true":"false")}catch{}sg()}return ba()}function J0(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===eg||s.key===tg||s.key===ig)&&e()};return window.addEventListener(Sp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Sp,e),window.removeEventListener("storage",t)}}function ng(){return bh()?window.Notification.permission:"unsupported"}function Ck(){if(typeof window>"u")return qo;try{const e=window.localStorage.getItem(tg);return e===null?qo:ew(Number(e))}catch{return qo}}function xk(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(eg)!=="false"}catch{return!0}}function Ek(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ig)==="true"}catch{return!1}}function ew(e){if(!Number.isFinite(e))return qo;const t=Math.round(e*2)/2;return Math.max(wp,Math.min(Cp,t))}function sg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Sp))}async function kk(){if(!bh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return ng()}}function Tk(e){if(!bh()||ng()!=="granted"||!Q0()||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 Dk=1500,rg="nterminal.terminal.fontSize",ag="nterminal.terminal.fontFamily",xp="nterminal:terminal-font-size",Ep="nterminal:terminal-font-family",kp=11,Tp=20,_a=14,Zu=[{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:[]}],yl="meslo";Dp(yl);async function Pf(e=_a,t=yl){if(typeof document>"u"||!document.fonts)return;const s=nw(t).webFontFamilies;if(s.length===0)return;const r=Promise.all(s.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,Dk)})])}function tw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return _a;const s=Math.round(t);return Math.max(kp,Math.min(Tp,s))}function iw(e){return Zu.some(t=>t.id===e)?e:yl}function Dp(e){return nw(e).cssFamily}function nw(e){return Zu.find(t=>t.id===e)??Zu[0]}function Rp(){if(typeof window>"u")return _a;try{const e=window.localStorage.getItem(rg);return e?tw(e):_a}catch{return _a}}function Mp(){if(typeof window>"u")return yl;try{return iw(window.localStorage.getItem(ag))}catch{return yl}}function wu(e){const t=tw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(rg,String(t))}catch{}return window.dispatchEvent(new CustomEvent(xp,{detail:t})),t}function Rk(e){const t=iw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ag,t)}catch{}return window.dispatchEvent(new CustomEvent(Ep,{detail:t})),t}function sw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===rg&&e()};return window.addEventListener(xp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(xp,e),window.removeEventListener("storage",t)}}function rw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===ag&&e()};return window.addEventListener(Ep,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Ep,e),window.removeEventListener("storage",t)}}const lg="nterminal.terminal.showScrollProgress",Np="nterminal:terminal-scroll-progress";function Ap(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(lg)!=="false"}catch{return!0}}function Mk(e){if(typeof window<"u"){try{window.localStorage.setItem(lg,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Np,{detail:e}))}return e}function aw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===lg&&e()};return window.addEventListener(Np,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Np,e),window.removeEventListener("storage",t)}}const og="nterminal.shortcuts.workspace.v1",Lp="nterminal:workspace-shortcuts",Qo=[{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}],Sh={"server.previous":Mi("ArrowUp",{ctrlKey:!0}),"server.next":Mi("ArrowDown",{ctrlKey:!0}),"tab.previous":Mi("ArrowLeft",{ctrlKey:!0}),"tab.next":Mi("ArrowRight",{ctrlKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Mi("KeyH",{altKey:!0})},Nk={"server.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Mi("KeyH",{altKey:!0})};function Sa(){const e=cw(Sh);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(og);if(!t)return e;const s=JSON.parse(t);for(const r of Qo){const o=s[r.id];if(Uk(o)){const c=uw(o,r);Hk(c,Nk[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Hb(){return JSON.stringify(Sa())}function Ak(e,t){const s=Sa(),r=Qo.find(o=>o.id===e);return r&&(s[e]=uw(t,r),hg(s)),s}function Lk(e){const t=Sa();return t[e]={...Sh[e]},hg(t),t}function Bk(){const e=cw(Sh);return hg(e),e}function cg(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===og&&e()};return window.addEventListener(Lp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Lp,e),window.removeEventListener("storage",t)}}function Ok(e,t){const s=fw(e);return!s||Ik(s)||t.indexed&&dw(e)===null||t.requiresPrimaryModifier&&!hw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":s}}function lw(e){const t=Sa();for(const s of Qo){const r=t[s.id];if(!(!r||!Pk(e,r))){if(s.indexed){if(r.code!=="Digit")continue;const o=dw(e);if(o!==null)return{id:s.id,index:o};continue}if(fw(e)===r.code)return{id:s.id,index:null}}}return null}function ug(e){return ow(Sa()[e])}function ow(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(Kk(e.code)),t.join("+")}const zk=()=>ug("split.right"),jk=()=>ug("split.down");function Mi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function cw(e){return Object.fromEntries(Object.entries(e).map(([t,s])=>[t,{...s}]))}function Hk(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(og,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(Lp))}}function uw(e,t){return t.requiresPrimaryModifier&&!hw(e)?{...Sh[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function hw(e){return e.ctrlKey||e.altKey||e.metaKey}function Uk(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 Pk(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function dw(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 fw(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 Ik(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function Kk(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const s=/^Key([A-Z])$/.exec(e);if(s?.[1])return s[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 Fk="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 Wk(e="nterminal",t=new Date){return{reason:"permission",message:Fk,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function qk(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 pw=3600*1e3,$k="local",Bp=new Set,Ar=new Map;let zr={checking:!1,hasUpdates:!1,lastCheckedAt:null},dg=null,$o=null,Qu=0,Tr=null;function Yk(e){return Bp.add(e),()=>{Bp.delete(e)}}function Ub(){return zr}function Vk(e){const t=Jk();dg=e,fg(),Op(e,t);const s=()=>{if(document.visibilityState!=="visible"||!jr(e,t))return;const r=zr.lastCheckedAt;(r===null||Date.now()-r>=pw)&&Op(e,t)};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),jr(e,t)&&Qk()}}function Xk(e,t){Ar.set(e,mw(t)),bl({...zr,hasUpdates:pg(),lastCheckedAt:Date.now()})}function If(e){e===void 0?Ar.clear():Ar.set(e,!1),bl({...zr,hasUpdates:pg()})}async function Op(e,t){if(!jr(e,t))return;if(Tr&&Tr.api===e&&Tr.runId===t)return Tr.promise;bl({...zr,checking:!0});const s=Gk(e,t).finally(()=>{Tr?.promise===s&&(Tr=null),jr(e,t)&&(bl({...zr,checking:!1,lastCheckedAt:Date.now()}),Zk(e,t))});return Tr={api:e,runId:t,promise:s},s}async function Gk(e,t){try{const s=await e.listAgents();if(!jr(e,t))return;const r=[{key:$k,check:()=>e.checkUpdate()},...s.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const h=await c.check();o.set(c.key,mw(h))}catch{o.set(c.key,Ar.get(c.key)??!1)}})),!jr(e,t))return;Ar.clear();for(const[c,h]of o)Ar.set(c,h);bl({...zr,hasUpdates:pg()})}catch{}}function Zk(e,t){jr(e,t)&&(fg(),$o=window.setTimeout(()=>{$o=null,jr(e,t)&&Op(e,t)},pw))}function Qk(){Qu+=1,fg(),dg=null,Tr=null,Ar.clear(),bl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function fg(){$o!==null&&(window.clearTimeout($o),$o=null)}function Jk(){return Qu+=1,Qu}function jr(e,t){return dg===e&&Qu===t}function mw(e){return e.updateAvailable===!0}function pg(){return Array.from(Ar.values()).some(Boolean)}function bl(e){zr=e;for(const t of Array.from(Bp))t()}const eT=e=>new Promise(t=>setTimeout(t,e));function tT({api:e,onAgentRemoved:t}){const[s,r]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,p]=v.useState(!1),[g,f]=v.useState(null),[b,y]=v.useState(!1),[w,S]=v.useState(null),[E,T]=v.useState(!1),[B,A]=v.useState(null);function N(D,Z){c(ge=>({...ge,[D]:{...ge[D],...Z}}))}const I=D=>D.id===null?e.getVersion():e.getAgentVersion(D.id),P=D=>D.id===null?e.checkUpdate():e.checkAgentUpdate(D.id),te=D=>D.id===null?e.runUpdate():e.runAgentUpdate(D.id);v.useEffect(()=>{let D=!1;e.listAgents().then(ge=>{if(D)return;const R=[{key:"local",id:null,name:"Local (main)"},...ge.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];r(R);for(const H of R)I(H).then(ee=>N(H.key,{version:ee,manualUpdate:ee.manualUpdate??null})).catch(ee=>N(H.key,{error:ee instanceof Error?ee.message:"unreachable"}))}).catch(()=>{});const Z=e.getDistributedCallSettings;return typeof Z=="function"&&Z().then(ge=>{D||S(ge)}).catch(ge=>{D||A(ge instanceof Error?ge.message:"failed to load distributed call settings")}),()=>{D=!0}},[]);async function Q(D){N(D.key,{busy:!0,status:"checking…",error:void 0});try{const Z=await P(D);Xk(D.key,Z),N(D.key,{latestVersion:Z.latestVersion,updateAvailable:Z.updateAvailable,status:F(Z),...Z.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(Z){N(D.key,{busy:!1,error:Z instanceof Error?Z.message:"check failed"})}}async function le(){p(!0),await Promise.all(s.map(D=>Q(D))),p(!1)}async function oe(D,Z){const ge=Date.now()+18e4;for(;Date.now()<ge;){await eT(3e3);try{const R=await I(D);if(Z&&R.runningVersion!==Z.runningVersion)return R}catch{}}return null}async function ve(D){let Z=o[D.key]?.version;if(!Z)try{Z=await I(D),N(D.key,{version:Z,manualUpdate:Z.manualUpdate??null})}catch(H){return N(D.key,{busy:!1,error:H instanceof Error?H.message:"version check failed"}),"failed"}N(D.key,{busy:!0,status:"updating…",error:void 0});let ge;try{ge=await te(D)}catch(H){return N(D.key,{busy:!1,error:H instanceof Error?H.message:"update failed"}),"failed"}if(!ge.ok){const H=ge.manualUpdate??(qk(ge.message)?Wk():null);return H?(N(D.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:H}),"manual"):(N(D.key,{busy:!1,status:void 0,error:ge.message}),"failed")}if(!ge.changed)return N(D.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),If(D.key),"unchanged";N(D.key,{status:"restarting…"});const R=await oe(D,Z);return R?(N(D.key,{busy:!1,version:R,updateAvailable:!1,status:"updated",manualUpdate:R.manualUpdate??null}),If(D.key),D.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(N(D.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function Ce(D){if(!(D.id===null||!window.confirm([`Delete secondary server "${D.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
|
+
`)))){N(D.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ge=await e.uninstallAgent(D.id);r(R=>R.filter(H=>H.key!==D.key)),c(R=>{const H={...R};return delete H[D.key],H}),If(D.key),t?.(D.id),f(ge.message)}catch(ge){N(D.key,{busy:!1,status:void 0,error:ge instanceof Error?ge.message:"delete failed"})}}}async function ie(){p(!0),f(null);const D=s.filter(he=>he.id!==null),Z=s.find(he=>he.id===null),ge=await Promise.all(D.map(he=>ve(he))),R=ge.filter(he=>he==="failed").length;let H=ge.filter(he=>he==="manual").length,ee=null;if(Z&&(ee=await ve(Z),ee==="manual"&&(H+=1),ee==="updated")){R>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}R>0&&H>0?f("Some servers failed and some need manual update. Check each marked row."):R>0?f("Some secondary servers failed to update. Check their rows and retry."):H>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function J(D){return D?D.error?D.error:D.status?D.status:D.manualUpdate?"manual update required":D.version?`v${D.version.version}`:"…":"…"}function F(D){return D.error?D.error:typeof D.updateAvailable=="boolean"?D.updateAvailable?`latest v${D.latestVersion??"available"}`:"up to date":"unknown"}function K(D){const Z=D?.version;return Z?`npm package v${Z.runningVersion}`:""}async function se(D,Z){try{await iT(Z),N(D,{copiedCommand:!0}),window.setTimeout(()=>N(D,{copiedCommand:!1}),1800)}catch(ge){N(D,{error:ge instanceof Error?ge.message:"copy failed"})}}async function L(D){if(!(!w||E)){T(!0),A(null);try{const Z=await e.updateDistributedCallSettings(D);S(Z)}catch(Z){A(Z instanceof Error?Z.message:"failed to save distributed call settings")}finally{T(!1)}}}function Y(D,Z){if(!w)return;const ge=new Set(w.settings.workerIds);Z?ge.add(D):ge.delete(D),L({workerIds:Array.from(ge)})}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:()=>{le()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{ie()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsxs("div",{className:"server-addon-panel",children:[m.jsxs("div",{className:"server-addon-header",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:"Distributed calls"}),m.jsx("span",{className:"security-item-meta",children:"Programmatic worker fan-out for trusted NTerminal servers."})]}),m.jsxs("label",{className:"auth-checkbox server-addon-toggle",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.enabled??!1,disabled:!w||E,onChange:D=>{L({enabled:D.currentTarget.checked})}}),"Enabled"]})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.allowPrivateTargets??!1,disabled:!w||E||!(w?.settings.enabled??!1),onChange:D=>{L({allowPrivateTargets:D.currentTarget.checked})}}),"Allow private network targets when the CLI also requests it"]}),w?m.jsx("div",{className:"server-addon-workers","aria-label":"Distributed call workers",children:w.workers.map(D=>m.jsxs("label",{className:"auth-checkbox server-addon-worker",children:[m.jsx("input",{type:"checkbox",checked:D.enabled,disabled:E||!w.settings.enabled,onChange:Z=>Y(D.id,Z.currentTarget.checked)}),m.jsx("span",{children:D.id===Mr?"Local (main)":D.name})]},D.id))}):null,B?m.jsx("p",{className:"settings-status settings-status-error",children:B}):null]}),m.jsx("ul",{className:"security-list",children:s.map(D=>{const Z=o[D.key],ge=K(Z),R=Z?.manualUpdate??null,H=Z?.version!==void 0&&Z?.updateAvailable!==!1&&!Z?.busy&&!h,ee=D.id!==null&&!Z?.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:D.name}),m.jsxs("span",{className:"security-item-meta",children:[ge?`${ge} — `:"",J(Z)]})]}),R?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:R.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:R.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{se(D.key,R.command)},children:Z?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(D)},disabled:!H,children:Z?.busy?"…":"Update"}),D.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{Ce(D)},disabled:!ee,children:"Delete"}):null]})]},D.key)})})]})}async function iT(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 Cu=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"diagnostics",label:"Diagnostics"},{id:"servers",label:"Servers"}];function nT({onClose:e,api:t,updateAvailable:s=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??dh(),[t]),[h,p]=v.useState(()=>Rp()),[g,f]=v.useState(()=>Mp()),[b,y]=v.useState(()=>Ap()),[w,S]=v.useState(()=>Br()),[E,T]=v.useState(()=>Sa()),[B,A]=v.useState(null),[N,I]=v.useState(null),[P,te]=v.useState("appearance"),[Q,le]=v.useState(()=>Q0()),[oe,ve]=v.useState(()=>ba()),[Ce,ie]=v.useState(()=>ng()),[J,F]=v.useState([]),[K,se]=v.useState([]),[L,Y]=v.useState([]),[D,Z]=v.useState(5*1024*1024),[ge,R]=v.useState(!1),[H,ee]=v.useState(null),[he,we]=v.useState(()=>ma()),[xe,Re]=v.useState(!1),[Ye,_e]=v.useState(null),X=v.useRef(null),ce=v.useRef(null),Ee=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,diagnostics:null,servers:null}),be=v.useMemo(()=>new Set(K),[K]),De=!lT(K,L);v.useEffect(()=>sw(()=>p(Rp())),[]),v.useEffect(()=>rw(()=>f(Mp())),[]),v.useEffect(()=>aw(()=>y(Ap())),[]),v.useEffect(()=>Wm(()=>S(Br())),[]),v.useEffect(()=>cg(()=>T(Sa())),[]),v.useEffect(()=>J0(()=>ve(ba())),[]),v.useEffect(()=>{const W=()=>we(ma());W();const We=window.setInterval(W,1500);return()=>window.clearInterval(We)},[]),v.useEffect(()=>{if(!B)return;const W=Qo.find(ut=>ut.id===B);if(!W)return;const We=ut=>{if(ut.preventDefault(),ut.stopPropagation(),ut.key==="Escape"){A(null),I(null);return}const gt=Ok(ut,W);if(!gt){I(aT(W));return}T(Ak(B,gt)),A(null),I(null)};return window.addEventListener("keydown",We,!0),()=>window.removeEventListener("keydown",We,!0)},[B]),v.useEffect(()=>{let W=!1;return c.listNotificationAssets().then(We=>{W||ze(We)}).catch(We=>{W||ee(ol(We))}),()=>{W=!0}},[c]);function Be(W){p(wu(Number(W)))}function Ie(W){ve(jb(Number(W)))}function ae(W){te(W);const We=ce.current,ut=Ee.current[W];if(!We||!ut)return;const gt=Math.max(0,Pb(ut,We)-12);typeof We.scrollTo=="function"?We.scrollTo({top:gt,behavior:"smooth"}):We.scrollTop=gt}function Te(){const W=ce.current;if(!W)return;if(W.scrollTop+W.clientHeight>=W.scrollHeight-2){te(Cu[Cu.length-1].id);return}let We="appearance";const ut=W.scrollTop+Math.min(180,Math.max(48,W.clientHeight*.28));for(const gt of Cu){const vi=Ee.current[gt.id];vi&&Pb(vi,W)<=ut&&(We=gt.id)}te(We)}function Le(W){T(Lk(W)),A(null),I(null)}function Oe(){T(Bk()),A(null),I(null)}function ze(W){const We=W.assets.filter(ut=>ut.enabled).map(ut=>ut.id);F(W.assets),se(We),Y(We),Z(W.maxFileBytes),ee(null)}async function ht(){if(Q){zb(!1),le(!1);return}let W=Ce;W==="default"&&(W=await kk(),ie(W)),W==="granted"&&(zb(!0),le(!0))}async function Xe(W){const We=W?.[0];if(We){if(We.size>D){ee(`File must be ${Kf(D)} or smaller.`),gi();return}if(We.type!=="video/mp4"&&We.type!=="video/webm"){ee("Upload an MP4 or WebM video."),gi();return}R(!0),ee(null);try{await c.uploadNotificationAsset(We),ze(await c.listNotificationAssets()),r?.()}catch(ut){ee(ol(ut))}finally{R(!1),gi()}}}async function ot(W){R(!0),ee(null);try{await c.deleteNotificationAsset(W),ze(await c.listNotificationAssets()),r?.()}catch(We){ee(ol(We))}finally{R(!1)}}function gi(){X.current&&(X.current.value="")}function Ji(W,We){const ut=new Set(K);if(We?ut.add(W):ut.delete(W),ut.size===0){ee("Keep at least one toast video selected.");return}ee(null),se(Array.from(ut))}async function qi(){if(K.length===0){ee("Keep at least one toast video selected.");return}R(!0),ee(null);try{const W=await c.updateNotificationAssetSelection({enabledAssetIds:K});ze(W),r?.()}catch(W){ee(ol(W))}finally{R(!1)}}async function $t(){_e(null),Re(!0);try{const W=await lk();_e(W?"Diagnostics copied.":"Copy failed in this browser."),we(ma())}catch(W){_e(ol(W))}finally{Re(!1)}}async function _i(){_e(null),Re(!0);try{const W=await vh("manual-settings");_e(`Sent ${W.accepted} diagnostic events.`),we(ma())}catch(W){_e(ol(W))}finally{Re(!1)}}function _n(){rk(),we([]),_e("Diagnostics cleared.")}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:W=>W.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:Cu.map(W=>m.jsxs("button",{type:"button","data-active":P===W.id?"true":"false","aria-current":P===W.id?"true":void 0,onClick:()=>ae(W.id),children:[W.label,W.id==="servers"&&s?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},W.id))}),m.jsxs("div",{ref:ce,className:"settings-content",onScroll:Te,children:[m.jsxs("section",{id:"settings-appearance",ref:W=>{Ee.current.appearance=W},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:$u.map(W=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":w===W.id,"data-active":w===W.id?"true":"false",onClick:()=>S(oE(W.id)),style:{"--settings-theme-bg":W.tokens.bg,"--settings-theme-bg-2":W.tokens.bg2,"--settings-theme-sidebar":W.tokens.bgSidebar,"--settings-theme-line":W.tokens.line,"--settings-theme-fg":W.tokens.fg,"--settings-theme-fg-2":W.tokens.fg2,"--settings-theme-accent":W.tokens.accent,"--settings-theme-xterm-bg":W.xterm.background,"--settings-theme-xterm-fg":W.xterm.foreground,"--settings-theme-xterm-selection":W.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:W.label}),m.jsx("small",{children:W.description})]})]},W.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:kp,max:Tp,step:1,value:h,"aria-label":"Terminal font size",onChange:W=>Be(W.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(wu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:kp,max:Tp,step:1,value:h,"aria-label":"Terminal font size value",onChange:W=>Be(W.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(wu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(wu(_a)),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:W=>f(Rk(W.currentTarget.value)),children:Zu.map(W=>m.jsx("option",{value:W.id,children:W.label},W.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:W=>y(Mk(W.currentTarget.checked))}),"Show scroll progress"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:W=>{Ee.current.shortcuts=W},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:Oe,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."}),N?m.jsx("p",{className:"settings-error",children:N}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Qo.map(W=>{const We=B===W.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:W.label}),m.jsx("span",{className:"settings-shortcut-group",children:W.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":We?"true":"false",onClick:()=>{A(W.id),I(null)},children:We?"Press keys…":ow(E[W.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Le(W.id),children:"Reset"})]})]},W.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:W=>{Ee.current.notifications=W},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),bh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:Q&&Ce==="granted",onChange:()=>{ht()},disabled:Ce==="denied"}),"System notification when page is hidden"]}),Ce==="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("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:oe.enabled,onChange:W=>ve(Sk(W.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:oe.persistUntilDismissed?"Until closed":`${oe.durationSeconds}s`}),m.jsx("input",{type:"range",min:wp,max:Cp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:W=>Ie(W.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:wp,max:Cp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:W=>Ie(W.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!oe.enabled||oe.persistUntilDismissed,onClick:()=>ve(jb(qo)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:oe.persistUntilDismissed,disabled:!oe.enabled,onChange:W=>ve(wk(W.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[Kf(D)," max"]})]}),m.jsx("input",{ref:X,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:W=>{Xe(W.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:ge,onClick:()=>X.current?.click(),children:"Upload video"}),H?m.jsx("p",{className:"settings-error",children:H}):null,J.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:J.map(W=>m.jsxs("li",{"data-enabled":be.has(W.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:be.has(W.id),disabled:ge,"aria-label":`Use ${W.filename}`,onChange:We=>Ji(W.id,We.currentTarget.checked)}),m.jsx("video",{src:W.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:W.filename}),m.jsx("small",{children:W.source==="built-in"?"Built-in":Kf(W.size)})]})]}),W.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:ge,"aria-label":`Delete ${W.filename}`,onClick:()=>{ot(W.id)},children:"x"}):null]},W.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:ge||J.length===0||!De,onClick:()=>{qi()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:W=>{Ee.current.security=W},className:"settings-section-group",children:m.jsx(tk,{api:c})}),m.jsxs("section",{id:"settings-diagnostics",ref:W=>{Ee.current.diagnostics=W},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsxs("div",{children:[m.jsx("h3",{children:"Diagnostics"}),m.jsx("p",{className:"muted settings-control-description",children:"Recent browser lifecycle and auth transition events for troubleshooting."})]}),m.jsx("span",{className:"settings-diagnostics-count",children:he.length})]}),m.jsxs("div",{className:"settings-diagnostics-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||he.length===0,onClick:()=>{$t()},children:"Copy"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||he.length===0,onClick:()=>{_i()},children:"Send"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:xe||he.length===0,onClick:_n,children:"Clear"})]}),Ye?m.jsx("p",{className:"settings-status",children:Ye}):null,he.length>0?m.jsx("ol",{className:"settings-diagnostics-list","aria-label":"Recent diagnostics",children:he.slice(-8).reverse().map((W,We)=>m.jsxs("li",{children:[m.jsx("span",{children:sT(W.at)}),m.jsx("strong",{children:W.event}),W.data?m.jsx("code",{children:rT(W.data)}):null]},`${W.at}:${W.event}:${We}`))}):m.jsx("p",{className:"muted",children:"No diagnostics recorded yet."})]}),m.jsx("div",{id:"settings-servers",ref:W=>{Ee.current.servers=W},className:"settings-section-group",children:m.jsx(tT,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Pb(e,t){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();return s.top-r.top+t.scrollTop}function Kf(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 ol(e){return e instanceof Error?e.message:"Request failed."}function sT(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function rT(e){return Object.entries(e).slice(0,5).map(([t,s])=>`${t}=${String(s)}`).join(" ")}function aT(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 lT(e,t){if(e.length!==t.length)return!1;const s=new Set(t);return e.every(r=>s.has(r))}class oa extends Error{constructor(t,s){super(s),this.status=t,this.name="UploadClientError"}status}function oT(e){const t=e.createXhr?.()??new XMLHttpRequest,s=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));s.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())s.append(`file${o}`,c.file);return new Promise((o,c)=>{let h=!1;const p=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,p(),o(y))},f=y=>{h||(h=!0,p(),c(y))},b=()=>{t.abort(),f(new oa(0,"Upload aborted."))};if(e.signal?.aborted){f(new oa(0,"Upload aborted."));return}e.signal?.addEventListener("abort",b,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{f(new oa(t.status,"Invalid upload response."))}return}f(new oa(t.status,cT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new oa(0,"Upload failed.")),t.onabort=()=>f(new oa(0,"Upload aborted.")),t.ontimeout=()=>f(new oa(0,"Upload timed out.")),t.send(s)})}function cT(e,t){try{const s=JSON.parse(e),r=typeof s.error=="string"?s.error:s.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}const uT="modulepreload",hT=function(e){return"/"+e},Ib={},mg=function(t,s,r){let o=Promise.resolve();if(s&&s.length>0){let g=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=h?.nonce||h?.getAttribute("nonce");o=g(s.map(f=>{if(f=hT(f),f in Ib)return;Ib[f]=!0;const b=f.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const w=document.createElement("link");if(w.rel=b?"stylesheet":uT,b||(w.as="script"),w.crossOrigin="",w.href=f,p&&w.setAttribute("nonce",p),document.head.appendChild(w),b)return new Promise((S,E)=>{w.addEventListener("load",S),w.addEventListener("error",()=>E(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 o.then(h=>{for(const p of h||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},dT=v.lazy(()=>mg(()=>import("./MarkdownPreview-D-oOD4FK.js"),__vite__mapDeps([0,1])));function fT({api:e,activeTerminalId:t,activeTerminalCwd:s,workspaceRootPath:r=null,onOpenFile:o}){const[c,h]=v.useState(null),[p,g]=v.useState(""),[f,b]=v.useState({}),[y,w]=v.useState(()=>new Set),[S,E]=v.useState(null),[T,B]=v.useState({type:"empty"}),[A,N]=v.useState("idle"),[I,P]=v.useState(null),te=v.useRef(null),Q=v.useRef(null),le=v.useRef(!1),oe=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const Ce=ve.current,ie=r?mT(r):t?Kb(t,s):null,J=c?[c.rootPath,p].filter(Boolean).join("/"):"",F=S?.path??null;v.useEffect(()=>(le.current=!0,()=>{le.current=!1,oe.current+=1,ce()}),[]),v.useEffect(()=>{ve.current=t,Q.current=null,K(ie)},[e]),v.useEffect(()=>{r&&ie!==Q.current&&se(r,ie)},[r,ie]),v.useEffect(()=>{if(r||!Ce||t!==Ce)return;const ae=Kb(Ce,s);ae!==Q.current&&L(Ce,ae)},[Ce,t,s,r]);async function K(ae=ie){if(r){await se(r,ae);return}await L(t,ae)}async function se(ae,Te=ie){const Le=Ee();if(Q.current=Te,ce(),h(null),g(""),b({}),w(new Set),E(null),B({type:"empty"}),P(null),!ae){N("idle");return}N("loading");try{const Oe=await e.createFileRoot({path:ae});if(!be(Le))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const ze=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!be(Le))return;Z(ze),N("idle")}catch(Oe){be(Le)&&(P(Us(Oe)),N("idle"))}}async function L(ae,Te=ie){const Le=Ee();if(Q.current=Te,ce(),h(null),g(""),b({}),w(new Set),E(null),B({type:"empty"}),P(null),!ae){N("idle");return}N("loading");try{const Oe=await e.createFileRoot({terminalId:ae});if(!be(Le))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const ze=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!be(Le))return;Z(ze),N("idle")}catch(Oe){if(await De(Oe,Le))return;be(Le)&&(P(Us(Oe)),N("idle"))}}async function Y(ae=p,Te=c){if(!Te)return;const Le=Ee();N("loading"),P(null);try{const Oe=await e.listFiles({rootToken:Te.rootToken,path:ae});if(!be(Le))return;Z(Oe),N("idle")}catch(Oe){if(await De(Oe,Le))return;be(Le)&&(P(Us(Oe)),N("idle"))}}async function D(){if(r){await se(r,ie);return}ve.current=t,await L(t,ie)}function Z(ae){b(Te=>({...Te,[ae.path]:gT(ae.entries)}))}async function ge(ae){if(!(!Ff(ae)||!c)){if(E(ae),P(null),ae.kind==="directory"){g(ae.path),X(),await H(ae);return}if(g(ca(ae.path)),ae.editable){await he(ae);return}ae.previewKind!=="none"&&await xe(ae,ae.previewKind)}}async function R(ae){if(!(!Ff(ae)||!c)){if(E(ae),P(null),ae.kind==="directory"){g(ae.path),X(),await H(ae);return}if(g(ca(ae.path)),ae.editable){await we(ae);return}ae.previewKind!=="none"&&await xe(ae,ae.previewKind)}}async function H(ae){if(y.has(ae.path)){w(Te=>{const Le=new Set(Te);return Le.delete(ae.path),Le});return}w(Te=>new Set(Te).add(ae.path)),await Y(ae.path)}function ee(ae,Te){ae.key==="Enter"&&(ae.preventDefault(),R(Te))}async function he(ae){if(!c)return;const Te=Ee();N("loading"),ce();try{const Le=await e.readFile({rootToken:c.rootToken,path:ae.path});if(!be(Te))return;B({type:"text-preview",file:ae,read:Le}),N("idle")}catch(Le){if(await De(Le,Te))return;be(Te)&&(P(Us(Le)),N("idle"))}}async function we(ae){if(!c)return;const Te=Ee();N("loading");try{await o({rootToken:c.rootToken,path:ae.path,...t?{terminalId:t}:{}}),be(Te)&&N("idle")}catch(Le){if(await De(Le,Te))return;be(Te)&&(P(Us(Le)),N("idle"))}}async function xe(ae,Te){if(!c)return;const Le=Ee();N("loading"),ce();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:ae.path});if(!be(Le))return;const ze=URL.createObjectURL(Oe);if(!be(Le)){URL.revokeObjectURL(ze);return}te.current=ze,B({type:"preview",file:ae,previewKind:Te,url:ze}),N("idle")}catch(Oe){if(await De(Oe,Le))return;be(Le)&&(P(Us(Oe)),N("idle"))}}async function Re(ae){if(!c)return;const Te=ae==="file"?"New file":"New folder",Le=window.prompt(Te,""),Oe=S?S.kind==="directory"?S.path:ca(S.path):p,ze=Fb(Le,Oe);if(ze){P(null);try{const ht=await e.createFileEntry({rootToken:c.rootToken,path:ze,kind:ae});E(ht.entry),await Y(Oe)}catch(ht){if(await De(ht))return;P(Us(ht))}}}async function Ye(){if(!c||!S)return;const ae=window.prompt("Move selected entry",S.path),Te=Fb(ae,"");if(!Te||Te===S.path)return;const Le=ca(S.path),Oe=ca(Te);P(null);try{const ze=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:S.path,destinationPath:Te});E(ze.entry),g(ze.entry.kind==="directory"?ze.entry.path:ca(ze.entry.path)),X(),await Y(Le),Oe!==Le&&await Y(Oe)}catch(ze){if(await De(ze))return;P(Us(ze))}}async function _e(){if(!c||!S)return;const ae=S.path,Te=ca(ae);P(null);try{const Le=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:S.path}),Oe=Le.descendantCount>0?` and ${Le.descendantCount} nested item${Le.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Le.path}${Oe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:S.path,previewToken:Le.previewToken}),E(null),g(Te),w(ze=>{const ht=new Set(ze);for(const Xe of ze)(Xe===ae||Xe.startsWith(`${ae}/`))&&ht.delete(Xe);return ht}),X(),await Y(Te)}catch(Le){if(await De(Le))return;P(Us(Le))}}function X(){oe.current+=1,ce(),B({type:"empty"})}function ce(){te.current&&(URL.revokeObjectURL(te.current),te.current=null)}function Ee(){return oe.current+=1,oe.current}function be(ae){return le.current&&ae===oe.current}async function De(ae,Te){return _T(ae)?(Te!==void 0&&!be(Te)||await K(ie),!0):!1}function Be(ae,Te){const Le=Ff(ae),Oe=ae.kind==="directory"&&y.has(ae.path),ze=f[ae.path]??[],ht={"--file-tree-depth":Te};return m.jsxs(Ei.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ae.kind,"data-expanded":Oe,"data-active":F===ae.path,disabled:!Le,style:ht,"aria-expanded":ae.kind==="directory"?Oe:void 0,"aria-label":`${ae.kind==="directory"?"Open folder":"Open file"} ${ae.name}`,title:ae.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{ge(ae)},onDoubleClick:()=>{R(ae)},onKeyDown:Xe=>ee(Xe,ae),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ae.kind==="directory"?Oe?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:ae.name}),m.jsx("small",{children:pT(ae)})]}),Oe?m.jsx("div",{className:"file-tree-children",role:"group",children:ze.map(Xe=>Be(Xe,Te+1))}):null]},ae.path)}const Ie=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:J,children:J||"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:!r&&!t,onClick:()=>{D()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Re("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Re("directory")},children:"▣"})]})]}),I?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:I}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":J?`Files in ${J}`:"Files",children:Ie.map(ae=>Be(ae,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:S?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{Ye()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{_e()},children:"Delete"})]})]}),A==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&A!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?m.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?m.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(dT,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function Ff(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function pT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Kb(e,t){return`${e}\0${t??""}`}function mT(e){return`workspace\0${e}`}function gT(e){return[...e].sort((t,s)=>t.kind==="directory"&&s.kind!=="directory"?-1:t.kind!=="directory"&&s.kind==="directory"?1:t.name.localeCompare(s.name))}function ca(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Fb(e,t){if(e===null)return null;const s=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return s?!t||s.includes("/")?s:`${t}/${s}`:null}function Us(e){return e instanceof Error?e.message:"Request failed"}function _T(e){return e instanceof is&&e.status===409&&e.message==="terminal_cwd_changed"}const vT=v.lazy(()=>mg(()=>import("./MarkdownPreview-D-oOD4FK.js"),__vite__mapDeps([0,1])));function Wb({api:e,editor:t,canClose:s,onClose:r}){const[o,c]=v.useState(t.read),[h,p]=v.useState(t.read.content),[g,f]=v.useState("idle"),[b,y]=v.useState(null),[w,S]=v.useState(!1),[E,T]=v.useState("edit"),B=v.useRef(t),A=v.useRef(t.read),N=v.useRef(t.read.content),I=v.useRef(!1),P=v.useRef(!1),te=v.useRef(0),Q=h!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(P.current=!0,()=>{P.current=!1,te.current+=1}),[]),v.useEffect(()=>{te.current+=1,I.current=!1,B.current=t,A.current=t.read,N.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),S(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{A.current=o},[o]),v.useEffect(()=>{N.current=h},[h]),v.useEffect(()=>{if(h===o.content||w)return;const ie=window.setInterval(()=>{!I.current&&N.current!==A.current.content&&le()},1e3);return()=>window.clearInterval(ie)},[h===o.content,w,t.id]);async function le(){if(I.current)return;const ie=N.current,J=A.current;if(ie===J.content)return;const F=B.current,K=te.current;I.current=!0,f("saving"),y(null),S(!1);try{const se=await e.writeFile({rootToken:F.rootToken,path:F.path,content:ie,expectedVersion:J.version});if(!P.current||K!==te.current)return;const L={...J,content:ie,version:se.version};A.current=L,c(L),f(N.current===ie?"saved":"idle")}catch(se){if(!P.current||K!==te.current)return;if(se instanceof is&&se.status===409){S(!0),f("idle");return}y(yT(se)),f("idle")}finally{K===te.current&&(I.current=!1)}}const oe=g==="saving"?"saving":g==="saved"?"saved":o.language,ve=o.language==="markdown",Ce=ve&&E==="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:oe}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!Q,onClick:()=>{le()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${Ce?"Edit":"Preview"} ${t.title}`,onClick:()=>T(ie=>ie==="preview"?"edit":"preview"),children:Ce?"Edit":"Preview"}):null,s?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),b?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:b}):null,w?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,Ce?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(vT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:ie=>{const J=ie.target.value;N.current=J,p(J),f("idle"),y(null),S(!1)}})]})}function yT(e){return e instanceof Error?e.message:"Request failed"}var bT=2,ST=1,wT=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,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.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=r-p,b=o-g-t;return{cols:Math.max(bT,Math.floor(b/e.css.cell.width)),rows:Math.max(ST,Math.floor(f/e.css.cell.height))}}};var gw=Object.defineProperty,CT=Object.getOwnPropertyDescriptor,xT=(e,t)=>{for(var s in t)gw(e,s,{get:t[s],enumerable:!0})},ti=(e,t,s,r)=>{for(var o=r>1?void 0:r?CT(t,s):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(o=(r?h(t,s,o):h(o))||o);return r&&o&&gw(t,s,o),o},Me=(e,t)=>(s,r)=>t(s,r,e),qb="Terminal input",zp={get:()=>qb,set:e=>qb=e},$b="Too much output to announce, navigate to rows manually to read",jp={get:()=>$b,set:e=>$b=e};function ET(e){return e.replace(/\r?\n/g,"\r")}function kT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function TT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function DT(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");_w(o,t,s,r)}}function _w(e,t,s,r){e=ET(e),e=kT(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function vw(e,t,s){let r=s.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Yb(e,t,s,r,o){vw(e,t,s),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Rr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wh(e,t=0,s=e.length){let r="";for(let o=t;o<s;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var RT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<s;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=s)return this._interim=h,r;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[r++]=(h-55296)*1024+p-56320+65536:(t[r++]=h,t[r++]=p);continue}h!==65279&&(t[r++]=h)}return r}},MT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o,c,h,p,g=0,f=0;if(this.interim[0]){let w=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let E=0,T;for(;(T=this.interim[++E]&63)&&E<4;)S<<=6,S|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=B-E;for(;f<A;){if(f>=s)return 0;if(T=e[f++],(T&192)!==128){f--,w=!0;break}else this.interim[E++]=T,S<<=6,S|=T&63}w||(B===2?S<128?f--:t[r++]=S:B===3?S<2048||S>=55296&&S<=57343||S===65279||(t[r++]=S):S<65536||S>1114111||(t[r++]=S)),this.interim.fill(0)}let b=s-4,y=f;for(;y<s;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((p=e[y+3])&128);)t[r++]=o,t[r++]=c,t[r++]=h,t[r++]=p,y+=4;if(o=e[y++],o<128)t[r++]=o;else if((o&224)===192){if(y>=s)return this.interim[0]=o,r;if(c=e[y++],(c&192)!==128){y--;continue}if(g=(o&31)<<6|c&63,g<128){y--;continue}t[r++]=g}else if((o&240)===224){if(y>=s)return this.interim[0]=o,r;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[y++],(h&192)!==128){y--;continue}if(g=(o&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(y>=s)return this.interim[0]=o,r;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[y++],(h&192)!==128){y--;continue}if(y>=s)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=h,r;if(p=e[y++],(p&192)!==128){y--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|p&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},yw="",Nr=" ",uc=class bw{constructor(){this.fg=0,this.bg=0,this.extended=new Ju}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 bw;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}},Ju=class Sw{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Sw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xn=class ww extends uc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ju,this.combinedData=""}static fromCharData(t){let s=new ww;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Rr(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vb="di$target",Hp="di$dependencies",Wf=new Map;function NT(e){return e[Hp]||[]}function zi(e){if(Wf.has(e))return Wf.get(e);let t=function(s,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");AT(t,s,o)};return t._id=e,Wf.set(e,t),t}function AT(e,t,s){t[Vb]===t?t[Hp].push({id:e,index:s}):(t[Hp]=[{id:e,index:s}],t[Vb]=t)}var rn=zi("BufferService"),Cw=zi("CoreMouseService"),Ea=zi("CoreService"),LT=zi("CharsetService"),gg=zi("InstantiationService"),xw=zi("LogService"),an=zi("OptionsService"),Ew=zi("OscLinkService"),BT=zi("UnicodeService"),hc=zi("DecorationService"),Up=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new Xn,h=s.getTrimmedLength(),p=-1,g=-1,f=!1;for(let b=0;b<h;b++)if(!(g===-1&&!s.hasContent(b))){if(s.loadCell(b,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=b,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else g!==-1&&(f=!0);if(f||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let w={start:{x:g+1,y:e},end:{x:b+(!f&&b===h-1?1:0),y:e}},S=!1;if(!o?.allowNonHttpProtocols)try{let E=new URL(y);["http:","https:"].includes(E.protocol)||(S=!0)}catch{S=!0}S||r.push({text:y,range:w,activate:(E,T)=>o?o.activate(E,T,w):OT(E,T),hover:(E,T)=>o?.hover?.(E,T,w),leave:(E,T)=>o?.leave?.(E,T,w)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,p=c.extended.urlId):(g=-1,p=-1)}}t(r)}};Up=ti([Me(0,rn),Me(1,an),Me(2,Ew)],Up);function OT(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ch=zi("CharSizeService"),qs=zi("CoreBrowserService"),_g=zi("MouseService"),$s=zi("RenderService"),zT=zi("SelectionService"),kw=zi("CharacterJoinerService"),Tl=zi("ThemeService"),Tw=zi("LinkProviderService"),jT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Xb.isErrorNoTelemetry(e)?new Xb(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)}},HT=new jT;function Ou(e){UT(e)||HT.onUnexpectedError(e)}var Pp="Canceled";function UT(e){return e instanceof PT?!0:e instanceof Error&&e.name===Pp&&e.message===Pp}var PT=class extends Error{constructor(){super(Pp),this.name=this.message}};function IT(e){return new Error(`Illegal argument: ${e}`)}var Xb=class Ip extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Ip)return t;let s=new Ip;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Kp=class Dw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Dw.prototype)}};function Dn(e,t=0){return e[e.length-(1+t)]}var KT;(e=>{function t(c){return c<0}e.isLessThan=t;function s(c){return c<=0}e.isLessThanOrEqual=s;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(KT||={});function FT(e,t){let s=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(s,arguments))),o}}var Rw;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*o(P){yield P}e.single=o;function c(P){return t(P)?P:o(P)}e.wrap=c;function h(P){return P||s}e.from=h;function*p(P){for(let te=P.length-1;te>=0;te--)yield P[te]}e.reverse=p;function g(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=g;function f(P){return P[Symbol.iterator]().next().value}e.first=f;function b(P,te){let Q=0;for(let le of P)if(te(le,Q++))return!0;return!1}e.some=b;function y(P,te){for(let Q of P)if(te(Q))return Q}e.find=y;function*w(P,te){for(let Q of P)te(Q)&&(yield Q)}e.filter=w;function*S(P,te){let Q=0;for(let le of P)yield te(le,Q++)}e.map=S;function*E(P,te){let Q=0;for(let le of P)yield*te(le,Q++)}e.flatMap=E;function*T(...P){for(let te of P)yield*te}e.concat=T;function B(P,te,Q){let le=Q;for(let oe of P)le=te(le,oe);return le}e.reduce=B;function*A(P,te,Q=P.length){for(te<0&&(te+=P.length),Q<0?Q+=P.length:Q>P.length&&(Q=P.length);te<Q;te++)yield P[te]}e.slice=A;function N(P,te=Number.POSITIVE_INFINITY){let Q=[];if(te===0)return[Q,P];let le=P[Symbol.iterator]();for(let oe=0;oe<te;oe++){let ve=le.next();if(ve.done)return[Q,e.empty()];Q.push(ve.value)}return[Q,{[Symbol.iterator](){return le}}]}e.consume=N;async function I(P){let te=[];for await(let Q of P)te.push(Q);return Promise.resolve(te)}e.asyncToArray=I})(Rw||={});function wa(e){if(Rw.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function WT(...e){return Pt(()=>wa(e))}function Pt(e){return{dispose:FT(()=>{e()})}}var Mw=class Nw{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{wa(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?Nw.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)}};Mw.DISABLE_DISPOSED_WARNING=!1;var Lr=Mw,et=class{constructor(){this._store=new Lr,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)}};et.None=Object.freeze({dispose(){}});var Sl=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}},Fs=typeof window=="object"?window:globalThis,Fp=class Wp{constructor(t){this.element=t,this.next=Wp.Undefined,this.prev=Wp.Undefined}};Fp.Undefined=new Fp(void 0);var Wt=Fp,Gb=class{constructor(){this._first=Wt.Undefined,this._last=Wt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Wt.Undefined}clear(){let e=this._first;for(;e!==Wt.Undefined;){let t=e.next;e.prev=Wt.Undefined,e.next=Wt.Undefined,e=t}this._first=Wt.Undefined,this._last=Wt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Wt(e);if(this._first===Wt.Undefined)this._first=s,this._last=s;else if(t){let o=this._last;this._last=s,s.prev=o,o.next=s}else{let o=this._first;this._first=s,s.next=o,o.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Wt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Wt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Wt.Undefined&&e.next!==Wt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Wt.Undefined&&e.next===Wt.Undefined?(this._first=Wt.Undefined,this._last=Wt.Undefined):e.next===Wt.Undefined?(this._last=this._last.prev,this._last.next=Wt.Undefined):e.prev===Wt.Undefined&&(this._first=this._first.next,this._first.prev=Wt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Wt.Undefined;)yield e.element,e=e.next}},qT=globalThis.performance&&typeof globalThis.performance.now=="function",$T=class Aw{static create(t){return new Aw(t)}constructor(t){this._now=qT&&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}},Wi;(e=>{e.None=()=>et.None;function t(J,F){return y(J,()=>{},0,void 0,!0,void 0,F)}e.defer=t;function s(J){return(F,K=null,se)=>{let L=!1,Y;return Y=J(D=>{if(!L)return Y?Y.dispose():L=!0,F.call(K,D)},null,se),L&&Y.dispose(),Y}}e.once=s;function r(J,F,K){return f((se,L=null,Y)=>J(D=>se.call(L,F(D)),null,Y),K)}e.map=r;function o(J,F,K){return f((se,L=null,Y)=>J(D=>{F(D),se.call(L,D)},null,Y),K)}e.forEach=o;function c(J,F,K){return f((se,L=null,Y)=>J(D=>F(D)&&se.call(L,D),null,Y),K)}e.filter=c;function h(J){return J}e.signal=h;function p(...J){return(F,K=null,se)=>{let L=WT(...J.map(Y=>Y(D=>F.call(K,D))));return b(L,se)}}e.any=p;function g(J,F,K,se){let L=K;return r(J,Y=>(L=F(L,Y),L),se)}e.reduce=g;function f(J,F){let K,se={onWillAddFirstListener(){K=J(L.fire,L)},onDidRemoveLastListener(){K?.dispose()}},L=new ke(se);return F?.add(L),L.event}function b(J,F){return F instanceof Array?F.push(J):F&&F.add(J),J}function y(J,F,K=100,se=!1,L=!1,Y,D){let Z,ge,R,H=0,ee,he={leakWarningThreshold:Y,onWillAddFirstListener(){Z=J(xe=>{H++,ge=F(ge,xe),se&&!R&&(we.fire(ge),ge=void 0),ee=()=>{let Re=ge;ge=void 0,R=void 0,(!se||H>1)&&we.fire(Re),H=0},typeof K=="number"?(clearTimeout(R),R=setTimeout(ee,K)):R===void 0&&(R=0,queueMicrotask(ee))})},onWillRemoveListener(){L&&H>0&&ee?.()},onDidRemoveLastListener(){ee=void 0,Z.dispose()}},we=new ke(he);return D?.add(we),we.event}e.debounce=y;function w(J,F=0,K){return e.debounce(J,(se,L)=>se?(se.push(L),se):[L],F,void 0,!0,void 0,K)}e.accumulate=w;function S(J,F=(se,L)=>se===L,K){let se=!0,L;return c(J,Y=>{let D=se||!F(Y,L);return se=!1,L=Y,D},K)}e.latch=S;function E(J,F,K){return[e.filter(J,F,K),e.filter(J,se=>!F(se),K)]}e.split=E;function T(J,F=!1,K=[],se){let L=K.slice(),Y=J(ge=>{L?L.push(ge):Z.fire(ge)});se&&se.add(Y);let D=()=>{L?.forEach(ge=>Z.fire(ge)),L=null},Z=new ke({onWillAddFirstListener(){Y||(Y=J(ge=>Z.fire(ge)),se&&se.add(Y))},onDidAddFirstListener(){L&&(F?setTimeout(D):D())},onDidRemoveLastListener(){Y&&Y.dispose(),Y=null}});return se&&se.add(Z),Z.event}e.buffer=T;function B(J,F){return(K,se,L)=>{let Y=F(new N);return J(function(D){let Z=Y.evaluate(D);Z!==A&&K.call(se,Z)},void 0,L)}}e.chain=B;let A=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(F){return this.steps.push(F),this}forEach(F){return this.steps.push(K=>(F(K),K)),this}filter(F){return this.steps.push(K=>F(K)?K:A),this}reduce(F,K){let se=K;return this.steps.push(L=>(se=F(se,L),se)),this}latch(F=(K,se)=>K===se){let K=!0,se;return this.steps.push(L=>{let Y=K||!F(L,se);return K=!1,se=L,Y?L:A}),this}evaluate(F){for(let K of this.steps)if(F=K(F),F===A)break;return F}}function I(J,F,K=se=>se){let se=(...Z)=>D.fire(K(...Z)),L=()=>J.on(F,se),Y=()=>J.removeListener(F,se),D=new ke({onWillAddFirstListener:L,onDidRemoveLastListener:Y});return D.event}e.fromNodeEventEmitter=I;function P(J,F,K=se=>se){let se=(...Z)=>D.fire(K(...Z)),L=()=>J.addEventListener(F,se),Y=()=>J.removeEventListener(F,se),D=new ke({onWillAddFirstListener:L,onDidRemoveLastListener:Y});return D.event}e.fromDOMEventEmitter=P;function te(J){return new Promise(F=>s(J)(F))}e.toPromise=te;function Q(J){let F=new ke;return J.then(K=>{F.fire(K)},()=>{F.fire(void 0)}).finally(()=>{F.dispose()}),F.event}e.fromPromise=Q;function le(J,F){return J(K=>F.fire(K))}e.forward=le;function oe(J,F,K){return F(K),J(se=>F(se))}e.runAndSubscribe=oe;class ve{constructor(F,K){this._observable=F,this._counter=0,this._hasChanged=!1;let se={onWillAddFirstListener:()=>{F.addObserver(this)},onDidRemoveLastListener:()=>{F.removeObserver(this)}};this.emitter=new ke(se),K&&K.add(this.emitter)}beginUpdate(F){this._counter++}handlePossibleChange(F){}handleChange(F,K){this._hasChanged=!0}endUpdate(F){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ce(J,F){return new ve(J,F).emitter.event}e.fromObservable=Ce;function ie(J){return(F,K,se)=>{let L=0,Y=!1,D={beginUpdate(){L++},endUpdate(){L--,L===0&&(J.reportChanges(),Y&&(Y=!1,F.call(K)))},handlePossibleChange(){},handleChange(){Y=!0}};J.addObserver(D),J.reportChanges();let Z={dispose(){J.removeObserver(D)}};return se instanceof Lr?se.add(Z):Array.isArray(se)&&se.push(Z),Z}}e.fromObservableLight=ie})(Wi||={});var qp=class $p{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${$p._idPool++}`,$p.all.add(this)}start(t){this._stopWatch=new $T,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}}};qp.all=new Set,qp._idPool=0;var YT=qp,VT=-1,Lw=class Bw{constructor(t,s,r=(Bw._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let r=this.threshold;if(r<=0||s<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,h]=this.getMostFrequentStack(),p=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${h}):`;console.warn(p),console.warn(c);let g=new ZT(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,s=0;for(let[r,o]of this._stacks)(!t||s<o)&&(t=[r,o],s=o);return t}};Lw._idPool=1;var XT=Lw,GT=class Ow{constructor(t){this.value=t}static create(){let t=new Error;return new Ow(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},ZT=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},QT=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},JT=0,qf=class{constructor(e){this.value=e,this.id=JT++}},eD=2,tD,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new XT(e?.onListenerError??Ou,this._options?.leakWarningThreshold??VT):void 0,this._perfMon=this._options?._profName?new YT(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,s)=>{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 QT(`${h}. HINT: Stack shows most frequent listener (${p[1]}-times)`,p[0]);return(this._options?.onListenerError||Ou)(g),et.None}if(this._disposed)return et.None;t&&(e=e.bind(t));let r=new qf(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=GT.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof qf?(this._deliveryQueue??=new iD,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Pt(()=>{o?.(),this._removeListener(r)});return s instanceof Lr?s.add(c):Array.isArray(s)&&s.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,s=t.indexOf(e);if(s===-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[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*eD<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||Ou;if(!s){e.value(t);return}try{e.value(t)}catch(r){s(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof qf)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}},iD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Yp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Yp.INSTANCE=new Yp;var vg=Yp;function nD(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}vg.INSTANCE.onDidChangeZoomLevel;function sD(e){return vg.INSTANCE.getZoomFactor(e)}vg.INSTANCE.onDidChangeFullscreen;var Dl=typeof navigator=="object"?navigator.userAgent:"",Vp=Dl.indexOf("Firefox")>=0,rD=Dl.indexOf("AppleWebKit")>=0,yg=Dl.indexOf("Chrome")>=0,aD=!yg&&Dl.indexOf("Safari")>=0;Dl.indexOf("Electron/")>=0;Dl.indexOf("Android")>=0;var $f=!1;if(typeof Fs.matchMedia=="function"){let e=Fs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Fs.matchMedia("(display-mode: fullscreen)");$f=e.matches,nD(Fs,e,({matches:s})=>{$f&&t.matches||($f=s)})}var dl="en",Xp=!1,Gp=!1,zu=!1,zw=!1,xu,ju=dl,Zb=dl,lD,Is,va=globalThis,Nn;typeof va.vscode<"u"&&typeof va.vscode.process<"u"?Nn=va.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Nn=process);var oD=typeof Nn?.versions?.electron=="string",cD=oD&&Nn?.type==="renderer";if(typeof Nn=="object"){Xp=Nn.platform==="win32",Gp=Nn.platform==="darwin",zu=Nn.platform==="linux",zu&&Nn.env.SNAP&&Nn.env.SNAP_REVISION,Nn.env.CI||Nn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xu=dl,ju=dl;let e=Nn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);xu=t.userLocale,Zb=t.osLocale,ju=t.resolvedLanguage||dl,lD=t.languagePack?.translationsConfigFile}catch{}zw=!0}else typeof navigator=="object"&&!cD?(Is=navigator.userAgent,Xp=Is.indexOf("Windows")>=0,Gp=Is.indexOf("Macintosh")>=0,(Is.indexOf("Macintosh")>=0||Is.indexOf("iPad")>=0||Is.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zu=Is.indexOf("Linux")>=0,Is?.indexOf("Mobi")>=0,ju=globalThis._VSCODE_NLS_LANGUAGE||dl,xu=navigator.language.toLowerCase(),Zb=xu):console.error("Unable to resolve platform.");var jw=Xp,vs=Gp,uD=zu,Qb=zw,ys=Is,wr=ju,hD;(e=>{function t(){return wr}e.value=t;function s(){return wr.length===2?wr==="en":wr.length>=3?wr[0]==="e"&&wr[1]==="n"&&wr[2]==="-":!1}e.isDefaultVariant=s;function r(){return wr==="en"}e.isDefault=r})(hD||={});var dD=typeof va.postMessage=="function"&&!va.importScripts;(()=>{if(dD){let e=[];va.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===s.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return s=>{let r=++t;e.push({id:r,callback:s}),va.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var fD=!!(ys&&ys.indexOf("Chrome")>=0);ys&&ys.indexOf("Firefox")>=0;!fD&&ys&&ys.indexOf("Safari")>=0;ys&&ys.indexOf("Edg/")>=0;ys&&ys.indexOf("Android")>=0;var cl=typeof navigator=="object"?navigator:{};Qb||document.queryCommandSupported&&document.queryCommandSupported("copy")||cl&&cl.clipboard&&cl.clipboard.writeText,Qb||cl&&cl.clipboard&&cl.clipboard.readText;var bg=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}},Yf=new bg,Jb=new bg,eS=new bg,pD=new Array(230),Hw;(e=>{function t(p){return Yf.keyCodeToStr(p)}e.toString=t;function s(p){return Yf.strToKeyCode(p)}e.fromString=s;function r(p){return Jb.keyCodeToStr(p)}e.toUserSettingsUS=r;function o(p){return eS.keyCodeToStr(p)}e.toUserSettingsGeneral=o;function c(p){return Jb.strToKeyCode(p)||eS.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 Yf.keyCodeToStr(p)}e.toElectronAccelerator=h})(Hw||={});var mD=class Uw{constructor(t,s,r,o,c){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Uw&&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",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${s}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new gD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},gD=class{constructor(e){if(e.length===0)throw IT("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;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 _D(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Hw.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Vp)switch(t){case 59:return 85;case 60:if(uD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(vs)return 57;break}else if(rD&&(vs&&t===93||!vs&&t===92))return 57;return pD[t]||0}var vD=vs?256:2048,yD=512,bD=1024,SD=vs?2048:256,tS=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=_D(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|=vD),this.altKey&&(t|=yD),this.shiftKey&&(t|=bD),this.metaKey&&(t|=SD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new mD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},iS=new WeakMap;function wD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var CD=class{static getSameOriginWindowChain(e){let t=iS.get(e);if(!t){t=[],iS.set(e,t);let s=e,r;do r=wD(s),r?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=r;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let h=c.window.deref();if(s+=h?.scrollY??0,r+=h?.scrollX??0,h===t||!c.iframeElement)break;let p=c.iframeElement.getBoundingClientRect();s+=p.top,r+=p.left}return{top:s,left:r}}},Eu=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 s=CD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},nS=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let r=!1;if(yg){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vp&&!vs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")aD&&jw?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vp&&!vs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Pw=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),xD;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof ED?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Wi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Pw})})(xD||={});var ED=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?Pw:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Sg=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 Kp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Kp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},kD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Kp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Pt(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},TD;(e=>{async function t(r){let o,c=await Promise.all(r.map(h=>h.then(p=>p,p=>{o||(o=p)})));if(typeof o<"u")throw o;return c}e.settled=t;function s(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(h){c(h)}})}e.withAsyncBody=s})(TD||={});var sS=class qn{static fromArray(t){return new qn(s=>{s.emitMany(t)})}static fromPromise(t){return new qn(async s=>{s.emitMany(await t)})}static fromPromises(t){return new qn(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new qn(async s=>{await Promise.all(t.map(async r=>{for await(let o of r)s.emitOne(o)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new ke,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Wi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new qn(async r=>{for await(let o of t)r.emitOne(s(o))})}map(t){return qn.map(this,t)}static filter(t,s){return new qn(async r=>{for await(let o of t)s(o)&&r.emitOne(o)})}filter(t){return qn.filter(this,t)}static coalesce(t){return qn.filter(t,s=>!!s)}coalesce(){return qn.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return qn.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())}};sS.EMPTY=sS.fromArray([]);var{getWindow:_s,getWindowId:DD,onDidRegisterWindow:RD}=(function(){let e=new Map,t={window:Fs,disposables:new Lr};e.set(Fs.vscodeWindowId,t);let s=new ke,r=new ke,o=new ke;function c(h,p){return(typeof h=="number"?e.get(h):void 0)??(p?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(h){if(e.has(h.vscodeWindowId))return et.None;let p=new Lr,g={window:h,disposables:p.add(new Lr)};return e.set(h.vscodeWindowId,g),p.add(Pt(()=>{e.delete(h.vscodeWindowId),r.fire(h)})),p.add(qe(h,Ri.BEFORE_UNLOAD,()=>{o.fire(h)})),s.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:Fs},getDocument(h){return _s(h).document}}})(),MD=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function qe(e,t,s,r){return new MD(e,t,s,r)}var rS=function(e,t,s,r){return qe(e,t,s,r)},wg,ND=class extends kD{constructor(e){super(),this.defaultTarget=e&&_s(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},aS=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){Ou(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,o=c=>{s.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),r.set(c,!0);h.length>0;)h.sort(aS.sort),h.shift().execute();r.set(c,!1)};wg=(c,h,p=0)=>{let g=DD(c),f=new aS(h,p),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(f),s.get(g)||(s.set(g,!0),c.requestAnimationFrame(()=>o(g))),f}})();function AD(e){let t=e.getBoundingClientRect(),s=_s(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ri={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"},LD=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=pn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=pn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=pn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=pn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=pn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=pn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=pn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=pn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=pn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=pn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=pn(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=pn(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=pn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=pn(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 pn(e){return typeof e=="number"?`${e}px`:e}function Yo(e){return new LD(e)}var Iw=class{constructor(){this._hooks=new Lr,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(Pt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=_s(e)}this._hooks.add(qe(c,Ri.POINTER_MOVE,h=>{if(h.buttons!==s){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(qe(c,Ri.POINTER_UP,h=>this.stopMonitoring(!0)))}};function BD(e,t,s){let r=null,o=null;if(typeof s.value=="function"?(r="value",o=s.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",o=s.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;s[r]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,h)}),this[c]}}var gs;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(gs||={});var Ao=class Qi extends et{constructor(){super(),this.dispatched=!1,this.targets=new Gb,this.ignoreTargets=new Gb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Wi.runAndSubscribe(RD,({window:t,disposables:s})=>{s.add(qe(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(qe(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(qe(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Fs,disposables:this._store}))}static addTarget(t){if(!Qi.isTouchDevice())return et.None;Qi.INSTANCE||(Qi.INSTANCE=new Qi);let s=Qi.INSTANCE.targets.push(t);return Pt(s)}static ignoreTarget(t){if(!Qi.isTouchDevice())return et.None;Qi.INSTANCE||(Qi.INSTANCE=new Qi);let s=Qi.INSTANCE.ignoreTargets.push(t);return Pt(s)}static isTouchDevice(){return"ontouchstart"in Fs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:s,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[s],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(gs.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,s){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,h=s.changedTouches.length;c<h;c++){let p=s.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<Qi.HOLD_DELAY&&Math.abs(g.initialPageX-Dn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Dn(g.rollingPageY))<30){let b=this.newGestureEvent(gs.Tap,g.initialTarget);b.pageX=Dn(g.rollingPageX),b.pageY=Dn(g.rollingPageY),this.dispatchEvent(b)}else if(f>=Qi.HOLD_DELAY&&Math.abs(g.initialPageX-Dn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Dn(g.rollingPageY))<30){let b=this.newGestureEvent(gs.Contextmenu,g.initialTarget);b.pageX=Dn(g.rollingPageX),b.pageY=Dn(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=Dn(g.rollingPageX),y=Dn(g.rollingPageY),w=Dn(g.rollingTimestamps)-g.rollingTimestamps[0],S=b-g.rollingPageX[0],E=y-g.rollingPageY[0],T=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,T,r,Math.abs(S)/w,S>0?1:-1,b,Math.abs(E)/w,E>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(gs.End,g.initialTarget)),delete this.activeTouches[p.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===gs.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Qi.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===gs.Change||t.type===gs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;s.push([o,r])}s.sort((r,o)=>r[0]-o[0]);for(let[r,o]of s)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,o,c,h,p,g,f){this.handle=wg(t,()=>{let b=Date.now(),y=b-r,w=0,S=0,E=!0;o+=Qi.SCROLL_FRICTION*y,p+=Qi.SCROLL_FRICTION*y,o>0&&(E=!1,w=c*o*y),p>0&&(E=!1,S=g*p*y);let T=this.newGestureEvent(gs.Change);T.translationX=w,T.translationY=S,s.forEach(B=>B.dispatchEvent(T)),E||this.inertia(t,s,b,o,c,h+w,p,g,f+S)})}onTouchMove(t){let s=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],p=this.newGestureEvent(gs.Change,h.initialTarget);p.translationX=c.pageX-Dn(h.rollingPageX),p.translationY=c.pageY-Dn(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(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ao.SCROLL_FRICTION=-.005,Ao.HOLD_DELAY=700,Ao.CLEAR_TAP_COUNT_TIME=400,ti([BD],Ao,"isTouchDevice",1);var OD=Ao,Cg=class extends et{onclick(e,t){this._register(qe(e,Ri.CLICK,s=>t(new Eu(_s(e),s))))}onmousedown(e,t){this._register(qe(e,Ri.MOUSE_DOWN,s=>t(new Eu(_s(e),s))))}onmouseover(e,t){this._register(qe(e,Ri.MOUSE_OVER,s=>t(new Eu(_s(e),s))))}onmouseleave(e,t){this._register(qe(e,Ri.MOUSE_LEAVE,s=>t(new Eu(_s(e),s))))}onkeydown(e,t){this._register(qe(e,Ri.KEY_DOWN,s=>t(new tS(s))))}onkeyup(e,t){this._register(qe(e,Ri.KEY_UP,s=>t(new tS(s))))}oninput(e,t){this._register(qe(e,Ri.INPUT,t))}onblur(e,t){this._register(qe(e,Ri.BLUR,t))}onfocus(e,t){this._register(qe(e,Ri.FOCUS,t))}onchange(e,t){this._register(qe(e,Ri.CHANGE,t))}ignoreGesture(e){return OD.ignoreTarget(e)}},lS=11,zD=class extends Cg{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=lS+"px",this.domNode.style.height=lS+"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 Iw),this._register(rS(this.bgDomNode,Ri.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(rS(this.domNode,Ri.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ND),this._pointerdownScheduleRepeatTimer=this._register(new Sg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,_s(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},jD=class Zp{constructor(t,s,r,o,c,h,p){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,o=o|0,c=c|0,h=h|0,p=p|0),this.rawScrollLeft=o,this.rawScrollTop=p,s<0&&(s=0),o+s>r&&(o=r-s),o<0&&(o=0),c<0&&(c=0),p+c>h&&(p=h-c),p<0&&(p=0),this.width=s,this.scrollWidth=r,this.scrollLeft=o,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,s){return new Zp(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Zp(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,s){let r=this.width!==t.width,o=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:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:p,scrollTopChanged:g}}},HD=class extends et{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new jD(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 s=this._state.withScrollDimensions(e,t);this._setState(s,!!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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new cS(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=cS.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},oS=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Vf(e,t){let s=t-e;return function(r){return e+s*ID(r)}}function UD(e,t,s){return function(r){return r<s?e(r/s):t((r-s)/(1-s))}}var cS=class Qp{constructor(t,s,r,o){this.from=t,this.to=s,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,r){if(Math.abs(t-s)>2.5*r){let o,c;return t<s?(o=t+.75*r,c=s-.75*r):(o=t-.75*r,c=s+.75*r),UD(Vf(t,o),Vf(c,s),.33)}return Vf(t,s)}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 s=(t-this.startTime)/this.duration;if(s<1){let r=this.scrollLeft(s),o=this.scrollTop(s);return new oS(r,o,!1)}return new oS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,r){return Qp.start(t,s,r)}static start(t,s,r){r=r+10;let o=Date.now()-10;return new Qp(t,s,o,r)}};function PD(e){return Math.pow(e,3)}function ID(e){return 1-PD(1-e)}var KD=class extends et{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Sg)}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":"")))}},FD=140,Kw=class extends Cg{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 KD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Iw),this._shouldRender=!0,this.domNode=Yo(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(qe(this.domNode.domNode,Ri.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Yo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(qe(this.slider.domNode,Ri.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);s<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let o=AD(this.domNode.domNode);t=e.pageX-o.left,s=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),h=Math.abs(c-s);if(jw&&h>FD){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let p=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.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()}},Fw=class Jp{constructor(t,s,r,o,c,h){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,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 Jp(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,o,c){let h=Math.max(0,r-t),p=Math.max(0,h-2*s),g=o>0&&o>r;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(r*p/o))),b=(p-f)/(o-r),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=Jp._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},WD=class extends Kw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Fw(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},qD=class extends Kw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Fw(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,o.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},$D=500,uS=50,YD=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},em=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,s=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,s+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(yg){let s=_s(t.browserEvent),r=sD(s);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,r){let o=null,c=new YD(t,s,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(s.deltaX),p=Math.abs(s.deltaY),g=Math.max(Math.min(o,h),1),f=Math.max(Math.min(c,p),1),b=Math.max(o,h),y=Math.max(c,p);b%g===0&&y%f===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};em.INSTANCE=new em;var VD=em,XD=class extends Cg{constructor(e,t,s){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=ZD(t),this._scrollable=s,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new qD(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new WD(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Yo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Yo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Yo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new Sg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=wa(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,vs&&(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 nS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=wa(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new nS(s))};this._mouseWheelToDispose.push(qe(this._listenOnDomNode,Ri.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=VD.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!vs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),g={};if(o){let f=uS*o,b=p.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let f=uS*c,b=p.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(p.scrollLeft!==g.scrollLeft||p.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,r=s?" left":"",o=t?" top":"",c=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),$D)}},GD=class extends XD{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ZD(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,vs&&(t.className+=" mac"),t}var tm=class extends et{constructor(e,t,s,r,o,c,h,p){super(),this._bufferService=s,this._optionsService=h,this._renderService=p,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new HD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>wg(r.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new GD(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Wi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Pt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Pt(()=>this._styleElement.remove())),this._register(Wi.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),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};tm=ti([Me(2,rn),Me(3,qs),Me(4,Cw),Me(5,Tl),Me(6,an),Me(7,$s)],tm);var im=class extends et{constructor(e,t,s,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(Pt(()=>{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 s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};im=ti([Me(1,rn),Me(2,qs),Me(3,hc),Me(4,$s)],im);var QD=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ps={full:0,left:0,center:0,right:0},Cr={full:0,left:0,center:0,right:0},So={full:0,left:0,center:0,right:0},eh=class extends et{constructor(e,t,s,r,o,c,h,p){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=p,this._colorZoneStore=new QD,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(Pt(()=>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);Cr.full=this._canvas.width,Cr.left=e,Cr.center=t,Cr.right=e,this._refreshDrawHeightConstants(),So.full=1,So.left=1,So.center=1+Cr.left,So.right=1+Cr.left+Cr.center}_refreshDrawHeightConstants(){ps.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ps.left=t,ps.center=t,ps.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ps.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ps.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ps.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ps.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(So[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ps[e.position||"full"]/2),Cr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ps[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};eh=ti([Me(2,rn),Me(3,hc),Me(4,$s),Me(5,an),Me(6,Tl),Me(7,qs)],eh);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 Hu;(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=""))(Hu||={});var Ww;(e=>e.ST=`${fe.ESC}\\`)(Ww||={});var nm=class{constructor(e,t,s,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!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),s=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};nm=ti([Me(2,rn),Me(3,an),Me(4,Ea),Me(5,$s)],nm);var Ai=0,Li=0,Bi=0,ei=0,hS={css:"#00000000",rgba:0},mi;(e=>{function t(o,c,h,p){return p!==void 0?`#${ua(o)}${ua(c)}${ua(h)}${ua(p)}`:`#${ua(o)}${ua(c)}${ua(h)}`}e.toCss=t;function s(o,c,h,p=255){return(o<<24|c<<16|h<<8|p)>>>0}e.toRgba=s;function r(o,c,h,p){return{css:e.toCss(o,c,h,p),rgba:e.toRgba(o,c,h,p)}}e.toColor=r})(mi||={});var Ht;(e=>{function t(g,f){if(ei=(f.rgba&255)/255,ei===1)return{css:f.css,rgba:f.rgba};let b=f.rgba>>24&255,y=f.rgba>>16&255,w=f.rgba>>8&255,S=g.rgba>>24&255,E=g.rgba>>16&255,T=g.rgba>>8&255;Ai=S+Math.round((b-S)*ei),Li=E+Math.round((y-E)*ei),Bi=T+Math.round((w-T)*ei);let B=mi.toCss(Ai,Li,Bi),A=mi.toRgba(Ai,Li,Bi);return{css:B,rgba:A}}e.blend=t;function s(g){return(g.rgba&255)===255}e.isOpaque=s;function r(g,f,b){let y=Uu.ensureContrastRatio(g.rgba,f.rgba,b);if(y)return mi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=r;function o(g){let f=(g.rgba|255)>>>0;return[Ai,Li,Bi]=Uu.toChannels(f),{css:mi.toCss(Ai,Li,Bi),rgba:f}}e.opaque=o;function c(g,f){return ei=Math.round(f*255),[Ai,Li,Bi]=Uu.toChannels(g.rgba),{css:mi.toCss(Ai,Li,Bi,ei),rgba:mi.toRgba(Ai,Li,Bi,ei)}}e.opacity=c;function h(g,f){return ei=g.rgba&255,c(g,ei*f/255)}e.multiplyOpacity=h;function p(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=p})(Ht||={});var qt;(e=>{let t,s;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Ai=parseInt(o.slice(1,2).repeat(2),16),Li=parseInt(o.slice(2,3).repeat(2),16),Bi=parseInt(o.slice(3,4).repeat(2),16),mi.toColor(Ai,Li,Bi);case 5:return Ai=parseInt(o.slice(1,2).repeat(2),16),Li=parseInt(o.slice(2,3).repeat(2),16),Bi=parseInt(o.slice(3,4).repeat(2),16),ei=parseInt(o.slice(4,5).repeat(2),16),mi.toColor(Ai,Li,Bi,ei);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let c=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Ai=parseInt(c[1]),Li=parseInt(c[2]),Bi=parseInt(c[3]),ei=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),mi.toColor(Ai,Li,Bi,ei);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ai,Li,Bi,ei]=t.getImageData(0,0,1,1).data,ei!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:mi.toRgba(Ai,Li,Bi,ei),css:o}}e.toColor=r})(qt||={});var sn;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,o,c){let h=r/255,p=o/255,g=c/255,f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return f*.2126+b*.7152+y*.0722}e.relativeLuminance2=s})(sn||={});var Uu;(e=>{function t(h,p){if(ei=(p&255)/255,ei===1)return p;let g=p>>24&255,f=p>>16&255,b=p>>8&255,y=h>>24&255,w=h>>16&255,S=h>>8&255;return Ai=y+Math.round((g-y)*ei),Li=w+Math.round((f-w)*ei),Bi=S+Math.round((b-S)*ei),mi.toRgba(Ai,Li,Bi)}e.blend=t;function s(h,p,g){let f=sn.relativeLuminance(h>>8),b=sn.relativeLuminance(p>>8);if(Ps(f,b)<g){if(b<f){let S=r(h,p,g),E=Ps(f,sn.relativeLuminance(S>>8));if(E<g){let T=o(h,p,g),B=Ps(f,sn.relativeLuminance(T>>8));return E>B?S:T}return S}let y=o(h,p,g),w=Ps(f,sn.relativeLuminance(y>>8));if(w<g){let S=r(h,p,g),E=Ps(f,sn.relativeLuminance(S>>8));return w>E?y:S}return y}}e.ensureContrastRatio=s;function r(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,w=p>>24&255,S=p>>16&255,E=p>>8&255,T=Ps(sn.relativeLuminance2(w,S,E),sn.relativeLuminance2(f,b,y));for(;T<g&&(w>0||S>0||E>0);)w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),E-=Math.max(0,Math.ceil(E*.1)),T=Ps(sn.relativeLuminance2(w,S,E),sn.relativeLuminance2(f,b,y));return(w<<24|S<<16|E<<8|255)>>>0}e.reduceLuminance=r;function o(h,p,g){let f=h>>24&255,b=h>>16&255,y=h>>8&255,w=p>>24&255,S=p>>16&255,E=p>>8&255,T=Ps(sn.relativeLuminance2(w,S,E),sn.relativeLuminance2(f,b,y));for(;T<g&&(w<255||S<255||E<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),E=Math.min(255,E+Math.ceil((255-E)*.1)),T=Ps(sn.relativeLuminance2(w,S,E),sn.relativeLuminance2(f,b,y));return(w<<24|S<<16|E<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(Uu||={});function ua(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ps(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var JD=class extends uc{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}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()]}},th=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Xn}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 s=[],r=t.translateToString(!0),o=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-o>1){let b=this._getJoinedRanges(r,h,c,t,o);for(let y=0;y<b.length;y++)s.push(b[y])}o=f,h=c,p=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Nr.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(r,h,c,t,o);for(let b=0;b<f.length;b++)s.push(f[b])}return s}_getJoinedRanges(e,t,s,r,o){let c=e.substring(t,s),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++)th._mergeRanges(h,g[f])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,r,o),h}_stringRangesToCellRanges(e,t,s){let r=0,o=!1,c=0,h=e[r];if(h){for(let p=s;p<this._bufferService.cols;p++){let g=t.getWidth(p),f=t.getString(p).length||Nr.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=p,o=!0),h[1]<=c){if(h[1]=p,h=e[++r],!h)break;h[0]<=c?(h[0]=p,o=!0):o=!1}c+=f}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let r=0;r<e.length;r++){let o=e[r];if(s){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};th=ti([Me(0,rn)],th);function eR(e){return 57508<=e&&e<=57558}function tR(e){return 9472<=e&&e<=9631}function iR(e){return eR(e)||tR(e)}function nR(){return{css:{canvas:ku(),cell:ku()},device:{canvas:ku(),cell:ku(),char:{width:0,height:0,left:0,top:0}}}}function ku(){return{width:0,height:0}}var sm=class{constructor(e,t,s,r,o,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=h,this._workCell=new Xn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,r,o,c,h,p,g,f,b){let y=[],w=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,E=e.getNoBgTrimmedLength();s&&E<c+1&&(E=c+1);let T,B=0,A="",N=0,I=0,P=0,te=0,Q=!1,le=0,oe=!1,ve=0,Ce=0,ie=[],J=f!==-1&&b!==-1;for(let F=0;F<E;F++){e.loadCell(F,this._workCell);let K=this._workCell.getWidth();if(K===0)continue;let se=!1,L=F>=Ce,Y=F,D=this._workCell;if(w.length>0&&F===w[0][0]&&L){let be=w.shift(),De=this._isCellInSelection(be[0],t);for(N=be[0]+1;N<be[1];N++)L&&=De===this._isCellInSelection(N,t);L&&=!s||c<be[0]||c>=be[1],L?(se=!0,D=new JD(this._workCell,e.translateToString(!0,be[0],be[1]),be[1]-be[0]),Y=be[1]-1,K=D.getWidth()):Ce=be[1]}let Z=this._isCellInSelection(F,t),ge=s&&F===c,R=J&&F>=f&&F<=b,H=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,be=>{H=!0});let ee=D.getChars()||Nr;if(ee===" "&&(D.isUnderline()||D.isOverline())&&(ee=" "),ve=K*p-g.get(ee,D.isBold(),D.isItalic()),!T)T=this._document.createElement("span");else if(B&&(Z&&oe||!Z&&!oe&&D.bg===I)&&(Z&&oe&&S.selectionForeground||D.fg===P)&&D.extended.ext===te&&R===Q&&ve===le&&!ge&&!se&&!H&&L){D.isInvisible()?A+=Nr:A+=ee,B++;continue}else B&&(T.textContent=A),T=this._document.createElement("span"),B=0,A="";if(I=D.bg,P=D.fg,te=D.extended.ext,Q=R,le=ve,oe=Z,se&&c>=F&&c<=Y&&(c=F),!this._coreService.isCursorHidden&&ge&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&ie.push("xterm-cursor-blink"),ie.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(D.isBold()&&ie.push("xterm-bold"),D.isItalic()&&ie.push("xterm-italic"),D.isDim()&&ie.push("xterm-dim"),D.isInvisible()?A=Nr:A=D.getChars()||Nr,D.isUnderline()&&(ie.push(`xterm-underline-${D.extended.underlineStyle}`),A===" "&&(A=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${uc.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let be=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&be<8&&(be+=8),T.style.textDecorationColor=S.ansi[be].css}D.isOverline()&&(ie.push("xterm-overline"),A===" "&&(A=" ")),D.isStrikethrough()&&ie.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let he=D.getFgColor(),we=D.getFgColorMode(),xe=D.getBgColor(),Re=D.getBgColorMode(),Ye=!!D.isInverse();if(Ye){let be=he;he=xe,xe=be;let De=we;we=Re,Re=De}let _e,X,ce=!1;this._decorationService.forEachDecorationAtCell(F,t,void 0,be=>{be.options.layer!=="top"&&ce||(be.backgroundColorRGB&&(Re=50331648,xe=be.backgroundColorRGB.rgba>>8&16777215,_e=be.backgroundColorRGB),be.foregroundColorRGB&&(we=50331648,he=be.foregroundColorRGB.rgba>>8&16777215,X=be.foregroundColorRGB),ce=be.options.layer==="top")}),!ce&&Z&&(_e=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,xe=_e.rgba>>8&16777215,Re=50331648,ce=!0,S.selectionForeground&&(we=50331648,he=S.selectionForeground.rgba>>8&16777215,X=S.selectionForeground)),ce&&ie.push("xterm-decoration-top");let Ee;switch(Re){case 16777216:case 33554432:Ee=S.ansi[xe],ie.push(`xterm-bg-${xe}`);break;case 50331648:Ee=mi.toColor(xe>>16,xe>>8&255,xe&255),this._addStyle(T,`background-color:#${dS((xe>>>0).toString(16),"0",6)}`);break;default:Ye?(Ee=S.foreground,ie.push("xterm-bg-257")):Ee=S.background}switch(_e||D.isDim()&&(_e=Ht.multiplyOpacity(Ee,.5)),we){case 16777216:case 33554432:D.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(T,Ee,S.ansi[he],D,_e,void 0)||ie.push(`xterm-fg-${he}`);break;case 50331648:let be=mi.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(T,Ee,be,D,_e,X)||this._addStyle(T,`color:#${dS(he.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Ee,S.foreground,D,_e,X)||Ye&&ie.push("xterm-fg-257")}ie.length&&(T.className=ie.join(" "),ie.length=0),!ge&&!se&&!H&&L?B++:T.textContent=A,ve!==this.defaultSpacing&&(T.style.letterSpacing=`${ve}px`),y.push(T),F=Y}return T&&B&&(T.textContent=A),y}_applyMinimumContrast(e,t,s,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||iR(r.getCode()))return!1;let h=this._getContrastCache(r),p;if(!o&&!c&&(p=h.getColor(t.rgba,s.rgba)),p===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);p=Ht.ensureContrastRatio(o||t,c||s,g),h.setColor((o||t).rgba,(c||s).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 s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e<r[0]&&t<=r[1]:e<s[0]&&t>=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t<r[1]||s[1]===r[1]&&t===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&t===r[1]&&e<r[0]||s[1]<r[1]&&t===s[1]&&e>=s[0]}};sm=ti([Me(1,kw),Me(2,an),Me(3,qs),Me(4,Ea),Me(5,hc),Me(6,Tl)],sm);function dS(e,t,s){for(;e.length<s;)e=t+e;return e}var sR=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,r,o,c],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,r){e===this._font&&t===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,s){let r=0;if(!t&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let h=this._measure(e,0);return h>0&&(this._flat[r]=h),h}let o=e;t&&(o+="B"),s&&(o+="I");let c=this._holey.get(o);if(c===void 0){let h=0;t&&(h|=1),s&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},rR=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,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,h=s[1]-o,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=r,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=p,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function aR(){return new rR}var Xf="xterm-dom-renderer-owner-",Wn="xterm-rows",Tu="xterm-fg-",fS="xterm-bg-",wo="xterm-focus",Du="xterm-selection",lR=1,rm=class extends et{constructor(e,t,s,r,o,c,h,p,g,f,b,y,w,S){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=f,this._bufferService=b,this._coreService=y,this._coreBrowserService=w,this._themeService=S,this._terminalClass=lR++,this._rowElements=[],this._selectionRenderModel=aR(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Wn),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(Du),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=nR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(E=>this._injectCss(E))),this._injectCss(this._themeService.colors),this._rowFactory=p.createInstance(sm,document),this._element.classList.add(Xf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(E=>this._handleLinkHover(E))),this._register(this._linkifier2.onHideLinkUnderline(E=>this._handleLinkLeave(E))),this._register(Pt(()=>{this._element.classList.remove(Xf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new sR(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Wn} 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} .${Wn} { 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} .${Wn} .xterm-dim { color: ${Ht.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 s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Wn}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Wn}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Wn}.${wo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Wn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Wn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Wn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Wn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Wn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Du} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Du} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Du} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Tu}${c} { color: ${h.css}; }${this._terminalSelector} .${Tu}${c}.xterm-dim { color: ${Ht.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${fS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Tu}257 { color: ${Ht.opaque(e.background).css}; }${this._terminalSelector} .${Tu}257.xterm-dim { color: ${Ht.multiplyOpacity(Ht.opaque(e.background),.5).css}; }${this._terminalSelector} .${fS}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 s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(wo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(wo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,p=this._document.createDocumentFragment();if(s){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=r===c?e[0]:0,f=c===o?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(c,g,f));let b=h-c-1;if(p.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=o===h?t[0]:this._bufferService.cols;p.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(p)}_createSelectionElement(e,t,s,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(s-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${h}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,r=s.ybase+s.y,o=Math.min(s.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+s.ydisp,b=this._rowElements[g],y=s.lines.get(f);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,f,f===r,h,p,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Xf}${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,s,r,o,c){s<0&&(e=0),r<0&&(t=0);let h=this._bufferService.rows-1;s=Math.max(Math.min(s,h),0),r=Math.max(Math.min(r,h),0),o=Math.min(o,this._bufferService.cols);let p=this._bufferService.buffer,g=p.ybase+p.y,f=Math.min(p.x,o-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=s;S<=r;++S){let E=S+p.ydisp,T=this._rowElements[S],B=p.lines.get(E);if(!T||!B)break;T.replaceChildren(...this._rowFactory.createRow(B,E,E===g,y,w,f,b,this.dimensions.css.cell.width,this._widthCache,c?S===s?e:0:-1,c?(S===r?t:o)-1:-1))}}};rm=ti([Me(7,gg),Me(8,Ch),Me(9,an),Me(10,rn),Me(11,Ea),Me(12,qs),Me(13,Tl)],rm);var am=class extends et{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new cR(this._optionsService))}catch{this._measureStrategy=this._register(new oR(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())}};am=ti([Me(2,an)],am);var qw=class extends et{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)}},oR=class extends qw{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},cR=class extends qw{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}},uR=class extends et{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new hR(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Wi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(qe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(qe(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 et{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Sl),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Pt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=qe(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)}},dR=class extends et{constructor(){super(),this.linkProviders=[],this._register(Pt(()=>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 xg(e,t,s){let r=s.getBoundingClientRect(),o=e.getComputedStyle(s),c=parseInt(o.getPropertyValue("padding-left")),h=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-h]}function fR(e,t,s,r,o,c,h,p,g){if(!c)return;let f=xg(e,t,s);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),r+(g?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var lm=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,o){return fR(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let s=xg(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};lm=ti([Me(0,$s),Me(1,Ch)],lm);var pR=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,s){this._rowCount=s,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=[]}},$w={};xT($w,{getSafariVersion:()=>gR,isChromeOS:()=>Gw,isFirefox:()=>Yw,isIpad:()=>_R,isIphone:()=>vR,isLegacyEdge:()=>mR,isLinux:()=>Eg,isMac:()=>ih,isNode:()=>xh,isSafari:()=>Vw,isWindows:()=>Xw});var xh=typeof process<"u"&&"title"in process,dc=xh?"node":navigator.userAgent,fc=xh?"node":navigator.platform,Yw=dc.includes("Firefox"),mR=dc.includes("Edge"),Vw=/^((?!chrome|android).)*safari/i.test(dc);function gR(){if(!Vw)return 0;let e=dc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ih=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(fc),_R=fc==="iPad",vR=fc==="iPhone",Xw=["Windows","Win16","Win32","WinCE"].includes(fc),Eg=fc.indexOf("Linux")>=0,Gw=/\bCrOS\b/.test(dc),Zw=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,s=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),o=e.timeRemaining(),s*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},yR=class extends Zw{_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())}}},bR=class extends Zw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},nh=!xh&&"requestIdleCallback"in window?bR:yR,SR=class{constructor(){this._queue=new nh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},om=class extends et{constructor(e,t,s,r,o,c,h,p,g){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=o,this._coreBrowserService=p,this._renderer=this._register(new Sl),this._pausedResizeTask=new SR,this._observerDisposable=this._register(new Sl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new pR((f,b)=>this._renderRows(f,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new wR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Pt(()=>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 s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Pt(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(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,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};om=ti([Me(2,an),Me(3,Ch),Me(4,Ea),Me(5,hc),Me(6,rn),Me(7,qs),Me(8,Tl)],om);var wR=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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 CR(e,t,s,r){let o=s.buffer.x,c=s.buffer.y;if(!s.buffer.hasScrollback)return kR(o,c,e,t,s,r)+Eh(c,t,s,r)+TR(o,c,e,t,s,r);let h;if(c===t)return h=o>e?"D":"C",ec(Math.abs(o-e),Jo(h,r));h=c>t?"D":"C";let p=Math.abs(c-t),g=ER(c>t?e:o,s)+(p-1)*s.cols+1+xR(c>t?o:e);return ec(g,Jo(h,r))}function xR(e,t){return e-1}function ER(e,t){return t.cols-e}function kR(e,t,s,r,o,c){return Eh(t,r,o,c).length===0?"":ec(Jw(e,t,e,t-Ca(t,o),!1,o).length,Jo("D",c))}function Eh(e,t,s,r){let o=e-Ca(e,s),c=t-Ca(t,s),h=Math.abs(o-c)-DR(e,t,s);return ec(h,Jo(Qw(e,t),r))}function TR(e,t,s,r,o,c){let h;Eh(t,r,o,c).length>0?h=r-Ca(r,o):h=t;let p=r,g=RR(e,t,s,r,o,c);return ec(Jw(e,h,s,p,g==="C",o).length,Jo(g,c))}function DR(e,t,s){let r=0,o=e-Ca(e,s),c=t-Ca(t,s);for(let h=0;h<Math.abs(o-c);h++){let p=Qw(e,t)==="A"?-1:1;s.buffer.lines.get(o+p*h)?.isWrapped&&r++}return r}function Ca(e,t){let s=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)s++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return s}function RR(e,t,s,r,o,c){let h;return Eh(s,r,o,c).length>0?h=r-Ca(r,o):h=t,e<s&&h<=r||e>=s&&h<r?"C":"D"}function Qw(e,t){return e>t?"A":"B"}function Jw(e,t,s,r,o,c){let h=e,p=t,g="";for(;(h!==s||p!==r)&&p>=0&&p<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(p,!1,e,h),h=0,e=0,p++):!o&&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 Jo(e,t){let s=t?"O":"[";return fe.ESC+s+e}function ec(e,t){e=Math.floor(e);let s="";for(let r=0;r<e;r++)s+=t;return s}var MR=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 pS(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 Gf=50,NR=15,AR=50,LR=500,BR=" ",OR=new RegExp(BR,"g"),cm=class extends et{constructor(e,t,s,r,o,c,h,p,g){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=h,this._renderService=p,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Xn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new MR(this._bufferService),this._activeSelectionMode=0,this._register(Pt(()=>{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 s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let p=s.translateBufferLineToString(h,!0,o,c);r.push(p)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let h=s.lines.get(c),p=s.translateBufferLineToString(c,!0);h?.isWrapped?r[r.length-1]+=p:r.push(p)}if(e[1]!==t[1]){let c=s.lines.get(t[1]),h=s.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=h:r.push(h)}}return r.map(o=>o.replace(OR," ")).join(Xw?`\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())),Eg&&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),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=pS(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=xg(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Gf),Gf),t/=Gf,t/Math.abs(t)+Math.round(t*(NR-1)))}shouldForceSelection(e){return ih?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(),AR)}_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&&!(ih&&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 s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let r=s.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<LR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let r=CR(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);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,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:o>1&&t!==r&&(s+=o-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let h=o.translateBufferLineToString(e[1],!1),p=this._convertViewportColToCharacterIndex(c,e[0]),g=p,f=e[0]-p,b=0,y=0,w=0,S=0;if(h.charAt(p)===" "){for(;p>0&&h.charAt(p-1)===" ";)p--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let B=e[0],A=e[0];c.getWidth(B)===0&&(b++,B--),c.getWidth(A)===2&&(y++,A++);let N=c.getString(A).length;for(N>1&&(S+=N-1,g+=N-1);B>0&&p>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,B--):I>1&&(w+=I-1,p-=I-1),p--,B--}for(;A<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(A+1,this._workCell));){c.loadCell(A+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,A++):I>1&&(S+=I-1,g+=I-1),g++,A++}}g++;let E=p+f-b+w,T=Math.min(this._bufferService.cols,g-p+b+y-w-S);if(!(!t&&h.slice(p,g).trim()==="")){if(s&&E===0&&c.getCodePoint(0)!==32){let B=o.lines.get(e[1]-1);if(B&&c.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let N=this._bufferService.cols-A.start;E-=N,T+=N}}}if(r&&E+T===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let B=o.lines.get(e[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(T+=A.length)}}return{start:E,length:T}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=pS(s,this._bufferService.cols)}};cm=ti([Me(3,rn),Me(4,Ea),Me(5,_g),Me(6,an),Me(7,$s),Me(8,qs)],cm);var mS=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},gS=class{constructor(){this._color=new mS,this._css=new mS}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},wi=Object.freeze((()=>{let e=[qt.toColor("#2e3436"),qt.toColor("#cc0000"),qt.toColor("#4e9a06"),qt.toColor("#c4a000"),qt.toColor("#3465a4"),qt.toColor("#75507b"),qt.toColor("#06989a"),qt.toColor("#d3d7cf"),qt.toColor("#555753"),qt.toColor("#ef2929"),qt.toColor("#8ae234"),qt.toColor("#fce94f"),qt.toColor("#729fcf"),qt.toColor("#ad7fa8"),qt.toColor("#34e2e2"),qt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],o=t[s/6%6|0],c=t[s%6];e.push({css:mi.toCss(r,o,c),rgba:mi.toRgba(r,o,c)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:mi.toCss(r,r,r),rgba:mi.toRgba(r,r,r)})}return e})()),da=qt.toColor("#ffffff"),Lo=qt.toColor("#000000"),_S=qt.toColor("#ffffff"),vS=Lo,Co={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},zR=da,um=class extends et{constructor(e){super(),this._optionsService=e,this._contrastCache=new gS,this._halfContrastCache=new gS,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:da,background:Lo,cursor:_S,cursorAccent:vS,selectionForeground:void 0,selectionBackgroundTransparent:Co,selectionBackgroundOpaque:Ht.blend(Lo,Co),selectionInactiveBackgroundTransparent:Co,selectionInactiveBackgroundOpaque:Ht.blend(Lo,Co),scrollbarSliderBackground:Ht.opacity(da,.2),scrollbarSliderHoverBackground:Ht.opacity(da,.4),scrollbarSliderActiveBackground:Ht.opacity(da,.5),overviewRulerBorder:da,ansi:wi.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=xt(e.foreground,da),t.background=xt(e.background,Lo),t.cursor=Ht.blend(t.background,xt(e.cursor,_S)),t.cursorAccent=Ht.blend(t.background,xt(e.cursorAccent,vS)),t.selectionBackgroundTransparent=xt(e.selectionBackground,Co),t.selectionBackgroundOpaque=Ht.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=xt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ht.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?xt(e.selectionForeground,hS):void 0,t.selectionForeground===hS&&(t.selectionForeground=void 0),Ht.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ht.opacity(t.selectionBackgroundTransparent,.3)),Ht.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ht.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=xt(e.scrollbarSliderBackground,Ht.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=xt(e.scrollbarSliderHoverBackground,Ht.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=xt(e.scrollbarSliderActiveBackground,Ht.opacity(t.foreground,.5)),t.overviewRulerBorder=xt(e.overviewRulerBorder,zR),t.ansi=wi.slice(),t.ansi[0]=xt(e.black,wi[0]),t.ansi[1]=xt(e.red,wi[1]),t.ansi[2]=xt(e.green,wi[2]),t.ansi[3]=xt(e.yellow,wi[3]),t.ansi[4]=xt(e.blue,wi[4]),t.ansi[5]=xt(e.magenta,wi[5]),t.ansi[6]=xt(e.cyan,wi[6]),t.ansi[7]=xt(e.white,wi[7]),t.ansi[8]=xt(e.brightBlack,wi[8]),t.ansi[9]=xt(e.brightRed,wi[9]),t.ansi[10]=xt(e.brightGreen,wi[10]),t.ansi[11]=xt(e.brightYellow,wi[11]),t.ansi[12]=xt(e.brightBlue,wi[12]),t.ansi[13]=xt(e.brightMagenta,wi[13]),t.ansi[14]=xt(e.brightCyan,wi[14]),t.ansi[15]=xt(e.brightWhite,wi[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)t.ansi[r+16]=xt(e.extendedAnsi[r],wi[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};um=ti([Me(0,an)],um);function xt(e,t){if(e!==void 0)try{return qt.toColor(e)}catch{}return t}var jR=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},HR=class{constructor(){this._services=new jR,this._services.set(gg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=NT(e).sort((c,h)=>c.index-h.index),r=[];for(let c of s){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(h)}let o=s.length>0?s[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},UR={trace:0,debug:1,info:2,warn:3,error:4,off:5},PR="xterm.js: ",hm=class extends et{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=UR[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,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":PR)+t,...s)}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=ti([Me(0,an)],hm);var yS=class extends et{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];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,...s){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let o=t-1;o>=0;o--)this.set(e+o+s,this.get(e+o));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Je=3,pi=Object.freeze(new uc),Ru=0,Zf=2,Bo=class e1{constructor(t,s,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Je);let o=s||Xn.fromCharData([0,yw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let s=this._data[t*Je+0],r=s&2097151;return[this._data[t*Je+1],s&2097152?this._combined[t]:r?Rr(r):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*Je+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*Je+0]=t|2097152|s[2]<<22):this._data[t*Je+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*Je+0]>>22}hasWidth(t){return this._data[t*Je+0]&12582912}getFg(t){return this._data[t*Je+1]}getBg(t){return this._data[t*Je+2]}hasContent(t){return this._data[t*Je+0]&4194303}getCodePoint(t){let s=this._data[t*Je+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*Je+0]&2097152}getString(t){let s=this._data[t*Je+0];return s&2097152?this._combined[t]:s&2097151?Rr(s&2097151):""}isProtected(t){return this._data[t*Je+2]&536870912}loadCell(t,s){return Ru=t*Je,s.content=this._data[Ru+0],s.fg=this._data[Ru+1],s.bg=this._data[Ru+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*Je+0]=s.content,this._data[t*Je+1]=s.fg,this._data[t*Je+2]=s.bg}setCellFromCodepoint(t,s,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Je+0]=s|r<<22,this._data[t*Je+1]=o.fg,this._data[t*Je+2]=o.bg}addCodepointToCell(t,s,r){let o=this._data[t*Je+0];o&2097152?this._combined[t]+=Rr(s):o&2097151?(this._combined[t]=Rr(o&2097151)+Rr(s),o&=-2097152,o|=2097152):o=s|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*Je+0]=o}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length-t){let o=new Xn;for(let c=this.length-t-s-1;c>=0;--c)this.setCell(t+s+c,this.loadCell(t+c,o));for(let c=0;c<s;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,s,r){if(t%=this.length,s<this.length-t){let o=new Xn;for(let c=0;c<this.length-t-s;++c)this.setCell(t+c,this.loadCell(t+s+c,o));for(let c=this.length-s;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,s,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,r);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,r);t<s&&t<this.length;)this.setCell(t++,r)}resize(t,s){if(t===this.length)return this._data.length*4*Zf<this._data.buffer.byteLength;let r=t*Je;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,s)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let h=0;h<o.length;h++){let p=parseInt(o[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,r*4*Zf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Zf<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new e1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303)return t+(this._data[t*Je+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Je+0]&4194303||this._data[t*Je+2]&50331648)return t+(this._data[t*Je+0]>>22);return 0}copyCellsFrom(t,s,r,o,c){let h=t._data;if(c)for(let g=o-1;g>=0;g--){for(let f=0;f<Je;f++)this._data[(r+g)*Je+f]=h[(s+g)*Je+f];h[(s+g)*Je+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}else for(let g=0;g<o;g++){for(let f=0;f<Je;f++)this._data[(r+g)*Je+f]=h[(s+g)*Je+f];h[(s+g)*Je+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}let p=Object.keys(t._combined);for(let g=0;g<p.length;g++){let f=parseInt(p[g],10);f>=s&&(this._combined[f-s+r]=t._combined[f])}}translateToString(t,s,r,o){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;s<r;){let h=this._data[s*Je+0],p=h&2097151,g=h&2097152?this._combined[s]:p?Rr(p):Nr;if(c+=g,o)for(let f=0;f<g.length;++f)o.push(s);s+=h>>22||1}return o&&o.push(s),c}};function IR(e,t,s,r,o,c){let h=[];for(let p=0;p<e.length-1;p++){let g=p,f=e.get(++g);if(!f.isWrapped)continue;let b=[e.get(p)];for(;g<e.length&&f.isWrapped;)b.push(f),f=e.get(++g);if(!c&&r>=p&&r<g){p+=b.length-1;continue}let y=0,w=tc(b,y,t),S=1,E=0;for(;S<b.length;){let B=tc(b,S,t),A=B-E,N=s-w,I=Math.min(A,N);b[y].copyCellsFrom(b[S],E,w,I,!1),w+=I,w===s&&(y++,w=0),E+=I,E===B&&(S++,E=0),w===0&&y!==0&&b[y-1].getWidth(s-1)===2&&(b[y].copyCellsFrom(b[y-1],s-1,w++,1,!1),b[y-1].setCell(s-1,o))}b[y].replaceCells(w,s,o);let T=0;for(let B=b.length-1;B>0&&(B>y||b[B].getTrimmedLength()===0);B--)T++;T>0&&(h.push(p+b.length-T),h.push(T)),p+=b.length-1}return h}function KR(e,t){let s=[],r=0,o=t[r],c=0;for(let h=0;h<e.length;h++)if(o===h){let p=t[++r];e.onDeleteEmitter.fire({index:h-c,amount:p}),h+=p-1,c+=p,o=t[++r]}else s.push(h);return{layout:s,countRemoved:c}}function FR(e,t){let s=[];for(let r=0;r<t.length;r++)s.push(e.get(t[r]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=t.length}function WR(e,t,s){let r=[],o=e.map((g,f)=>tc(e,f,t)).reduce((g,f)=>g+f),c=0,h=0,p=0;for(;p<o;){if(o-p<s){r.push(o-p);break}c+=s;let g=tc(e,h,t);c>g&&(c-=g,h++);let f=e[h].getWidth(c-1)===2;f&&c--;let b=f?s-1:s;r.push(b),p+=b}return r}function tc(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?s-1:s}var t1=class i1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=i1._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),wa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};t1._nextId=1;var qR=t1,ki={},fa=ki.B;ki[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ki.A={"#":"£"};ki.B=void 0;ki[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ki.C=ki[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ki.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ki.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ki.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ki.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ki.E=ki[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ki.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ki.H=ki[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ki["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var bS=4294967295,SS=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=pi.clone(),this.savedCharset=fa,this.markers=[],this._nullCell=Xn.fromCharData([0,yw,1,0]),this._whitespaceCell=Xn.fromCharData([0,Nr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new nh,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 Ju),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 Ju),this._whitespaceCell}getBlankLine(e,t){return new Bo(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>bS?bS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=pi);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 s=this.getNullCell(pi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)r+=+this.lines.get(h).resize(e,s);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 Bo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new Bo(e,s)));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(o<this.lines.maxLength){let h=this.lines.length-o;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=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,r=IR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(pi),s);if(r.length>0){let o=KR(this.lines,r);FR(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(pi),o=s;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Bo(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(pi),o=[],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(!s){let I=this.ybase+this.y;if(I>=h&&I<h+g.length)continue}let f=g[g.length-1].getTrimmedLength(),b=WR(g,this._cols,e),y=b.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+y):w=Math.max(0,this.lines.length-this.lines.maxLength+y);let S=[];for(let I=0;I<y;I++){let P=this.getBlankLine(pi,!0);S.push(P)}S.length>0&&(o.push({start:h+g.length+c,newLines:S}),c+=S.length),g.push(...S);let E=b.length-1,T=b[E];T===0&&(E--,T=b[E]);let B=g.length-y-1,A=f;for(;B>=0;){let I=Math.min(A,T);if(g[E]===void 0)break;if(g[E].copyCellsFrom(g[B],A-I,T-I,I,!0),T-=I,T===0&&(E--,T=b[E]),A-=I,A===0){B--;let P=Math.max(B,0);A=tc(g,P,this._cols)}}for(let I=0;I<g.length;I++)b[I]<e&&g[I].setCell(b[I],r);let N=y-w;for(;N-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+y,this.ybase+t-1)}if(o.length>0){let h=[],p=[];for(let T=0;T<this.lines.length;T++)p.push(this.lines.get(T));let g=this.lines.length,f=g-1,b=0,y=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(y&&y.start>f+w){for(let B=y.newLines.length-1;B>=0;B--)this.lines.set(T--,y.newLines[B]);T++,h.push({index:f+1,amount:y.newLines.length}),w+=y.newLines.length,y=o[++b]}else this.lines.set(T,p[f--]);let S=0;for(let T=h.length-1;T>=0;T--)h[T].index+=S,this.lines.onInsertEmitter.fire(h[T]),S+=h[T].amount;let E=Math.max(0,g+c-this.lines.maxLength);E>0&&this.lines.onTrimEmitter.fire(E)}}translateBufferLineToString(e,t,s=0,r){let o=this.lines.get(e);return o?o.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}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 qR(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},$R=class extends et{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new SS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new SS(!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)}},n1=2,s1=1,dm=class extends et{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,n1),this.rows=Math.max(e.rawOptions.rows||0,s1),this.buffers=this._register(new $R(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=s.ybase+s.scrollTop,c=s.ybase+s.scrollBottom;if(s.scrollTop===0){let h=s.lines.isFull;c===s.lines.length-1?h?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(c+1,0,r.clone()),h?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let h=c-o+1;s.lines.shiftElements(o+1,h-1,-1),s.lines.set(c,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};dm=ti([Me(0,an)],dm);var ul={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:ih,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},YR=["normal","bold","100","200","300","400","500","600","700","800","900"],VR=class extends et{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...ul};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Pt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in ul))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in ul))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=ul[e]),!XR(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=ul[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=YR.includes(t)?t:ul[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 XR(e){return e==="block"||e==="underline"||e==="bar"}function Oo(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&Oo(e[r],t-1);return s}var wS=Object.freeze({insertMode:!1}),CS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fm=class extends et{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Oo(wS),this.decPrivateModes=Oo(CS)}reset(){this.modes=Oo(wS),this.decPrivateModes=Oo(CS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};fm=ti([Me(0,rn),Me(1,xw),Me(2,an)],fm);var xS={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 Qf(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Jf=String.fromCharCode,ES={DEFAULT:e=>{let t=[Qf(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Jf(t[0])}${Jf(t[1])}${Jf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Qf(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Qf(e,!0)};${e.x};${e.y}${t}`}},pm=class extends et{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(xS))this.addProtocol(r,xS[r]);for(let r of Object.keys(ES))this.addEncoding(r,ES[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){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)}};pm=ti([Me(0,rn),Me(1,Ea),Me(2,an)],pm);var ep=[[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]],GR=[[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]],Ci;function ZR(e,t){let s=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(o=s+r>>1,e>t[o][1])s=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var QR=class{constructor(){if(this.version="6",!Ci){Ci=new Uint8Array(65536),Ci.fill(1),Ci[0]=0,Ci.fill(0,1,32),Ci.fill(0,127,160),Ci.fill(2,4352,4448),Ci[9001]=2,Ci[9002]=2,Ci.fill(2,11904,42192),Ci[12351]=1,Ci.fill(2,44032,55204),Ci.fill(2,63744,64256),Ci.fill(2,65040,65050),Ci.fill(2,65072,65136),Ci.fill(2,65280,65377),Ci.fill(2,65504,65511);for(let e=0;e<ep.length;++e)Ci.fill(0,ep[e][0],ep[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ci[e]:ZR(e,GR)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let o=ga.extractWidth(t);o===0?r=!1:o>s&&(s=o)}return ga.createPropertyValue(0,s,r)}},ga=class Pu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new QR;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,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,r=0,o=t.length;for(let c=0;c<o;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=o)return s+this.wcwidth(h);let f=t.charCodeAt(c);56320<=f&&f<=57343?h=(h-55296)*1024+f-56320+65536:s+=this.wcwidth(f)}let p=this.charProperties(h,r),g=Pu.extractWidth(p);Pu.extractShouldJoin(p)&&(g-=Pu.extractWidth(r)),s+=g,r=p}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},JR=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 kS(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var xo=2147483647,eM=256,r1=class mm{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>eM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new mm;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)s.addSubParam(o[c]);else s.addParam(o)}return s}clone(){let t=new mm(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 s=0;s<this.length;++s){t.push(this.params[s]);let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>xo?xo: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>xo?xo:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&255;o-r>0&&(t[s]=this._subParams.slice(r,o))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[s-1];r[s-1]=~o?Math.min(o*10+t,xo):t}},Eo=[],tM=class{constructor(){this._state=0,this._active=Eo,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Eo}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=Eo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Eo,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",wh(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&s-t>0&&this._put(e,t,s)}}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 s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Eo,this._id=-1,this._state=0}}},Rn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wh(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},ko=[],iM=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 s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=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 s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",wh(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=ko,this._ident=0}},zo=new r1;zo.addParam(0);var TS=class{constructor(e){this._handler=e,this._data="",this._params=zo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():zo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wh(e,t,s),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(s=>(this._params=zo,this._data="",this._hitLimit=!1,s));return this._params=zo,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,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=s<<4|r}},Yn=160,sM=(function(){let e=new nM(4095),t=Array.apply(null,Array(256)).map((p,g)=>g),s=(p,g)=>t.slice(p,g),r=s(32,127),o=s(0,24);o.push(25),o.push.apply(o,s(28,32));let c=s(0,14),h;e.setDefault(1,0),e.addMany(r,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(s(128,144),h,3,0),e.addMany(s(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(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Yn,0,2,0),e.add(Yn,8,5,8),e.add(Yn,6,0,6),e.add(Yn,11,0,11),e.add(Yn,13,13,13),e})(),rM=class extends et{constructor(e=sM){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 r1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(Pt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new tM),this._dcsParser=this._register(new iM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,s){let r=0,o=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===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(s===!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(s===!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(r=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(r!==24&&r!==26,s),h)return h;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],h=this._oscParser.end(r!==24&&r!==26,s),h)return h;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let p=c;p<t;++p){switch(r=e[p],o=this._transitions.table[this.currentState<<8|(r<160?r:Yn)],o>>4){case 2:for(let w=p+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<Yn){this._printHandler(e,p,w),p=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Yn){this._printHandler(e,p,w),p=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Yn){this._printHandler(e,p,w),p=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Yn){this._printHandler(e,p,w),p=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:p,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],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,o,p),h;f<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++p<t&&(r=e[p])>47&&r<60);p--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let b=this._escHandlers[this._collect<<8|r],y=b?b.length-1:-1;for(;y>=0&&(h=b[y](),h!==!0);y--)if(h instanceof Promise)return this._preserveStack(4,b,y,o,p),h;y<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let w=p+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<Yn){this._dcsParser.put(e,p,w),p=w-1;break}break;case 14:if(h=this._dcsParser.unhook(r!==24&&r!==26),h)return this._preserveStack(6,[],0,o,p),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=p+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<Yn){this._oscParser.put(e,p,w),p=w-1;break}break;case 6:if(h=this._oscParser.end(r!==24&&r!==26),h)return this._preserveStack(5,[],0,o,p),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},aM=/^([\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})$/,lM=/^[\da-f]+$/;function DS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=aM.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),lM.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(s*o,s*o+s),16);r[o]=s===1?c<<4:s===2?c:s===3?c>>4:c>>8}return r}}function tp(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function oM(e,t=16){let[s,r,o]=e;return`rgb:${tp(s,t)}/${tp(r,t)}/${tp(o,t)}`}var cM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},xr=131072,RS=10;function MS(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 NS=5e3,AS=0,uM=class extends et{constructor(e,t,s,r,o,c,h,p,g=new rM){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=p,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new RT,this._utf8Decoder=new MT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=pi.clone(),this._eraseAttrDataInternal=pi.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new gm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:b.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:b,data:y})}),this._parser.setDcsHandlerFallback((f,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:b,payload:y})}),this._parser.setPrintHandler((f,b,y)=>this.print(f,b,y)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(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(Hu.IND,()=>this.index()),this._parser.setExecuteHandler(Hu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Hu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Rn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Rn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Rn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Rn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Rn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Rn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Rn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Rn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Rn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Rn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Rn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Rn(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 ki)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 TS((f,b)=>this.requestStatusString(f,b)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),NS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${NS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>xr&&(c=this._parseStack.position+xr)}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<xr&&(this._parseBuffer=new Uint32Array(Math.min(e.length,xr))),h||this._dirtyRowTracker.clearRange(),e.length>xr)for(let f=c;f<e.length;f+=xr){let b=f+xr<e.length?f+xr:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(f,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,b),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,y))return this._preserveStack(r,o,y,f),this._logSlowResolvingAsync(s),s}else if(!h){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,f))return this._preserveStack(r,o,f,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&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,s){let r,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,p=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,b=this._curAttrData,y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&y.getWidth(this._activeBuffer.x-1)===2&&y.setCellFromCodepoint(this._activeBuffer.x-1,0,1,b);let w=this._parser.precedingJoinState;for(let S=t;S<s;++S){if(r=e[S],r<127&&c){let A=c[String.fromCharCode(r)];A&&(r=A.charCodeAt(0))}let E=this._unicodeService.charProperties(r,w);o=ga.extractWidth(E);let T=ga.extractShouldJoin(E),B=T?ga.extractWidth(w):0;if(w=E,h&&this._onA11yChar.fire(Rr(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>p){if(g){let A=y,N=this._activeBuffer.x-B;for(this._activeBuffer.x=B,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),y=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),B>0&&y instanceof Bo&&y.copyCellsFrom(A,N,0,B,!1);N<p;)A.setCellFromCodepoint(N++,0,1,b)}else if(this._activeBuffer.x=p-1,o===2)continue}if(T&&this._activeBuffer.x){let A=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-A,r,o);for(let N=o-B;--N>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(f&&(y.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(b)),y.getWidth(p-1)===2&&y.setCellFromCodepoint(p-1,0,1,b)),y.setCellFromCodepoint(this._activeBuffer.x++,r,o,b),o>0)for(;--o;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b)}this._parser.precedingJoinState=w,this._activeBuffer.x<p&&s-t>0&&y.getWidth(this._activeBuffer.x)===0&&!y.hasContent(this._activeBuffer.x)&&y.setCellFromCodepoint(this._activeBuffer.x,0,1,b),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>MS(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new TS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Rn(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,s,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(s,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 s=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(pi));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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,r=ga.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),h=new Uint32Array(c.length*s),p=0;for(let f=0;f<c.length;){let b=c.codePointAt(f)||0;h[p++]=b,f+=b>65535?2:1}let g=p;for(let f=1;f<s;++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,fa),this._charsetService.setgCharset(1,fa),this._charsetService.setgCharset(2,fa),this._charsetService.setgCharset(3,fa);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 s;(T=>(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:p,cols:g}=this._bufferService,{active:f,alt:b}=p,y=this._optionsService.rawOptions,w=(T,B)=>(h.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${T};${B}$y`),!0),S=T=>T?1:2,E=e.params[0];return t?E===2?w(E,4):E===4?w(E,S(h.modes.insertMode)):E===12?w(E,3):E===20?w(E,S(y.convertEol)):w(E,0):E===1?w(E,S(r.applicationCursorKeys)):E===3?w(E,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):E===6?w(E,S(r.origin)):E===7?w(E,S(r.wraparound)):E===8?w(E,3):E===9?w(E,S(o==="X10")):E===12?w(E,S(y.cursorBlink)):E===25?w(E,S(!h.isCursorHidden)):E===45?w(E,S(r.reverseWraparound)):E===66?w(E,S(r.applicationKeypad)):E===67?w(E,4):E===1e3?w(E,S(o==="VT200")):E===1002?w(E,S(o==="DRAG")):E===1003?w(E,S(o==="ANY")):E===1004?w(E,S(r.sendFocus)):E===1005?w(E,4):E===1006?w(E,S(c==="SGR")):E===1015?w(E,4):E===1016?w(E,S(c==="SGR_PIXELS")):E===1048?w(E,1):E===47||E===1047||E===1049?w(E,S(f===b)):E===2004?w(E,S(r.bracketedPasteMode)):E===2026?w(E,S(r.synchronizedOutput)):w(E,0)}_updateAttrColor(e,t,s,r,o){return t===2?(e|=50331648,e&=-16777216,e|=uc.fromColorRGB([s,r,o])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),p=0;do r[1]===5&&(o=1),r[c+p+1+o]=h[p];while(++p<h.length&&p+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let h=2;h<r.length;++h)r[h]===-1&&(r[h]=0);switch(r[0]){case 38:s.fg=this._updateAttrColor(s.fg,r[1],r[3],r[4],r[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,r[1],r[3],r[4],r[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=pi.fg,e.bg=pi.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,s,r=this._curAttrData;for(let o=0;o<t;o++)s=e.params[o],s>=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=pi.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=pi.bg&16777215):s===38||s===48||s===58?o+=this._extractColor(e,o,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=pi.fg&16777215,r.bg&=-67108864,r.bg|=pi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);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,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[?${t};${s}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=pi.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!MS(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>RS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>RS&&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=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),o=s.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(LS(c))if(o==="?")t.push({type:0,index:c});else{let h=DS(o);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 s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,o=s.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=s[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let r=0;r<s.length&&!(t>=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=DS(s[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let r=0;r<s.length;++r)if(/^\d+$/.exec(s[r])){let o=parseInt(s[r]);LS(o)&&t.push({type:2,index:o})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,fa),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(cM[e[0]],ki[e[1]]||fa),!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=pi.clone(),this._eraseAttrDataInternal=pi.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 Xn;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 s=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(s);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=h=>(this._coreService.triggerDataEvent(`${fe.ESC}${h}${fe.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},gm=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&&(AS=e,e=t,t=AS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gm=ti([Me(0,rn)],gm);function LS(e){return 0<=e&&e<256}var hM=5e7,BS=12,dM=50,fM=class extends et{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let h=p=>performance.now()-s>=BS?setTimeout(()=>this._innerWrite(0,p)):this._innerWrite(s,p);o.catch(p=>(queueMicrotask(()=>{throw p}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=BS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>dM&&(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()}},_m=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 s=e,r=this._getEntryIdKey(s),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(s),data:s,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 s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};_m=ti([Me(0,rn)],_m);var OS=!1,pM=class extends et{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Sl),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new HR,this.optionsService=this._register(new VR(e)),this._instantiationService.setService(an,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(dm)),this._instantiationService.setService(rn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(hm)),this._instantiationService.setService(xw,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fm)),this._instantiationService.setService(Ea,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(pm)),this._instantiationService.setService(Cw,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ga)),this._instantiationService.setService(BT,this.unicodeService),this._charsetService=this._instantiationService.createInstance(JR),this._instantiationService.setService(LT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_m),this._instantiationService.setService(Ew,this._oscLinkService),this._inputHandler=this._register(new uM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Wi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Wi.forward(this._bufferService.onResize,this._onResize)),this._register(Wi.forward(this.coreService.onData,this._onData)),this._register(Wi.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 fM((t,s)=>this._inputHandler.parse(t,s))),this._register(Wi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!OS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),OS=!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,n1),t=Math.max(t,s1),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(kS.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(kS(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Pt(()=>{for(let t of e)t.dispose()})}}},mM={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 gM(e,t,s,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=fe.ESC+"OA":o.key=fe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":fe.DEL,e.altKey&&(o.key=fe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=fe.ESC+"[Z";break}o.key=fe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?fe.ESC+fe.CR:fe.CR,o.cancel=!0;break;case 27:o.key=fe.ESC,e.altKey&&(o.key=fe.ESC+fe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=fe.ESC+"[1;"+(c+1)+"D":t?o.key=fe.ESC+"OD":o.key=fe.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=fe.ESC+"[1;"+(c+1)+"C":t?o.key=fe.ESC+"OC":o.key=fe.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=fe.ESC+"[1;"+(c+1)+"A":t?o.key=fe.ESC+"OA":o.key=fe.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=fe.ESC+"[1;"+(c+1)+"B":t?o.key=fe.ESC+"OB":o.key=fe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=fe.ESC+"[2~");break;case 46:c?o.key=fe.ESC+"[3;"+(c+1)+"~":o.key=fe.ESC+"[3~";break;case 36:c?o.key=fe.ESC+"[1;"+(c+1)+"H":t?o.key=fe.ESC+"OH":o.key=fe.ESC+"[H";break;case 35:c?o.key=fe.ESC+"[1;"+(c+1)+"F":t?o.key=fe.ESC+"OF":o.key=fe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=fe.ESC+"[5;"+(c+1)+"~":o.key=fe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=fe.ESC+"[6;"+(c+1)+"~":o.key=fe.ESC+"[6~";break;case 112:c?o.key=fe.ESC+"[1;"+(c+1)+"P":o.key=fe.ESC+"OP";break;case 113:c?o.key=fe.ESC+"[1;"+(c+1)+"Q":o.key=fe.ESC+"OQ";break;case 114:c?o.key=fe.ESC+"[1;"+(c+1)+"R":o.key=fe.ESC+"OR";break;case 115:c?o.key=fe.ESC+"[1;"+(c+1)+"S":o.key=fe.ESC+"OS";break;case 116:c?o.key=fe.ESC+"[15;"+(c+1)+"~":o.key=fe.ESC+"[15~";break;case 117:c?o.key=fe.ESC+"[17;"+(c+1)+"~":o.key=fe.ESC+"[17~";break;case 118:c?o.key=fe.ESC+"[18;"+(c+1)+"~":o.key=fe.ESC+"[18~";break;case 119:c?o.key=fe.ESC+"[19;"+(c+1)+"~":o.key=fe.ESC+"[19~";break;case 120:c?o.key=fe.ESC+"[20;"+(c+1)+"~":o.key=fe.ESC+"[20~";break;case 121:c?o.key=fe.ESC+"[21;"+(c+1)+"~":o.key=fe.ESC+"[21~";break;case 122:c?o.key=fe.ESC+"[23;"+(c+1)+"~":o.key=fe.ESC+"[23~";break;case 123:c?o.key=fe.ESC+"[24;"+(c+1)+"~":o.key=fe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=fe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=fe.DEL:e.keyCode===219?o.key=fe.ESC:e.keyCode===220?o.key=fe.FS:e.keyCode===221&&(o.key=fe.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let h=mM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.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()),o.key=fe.ESC+g}else if(e.keyCode===32)o.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()),o.key=fe.ESC+p,o.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=fe.US),e.key==="@"&&(o.key=fe.NUL));break}return o}var li=0,_M=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new nh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new nh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[o]=e[t],t++):r[o]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(li=this._search(t),li===-1)||this._getKey(this._array[li])!==t)return!1;do if(this._array[li]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(li),!0;while(++li<this._array.length&&this._getKey(this._array[li])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,s=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:s[r++]=this._array[o];this._array=s,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&&(li=this._search(e),!(li<0||li>=this._array.length)&&this._getKey(this._array[li])===e))do yield this._array[li];while(++li<this._array.length&&this._getKey(this._array[li])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(li=this._search(e),!(li<0||li>=this._array.length)&&this._getKey(this._array[li])===e))do t(this._array[li]);while(++li<this._array.length&&this._getKey(this._array[li])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let r=t+s>>1,o=this._getKey(this._array[r]);if(o>e)s=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},ip=0,zS=0,vM=class extends et{constructor(){super(),this._decorations=new _M(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Pt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new yM(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!s||(c.options.layer??"bottom")===s)&&(yield c)}forEachDecorationAtCell(e,t,s,r){this._decorations.forEachByKey(t,o=>{ip=o.options.x??0,zS=ip+(o.options.width??1),e>=ip&&e<zS&&(!s||(o.options.layer??"bottom")===s)&&r(o)})}},yM=class extends Lr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=qt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=qt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},bM=1e3,SM=class{constructor(e,t=bM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},jS=20,sh=class extends et{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new SM(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(qe(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Pt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<jS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===jS+1&&(this._liveRegion.textContent+=jp.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 s=this._terminal.buffer,r=s.lines.length.toString();for(let o=e;o<=t;o++){let c=s.lines.get(s.ydisp+o),h=[],p=c?.translateToString(!0,void 0,void 0,h)||"",g=(s.ydisp+o+1).toString(),f=this._rowElements[o];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",r),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=s.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let h,p;if(t===0?(h=s,p=this._rowElements.pop(),this._rowContainer.removeChild(p)):(h=this._rowElements.shift(),p=s,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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let o=({node:p,offset:g})=>{let f=p instanceof Text?p.parentNode:p,b=parseInt(f?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(f);if(!y)return console.warn("columns is null. Race condition?"),null;let w=g<y.length?y[g]:y.slice(-1)[0]+1;return w>=this._terminal.cols&&(++b,w=0),{row:b,column:w}},c=o(t),h=o(s);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,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};sh=ti([Me(1,gg),Me(2,qs),Me(3,$s)],sh);var vm=class extends et{constructor(e,t,s,r,o){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Pt(()=>{wa(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(qe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(qe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(qe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(qe(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 s=e.composedPath();for(let r=0;r<s.length;r++){let o=s[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(p=>({link:p}));this._activeProviderReplies?.set(r,h),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let h=o[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(s.has(f)){o.splice(c--,1);break}s.add(f)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(h=>this._linkAtPosition(h.link,t));c&&(s=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(p=>this._linkAtPosition(p.link,t));if(h){s=!0,this._handleNewLink(h);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&wM(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,wa(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:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,s){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(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,s){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(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return s<=o&&o<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,o){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:o}}};vm=ti([Me(1,_g),Me(2,$s),Me(3,rn),Me(4,Tw)],vm);function wM(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 CM=class extends pM{constructor(e={}){super(e),this._linkifier=this._register(new Sl),this.browser=$w,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Sl),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(vM),this._instantiationService.setService(hc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(dR),this._instantiationService.setService(Tw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Up)),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(Wi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Wi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Wi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Wi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Pt(()=>{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 s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let o=Ht.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${fe.ESC}]${r};${oM(o)}${Ww.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=mi.toColor(...t.color));else{let c=s;this._themeService.modifyColors(h=>h[c]=mi.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(sh,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 s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(s),c=this._renderService.dimensions.css.cell.width*o,h=this.buffer.y*this._renderService.dimensions.css.cell.height,p=s*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=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(qe(this.element,"copy",t=>{this.hasSelection()&&TT(t,this._selectionService)}));let e=t=>DT(t,this.textarea,this.coreService,this.optionsService);this._register(qe(this.textarea,"paste",e)),this._register(qe(this.element,"paste",e)),Yw?this._register(qe(this.element,"mousedown",t=>{t.button===2&&Yb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(qe(this.element,"contextmenu",t=>{Yb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Eg&&this._register(qe(this.element,"auxclick",t=>{t.button===1&&vw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(qe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(qe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(qe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(qe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(qe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(qe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(qe(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(qe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",zp.get()),Gw||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(uR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(qs,this._coreBrowserService),this._register(qe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(qe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(am,this._document,this._helperContainer),this._instantiationService.setService(Ch,this._charSizeService),this._themeService=this._instantiationService.createInstance(um),this._instantiationService.setService(Tl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(th),this._instantiationService.setService(kw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(om,this.rows,this.screenElement)),this._instantiationService.setService($s,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(nm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lm),this._instantiationService.setService(_g,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(vm,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(tm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(cm,this.element,this.screenElement,r)),this._instantiationService.setService(zT,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Wi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(im,this.screenElement)),this._register(qe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(sh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(eh,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(eh,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(rm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(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 r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(qe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(qe(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let 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){_w(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,s){this._selectionService.setSelection(e,t,s)}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 s=gM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===fe.ETX||s.key===fe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(xM(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(pi));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),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[4;${s};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function xM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var EM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;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)}},kM=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 Xn)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},HS=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 kM(t)}getNullCell(){return new Xn}},TM=class extends et{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new HS(this._core.buffers.normal,"normal"),this._alternate=new HS(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)}},DM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},RM=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}},MM=["cols","rows"],ms=0,NM=class extends et{constructor(e){super(),this._core=this._register(new CM(e)),this._addonManager=this._register(new EM),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(MM.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 DM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new RM(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 TM(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 zp.get()},set promptLabel(e){zp.set(e)},get tooMuchOutput(){return jp.get()},set tooMuchOutput(e){jp.set(e)}}}_verifyIntegers(...e){for(ms of e)if(ms===1/0||isNaN(ms)||ms%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ms of e)if(ms&&(ms===1/0||isNaN(ms)||ms%1!==0||ms<0))throw new Error("This API only accepts positive integers")}};class AM{pending=null;accept(t){let s="";for(const r of t)s+=this.acceptChar(r);return s}acceptChar(t){return t===""?this.acceptBackspace():c1.has(t)?this.acceptConsonant(t):u1.has(t)?this.acceptVowel(t):zM(t)&&this.canReplacePendingWith(t)?(this.pending=PS(t),""):this.flushPending()+t}acceptConsonant(t){if(!this.pending)return this.pending={initial:t},"";if(!this.pending.vowel){const o=this.flushPending();return this.pending={initial:t},o}if(!this.pending.final){if(h1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const s=OM.get(`${this.pending.final}${t}`);if(s)return this.pending.final=s,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=BM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const s=US.get(this.pending.final);if(s){this.pending.final=s[0];const c=this.flushPending();return this.pending={initial:s[1],vowel:t},c}const r=this.pending.final,o=IS({initial:this.pending.initial,vowel:this.pending.vowel});return this.pending={initial:r,vowel:t},o}acceptBackspace(){if(!this.pending)return"";if(this.pending.final){const t=US.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 s=PS(t);return s.initial===this.pending.initial&&(!this.pending.vowel||s.vowel===this.pending.vowel)&&(!this.pending.final||s.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=IS(this.pending);return this.pending=null,t}}const rh=44032,ah=21,fl=28,LM=19*ah*fl,a1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],l1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],o1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],c1=kg(a1),u1=kg(l1),h1=kg(o1),BM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),d1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],OM=new Map(d1),US=new Map(d1.map(([e,t])=>[t,[e[0],e[1]]]));function kg(e){return new Map(e.map((t,s)=>[t,s]))}function zM(e){const t=e.codePointAt(0);return t!==void 0&&t>=rh&&t<rh+LM}function PS(e){const t=e.codePointAt(0)-rh,s=Math.floor(t/(ah*fl)),r=Math.floor(t%(ah*fl)/fl),o=t%fl,c={initial:a1[s],vowel:l1[r]};return o===0?c:{...c,final:o1[o]}}function IS(e){if(!e.vowel)return e.initial;const t=c1.get(e.initial),s=u1.get(e.vowel),r=e.final?h1.get(e.final):0;return t===void 0||s===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(rh+(t*ah+s)*fl+r)}const jM=[{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 HM({ctrlActive:e,onCtrl:t,onStandaloneKey:s,onPreserveFocus:r,onHide:o}){function c(h){h.stopPropagation(),r()}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"}),jM.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>s(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:o,children:"×"})]})}const UM={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function PM(e){return UM[e]}function IM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const KS="--nterminal-viewport-height",FS="--nterminal-keyboard-inset-bottom",WS="data-nterminal-keyboard-visible",Tg="data-nterminal-compose-open",ym="nterminal:viewport-refresh",KM=120;function FM(e=window){const t=e.document.documentElement,s=e.visualViewport;function r(){const o=WM(e);o!==null&&t.style.setProperty(KS,`${o}px`),t.style.setProperty(FS,`${f1(e)}px`),t.setAttribute(WS,String(qM(e)))}return r(),s?.addEventListener("resize",r),s?.addEventListener("scroll",r),e.addEventListener("resize",r),e.addEventListener(ym,r),e.addEventListener("orientationchange",r),e.addEventListener("pageshow",r),e.document.addEventListener("visibilitychange",r),()=>{s?.removeEventListener("resize",r),s?.removeEventListener("scroll",r),e.removeEventListener("resize",r),e.removeEventListener(ym,r),e.removeEventListener("orientationchange",r),e.removeEventListener("pageshow",r),e.document.removeEventListener("visibilitychange",r),t.style.removeProperty(KS),t.style.removeProperty(FS),t.removeAttribute(WS)}}function WM(e){if(e.document.documentElement.hasAttribute(Tg)&&Vo(e.innerHeight))return e.innerHeight;const t=e.visualViewport?.height;return Vo(t)?t:Vo(e.innerHeight)?e.innerHeight:null}function Vo(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function qM(e){return f1(e)>KM}function f1(e){const t=e.visualViewport?.height;if(!Vo(t)||!Vo(e.innerHeight))return 0;const s=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-s))}const pc=new Map,ic=new Map,$M=Object.freeze({open:!1,text:""});function YM(e){let t=ic.get(e);return t||(t=new Set,ic.set(e,t)),t}function p1(e){const t=ic.get(e);if(t)for(const s of Array.from(t))s()}function Dg(e){return pc.get(e)??$M}function VM(e,t){const s=YM(e);return s.add(t),()=>{s.delete(t)}}function XM(e,t){const s=Dg(e);s.open!==t&&(pc.set(e,{...s,open:t}),p1(e))}function GM(e,t){const s=Dg(e);s.text!==t&&(pc.set(e,{...s,text:t}),p1(e))}function Mu(e){pc.delete(e),ic.delete(e)}function qS(){pc.clear(),ic.clear()}const $S=120,ZM=420,Iu=new Set;let _l=null;function QM({terminalId:e,onSubmit:t,disabled:s=!1}){const r=v.useMemo(()=>T=>VM(e,T),[e]),o=v.useMemo(()=>()=>Dg(e),[e]),c=v.useSyncExternalStore(r,o,o),{open:h,text:p}=c,g=v.useRef(null),f=v.useRef(null),b=v.useRef(null);v.useLayoutEffect(()=>{if(!(!h||!bm()))return eN(e),()=>tN(e)},[h,e]),v.useLayoutEffect(()=>{const T=g.current?.closest(".terminal-pane");if(!T)return;function B(){T?.removeAttribute("data-compose-open"),T?.style.removeProperty("--compose-drawer-panel-height")}if(!h){B();return}const A=f.current;T.setAttribute("data-compose-open","true");function N(){const Q=A?.getBoundingClientRect().height??0;Q>0&&T?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(Q)}px`)}N();const I=[window.setTimeout(N,0),window.setTimeout(N,180),window.setTimeout(N,260)],P=window.requestAnimationFrame?.(N)??null,te=typeof ResizeObserver=="function"&&A?new ResizeObserver(N):null;return te&&A&&te.observe(A),()=>{for(const Q of I)window.clearTimeout(Q);P!==null&&window.cancelAnimationFrame?.(P),te?.disconnect(),B()}},[h]),v.useEffect(()=>{h&&b.current?.focus()},[h]);function y(T){XM(e,T)}function w(T){GM(e,T)}function S(){JM(g.current),y(!1),YS()}function E(){if(s||!p)return;const T=p.replace(/\r\n/g,`
|
|
31
|
+
`).replace(/\n/g,"\r");if(T&&t(T),window.setTimeout(()=>t("\r"),$S),w(""),bm()){b.current?.blur(),YS();return}window.setTimeout(()=>b.current?.focus(),$S+20)}return m.jsxs("div",{ref:g,className:"compose-drawer","data-open":h?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":h?"true":void 0,tabIndex:h?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>y(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),p?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:f,className:"compose-drawer-panel","aria-hidden":h?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:h?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:S,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:"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:h?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:p,onChange:T=>w(T.target.value),onKeyDown:T=>{if(T.key==="Enter"&&(T.metaKey||T.ctrlKey)){T.preventDefault(),E();return}T.key==="Escape"&&(T.preventDefault(),S())},placeholder:"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:h?0:-1,onClick:()=>{w(""),b.current?.focus()},disabled:!p,children:"Clear"}),m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:h?0:-1,onClick:E,disabled:s||!p,children:"Send"})]})]})]})}function JM(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function bm(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function YS(){if(!bm())return;const e=()=>{window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,pl()};e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function eN(e){_l!==null&&(window.clearTimeout(_l),_l=null),Iu.add(e),document.documentElement.setAttribute(Tg,"true"),pl()}function tN(e){if(Iu.delete(e),Iu.size>0||_l!==null){pl();return}_l=window.setTimeout(()=>{if(_l=null,Iu.size>0){pl();return}document.documentElement.removeAttribute(Tg),pl()},ZM),pl()}function pl(){window.dispatchEvent(new Event(ym))}function iN(e){e.attachCustomKeyEventHandler(o=>{if(nN(o)){const c=VS(e);return c?(o.preventDefault(),o.stopPropagation(),XS(c),!1):!0}return sN(o)?(o.preventDefault(),o.stopPropagation(),rN(e),!1):!0});const t=e.element;if(!t)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const s=o=>{const c=VS(e);if(c){if(o.clipboardData){o.clipboardData.setData("text/plain",c),o.preventDefault();return}o.preventDefault(),XS(c)}},r=o=>{const c=o.clipboardData?.getData("text/plain");if(c===void 0)return;const h=m1(c);h!==c&&(o.preventDefault(),o.stopImmediatePropagation(),e.paste(h))};return t.addEventListener("copy",s,!0),t.addEventListener("paste",r,!0),{dispose(){t.removeEventListener("copy",s,!0),t.removeEventListener("paste",r,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function nN(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 sN(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 rN(e){if(navigator.clipboard?.readText)try{const t=await navigator.clipboard.readText();if(!t)return;e.paste(m1(t))}catch{}}function VS(e){return e.hasSelection()?e.getSelection():""}function m1(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}async function XS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}aN(e)}function aN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.left="-9999px",s.style.top="0",s.style.opacity="0",document.body.appendChild(s),s.focus({preventScroll:!0}),s.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{s.remove(),t?.focus({preventScroll:!0})}}const lN=[4,10,11,12];function oN(e,t){const s=[e.parser.registerCsiHandler({final:"c"},r=>GS(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>GS(r)),e.parser.registerCsiHandler({final:"n"},r=>cN(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>uN(r)),e.parser.registerCsiHandler({final:"t"},r=>hN(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...lN.map(r=>e.parser.registerOscHandler(r,o=>dN(o)))];return{dispose(){for(const r of s)r.dispose()}}}function GS(e){return kh(e)===0}function cN(e){const t=kh(e);return t===5||t===6}function uN(e){return kh(e)===6}function hN(e){const t=kh(e);return t===14||t===16||t===18}function dN(e){return e.split(";").some(t=>t==="?")}function kh(e){const t=e[0];return typeof t=="number"?t:0}const xa=new Map,fN=2*1024*1024,pN=1500,mN=25e3;function gN(e,t){let s=xa.get(e);s||(s=yN(e),xa.set(e,s),Th(s)),s.listeners.add(t);const r=c=>EN(s,c),o=()=>{s.listeners.delete(t)};return{status:s.status,snapshot:s.snapshot,output:s.output.slice(),history:s.history,send:r,detach:o}}function jo(e){const t=xa.get(e);t&&(kN(t),xa.delete(e))}function _N(e,t={}){const s=xa.get(e);if(!s)return!1;s.exited=!1,s.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(s.preserveCachedOutputOnNextSnapshot=!0),s.reconnectTimer!==null&&(window.clearTimeout(s.reconnectTimer),s.reconnectTimer=null),mc(s);const r=s.socket;return s.socket=null,pa(s,"reconnecting"),r&&(r.readyState===WebSocket.OPEN||r.readyState===WebSocket.CONNECTING)&&r.close(),Th(s),!0}function vN(){for(const e of xa.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),mc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,pa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Th(e)}}function np(){for(const e of Array.from(xa.keys()))jo(e)}function yN(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 Th(e){if(!e.reconnectEnabled)return;pa(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){pa(e,"connected");for(const s of e.pendingOut)t.send(JSON.stringify(s));e.pendingOut.length=0,e.isAlive=!0,bN(e)}}),t.addEventListener("message",s=>{if(e.socket!==t)return;const r=typeof s.data=="string"?s.data:"";if(!r)return;let o=null;try{o=JSON.parse(r)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;return}const c=wN(e,o);g1(e,{type:"message",message:c})}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,mc(e),s.code===1008){e.reconnectEnabled=!1,pa(e,SN(s.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){pa(e,"closed");return}pa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Th(e)},pN)}}),t.addEventListener("error",()=>{})}function bN(e){mc(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)}))}},mN)}function mc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function SN(e){return e.trim().toLowerCase()==="unauthorized"}function wN(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,CN(e,t.output),sp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((s,r)=>s+r.length,0),sp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,sp(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 CN(e,t){const s=xN(e.output,t);if(s===0)return;const r=t.slice(s);for(const o of r)e.output.push(o),e.outputBytes+=o.length}function xN(e,t){const s=Math.min(e.length,t.length);for(let r=s;r>0;r-=1){let o=!0;for(let c=0;c<r;c+=1)if(e[e.length-r+c]!==t[c]){o=!1;break}if(o)return r}return 0}function sp(e){for(;e.outputBytes>fN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function pa(e,t){e.status!==t&&(e.status=t,g1(e,{type:"status",status:t}))}function g1(e,t){for(const s of Array.from(e.listeners))s(t)}function EN(e,t){const s=e.socket;return s&&s.readyState===WebSocket.OPEN?(s.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function kN(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),mc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const TN=[0,50,150,350],DN=[300,1200,2500],RN=1e3,MN=1e5,Sm="\x1B[?1049l\x1B[?1047l\x1B[?47l",NN=new Set(["47","1047","1049"]),AN=400,LN=3,BN=3,ON=32,zN=1.42,jN=2,HN=24,UN=240,PN=60,IN=420,KN=6,FN=2,ZS=[500,1500,3e3,5e3,8e3],QS=15e3,WN=Ei.lazy(()=>mg(()=>import("./TranscriptMarkdownBody-BDE5VmlN.js"),__vite__mapDeps([2,1])));function JS({terminal:e,serverApi:t,active:s,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:p,onClose:g,onExit:f,onSnapshot:b,onAuthClose:y}){const w=v.useSyncExternalStore(sw,Rp,()=>_a),S=v.useSyncExternalStore(rw,Mp,()=>yl),E=v.useSyncExternalStore(aw,Ap,()=>!0),T=v.useSyncExternalStore(Wm,Br,()=>vl),B=v.useSyncExternalStore(cg,()=>ug("history.toggle"),()=>"Alt+H"),A=v.useRef(null),N=v.useRef(null),I=v.useRef(null),P=v.useRef(null),te=v.useRef({onExit:f,onSnapshot:b}),Q=v.useRef(t.createWebSocketUrl),le=v.useRef(y),oe=v.useRef(null),ve=v.useRef(new Map),Ce=v.useRef([]),ie=v.useRef([]),J=v.useRef([]),F=v.useRef(0),K=v.useRef(!1),se=v.useRef(null),L=v.useRef(0),Y=v.useRef(null),D=v.useRef(null),Z=v.useRef(!1),ge=v.useRef(!1),R=v.useRef(!1),H=v.useRef(!1),ee=v.useRef(null),he=v.useRef(null),we=v.useRef(!1),xe=v.useRef(!1),Re=v.useRef(!1),Ye=v.useRef(!1),_e=v.useRef(!1),X=v.useRef(!1),ce=v.useRef(!1),Ee=v.useRef(s),be=v.useRef(r),De=v.useRef(c),Be=v.useRef(w),Ie=v.useRef(S),ae=v.useRef(!1),Te=v.useRef(null),Le=v.useRef(null),Oe=v.useRef(!1),ze=v.useRef(null),[,ht]=v.useState("connecting"),[Xe,ot]=v.useState(!1),[gi,Ji]=v.useState(null),[qi,$t]=v.useState(!1),[_i,_n]=v.useState(null),[W,We]=v.useState(!1),[ut,gt]=v.useState(!1),[vi,bt]=v.useState(!1),[It,en]=v.useState(null),[An,yi]=v.useState(!1),ln=!!It||Ku(e.currentCommand),[Et,kt]=v.useState(!1);v.useLayoutEffect(()=>{Ee.current=s},[s]),v.useLayoutEffect(()=>{be.current=r},[r]),v.useLayoutEffect(()=>{De.current=c},[c]),v.useLayoutEffect(()=>{Be.current=w},[w]),v.useLayoutEffect(()=>{Ie.current=S},[S]),v.useLayoutEffect(()=>{ae.current=An},[An]),v.useLayoutEffect(()=>{Te.current=It},[It]),v.useLayoutEffect(()=>{Oe.current=ln},[ln]),v.useEffect(()=>{r&&s&&e.status==="running"&&(_t(),Vi())},[s,r,e.status]),v.useEffect(()=>{te.current={onExit:f,onSnapshot:b}},[f,b]),v.useEffect(()=>{Q.current=t.createWebSocketUrl,le.current=y},[t,y]),v.useEffect(()=>{let O=!1,pe=null,Fe=0;const Pe=s3(e.currentCommand),Ge=Ku(e.currentCommand);function dt(){pe!==null&&(window.clearTimeout(pe),pe=null)}function Bt(Lt){if(O)return;let Ot;if(Lt){if(!Ge)return;Ot=QS}else if(Fe<ZS.length){if(!Pe)return;Ot=ZS[Fe++]}else{if(!Ge)return;Ot=QS}pe=window.setTimeout(()=>{pe=null,Gi()},Ot)}async function Gi(){try{const Lt=await t.getTerminalTranscriptSource(e.id);if(O)return;en(Ot=>Ot&&Lt.source&&Ot.provider===Lt.source.provider&&Ot.sessionId===Lt.source.sessionId?Ot:Lt.source),Bt(!!Lt.source)}catch(Lt){if(O)return;rp(Lt)&&en(null),Bt(!1)}}return en(null),e.status!=="running"?()=>{O=!0,dt()}:(Gi(),()=>{O=!0,dt()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const O=It?`${e.id}:${It.provider}:${It.sessionId}`:null,pe=Le.current;pe!==null&&O!==null&&pe!==O&&ae.current&&yi(!1),Le.current=O},[e.id,It?.provider,It?.sessionId]),v.useEffect(()=>{function O(pe){!Ee.current||!be.current||!Te.current||pe.isComposing||pe.key==="Process"||YN(pe.target)||lw(pe)?.id!=="history.toggle"||(pe.preventDefault(),pe.stopPropagation(),yi(Pe=>!Pe))}return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[]),v.useEffect(()=>{const O=N.current;O&&(O.options.disableStdin=e.status==="exited"),e.status==="exited"&&ht("closed")},[e.status]),v.useEffect(()=>{const O=N.current;O&&(O.options.fontSize=w,Pf(w,Ie.current).then(()=>{Be.current===w&&_t()}))},[w]),v.useEffect(()=>{const O=N.current;O&&(O.options.fontFamily=Dp(S),Pf(Be.current,S).then(()=>{Ie.current===S&&_t()}))},[S]),v.useEffect(()=>{const O=N.current;O&&(O.options.theme=e0(T))},[T]),v.useEffect(()=>{const O=A.current;if(!O)return;let pe=!1,Fe=null,Pe=null,Ge=null,dt=null,Bt=null,Gi=null,Lt=null;oe.current=null,_e.current=!1,X.current=!1,H.current=!1,Ui(),bi();const Ot=Be.current,On=Ie.current,Gt=new NM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Dp(On),fontSize:Ot,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:MN,theme:{...e0(Br())}}),ws=new wT;return Gt.loadAddon(ws),dt=oN(Gt),N.current=Gt,I.current=ws,Pf(Ot,On).then(()=>{if(pe)return;Gt.open(O),_e.current=!0,Fe=iN(Gt),be.current&&Ee.current&&e.status==="running"&&Vi(),_t(),Bt=f3(O,Gt,()=>Be.current*1.2,Vt,ci=>{Dt(ci)},Vs,on),Gi=u3(O,Gt,Vt,ci=>{Dt(ci)},Vs,on);const Cs=new AM;Pe=Gt.onData(ci=>{if(ce.current){const Zs=IM(ci);if(Zs){qr(!1),ls(Zs);return}}const Gs=Cs.accept(ci);Gs&&ls(Gs)}),Ge=Gt.onScroll(ci=>{if(xe.current||Ye.current||Re.current){At();return}Pr(),ts(Gt)&&Yi({scrollToBottom:!0}),Vt(),ci<=3&&Dt()}),Lt=new ResizeObserver(()=>{tn()}),Lt.observe(O),X.current&&(oi(),X.current=!1,_t()),Hi()}),()=>{pe=!0,_e.current=!1,X.current=!1,Ui(),Kt(),Da(),Re.current=!1,Bt?.(),Gi?.(),Lt?.disconnect(),Fe?.dispose(),Pe?.dispose(),Ge?.dispose(),dt?.dispose(),Gt.dispose(),N.current=null,I.current=null}},[e.id]),v.useEffect(()=>{const O=Q.current(e.id),pe=gN(O,Tt);return P.current=pe.send,ht(pe.status),pe.status==="connected"&&_t(),pe.snapshot&&(te.current.onSnapshot(pe.snapshot,{notifyCompletion:!1}),N.current&&(_t(),ii(pe.output,pe.history),_t())),()=>{pe.detach(),P.current=null}},[e.id,e.status]);function Tt(O){if(O.type==="status"){ht(O.status),O.status==="unauthorized"&&le.current?.({source:"terminal-ws-1008",terminalId:e.id}),O.status==="connected"&&_t();return}vn(O.message)}function bi(O=[],pe=null){ie.current=[],J.current=Nu(O),F.current=0,K.current=!1,se.current=null,Re.current=!1,L.current+=1,Y.current=pe,D.current=null,Z.current=!1,ge.current=!1,R.current=!1,X.current=!1,ze.current=null,ee.current=null,we.current=!1,ot(!1),Ji(null),$t(!1),_n(null),We(!1),gt(!1)}function ii(O=[],pe=null){bi(O,pe),Yt()}function Yt(){if(!N.current||!_e.current){X.current=!0;return}X.current=!1,oi()}async function oi(){const O=N.current;if(!O)return;const pe=Au(O,we.current),Fe=pe?J.current.length:F.current;await Ti(O,{liveOutputLimit:Fe,scrollToBottom:pe}),N.current===O&&At()}function Ti(O,pe={}){return new Promise(Fe=>{Re.current=!0,K.current=!1;const Pe=L.current+1;L.current=Pe;const Ge=Math.max(0,Math.min(pe.liveOutputLimit??J.current.length,J.current.length)),dt=pe.historyPages??ie.current,Bt=()=>{if(N.current!==O||L.current!==Pe){Fe(!1);return}try{F.current=Ge,pe.scrollToBottom&&Bn(O)}finally{Re.current=!1;const Lt=Ys();Lt?Yi(Lt):pe.applyDeferredSnapshot!==!1&&Kr(),Fe(!0)}},Gi=()=>{if(N.current!==O||L.current!==Pe){Fe(!1);return}O.clear();const Lt=Nu([...dt,...J.current.slice(0,Ge)]);if(Lt.length===0){Bt();return}for(let Ot=0;Ot<Lt.length;Ot+=1){const On=Lt[Ot];Ot===Lt.length-1?O.write(On,Bt):O.write(On)}};if(O.buffer.active.type==="alternate"){O.write(Sm,Gi);return}Gi()})}async function Dt(O=0){const pe=N.current;if(R.current||!pe)return;if(Ln(pe)){At();return}const Fe=Y.current;R.current=!0,ot(!0);const Pe=pe.buffer.active.viewportY;try{let Ge=!!(Fe&&!Fe.hasMore);if(!Ge)try{const dt=await t.getTerminalHistory(e.id,{beforeLine:Fe?.startLine??0,limit:RN}),Bt={startLine:dt.startLine,endLine:dt.endLine,hasMore:dt.hasMore};if(dt.output.length>0){await ni(pe,dt.output,Pe,O)&&(Y.current=Bt);return}Y.current=Bt,Ge=!dt.hasMore}catch(dt){Ge=rp(dt)}if(Ge){if(Ln(pe)){At();return}await ji(pe,Pe,O)}}catch{}finally{R.current=!1,ot(!1)}}async function ji(O,pe,Fe){if(!(Z.current||ge.current))try{const Pe=D.current,Ge=await t.getTerminalTranscriptHistory(e.id,{...Pe?{cursor:Pe}:{},limit:AN}),dt=Ge.output.map(v1);if(!Ge.source)return;if(dt.length===0){en(Ge.source),D.current=Ge.cursor,ge.current=!Ge.hasMore||!Ge.cursor;return}await ni(O,dt,pe,Fe)&&(en(Ge.source),D.current=Ge.cursor,ge.current=!Ge.hasMore||!Ge.cursor)}catch(Pe){rp(Pe)&&(Z.current=!0)}}async function ni(O,pe,Fe,Pe){if(Ln(O))return At(),!1;const Ge=[...pe,...ie.current],dt=o3(pe);return!await Ti(O,{liveOutputLimit:F.current,scrollToBottom:!1,historyPages:Ge,applyDeferredSnapshot:!1})||N.current!==O?!1:(ie.current=Ge,Nl(O,Math.max(0,Fe+dt+Math.min(0,Pe))),we.current=!ts(O),Vt(),!0)}v.useEffect(()=>{const O=window.visualViewport;function pe(){document.visibilityState==="visible"&&_t()}function Fe(){_t()}function Pe(){Hi()}return document.addEventListener("visibilitychange",pe),window.addEventListener("pageshow",Fe),window.addEventListener("resize",Pe),O?.addEventListener("resize",Pe),O?.addEventListener("scroll",Pe),()=>{document.removeEventListener("visibilitychange",pe),window.removeEventListener("pageshow",Fe),window.removeEventListener("resize",Pe),O?.removeEventListener("resize",Pe),O?.removeEventListener("scroll",Pe)}},[e.id]);function $i(){const O=Q.current(e.id);H.current=!0,ze.current=null,ht("reconnecting"),_t(),_N(O,{preserveCachedOutputOnNextSnapshot:!0})}function vn(O){if(O.type==="snapshot"&&O.terminal.id===e.id){te.current.onSnapshot(O.terminal,{notifyCompletion:!1});const Fe=N.current;if(!Fe)return;_t();const Pe=H.current;if(H.current=!1,Pe){Y.current=O.history??Y.current,At(),_t();return}if(rs(Fe,O.terminal)){Xt(O.output,O.history??null),At(),_t();return}ii(O.output,O.history??null),_t();return}if(O.type==="terminal_updated"&&O.terminal.id===e.id){te.current.onSnapshot(O.terminal,{notifyCompletion:!0});return}if(O.type==="output"&&O.terminalId===e.id){const Fe=S1(O.data);if(!Fe)return;J.current.push(Fe),N.current&&_e.current?Yi({scrollToBottom:!0}):X.current=!0;return}const pe=N.current;if(pe){if(O.type==="exit"&&O.terminalId===e.id){te.current.onExit(O.exitCode),ht("closed");return}O.type==="error"&&pe.writeln(`\r
|
|
32
|
+
[nterminal] ${O.message}`)}}function tn(O=25){if(document.visibilityState==="hidden"||!be.current||ve.current.has(O))return;const pe=window.setTimeout(()=>{ve.current.delete(O),bn()},O);ve.current.set(O,pe)}function Hi(){for(const O of TN)tn(O)}function _t(){oe.current=null,Hi()}function Ui(){for(const O of ve.current.values())window.clearTimeout(O);ve.current.clear()}function Kt(){for(const O of Ce.current)window.clearTimeout(O);Ce.current=[]}function Vt(){if(At(),!ee.current){$t(!1);return}$t(!0),Da(),he.current=window.setTimeout(()=>{he.current=null,$t(!1)},1200)}function At(){const O=N.current,pe=O?c3(O):null;if(ee.current=pe,Ji(pe),gt(!!(O&&pe)),We(!!(O&&pe&&!ts(O))),pe||!O||!Ur()){_n(null);return}_n({alternate:O.buffer.active.type==="alternate"})}function Ur(){const O=Y.current;return ie.current.length>0||!!O?.hasMore}function Da(){he.current!==null&&(window.clearTimeout(he.current),he.current=null)}function Pr(){const O=N.current;O&&(we.current=!ts(O),At())}function Ir(O){se.current=ap(se.current,O)}function bs(O){const pe=se.current;return se.current=null,ap(pe,O)}function Ys(){const O=se.current;return se.current=null,O}function Yi(O={}){const pe=N.current;if(!pe||!_e.current){X.current=!0;return}if(Re.current){Ir(O);return}if(K.current){Ir(O);return}const Fe=bs(O);if(!Fe.force&&!Au(pe,we.current)){At();return}K.current=!0;const Pe=L.current,Ge=()=>{if(N.current!==pe||L.current!==Pe){K.current=!1;return}if(!Fe.force&&!Au(pe,we.current)){K.current=!1,At();return}const dt=F.current,Bt=J.current[dt];if(Bt===void 0){K.current=!1,Fe.scrollToBottom&&Bn(pe),At();const Gi=Ys();Gi?Yi(ap(Fe,Gi)):Kr();return}pe.write(Bt,()=>{if(N.current!==pe||L.current!==Pe){K.current=!1;return}F.current=dt+1,Ge()})};Ge()}function Ln(O){return!ts(O)&&(yn()||K.current||Re.current)}function rs(O,pe){return(Oe.current||Ku(pe?.currentCommand))&&!ts(O)}function yn(){return F.current<J.current.length}function Xt(O,pe){ze.current={output:O,history:pe,appendFromLiveOutputIndex:F.current}}function Kr(){const O=N.current,pe=ze.current;if(!O||!pe||!ts(O)||yn()||K.current||Re.current)return;const Fe=Nu(pe.output),Pe=Nu(J.current.slice(pe.appendFromLiveOutputIndex));ze.current=null,ii(l3(Fe,Pe),pe.history),_t()}function Vs(){Ye.current=!0}function on(){Pr(),Ye.current=!1;const O=N.current;O&&ts(O)&&Yi({scrollToBottom:!0})}function Bn(O){Fr(()=>r0(O))&&(we.current=!1)}function Nl(O,pe){Fr(()=>(O.scrollToLine(pe),!0))}function Fr(O){xe.current=!0;try{return O()}finally{xe.current=!1}}function Ra(){const O=N.current;if(!O)return;const pe=()=>{r0(O),we.current=!1,At(),Yi({force:!0,scrollToBottom:!0}),Vi()};if(O.buffer.active.type==="alternate"){O.write(Sm,pe);return}pe()}function Ma(O){const pe=N.current,Fe=A.current;if(!pe||!Fe)return;const Pe=Fe.getBoundingClientRect();if(Pe.height<=0)return;const Ge=Math.max(0,Math.min(1,(O-Pe.top)/Pe.height)),dt=Math.round(pe.buffer.active.baseY*Ge);Vs();try{pe.scrollToLine(dt)}finally{on()}we.current=!ts(pe),At(),Vt(),dt<=3&&Dt()}function Xs(O){O.preventDefault(),O.stopPropagation(),O.currentTarget.setPointerCapture?.(O.pointerId),Ma(O.clientY)}function as(O){(O.buttons&1)!==0&&(O.preventDefault(),O.stopPropagation(),Ma(O.clientY))}function bn(){const O=N.current,pe=I.current;if(!(!O||!pe)&&!(document.visibilityState==="hidden"||!be.current||A.current?.isConnected===!1))try{const Fe=Au(O,we.current);pe.fit(),Fe&&Bn(O),O.refresh(0,Math.max(0,O.rows-1)),At();const Pe={cols:O.cols,rows:O.rows},Ge=oe.current;if(Ge&&Ge.cols===Pe.cols&&Ge.rows===Pe.rows)return;Ft({type:"resize",terminalId:e.id,cols:Pe.cols,rows:Pe.rows})&&(oe.current=Pe)}catch{}}function Ft(O){const pe=P.current;return pe?pe(O):!1}function ls(O){Yi({force:!0,scrollToBottom:!0}),Ft({type:"input",terminalId:e.id,data:O})&&n3(O)&&rt()}function rt(){!De.current||!Ee.current||(Kt(),Ce.current=DN.map(O=>{const pe=window.setTimeout(()=>{Ce.current=Ce.current.filter(Fe=>Fe!==pe),De.current&&Ee.current&&Ft({type:"refresh_cwd",terminalId:e.id})},O);return pe}))}function Vi(){ae.current||N.current?.focus()}const Wr=v.useCallback(()=>{yi(!1)},[]);function Ss(){bt(O=>{const pe=!O;return ce.current=pe,pe}),Vi()}function qr(O){ce.current=O,bt(O)}function Xi(O){ce.current&&qr(!1),ls(PM(O)),Vi()}return m.jsxs("section",{className:"terminal-pane","data-active":s,onMouseDown:()=>{s||p()},children:[m.jsx(VN,{terminal:e,canClose:o,tabId:h,transcriptSource:It,transcriptShortcutLabel:B,onOpenTranscript:()=>yi(!0),onReload:$i,onClose:g}),m.jsx("div",{className:"xterm-container",ref:A}),Xe?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,E&&gi?m.jsxs("div",{className:"terminal-scroll-progress","data-active":qi,"aria-hidden":"true",children:[gi.current,"/",gi.total]}):E&&_i?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":_i.alternate?"alternate":"normal","aria-hidden":"true",children:[_i.alternate?"alt ":"","0/?"]}):null,W?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:O=>O.stopPropagation(),onMouseDown:O=>O.stopPropagation(),onClick:O=>{O.stopPropagation(),Ra()},children:"↓"}):null,ut?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Xs,onPointerMove:as,children:m.jsx("span",{"aria-hidden":"true"})}):null,s&&e.status==="running"?Et?m.jsx(HM,{ctrlActive:vi,onCtrl:Ss,onStandaloneKey:Xi,onPreserveFocus:Vi,onHide:()=>kt(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:O=>{O.stopPropagation(),Vi()},onPointerDown:O=>{O.stopPropagation(),Vi()},onClick:()=>kt(!0),children:"⌨"}):null,m.jsx(QM,{terminalId:e.id,onSubmit:ls,disabled:e.status!=="running"}),An&&It?m.jsx(XN,{terminalId:e.id,serverApi:t,source:It,fontSize:w,onClose:Wr}):null]})}function e0(e){return cE(e)}function qN(e,t,s){const r=$N(e,t),o=t0(r*Math.max(1,s),PN,IN);return{limit:t0(Math.ceil(o/jN),HN,UN),maxLines:o}}function $N(e,t){const s=e?.clientHeight??0;if(s<=0)return ON;const r=Math.max(10,t*zN);return Math.max(1,Math.floor(s/r))}function t0(e,t,s){return Math.max(t,Math.min(s,Math.floor(e)))}function YN(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function VN({terminal:e,canClose:t,tabId:s,transcriptSource:r,transcriptShortcutLabel:o,onOpenTranscript:c,onReload:h,onClose:p}){const g=K0({id:`pane-${e.id}`,disabled:!s,...s?{data:{kind:"pane",sourceTabId:s,terminalId:e.id}}:{}}),f={cursor:s?"grab":"default",opacity:g.isDragging?.5:void 0};return m.jsxs("header",{ref:g.setNodeRef,className:"terminal-pane-header",style:f,"data-dragging":g.isDragging,...g.attributes,...g.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"}),r?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${lh(r.provider)} transcript history`,"aria-label":`View ${lh(r.provider)} transcript history`,onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),c()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:o})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),h()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:b=>b.stopPropagation(),onMouseDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),p()},children:"x"}):null]})}const XN=Ei.memo(function({terminalId:t,serverApi:s,source:r,fontSize:o,onClose:c}){const h=v.useRef(null),p=v.useRef(0),g=v.useRef(!1),f=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),[w,S]=v.useState([]),[E,T]=v.useState(!1),[B,A]=v.useState(""),[N,I]=v.useState(-1),[P,te]=v.useState(null),[Q,le]=v.useState(!1),[oe,ve]=v.useState(!0),[Ce,ie]=v.useState(!1),[J,F]=v.useState(null);v.useEffect(()=>{function _e(X){X.key==="Escape"&&(X.preventDefault(),X.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,b.current=null,S([]),te(null),le(!1),F(null),he(null,"initial",_e),()=>{p.current===_e&&(p.current+=1)}},[s,E,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const _e=h.current;if(!_e)return;if(f.current){if(oe||w.length===0)return;f.current=!1;const ce=()=>{_e.scrollTop=_e.scrollHeight};ce(),window.requestAnimationFrame?.(ce);return}const X=b.current;X!==null&&(b.current=null,_e.scrollTop+=_e.scrollHeight-X)},[w,oe,E]);const K=lh(r.provider),se=s0(w,E),L=QN(se),Y=t3(L,B),D=Y.length,Z=D>0?N>=0&&N<D?N:0:-1,ge=Z>=0?Y[Z]?.entryIndex??null:null,R=Z>=0?Y[Z]??null:null,H=se?se.split(`
|
|
33
|
+
`).length-1:0,ee=B.trim()?D>0?`${Z+1}/${D} ${D===1?"match":"matches"} · ${H} ${H===1?"line":"lines"}`:`0 matches · ${H} ${H===1?"line":"lines"}`:H>0?`${H} lines`:"0 lines";v.useEffect(()=>{const _e=B.trim().toLowerCase();I(X=>!_e||D===0?-1:y.current!==_e?0:X>=0&&X<D?X:0),y.current=_e},[B,D]);async function he(_e,X,ce=p.current){if(!g.current){g.current=!0,X==="initial"?ve(!0):(ie(!0),b.current=h.current?.scrollHeight??null),F(null);try{await we(_e,X,ce)}catch(Ee){if(p.current!==ce)return;F(Ee instanceof Error?Ee.message:"Failed to load transcript history.")}finally{p.current===ce&&(g.current=!1,ve(!1),ie(!1))}}}async function we(_e,X,ce){let Ee=_e,be=0,De=[];const Be=X==="initial"&&r.provider!=="claude"?FN:KN;for(;p.current===ce;){const Ie=await s.getTerminalTranscriptHistory(t,{...Ee?{cursor:Ee}:{},...qN(h.current,o,X==="initial"?LN:BN),includeTools:E});if(p.current!==ce)return;const ae=n0(Ie.output,r.provider,{includeTools:E}),Te=xe(Ie,X,De,ae);if(ae&&(De=[ae,...De],Te))return;if(!Ie.hasMore||!Ie.cursor||be>=Be){De.length>0&&S(Le=>X==="older"?[...De,...Le]:De);return}Ee=Ie.cursor,be+=1}}function xe(_e,X,ce,Ee=n0(_e.output,r.provider,{includeTools:E})){if(te(_e.cursor),le(!!(_e.hasMore&&_e.cursor)),!Ee)return!1;const be=[Ee,...ce];return s0(be,E)?(S(De=>X==="older"?[...be,...De]:be),!0):!1}function Re(){const _e=h.current;!_e||_e.scrollTop>72||!Q||!P||g.current||he(P,"older")}function Ye(_e){D!==0&&I(X=>{const ce=Z>=0?Z:_e>0?-1:0;return((X>=0&&X<D?X:ce)+_e+D)%D})}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:[K," JSONL"]}),m.jsx("span",{title:r.sessionId,children:r.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:E,onChange:_e=>T(_e.currentTarget.checked)}),"Show tool output"]}),m.jsxs("label",{className:"transcript-search",children:[m.jsx("span",{children:"Search"}),m.jsx("input",{type:"search",value:B,"aria-label":"Search JSONL transcript",placeholder:"Find in history",onChange:_e=>A(_e.currentTarget.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),Ye(_e.shiftKey?-1:1))}})]}),m.jsxs("div",{className:"transcript-search-actions","aria-label":"Search result navigation",children:[m.jsx("button",{type:"button",onClick:()=>Ye(-1),disabled:D===0,children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>Ye(1),disabled:D===0,children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:ee})]}),m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Re,children:[Ce?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!oe&&Q?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,se?m.jsx(GN,{entries:L,searchQuery:B,activeEntryIndex:ge,activeSearchMatch:R,fontSize:o}):null,oe?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!oe&&!se&&!J?Q&&P?m.jsxs("div",{className:"transcript-dialog-status",children:[E?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{he(P,"older")},disabled:Ce,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,J?m.jsx("div",{className:"transcript-dialog-error",children:J}):null]})]})})});function GN({entries:e,searchQuery:t,activeEntryIndex:s,activeSearchMatch:r,fontSize:o}){const c=v.useRef(new Map);return v.useEffect(()=>{if(s===null)return;const h=c.current.get(s);if(!h||typeof h.scrollIntoView!="function")return;const p=h.querySelectorAll(".transcript-search-hit");((r?.entryIndex===s?p[r.matchIndexInEntry]:null)??h).scrollIntoView({block:"center",inline:"nearest"})},[s,r,t]),m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:o},children:e.map((h,p)=>m.jsxs("section",{ref:g=>{g?c.current.set(p,g):c.current.delete(p)},className:`transcript-entry transcript-entry-${h.kind}${s===p?" transcript-entry-search-active":""}`,children:[h.header?m.jsx("div",{className:"transcript-entry-header",children:_1(h.header,t)}):null,h.body?m.jsx("div",{className:"transcript-entry-body",children:h.kind==="tool"?m.jsx(i0,{text:h.body,searchQuery:t}):m.jsx(Ei.Suspense,{fallback:m.jsx(i0,{text:h.body,searchQuery:t}),children:m.jsx(WN,{text:h.body,searchQuery:t})})}):null]},`${h.header??"plain"}-${p}`))})}function i0({text:e,searchQuery:t}){const s=e.endsWith(`
|
|
34
|
+
`)?e.slice(0,-1).split(`
|
|
35
|
+
`):e.split(`
|
|
36
|
+
`);return m.jsx("pre",{className:"transcript-entry-pre",children:s.map((r,o)=>m.jsx("span",{className:`transcript-line transcript-line-${i3(r,o===0||s[o-1]?.trim()==="")}`,children:_1(r,t)},o))})}function _1(e,t){const s=t.trim();if(!s)return e||" ";const r=e.toLowerCase(),o=s.toLowerCase(),c=[];let h=0,p=r.indexOf(o);for(;p!==-1;){p>h&&c.push(e.slice(h,p));const g=p+s.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(p,g)},`${p}-${g}`)),h=g,p=r.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function ZN(e,t){const s=t.trim().toLowerCase();if(!s)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(s);for(;c!==-1;)o+=1,c=r.indexOf(s,c+s.length);return o}function QN(e){const t=e.endsWith(`
|
|
37
|
+
`)?e.slice(0,-1):e;if(!t)return[];const s=[];let r=null,o="plain",c=[];function h(){const p=JN(c).join(`
|
|
38
|
+
`);(r||p)&&s.push({header:r,body:p,kind:o}),r=null,o="plain",c=[]}for(const p of t.split(`
|
|
39
|
+
`)){const g=e3(p);g?(h(),r=p,o=g):c.push(p)}return h(),s}function JN(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function e3(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const s=t[1]??"";return s==="User"?"user":s==="Codex"||s==="Claude"?"assistant":s==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(s)?"tool":null}function t3(e,t){const s=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
40
|
+
${o.body}`:o.body,h=ZN(c,t);for(let p=0;p<h;p+=1)s.push({entryIndex:r,matchIndexInEntry:p})}return s}function i3(e,t){const s=e.trim();if(!s)return"blank";const r=s.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(s);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||b1(s))?"tool":/^(?:\$|>|❯|➜)\s+/.test(s)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(s)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(s)?"error":/^\[[^\]]+\]/.test(s)||/^(?:info|debug|warn)\b/i.test(s)?"dim":"plain"}function n3(e){return e.includes("\r")||e.includes(`
|
|
41
|
+
`)}function rp(e){return e instanceof is&&e.status===404}function Ku(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")||t==="claude"||t==="claude.js"||t.startsWith("claude-")}function s3(e){if(Ku(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function lh(e){return e==="codex"?"Codex":"Claude"}function n0(e,t,s={}){const r=`[nterminal] ${lh(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
42
|
+
`).replace(/\r/g,`
|
|
43
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
44
|
+
|
|
45
|
+
`).trimEnd(),c=v1(o),h=s.includeTools?c:y1(c);return h?`${h}
|
|
46
|
+
`:""}function v1(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,s)=>{const r=r3(s);return r?`[${r}]`:t})}function r3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const s=t.getFullYear(),r=To(t.getMonth()+1),o=To(t.getDate()),c=To(t.getHours()),h=To(t.getMinutes()),p=To(t.getSeconds());return`${s}-${r}-${o} ${c}:${h}:${p}`}function To(e){return e.toString().padStart(2,"0")}function s0(e,t){return e.map(s=>t?s:y1(s)).filter(Boolean).map(s=>s.endsWith(`
|
|
47
|
+
`)?s:`${s}
|
|
48
|
+
`).join("")}function y1(e){if(!e)return"";const t=e.split(`
|
|
49
|
+
`),s=[];let r=!1,o=!1,c=!0;for(const h of t){const p=h.trim()==="",g=c?a3(h):null;if(g&&(r=g==="tool",o=!1),b1(h)){o=!0,c=!1;continue}if(o){p?(o=!1,r||s.push(h),c=!0):c=!1;continue}r||s.push(h),c=p}return s.join(`
|
|
50
|
+
`).replace(/\n{3,}/g,`
|
|
51
|
+
|
|
52
|
+
`).trimEnd()}function a3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function b1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function l3(e,t){if(t.length===0)return e;let s=0;const r=Math.min(e.length,t.length);for(let o=r;o>0;o-=1){let c=!0;for(let h=0;h<o;h+=1)if(e[e.length-o+h]!==t[h]){c=!1;break}if(c){s=o;break}}return[...e,...t.slice(s)]}function o3(e){let t=0;for(const s of e){if(!s)continue;const r=s.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Nu(e){const t=[];for(const s of e){const r=S1(s);r&&t.push(r)}return t}function S1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,s,r)=>{const o=s.split(";").filter(Boolean).filter(c=>!NN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function ap(e,t={}){const s={};return(e?.force||t.force)&&(s.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(s.scrollToBottom=!0),s}function c3(e){const t=e.buffer.active,s=t.baseY+e.rows;return s<=e.rows?null:{current:Math.max(1,Math.min(s,t.viewportY+1)),total:s}}function ts(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Au(e,t){return!t||ts(e)}function r0(e){return ts(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function u3(e,t,s,r,o,c){const h=p=>{const g=d3(p);g!==0&&(p.cancelable&&p.preventDefault(),p.stopPropagation(),h3(t,g,s,r,o,c))};return e.addEventListener("wheel",h,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",h,{capture:!0})}}function h3(e,t,s,r,o,c){const h=()=>{o();try{e.scrollLines(t)}finally{c()}s(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(Sm,h);return}h()}function d3(e){const s=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(s===0)return 0;const r=s<0?Math.floor(s):Math.ceil(s);return Math.max(-30,Math.min(30,r))}function f3(e,t,s,r,o,c,h){let p=null,g=0;const f={passive:!1};function b(S){p=lp(S),g=0}function y(S){const E=lp(S);if(E===null){p=null,g=0;return}if(p===null){p=E;return}const T=E.clientY-p.clientY;if(p=E,S.cancelable&&S.preventDefault(),T===0)return;if(p3(t)&&m3(t,E,-T)){g=0;return}g-=T/s();const B=g<0?Math.ceil(g):Math.floor(g);if(B!==0){g-=B,c();try{t.scrollLines(B)}finally{h()}r(),B<0&&t.buffer.active.viewportY<=3&&o(B)}}function w(S){if(S.touches.length>0){p=lp(S);return}p=null,g=0}return e.addEventListener("touchstart",b,f),e.addEventListener("touchmove",y,f),e.addEventListener("touchend",w),e.addEventListener("touchcancel",w),()=>{e.removeEventListener("touchstart",b,f),e.removeEventListener("touchmove",y,f),e.removeEventListener("touchend",w),e.removeEventListener("touchcancel",w)}}function lp(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function p3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function m3(e,t,s){const r=e.element;return r?(r.dispatchEvent(g3(t,s)),!0):!1}function g3(e,t){const s=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:s};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function wm({node:e,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:p,dropZoneActive:g=!1,draggingTerminalId:f=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:w,onSelect:S,onClose:E,onResize:T,onExit:B,onSnapshot:A,onCloseEditor:N,onAuthClose:I}){const P=w??Cm(e);if(y.length===0&&b){const oe=xm(e),ve=oe.some(Ce=>Ce.key===b)?b:oe[0]?.key;if(oe.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:oe.map(Ce=>{const ie=Ce.key===ve;if(Ce.type==="editor"){const F=s[Ce.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:F?m.jsx(Wb,{api:r,editor:F,canClose:P>1,onClose:()=>N(Ce.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},Ce.key)}const J=t[Ce.terminalId];return J?m.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:m.jsx(JS,{terminal:J,serverApi:r,active:ie,visible:c&&ie,canClose:P>1,refreshCwdOnEnter:h&&ie,tabId:p,onSelect:()=>S(Ce.terminalId),onClose:()=>E(Ce.terminalId),onExit:F=>B(Ce.terminalId,F),onSnapshot:A,...I?{onAuthClose:I}:{}})},Ce.key):m.jsx("div",{className:"mobile-focused-pane","data-active":ie,"aria-hidden":!ie,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},Ce.key)})})}if(e.type==="pane"){const oe=t[e.terminalId];if(!oe)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(JS,{terminal:oe,serverApi:r,active:e.terminalId===o,visible:c,canClose:P>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:p,onSelect:()=>S(e.terminalId),onClose:()=>E(e.terminalId),onExit:ie=>B(e.terminalId,ie),onSnapshot:A,...I?{onAuthClose:I}:{}});return g&&f!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(Lu,{terminalId:e.terminalId,side:"top"}),m.jsx(Lu,{terminalId:e.terminalId,side:"right"}),m.jsx(Lu,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Lu,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const oe=s[e.editorId];return oe?m.jsx(Wb,{api:r,editor:oe,canClose:P>1,onClose:()=>N(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const te=Math.max(.1,Math.min(.9,e.ratio)),Q=1-te,le=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${te}fr) 1px minmax(0, ${Q}fr)`}:{gridTemplateRows:`minmax(0, ${te}fr) 1px minmax(0, ${Q}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:le,children:[m.jsx("div",{className:"split-cell",children:m.jsx(wm,{node:e.first,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,0],totalPanes:P,onSelect:S,onClose:E,onResize:T,onExit:B,onSnapshot:A,onCloseEditor:N,...I?{onAuthClose:I}:{}})}),m.jsx(_3,{direction:e.direction,path:y,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(wm,{node:e.second,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:p,dropZoneActive:g,draggingTerminalId:f,mobileFocusLeafKey:b,path:[...y,1],totalPanes:P,onSelect:S,onClose:E,onResize:T,onExit:B,onSnapshot:A,onCloseEditor:N,...I?{onAuthClose:I}:{}})})]})}function Lu({terminalId:e,side:t}){const{setNodeRef:s,isOver:r}=Zm({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:s,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function _3({direction:e,path:t,onResize:s}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const p=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-p.left)/p.width:(b.clientY-p.top)/p.height;s(t,Math.min(.9,Math.max(.1,y)))}function f(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",f)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Cm(e){return e.type==="pane"||e.type==="editor"?1:Cm(e.first)+Cm(e.second)}function xm(e){return e.type==="pane"?[{key:v3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:y3(e.editorId),type:"editor",editorId:e.editorId}]:[...xm(e.first),...xm(e.second)]}function v3(e){return`terminal:${e}`}function y3(e){return`editor:${e}`}const Dh="workspace-default",b3="NTerminal";function S3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function w3(e,t){switch(t.type){case"workspace.hydrated":return Em(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return C3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return T3(e,t.workspaceId);case"workspace.selected":return w1(e,t.workspaceId);case"workspace.renamed":return x3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return E3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return k3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return C1(e,t.terminal);case"terminal.split":return D3(e,t.terminal,t.direction);case"terminal.updated":return U3(e,t.terminal);case"terminal.exited":return P3(e,t.terminalId,t.exitCode);case"terminal.closed":return k1(e,t.terminalId);case"terminal.detached":return I3(e,t.terminalId,t.workspaceId);case"editor.split":return R3(e,t.editorId,t.title,t.direction);case"editor.closed":return K3(e,t.editorId);case"pane.selected":return j3(e,t.terminalId);case"pane.resized":return H3(e,t.path,t.ratio);case"tab.selected":return N3(e,t.tabId);case"tab.renamed":return z3(e,t.tabId,t.title);case"tab.reordered":return Rg(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return A3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return x1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return E1(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return L3(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return M3(e);default:return e}}function C3(e,t){if(e.workspaces.some(r=>r.id===t.id))return w1(e,t.id);const s={id:t.id,title:t.title,defaultCwd:ss(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,s],activeWorkspaceId:s.id}}function w1(e,t){return e.workspaces.some(s=>s.id===t)?{...e,activeWorkspaceId:t}:e}function x3(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===r?h:(o=!0,{...h,title:r}));return o?{...e,workspaces:c}:e}function E3(e,t,s){const r=ss(s);let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===r?h:(o=!0,{...h,defaultCwd:r}));return o?{...e,workspaces:c}:e}function k3(e,t,s,r){if(t===s)return e;const o=e.workspaces.findIndex(y=>y.id===t),c=e.workspaces.findIndex(y=>y.id===s);if(o<0||c<0)return e;const h=e.workspaces.slice(),[p]=h.splice(o,1);if(!p)return e;const g=h.findIndex(y=>y.id===s);if(g<0)return e;const f=r==="before"?g:g+1,b=h.slice();return b.splice(f,0,p),O3(e.workspaces,b)?e:{...e,workspaces:b}}function T3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const s=e.workspaces.find(p=>p.id===t),r=new Set(s?oh(s):[]),o={...e.terminals};for(const p of r)delete o[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:o}}function C1(e,t){const s=D1(e),r=ka(s)??Mh(),o=L1(t);return{...s,activeWorkspaceId:r.id,terminals:{...s.terminals,[t.id]:t},workspaces:s.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??ss(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:A1(c,t.id))}}function D3(e,t,s){const r=ka(e),o=r?Rh(r):void 0;if(!r||!o)return C1(e,t);const c=o.activeTerminalId,h=sc(o.root,c,{type:"split",direction:s,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===r.id?{...p,defaultCwd:p.defaultCwd??ss(t.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(g=>g!==t.id),tabs:p.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:A1(p,t.id))}}function R3(e,t,s,r){const o=ka(e),c=o?Rh(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,p=sc(c.root,h,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:s}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:h}:f)}:g)}}function M3(e){const t=ka(e),s=t?Rh(t):void 0;return s?k1(e,s.activeTerminalId):e}function N3(e,t){const s=ka(e);return!s||!s.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===s.id?{...r,activeTabId:t}:r)}}function Rg(e,t,s){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(b=>b.id===t);if(c<0)return o;const h=o.tabs.slice(),[p]=h.splice(c,1);if(!p)return o;const g=Math.max(0,Math.min(h.length,s)),f=h.slice();return f.splice(g,0,p),B3(o.tabs,f)?o:{...o,tabs:f}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function A3(e,t,s,r,o){if(s===r||!e.terminals[s]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const f=g.tabs.findIndex(E=>E.id===t);if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y=wl(b.root,s);if(!y){const E=g.tabs.filter((T,B)=>B!==f);return{...g,tabs:E}}const w={...b,root:y,activeTerminalId:Oi(y)[0]??b.activeTerminalId},S=g.tabs.slice();return S[f]=w,{...g,tabs:S}});const h=o==="left"||o==="right"?"vertical":"horizontal",p=o==="left"||o==="top";return c=c.map(g=>{const f=g.tabs.findIndex(T=>Oi(T.root).includes(r));if(f<0)return g;const b=g.tabs[f];if(!b)return g;const y={type:"pane",terminalId:s},w={type:"split",direction:h,ratio:.5,first:p?y:{type:"pane",terminalId:r},second:p?{type:"pane",terminalId:r}:y},S=sc(b.root,r,w),E=g.tabs.slice();return E[f]={...b,root:S,activeTerminalId:s},{...g,tabs:E,activeTabId:b.id}}),D1({...e,workspaces:c})}function x1(e,t,s,r){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const A=e.workspaces[B].tabs.findIndex(N=>N.id===t);if(A>=0){o=B,c=A;break}}if(o<0)return e;const h=e.workspaces[o],p=h.tabs[c],g=Oi(p.root);if(!g.includes(s))return e;if(g.length===1)return Rg(e,t,r);const f=wl(p.root,s);if(!f)return e;const b={...p,root:f,activeTerminalId:Oi(f)[0]??p.activeTerminalId},y=e.terminals[s],w={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:y?.title??"",activeTerminalId:s,root:{type:"pane",terminalId:s}},S=h.tabs.slice();S[c]=b;const E=Math.max(0,Math.min(S.length,r));S.splice(E,0,w);const T=e.workspaces.slice();return T[o]={...h,tabs:S,activeTabId:w.id},{...e,workspaces:T}}function E1(e,t,s,r=Number.MAX_SAFE_INTEGER){const o=R1(e.workspaces,t),c=e.workspaces.find(f=>f.id===s);if(!o||!c)return e;if(o.workspace.id===s)return r===Number.MAX_SAFE_INTEGER?e:Rg(e,t,r);const h=Oi(o.tab.root),p=h.map(f=>e.terminals[f]).find(Boolean),g=e.workspaces.map(f=>{if(f.id===o.workspace.id)return Ta({...f,tabs:f.tabs.filter(b=>b.id!==t)});if(f.id===s){const b=f.tabs.slice(),y=Math.max(0,Math.min(b.length,r));return b.splice(y,0,o.tab),{...f,defaultCwd:f.defaultCwd??ss(p?.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(w=>!h.includes(w)),tabs:b,activeTabId:o.tab.id}}return f});return{...e,workspaces:g,activeWorkspaceId:s}}function L3(e,t,s,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(S=>S.id===r),h=R1(e.workspaces,t);if(!c||!h||!e.terminals[s]||!Oi(h.tab.root).includes(s))return e;if(h.workspace.id===r)return x1(e,t,s,o);if(Oi(h.tab.root).length===1)return E1(e,t,r,o);const g=wl(h.tab.root,s);if(!g)return e;const f={...h.tab,root:g,activeTerminalId:Oi(g)[0]??h.tab.activeTerminalId},b=e.terminals[s],y={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:b.title??s,activeTerminalId:s,root:{type:"pane",terminalId:s}},w=e.workspaces.map(S=>{if(S.id===h.workspace.id)return Ta({...S,tabs:S.tabs.map(E=>E.id===t?f:E)});if(S.id===r){const E=S.tabs.slice(),T=Math.max(0,Math.min(E.length,o));return E.splice(T,0,y),{...S,defaultCwd:S.defaultCwd??ss(b.cwd),detachedTerminalIds:S.detachedTerminalIds.filter(B=>B!==s),tabs:E,activeTabId:y.id}}return S});return{...e,workspaces:w,activeWorkspaceId:r}}function B3(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function O3(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function z3(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>{let p=!1;const g=h.tabs.map(f=>f.id!==t||f.title===r?f:(o=!0,p=!0,{...f,title:r}));return p?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function j3(e,t){const s=e.workspaces.find(o=>o.tabs.some(c=>Cl(c.root,t))),r=s?.tabs.find(o=>Cl(o.root,t));return!s||!r?e:{...e,activeWorkspaceId:s.id,workspaces:e.workspaces.map(o=>o.id===s.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function H3(e,t,s){const r=ka(e),o=r?Rh(r):void 0;if(!r||!o)return e;const c=Nm(o.root,t,z1(s));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===r.id?{...h,tabs:h.tabs.map(p=>p.id===o.id?{...p,root:c}:p)}:h)}}function Em(e,t,s,r){const o=Object.fromEntries(e.map(y=>[y.id,y])),c=new Set(e.map(y=>y.id)),h=new Set,p=!!(s&&s.some(y=>B1(y))||t&&t.some(y=>O1(y)));let g=F3(t,s,c,h);g.length===0&&(g=[Mh()]);const f=typeof r=="string"&&g.some(y=>y.id===r)?r:g[0]?.id??null,b=f??g[0]?.id??Dh;for(const y of e)if(!h.has(y.id)){if(p)g=$3(g,b,y.id,y);else{const w=L1(y);g=V3(g,b,w,y)}h.add(y.id)}return{workspaces:g.map(y=>Ta(Y3(y,o))),activeWorkspaceId:f,terminals:o}}function nc(e){return Oi(e.root)}function km(e){return Am(e.root)}function oh(e){return Mg([...e.tabs.flatMap(t=>Oi(t.root)),...e.detachedTerminalIds])}function op(e){const t=e.workspaces.map(s=>{const r=s.tabs.flatMap(o=>{const c=Rm(o.root);return c?[{...o,root:c}]:[]});return Ta({...s,tabs:r})});return{activeWorkspaceId:t.some(s=>s.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function U3(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(s=>({...s,tabs:s.tabs.map(r=>Cl(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function P3(e,t,s){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:s}}}:e}function k1(e,t){const s={...e.terminals};return delete s[t],T1(e,t,s)}function I3(e,t,s){if(!e.terminals[t])return e;const r=(s&&e.workspaces.some(c=>c.id===s)?s:null)??W3(e,t)?.id??q3(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Dh,o=e.workspaces.find(c=>c.id===r);return!o||!N1(o,t)?e:T1(e,t,{...e.terminals},{detachToWorkspaceId:r})}function T1(e,t,s,r={}){let o=e.workspaces.map(h=>{const p=[];for(const g of h.tabs){const f=wl(g.root,t);if(!f)continue;const b=Oi(f),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&p.push({...g,root:f,activeTerminalId:y})}return Ta({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:p})});r.detachToWorkspaceId&&s[t]&&(o=o.map(h=>h.id===r.detachToWorkspaceId?M1(h,t,s[t]):h));const c=o.some(h=>h.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:s}}function K3(e,t){const s=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const p=Tm(h.root,t);if(!p)continue;const g=Oi(p),f=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];f&&c.push({...h,root:p,activeTerminalId:f})}return Ta({...o,tabs:c})}),r=s.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:s,activeWorkspaceId:r?e.activeWorkspaceId:s[0]?.id??null}}function F3(e,t,s,r){if(t&&t.length>0){const o=[];for(const c of t)B1(c)&&o.push(a0(c,s,r));if(o.length>0)return o}return[a0({...Mh(),tabs:e??[]},s,r)]}function a0(e,t,s){const r=[];for(const c of e.tabs){if(!O1(c))continue;const h=Dm(c.root,t);if(!h)continue;const p=Oi(h);for(const f of p)s.add(f);const g=p.includes(c.activeTerminalId)?c.activeTerminalId:p[0];g&&r.push({...c,root:h,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||s.has(c)||(s.add(c),o.push(c));return Ta({...e,defaultCwd:ss(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function D1(e){return ka(e)?e:{...e,workspaces:[Mh()],activeWorkspaceId:Dh}}function ka(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Rh(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function R1(e,t){for(const s of e){const r=s.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:s,tab:s.tabs[r],tabIndex:r}}return null}function W3(e,t){return e.workspaces.find(s=>s.tabs.some(r=>Cl(r.root,t)))}function q3(e,t){return e.workspaces.find(s=>s.detachedTerminalIds.includes(t))}function $3(e,t,s,r){return e.map(o=>o.id===t?M1(o,s,r):o)}function M1(e,t,s){return N1(e,t)?{...e,defaultCwd:e.defaultCwd??ss(s?.cwd),detachedTerminalIds:Mg([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function N1(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<kl}function A1(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(s=>s!==t)}:e}function Y3(e,t){if(e.defaultCwd)return e;const s=oh(e).find(o=>!!t[o]),r=s?ss(t[s]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Mh(){return{id:Dh,title:b3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Ta(e){const t=e.tabs.some(s=>s.id===e.activeTabId);return{...e,defaultCwd:ss(e.defaultCwd),detachedTerminalIds:Mg(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function V3(e,t,s,r){const o=Oi(s.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??ss(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,s],activeTabId:c.activeTabId??s.id}:c)}function L1(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function sc(e,t,s){return e.type==="pane"?e.terminalId===t?s:e:e.type==="editor"?e:{...e,first:sc(e.first,t,s),second:sc(e.second,t,s)}}function wl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const s=wl(e.first,t),r=wl(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Tm(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const s=Tm(e.first,t),r=Tm(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Dm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const s=Dm(e.first,t),r=Dm(e.second,t);return s&&r?{...e,ratio:z1(e.ratio),first:s,second:r}:s??r}function Rm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Rm(e.first),s=Rm(e.second);return t&&s?{...e,first:t,second:s}:t??s}function B1(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 O1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Mm(t.root)}function Mm(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")&&Mm(t.first)&&Mm(t.second):!1}function Nm(e,t,s){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===s?e:{...e,ratio:s};const[r,...o]=t;if(r===0){const c=Nm(e.first,o,s);return c===e.first?e:{...e,first:c}}if(r===1){const c=Nm(e.second,o,s);return c===e.second?e:{...e,second:c}}return e}function z1(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function ss(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Mg(e){const t=new Set,s=[];for(const r of e)!r||t.has(r)||(t.add(r),s.push(r));return s}function Cl(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:Cl(e.first,t)||Cl(e.second,t)}function Oi(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Oi(e.first),...Oi(e.second)]}function Am(e){return e.type==="pane"||e.type==="editor"?1:Am(e.first)+Am(e.second)}const Hr=new Map,rc=new Map,ac=new Map;function Rl(e){return e??"__local__"}function X3(e){return{agentId:e,state:S3(),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 Mt(e){const t=Rl(e);let s=Hr.get(t);return s||(s=X3(e),Hr.set(t,s)),s}function j1(e,t){const s=Rl(e);let r=rc.get(s);return r||(r=new Set,rc.set(s,r)),r.add(t),()=>{r.delete(t)}}function G3(e){const t=Rl(e),s=rc.get(t);if(s)for(const r of Array.from(s))r()}function Ml(e,t){Hr.set(Rl(e),t),G3(e)}const Lm=new Set;function Z3(e){return Lm.add(e),()=>{Lm.delete(e)}}function Do(e,t){const s=Mt(e),r=Rl(e);t.type==="workspace.hydrated"&&ac.delete(r);const o=w3(s.state,t);let c=s.unreadCompletions,h=null;if(t.type==="terminal.updated"){const f=s.state.terminals[t.terminal.id],b=f?.activity==="busy",y=t.terminal.activity==="busy",w=t.terminal.activity==="idle",S=rA(r);if(t.notifyCompletion===!0&&y&&S.add(t.terminal.id),t.notifyCompletion===!0&&b&&w&&S.has(t.terminal.id)){const E=Q3(o,t.terminal.id);E&&(h={terminalId:t.terminal.id,tabId:E.tab.id,commandName:f?.currentCommand??null},(E.workspace.activeTabId!==E.tab.id||E.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id))))}(w||t.terminal.status==="exited")&&S.delete(t.terminal.id)}if(t.type==="tab.selected"||t.type==="workspace.selected"){let f=null;if(t.type==="tab.selected")f=J3(o,t.tabId)?.tab??null;else{const y=o.workspaces.find(w=>w.id===t.workspaceId);f=y?.tabs.find(w=>w.id===y.activeTabId)??null}const b=f?Oi(f.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const w of b)y.delete(w);c=y}}const p=o!==s.state,g=c!==s.unreadCompletions;if((p||g)&&Ml(e,{...s,state:o,unreadCompletions:c}),g&&Ng(),h)for(const f of Array.from(Lm))f({agentId:e,...h})}function Q3(e,t){for(const s of e.workspaces)for(const r of s.tabs)if(Oi(r.root).includes(t))return{workspace:s,tab:r};return null}function J3(e,t){for(const s of e.workspaces){const r=s.tabs.find(o=>o.id===t);if(r)return{workspace:s,tab:r}}return null}const Bm=new Set;function eA(e){return Bm.add(e),()=>{Bm.delete(e)}}function tA(){let e=0;for(const t of Hr.values())e+=t.unreadCompletions.size;return e}function Ng(){for(const e of Array.from(Bm))e()}function iA(e,t){const s=Mt(e);if(!s.unreadCompletions.has(t))return;const r=new Set(s.unreadCompletions);r.delete(t),Ml(e,{...s,unreadCompletions:r}),Ng()}function l0(e,t){const s=Mt(e);t!==s.state&&Ml(e,{...s,state:t})}function cp(e,t){const s=Mt(e),r=t(s.editors);r!==s.editors&&Ml(e,{...s,editors:r})}function Er(e,t,s){const r=Mt(e);r.loaded===t&&r.error===s||Ml(e,{...r,loaded:t,error:s})}function Ro(e,t,s){const r=Mt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===s||Ml(e,{...r,layoutRevision:t,lastPersistedLayoutJson:s})}function nA(e){const t=Mt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function sA(e){const t=Rl(e),s=Hr.get(t);s&&s.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(s.mutable.saveCoord.saveTimer);const r=s?s.unreadCompletions.size>0:!1;Hr.delete(t),rc.delete(t),ac.delete(t),r&&Ng()}function up(){for(const e of Hr.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Hr.clear(),rc.clear(),ac.clear()}function rA(e){let t=ac.get(e);return t||(t=new Set,ac.set(e,t)),t}function Om(e,t){let s=!1,r=!1,o=null,c=!1;for(const h of nc(e)){const p=t[h];if(p){if(p.status==="exited"){c=!0,s=!0;continue}p.activity==="busy"?(r=!0,s=!0,!o&&p.currentCommand&&(o=p.currentCommand)):p.activity==="idle"&&(s=!0)}}return s?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Ag(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function zm(e,t){const s=t[e.activeTerminalId];return e.title||s?.title||e.activeTerminalId}function aA(e,t,s,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${s} pane${s===1?"":"s"}`}function lA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:p,onCloseTerminals:g,onReattachTerminal:f,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:w,onRenameTab:S,activePaneAvailable:E}){const[T,B]=v.useState(null),[A,N]=v.useState(!1),[I,P]=v.useState(null),te=v.useRef(null),Q=e.findIndex(K=>K.id===t),le=Q>=0?e[Q]:e[0]??null,oe=le?Om(le,s):null,ve=le?km(le):0,Ce=le?zm(le,s):"No tab";v.useEffect(()=>{te.current?.focus(),te.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!A)return;const K=se=>{se.key==="Escape"&&N(!1)};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[A]),v.useEffect(()=>{A&&e.length===0&&N(!1)},[A,e.length]);function ie(K,se){B({tabId:K,title:se})}function J(){if(!T)return;const K=T.title.trim();K&&S(T.tabId,K),B(null)}function F(){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 - ${zk()}`,onClick:y,disabled:!E,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 - ${jk()}`,onClick:w,disabled:!E,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:Ce,onClick:()=>N(!0),disabled:e.length===0,children:[oe?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":oe.state,"aria-hidden":"true",title:Ag(oe)}):null,m.jsx("span",{children:Ce}),m.jsxs("small",{children:[Q>=0?Q+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((K,se)=>{const L=nc(K),Y=km(K),D=zm(K,s),Z=K.id===t,ge=T?.tabId===K.id,R=Om(K,s),H=r?.has(K.id)??!1;return m.jsxs(Ei.Fragment,{children:[m.jsx(o0,{index:se}),m.jsx(oA,{tab:K,active:Z,editing:ge,title:D,paneCount:Y,terminalIds:L,canClose:e.length>1,editValue:ge?T.title:null,editInputRef:ge?te:null,activity:R,unread:H,onSelect:()=>c(K.id),onBeginRename:()=>ie(K.id,D),onCloseAll:()=>g(L),onCommitRename:J,onCancelRename:()=>B(null),onRenameChange:ee=>B({tabId:K.id,title:ee})})]},K.id)}),m.jsx(o0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(o?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(K=>m.jsx(uA,{terminal:K,onReattach:()=>f?.(K.id),onDelete:()=>P(K)},K.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),E?F():null]}),A?m.jsx(cA,{tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:T,editInputRef:te,onClose:()=>N(!1),onSelectTab:K=>{c(K),N(!1)},onCreateTab:()=>{h(),N(!1)},onBeginRename:ie,onCloseTerminals:K=>{g(K),N(!1)},onCommitRename:J,onCancelRename:()=>B(null),onRenameChange:(K,se)=>B({tabId:K,title:se}),onReattachTerminal:K=>{f?.(K),N(!1)},onDeleteTerminal:K=>{P(K),N(!1)}}):null,I?m.jsx(hA,{terminal:I,onCancel:()=>P(null),onConfirm:()=>{b?.(I.id),P(null)}}):null]})}function oA({tab:e,active:t,editing:s,title:r,paneCount:o,canClose:c,editValue:h,editInputRef:p,activity:g,unread:f,onSelect:b,onBeginRename:y,onCloseAll:w,onCommitRename:S,onCancelRename:E,onRenameChange:T}){const{attributes:B,listeners:A,setNodeRef:N,transform:I,isDragging:P}=K0({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:s}),te={transform:mp.Translate.toString(I),opacity:P?.4:void 0,zIndex:P?2:void 0};return m.jsxs("div",{ref:N,className:"terminal-tab","data-active":t,"data-dragging":P,"data-unread":f?"true":void 0,style:te,...B,...A,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Ag(g)}):null,s&&p&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:Q=>{Q.preventDefault(),S()},children:[m.jsx("input",{ref:p,"aria-label":`Rename ${r}`,value:h,onBlur:S,onChange:Q=>T(Q.target.value),onKeyDown:Q=>{if(Q.key==="Enter"){Q.preventDefault(),S();return}Q.key==="Escape"&&(Q.preventDefault(),E())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:b,onDoubleClick:Q=>{Q.preventDefault(),y()},children:[m.jsx("span",{children:r}),m.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!s?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:Q=>Q.stopPropagation(),onClick:Q=>{Q.stopPropagation(),w()},children:"x"}):null]})}function cA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:p,onSelectTab:g,onCreateTab:f,onBeginRename:b,onCloseTerminals:y,onCommitRename:w,onCancelRename:S,onRenameChange:E,onReattachTerminal:T,onDeleteTerminal:B}){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:N=>N.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((N,I)=>{const P=nc(N),te=km(N),Q=zm(N,s),le=N.id===t,oe=c?.tabId===N.id,ve=Om(N,s),Ce=r?.has(N.id)??!1;return m.jsxs("div",{ref:le?A:null,className:"mobile-tab-sheet-row","data-active":le,"data-unread":Ce?"true":void 0,children:[oe&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ie=>{ie.preventDefault(),w()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${Q}`,value:c.title,onBlur:w,onChange:ie=>E(N.id,ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),w();return}ie.key==="Escape"&&(ie.preventDefault(),S())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${Q}`,onClick:()=>g(N.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:I+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:Q}),m.jsx("small",{children:aA(N,s,te,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:Ag(ve)}):null,m.jsx("span",{children:te})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[oe?m.jsx("button",{type:"button","aria-label":`Done renaming ${Q}`,onClick:w,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${Q}`,onClick:()=>b(N.id,Q),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${Q}`,onClick:()=>y(P),children:"×"}):null]})]},N.id)}),(o?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(o??[]).map(N=>{const I=N.title||N.cwd||N.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 ${I}`,onClick:()=>T(N.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:I}),m.jsx("small",{children:N.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 ${I}`,onClick:()=>B(N),children:"×"})})]},N.id)})]}):null]})]})})}function o0({index:e}){const{setNodeRef:t,isOver:s}=Zm({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":s,"aria-hidden":"true"})}function uA({terminal:e,onReattach:t,onDelete:s}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
53
|
+
${e.cwd}
|
|
54
|
+
(detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:o,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),s()},children:"×"})]})}function hA({terminal:e,onCancel:t,onConfirm:s}){const r=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:o=>o.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:r}),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:s,children:"Delete"})]})]})})}function dA({uploads:e,onDismiss:t,onDismissAll:s,onRetry:r,onCancel:o}){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-${_A(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?Fu(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:s,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(fA,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function fA({upload:e,compact:t,onDismiss:s,onRetry:r,onCancel:o}){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":Fu(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:Fu(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[p?m.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${Fu(e)}`,onClick:s,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(pA,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(mA,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function pA({toast:e}){const t=e.percent===null?vA(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 mA({response:e,compact:t}){const s=e.results.filter(h=>h.status==="failed"),r=e.results.filter(h=>h.status==="uploaded"),o=t?3:6,c=[...s,...r].slice(0,o);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(gA,{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 gA({result:e}){const t=e.savedRelativePath??e.relativePath,s=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}),s?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 Fu(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,s=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${s} files`}return"Upload failed"}function _A(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 vA(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function yA({toast:e,onActivate:t,onDismiss:s}){if(!e)return null;const r=e,o=r.commandName?`${r.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),s()}function h(p){p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(r))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:h,children:[m.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:r.tabTitle}),m.jsx("span",{children:o})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,children:"x"})]})}const bA=Uo(0,0,1,1),Ks=1e-6;function SA(e){return H1(e).map(t=>t.terminalId)}function H1(e){return Ho(e,bA).sort(EA).map((t,s)=>({...t,index:s+1}))}function wA(e,t,s){const r=H1(e),o=r.find(h=>h.terminalId===t);return o?r.filter(h=>h.terminalId!==t).map(h=>xA(o,h,s)).filter(h=>h!==null).sort(kA)[0]?.entry.terminalId??null:null}function CA(e,t){return!Number.isInteger(t)||t<1?null:SA(e)[t-1]??null}function Ho(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const s=TA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*s;return[...Ho(e.first,Uo(t.left,t.top,o,t.bottom)),...Ho(e.second,Uo(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*s;return[...Ho(e.first,Uo(t.left,t.top,t.right,r)),...Ho(e.second,Uo(t.left,r,t.right,t.bottom))]}function xA(e,t,s){const r=e.bounds,o=t.bounds,c=c0(r.left,r.right,o.left,o.right),h=c0(r.top,r.bottom,o.top,o.bottom);switch(s){case"left":return o.centerX>=r.centerX-Ks||h<=Ks?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"right":return o.centerX<=r.centerX+Ks||h<=Ks?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"up":return o.centerY>=r.centerY-Ks||c<=Ks?null:{entry:t,primaryDistance:Math.max(0,r.top-o.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};case"down":return o.centerY<=r.centerY+Ks||c<=Ks?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function EA(e,t){return ml(e.bounds.top,t.bounds.top)||ml(e.bounds.left,t.bounds.left)}function kA(e,t){return ml(e.primaryDistance,t.primaryDistance)||ml(e.perpendicularDistance,t.perpendicularDistance)||ml(t.overlap,e.overlap)||ml(e.entry.index,t.entry.index)}function ml(e,t){const s=e-t;return Math.abs(s)<=Ks?0:s}function c0(e,t,s,r){return Math.max(0,Math.min(t,r)-Math.max(e,s))}function Uo(e,t,s,r){return{left:e,top:t,right:s,bottom:r,centerX:e+(s-e)/2,centerY:t+(r-t)/2}}function TA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class DA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function u0(e){return e?Array.from(e.types??[]).includes("Files")||K1(e.items).some(s=>s.kind==="file")?!0:F1(e.files).length>0:!1}async function RA(e){const t=K1(e.items).filter(s=>s.kind==="file");return t.length>0?MA(t):NA(e.files)}async function MA(e){const t=[];for(const s of e){const r=OA(s);if(r){await U1(r,"",t);continue}const o=s.getAsFile();if(o){t.push({relativePath:P1(o),file:o});continue}throw new DA("Folder upload is not supported by this browser.")}return t}function NA(e){return F1(e).map(t=>({relativePath:P1(t),file:t}))}async function U1(e,t,s){const r=jA(t,e.name);if(e.isFile){const h=await AA(e);s.push({relativePath:r,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await LA(o);for(const h of c)await U1(h,r,s)}function AA(e){return new Promise((t,s)=>{e.file(t,r=>s(r))})}async function LA(e){const t=[];for(;;){const s=await BA(e);if(s.length===0)return t;t.push(...s)}}function BA(e){return new Promise((t,s)=>{e.readEntries(t,r=>s(r))})}function P1(e){const t=e.webkitRelativePath;return I1(typeof t=="string"&&t?t:e.name)}function OA(e){const t=e.webkitGetAsEntry?.();return zA(t)?t:null}function zA(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 jA(e,t){return I1(e?`${e}/${t}`:t)}function I1(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function K1(e){return e?Array.from(e):[]}function F1(e){return e?Array.from(e):[]}const h0="nterminal.terminalWorkspaces.v2",W1="nterminal.sidebarCollapsed.v1",HA=75,d0=q0.map(e=>e.url),UA=q0[0].url,PA=6;function IA({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:h}){const p=v.useMemo(()=>e??dh(),[e]),g=v.useMemo(()=>t??Xo(null),[t]),f=v.useMemo(()=>r5(s),[s]),b=v.useMemo(()=>x=>j1(s,x),[s]),y=v.useMemo(()=>()=>Mt(s),[s]),w=v.useSyncExternalStore(b,y,y),S=w.state,E=w.editors,T=!w.loaded,B=w.error,[A,N]=v.useState(!1),[I,P]=v.useState(()=>d5()),[te,Q]=v.useState("servers"),[le,oe]=v.useState(!1),ve=v.useSyncExternalStore(Yk,Ub,Ub);v.useSyncExternalStore(cg,Hb,Hb);const[Ce,ie]=v.useState(0),[J,F]=v.useState(null),[K,se]=v.useState(()=>[null]),[L,Y]=v.useState(0),[D,Z]=v.useState(()=>[s]),[ge,R]=v.useState(()=>new Set),[H,ee]=v.useState({}),[he,we]=v.useState(null),xe=v.useRef(0),Re=v.useRef(0),[Ye,_e]=v.useState(null),[X,ce]=v.useState(null),Ee=v.useRef(null),be=v.useRef(0),De=v.useRef(null),Be=v.useRef(null),Ie=v.useRef(null),[ae,Te]=v.useState(null),Le=kE(bb(j0,{activationConstraint:{distance:8}}),bb(H0,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>Vk(p),[p]);function Oe(x){const k=x.active.data.current;if(k){if(k.kind==="tab"&&typeof k.tabId=="string"&&typeof k.terminalId=="string"){Te({tabId:k.tabId,terminalId:k.terminalId});return}k.kind==="pane"&&typeof k.sourceTabId=="string"&&typeof k.terminalId=="string"&&Te({tabId:k.sourceTabId,terminalId:k.terminalId})}}function ze(x){Te(null);const k=x.active.data.current,j=x.over?.data.current;if(!(!k||!j||typeof k.terminalId!="string")){if(k.kind==="tab"&&typeof k.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){rt({type:"tab.reordered",sourceTabId:k.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){rt({type:"tab.moved_to_workspace",sourceTabId:k.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:k.tabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(k.kind==="pane"&&typeof k.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){rt({type:"terminal.extracted_to_tab",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){rt({type:"terminal.extracted_to_workspace",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function ht(){Te(null)}const Xe=S.workspaces.find(x=>x.id===S.activeWorkspaceId)??S.workspaces[0],ot=Xe?.tabs.find(x=>x.id===Xe.activeTabId)??Xe?.tabs[0],gi=ot?.activeTerminalId??null,Ji=gi?S.terminals[gi]:void 0,qi=i5("(max-width: 760px)"),$t=v.useMemo(()=>ot?ch(ot.root):[],[ot]),_i=Xe&&ot?Po(s,Xe.id,ot.id):null,_n=ot?q1($t,ot.activeTerminalId,_i?H[_i]:void 0):null,W=qi&&$t.length>1,We=v.useMemo(()=>(Xe?.detachedTerminalIds??[]).flatMap(x=>{const k=S.terminals[x];return k?[k]:[]}),[Xe?.detachedTerminalIds,S.terminals]),ut=v.useMemo(()=>{const x=new Set;for(const k of Xe?.tabs??[])nc(k).some(j=>w.unreadCompletions.has(j))&&x.add(k.id);return x},[Xe?.tabs,w.unreadCompletions]),[gt,vi]=v.useState([]),bt=v.useRef([]),It=v.useRef(null),[en,An]=v.useState(null),[yi,ln]=v.useState(null),[Et,kt]=v.useState([]),[Tt,bi]=v.useState(()=>ba()),ii=v.useRef(0),Yt=v.useRef(s),oi=v.useRef(d0),Ti=v.useRef(Tt),Dt=v.useRef(()=>{});Dt.current=O;const ji=v.useCallback(async()=>{try{const x=await p.listNotificationAssets();kt(x.assets.filter(k=>k.enabled).map(k=>k.url))}catch{kt([])}},[p]);v.useEffect(()=>{Z(x=>x.some(k=>mn(k,s))?x:[...x,s])},[s]);const ni=v.useCallback(x=>{const k=Mt(x),j=Xo(x);for(const ne of Object.keys(k.state.terminals))jo(j.createWebSocketUrl(ne)),Mu(ne);sA(x),Z(ne=>ne.filter(ye=>!mn(ye,x))),R(ne=>{const ye=`${qu(x)}:`;let me=!1;const Se=new Set;for(const He of ne){if(He.startsWith(ye)){me=!0;continue}Se.add(He)}return me?Se:ne}),ee(ne=>{const ye=`${qu(x)}:`;let me=!1;const Se={};for(const[He,tt]of Object.entries(ne)){if(He.startsWith(ye)){me=!0;continue}Se[He]=tt}return me?Se:ne})},[]);v.useEffect(()=>{let x=!1;return p.listAgents().then(k=>{if(!x){const j=k.agents.map(ye=>ye.id),ne=[null,...j];s!==null&&!j.includes(s)&&(ni(s),r?.(null)),se(ne)}}).catch(()=>{}),()=>{x=!0}},[s,p,ni,r,L]);const $i=v.useCallback(x=>{ni(x),Y(k=>k+1),mn(x,Yt.current)&&r?.(null)},[ni,r]);v.useEffect(()=>{se(x=>x.some(k=>mn(k,s))?x:[...x,s])},[s]),v.useEffect(()=>{Yt.current=s},[s]),v.useEffect(()=>{F(null)},[s]),v.useEffect(()=>{const x=De.current;if(!x)return;if(!mn(x.agentId,s)){De.current=null;return}if(!w.loaded||S.workspaces.length===0)return;De.current=null;const k=x.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];k&&k.id!==S.activeWorkspaceId&&rt({type:"workspace.selected",workspaceId:k.id})},[s,w.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const x=Be.current;if(x){if(!mn(x.agentId,s)){Be.current=null;return}w.loaded&&(Be.current=null,S.workspaces.some(k=>k.id===x.workspaceId)&&rt({type:"workspace.selected",workspaceId:x.workspaceId}))}},[s,w.loaded,S.workspaces]),v.useEffect(()=>{const x=Ie.current;if(x){if(!mn(x.agentId,s)){Ie.current=null;return}w.loaded&&(Ie.current=null,w.error||_t())}},[s,w.error,w.loaded]),v.useEffect(()=>{ji()},[ji]),v.useEffect(()=>J0(()=>bi(ba())),[]),v.useEffect(()=>{const x=k=>{Dt.current(k)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{oi.current=Et.length>0?Et:d0},[Et]),v.useEffect(()=>{Ti.current=Tt},[Tt]),v.useEffect(()=>{if(!w.loaded||!Xe||!ot)return;const x=Po(s,Xe.id,ot.id);R(k=>{if(k.has(x))return k;const j=new Set(k);return j.add(x),j})},[s,w.loaded,Xe?.id,ot?.id]),v.useEffect(()=>()=>{Al()},[]),v.useEffect(()=>Z3(x=>{const k=Mt(x.agentId).state,j=k.workspaces.flatMap(Se=>Se.tabs).find(Se=>Se.id===x.tabId),ne=k.terminals[x.terminalId],ye=j?.title?.trim()||ne?.title||x.commandName||"terminal",me=document.visibilityState==="visible"&&mn(x.agentId,Yt.current)&&x.tabId===s5(k);if(me||Tk({tabTitle:ye,commandName:x.commandName,terminalId:x.terminalId}),!me&&document.visibilityState==="visible"&&Ti.current.enabled){const Se=ii.current+1;ii.current=Se;const He=oi.current;An({id:Se,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:ye,commandName:x.commandName,assetSrc:He[Math.floor(Math.random()*He.length)]??UA})}}),[]),v.useEffect(()=>{if(!en||Tt.persistUntilDismissed)return;const x=window.setTimeout(()=>{An(k=>k?.id===en.id?null:k)},Tt.durationSeconds*1e3);return()=>window.clearTimeout(x)},[en,Tt]),v.useEffect(()=>{f5(I),I&&tn()},[I]),v.useEffect(()=>{let x=!1;async function k(){if(!Mt(s).loaded){Er(s,!1,null);try{let ne=null,ye=null;try{ne=a5(f)}catch(tt){if(!(tt instanceof hh))throw tt;ye=tt}const[me,Se]=await Promise.all([g.listTerminals(),g.getTerminalLayout()]),He=me.terminals.length>0?me.terminals:[(await g.createTerminal({cols:80,rows:24})).terminal];if(!x){const tt=Se.layout?Y1(Se.layout):null;if(!tt&&ye)throw ye;const Zt=tt??ne??{},si=Em(He,void 0,Zt.savedWorkspaces,Zt.savedActiveWorkspaceId),Aa=op(si);l0(s,si),Ro(s,Se.revision,JSON.stringify(Aa)),Er(s,!0,null),!tt&&ne&&Na(Aa,{baseRevision:Se.revision})}}catch(ne){!x&&!ls(ne)&&Er(s,!0,kr(ne))}}}return k(),()=>{x=!0}},[s,g,Ce]);function vn(){Er(s,!1,null),ie(x=>x+1)}function tn(){xe.current+=1,Re.current+=1,we(null)}function Hi(x){xe.current+=1,Re.current+=1,we(k=>k&&{...k,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function _t(){xe.current+=1,Re.current+=1;const x=S.workspaces.length+1,k=Vt();we({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),k&&At(k)}function Ui(x){if(mn(x,s)){_t();return}Ie.current={agentId:x},r?.(x)}function Kt(x){if(I&&!A)return;const k=S.workspaces.find(ne=>ne.id===x);if(!k)return;xe.current+=1,Re.current+=1;const j=k.defaultCwd??Ji?.cwd??"";we({mode:"edit",workspaceId:x,title:k.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&At(j)}function Vt(){return Xe?.defaultCwd??Ji?.cwd??""}async function At(x){const k=xe.current+1;xe.current=k;const j=x.trim();if(we(ne=>ne&&{...ne,cwd:x,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const ne=await g.createFileRoot({path:j}),ye=await g.listFiles({rootToken:ne.rootToken,path:""});if(xe.current!==k)return;we(me=>me&&{...me,cwd:ne.rootPath,browseRoot:{rootToken:ne.rootToken,rootPath:ne.rootPath},browseEntries:ye.entries.filter(Se=>Se.kind==="directory"),browseStatus:"idle",error:null})}catch(ne){if(xe.current!==k)return;we(ye=>ye&&{...ye,browseStatus:"idle",error:kr(ne)})}}async function Ur(){const x=he;if(!x)return;const k=x.title.trim(),j=x.cwd.trim();if(!k||!j){we({...x,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const ne=Re.current+1;Re.current=ne,we({...x,submitStatus:"submitting",error:null});try{const ye=await g.createFileRoot({path:j});if(Re.current!==ne)return;if(x.mode==="create"){const me=S.workspaces.length+1;rt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${me}`,title:k,defaultCwd:ye.rootPath})}else x.workspaceId&&(rt({type:"workspace.renamed",workspaceId:x.workspaceId,title:k}),rt({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:ye.rootPath}));we(null)}catch(ye){if(Re.current!==ne)return;we(me=>me&&{...me,submitStatus:"idle",error:kr(ye)})}}function Da(x){Re.current+=1,we(x)}function Pr(x,k,j){if(x===k)return;const ne=S.workspaces.some(me=>me.id===x),ye=S.workspaces.some(me=>me.id===k);!ne||!ye||rt({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:k,placement:j})}function Ir(x,k){const j=S.workspaces.findIndex(ye=>ye.id===x),ne=S.workspaces[j+k];j<0||!ne||Pr(x,ne.id,k<0?"before":"after")}function bs(x,k){k.pointerType==="mouse"&&k.button!==0||(k.preventDefault(),k.stopPropagation(),Ee.current={sourceId:x,pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,active:!1,targetId:null,placement:"after"},k.currentTarget.setPointerCapture?.(k.pointerId))}function Ys(x){const k=Ee.current;if(!k||k.pointerId!==x.pointerId)return;const j=Math.hypot(x.clientX-k.startX,x.clientY-k.startY);if(!k.active){if(j<PA)return;k.active=!0,_e(k.sourceId)}const ye=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),me=ye?.dataset.workspaceId??null;if(!ye||!me||me===k.sourceId||!S.workspaces.some(tt=>tt.id===me)){k.targetId=null,ce(null);return}const Se=ye.getBoundingClientRect(),He=x.clientY<Se.top+Se.height/2?"before":"after";k.targetId=me,k.placement=He,ce({workspaceId:me,placement:He})}function Yi(x){const k=Ee.current;!k||k.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),Ee.current=null,_e(null),ce(null),k.active&&k.targetId&&Pr(k.sourceId,k.targetId,k.placement))}function Ln(x){const k=Ee.current;k&&k.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),Ee.current=null,_e(null),ce(null)}async function rs(){await Ft(async()=>{const x=Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},k=await g.createTerminal(x);rt({type:"terminal.created",terminal:k.terminal})})}async function yn(x){await Ft(async()=>{const k=gi?{parentTerminalId:gi,cols:80,rows:24}:Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},j=await g.createTerminal(k);rt({type:"terminal.split",terminal:j.terminal,direction:x})})}async function Xt(x){let k=gi,j=_i;const ne=Xe?.defaultCwd?.trim();if(!k&&!ne)throw new Error("No active pane is available.");const ye=await g.readFile(x);if(!k&&ne){const He=await g.createTerminal({cols:80,rows:24,cwd:ne});k=He.terminal.id,rt({type:"terminal.created",terminal:He.terminal})}if(k){rt({type:"pane.selected",terminalId:k});const He=Mt(s).state,tt=He.workspaces.find(si=>si.id===He.activeWorkspaceId)??He.workspaces[0],Zt=tt?.tabs.find(si=>si.id===tt.activeTabId)??tt?.tabs[0];j=tt&&Zt?Po(s,tt.id,Zt.id):null}const me=`editor-${Date.now().toString(36)}-${nA(s)}`,Se=h5(ye.path);cp(s,He=>({...He,[me]:{id:me,title:Se,rootToken:x.rootToken,path:ye.path,read:ye}})),j&&ee(He=>({...He,[j]:$1(me)})),rt({type:"editor.split",editorId:me,title:Se,direction:"vertical"})}function Kr(x){cp(s,k=>{const j={...k};return delete j[x],j}),rt({type:"editor.closed",editorId:x})}function Vs(x){on([x])}function on(x){const k=[...new Set(x)].filter(ne=>S.terminals[ne]);if(k.length===0)return;const j=k.length===1?S.terminals[k[0]]?.title||S.terminals[k[0]]?.cwd||k[0]:`${k.length} panes`;F(null),ln({terminalIds:k,label:j,workspaceId:Xe?.id??S.activeWorkspaceId??null})}function Bn(x,k){const j=Ge(x,k);if(!j)return!1;const ne=x.filter(ye=>!j.detachedTerminalIds.includes(ye));if(j.detachedTerminalIds.length+ne.length>kl)return F(o5(j.detachedTerminalIds.length)),!1;F(null);for(const ye of x)rt(j.id?{type:"terminal.detached",terminalId:ye,workspaceId:j.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Nl(x){await Ft(async()=>{for(const k of x)await as(k),jo(g.createWebSocketUrl(k)),Mu(k),rt({type:"terminal.closed",terminalId:k})})}async function Fr(x){const k=S.workspaces.find(j=>j.id===x);!k||S.workspaces.length<=1||window.confirm(`Delete workspace "${k.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await Ft(async()=>{const j=oh(k),ne=[];let ye=null;for(const Se of j)try{await as(Se)}catch(He){ne.push(kr(He)),He instanceof is&&He.status===401&&!g.isAgent&&(ye=He)}finally{jo(g.createWebSocketUrl(Se)),Mu(Se)}const me=k.tabs.flatMap(Se=>jm(Se.root));if(me.length>0){const Se=new Set(me);cp(s,He=>{const tt={...He};for(const Zt of Se)delete tt[Zt];return tt})}if(rt({type:"workspace.closed",workspaceId:x}),ye)throw ye;if(ne.length>0)throw new Error(`Workspace was removed, but ${ne.length} terminal session${ne.length===1?"":"s"} may still be running. ${ne[0]}`)})}async function Ra(x){await Ft(async()=>{await as(x),jo(g.createWebSocketUrl(x)),Mu(x),rt({type:"terminal.closed",terminalId:x})})}async function Ma(x,k){const j=k.trim();if(!j)return;let ne=null;for(const ye of S.workspaces){const me=ye.tabs.find(Se=>Se.id===x);if(me){ne=me.activeTerminalId;break}}if(rt({type:"tab.renamed",tabId:x,title:j}),!!ne)try{const ye=await g.renameTerminal(ne,j);Vi({type:"terminal.updated",terminal:ye.terminal})}catch(ye){Er(s,!0,kr(ye))}}function Xs(x){const k=S.terminals[x];k&&rt({type:"terminal.created",terminal:k})}async function as(x){try{await g.closeTerminal(x)}catch(k){if(k instanceof is&&k.status===404)return;throw k}}async function bn(){await Ft(async()=>{await c()})}async function Ft(x){Er(s,!0,null);try{await x()}catch(k){if(ls(k))return;Er(s,!0,kr(k))}}function ls(x){return x instanceof is&&x.status===401&&!g.isAgent&&h?(h({source:"workspace-api-401",status:401,activeAgentId:s}),!0):!1}function rt(x){Do(s,x);const k=Mt(s),j=k.state;if(!k.loaded||j.workspaces.length===0)return;const ne=op(j);JSON.stringify(ne)!==k.lastPersistedLayoutJson&&gc(ne)}function Vi(x){Do(s,x)}function Wr(x,k,j,ne){const ye=Po(x,k,j);ee(me=>({...me,[ye]:ne}))}function Ss(x){_i&&ee(k=>({...k,[_i]:x}))}function qr(x,k){const j=uh(x);k?Wr(s,k.workspaceId,k.tabId,j):Ss(j),rt({type:"pane.selected",terminalId:x})}function Xi(x){Ss(x.key),x.type==="terminal"&&rt({type:"pane.selected",terminalId:x.terminalId})}function O(x){if(le||yi||x.isComposing||x.key==="Process"||YA(x.target))return;const k=FA(x);if(!k)return;if(x.preventDefault(),x.stopPropagation(),k.type==="server.previous"||k.type==="server.next"){Fe(k.type==="server.next"?1:-1);return}const j=Mt(s).state,ne=j.workspaces.find(Se=>Se.id===j.activeWorkspaceId)??j.workspaces[0],ye=ne?.tabs.find(Se=>Se.id===ne.activeTabId)??ne?.tabs[0];if(k.type==="split"){if(!ye)return;yn(k.direction);return}if(!ne||!ye)return;if(k.type==="tab.previous"||k.type==="tab.next"){const Se=$A(ne.tabs,ye.id,k.type==="tab.next"?1:-1);Se&&rt({type:"tab.selected",tabId:Se.id});return}if(k.type==="tab.index"){const Se=ne.tabs[k.index-1];Se&&rt({type:"tab.selected",tabId:Se.id});return}const me=WA(ye.root,ye.activeTerminalId,k);me&&qr(me,{workspaceId:ne.id,tabId:ye.id})}function pe(x,k){if(!r||K.length===0)return;const j=K.findIndex(Se=>mn(Se,s)),ye=((j===-1?0:j)+x+K.length)%K.length,me=K[ye]??null;mn(me,s)||(k&&(De.current={agentId:me,edge:k}),r(me))}function Fe(x){const k=Mt(s).state,j=k.workspaces;if(j.length===0){pe(x,x===1?"first":"last");return}const ne=j.findIndex(Se=>Se.id===k.activeWorkspaceId),me=(ne===-1?0:ne)+x;if(me>=0&&me<j.length){rt({type:"workspace.selected",workspaceId:j[me].id});return}pe(x,x===1?"first":"last")}function Pe(x,k){if(mn(x,s)){rt({type:"workspace.selected",workspaceId:k});return}Be.current={agentId:x,workspaceId:k},r?.(x)}function Ge(x,k){if(k)return S.workspaces.find(j=>j.id===k)??null;for(const j of x){const ne=S.workspaces.find(me=>me.tabs.some(Se=>nc(Se).includes(j)));if(ne)return ne;const ye=S.workspaces.find(me=>me.detachedTerminalIds.includes(j));if(ye)return ye}return S.workspaces.find(j=>j.id===S.activeWorkspaceId)??S.workspaces[0]??null}function dt(x){u0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function Bt(x){if(!u0(x.dataTransfer))return;x.preventDefault();const k=c5(Mt(s).state),j=be.current+1;if(be.current=j,!k){On({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}On({id:j,status:"queued",fileCount:0,terminalId:k.id,message:"Preparing upload..."}),Gi(j,k.id,x.dataTransfer)}async function Gi(x,k,j){try{const ne=await RA(j);if(ne.length===0)throw new Error("No files were found in the drop.");Gt(x,{id:x,status:"queued",fileCount:ne.length,message:"Queued"},{terminalId:k,files:ne})}catch(ne){Gt(x,{id:x,status:"failed",fileCount:0,message:kr(ne)},{terminalId:k})}finally{Ot()}}async function Lt(x){const k=bt.current.find(me=>me.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=k.terminalId,ne=k.files,ye=new AbortController;It.current=x,Gt(x,{id:x,status:"uploading",fileCount:ne.length,loaded:0,total:null,percent:null},{terminalId:j,files:ne,abortController:ye});try{const me=await oT({terminalId:j,files:ne,signal:ye.signal,onProgress:Zt=>{Gt(x,{id:x,status:"uploading",fileCount:ne.length,loaded:Zt.loaded,total:Zt.total,percent:Zt.percent},{terminalId:j,files:ne,abortController:ye})}}),Se=me.failed>0?me.uploaded>0?"partial":"failed":"success",He=me.failed>0?u5(me):void 0,tt={id:x,status:Se,fileCount:ne.length,response:me};He&&(tt.message=He),Gt(x,tt,{terminalId:j,files:ne})}catch(me){Gt(x,{id:x,status:"failed",fileCount:ne.length,message:ye.signal.aborted?"Upload canceled.":kr(me)},{terminalId:j,files:ne})}finally{It.current===x&&(It.current=null),Ot()}}function Ot(){if(It.current!==null)return;const x=bt.current.find(k=>k.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&Lt(x.id)}function On(x){ws(k=>[...k,x])}function Gt(x,k,j={}){ws(ne=>ne.map(ye=>{if(ye.id!==x)return ye;const me={...k},Se=j.terminalId??ye.terminalId,He=j.files??ye.files;return Se!==void 0&&(me.terminalId=Se),He!==void 0&&(me.files=He),j.abortController!==void 0&&(me.abortController=j.abortController),me}))}function ws(x){const k=x(bt.current);bt.current=k,vi(k)}function Cs(x){bt.current.find(j=>j.id===x)?.abortController?.abort(),It.current===x&&(It.current=null),ws(j=>j.filter(ne=>ne.id!==x)),Ot()}function ci(){for(const x of bt.current)x.abortController?.abort();It.current=null,ws(()=>[])}function Gs(x){const k=bt.current.find(j=>j.id===x);if(k){if(k.status==="queued"){Cs(x);return}k.abortController?.abort()}}function Zs(x){const k=bt.current.find(ne=>ne.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=Qs(k);if(j.length===0){Gt(x,{id:x,status:"failed",fileCount:k.fileCount,message:"No failed files are available to retry."},{terminalId:k.terminalId,files:k.files});return}Gt(x,{id:x,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:k.terminalId,files:j}),Ot()}function Qs(x){const k=x.files??[],j="response"in x?x.response:void 0;if(!j)return k;const ne=j.results.filter(Se=>Se.status==="failed").map(Se=>Se.relativePath);if(ne.length===0)return[];const ye=new Map;for(const Se of k){const He=ye.get(Se.relativePath)??[];He.push(Se),ye.set(Se.relativePath,He)}const me=[];for(const Se of ne){const tt=ye.get(Se)?.shift();tt&&me.push(tt)}return me}function Js(x){const j=Mt(x.agentId).state.workspaces.find(ne=>ne.tabs.some(ye=>ye.id===x.tabId));j&&Wr(x.agentId,j.id,x.tabId,uh(x.terminalId)),Do(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),iA(x.agentId,x.terminalId),mn(x.agentId,s)||r?.(x.agentId),An(null)}function gc(x){const k=Mt(s).mutable.saveCoord;k.pendingLayoutSave=x,Mo(x,f),k.saveTimer!==null&&window.clearTimeout(k.saveTimer),k.saveTimer=window.setTimeout(()=>{k.saveTimer=null;const j=k.pendingLayoutSave;k.pendingLayoutSave=null,j&&Na(j)},HA)}function Al(){const x=Mt(s).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const k=x.pendingLayoutSave;x.pendingLayoutSave=null,k&&(Mo(k,f),Na(k))}function Na(x,k={}){const j=Mt(s).mutable.saveCoord;j.nextPersistLayout=x,k.baseRevision!==void 0&&(j.queuedBaseRevision=k.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const ne=j.nextPersistLayout,ye=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,ne&&await $r(ne,ye!==void 0?{baseRevision:ye}:{})}))}async function $r(x,k={}){const j=Mt(s),ne=k.baseRevision??j.layoutRevision,ye={layout:x,...typeof ne=="number"?{baseRevision:ne}:{}};try{const me=await g.saveTerminalLayout(ye),Se=me.layout??x;Ro(s,me.revision,JSON.stringify(Se)),Mo(Se,f);return}catch(me){if(me instanceof is&&me.status===400&&me.message===L2){l5(s,f),Er(s,!0,V1());return}if(me instanceof is&&me.status===409)try{const Se=await g.getTerminalLayout(),He=Mt(s).mutable.saveCoord;if(He.nextPersistLayout||He.pendingLayoutSave){const tt=Se.layout?JSON.stringify(Se.layout):Mt(s).lastPersistedLayoutJson;Ro(s,Se.revision,tt);return}if(Se.layout){const tt=Mt(s).state,Zt=Em(Object.values(tt.terminals),void 0,Se.layout.workspaces,Se.layout.activeWorkspaceId),si=op(Zt);l0(s,Zt),Ro(s,Se.revision,JSON.stringify(si)),Mo(si,f)}else Ro(s,Se.revision,j.lastPersistedLayoutJson);return}catch{}Mo(x,f)}}const Gn=p5(o),Zn=!I||A,os=Zn?te:"servers";function cs(x){const k=x.active?w:Mt(x.agentId),j=x.active?S:k.state,ne=x.active?w.loaded:k.loaded,ye=x.active?B:k.error;return m.jsxs("div",{className:`workspace-list-panel${x.active?" workspace-list-panel--active-server":""}`,"aria-label":`${x.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 ${x.label}`,title:"New workspace",onClick:()=>Ui(x.agentId),children:"+"})]}),ne?ye?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(x.agentId),children:ye}):m.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(me=>{const Se=x.active&&me.id===Xe?.id,He=oh(me).length,tt=x.active&&j.workspaces.length>1,Zt=X?.workspaceId===me.id&&Ye!==me.id?X.placement:null;return m.jsxs(QA,{workspaceId:me.id,active:Se,disabled:!x.active,reorderable:tt,dragging:Ye===me.id,dropPlacement:Zt,children:[tt?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":me.id,title:"Drag to reorder","aria-label":`Reorder ${me.title}`,"aria-grabbed":Ye===me.id,onPointerDown:si=>bs(me.id,si),onPointerMove:Ys,onPointerUp:Yi,onPointerCancel:Ln,onKeyDown:si=>{(si.key==="ArrowUp"||si.key==="ArrowDown")&&(si.preventDefault(),si.stopPropagation(),Ir(me.id,si.key==="ArrowUp"?-1:1))},onClick:si=>si.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Se?"page":void 0,title:me.defaultCwd??void 0,onClick:()=>Pe(x.agentId,me.id),onDoubleClick:()=>{x.active&&Kt(me.id)},children:[m.jsx("span",{className:"workspace-list-name",children:me.title}),m.jsxs("small",{children:[me.defaultCwd??"No folder"," · ",He," ",He===1?"session":"sessions"]})]}),x.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${me.title}`,title:"Edit workspace",onClick:()=>Kt(me.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${me.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{Fr(me.id)},children:"x"})]}):null]},me.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(k2,{sensors:Le,onDragStart:Oe,onDragEnd:ze,onDragCancel:ht,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":I,"data-sidebar-open":A,onDragOver:dt,onDrop:Bt,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>N(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[Zn?m.jsx(w0,{height:20}):m.jsx(S0,{size:24}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":I?"Expand sidebar":"Collapse sidebar",title:I?"Expand sidebar":"Collapse sidebar",onClick:()=>P(x=>!x),children:I?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>N(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${os==="files"?"files":"servers"}`,children:[Zn?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":te==="servers",onClick:()=>{Q("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":te==="files",onClick:()=>{Q("files")},children:"Files"})]}):null,os==="servers"&&Zn?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(Bb,{api:p,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:L,renderServerChildren:cs})}):null,Zn?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(Bb,{api:p,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:L,compact:!0})}),os==="files"?m.jsx(fT,{api:g,activeTerminalId:gi,activeTerminalCwd:Ji?.cwd??null,workspaceRootPath:Xe?.defaultCwd??Ji?.cwd??null,onOpenFile:Xt}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[Zn?m.jsx("span",{children:Gn}):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:()=>oe(!0),children:[m.jsx(p0,{name:"settings"}),ve.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Zn?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{bn()},children:m.jsx(p0,{name:"logout"})}):null]})]})]}),le?m.jsx(nT,{api:p,onClose:()=>oe(!1),updateAvailable:ve.hasUpdates,onNotificationAssetsChanged:()=>{ji()},onAgentRemoved:$i}):null,he?m.jsx(VA,{dialog:he,activePaneCwd:Ji?.cwd??null,activeWorkspaceCwd:Xe?.defaultCwd??null,onChange:Da,onManualCwdChange:Hi,onBrowse:At,onCancel:tn,onSubmit:()=>{Ur()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":W?"true":void 0,children:[m.jsx(lA,{tabs:Xe?.tabs??[],activeTabId:Xe?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:ut,detachedTerminals:We,onSelectTab:x=>rt({type:"tab.selected",tabId:x}),onCreateTab:()=>{rs()},onToggleWorkspaces:()=>N(x=>!x),onCloseTerminals:x=>on(x),onReattachTerminal:x=>Xs(x),onDeleteTerminal:x=>{Ra(x)},onSplitVertical:()=>{yn("vertical")},onSplitHorizontal:()=>{yn("horizontal")},onRenameTab:(x,k)=>{Ma(x,k)},activePaneAvailable:!!gi}),W?m.jsx(e5,{targets:$t,activeLeafKey:_n,terminals:S.terminals,editors:E,onSelect:Xi}):null,B?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:B}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:vn,children:"Retry"}),s!==null&&r?m.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":T,children:[T?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!T&&!ot?m.jsx(ZA,{onCreate:()=>{rs()}}):null,D.map(x=>{const k=mn(x,s);return m.jsx(KA,{agentId:x,active:k,activeServerApi:k?g:void 0,visitedTabKeys:ge,refreshCwdOnEnter:k&&os==="files",draggingTab:k?ae:null,mobileSplitFocus:qi,mobileFocusedLeafByTabKey:H,onSelect:j=>{k&&qr(j)},onClose:j=>{k&&Vs(j)},onCloseEditor:j=>{k&&Kr(j)},onResize:(j,ne)=>{k&&rt({type:"pane.resized",path:j,ratio:ne})},onExit:(j,ne)=>{k?Vi({type:"terminal.exited",terminalId:j,exitCode:ne}):Do(x,{type:"terminal.exited",terminalId:j,exitCode:ne})},onSnapshot:(j,ne)=>{const ye={type:"terminal.updated",terminal:j,notifyCompletion:ne?.notifyCompletion===!0};k?Vi(ye):Do(x,ye)},...x===null&&h?{onAuthClose:j=>h({...j,source:j?.source??"terminal-ws-1008",activeAgentId:x})}:{}},qu(x))})]}),yi?m.jsx(JA,{label:yi.label,count:yi.terminalIds.length,warning:J,onCancel:()=>{F(null),ln(null)},onHide:()=>{Bn(yi.terminalIds,yi.workspaceId)&&ln(null)},onDelete:()=>{const x=yi.terminalIds;F(null),ln(null),Nl(x)}}):null,m.jsx(yA,{toast:en,onActivate:Js,onDismiss:()=>An(null)}),m.jsx(dA,{uploads:gt,onDismiss:Cs,onDismissAll:ci,onRetry:Zs,onCancel:Gs})]})]})})}function KA({agentId:e,active:t,activeServerApi:s,visitedTabKeys:r,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:p,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:w,onSnapshot:S,onAuthClose:E}){const T=v.useMemo(()=>ve=>j1(e,ve),[e]),B=v.useMemo(()=>()=>Mt(e),[e]),A=v.useSyncExternalStore(T,B,B),N=v.useMemo(()=>Xo(e),[e]),I=s??N,P=A.state,te=P.workspaces.find(ve=>ve.id===P.activeWorkspaceId)??P.workspaces[0],Q=te?.id??null,oe=(te?.tabs.find(ve=>ve.id===te.activeTabId)??te?.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(Ce=>{const ie=t&&ve.id===Q&&Ce.id===oe,J=Po(e,ve.id,Ce.id),F=ch(Ce.root),K=h&&F.length>1?q1(F,Ce.activeTerminalId,p[J]):null;return!ie&&!r.has(J)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":ie,"aria-hidden":!ie,children:m.jsx(wm,{node:Ce.root,terminals:P.terminals,editors:A.editors,api:I,activeTerminalId:Ce.activeTerminalId,visible:ie,refreshCwdOnEnter:ie&&o,tabId:Ce.id,dropZoneActive:ie&&c!==null,draggingTerminalId:ie?c?.terminalId??null:null,mobileFocusLeafKey:K,onSelect:g,onClose:f,onCloseEditor:b,onResize:y,onExit:w,onSnapshot:S,...E?{onAuthClose:E}:{}})},`${ve.id}:${Ce.id}`)}))})}function FA(e){const t=lw(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 s=qA(e.key);return s?{type:"pane.direction",direction:s}:null}return null}function WA(e,t,s){switch(s.type){case"pane.direction":return wA(e,t,s.direction);case"pane.index":return CA(e,s.index);default:return null}}function qA(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function $A(e,t,s){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+s+e.length)%e.length]??null}function ch(e){return e.type==="pane"?[{key:uh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:$1(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...ch(e.first),...ch(e.second)]}function jm(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...jm(e.first),...jm(e.second)]}function q1(e,t,s){if(s&&e.some(o=>o.key===s))return s;const r=t?uh(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function uh(e){return`terminal:${e}`}function $1(e){return`editor:${e}`}function YA(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 VA({dialog:e,activePaneCwd:t,activeWorkspaceCwd:s,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:p}){const g=e.browseRoot?.rootPath??e.cwd,f=e.browseEntries.filter(S=>S.kind==="directory"),b=e.submitStatus==="submitting";function y(S){r(E=>E&&{...E,...S})}function w(S){S&&(y({cwd:S,error:null}),c(S))}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:S=>S.stopPropagation(),onSubmit:S=>{S.preventDefault(),b||p()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:S=>y({title:S.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:b,onChange:S=>o(S.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>w(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>w(s),disabled:b||!s,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(GA(g))},disabled:b||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&f.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&f.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:f.map(S=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${S.name}`,disabled:b,onClick:()=>{c(XA(g,S.path))},children:[m.jsx("span",{children:S.name}),m.jsx("small",{children:S.path})]},S.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function XA(e,t){return t?t.startsWith("/")?Wu(t):Wu(`${e||"/"}/${t}`):Wu(e)}function GA(e){const t=Wu(e);if(!t||t==="/")return"/";const s=t.lastIndexOf("/");return s<=0?"/":t.slice(0,s)}function Wu(e){const t=e.trim();if(!t)return"";const s=t.replace(/\/+/g,"/");return s==="/"?"/":s.endsWith("/")?s.slice(0,-1):s}function ZA({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 QA({workspaceId:e,active:t,disabled:s=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:p,isOver:g}=Zm({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:s}),f=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:p,className:f,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function JA({label:e,count:t,warning:s,onCancel:r,onHide:o,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,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:r,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."}),s?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:s}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function e5({targets:e,activeLeafKey:t,terminals:s,editors:r,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(w=>w.key===t):-1,g=p>=0?p:0,f=e[g]??e[0],b=f0(f,s,r);function y(w){const S=(g+w+e.length)%e.length,E=e[S];E&&o(E)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.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((w,S)=>{const E=f0(w,s,r),T=t5(w,s,r),B=w.key===f.key;return m.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(w),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:S+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:E}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function f0(e,t,s){if(e.type==="editor")return s[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function t5(e,t,s){if(e.type==="editor"){const c=s[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function i5(e){const[t,s]=v.useState(()=>n5(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){s(!1);return}const r=window.matchMedia(e),o=()=>s(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function n5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function mn(e,t){return e===t}function s5(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function qu(e){return e??"__local__"}function Po(e,t,s){return`${qu(e)}:${t}:${s}`}class hh extends Error{constructor(){super(V1())}}function r5(e){return e?{workspaceKey:`${h0}:${e}`}:{workspaceKey:h0}}function a5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const s=JSON.parse(t);if(W0(s))throw new hh;const r=F0(s);return r?Y1(r):null}catch(s){if(s instanceof hh)throw s;return null}}function Y1(e){if(W0(e))throw new hh;const t=F0(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Mo(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function l5(e,t){const s=Mt(e).lastPersistedLayoutJson;if(s){localStorage.setItem(t.workspaceKey,s);return}localStorage.removeItem(t.workspaceKey)}function o5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${kl}. Re-open or delete hidden sessions before hiding more.`}function V1(){return`A saved terminal layout has more than ${kl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function c5(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],s=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=s?e.terminals[s.activeTerminalId]:void 0;return r?.status==="running"?r:null}function u5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function h5(e){return e.split("/").filter(Boolean).pop()??e}function d5(){try{return localStorage.getItem(W1)==="true"}catch{return!1}}function f5(e){try{localStorage.setItem(W1,e?"true":"false")}catch{}}function p5(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const s=t-Date.now();if(s<=0)return"session · expired";const r=Math.max(1,Math.floor(s/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function p0({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 kr(e){return e instanceof Error?e.message:"Request failed"}function m5({api:e,onDone:t}){const[s,r]=v.useState(null),[o,c]=v.useState(null),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(null),[w,S]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(B=>{T||(r(B.qrDataUrl),c(B.secret))}).catch(B=>{T||S(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function E(T){if(T.preventDefault(),!!o){f(!0),y(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(B){y(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return w?m.jsx("p",{className:"form-error",children:w}):!s||!o?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:s,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:o})]}),m.jsxs("form",{className:"auth-form",onSubmit:E,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>p(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),b?m.jsx("p",{className:"form-error",children:b}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}function g5(e){return{source:hp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:hp(e.terminalId)}:{},...e?.detail?{detail:hp(e.detail)}:{}}}function _5(e){return{invalidationSource:e.source}}function v5(e){Mn("auth.session_invalid.request",X1(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),vh("session-invalid-request").catch(()=>{}))}function y5(e,t){Mn("auth.session_invalid.result",{...X1(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),vh("session-invalid-result").catch(()=>{}))}function X1(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 hp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function b5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r}){const o=v.useMemo(()=>e??dh(),[e]),c=v.useMemo(()=>t??Xo(null),[t]),[h,p]=v.useState(null),[g,f]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let A=!1;return o.getSession().then(N=>{A||(p(N),f(null))}).catch(N=>{A||(f(ya(N)),p(null))}),()=>{A=!0}},[o]);const w=x5(h);v.useEffect(()=>{const A=y.current;Mn("auth.view",{view:w,previousView:A,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),A==="workspace"&&w!=="workspace"&&vh(`auth-left-workspace-${w}`).catch(()=>{}),y.current=w},[h,w]);async function S(){const A=await o.getSession();p(A),f(null)}async function E(){np(),up(),qS(),f(null),p(null);try{await S()}catch(A){f(ya(A))}}function T(A){const N=g5(A);if(v5(N),b.current)return b.current;const I=(async()=>{f(null);try{const P=await o.getSession(_5(N));if(y5(N,P.authenticated),p(P),P.authenticated){vN();return}np(),up(),qS()}catch(P){f(ya(P))}finally{b.current=null}})();return b.current=I,I}if(w==="workspace")return m.jsx(IA,{api:o,serverApi:c,activeAgentId:s,onSelectServer:r,sessionExpiresAt:h?.expiresAt??null,onSessionInvalid:A=>{T(A)},onLogout:async()=>{np(),up();const A=await o.logout();p(A)}});const B={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return 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":w==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(S0,{size:26}),m.jsxs("div",{children:[m.jsx(w0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:B[w]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,w==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{E()},children:"Retry"}):null,w==="setup_password"?m.jsx(S5,{api:o,onSession:A=>{p(A)}}):null,w==="setup_totp"?m.jsx(m5,{api:o,onDone:()=>{S()}}):null,w==="login"?m.jsx(w5,{api:o,session:h,onSession:p,onRefresh:S}):null,w==="reauth"?m.jsx(C5,{api:o,session:h,onSession:p,onFullLogin:()=>p(A=>A&&{...A,deviceTrusted:!1})}):null]})]})}function S5({api:e,onSession:t}){const[s,r]=v.useState(""),[o,c]=v.useState(""),[h,p]=v.useState(!1),[g,f]=v.useState(null);async function b(y){y.preventDefault(),p(!0),f(null);try{if(s!==o){f("Passwords do not match");return}t(await e.setupPassword({password:s}))}catch(w){f(ya(w))}finally{p(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:b,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:s,onChange:y=>r(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:o,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||s.length<8||o.length<8,children:"Set password"})]})}function w5({api:e,session:t,onSession:s,onRefresh:r}){const[o,c]=v.useState(""),[h,p]=v.useState(""),[g,f]=v.useState(!1),[b,y]=v.useState(!1),[w,S]=v.useState(null),E=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function B(A){A.preventDefault(),y(!0),S(null);try{s(await e.login({password:o,...E?{otp:h}:{},rememberNetwork:g}))}catch(N){S(ya(N))}finally{y(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:B,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:A=>c(A.currentTarget.value),required:!0})]}),E?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:A=>p(A.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:A=>f(A.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?m.jsx("p",{className:"form-error",children:w}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||o.length===0||E&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:b,children:"Refresh"})]})]})}function C5({api:e,session:t,onSession:s,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[p,g]=v.useState(!1),[f,b]=v.useState(!1),[y,w]=v.useState(!1),[S,E]=v.useState(!1),[T,B]=v.useState(null),A=Ei.useCallback(async(I,P)=>{b(!0),B(null);try{s(await e.reauth({...I?{otp:I}:{},rememberNetwork:P}))}catch(te){B(ya(te))}finally{b(!1)}},[e,s]);v.useEffect(()=>{if(o){let I=!1;w(!0),E(!1),B(null);const P=window.setTimeout(()=>{I||E(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(te=>{I||s(te)}).catch(te=>{I||(B(ya(te)),E(!0))}).finally(()=>{window.clearTimeout(P),I||w(!1)}),()=>{I=!0,window.clearTimeout(P)}}},[e,o,s]);async function N(I){I.preventDefault(),await A(c,p)}return o&&y&&!S&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:N,children:[o&&S&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:I=>h(I.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:p,onChange:I=>g(I.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?m.jsx("p",{className:"form-error",children:T}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:f,children:"Use password instead"})]})]})}function x5(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ya(e){return e instanceof Error?e.message:"Request failed"}const m0="NTerminal",Hm="nterminal.activeAgentId";function E5(){const[e,t]=v.useState(()=>k5()),s=v.useMemo(()=>dh(),[]),r=v.useMemo(()=>Xo(e),[e]);v.useEffect(()=>{const c=()=>{const h=tA();document.title=h>0?`(${h}) ${m0}`:m0};return c(),eA(c)},[]);function o(c){T5(c),t(c)}return m.jsx(b5,{api:s,activeAgentId:e,serverApi:r,onSelectServer:o})}function k5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Hm);return e&&e.trim()?e:null}catch{return null}}function T5(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Hm,e);return}window.localStorage.removeItem(Hm)}catch{}}const g0=["gesturestart","gesturechange","gestureend"],D5=[".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 R5(e=window){if(!N5(e))return()=>{};const t={passive:!1},s=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!M5(c.target))&&r(c)}for(const c of g0)s.addEventListener(c,r,t);return s.addEventListener("touchmove",o,t),s.addEventListener("dblclick",r,t),()=>{for(const c of g0)s.removeEventListener(c,r,t);s.removeEventListener("touchmove",o,t),s.removeEventListener("dblclick",r,t)}}function M5(e){return e instanceof Element&&e.closest(D5)!==null}function N5(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}sk();FM();R5();Fm();aE.createRoot(document.getElementById("root")).render(m.jsx(Ei.StrictMode,{children:m.jsx(E5,{})}));export{Ei as R,Zx as g,m as j};
|