nterminal 1.2.62 → 1.2.64
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/README.md +0 -3
- package/bin/nterminal.js +0 -4
- package/dist/client/assets/MarkdownPreview-3F25Ss3Q.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-B5UquJIY.js → TranscriptMarkdownBody-l6FWnQzY.js} +1 -1
- package/dist/client/assets/index-Br8oSqEJ.js +55 -0
- package/dist/client/assets/{index-CpqKK80t.css → index-CQdd_vcO.css} +1 -1
- package/dist/client/assets/{index-B56tTIJv.js → index-DeuQv7mk.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/agent/agentAuth.js +1 -11
- package/dist/server/agent/agentAuth.js.map +1 -1
- package/dist/server/agent/agentRoutes.js +2 -96
- package/dist/server/agent/agentRoutes.js.map +1 -1
- package/dist/server/http.d.ts +1 -2
- package/dist/server/http.js +0 -2
- package/dist/server/http.js.map +1 -1
- package/dist/server/routes/agentManagementRoutes.js +2 -14
- package/dist/server/routes/agentManagementRoutes.js.map +1 -1
- package/dist/server/routes/authRoutes.js +1 -1
- package/dist/server/routes/authRoutes.js.map +1 -1
- package/dist/server/routes/terminalRoutes.js +1 -1
- package/dist/server/routes/terminalRoutes.js.map +1 -1
- package/dist/server/routes/updateRoutes.js +2 -2
- package/dist/server/routes/updateRoutes.js.map +1 -1
- package/dist/server/storage/fileStore.d.ts +1 -8
- package/dist/server/storage/fileStore.js +2 -49
- package/dist/server/storage/fileStore.js.map +1 -1
- package/dist/server/terminal/TerminalManager.d.ts +1 -0
- package/dist/server/terminal/TerminalManager.js +9 -0
- package/dist/server/terminal/TerminalManager.js.map +1 -1
- package/dist/server/update/packageUpdate.d.ts +2 -2
- package/dist/server/update/packageUpdate.js +53 -20
- package/dist/server/update/packageUpdate.js.map +1 -1
- package/dist/shared/protocol.d.ts +0 -71
- package/dist/shared/protocol.js.map +1 -1
- package/docs/features.md +0 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-pEj4ukXa.js +0 -1
- package/dist/client/assets/index-Kt-1DNuk.js +0 -55
- package/dist/scripts/distcall.js +0 -436
- package/dist/scripts/distcall.js.map +0 -1
- package/dist/server/distcall/envelope.d.ts +0 -6
- package/dist/server/distcall/envelope.js +0 -56
- package/dist/server/distcall/envelope.js.map +0 -1
- package/dist/server/distcall/executor.d.ts +0 -23
- package/dist/server/distcall/executor.js +0 -316
- package/dist/server/distcall/executor.js.map +0 -1
- package/dist/server/routes/distributedCallRoutes.d.ts +0 -9
- package/dist/server/routes/distributedCallRoutes.js +0 -305
- package/dist/server/routes/distributedCallRoutes.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-3F25Ss3Q.js","assets/index-DeuQv7mk.js","assets/TranscriptMarkdownBody-l6FWnQzY.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 rE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Af={exports:{}},bo={};var cb;function aE(){if(cb)return bo;cb=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 f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:h,ref:o!==void 0?o:null,props:c}}return bo.Fragment=t,bo.jsx=s,bo.jsxs=s,bo}var ub;function lE(){return ub||(ub=1,Af.exports=aE()),Af.exports}var m=lE(),Lf={exports:{}},Ye={};var hb;function oE(){if(hb)return Ye;hb=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"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),S=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=S&&R[S]||R["@@iterator"],typeof R=="function"?R:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,B={};function L(R,G,ce){this.props=R,this.context=G,this.refs=B,this.updater=ce||k}L.prototype.isReactComponent={},L.prototype.setState=function(R,G){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,G,"setState")},L.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function A(){}A.prototype=L.prototype;function W(R,G,ce){this.props=R,this.context=G,this.refs=B,this.updater=ce||k}var I=W.prototype=new A;I.constructor=W,T(I,L.prototype),I.isPureReactComponent=!0;var ee=Array.isArray;function se(){}var ae={H:null,A:null,T:null,S:null},oe=Object.prototype.hasOwnProperty;function ve(R,G,ce){var me=ce.ref;return{$$typeof:e,type:R,key:G,ref:me!==void 0?me:null,props:ce}}function U(R,G){return ve(R.type,G,R.props)}function K(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function Y(R){var G={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ce){return G[ce]})}var H=/\/+/g;function j(R,G){return typeof R=="object"&&R!==null&&R.key!=null?Y(""+R.key):G.toString(36)}function te(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(se,se):(R.status="pending",R.then(function(G){R.status==="pending"&&(R.status="fulfilled",R.value=G)},function(G){R.status==="pending"&&(R.status="rejected",R.reason=G)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function N(R,G,ce,me,xe){var Ee=typeof R;(Ee==="undefined"||Ee==="boolean")&&(R=null);var Me=!1;if(R===null)Me=!0;else switch(Ee){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(R.$$typeof){case e:case t:Me=!0;break;case b:return Me=R._init,N(Me(R._payload),G,ce,me,xe)}}if(Me)return xe=xe(R),Me=me===""?"."+j(R,0):me,ee(xe)?(ce="",Me!=null&&(ce=Me.replace(H,"$&/")+"/"),N(xe,G,ce,"",function(Q){return Q})):xe!=null&&(K(xe)&&(xe=U(xe,ce+(xe.key==null||R&&R.key===xe.key?"":(""+xe.key).replace(H,"$&/")+"/")+Me)),G.push(xe)),1;Me=0;var qe=me===""?".":me+":";if(ee(R))for(var ge=0;ge<R.length;ge++)me=R[ge],Ee=qe+j(me,ge),Me+=N(me,G,ce,Ee,xe);else if(ge=w(R),typeof ge=="function")for(R=ge.call(R),ge=0;!(me=R.next()).done;)me=me.value,Ee=qe+j(me,ge++),Me+=N(me,G,ce,Ee,xe);else if(Ee==="object"){if(typeof R.then=="function")return N(te(R),G,ce,me,xe);throw G=String(R),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return Me}function $(R,G,ce){if(R==null)return R;var me=[],xe=0;return N(R,me,"","",function(Ee){return G.call(ce,Ee,xe++)}),me}function X(R){if(R._status===-1){var G=R._result;G=G(),G.then(function(ce){(R._status===0||R._status===-1)&&(R._status=1,R._result=ce)},function(ce){(R._status===0||R._status===-1)&&(R._status=2,R._result=ce)}),R._status===-1&&(R._status=0,R._result=G)}if(R._status===1)return R._result.default;throw R._result}var Se=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var G=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(G))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},De={map:$,forEach:function(R,G,ce){$(R,function(){G.apply(this,arguments)},ce)},count:function(R){var G=0;return $(R,function(){G++}),G},toArray:function(R){return $(R,function(G){return G})||[]},only:function(R){if(!K(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ye.Activity=y,Ye.Children=De,Ye.Component=L,Ye.Fragment=s,Ye.Profiler=o,Ye.PureComponent=W,Ye.StrictMode=r,Ye.Suspense=g,Ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=ae,Ye.__COMPILER_RUNTIME={__proto__:null,c:function(R){return ae.H.useMemoCache(R)}},Ye.cache=function(R){return function(){return R.apply(null,arguments)}},Ye.cacheSignal=function(){return null},Ye.cloneElement=function(R,G,ce){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var me=T({},R.props),xe=R.key;if(G!=null)for(Ee in G.key!==void 0&&(xe=""+G.key),G)!oe.call(G,Ee)||Ee==="key"||Ee==="__self"||Ee==="__source"||Ee==="ref"&&G.ref===void 0||(me[Ee]=G[Ee]);var Ee=arguments.length-2;if(Ee===1)me.children=ce;else if(1<Ee){for(var Me=Array(Ee),qe=0;qe<Ee;qe++)Me[qe]=arguments[qe+2];me.children=Me}return ve(R.type,xe,me)},Ye.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},Ye.createElement=function(R,G,ce){var me,xe={},Ee=null;if(G!=null)for(me in G.key!==void 0&&(Ee=""+G.key),G)oe.call(G,me)&&me!=="key"&&me!=="__self"&&me!=="__source"&&(xe[me]=G[me]);var Me=arguments.length-2;if(Me===1)xe.children=ce;else if(1<Me){for(var qe=Array(Me),ge=0;ge<Me;ge++)qe[ge]=arguments[ge+2];xe.children=qe}if(R&&R.defaultProps)for(me in Me=R.defaultProps,Me)xe[me]===void 0&&(xe[me]=Me[me]);return ve(R,Ee,xe)},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(R){return{$$typeof:f,render:R}},Ye.isValidElement=K,Ye.lazy=function(R){return{$$typeof:b,_payload:{_status:-1,_result:R},_init:X}},Ye.memo=function(R,G){return{$$typeof:p,type:R,compare:G===void 0?null:G}},Ye.startTransition=function(R){var G=ae.T,ce={};ae.T=ce;try{var me=R(),xe=ae.S;xe!==null&&xe(ce,me),typeof me=="object"&&me!==null&&typeof me.then=="function"&&me.then(se,Se)}catch(Ee){Se(Ee)}finally{G!==null&&ce.types!==null&&(G.types=ce.types),ae.T=G}},Ye.unstable_useCacheRefresh=function(){return ae.H.useCacheRefresh()},Ye.use=function(R){return ae.H.use(R)},Ye.useActionState=function(R,G,ce){return ae.H.useActionState(R,G,ce)},Ye.useCallback=function(R,G){return ae.H.useCallback(R,G)},Ye.useContext=function(R){return ae.H.useContext(R)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(R,G){return ae.H.useDeferredValue(R,G)},Ye.useEffect=function(R,G){return ae.H.useEffect(R,G)},Ye.useEffectEvent=function(R){return ae.H.useEffectEvent(R)},Ye.useId=function(){return ae.H.useId()},Ye.useImperativeHandle=function(R,G,ce){return ae.H.useImperativeHandle(R,G,ce)},Ye.useInsertionEffect=function(R,G){return ae.H.useInsertionEffect(R,G)},Ye.useLayoutEffect=function(R,G){return ae.H.useLayoutEffect(R,G)},Ye.useMemo=function(R,G){return ae.H.useMemo(R,G)},Ye.useOptimistic=function(R,G){return ae.H.useOptimistic(R,G)},Ye.useReducer=function(R,G,ce){return ae.H.useReducer(R,G,ce)},Ye.useRef=function(R){return ae.H.useRef(R)},Ye.useState=function(R){return ae.H.useState(R)},Ye.useSyncExternalStore=function(R,G,ce){return ae.H.useSyncExternalStore(R,G,ce)},Ye.useTransition=function(){return ae.H.useTransition()},Ye.version="19.2.6",Ye}var db;function Um(){return db||(db=1,Lf.exports=oE()),Lf.exports}var v=Um();const xi=rE(v);var Bf={exports:{}},So={},Of={exports:{}},zf={};var fb;function cE(){return fb||(fb=1,(function(e){function t(N,$){var X=N.length;N.push($);e:for(;0<X;){var Se=X-1>>>1,De=N[Se];if(0<o(De,$))N[Se]=$,N[X]=De,X=Se;else break e}}function s(N){return N.length===0?null:N[0]}function r(N){if(N.length===0)return null;var $=N[0],X=N.pop();if(X!==$){N[0]=X;e:for(var Se=0,De=N.length,R=De>>>1;Se<R;){var G=2*(Se+1)-1,ce=N[G],me=G+1,xe=N[me];if(0>o(ce,X))me<De&&0>o(xe,ce)?(N[Se]=xe,N[me]=X,Se=me):(N[Se]=ce,N[G]=X,Se=G);else if(me<De&&0>o(xe,X))N[Se]=xe,N[me]=X,Se=me;else break e}}return $}function o(N,$){var X=N.sortIndex-$.sortIndex;return X!==0?X:N.id-$.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,f=h.now();e.unstable_now=function(){return h.now()-f}}var g=[],p=[],b=1,y=null,S=3,w=!1,k=!1,T=!1,B=!1,L=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,W=typeof setImmediate<"u"?setImmediate:null;function I(N){for(var $=s(p);$!==null;){if($.callback===null)r(p);else if($.startTime<=N)r(p),$.sortIndex=$.expirationTime,t(g,$);else break;$=s(p)}}function ee(N){if(T=!1,I(N),!k)if(s(g)!==null)k=!0,se||(se=!0,Y());else{var $=s(p);$!==null&&te(ee,$.startTime-N)}}var se=!1,ae=-1,oe=5,ve=-1;function U(){return B?!0:!(e.unstable_now()-ve<oe)}function K(){if(B=!1,se){var N=e.unstable_now();ve=N;var $=!0;try{e:{k=!1,T&&(T=!1,A(ae),ae=-1),w=!0;var X=S;try{t:{for(I(N),y=s(g);y!==null&&!(y.expirationTime>N&&U());){var Se=y.callback;if(typeof Se=="function"){y.callback=null,S=y.priorityLevel;var De=Se(y.expirationTime<=N);if(N=e.unstable_now(),typeof De=="function"){y.callback=De,I(N),$=!0;break t}y===s(g)&&r(g),I(N)}else r(g);y=s(g)}if(y!==null)$=!0;else{var R=s(p);R!==null&&te(ee,R.startTime-N),$=!1}}break e}finally{y=null,S=X,w=!1}$=void 0}}finally{$?Y():se=!1}}}var Y;if(typeof W=="function")Y=function(){W(K)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,j=H.port2;H.port1.onmessage=K,Y=function(){j.postMessage(null)}}else Y=function(){L(K,0)};function te(N,$){ae=L(function(){N(e.unstable_now())},$)}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(N){N.callback=null},e.unstable_forceFrameRate=function(N){0>N||125<N?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):oe=0<N?Math.floor(1e3/N):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_next=function(N){switch(S){case 1:case 2:case 3:var $=3;break;default:$=S}var X=S;S=$;try{return N()}finally{S=X}},e.unstable_requestPaint=function(){B=!0},e.unstable_runWithPriority=function(N,$){switch(N){case 1:case 2:case 3:case 4:case 5:break;default:N=3}var X=S;S=N;try{return $()}finally{S=X}},e.unstable_scheduleCallback=function(N,$,X){var Se=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Se+X:Se):X=Se,N){case 1:var De=-1;break;case 2:De=250;break;case 5:De=1073741823;break;case 4:De=1e4;break;default:De=5e3}return De=X+De,N={id:b++,callback:$,priorityLevel:N,startTime:X,expirationTime:De,sortIndex:-1},X>Se?(N.sortIndex=X,t(p,N),s(g)===null&&N===s(p)&&(T?(A(ae),ae=-1):T=!0,te(ee,X-Se))):(N.sortIndex=De,t(g,N),k||w||(k=!0,se||(se=!0,Y()))),N},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(N){var $=S;return function(){var X=S;S=$;try{return N.apply(this,arguments)}finally{S=X}}}})(zf)),zf}var pb;function uE(){return pb||(pb=1,Of.exports=cE()),Of.exports}var jf={exports:{}},Xi={};var mb;function hE(){if(mb)return Xi;mb=1;var e=Um();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)p+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function 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,p,b){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:g,containerInfo:p,implementation:b}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Xi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Xi.createPortal=function(g,p){var b=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return c(g,p,null,b)},Xi.flushSync=function(g){var p=h.T,b=r.p;try{if(h.T=null,r.p=2,g)return g()}finally{h.T=p,r.p=b,r.d.f()}},Xi.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,r.d.C(g,p))},Xi.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Xi.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var b=p.as,y=f(b,p.crossOrigin),S=typeof p.integrity=="string"?p.integrity:void 0,w=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;b==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:w}):b==="script"&&r.d.X(g,{crossOrigin:y,integrity:S,fetchPriority:w,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Xi.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var b=f(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},Xi.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var b=p.as,y=f(b,p.crossOrigin);r.d.L(g,b,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Xi.preloadModule=function(g,p){if(typeof g=="string")if(p){var b=f(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},Xi.requestFormReset=function(g){r.d.r(g)},Xi.unstable_batchedUpdates=function(g,p){return g(p)},Xi.useFormState=function(g,p,b){return h.H.useFormState(g,p,b)},Xi.useFormStatus=function(){return h.H.useHostTransitionStatus()},Xi.version="19.2.6",Xi}var gb;function y0(){if(gb)return jf.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(),jf.exports=hE(),jf.exports}var _b;function dE(){if(_b)return So;_b=1;var e=uE(),t=Um(),s=y0();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 f(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 p(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,S=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),W=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),oe=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),K=Symbol.iterator;function Y(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Symbol.for("react.client.reference");function j(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===H?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case L:return"Profiler";case B:return"StrictMode";case ee:return"Suspense";case se:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case k:return"Portal";case W:return i.displayName||"Context";case A:return(i._context.displayName||"Context")+".Consumer";case I:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case ae:return n=i.displayName||null,n!==null?n:j(i.type)||"Memo";case oe:n=i._payload,i=i._init;try{return j(i(n))}catch{}}return null}var te=Array.isArray,N=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Se=[],De=-1;function R(i){return{current:i}}function G(i){0>De||(i.current=Se[De],Se[De]=null,De--)}function ce(i,n){De++,Se[De]=i.current,i.current=n}var me=R(null),xe=R(null),Ee=R(null),Me=R(null);function qe(i,n){switch(ce(Ee,n),ce(xe,i),ce(me,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?Ay(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=Ay(n),i=Ly(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}G(me),ce(me,i)}function ge(){G(me),G(xe),G(Ee)}function Q(i){i.memoizedState!==null&&ce(Me,i);var n=me.current,a=Ly(n,i.type);n!==a&&(ce(xe,i),ce(me,a))}function he(i){xe.current===i&&(G(me),G(xe)),Me.current===i&&(G(Me),go._currentValue=X)}var we,_e;function Te(i){if(we===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);we=n&&n[1]||"",_e=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+we+i+_e}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(J){var Z=J}Reflect.construct(i,[],de)}else{try{de.call()}catch(J){Z=J}i.call(de.prototype)}}else{try{throw Error()}catch(J){Z=J}(de=i())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(J){if(J&&Z&&typeof J.stack=="string")return[J.stack,Z.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
|
+
`),V=C.split(`
|
|
6
|
+
`);for(u=l=0;l<M.length&&!M[l].includes("DetermineComponentFrameRoot");)l++;for(;u<V.length&&!V[u].includes("DetermineComponentFrameRoot");)u++;if(l===M.length||u===V.length)for(l=M.length-1,u=V.length-1;1<=l&&0<=u&&M[l]!==V[u];)u--;for(;1<=l&&0<=u;l--,u--)if(M[l]!==V[u]){if(l!==1||u!==1)do if(l--,u--,0>u||M[l]!==V[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:"")?Te(a):""}function le(i,n){switch(i.tag){case 26:case 27:case 5:return Te(i.type);case 16:return Te("Lazy");case 13:return i.child!==n&&n!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("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 Te("Activity");default:return""}}function Ce(i){try{var n="",a=null;do n+=le(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var Ne=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,je=e.unstable_cancelCallback,mt=e.unstable_shouldYield,Xe=e.unstable_requestPaint,st=e.unstable_now,Qt=e.unstable_getCurrentPriorityLevel,sn=e.unstable_ImmediatePriority,ki=e.unstable_UserBlockingPriority,Jt=e.unstable_NormalPriority,Ti=e.unstable_LowPriority,Gn=e.unstable_IdlePriority,F=e.log,$e=e.unstable_setDisableYieldValue,ot=null,wt=null;function li(i){if(typeof F=="function"&&$e(i),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(ot,i)}catch{}}var Dt=Math.clz32?Math.clz32:Qn,rn=Math.log,Zn=Math.LN2;function Qn(i){return i>>>=0,i===0?32:31-(rn(i)/Zn|0)|0}var Rt=256,Pi=262144,gt=4194304;function _t(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 Ct(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=_t(l):(_&=C,_!==0?u=_t(_):a||(a=C&~i,a!==0&&(u=_t(a))))):(C=l&~d,C!==0?u=_t(C):_!==0?u=_t(_):a||(a=l&~i,a!==0&&(u=_t(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 Di(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function oi(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 qt(){var i=gt;return gt<<=1,(gt&62914560)===0&&(gt=4194304),i}function ci(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function _i(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ht(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,V=i.hiddenUpdates;for(a=_&~a;0<a;){var re=31-Dt(a),de=1<<re;C[re]=0,M[re]=-1;var Z=V[re];if(Z!==null)for(V[re]=null,re=0;re<Z.length;re++){var J=Z[re];J!==null&&(J.lane&=-536870913)}a&=~de}l!==0&&Ri(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function Ri(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-Dt(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ei(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-Dt(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function vi(i,n){var a=n&-n;return a=(a&42)!==0?1:mn(a),(a&(i.suspendedLanes|n))!==0?0:a}function mn(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 Zi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Qi(){var i=$.p;return i!==0?i:(i=window.event,i===void 0?32:ib(i.type))}function gn(i,n){var a=$.p;try{return $.p=i,n()}finally{$.p=a}}var $i=Math.random().toString(36).slice(2),Kt="__reactFiber$"+$i,yi="__reactProps$"+$i,Nn="__reactContainer$"+$i,Ir="__reactEvents$"+$i,Ll="__reactListeners$"+$i,Qs="__reactHandles$"+$i,Ra="__reactResources$"+$i,An="__reactMarker$"+$i;function Ln(i){delete i[Kt],delete i[yi],delete i[Ir],delete i[Ll],delete i[Qs]}function Bn(i){var n=i[Kt];if(n)return n;for(var a=i.parentNode;a;){if(n=a[Nn]||a[Kt]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=Uy(i);i!==null;){if(a=i[Kt])return a;i=Uy(i)}return n}i=a,a=i.parentNode}return null}function Lt(i){if(i=i[Kt]||i[Nn]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function Jn(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(r(33))}function _n(i){var n=i[Ra];return n||(n=i[Ra]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Bt(i){i[An]=!0}var ui=new Set,Ma={};function vn(i,n){es(i,n),es(i+"Capture",n)}function es(i,n){for(Ma[i]=n,i=0;i<n.length;i++)ui.add(n[i])}var Na=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]*$"),Aa={},Kr={};function ts(i){return Ne.call(Kr,i)?!0:Ne.call(Aa,i)?!1:Na.test(i)?Kr[i]=!0:(Aa[i]=!0,!1)}function hs(i,n,a){if(ts(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 ds(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function an(i,n,a,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 ti(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Js(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function it(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 is(i){if(!i._valueTracker){var n=Js(i)?"checked":"value";i._valueTracker=it(i,n,""+i[n])}}function Es(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=Js(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function ks(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 Wr=/[\n"\\]/g;function Vi(i){return i.replace(Wr,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function er(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=""+ti(n)):i.value!==""+ti(n)&&(i.value=""+ti(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?qr(i,_,ti(n)):a!=null?qr(i,_,ti(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=""+ti(C):i.removeAttribute("name")}function Fr(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)){is(i);return}a=a!=null?""+ti(a):"",n=n!=null?""+ti(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=_),is(i)}function qr(i,n,a){n==="number"&&ks(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function fs(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=""+ti(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 tr(i,n,a){if(n!=null&&(n=""+ti(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+ti(a):""}function ns(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(r(92));if(te(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=ti(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),is(i)}function ps(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Bl=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 La(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||Bl.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Yi(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&&La(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&La(i,d,n[d])}function ir(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 On=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"]]),Ts=/^[\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 Ds(i){return Ts.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function D(){}var ie=null;function He(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ke=null,We=null;function Je(i){var n=Lt(i);if(n&&(i=n.stateNode)){var a=i[yi]||null;e:switch(i=n.stateNode,n.type){case"input":if(er(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="'+Vi(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[yi]||null;if(!u)throw Error(r(90));er(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&&Es(l)}break e;case"textarea":tr(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&fs(i,!!a.multiple,n,!1)}}}var Pt=!1;function ii(i,n,a){if(Pt)return i(n,a);Pt=!0;try{var l=i(n);return l}finally{if(Pt=!1,(Ke!==null||We!==null)&&(Jc(),Ke&&(n=Ke,i=We,We=Ke=null,Je(n),i)))for(n=0;n<i.length;n++)Je(i[n])}}function vt(i,n){var a=i.stateNode;if(a===null)return null;var l=a[yi]||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 yt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ui=!1;if(yt)try{var $t={};Object.defineProperty($t,"passive",{get:function(){Ui=!0}}),window.addEventListener("test",$t,$t),window.removeEventListener("test",$t,$t)}catch{Ui=!1}var yn=null,x=null,E=null;function z(){if(E)return E;var i,n=x,a=n.length,l,u="value"in yn?yn.value:yn.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 E=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 pe(){return!1}function be(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:pe,this.isPropagationStopped=pe,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 Pe={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nt=be(Pe),Vt=y({},Pe,{view:0,detail:0}),ni=be(Vt),Ba,Bh,Ol,_c=y({},Vt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zh,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!==Ol&&(Ol&&i.type==="mousemove"?(Ba=i.screenX-Ol.screenX,Bh=i.screenY-Ol.screenY):Bh=Ba=0,Ol=i),Ba)},movementY:function(i){return"movementY"in i?i.movementY:Bh}}),Og=be(_c),sC=y({},_c,{dataTransfer:0}),rC=be(sC),aC=y({},Vt,{relatedTarget:0}),Oh=be(aC),lC=y({},Pe,{animationName:0,elapsedTime:0,pseudoElement:0}),oC=be(lC),cC=y({},Pe,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),uC=be(cC),hC=y({},Pe,{data:0}),zg=be(hC),dC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fC={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},pC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=pC[i])?!!n[i]:!1}function zh(){return mC}var gC=y({},Vt,{key:function(i){if(i.key){var n=dC[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"?fC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zh,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}}),_C=be(gC),vC=y({},_c,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jg=be(vC),yC=y({},Vt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zh}),bC=be(yC),SC=y({},Pe,{propertyName:0,elapsedTime:0,pseudoElement:0}),wC=be(SC),CC=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}),xC=be(CC),EC=y({},Pe,{newState:0,oldState:0}),kC=be(EC),TC=[9,13,27,32],jh=yt&&"CompositionEvent"in window,zl=null;yt&&"documentMode"in document&&(zl=document.documentMode);var DC=yt&&"TextEvent"in window&&!zl,Hg=yt&&(!jh||zl&&8<zl&&11>=zl),Pg=" ",Ug=!1;function Ig(i,n){switch(i){case"keyup":return TC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kg(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Oa=!1;function RC(i,n){switch(i){case"compositionend":return Kg(n);case"keypress":return n.which!==32?null:(Ug=!0,Pg);case"textInput":return i=n.data,i===Pg&&Ug?null:i;default:return null}}function MC(i,n){if(Oa)return i==="compositionend"||!jh&&Ig(i,n)?(i=z(),E=x=yn=null,Oa=!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 Hg&&n.locale!=="ko"?null:n.data;default:return null}}var NC={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 Wg(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!NC[i.type]:n==="textarea"}function Fg(i,n,a,l){Ke?We?We.push(l):We=[l]:Ke=l,n=au(n,"onChange"),0<n.length&&(a=new nt("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var jl=null,Hl=null;function AC(i){ky(i,0)}function vc(i){var n=Jn(i);if(Es(n))return i}function qg(i,n){if(i==="change")return n}var $g=!1;if(yt){var Hh;if(yt){var Ph="oninput"in document;if(!Ph){var Vg=document.createElement("div");Vg.setAttribute("oninput","return;"),Ph=typeof Vg.oninput=="function"}Hh=Ph}else Hh=!1;$g=Hh&&(!document.documentMode||9<document.documentMode)}function Yg(){jl&&(jl.detachEvent("onpropertychange",Xg),Hl=jl=null)}function Xg(i){if(i.propertyName==="value"&&vc(Hl)){var n=[];Fg(n,Hl,i,He(i)),ii(AC,n)}}function LC(i,n,a){i==="focusin"?(Yg(),jl=n,Hl=a,jl.attachEvent("onpropertychange",Xg)):i==="focusout"&&Yg()}function BC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return vc(Hl)}function OC(i,n){if(i==="click")return vc(n)}function zC(i,n){if(i==="input"||i==="change")return vc(n)}function jC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var bn=typeof Object.is=="function"?Object.is:jC;function Pl(i,n){if(bn(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(!Ne.call(n,u)||!bn(i[u],n[u]))return!1}return!0}function Gg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Zg(i,n){var a=Gg(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=Gg(a)}}function Qg(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?Qg(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function Jg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=ks(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=ks(i.document)}return n}function Uh(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 HC=yt&&"documentMode"in document&&11>=document.documentMode,za=null,Ih=null,Ul=null,Kh=!1;function e_(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Kh||za==null||za!==ks(l)||(l=za,"selectionStart"in l&&Uh(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}),Ul&&Pl(Ul,l)||(Ul=l,l=au(Ih,"onSelect"),0<l.length&&(n=new nt("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=za)))}function $r(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var ja={animationend:$r("Animation","AnimationEnd"),animationiteration:$r("Animation","AnimationIteration"),animationstart:$r("Animation","AnimationStart"),transitionrun:$r("Transition","TransitionRun"),transitionstart:$r("Transition","TransitionStart"),transitioncancel:$r("Transition","TransitionCancel"),transitionend:$r("Transition","TransitionEnd")},Wh={},t_={};yt&&(t_=document.createElement("div").style,"AnimationEvent"in window||(delete ja.animationend.animation,delete ja.animationiteration.animation,delete ja.animationstart.animation),"TransitionEvent"in window||delete ja.transitionend.transition);function Vr(i){if(Wh[i])return Wh[i];if(!ja[i])return i;var n=ja[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in t_)return Wh[i]=n[a];return i}var i_=Vr("animationend"),n_=Vr("animationiteration"),s_=Vr("animationstart"),PC=Vr("transitionrun"),UC=Vr("transitionstart"),IC=Vr("transitioncancel"),r_=Vr("transitionend"),a_=new Map,Fh="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(" ");Fh.push("scrollEnd");function ss(i,n){a_.set(i,n),vn(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=[],Ha=0,qh=0;function bc(){for(var i=Ha,n=qh=Ha=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&&l_(a,u,d)}}function Sc(i,n,a,l){zn[Ha++]=i,zn[Ha++]=n,zn[Ha++]=a,zn[Ha++]=l,qh|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function $h(i,n,a,l){return Sc(i,n,a,l),wc(i)}function Yr(i,n){return Sc(i,null,null,n),wc(i)}function l_(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-Dt(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<oo)throw oo=0,tf=null,Error(r(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var Pa={};function KC(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 Sn(i,n,a,l){return new KC(i,n,a,l)}function Vh(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Rs(i,n){var a=i.alternate;return a===null?(a=Sn(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 o_(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")Vh(i)&&(_=1);else if(typeof i=="string")_=Vx(i,a,me.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=Sn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case T:return Xr(a.children,u,d,n);case B:_=8,u|=24;break;case L:return i=Sn(12,a,n,u|2),i.elementType=L,i.lanes=d,i;case ee:return i=Sn(13,a,n,u),i.elementType=ee,i.lanes=d,i;case se:return i=Sn(19,a,n,u),i.elementType=se,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case W:_=10;break e;case A:_=9;break e;case I:_=11;break e;case ae:_=14;break e;case oe:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return n=Sn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function Xr(i,n,a,l){return i=Sn(7,i,l,n),i.lanes=a,i}function Yh(i,n,a){return i=Sn(6,i,null,n),i.lanes=a,i}function c_(i){var n=Sn(18,null,null,0);return n.stateNode=i,n}function Xh(i,n,a){return n=Sn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var u_=new WeakMap;function jn(i,n){if(typeof i=="object"&&i!==null){var a=u_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:Ce(n)},u_.set(i,n),n)}return{value:i,source:n,stack:Ce(n)}}var Ua=[],Ia=0,xc=null,Il=0,Hn=[],Pn=0,nr=null,ms=1,gs="";function Ms(i,n){Ua[Ia++]=Il,Ua[Ia++]=xc,xc=i,Il=n}function h_(i,n,a){Hn[Pn++]=ms,Hn[Pn++]=gs,Hn[Pn++]=nr,nr=i;var l=ms;i=gs;var u=32-Dt(l)-1;l&=~(1<<u),a+=1;var d=32-Dt(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,ms=1<<32-Dt(n)+u|a<<u|l,gs=d+i}else ms=1<<d|a<<u|l,gs=i}function Gh(i){i.return!==null&&(Ms(i,1),h_(i,1,0))}function Zh(i){for(;i===xc;)xc=Ua[--Ia],Ua[Ia]=null,Il=Ua[--Ia],Ua[Ia]=null;for(;i===nr;)nr=Hn[--Pn],Hn[Pn]=null,gs=Hn[--Pn],Hn[Pn]=null,ms=Hn[--Pn],Hn[Pn]=null}function d_(i,n){Hn[Pn++]=ms,Hn[Pn++]=gs,Hn[Pn++]=nr,ms=n.id,gs=n.overflow,nr=i}var Ii=null,Ot=null,ht=!1,sr=null,Un=!1,Qh=Error(r(519));function rr(i){var n=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Kl(jn(n,i)),Qh}function f_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[Kt]=i,n[yi]=l,a){case"dialog":at("cancel",n),at("close",n);break;case"iframe":case"object":case"embed":at("load",n);break;case"video":case"audio":for(a=0;a<uo.length;a++)at(uo[a],n);break;case"source":at("error",n);break;case"img":case"image":case"link":at("error",n),at("load",n);break;case"details":at("toggle",n);break;case"input":at("invalid",n),Fr(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":at("invalid",n);break;case"textarea":at("invalid",n),ns(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||My(n.textContent,a)?(l.popover!=null&&(at("beforetoggle",n),at("toggle",n)),l.onScroll!=null&&at("scroll",n),l.onScrollEnd!=null&&at("scrollend",n),l.onClick!=null&&(n.onclick=D),n=!0):n=!1,n||rr(i,!0)}function p_(i){for(Ii=i.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:Un=!1;return;case 27:case 3:Un=!0;return;default:Ii=Ii.return}}function Ka(i){if(i!==Ii)return!1;if(!ht)return p_(i),ht=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||_f(i.type,i.memoizedProps)),a=!a),a&&Ot&&rr(i),p_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Py(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Py(i)}else n===27?(n=Ot,yr(i.type)?(i=wf,wf=null,Ot=i):Ot=n):Ot=Ii?Kn(i.stateNode.nextSibling):null;return!0}function Gr(){Ot=Ii=null,ht=!1}function Jh(){var i=sr;return i!==null&&(un===null?un=i:un.push.apply(un,i),sr=null),i}function Kl(i){sr===null?sr=[i]:sr.push(i)}var ed=R(null),Zr=null,Ns=null;function ar(i,n,a){ce(ed,n._currentValue),n._currentValue=a}function As(i){i._currentValue=ed.current,G(ed)}function td(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 id(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),td(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),td(_,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 Wa(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;bn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Me.current){if(_=u.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(go):i=[go])}u=u.return}i!==null&&id(n,i,a,l),n.flags|=262144}function Ec(i){for(i=i.firstContext;i!==null;){if(!bn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Qr(i){Zr=i,Ns=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ki(i){return m_(Zr,i)}function kc(i,n){return Zr===null&&Qr(i),m_(i,n)}function m_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Ns===null){if(i===null)throw Error(r(308));Ns=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Ns=Ns.next=n;return a}var WC=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()})}},FC=e.unstable_scheduleCallback,qC=e.unstable_NormalPriority,hi={$$typeof:W,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function nd(){return{controller:new WC,data:new Map,refCount:0}}function Wl(i){i.refCount--,i.refCount===0&&FC(qC,function(){i.controller.abort()})}var Fl=null,sd=0,Fa=0,qa=null;function $C(i,n){if(Fl===null){var a=Fl=[];sd=0,Fa=of(),qa={status:"pending",value:void 0,then:function(l){a.push(l)}}}return sd++,n.then(g_,g_),n}function g_(){if(--sd===0&&Fl!==null){qa!==null&&(qa.status="fulfilled");var i=Fl;Fl=null,Fa=0,qa=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function VC(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 __=N.S;N.S=function(i,n){ey=st(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&$C(i,n),__!==null&&__(i,n)};var Jr=R(null);function rd(){var i=Jr.current;return i!==null?i:Mt.pooledCache}function Tc(i,n){n===null?ce(Jr,Jr.current):ce(Jr,n.pool)}function v_(){var i=rd();return i===null?null:{parent:hi._currentValue,pool:i}}var $a=Error(r(460)),ad=Error(r(474)),Dc=Error(r(542)),Rc={then:function(){}};function y_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function b_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(D,D),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,w_(i),i;default:if(typeof n.status=="string")n.then(D,D);else{if(i=Mt,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,w_(i),i}throw ta=n,$a}}function ea(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ta=a,$a):a}}var ta=null;function S_(){if(ta===null)throw Error(r(459));var i=ta;return ta=null,i}function w_(i){if(i===$a||i===Dc)throw Error(r(483))}var Va=null,ql=0;function Mc(i){var n=ql;return ql+=1,Va===null&&(Va=[]),b_(Va,i,n)}function $l(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Nc(i,n){throw n.$$typeof===S?Error(r(525)):(i=Object.prototype.toString.call(n),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function C_(i){function n(P,O){if(i){var q=P.deletions;q===null?(P.deletions=[O],P.flags|=16):q.push(O)}}function a(P,O){if(!i)return null;for(;O!==null;)n(P,O),O=O.sibling;return null}function l(P){for(var O=new Map;P!==null;)P.key!==null?O.set(P.key,P):O.set(P.index,P),P=P.sibling;return O}function u(P,O){return P=Rs(P,O),P.index=0,P.sibling=null,P}function d(P,O,q){return P.index=q,i?(q=P.alternate,q!==null?(q=q.index,q<O?(P.flags|=67108866,O):q):(P.flags|=67108866,O)):(P.flags|=1048576,O)}function _(P){return i&&P.alternate===null&&(P.flags|=67108866),P}function C(P,O,q,ue){return O===null||O.tag!==6?(O=Yh(q,P.mode,ue),O.return=P,O):(O=u(O,q),O.return=P,O)}function M(P,O,q,ue){var Ue=q.type;return Ue===T?re(P,O,q.props.children,ue,q.key):O!==null&&(O.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===oe&&ea(Ue)===O.type)?(O=u(O,q.props),$l(O,q),O.return=P,O):(O=Cc(q.type,q.key,q.props,null,P.mode,ue),$l(O,q),O.return=P,O)}function V(P,O,q,ue){return O===null||O.tag!==4||O.stateNode.containerInfo!==q.containerInfo||O.stateNode.implementation!==q.implementation?(O=Xh(q,P.mode,ue),O.return=P,O):(O=u(O,q.children||[]),O.return=P,O)}function re(P,O,q,ue,Ue){return O===null||O.tag!==7?(O=Xr(q,P.mode,ue,Ue),O.return=P,O):(O=u(O,q),O.return=P,O)}function de(P,O,q){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=Yh(""+O,P.mode,q),O.return=P,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case w:return q=Cc(O.type,O.key,O.props,null,P.mode,q),$l(q,O),q.return=P,q;case k:return O=Xh(O,P.mode,q),O.return=P,O;case oe:return O=ea(O),de(P,O,q)}if(te(O)||Y(O))return O=Xr(O,P.mode,q,null),O.return=P,O;if(typeof O.then=="function")return de(P,Mc(O),q);if(O.$$typeof===W)return de(P,kc(P,O),q);Nc(P,O)}return null}function Z(P,O,q,ue){var Ue=O!==null?O.key:null;if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return Ue!==null?null:C(P,O,""+q,ue);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case w:return q.key===Ue?M(P,O,q,ue):null;case k:return q.key===Ue?V(P,O,q,ue):null;case oe:return q=ea(q),Z(P,O,q,ue)}if(te(q)||Y(q))return Ue!==null?null:re(P,O,q,ue,null);if(typeof q.then=="function")return Z(P,O,Mc(q),ue);if(q.$$typeof===W)return Z(P,O,kc(P,q),ue);Nc(P,q)}return null}function J(P,O,q,ue,Ue){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return P=P.get(q)||null,C(O,P,""+ue,Ue);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case w:return P=P.get(ue.key===null?q:ue.key)||null,M(O,P,ue,Ue);case k:return P=P.get(ue.key===null?q:ue.key)||null,V(O,P,ue,Ue);case oe:return ue=ea(ue),J(P,O,q,ue,Ue)}if(te(ue)||Y(ue))return P=P.get(q)||null,re(O,P,ue,Ue,null);if(typeof ue.then=="function")return J(P,O,q,Mc(ue),Ue);if(ue.$$typeof===W)return J(P,O,q,kc(O,ue),Ue);Nc(O,ue)}return null}function Ae(P,O,q,ue){for(var Ue=null,dt=null,ze=O,Ze=O=0,ut=null;ze!==null&&Ze<q.length;Ze++){ze.index>Ze?(ut=ze,ze=null):ut=ze.sibling;var ft=Z(P,ze,q[Ze],ue);if(ft===null){ze===null&&(ze=ut);break}i&&ze&&ft.alternate===null&&n(P,ze),O=d(ft,O,Ze),dt===null?Ue=ft:dt.sibling=ft,dt=ft,ze=ut}if(Ze===q.length)return a(P,ze),ht&&Ms(P,Ze),Ue;if(ze===null){for(;Ze<q.length;Ze++)ze=de(P,q[Ze],ue),ze!==null&&(O=d(ze,O,Ze),dt===null?Ue=ze:dt.sibling=ze,dt=ze);return ht&&Ms(P,Ze),Ue}for(ze=l(ze);Ze<q.length;Ze++)ut=J(ze,P,Ze,q[Ze],ue),ut!==null&&(i&&ut.alternate!==null&&ze.delete(ut.key===null?Ze:ut.key),O=d(ut,O,Ze),dt===null?Ue=ut:dt.sibling=ut,dt=ut);return i&&ze.forEach(function(xr){return n(P,xr)}),ht&&Ms(P,Ze),Ue}function Fe(P,O,q,ue){if(q==null)throw Error(r(151));for(var Ue=null,dt=null,ze=O,Ze=O=0,ut=null,ft=q.next();ze!==null&&!ft.done;Ze++,ft=q.next()){ze.index>Ze?(ut=ze,ze=null):ut=ze.sibling;var xr=Z(P,ze,ft.value,ue);if(xr===null){ze===null&&(ze=ut);break}i&&ze&&xr.alternate===null&&n(P,ze),O=d(xr,O,Ze),dt===null?Ue=xr:dt.sibling=xr,dt=xr,ze=ut}if(ft.done)return a(P,ze),ht&&Ms(P,Ze),Ue;if(ze===null){for(;!ft.done;Ze++,ft=q.next())ft=de(P,ft.value,ue),ft!==null&&(O=d(ft,O,Ze),dt===null?Ue=ft:dt.sibling=ft,dt=ft);return ht&&Ms(P,Ze),Ue}for(ze=l(ze);!ft.done;Ze++,ft=q.next())ft=J(ze,P,Ze,ft.value,ue),ft!==null&&(i&&ft.alternate!==null&&ze.delete(ft.key===null?Ze:ft.key),O=d(ft,O,Ze),dt===null?Ue=ft:dt.sibling=ft,dt=ft);return i&&ze.forEach(function(sE){return n(P,sE)}),ht&&Ms(P,Ze),Ue}function kt(P,O,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 w:e:{for(var Ue=q.key;O!==null;){if(O.key===Ue){if(Ue=q.type,Ue===T){if(O.tag===7){a(P,O.sibling),ue=u(O,q.props.children),ue.return=P,P=ue;break e}}else if(O.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===oe&&ea(Ue)===O.type){a(P,O.sibling),ue=u(O,q.props),$l(ue,q),ue.return=P,P=ue;break e}a(P,O);break}else n(P,O);O=O.sibling}q.type===T?(ue=Xr(q.props.children,P.mode,ue,q.key),ue.return=P,P=ue):(ue=Cc(q.type,q.key,q.props,null,P.mode,ue),$l(ue,q),ue.return=P,P=ue)}return _(P);case k:e:{for(Ue=q.key;O!==null;){if(O.key===Ue)if(O.tag===4&&O.stateNode.containerInfo===q.containerInfo&&O.stateNode.implementation===q.implementation){a(P,O.sibling),ue=u(O,q.children||[]),ue.return=P,P=ue;break e}else{a(P,O);break}else n(P,O);O=O.sibling}ue=Xh(q,P.mode,ue),ue.return=P,P=ue}return _(P);case oe:return q=ea(q),kt(P,O,q,ue)}if(te(q))return Ae(P,O,q,ue);if(Y(q)){if(Ue=Y(q),typeof Ue!="function")throw Error(r(150));return q=Ue.call(q),Fe(P,O,q,ue)}if(typeof q.then=="function")return kt(P,O,Mc(q),ue);if(q.$$typeof===W)return kt(P,O,kc(P,q),ue);Nc(P,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,O!==null&&O.tag===6?(a(P,O.sibling),ue=u(O,q),ue.return=P,P=ue):(a(P,O),ue=Yh(q,P.mode,ue),ue.return=P,P=ue),_(P)):a(P,O)}return function(P,O,q,ue){try{ql=0;var Ue=kt(P,O,q,ue);return Va=null,Ue}catch(ze){if(ze===$a||ze===Dc)throw ze;var dt=Sn(29,ze,null,P.mode);return dt.lanes=ue,dt.return=P,dt}}}var ia=C_(!0),x_=C_(!1),lr=!1;function ld(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function od(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 or(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function cr(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(pt&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),l_(i,null,a),n}return Sc(i,l,n,a),wc(i)}function Vl(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,ei(i,a)}}function cd(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 ud=!1;function Yl(){if(ud){var i=qa;if(i!==null)throw i}}function Xl(i,n,a,l){ud=!1;var u=i.updateQueue;lr=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var M=C,V=M.next;M.next=null,_===null?d=V:_.next=V,_=M;var re=i.alternate;re!==null&&(re=re.updateQueue,C=re.lastBaseUpdate,C!==_&&(C===null?re.firstBaseUpdate=V:C.next=V,re.lastBaseUpdate=M))}if(d!==null){var de=u.baseState;_=0,re=V=M=null,C=d;do{var Z=C.lane&-536870913,J=Z!==C.lane;if(J?(ct&Z)===Z:(l&Z)===Z){Z!==0&&Z===Fa&&(ud=!0),re!==null&&(re=re.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Ae=i,Fe=C;Z=n;var kt=a;switch(Fe.tag){case 1:if(Ae=Fe.payload,typeof Ae=="function"){de=Ae.call(kt,de,Z);break e}de=Ae;break e;case 3:Ae.flags=Ae.flags&-65537|128;case 0:if(Ae=Fe.payload,Z=typeof Ae=="function"?Ae.call(kt,de,Z):Ae,Z==null)break e;de=y({},de,Z);break e;case 2:lr=!0}}Z=C.callback,Z!==null&&(i.flags|=64,J&&(i.flags|=8192),J=u.callbacks,J===null?u.callbacks=[Z]:J.push(Z))}else J={lane:Z,tag:C.tag,payload:C.payload,callback:C.callback,next:null},re===null?(V=re=J,M=de):re=re.next=J,_|=Z;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;J=C,C=J.next,J.next=null,u.lastBaseUpdate=J,u.shared.pending=null}}while(!0);re===null&&(M=de),u.baseState=M,u.firstBaseUpdate=V,u.lastBaseUpdate=re,d===null&&(u.shared.lanes=0),pr|=_,i.lanes=_,i.memoizedState=de}}function E_(i,n){if(typeof i!="function")throw Error(r(191,i));i.call(n)}function k_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)E_(a[i],n)}var Ya=R(null),Ac=R(0);function T_(i,n){i=Is,ce(Ac,i),ce(Ya,n),Is=i|n.baseLanes}function hd(){ce(Ac,Is),ce(Ya,Ya.current)}function dd(){Is=Ac.current,G(Ya),G(Ac)}var wn=R(null),In=null;function ur(i){var n=i.alternate;ce(si,si.current&1),ce(wn,i),In===null&&(n===null||Ya.current!==null||n.memoizedState!==null)&&(In=i)}function fd(i){ce(si,si.current),ce(wn,i),In===null&&(In=i)}function D_(i){i.tag===22?(ce(si,si.current),ce(wn,i),In===null&&(In=i)):hr()}function hr(){ce(si,si.current),ce(wn,wn.current)}function Cn(i){G(wn),In===i&&(In=null),G(si)}var si=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||bf(a)||Sf(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 Ls=0,Ge=null,xt=null,di=null,Bc=!1,Xa=!1,na=!1,Oc=0,Gl=0,Ga=null,YC=0;function Yt(){throw Error(r(321))}function pd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!bn(i[a],n[a]))return!1;return!0}function md(i,n,a,l,u,d){return Ls=d,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,N.H=i===null||i.memoizedState===null?hv:Md,na=!1,d=a(l,u),na=!1,Xa&&(d=M_(n,a,l,u)),R_(i),d}function R_(i){N.H=Jl;var n=xt!==null&&xt.next!==null;if(Ls=0,di=xt=Ge=null,Bc=!1,Gl=0,Ga=null,n)throw Error(r(300));i===null||fi||(i=i.dependencies,i!==null&&Ec(i)&&(fi=!0))}function M_(i,n,a,l){Ge=i;var u=0;do{if(Xa&&(Ga=null),Gl=0,Xa=!1,25<=u)throw Error(r(301));if(u+=1,di=xt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}N.H=dv,d=n(a,l)}while(Xa);return d}function XC(){var i=N.H,n=i.useState()[0];return n=typeof n.then=="function"?Zl(n):n,i=i.useState()[0],(xt!==null?xt.memoizedState:null)!==i&&(Ge.flags|=1024),n}function gd(){var i=Oc!==0;return Oc=0,i}function _d(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function vd(i){if(Bc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Bc=!1}Ls=0,di=xt=Ge=null,Xa=!1,Gl=Oc=0,Ga=null}function Ji(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return di===null?Ge.memoizedState=di=i:di=di.next=i,di}function ri(){if(xt===null){var i=Ge.alternate;i=i!==null?i.memoizedState:null}else i=xt.next;var n=di===null?Ge.memoizedState:di.next;if(n!==null)di=n,xt=i;else{if(i===null)throw Ge.alternate===null?Error(r(467)):Error(r(310));xt=i,i={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},di===null?Ge.memoizedState=di=i:di=di.next=i}return di}function zc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Zl(i){var n=Gl;return Gl+=1,Ga===null&&(Ga=[]),i=b_(Ga,i,n),n=Ge,(di===null?n.memoizedState:di.next)===null&&(n=n.alternate,N.H=n===null||n.memoizedState===null?hv:Md),i}function jc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Zl(i);if(i.$$typeof===W)return Ki(i)}throw Error(r(438,String(i)))}function yd(i){var n=null,a=Ge.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Ge.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(),Ge.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]=U;return n.index++,a}function Bs(i,n){return typeof n=="function"?n(i):n}function Hc(i){var n=ri();return bd(n,xt,i)}function bd(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,V=n,re=!1;do{var de=V.lane&-536870913;if(de!==V.lane?(ct&de)===de:(Ls&de)===de){var Z=V.revertLane;if(Z===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),de===Fa&&(re=!0);else if((Ls&Z)===Z){V=V.next,Z===Fa&&(re=!0);continue}else de={lane:0,revertLane:V.revertLane,gesture:null,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},M===null?(C=M=de,_=d):M=M.next=de,Ge.lanes|=Z,pr|=Z;de=V.action,na&&a(d,de),d=V.hasEagerState?V.eagerState:a(d,de)}else Z={lane:de,revertLane:V.revertLane,gesture:V.gesture,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null},M===null?(C=M=Z,_=d):M=M.next=Z,Ge.lanes|=de,pr|=de;V=V.next}while(V!==null&&V!==n);if(M===null?_=d:M.next=C,!bn(d,i.memoizedState)&&(fi=!0,re&&(a=qa,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 Sd(i){var n=ri(),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);bn(d,n.memoizedState)||(fi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function N_(i,n,a){var l=Ge,u=ri(),d=ht;if(d){if(a===void 0)throw Error(r(407));a=a()}else a=n();var _=!bn((xt||u).memoizedState,a);if(_&&(u.memoizedState=a,fi=!0),u=u.queue,xd(B_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||di!==null&&di.memoizedState.tag&1){if(l.flags|=2048,Za(9,{destroy:void 0},L_.bind(null,l,u,a,n),null),Mt===null)throw Error(r(349));d||(Ls&127)!==0||A_(l,n,a)}return a}function A_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Ge.updateQueue,n===null?(n=zc(),Ge.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function L_(i,n,a,l){n.value=a,n.getSnapshot=l,O_(n)&&z_(i)}function B_(i,n,a){return a(function(){O_(n)&&z_(i)})}function O_(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!bn(i,a)}catch{return!0}}function z_(i){var n=Yr(i,2);n!==null&&hn(n,i,2)}function wd(i){var n=Ji();if(typeof i=="function"){var a=i;if(i=a(),na){li(!0);try{a()}finally{li(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:i},n}function j_(i,n,a,l){return i.baseState=a,bd(i,xt,typeof l=="function"?l:Bs)}function GC(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(_)}};N.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,H_(n,d)):(d.next=a.next,n.pending=a.next=d)}}function H_(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=N.T,_={};N.T=_;try{var C=a(u,l),M=N.S;M!==null&&M(_,C),P_(i,n,C)}catch(V){Cd(i,n,V)}finally{d!==null&&_.types!==null&&(d.types=_.types),N.T=d}}else try{d=a(u,l),P_(i,n,d)}catch(V){Cd(i,n,V)}}function P_(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){U_(i,n,l)},function(l){return Cd(i,n,l)}):U_(i,n,a)}function U_(i,n,a){n.status="fulfilled",n.value=a,I_(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,H_(i,a)))}function Cd(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,I_(n),n=n.next;while(n!==l)}i.action=null}function I_(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function K_(i,n){return n}function W_(i,n){if(ht){var a=Mt.formState;if(a!==null){e:{var l=Ge;if(ht){if(Ot){t:{for(var u=Ot,d=Un;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){Ot=Kn(u.nextSibling),l=u.data==="F!";break e}}rr(l)}l=!1}l&&(n=a[0])}}return a=Ji(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:K_,lastRenderedState:n},a.queue=l,a=ov.bind(null,Ge,l),l.dispatch=a,l=wd(!1),d=Rd.bind(null,Ge,!1,l.queue),l=Ji(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=GC.bind(null,Ge,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function F_(i){var n=ri();return q_(n,xt,i)}function q_(i,n,a){if(n=bd(i,n,K_)[0],i=Hc(Bs)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=Zl(n)}catch(_){throw _===$a?Dc:_}else l=n;n=ri();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Ge.flags|=2048,Za(9,{destroy:void 0},ZC.bind(null,u,a),null)),[l,d,i]}function ZC(i,n){i.action=n}function $_(i){var n=ri(),a=xt;if(a!==null)return q_(n,a,i);ri(),n=n.memoizedState,a=ri();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function Za(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Ge.updateQueue,n===null&&(n=zc(),Ge.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 V_(){return ri().memoizedState}function Pc(i,n,a,l){var u=Ji();Ge.flags|=i,u.memoizedState=Za(1|n,{destroy:void 0},a,l===void 0?null:l)}function Uc(i,n,a,l){var u=ri();l=l===void 0?null:l;var d=u.memoizedState.inst;xt!==null&&l!==null&&pd(l,xt.memoizedState.deps)?u.memoizedState=Za(n,d,a,l):(Ge.flags|=i,u.memoizedState=Za(1|n,d,a,l))}function Y_(i,n){Pc(8390656,8,i,n)}function xd(i,n){Uc(2048,8,i,n)}function QC(i){Ge.flags|=4;var n=Ge.updateQueue;if(n===null)n=zc(),Ge.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function X_(i){var n=ri().memoizedState;return QC({ref:n,nextImpl:i}),function(){if((pt&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}function G_(i,n){return Uc(4,2,i,n)}function Z_(i,n){return Uc(4,4,i,n)}function Q_(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 J_(i,n,a){a=a!=null?a.concat([i]):null,Uc(4,4,Q_.bind(null,n,i),a)}function Ed(){}function ev(i,n){var a=ri();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&pd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function tv(i,n){var a=ri();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&pd(n,l[1]))return l[0];if(l=i(),na){li(!0);try{i()}finally{li(!1)}}return a.memoizedState=[l,n],l}function kd(i,n,a){return a===void 0||(Ls&1073741824)!==0&&(ct&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=iy(),Ge.lanes|=i,pr|=i,a)}function iv(i,n,a,l){return bn(a,n)?a:Ya.current!==null?(i=kd(i,a,l),bn(i,n)||(fi=!0),i):(Ls&42)===0||(Ls&1073741824)!==0&&(ct&261930)===0?(fi=!0,i.memoizedState=a):(i=iy(),Ge.lanes|=i,pr|=i,n)}function nv(i,n,a,l,u){var d=$.p;$.p=d!==0&&8>d?d:8;var _=N.T,C={};N.T=C,Rd(i,!1,n,a);try{var M=u(),V=N.S;if(V!==null&&V(C,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var re=VC(M,l);Ql(i,n,re,kn(i))}else Ql(i,n,l,kn(i))}catch(de){Ql(i,n,{then:function(){},status:"rejected",reason:de},kn())}finally{$.p=d,_!==null&&C.types!==null&&(_.types=C.types),N.T=_}}function JC(){}function Td(i,n,a,l){if(i.tag!==5)throw Error(r(476));var u=sv(i).queue;nv(i,u,n,X,a===null?JC:function(){return rv(i),a(l)})}function sv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:X},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bs,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function rv(i){var n=sv(i);n.next===null&&(n=i.alternate.memoizedState),Ql(i,n.next.queue,{},kn())}function Dd(){return Ki(go)}function av(){return ri().memoizedState}function lv(){return ri().memoizedState}function ex(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=kn();i=or(a);var l=cr(n,i,a);l!==null&&(hn(l,n,a),Vl(l,n,a)),n={cache:nd()},i.payload=n;return}n=n.return}}function tx(i,n,a){var l=kn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ic(i)?cv(n,a):(a=$h(i,n,a,l),a!==null&&(hn(a,i,l),uv(a,n,l)))}function ov(i,n,a){var l=kn();Ql(i,n,a,l)}function Ql(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ic(i))cv(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,bn(C,_))return Sc(i,n,u,0),Mt===null&&bc(),!1}catch{}if(a=$h(i,n,u,l),a!==null)return hn(a,i,l),uv(a,n,l),!0}return!1}function Rd(i,n,a,l){if(l={lane:2,revertLane:of(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ic(i)){if(n)throw Error(r(479))}else n=$h(i,a,l,2),n!==null&&hn(n,i,2)}function Ic(i){var n=i.alternate;return i===Ge||n!==null&&n===Ge}function cv(i,n){Xa=Bc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function uv(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ei(i,a)}}var Jl={readContext:Ki,use:jc,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useLayoutEffect:Yt,useInsertionEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useSyncExternalStore:Yt,useId:Yt,useHostTransitionStatus:Yt,useFormState:Yt,useActionState:Yt,useOptimistic:Yt,useMemoCache:Yt,useCacheRefresh:Yt};Jl.useEffectEvent=Yt;var hv={readContext:Ki,use:jc,useCallback:function(i,n){return Ji().memoizedState=[i,n===void 0?null:n],i},useContext:Ki,useEffect:Y_,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,Pc(4194308,4,Q_.bind(null,n,i),a)},useLayoutEffect:function(i,n){return Pc(4194308,4,i,n)},useInsertionEffect:function(i,n){Pc(4,2,i,n)},useMemo:function(i,n){var a=Ji();n=n===void 0?null:n;var l=i();if(na){li(!0);try{i()}finally{li(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=Ji();if(a!==void 0){var u=a(n);if(na){li(!0);try{a(n)}finally{li(!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=tx.bind(null,Ge,i),[l.memoizedState,i]},useRef:function(i){var n=Ji();return i={current:i},n.memoizedState=i},useState:function(i){i=wd(i);var n=i.queue,a=ov.bind(null,Ge,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:Ed,useDeferredValue:function(i,n){var a=Ji();return kd(a,i,n)},useTransition:function(){var i=wd(!1);return i=nv.bind(null,Ge,i.queue,!0,!1),Ji().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Ge,u=Ji();if(ht){if(a===void 0)throw Error(r(407));a=a()}else{if(a=n(),Mt===null)throw Error(r(349));(ct&127)!==0||A_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,Y_(B_.bind(null,l,d,i),[i]),l.flags|=2048,Za(9,{destroy:void 0},L_.bind(null,l,d,a,n),null),a},useId:function(){var i=Ji(),n=Mt.identifierPrefix;if(ht){var a=gs,l=ms;a=(l&~(1<<32-Dt(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Oc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=YC++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Dd,useFormState:W_,useActionState:W_,useOptimistic:function(i){var n=Ji();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Rd.bind(null,Ge,!0,a),a.dispatch=n,[i,n]},useMemoCache:yd,useCacheRefresh:function(){return Ji().memoizedState=ex.bind(null,Ge)},useEffectEvent:function(i){var n=Ji(),a={impl:i};return n.memoizedState=a,function(){if((pt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Md={readContext:Ki,use:jc,useCallback:ev,useContext:Ki,useEffect:xd,useImperativeHandle:J_,useInsertionEffect:G_,useLayoutEffect:Z_,useMemo:tv,useReducer:Hc,useRef:V_,useState:function(){return Hc(Bs)},useDebugValue:Ed,useDeferredValue:function(i,n){var a=ri();return iv(a,xt.memoizedState,i,n)},useTransition:function(){var i=Hc(Bs)[0],n=ri().memoizedState;return[typeof i=="boolean"?i:Zl(i),n]},useSyncExternalStore:N_,useId:av,useHostTransitionStatus:Dd,useFormState:F_,useActionState:F_,useOptimistic:function(i,n){var a=ri();return j_(a,xt,i,n)},useMemoCache:yd,useCacheRefresh:lv};Md.useEffectEvent=X_;var dv={readContext:Ki,use:jc,useCallback:ev,useContext:Ki,useEffect:xd,useImperativeHandle:J_,useInsertionEffect:G_,useLayoutEffect:Z_,useMemo:tv,useReducer:Sd,useRef:V_,useState:function(){return Sd(Bs)},useDebugValue:Ed,useDeferredValue:function(i,n){var a=ri();return xt===null?kd(a,i,n):iv(a,xt.memoizedState,i,n)},useTransition:function(){var i=Sd(Bs)[0],n=ri().memoizedState;return[typeof i=="boolean"?i:Zl(i),n]},useSyncExternalStore:N_,useId:av,useHostTransitionStatus:Dd,useFormState:$_,useActionState:$_,useOptimistic:function(i,n){var a=ri();return xt!==null?j_(a,xt,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:yd,useCacheRefresh:lv};dv.useEffectEvent=X_;function Nd(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 Ad={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=kn(),u=or(l);u.payload=n,a!=null&&(u.callback=a),n=cr(i,u,l),n!==null&&(hn(n,i,l),Vl(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=kn(),u=or(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=cr(i,u,l),n!==null&&(hn(n,i,l),Vl(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=kn(),l=or(a);l.tag=2,n!=null&&(l.callback=n),n=cr(i,l,a),n!==null&&(hn(n,i,a),Vl(n,i,a))}};function fv(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!Pl(a,l)||!Pl(u,d):!0}function pv(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&&Ad.enqueueReplaceState(n,n.state,null)}function sa(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 mv(i){yc(i)}function gv(i){console.error(i)}function _v(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 vv(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 Ld(i,n,a){return a=or(a),a.tag=3,a.payload={element:null},a.callback=function(){Kc(i,n)},a}function yv(i){return i=or(i),i.tag=3,i}function bv(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(){vv(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){vv(n,a,l),typeof u!="function"&&(mr===null?mr=new Set([this]):mr.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function ix(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&Wa(n,a,u,!0),a=wn.current,a!==null){switch(a.tag){case 31:case 13:return In===null?eu():a.alternate===null&&Xt===0&&(Xt=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),rf(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)),rf(i,l,u)),!1}throw Error(r(435,a.tag))}return rf(i,l,u),eu(),!1}if(ht)return n=wn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==Qh&&(i=Error(r(422),{cause:l}),Kl(jn(i,a)))):(l!==Qh&&(n=Error(r(423),{cause:l}),Kl(jn(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=jn(l,a),u=Ld(i.stateNode,l,u),cd(i,u),Xt!==4&&(Xt=2)),!1;var d=Error(r(520),{cause:l});if(d=jn(d,a),lo===null?lo=[d]:lo.push(d),Xt!==4&&(Xt=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=Ld(a.stateNode,l,i),cd(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"&&(mr===null||!mr.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=yv(u),bv(u,i,a,l),cd(a,u),!1}a=a.return}while(a!==null);return!1}var Bd=Error(r(461)),fi=!1;function Wi(i,n,a,l){n.child=i===null?x_(n,null,a,l):ia(n,i.child,a,l)}function Sv(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 Qr(n),l=md(i,n,a,_,d,u),C=gd(),i!==null&&!fi?(_d(i,n,u),Os(i,n,u)):(ht&&C&&Gh(n),n.flags|=1,Wi(i,n,l,u),n.child)}function wv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!Vh(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Cv(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,!Kd(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:Pl,a(_,l)&&i.ref===n.ref)return Os(i,n,u)}return n.flags|=1,i=Rs(d,l),i.ref=n.ref,i.return=n,n.child=i}function Cv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(Pl(d,l)&&i.ref===n.ref)if(fi=!1,n.pendingProps=l=d,Kd(i,u))(i.flags&131072)!==0&&(fi=!0);else return n.lanes=i.lanes,Os(i,n,u)}return Od(i,n,a,l,u)}function xv(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 Ev(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?T_(n,d):hd(),D_(n);else return l=n.lanes=536870912,Ev(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Tc(n,d.cachePool),T_(n,d),hr(),n.memoizedState=null):(i!==null&&Tc(n,null),hd(),hr());return Wi(i,n,u,a),n.child}function eo(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Ev(i,n,a,l,u){var d=rd();return d=d===null?null:{parent:hi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Tc(n,null),hd(),D_(n),i!==null&&Wa(i,n,l,!0),n.childLanes=u,null}function Wc(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 kv(i,n,a){return ia(n,i.child,null,a),i=Wc(n,n.pendingProps),i.flags|=2,Cn(n),n.memoizedState=null,i}function nx(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(ht){if(l.mode==="hidden")return i=Wc(n,l),n.lanes=536870912,eo(null,i);if(fd(n),(i=Ot)?(i=Hy(i,Un),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:nr!==null?{id:ms,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},a=c_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw rr(n);return n.lanes=536870912,null}return Wc(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(fd(n),u)if(n.flags&256)n.flags&=-257,n=kv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(r(558));else if(fi||Wa(i,n,a,!1),u=(a&i.childLanes)!==0,fi||u){if(l=Mt,l!==null&&(_=vi(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,Yr(i,_),hn(l,i,_),Bd;eu(),n=kv(i,n,a)}else i=d.treeContext,Ot=Kn(_.nextSibling),Ii=n,ht=!0,sr=null,Un=!1,i!==null&&d_(n,i),n=Wc(n,l),n.flags|=4096;return n}return i=Rs(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function Fc(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 Od(i,n,a,l,u){return Qr(n),a=md(i,n,a,l,void 0,u),l=gd(),i!==null&&!fi?(_d(i,n,u),Os(i,n,u)):(ht&&l&&Gh(n),n.flags|=1,Wi(i,n,a,u),n.child)}function Tv(i,n,a,l,u,d){return Qr(n),n.updateQueue=null,a=M_(n,l,a,u),R_(i),l=gd(),i!==null&&!fi?(_d(i,n,d),Os(i,n,d)):(ht&&l&&Gh(n),n.flags|=1,Wi(i,n,a,d),n.child)}function Dv(i,n,a,l,u){if(Qr(n),n.stateNode===null){var d=Pa,_=a.contextType;typeof _=="object"&&_!==null&&(d=Ki(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Ad,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},ld(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Ki(_):Pa,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Nd(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&&Ad.enqueueReplaceState(d,d.state,null),Xl(n,l,d,u),Yl(),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=sa(a,C);d.props=M;var V=d.context,re=a.contextType;_=Pa,typeof re=="object"&&re!==null&&(_=Ki(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||V!==_)&&pv(n,d,l,_),lr=!1;var Z=n.memoizedState;d.state=Z,Xl(n,l,d,u),Yl(),V=n.memoizedState,C||Z!==V||lr?(typeof de=="function"&&(Nd(n,a,de,l),V=n.memoizedState),(M=lr||fv(n,a,M,l,Z,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=V),d.props=l,d.state=V,d.context=_,l=M):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,od(i,n),_=n.memoizedProps,re=sa(a,_),d.props=re,de=n.pendingProps,Z=d.context,V=a.contextType,M=Pa,typeof V=="object"&&V!==null&&(M=Ki(V)),C=a.getDerivedStateFromProps,(V=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==de||Z!==M)&&pv(n,d,l,M),lr=!1,Z=n.memoizedState,d.state=Z,Xl(n,l,d,u),Yl();var J=n.memoizedState;_!==de||Z!==J||lr||i!==null&&i.dependencies!==null&&Ec(i.dependencies)?(typeof C=="function"&&(Nd(n,a,C,l),J=n.memoizedState),(re=lr||fv(n,a,re,l,Z,J,M)||i!==null&&i.dependencies!==null&&Ec(i.dependencies))?(V||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,J,M),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,J,M)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&Z===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Z===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=J),d.props=l,d.state=J,d.context=M,l=re):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&Z===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Z===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,Fc(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=ia(n,i.child,null,u),n.child=ia(n,null,a,u)):Wi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Os(i,n,u),i}function Rv(i,n,a,l){return Gr(),n.flags|=256,Wi(i,n,a,l),n.child}var zd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function jd(i){return{baseLanes:i,cachePool:v_()}}function Hd(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=En),i}function Mv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(si.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(ht){if(u?ur(n):hr(),(i=Ot)?(i=Hy(i,Un),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:nr!==null?{id:ms,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},a=c_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw rr(n);return Sf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(hr(),u=n.mode,C=qc({mode:"hidden",children:C},u),l=Xr(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=jd(a),l.childLanes=Hd(i,_,a),n.memoizedState=zd,eo(null,l)):(ur(n),Pd(n,C))}var M=i.memoizedState;if(M!==null&&(C=M.dehydrated,C!==null)){if(d)n.flags&256?(ur(n),n.flags&=-257,n=Ud(i,n,a)):n.memoizedState!==null?(hr(),n.child=i.child,n.flags|=128,n=null):(hr(),C=l.fallback,u=n.mode,l=qc({mode:"visible",children:l.children},u),C=Xr(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,ia(n,i.child,null,a),l=n.child,l.memoizedState=jd(a),l.childLanes=Hd(i,_,a),n.memoizedState=zd,n=eo(null,l));else if(ur(n),Sf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var V=_.dgst;_=V,l=Error(r(419)),l.stack="",l.digest=_,Kl({value:l,source:null,stack:null}),n=Ud(i,n,a)}else if(fi||Wa(i,n,a,!1),_=(a&i.childLanes)!==0,fi||_){if(_=Mt,_!==null&&(l=vi(_,a),l!==0&&l!==M.retryLane))throw M.retryLane=l,Yr(i,l),hn(_,i,l),Bd;bf(C)||eu(),n=Ud(i,n,a)}else bf(C)?(n.flags|=192,n.child=i.child,n=null):(i=M.treeContext,Ot=Kn(C.nextSibling),Ii=n,ht=!0,sr=null,Un=!1,i!==null&&d_(n,i),n=Pd(n,l.children),n.flags|=4096);return n}return u?(hr(),C=l.fallback,u=n.mode,M=i.child,V=M.sibling,l=Rs(M,{mode:"hidden",children:l.children}),l.subtreeFlags=M.subtreeFlags&65011712,V!==null?C=Rs(V,C):(C=Xr(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,eo(null,l),l=n.child,C=i.child.memoizedState,C===null?C=jd(a):(u=C.cachePool,u!==null?(M=hi._currentValue,u=u.parent!==M?{parent:M,pool:M}:u):u=v_(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=Hd(i,_,a),n.memoizedState=zd,eo(i.child,l)):(ur(n),a=i.child,i=a.sibling,a=Rs(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 Pd(i,n){return n=qc({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function qc(i,n){return i=Sn(22,i,null,n),i.lanes=0,i}function Ud(i,n,a){return ia(n,i.child,null,a),i=Pd(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Nv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),td(i.return,n,a)}function Id(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 Av(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=si.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,ce(si,_),Wi(i,n,l,a),l=ht?Il:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Nv(i,a,n);else if(i.tag===19)Nv(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),Id(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}Id(n,!0,a,null,d,l);break;case"together":Id(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Os(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),pr|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(Wa(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=Rs(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Rs(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function Kd(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Ec(i)))}function sx(i,n,a){switch(n.tag){case 3:qe(n,n.stateNode.containerInfo),ar(n,hi,i.memoizedState.cache),Gr();break;case 27:case 5:Q(n);break;case 4:qe(n,n.stateNode.containerInfo);break;case 10:ar(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,fd(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(ur(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Mv(i,n,a):(ur(n),i=Os(i,n,a),i!==null?i.sibling:null);ur(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(Wa(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Av(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ce(si,si.current),l)break;return null;case 22:return n.lanes=0,xv(i,n,a,n.pendingProps);case 24:ar(n,hi,i.memoizedState.cache)}return Os(i,n,a)}function Lv(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)fi=!0;else{if(!Kd(i,a)&&(n.flags&128)===0)return fi=!1,sx(i,n,a);fi=(i.flags&131072)!==0}else fi=!1,ht&&(n.flags&1048576)!==0&&h_(n,Il,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=ea(n.elementType),n.type=i,typeof i=="function")Vh(i)?(l=sa(i,l),n.tag=1,n=Dv(null,n,i,l,a)):(n.tag=0,n=Od(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===I){n.tag=11,n=Sv(null,n,i,l,a);break e}else if(u===ae){n.tag=14,n=wv(null,n,i,l,a);break e}}throw n=j(i)||i,Error(r(306,n,""))}}return n;case 0:return Od(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=sa(l,n.pendingProps),Dv(i,n,l,u,a);case 3:e:{if(qe(n,n.stateNode.containerInfo),i===null)throw Error(r(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,od(i,n),Xl(n,l,null,a);var _=n.memoizedState;if(l=_.cache,ar(n,hi,l),l!==d.cache&&id(n,[hi],a,!0),Yl(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Rv(i,n,l,a);break e}else if(l!==u){u=jn(Error(r(424)),n),Kl(u),n=Rv(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,Ot=Kn(i.firstChild),Ii=n,ht=!0,sr=null,Un=!0,a=x_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Gr(),l===u){n=Os(i,n,a);break e}Wi(i,n,l,a)}n=n.child}return n;case 26:return Fc(i,n),i===null?(a=Fy(n.type,null,n.pendingProps,null))?n.memoizedState=a:ht||(a=n.type,i=n.pendingProps,l=lu(Ee.current).createElement(a),l[Kt]=n,l[yi]=i,Fi(l,a,i),Bt(l),n.stateNode=l):n.memoizedState=Fy(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return Q(n),i===null&&ht&&(l=n.stateNode=Iy(n.type,n.pendingProps,Ee.current),Ii=n,Un=!0,u=Ot,yr(n.type)?(wf=u,Ot=Kn(l.firstChild)):Ot=u),Wi(i,n,n.pendingProps.children,a),Fc(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&ht&&((u=l=Ot)&&(l=Bx(l,n.type,n.pendingProps,Un),l!==null?(n.stateNode=l,Ii=n,Ot=Kn(l.firstChild),Un=!1,u=!0):u=!1),u||rr(n)),Q(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,_f(u,d)?l=null:_!==null&&_f(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=md(i,n,XC,null,null,a),go._currentValue=u),Fc(i,n),Wi(i,n,l,a),n.child;case 6:return i===null&&ht&&((i=a=Ot)&&(a=Ox(a,n.pendingProps,Un),a!==null?(n.stateNode=a,Ii=n,Ot=null,i=!0):i=!1),i||rr(n)),null;case 13:return Mv(i,n,a);case 4:return qe(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=ia(n,null,l,a):Wi(i,n,l,a),n.child;case 11:return Sv(i,n,n.type,n.pendingProps,a);case 7:return Wi(i,n,n.pendingProps,a),n.child;case 8:return Wi(i,n,n.pendingProps.children,a),n.child;case 12:return Wi(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,ar(n,n.type,l.value),Wi(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,Qr(n),u=Ki(u),l=l(u),n.flags|=1,Wi(i,n,l,a),n.child;case 14:return wv(i,n,n.type,n.pendingProps,a);case 15:return Cv(i,n,n.type,n.pendingProps,a);case 19:return Av(i,n,a);case 31:return nx(i,n,a);case 22:return xv(i,n,a,n.pendingProps);case 24:return Qr(n),l=Ki(hi),i===null?(u=rd(),u===null&&(u=Mt,d=nd(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},ld(n),ar(n,hi,u)):((i.lanes&a)!==0&&(od(i,n),Xl(n,null,null,a),Yl()),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),ar(n,hi,l)):(l=d.cache,ar(n,hi,l),l!==u.cache&&id(n,[hi],a,!0))),Wi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(r(156,n.tag))}function zs(i){i.flags|=4}function Wd(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(ay())i.flags|=8192;else throw ta=Rc,ad}else i.flags&=-16777217}function Bv(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Xy(n))if(ay())i.flags|=8192;else throw ta=Rc,ad}function $c(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?qt():536870912,i.lanes|=n,tl|=n)}function to(i,n){if(!ht)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 zt(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 rx(i,n,a){var l=n.pendingProps;switch(Zh(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zt(n),null;case 1:return zt(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),As(hi),ge(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ka(n)?zs(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Jh())),zt(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(zs(n),d!==null?(zt(n),Bv(n,d)):(zt(n),Wd(n,u,null,l,a))):d?d!==i.memoizedState?(zs(n),zt(n),Bv(n,d)):(zt(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&zs(n),zt(n),Wd(n,u,i,l,a)),null;case 27:if(he(n),a=Ee.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}i=me.current,Ka(n)?f_(n):(i=Iy(u,l,a),n.stateNode=i,zs(n))}return zt(n),null;case 5:if(he(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}if(d=me.current,Ka(n))f_(n);else{var _=lu(Ee.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[yi]=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&&zs(n)}}return zt(n),Wd(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&zs(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(r(166));if(i=Ee.current,Ka(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Ii,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[Kt]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||My(i.nodeValue,a)),i||rr(n,!0)}else i=lu(i).createTextNode(l),i[Kt]=n,n.stateNode=i}return zt(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Ka(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 Gr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),i=!1}else a=Jh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(Cn(n),n):(Cn(n),null);if((n.flags&128)!==0)throw Error(r(558))}return zt(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Ka(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 Gr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),u=!1}else u=Jh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(Cn(n),n):(Cn(n),null)}return Cn(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),zt(n),null);case 4:return ge(),i===null&&df(n.stateNode.containerInfo),zt(n),null;case 10:return As(n.type),zt(n),null;case 19:if(G(si),l=n.memoizedState,l===null)return zt(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)to(l,!1);else{if(Xt!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Lc(i),d!==null){for(n.flags|=128,to(l,!1),i=d.updateQueue,n.updateQueue=i,$c(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)o_(a,i),a=a.sibling;return ce(si,si.current&1|2),ht&&Ms(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&st()>Zc&&(n.flags|=128,u=!0,to(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),to(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!ht)return zt(n),null}else 2*st()-l.renderingStartTime>Zc&&a!==536870912&&(n.flags|=128,u=!0,to(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=st(),i.sibling=null,a=si.current,ce(si,u?a&1|2:a&1),ht&&Ms(n,l.treeForkCount),i):(zt(n),null);case 22:case 23:return Cn(n),dd(),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&&(zt(n),n.subtreeFlags&6&&(n.flags|=8192)):zt(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&&G(Jr),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),As(hi),zt(n),null;case 25:return null;case 30:return null}throw Error(r(156,n.tag))}function ax(i,n){switch(Zh(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return As(hi),ge(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return he(n),null;case 31:if(n.memoizedState!==null){if(Cn(n),n.alternate===null)throw Error(r(340));Gr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(Cn(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(r(340));Gr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return G(si),null;case 4:return ge(),null;case 10:return As(n.type),null;case 22:case 23:return Cn(n),dd(),i!==null&&G(Jr),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return As(hi),null;case 25:return null;default:return null}}function Ov(i,n){switch(Zh(n),n.tag){case 3:As(hi),ge();break;case 26:case 27:case 5:he(n);break;case 4:ge();break;case 31:n.memoizedState!==null&&Cn(n);break;case 13:Cn(n);break;case 19:G(si);break;case 10:As(n.type);break;case 22:case 23:Cn(n),dd(),i!==null&&G(Jr);break;case 24:As(hi)}}function io(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){St(n,n.return,C)}}function dr(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,V=C;try{V()}catch(re){St(u,M,re)}}}l=l.next}while(l!==d)}}catch(re){St(n,n.return,re)}}function zv(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{k_(n,a)}catch(l){St(i,i.return,l)}}}function jv(i,n,a){a.props=sa(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){St(i,n,l)}}function no(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){St(i,n,u)}}function _s(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){St(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){St(i,n,u)}else a.current=null}function Hv(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){St(i,i.return,u)}}function Fd(i,n,a){try{var l=i.stateNode;Dx(l,i.type,a,n),l[yi]=n}catch(u){St(i,i.return,u)}}function Pv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&yr(i.type)||i.tag===4}function qd(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Pv(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&&yr(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 $d(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=D));else if(l!==4&&(l===27&&yr(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for($d(i,n,a),i=i.sibling;i!==null;)$d(i,n,a),i=i.sibling}function Vc(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&&yr(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vc(i,n,a),i=i.sibling;i!==null;)Vc(i,n,a),i=i.sibling}function Uv(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[yi]=a}catch(d){St(i,i.return,d)}}var js=!1,pi=!1,Vd=!1,Iv=typeof WeakSet=="function"?WeakSet:Set,Mi=null;function lx(i,n){if(i=i.containerInfo,mf=pu,i=Jg(i),Uh(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,V=0,re=0,de=i,Z=null;t:for(;;){for(var J;de!==a||u!==0&&de.nodeType!==3||(C=_+u),de!==d||l!==0&&de.nodeType!==3||(M=_+l),de.nodeType===3&&(_+=de.nodeValue.length),(J=de.firstChild)!==null;)Z=de,de=J;for(;;){if(de===i)break t;if(Z===a&&++V===u&&(C=_),Z===d&&++re===l&&(M=_),(J=de.nextSibling)!==null)break;de=Z,Z=de.parentNode}de=J}a=C===-1||M===-1?null:{start:C,end:M}}else a=null}a=a||{start:0,end:0}}else a=null;for(gf={focusedElem:i,selectionRange:a},pu=!1,Mi=n;Mi!==null;)if(n=Mi,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Mi=i;else for(;Mi!==null;){switch(n=Mi,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=sa(a.type,u);i=l.getSnapshotBeforeUpdate(Ae,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(Fe){St(a,a.return,Fe)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)yf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":yf(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,Mi=i;break}Mi=n.return}}function Kv(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Ps(i,a),l&4&&io(5,a);break;case 1:if(Ps(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){St(a,a.return,_)}else{var u=sa(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){St(a,a.return,_)}}l&64&&zv(a),l&512&&no(a,a.return);break;case 3:if(Ps(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{k_(i,n)}catch(_){St(a,a.return,_)}}break;case 27:n===null&&l&4&&Uv(a);case 26:case 5:Ps(i,a),n===null&&l&4&&Hv(a),l&512&&no(a,a.return);break;case 12:Ps(i,a);break;case 31:Ps(i,a),l&4&&qv(i,a);break;case 13:Ps(i,a),l&4&&$v(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=gx.bind(null,a),zx(i,a))));break;case 22:if(l=a.memoizedState!==null||js,!l){n=n!==null&&n.memoizedState!==null||pi,u=js;var d=pi;js=l,(pi=n)&&!d?Us(i,a,(a.subtreeFlags&8772)!==0):Ps(i,a),js=u,pi=d}break;case 30:break;default:Ps(i,a)}}function Wv(i){var n=i.alternate;n!==null&&(i.alternate=null,Wv(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&Ln(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,ln=!1;function Hs(i,n,a){for(a=a.child;a!==null;)Fv(i,n,a),a=a.sibling}function Fv(i,n,a){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(ot,a)}catch{}switch(a.tag){case 26:pi||_s(a,n),Hs(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:pi||_s(a,n);var l=Ut,u=ln;yr(a.type)&&(Ut=a.stateNode,ln=!1),Hs(i,n,a),fo(a.stateNode),Ut=l,ln=u;break;case 5:pi||_s(a,n);case 6:if(l=Ut,u=ln,Ut=null,Hs(i,n,a),Ut=l,ln=u,Ut!==null)if(ln)try{(Ut.nodeType===9?Ut.body:Ut.nodeName==="HTML"?Ut.ownerDocument.body:Ut).removeChild(a.stateNode)}catch(d){St(a,n,d)}else try{Ut.removeChild(a.stateNode)}catch(d){St(a,n,d)}break;case 18:Ut!==null&&(ln?(i=Ut,zy(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),cl(i)):zy(Ut,a.stateNode));break;case 4:l=Ut,u=ln,Ut=a.stateNode.containerInfo,ln=!0,Hs(i,n,a),Ut=l,ln=u;break;case 0:case 11:case 14:case 15:dr(2,a,n),pi||dr(4,a,n),Hs(i,n,a);break;case 1:pi||(_s(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&jv(a,n,l)),Hs(i,n,a);break;case 21:Hs(i,n,a);break;case 22:pi=(l=pi)||a.memoizedState!==null,Hs(i,n,a),pi=l;break;default:Hs(i,n,a)}}function qv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{cl(i)}catch(a){St(n,n.return,a)}}}function $v(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{cl(i)}catch(a){St(n,n.return,a)}}function ox(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new Iv),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new Iv),n;default:throw Error(r(435,i.tag))}}function Yc(i,n){var a=ox(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=_x.bind(null,i,l);l.then(u,u)}})}function on(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(yr(C.type)){Ut=C.stateNode,ln=!1;break e}break;case 5:Ut=C.stateNode,ln=!1;break e;case 3:case 4:Ut=C.stateNode.containerInfo,ln=!0;break e}C=C.return}if(Ut===null)throw Error(r(160));Fv(d,_,u),Ut=null,ln=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Vv(n,i),n=n.sibling}var rs=null;function Vv(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:on(n,i),cn(i),l&4&&(dr(3,i,i.return),io(3,i),dr(5,i,i.return));break;case 1:on(n,i),cn(i),l&512&&(pi||a===null||_s(a,a.return)),l&64&&js&&(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=rs;if(on(n,i),cn(i),l&512&&(pi||a===null||_s(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[An]||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,Bt(d),l=d;break e;case"link":var _=Vy("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(_=Vy("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,Bt(d),l=d}i.stateNode=l}else Yy(u,i.type,i.stateNode);else i.stateNode=$y(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?Yy(u,i.type,i.stateNode):$y(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Fd(i,i.memoizedProps,a.memoizedProps)}break;case 27:on(n,i),cn(i),l&512&&(pi||a===null||_s(a,a.return)),a!==null&&l&4&&Fd(i,i.memoizedProps,a.memoizedProps);break;case 5:if(on(n,i),cn(i),l&512&&(pi||a===null||_s(a,a.return)),i.flags&32){u=i.stateNode;try{ps(u,"")}catch(Ae){St(i,i.return,Ae)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Fd(i,u,a!==null?a.memoizedProps:u)),l&1024&&(Vd=!0);break;case 6:if(on(n,i),cn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Ae){St(i,i.return,Ae)}}break;case 3:if(uu=null,u=rs,rs=ou(n.containerInfo),on(n,i),rs=u,cn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{cl(n.containerInfo)}catch(Ae){St(i,i.return,Ae)}Vd&&(Vd=!1,Yv(i));break;case 4:l=rs,rs=ou(i.stateNode.containerInfo),on(n,i),cn(i),rs=l;break;case 12:on(n,i),cn(i);break;case 31:on(n,i),cn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 13:on(n,i),cn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Gc=st()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 22:u=i.memoizedState!==null;var M=a!==null&&a.memoizedState!==null,V=js,re=pi;if(js=V||u,pi=re||M,on(n,i),pi=re,js=V,cn(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||M||js||pi||ra(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,Z=de!=null&&de.hasOwnProperty("display")?de.display:null;C.style.display=Z==null||typeof Z=="boolean"?"":(""+Z).trim()}}catch(Ae){St(M,M.return,Ae)}}}else if(n.tag===6){if(a===null){M=n;try{M.stateNode.nodeValue=u?"":M.memoizedProps}catch(Ae){St(M,M.return,Ae)}}}else if(n.tag===18){if(a===null){M=n;try{var J=M.stateNode;u?jy(J,!0):jy(M.stateNode,!1)}catch(Ae){St(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,Yc(i,a))));break;case 19:on(n,i),cn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 30:break;case 21:break;default:on(n,i),cn(i)}}function cn(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(Pv(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var u=a.stateNode,d=qd(i);Vc(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(ps(_,""),a.flags&=-33);var C=qd(i);Vc(i,C,_);break;case 3:case 4:var M=a.stateNode.containerInfo,V=qd(i);$d(i,V,M);break;default:throw Error(r(161))}}catch(re){St(i,i.return,re)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function Yv(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;Yv(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Ps(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Kv(i,n.alternate,n),n=n.sibling}function ra(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:dr(4,n,n.return),ra(n);break;case 1:_s(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&jv(n,n.return,a),ra(n);break;case 27:fo(n.stateNode);case 26:case 5:_s(n,n.return),ra(n);break;case 22:n.memoizedState===null&&ra(n);break;case 30:ra(n);break;default:ra(n)}i=i.sibling}}function Us(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:Us(u,d,a),io(4,d);break;case 1:if(Us(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(V){St(l,l.return,V)}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++)E_(M[u],C)}catch(V){St(l,l.return,V)}}a&&_&64&&zv(d),no(d,d.return);break;case 27:Uv(d);case 26:case 5:Us(u,d,a),a&&l===null&&_&4&&Hv(d),no(d,d.return);break;case 12:Us(u,d,a);break;case 31:Us(u,d,a),a&&_&4&&qv(u,d);break;case 13:Us(u,d,a),a&&_&4&&$v(u,d);break;case 22:d.memoizedState===null&&Us(u,d,a),no(d,d.return);break;case 30:break;default:Us(u,d,a)}n=n.sibling}}function Yd(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&&Wl(a))}function Xd(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Wl(i))}function as(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Xv(i,n,a,l),n=n.sibling}function Xv(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:as(i,n,a,l),u&2048&&io(9,n);break;case 1:as(i,n,a,l);break;case 3:as(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&&Wl(i)));break;case 12:if(u&2048){as(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){St(n,n.return,M)}}else as(i,n,a,l);break;case 31:as(i,n,a,l);break;case 13:as(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?as(i,n,a,l):so(i,n):d._visibility&2?as(i,n,a,l):(d._visibility|=2,Qa(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&Yd(_,n);break;case 24:as(i,n,a,l),u&2048&&Xd(n.alternate,n);break;default:as(i,n,a,l)}}function Qa(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,V=_.flags;switch(_.tag){case 0:case 11:case 15:Qa(d,_,C,M,u),io(8,_);break;case 23:break;case 22:var re=_.stateNode;_.memoizedState!==null?re._visibility&2?Qa(d,_,C,M,u):so(d,_):(re._visibility|=2,Qa(d,_,C,M,u)),u&&V&2048&&Yd(_.alternate,_);break;case 24:Qa(d,_,C,M,u),u&&V&2048&&Xd(_.alternate,_);break;default:Qa(d,_,C,M,u)}n=n.sibling}}function so(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:so(a,l),u&2048&&Yd(l.alternate,l);break;case 24:so(a,l),u&2048&&Xd(l.alternate,l);break;default:so(a,l)}n=n.sibling}}var ro=8192;function Ja(i,n,a){if(i.subtreeFlags&ro)for(i=i.child;i!==null;)Gv(i,n,a),i=i.sibling}function Gv(i,n,a){switch(i.tag){case 26:Ja(i,n,a),i.flags&ro&&i.memoizedState!==null&&Yx(a,rs,i.memoizedState,i.memoizedProps);break;case 5:Ja(i,n,a);break;case 3:case 4:var l=rs;rs=ou(i.stateNode.containerInfo),Ja(i,n,a),rs=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=ro,ro=16777216,Ja(i,n,a),ro=l):Ja(i,n,a));break;default:Ja(i,n,a)}}function Zv(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 ao(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];Mi=l,Jv(l,i)}Zv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Qv(i),i=i.sibling}function Qv(i){switch(i.tag){case 0:case 11:case 15:ao(i),i.flags&2048&&dr(9,i,i.return);break;case 3:ao(i);break;case 12:ao(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)):ao(i);break;default:ao(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];Mi=l,Jv(l,i)}Zv(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:dr(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 Jv(i,n){for(;Mi!==null;){var a=Mi;switch(a.tag){case 0:case 11:case 15:dr(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:Wl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Mi=l;else e:for(a=i;Mi!==null;){l=Mi;var u=l.sibling,d=l.return;if(Wv(l),l===a){Mi=null;break e}if(u!==null){u.return=d,Mi=u;break e}Mi=d}}}var cx={getCacheForType:function(i){var n=Ki(hi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Ki(hi).controller.signal}},ux=typeof WeakMap=="function"?WeakMap:Map,pt=0,Mt=null,rt=null,ct=0,bt=0,xn=null,fr=!1,el=!1,Gd=!1,Is=0,Xt=0,pr=0,aa=0,Zd=0,En=0,tl=0,lo=null,un=null,Qd=!1,Gc=0,ey=0,Zc=1/0,Qc=null,mr=null,bi=0,gr=null,il=null,Ks=0,Jd=0,ef=null,ty=null,oo=0,tf=null;function kn(){return(pt&2)!==0&&ct!==0?ct&-ct:N.T!==null?of():Qi()}function iy(){if(En===0)if((ct&536870912)===0||ht){var i=Pi;Pi<<=1,(Pi&3932160)===0&&(Pi=262144),En=i}else En=536870912;return i=wn.current,i!==null&&(i.flags|=32),En}function hn(i,n,a){(i===Mt&&(bt===2||bt===9)||i.cancelPendingCommit!==null)&&(nl(i,0),_r(i,ct,En,!1)),_i(i,a),((pt&2)===0||i!==Mt)&&(i===Mt&&((pt&2)===0&&(aa|=a),Xt===4&&_r(i,ct,En,!1)),vs(i))}function ny(i,n,a){if((pt&6)!==0)throw Error(r(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Di(i,n),u=l?fx(i,n):sf(i,n,!0),d=l;do{if(u===0){el&&!l&&_r(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!hx(a)){u=sf(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=lo;var M=C.current.memoizedState.isDehydrated;if(M&&(nl(C,_).flags|=256),_=sf(C,_,!1),_!==2){if(Gd&&!M){C.errorRecoveryDisabledLanes|=d,aa|=d,u=4;break e}d=un,un=u,d!==null&&(un===null?un=d:un.push.apply(un,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){nl(i,0),_r(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:_r(l,n,En,!fr);break e;case 2:un=null;break;case 3:case 5:break;default:throw Error(r(329))}if((n&62914560)===n&&(u=Gc+300-st(),10<u)){if(_r(l,n,En,!fr),Ct(l,0,!0)!==0)break e;Ks=n,l.timeoutHandle=By(sy.bind(null,l,a,un,Qc,Qd,n,En,aa,tl,fr,d,"Throttled",-0,0),u);break e}sy(l,a,un,Qc,Qd,n,En,aa,tl,fr,d,null,-0,0)}}break}while(!0);vs(i)}function sy(i,n,a,l,u,d,_,C,M,V,re,de,Z,J){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:D},Gv(n,d,de);var Ae=(d&62914560)===d?Gc-st():(d&4194048)===d?ey-st():0;if(Ae=Xx(de,Ae),Ae!==null){Ks=d,i.cancelPendingCommit=Ae(dy.bind(null,i,n,d,a,l,u,_,C,M,re,de,null,Z,J)),_r(i,d,_,!V);return}}dy(i,n,d,a,l,u,_,C,M)}function hx(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(!bn(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 _r(i,n,a,l){n&=~Zd,n&=~aa,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-Dt(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&Ri(i,a,n)}function Jc(){return(pt&6)===0?(co(0),!1):!0}function nf(){if(rt!==null){if(bt===0)var i=rt.return;else i=rt,Ns=Zr=null,vd(i),Va=null,ql=0,i=rt;for(;i!==null;)Ov(i.alternate,i),i=i.return;rt=null}}function nl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Nx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Ks=0,nf(),Mt=i,rt=a=Rs(i.current,null),ct=n,bt=0,xn=null,fr=!1,el=Di(i,n),Gd=!1,tl=En=Zd=aa=pr=Xt=0,un=lo=null,Qd=!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-Dt(l),d=1<<u;n|=i[u],l&=~d}return Is=n,bc(),a}function ry(i,n){Ge=null,N.H=Jl,n===$a||n===Dc?(n=S_(),bt=3):n===ad?(n=S_(),bt=4):bt=n===Bd?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,xn=n,rt===null&&(Xt=1,Kc(i,jn(n,i.current)))}function ay(){var i=wn.current;return i===null?!0:(ct&4194048)===ct?In===null:(ct&62914560)===ct||(ct&536870912)!==0?i===In:!1}function ly(){var i=N.H;return N.H=Jl,i===null?Jl:i}function oy(){var i=N.A;return N.A=cx,i}function eu(){Xt=4,fr||(ct&4194048)!==ct&&wn.current!==null||(el=!0),(pr&134217727)===0&&(aa&134217727)===0||Mt===null||_r(Mt,ct,En,!1)}function sf(i,n,a){var l=pt;pt|=2;var u=ly(),d=oy();(Mt!==i||ct!==n)&&(Qc=null,nl(i,n)),n=!1;var _=Xt;e:do try{if(bt!==0&&rt!==null){var C=rt,M=xn;switch(bt){case 8:nf(),_=6;break e;case 3:case 2:case 9:case 6:wn.current===null&&(n=!0);var V=bt;if(bt=0,xn=null,sl(i,C,M,V),a&&el){_=0;break e}break;default:V=bt,bt=0,xn=null,sl(i,C,M,V)}}dx(),_=Xt;break}catch(re){ry(i,re)}while(!0);return n&&i.shellSuspendCounter++,Ns=Zr=null,pt=l,N.H=u,N.A=d,rt===null&&(Mt=null,ct=0,bc()),_}function dx(){for(;rt!==null;)cy(rt)}function fx(i,n){var a=pt;pt|=2;var l=ly(),u=oy();Mt!==i||ct!==n?(Qc=null,Zc=st()+500,nl(i,n)):el=Di(i,n);e:do try{if(bt!==0&&rt!==null){n=rt;var d=xn;t:switch(bt){case 1:bt=0,xn=null,sl(i,n,d,1);break;case 2:case 9:if(y_(d)){bt=0,xn=null,uy(n);break}n=function(){bt!==2&&bt!==9||Mt!==i||(bt=7),vs(i)},d.then(n,n);break e;case 3:bt=7;break e;case 4:bt=5;break e;case 7:y_(d)?(bt=0,xn=null,uy(n)):(bt=0,xn=null,sl(i,n,d,7));break;case 5:var _=null;switch(rt.tag){case 26:_=rt.memoizedState;case 5:case 27:var C=rt;if(_?Xy(_):C.stateNode.complete){bt=0,xn=null;var M=C.sibling;if(M!==null)rt=M;else{var V=C.return;V!==null?(rt=V,tu(V)):rt=null}break t}}bt=0,xn=null,sl(i,n,d,5);break;case 6:bt=0,xn=null,sl(i,n,d,6);break;case 8:nf(),Xt=6;break e;default:throw Error(r(462))}}px();break}catch(re){ry(i,re)}while(!0);return Ns=Zr=null,N.H=l,N.A=u,pt=a,rt!==null?0:(Mt=null,ct=0,bc(),Xt)}function px(){for(;rt!==null&&!mt();)cy(rt)}function cy(i){var n=Lv(i.alternate,i,Is);i.memoizedProps=i.pendingProps,n===null?tu(i):rt=n}function uy(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=Tv(a,n,n.pendingProps,n.type,void 0,ct);break;case 11:n=Tv(a,n,n.pendingProps,n.type.render,n.ref,ct);break;case 5:vd(n);default:Ov(a,n),n=rt=o_(n,Is),n=Lv(a,n,Is)}i.memoizedProps=i.pendingProps,n===null?tu(i):rt=n}function sl(i,n,a,l){Ns=Zr=null,vd(n),Va=null,ql=0;var u=n.return;try{if(ix(i,u,n,a,ct)){Xt=1,Kc(i,jn(a,i.current)),rt=null;return}}catch(d){if(u!==null)throw rt=u,d;Xt=1,Kc(i,jn(a,i.current)),rt=null;return}n.flags&32768?(ht||l===1?i=!0:el||(ct&536870912)!==0?i=!1:(fr=i=!0,(l===2||l===9||l===3||l===6)&&(l=wn.current,l!==null&&l.tag===13&&(l.flags|=16384))),hy(n,i)):tu(n)}function tu(i){var n=i;do{if((n.flags&32768)!==0){hy(n,fr);return}i=n.return;var a=rx(n.alternate,n,Is);if(a!==null){rt=a;return}if(n=n.sibling,n!==null){rt=n;return}rt=n=i}while(n!==null);Xt===0&&(Xt=5)}function hy(i,n){do{var a=ax(i.alternate,i);if(a!==null){a.flags&=32767,rt=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){rt=i;return}rt=i=a}while(i!==null);Xt=6,rt=null}function dy(i,n,a,l,u,d,_,C,M){i.cancelPendingCommit=null;do iu();while(bi!==0);if((pt&6)!==0)throw Error(r(327));if(n!==null){if(n===i.current)throw Error(r(177));if(d=n.lanes|n.childLanes,d|=qh,Ht(i,a,d,_,C,M),i===Mt&&(rt=Mt=null,ct=0),il=n,gr=i,Ks=a,Jd=d,ef=u,ty=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,vx(Jt,function(){return _y(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=N.T,N.T=null,u=$.p,$.p=2,_=pt,pt|=4;try{lx(i,n,a)}finally{pt=_,$.p=u,N.T=l}}bi=1,fy(),py(),my()}}function fy(){if(bi===1){bi=0;var i=gr,n=il,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=N.T,N.T=null;var l=$.p;$.p=2;var u=pt;pt|=4;try{Vv(n,i);var d=gf,_=Jg(i.containerInfo),C=d.focusedElem,M=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&Qg(C.ownerDocument.documentElement,C)){if(M!==null&&Uh(C)){var V=M.start,re=M.end;if(re===void 0&&(re=V),"selectionStart"in C)C.selectionStart=V,C.selectionEnd=Math.min(re,C.value.length);else{var de=C.ownerDocument||document,Z=de&&de.defaultView||window;if(Z.getSelection){var J=Z.getSelection(),Ae=C.textContent.length,Fe=Math.min(M.start,Ae),kt=M.end===void 0?Fe:Math.min(M.end,Ae);!J.extend&&Fe>kt&&(_=kt,kt=Fe,Fe=_);var P=Zg(C,Fe),O=Zg(C,kt);if(P&&O&&(J.rangeCount!==1||J.anchorNode!==P.node||J.anchorOffset!==P.offset||J.focusNode!==O.node||J.focusOffset!==O.offset)){var q=de.createRange();q.setStart(P.node,P.offset),J.removeAllRanges(),Fe>kt?(J.addRange(q),J.extend(O.node,O.offset)):(q.setEnd(O.node,O.offset),J.addRange(q))}}}}for(de=[],J=C;J=J.parentNode;)J.nodeType===1&&de.push({element:J,left:J.scrollLeft,top:J.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=!!mf,gf=mf=null}finally{pt=u,$.p=l,N.T=a}}i.current=n,bi=2}}function py(){if(bi===2){bi=0;var i=gr,n=il,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=N.T,N.T=null;var l=$.p;$.p=2;var u=pt;pt|=4;try{Kv(i,n.alternate,n)}finally{pt=u,$.p=l,N.T=a}}bi=3}}function my(){if(bi===4||bi===3){bi=0,Xe();var i=gr,n=il,a=Ks,l=ty;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?bi=5:(bi=0,il=gr=null,gy(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(mr=null),Zi(a),n=n.stateNode,wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(ot,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=N.T,u=$.p,$.p=2,N.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{N.T=n,$.p=u}}(Ks&3)!==0&&iu(),vs(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===tf?oo++:(oo=0,tf=i):oo=0,co(0)}}function gy(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Wl(n)))}function iu(){return fy(),py(),my(),_y()}function _y(){if(bi!==5)return!1;var i=gr,n=Jd;Jd=0;var a=Zi(Ks),l=N.T,u=$.p;try{$.p=32>a?32:a,N.T=null,a=ef,ef=null;var d=gr,_=Ks;if(bi=0,il=gr=null,Ks=0,(pt&6)!==0)throw Error(r(331));var C=pt;if(pt|=4,Qv(d.current),Xv(d,d.current,_,a),pt=C,co(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(ot,d)}catch{}return!0}finally{$.p=u,N.T=l,gy(i,n)}}function vy(i,n,a){n=jn(a,n),n=Ld(i.stateNode,n,2),i=cr(i,n,2),i!==null&&(_i(i,2),vs(i))}function St(i,n,a){if(i.tag===3)vy(i,i,a);else for(;n!==null;){if(n.tag===3){vy(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(mr===null||!mr.has(l))){i=jn(a,i),a=yv(2),l=cr(n,a,2),l!==null&&(bv(a,l,n,i),_i(l,2),vs(l));break}}n=n.return}}function rf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new ux;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)||(Gd=!0,u.add(a),i=mx.bind(null,i,n,a),n.then(i,i))}function mx(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ct&a)===a&&(Xt===4||Xt===3&&(ct&62914560)===ct&&300>st()-Gc?(pt&2)===0&&nl(i,0):Zd|=a,tl===ct&&(tl=0)),vs(i)}function yy(i,n){n===0&&(n=qt()),i=Yr(i,n),i!==null&&(_i(i,n),vs(i))}function gx(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),yy(i,a)}function _x(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),yy(i,a)}function vx(i,n){return Oe(i,n)}var nu=null,rl=null,af=!1,su=!1,lf=!1,vr=0;function vs(i){i!==rl&&i.next===null&&(rl===null?nu=rl=i:rl=rl.next=i),su=!0,af||(af=!0,bx())}function co(i,n){if(!lf&&su){lf=!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-Dt(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Cy(l,d))}else d=ct,d=Ct(l,l===Mt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||Di(l,d)||(a=!0,Cy(l,d));l=l.next}while(a);lf=!1}}function yx(){by()}function by(){su=af=!1;var i=0;vr!==0&&Mx()&&(i=vr);for(var n=st(),a=null,l=nu;l!==null;){var u=l.next,d=Sy(l,n);d===0?(l.next=null,a===null?nu=u:a.next=u,u===null&&(rl=a)):(a=l,(i!==0||(d&3)!==0)&&(su=!0)),l=u}bi!==0&&bi!==5||co(i),vr!==0&&(vr=0)}function Sy(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-Dt(d),C=1<<_,M=u[_];M===-1?((C&a)===0||(C&l)!==0)&&(u[_]=oi(C,n)):M<=n&&(i.expiredLanes|=C),d&=~C}if(n=Mt,a=ct,a=Ct(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(bt===2||bt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&je(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Di(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&je(l),Zi(a)){case 2:case 8:a=ki;break;case 32:a=Jt;break;case 268435456:a=Gn;break;default:a=Jt}return l=wy.bind(null,i),a=Oe(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&je(l),i.callbackPriority=2,i.callbackNode=null,2}function wy(i,n){if(bi!==0&&bi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(iu()&&i.callbackNode!==a)return null;var l=ct;return l=Ct(i,i===Mt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(ny(i,l,n),Sy(i,st()),i.callbackNode!=null&&i.callbackNode===a?wy.bind(null,i):null)}function Cy(i,n){if(iu())return null;ny(i,n,!0)}function bx(){Ax(function(){(pt&6)!==0?Oe(sn,yx):by()})}function of(){if(vr===0){var i=Fa;i===0&&(i=Rt,Rt<<=1,(Rt&261888)===0&&(Rt=256)),vr=i}return vr}function xy(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Ds(""+i)}function Ey(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 Sx(i,n,a,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=xy((u[yi]||null).action),_=l.submitter;_&&(n=(n=_[yi]||null)?xy(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new nt("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(vr!==0){var M=_?Ey(u,_):new FormData(u);Td(a,{pending:!0,data:M,method:u.method,action:d},null,M)}}else typeof d=="function"&&(C.preventDefault(),M=_?Ey(u,_):new FormData(u),Td(a,{pending:!0,data:M,method:u.method,action:d},d,M))},currentTarget:u}]})}}for(var cf=0;cf<Fh.length;cf++){var uf=Fh[cf],wx=uf.toLowerCase(),Cx=uf[0].toUpperCase()+uf.slice(1);ss(wx,"on"+Cx)}ss(i_,"onAnimationEnd"),ss(n_,"onAnimationIteration"),ss(s_,"onAnimationStart"),ss("dblclick","onDoubleClick"),ss("focusin","onFocus"),ss("focusout","onBlur"),ss(PC,"onTransitionRun"),ss(UC,"onTransitionStart"),ss(IC,"onTransitionCancel"),ss(r_,"onTransitionEnd"),es("onMouseEnter",["mouseout","mouseover"]),es("onMouseLeave",["mouseout","mouseover"]),es("onPointerEnter",["pointerout","pointerover"]),es("onPointerLeave",["pointerout","pointerover"]),vn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),vn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),vn("onBeforeInput",["compositionend","keypress","textInput","paste"]),vn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),vn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),vn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var uo="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(" "),xx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(uo));function ky(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,V=C.currentTarget;if(C=C.listener,M!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(re){yc(re)}u.currentTarget=null,d=M}else for(_=0;_<l.length;_++){if(C=l[_],M=C.instance,V=C.currentTarget,C=C.listener,M!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=V;try{d(u)}catch(re){yc(re)}u.currentTarget=null,d=M}}}}function at(i,n){var a=n[Ir];a===void 0&&(a=n[Ir]=new Set);var l=i+"__bubble";a.has(l)||(Ty(n,i,2,!1),a.add(l))}function hf(i,n,a){var l=0;n&&(l|=4),Ty(a,i,l,n)}var ru="_reactListening"+Math.random().toString(36).slice(2);function df(i){if(!i[ru]){i[ru]=!0,ui.forEach(function(a){a!=="selectionchange"&&(xx.has(a)||hf(a,!1,i),hf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[ru]||(n[ru]=!0,hf("selectionchange",!1,n))}}function Ty(i,n,a,l){switch(ib(n)){case 2:var u=Qx;break;case 8:u=Jx;break;default:u=Tf}a=u.bind(null,n,a,i),u=void 0,!Ui||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 ff(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(_=Bn(C),_===null)return;if(M=_.tag,M===5||M===6||M===26||M===27){l=d=_;continue e}C=C.parentNode}}l=l.return}ii(function(){var V=d,re=He(a),de=[];e:{var Z=a_.get(i);if(Z!==void 0){var J=nt,Ae=i;switch(i){case"keypress":if(ne(a)===0)break e;case"keydown":case"keyup":J=_C;break;case"focusin":Ae="focus",J=Oh;break;case"focusout":Ae="blur",J=Oh;break;case"beforeblur":case"afterblur":J=Oh;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":J=Og;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=rC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=bC;break;case i_:case n_:case s_:J=oC;break;case r_:J=wC;break;case"scroll":case"scrollend":J=ni;break;case"wheel":J=xC;break;case"copy":case"cut":case"paste":J=uC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=jg;break;case"toggle":case"beforetoggle":J=kC}var Fe=(n&4)!==0,kt=!Fe&&(i==="scroll"||i==="scrollend"),P=Fe?Z!==null?Z+"Capture":null:Z;Fe=[];for(var O=V,q;O!==null;){var ue=O;if(q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||q===null||P===null||(ue=vt(O,P),ue!=null&&Fe.push(ho(O,ue,q))),kt)break;O=O.return}0<Fe.length&&(Z=new J(Z,Ae,null,a,re),de.push({event:Z,listeners:Fe}))}}if((n&7)===0){e:{if(Z=i==="mouseover"||i==="pointerover",J=i==="mouseout"||i==="pointerout",Z&&a!==ie&&(Ae=a.relatedTarget||a.fromElement)&&(Bn(Ae)||Ae[Nn]))break e;if((J||Z)&&(Z=re.window===re?re:(Z=re.ownerDocument)?Z.defaultView||Z.parentWindow:window,J?(Ae=a.relatedTarget||a.toElement,J=V,Ae=Ae?Bn(Ae):null,Ae!==null&&(kt=c(Ae),Fe=Ae.tag,Ae!==kt||Fe!==5&&Fe!==27&&Fe!==6)&&(Ae=null)):(J=null,Ae=V),J!==Ae)){if(Fe=Og,ue="onMouseLeave",P="onMouseEnter",O="mouse",(i==="pointerout"||i==="pointerover")&&(Fe=jg,ue="onPointerLeave",P="onPointerEnter",O="pointer"),kt=J==null?Z:Jn(J),q=Ae==null?Z:Jn(Ae),Z=new Fe(ue,O+"leave",J,a,re),Z.target=kt,Z.relatedTarget=q,ue=null,Bn(re)===V&&(Fe=new Fe(P,O+"enter",Ae,a,re),Fe.target=q,Fe.relatedTarget=kt,ue=Fe),kt=ue,J&&Ae)t:{for(Fe=Ex,P=J,O=Ae,q=0,ue=P;ue;ue=Fe(ue))q++;ue=0;for(var Ue=O;Ue;Ue=Fe(Ue))ue++;for(;0<q-ue;)P=Fe(P),q--;for(;0<ue-q;)O=Fe(O),ue--;for(;q--;){if(P===O||O!==null&&P===O.alternate){Fe=P;break t}P=Fe(P),O=Fe(O)}Fe=null}else Fe=null;J!==null&&Dy(de,Z,J,Fe,!1),Ae!==null&&kt!==null&&Dy(de,kt,Ae,Fe,!0)}}e:{if(Z=V?Jn(V):window,J=Z.nodeName&&Z.nodeName.toLowerCase(),J==="select"||J==="input"&&Z.type==="file")var dt=qg;else if(Wg(Z))if($g)dt=zC;else{dt=BC;var ze=LC}else J=Z.nodeName,!J||J.toLowerCase()!=="input"||Z.type!=="checkbox"&&Z.type!=="radio"?V&&ir(V.elementType)&&(dt=qg):dt=OC;if(dt&&(dt=dt(i,V))){Fg(de,dt,a,re);break e}ze&&ze(i,Z,V),i==="focusout"&&V&&Z.type==="number"&&V.memoizedProps.value!=null&&qr(Z,"number",Z.value)}switch(ze=V?Jn(V):window,i){case"focusin":(Wg(ze)||ze.contentEditable==="true")&&(za=ze,Ih=V,Ul=null);break;case"focusout":Ul=Ih=za=null;break;case"mousedown":Kh=!0;break;case"contextmenu":case"mouseup":case"dragend":Kh=!1,e_(de,a,re);break;case"selectionchange":if(HC)break;case"keydown":case"keyup":e_(de,a,re)}var Ze;if(jh)e:{switch(i){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else Oa?Ig(i,a)&&(ut="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(ut="onCompositionStart");ut&&(Hg&&a.locale!=="ko"&&(Oa||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&Oa&&(Ze=z()):(yn=re,x="value"in yn?yn.value:yn.textContent,Oa=!0)),ze=au(V,ut),0<ze.length&&(ut=new zg(ut,i,null,a,re),de.push({event:ut,listeners:ze}),Ze?ut.data=Ze:(Ze=Kg(a),Ze!==null&&(ut.data=Ze)))),(Ze=DC?RC(i,a):MC(i,a))&&(ut=au(V,"onBeforeInput"),0<ut.length&&(ze=new zg("onBeforeInput","beforeinput",null,a,re),de.push({event:ze,listeners:ut}),ze.data=Ze)),Sx(de,i,V,a,re)}ky(de,n)})}function ho(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=vt(i,a),u!=null&&l.unshift(ho(i,u,d)),u=vt(i,n),u!=null&&l.push(ho(i,u,d))),i.tag===3)return l;i=i.return}return[]}function Ex(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Dy(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,M=C.alternate,V=C.stateNode;if(C=C.tag,M!==null&&M===l)break;C!==5&&C!==26&&C!==27||V===null||(M=V,u?(V=vt(a,d),V!=null&&_.unshift(ho(a,V,M))):u||(V=vt(a,d),V!=null&&_.push(ho(a,V,M)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var kx=/\r\n?/g,Tx=/\u0000|\uFFFD/g;function Ry(i){return(typeof i=="string"?i:""+i).replace(kx,`
|
|
10
|
+
`).replace(Tx,"")}function My(i,n){return n=Ry(n),Ry(i)===n}function Et(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||ps(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&ps(i,""+l);break;case"className":ds(i,"class",l);break;case"tabIndex":ds(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":ds(i,a,l);break;case"style":Yi(i,l,d);break;case"data":if(n!=="object"){ds(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=Ds(""+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"&&Et(i,n,"name",u.name,u,null),Et(i,n,"formEncType",u.formEncType,u,null),Et(i,n,"formMethod",u.formMethod,u,null),Et(i,n,"formTarget",u.formTarget,u,null)):(Et(i,n,"encType",u.encType,u,null),Et(i,n,"method",u.method,u,null),Et(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=Ds(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=D);break;case"onScroll":l!=null&&at("scroll",i);break;case"onScrollEnd":l!=null&&at("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=Ds(""+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":at("beforetoggle",i),at("toggle",i),hs(i,"popover",l);break;case"xlinkActuate":an(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":an(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":an(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":an(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":an(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":an(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":an(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":an(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":an(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":hs(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=On.get(a)||a,hs(i,a,l))}}function pf(i,n,a,l,u,d){switch(a){case"style":Yi(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"?ps(i,l):(typeof l=="number"||typeof l=="bigint")&&ps(i,""+l);break;case"onScroll":l!=null&&at("scroll",i);break;case"onScrollEnd":l!=null&&at("scrollend",i);break;case"onClick":l!=null&&(i.onclick=D);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ma.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[yi]||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,""):hs(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":at("error",i),at("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:Et(i,n,d,_,a,null)}}u&&Et(i,n,"srcSet",a.srcSet,a,null),l&&Et(i,n,"src",a.src,a,null);return;case"input":at("invalid",i);var C=d=_=u=null,M=null,V=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":V=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:Et(i,n,l,re,a,null)}}Fr(i,d,C,M,V,_,u,!1);return;case"select":at("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:Et(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?fs(i,!!l,n,!1):a!=null&&fs(i,!!l,a,!0);return;case"textarea":at("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:Et(i,n,_,C,a,null)}ns(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":Et(i,n,M,l,a,null));return;case"dialog":at("beforetoggle",i),at("toggle",i),at("cancel",i),at("close",i);break;case"iframe":case"object":at("load",i);break;case"video":case"audio":for(l=0;l<uo.length;l++)at(uo[l],i);break;case"image":at("error",i),at("load",i);break;case"details":at("toggle",i);break;case"embed":case"source":case"link":at("error",i),at("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(V in a)if(a.hasOwnProperty(V)&&(l=a[V],l!=null))switch(V){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:Et(i,n,V,l,a,null)}return;default:if(ir(n)){for(re in a)a.hasOwnProperty(re)&&(l=a[re],l!==void 0&&pf(i,n,re,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&Et(i,n,C,l,a,null))}function Dx(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,V=null,re=null;for(J in a){var de=a[J];if(a.hasOwnProperty(J)&&de!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":M=de;default:l.hasOwnProperty(J)||Et(i,n,J,null,l,de)}}for(var Z in l){var J=l[Z];if(de=a[Z],l.hasOwnProperty(Z)&&(J!=null||de!=null))switch(Z){case"type":d=J;break;case"name":u=J;break;case"checked":V=J;break;case"defaultChecked":re=J;break;case"value":_=J;break;case"defaultValue":C=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(r(137,n));break;default:J!==de&&Et(i,n,Z,J,l,de)}}er(i,_,C,M,V,re,d,u);return;case"select":J=_=C=Z=null;for(d in a)if(M=a[d],a.hasOwnProperty(d)&&M!=null)switch(d){case"value":break;case"multiple":J=M;default:l.hasOwnProperty(d)||Et(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":Z=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==M&&Et(i,n,u,d,l,M)}n=C,a=_,l=J,Z!=null?fs(i,!!a,Z,!1):!!l!=!!a&&(n!=null?fs(i,!!a,n,!0):fs(i,!!a,a?[]:"",!1));return;case"textarea":J=Z=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:Et(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":Z=u;break;case"defaultValue":J=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==d&&Et(i,n,_,u,l,d)}tr(i,Z,J);return;case"option":for(var Ae in a)Z=a[Ae],a.hasOwnProperty(Ae)&&Z!=null&&!l.hasOwnProperty(Ae)&&(Ae==="selected"?i.selected=!1:Et(i,n,Ae,null,l,Z));for(M in l)Z=l[M],J=a[M],l.hasOwnProperty(M)&&Z!==J&&(Z!=null||J!=null)&&(M==="selected"?i.selected=Z&&typeof Z!="function"&&typeof Z!="symbol":Et(i,n,M,Z,l,J));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 Fe in a)Z=a[Fe],a.hasOwnProperty(Fe)&&Z!=null&&!l.hasOwnProperty(Fe)&&Et(i,n,Fe,null,l,Z);for(V in l)if(Z=l[V],J=a[V],l.hasOwnProperty(V)&&Z!==J&&(Z!=null||J!=null))switch(V){case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(r(137,n));break;default:Et(i,n,V,Z,l,J)}return;default:if(ir(n)){for(var kt in a)Z=a[kt],a.hasOwnProperty(kt)&&Z!==void 0&&!l.hasOwnProperty(kt)&&pf(i,n,kt,void 0,l,Z);for(re in l)Z=l[re],J=a[re],!l.hasOwnProperty(re)||Z===J||Z===void 0&&J===void 0||pf(i,n,re,Z,l,J);return}}for(var P in a)Z=a[P],a.hasOwnProperty(P)&&Z!=null&&!l.hasOwnProperty(P)&&Et(i,n,P,null,l,Z);for(de in l)Z=l[de],J=a[de],!l.hasOwnProperty(de)||Z===J||Z==null&&J==null||Et(i,n,de,Z,l,J)}function Ny(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Rx(){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&&Ny(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var M=a[l],V=M.startTime;if(V>C)break;var re=M.transferSize,de=M.initiatorType;re&&Ny(de)&&(M=M.responseEnd,_+=re*(M<C?1:(C-V)/(M-V)))}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 mf=null,gf=null;function lu(i){return i.nodeType===9?i:i.ownerDocument}function Ay(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 Ly(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 _f(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 vf=null;function Mx(){var i=window.event;return i&&i.type==="popstate"?i===vf?!1:(vf=i,!0):(vf=null,!1)}var By=typeof setTimeout=="function"?setTimeout:void 0,Nx=typeof clearTimeout=="function"?clearTimeout:void 0,Oy=typeof Promise=="function"?Promise:void 0,Ax=typeof queueMicrotask=="function"?queueMicrotask:typeof Oy<"u"?function(i){return Oy.resolve(null).then(i).catch(Lx)}:By;function Lx(i){setTimeout(function(){throw i})}function yr(i){return i==="head"}function zy(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),cl(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")fo(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,fo(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[An]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&fo(i.ownerDocument.body);a=u}while(a);cl(n)}function jy(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 yf(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":yf(a),Ln(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Bx(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[An])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 Ox(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 Hy(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 bf(i){return i.data==="$?"||i.data==="$~"}function Sf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function zx(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 wf=null;function Py(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 Uy(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 Iy(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 fo(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);Ln(i)}var Wn=new Map,Ky=new Set;function ou(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Ws=$.d;$.d={f:jx,r:Hx,D:Px,C:Ux,L:Ix,m:Kx,X:Fx,S:Wx,M:qx};function jx(){var i=Ws.f(),n=Jc();return i||n}function Hx(i){var n=Lt(i);n!==null&&n.tag===5&&n.type==="form"?rv(n):Ws.r(i)}var al=typeof document>"u"?null:document;function Wy(i,n,a){var l=al;if(l&&typeof n=="string"&&n){var u=Vi(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),Ky.has(u)||(Ky.add(u),i={rel:i,crossOrigin:a,href:n},l.querySelector(u)===null&&(n=l.createElement("link"),Fi(n,"link",i),Bt(n),l.head.appendChild(n)))}}function Px(i){Ws.D(i),Wy("dns-prefetch",i,null)}function Ux(i,n){Ws.C(i,n),Wy("preconnect",i,n)}function Ix(i,n,a){Ws.L(i,n,a);var l=al;if(l&&i&&n){var u='link[rel="preload"][as="'+Vi(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Vi(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Vi(a.imageSizes)+'"]')):u+='[href="'+Vi(i)+'"]';var d=u;switch(n){case"style":d=ll(i);break;case"script":d=ol(i)}Wn.has(d)||(i=y({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),Wn.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(po(d))||n==="script"&&l.querySelector(mo(d))||(n=l.createElement("link"),Fi(n,"link",i),Bt(n),l.head.appendChild(n)))}}function Kx(i,n){Ws.m(i,n);var a=al;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Vi(l)+'"][href="'+Vi(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=ol(i)}if(!Wn.has(d)&&(i=y({rel:"modulepreload",href:i},n),Wn.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(mo(d)))return}l=a.createElement("link"),Fi(l,"link",i),Bt(l),a.head.appendChild(l)}}}function Wx(i,n,a){Ws.S(i,n,a);var l=al;if(l&&i){var u=_n(l).hoistableStyles,d=ll(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(po(d)))C.loading=5;else{i=y({rel:"stylesheet",href:i,"data-precedence":n},a),(a=Wn.get(d))&&Cf(i,a);var M=_=l.createElement("link");Bt(M),Fi(M,"link",i),M._p=new Promise(function(V,re){M.onload=V,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 Fx(i,n){Ws.X(i,n);var a=al;if(a&&i){var l=_n(a).hoistableScripts,u=ol(i),d=l.get(u);d||(d=a.querySelector(mo(u)),d||(i=y({src:i,async:!0},n),(n=Wn.get(u))&&xf(i,n),d=a.createElement("script"),Bt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function qx(i,n){Ws.M(i,n);var a=al;if(a&&i){var l=_n(a).hoistableScripts,u=ol(i),d=l.get(u);d||(d=a.querySelector(mo(u)),d||(i=y({src:i,async:!0,type:"module"},n),(n=Wn.get(u))&&xf(i,n),d=a.createElement("script"),Bt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Fy(i,n,a,l){var u=(u=Ee.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=ll(a.href),a=_n(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=ll(a.href);var d=_n(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(po(i)))&&!d._p&&(_.instance=d,_.state.loading=5),Wn.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},Wn.set(i,a),d||$x(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=ol(a),a=_n(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 ll(i){return'href="'+Vi(i)+'"'}function po(i){return'link[rel="stylesheet"]['+i+"]"}function qy(i){return y({},i,{"data-precedence":i.precedence,precedence:null})}function $x(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),Bt(n),i.head.appendChild(n))}function ol(i){return'[src="'+Vi(i)+'"]'}function mo(i){return"script[async]"+i}function $y(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+Vi(a.href)+'"]');if(l)return n.instance=l,Bt(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"),Bt(l),Fi(l,"style",u),cu(l,a.precedence,i),n.instance=l;case"stylesheet":u=ll(a.href);var d=i.querySelector(po(u));if(d)return n.state.loading|=4,n.instance=d,Bt(d),d;l=qy(a),(u=Wn.get(u))&&Cf(l,u),d=(i.ownerDocument||i).createElement("link"),Bt(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=ol(a.src),(u=i.querySelector(mo(d)))?(n.instance=u,Bt(u),u):(l=a,(u=Wn.get(d))&&(l=y({},a),xf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),Bt(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 Cf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function xf(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 Vy(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[An]||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 Yy(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function Vx(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 Xy(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Yx(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=ll(l.href),d=n.querySelector(po(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,Bt(d);return}d=n.ownerDocument||n,l=qy(l),(u=Wn.get(u))&&Cf(l,u),d=d.createElement("link"),Bt(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 Ef=0;function Xx(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&&Ef===0&&(Ef=62500*Rx());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>Ef?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(Gx,i),du=null,hu.call(i))}function Gx(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 go={$$typeof:W,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Zx(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=ci(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ci(0),this.hiddenUpdates=ci(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 Gy(i,n,a,l,u,d,_,C,M,V,re,de){return i=new Zx(i,n,a,_,M,V,re,de,C),n=1,d===!0&&(n|=24),d=Sn(3,null,null,n),i.current=d,d.stateNode=i,n=nd(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},ld(d),i}function Zy(i){return i?(i=Pa,i):Pa}function Qy(i,n,a,l,u,d){u=Zy(u),l.context===null?l.context=u:l.pendingContext=u,l=or(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=cr(i,l,n),a!==null&&(hn(a,i,n),Vl(a,i,n))}function Jy(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function kf(i,n){Jy(i,n),(i=i.alternate)&&Jy(i,n)}function eb(i){if(i.tag===13||i.tag===31){var n=Yr(i,67108864);n!==null&&hn(n,i,67108864),kf(i,67108864)}}function tb(i){if(i.tag===13||i.tag===31){var n=kn();n=mn(n);var a=Yr(i,n);a!==null&&hn(a,i,n),kf(i,n)}}var pu=!0;function Qx(i,n,a,l){var u=N.T;N.T=null;var d=$.p;try{$.p=2,Tf(i,n,a,l)}finally{$.p=d,N.T=u}}function Jx(i,n,a,l){var u=N.T;N.T=null;var d=$.p;try{$.p=8,Tf(i,n,a,l)}finally{$.p=d,N.T=u}}function Tf(i,n,a,l){if(pu){var u=Df(l);if(u===null)ff(i,n,l,mu,a),nb(i,l);else if(tE(u,i,n,a,l))l.stopPropagation();else if(nb(i,l),n&4&&-1<eE.indexOf(i)){for(;u!==null;){var d=Lt(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=_t(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var M=1<<31-Dt(_);C.entanglements[1]|=M,_&=~M}vs(d),(pt&6)===0&&(Zc=st()+500,co(0))}}break;case 31:case 13:C=Yr(d,2),C!==null&&hn(C,d,2),Jc(),kf(d,2)}if(d=Df(l),d===null&&ff(i,n,l,mu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else ff(i,n,l,null,a)}}function Df(i){return i=He(i),Rf(i)}var mu=null;function Rf(i){if(mu=null,i=Bn(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=f(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 ib(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(Qt()){case sn:return 2;case ki:return 8;case Jt:case Ti:return 32;case Gn:return 268435456;default:return 32}default:return 32}}var Mf=!1,br=null,Sr=null,wr=null,_o=new Map,vo=new Map,Cr=[],eE="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 nb(i,n){switch(i){case"focusin":case"focusout":br=null;break;case"dragenter":case"dragleave":Sr=null;break;case"mouseover":case"mouseout":wr=null;break;case"pointerover":case"pointerout":_o.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":vo.delete(n.pointerId)}}function yo(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=Lt(n),n!==null&&eb(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function tE(i,n,a,l,u){switch(n){case"focusin":return br=yo(br,i,n,a,l,u),!0;case"dragenter":return Sr=yo(Sr,i,n,a,l,u),!0;case"mouseover":return wr=yo(wr,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return _o.set(d,yo(_o.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,vo.set(d,yo(vo.get(d)||null,i,n,a,l,u)),!0}return!1}function sb(i){var n=Bn(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,gn(i.priority,function(){tb(a)});return}}else if(n===31){if(n=f(a),n!==null){i.blockedOn=n,gn(i.priority,function(){tb(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=Df(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);ie=l,a.target.dispatchEvent(l),ie=null}else return n=Lt(a),n!==null&&eb(n),i.blockedOn=a,!1;n.shift()}return!0}function rb(i,n,a){gu(i)&&a.delete(n)}function iE(){Mf=!1,br!==null&&gu(br)&&(br=null),Sr!==null&&gu(Sr)&&(Sr=null),wr!==null&&gu(wr)&&(wr=null),_o.forEach(rb),vo.forEach(rb)}function _u(i,n){i.blockedOn===n&&(i.blockedOn=null,Mf||(Mf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,iE)))}var vu=null;function ab(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(Rf(l||a)===null)continue;break}var d=Lt(a);d!==null&&(i.splice(n,3),n-=3,Td(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function cl(i){function n(M){return _u(M,i)}br!==null&&_u(br,i),Sr!==null&&_u(Sr,i),wr!==null&&_u(wr,i),_o.forEach(n),vo.forEach(n);for(var a=0;a<Cr.length;a++){var l=Cr[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Cr.length&&(a=Cr[0],a.blockedOn===null);)sb(a),a.blockedOn===null&&Cr.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[yi]||null;if(typeof d=="function")_||ab(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[yi]||null)C=_.formAction;else if(Rf(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),ab(a)}}}function lb(){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 Nf(i){this._internalRoot=i}yu.prototype.render=Nf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(r(409));var a=n.current,l=kn();Qy(a,l,i,n,null,null)},yu.prototype.unmount=Nf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Qy(i.current,2,null,i,null,null),Jc(),n[Nn]=null}};function yu(i){this._internalRoot=i}yu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Qi();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Cr.length&&n!==0&&n<Cr[a].priority;a++);Cr.splice(a,0,i),a===0&&sb(i)}};var ob=t.version;if(ob!=="19.2.6")throw Error(r(527,ob,"19.2.6"));$.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=p(n),i=i!==null?b(i):null,i=i===null?null:i.stateNode,i};var nE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:N,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var bu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bu.isDisabled&&bu.supportsFiber)try{ot=bu.inject(nE),wt=bu}catch{}}return So.createRoot=function(i,n){if(!o(i))throw Error(r(299));var a=!1,l="",u=mv,d=gv,_=_v;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=Gy(i,1,!1,null,null,a,l,null,u,d,_,lb),i[Nn]=n.current,df(i),new Nf(n)},So.hydrateRoot=function(i,n,a){if(!o(i))throw Error(r(299));var l=!1,u="",d=mv,_=gv,C=_v,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=Gy(i,1,!0,n,a??null,l,u,M,d,_,C,lb),n.context=Zy(null),a=n.current,l=kn(),l=mn(l),u=or(l),u.callback=null,cr(a,u,l),a=l,n.current.lanes=a,_i(n,a),vs(n),i[Nn]=n.current,df(i),new yu(n)},So.version="19.2.6",So}var vb;function fE(){if(vb)return Bf.exports;vb=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=dE(),Bf.exports}var pE=fE();class os extends Error{constructor(t,s){super(s),this.status=t,this.name="ApiError"}status}function ph(e=fetch){return{getSession:(t={})=>Le(e,`/api/auth/session${Wo(t)}`),setupPassword:t=>Le(e,"/api/auth/password",lt("POST",t)),login:t=>Le(e,"/api/auth/login",lt("POST",t)),reauth:t=>Le(e,"/api/auth/reauth",lt("POST",t)),logout:()=>Le(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Le(e,"/api/client-diagnostics",lt("POST",t)),setupTotp:()=>Le(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Le(e,"/api/auth/totp/activate",lt("POST",t)),disableTotp:()=>Le(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Le(e,"/api/auth/devices"),revokeDevice:async t=>{await fl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Le(e,"/api/auth/networks"),addNetwork:t=>Le(e,"/api/auth/networks",lt("POST",t)),removeNetwork:async t=>{await fl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Le(e,"/api/agents"),addAgent:t=>Le(e,"/api/agents",lt("POST",t)),reorderAgents:t=>Le(e,"/api/agents/order",lt("PUT",{serverIds:t})),renameAgent:(t,s)=>Le(e,`/api/agents/${encodeURIComponent(t)}`,lt("PATCH",{name:s})),getMainInfo:()=>Le(e,"/api/main"),renameMain:t=>Le(e,"/api/main",lt("PATCH",{name:t})),removeAgent:async t=>{await fl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Le(e,"/api/stats"),getAgentStats:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Le(e,"/api/version"),checkUpdate:()=>Le(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Le(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Le(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Le(e,"/api/terminals"),getTerminalLayout:()=>Le(e,"/api/terminal-layout"),saveTerminalLayout:t=>Le(e,"/api/terminal-layout",lt("PUT",t)),createFileRoot:t=>Le(e,"/api/files/root",lt("POST",t)),listFiles:t=>Le(e,"/api/files/list",lt("POST",t)),readFile:t=>Le(e,"/api/files/read",lt("POST",t)),writeFile:t=>Le(e,"/api/files/write",lt("POST",t)),createFileEntry:t=>Le(e,"/api/files/create",lt("POST",t)),moveFileEntry:t=>Le(e,"/api/files/move",lt("POST",t)),previewDeleteFileEntry:t=>Le(e,"/api/files/delete-preview",lt("POST",t)),deleteFileEntry:t=>Le(e,"/api/files/delete",lt("POST",t)),openFileInTerminal:t=>Le(e,"/api/files/open",lt("POST",t)),previewFile:t=>b0(e,"/api/files/preview",lt("POST",t)),createTerminal:(t={})=>Le(e,"/api/terminals",lt("POST",t)),closeTerminal:async t=>{await fl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,s)=>Le(e,`/api/terminals/${encodeURIComponent(t)}`,lt("PATCH",{title:s})),getTerminalHistory:(t,s={})=>Le(e,`/api/terminals/${encodeURIComponent(t)}/history${Wo(s)}`),getTerminalTranscriptHistory:(t,s={})=>Le(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Wo(s)}`),getTerminalTranscriptSource:t=>Le(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Le(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const s=new FormData;return s.append("asset",t),Le(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:s})},updateNotificationAssetSelection:t=>Le(e,"/api/notification-assets/selection",lt("PUT",t)),deleteNotificationAsset:async t=>{await fl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function Go(e,t=fetch){const s=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Le(t,s("terminals")),createTerminal:(r={})=>Le(t,s("terminals"),lt("POST",r)),closeTerminal:async r=>{await fl(t,s(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Le(t,s(`terminals/${encodeURIComponent(r)}`),lt("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Le(t,`${s(`terminals/${encodeURIComponent(r)}/history`)}${Wo(o)}`),getTerminalTranscriptHistory:(r,o={})=>Le(t,`${s(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Wo(o)}`),getTerminalTranscriptSource:r=>Le(t,s(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalLayout:()=>Le(t,s("terminal-layout")),saveTerminalLayout:r=>Le(t,s("terminal-layout"),lt("PUT",r)),createFileRoot:r=>Le(t,s("files/root"),lt("POST",r)),listFiles:r=>Le(t,s("files/list"),lt("POST",r)),readFile:r=>Le(t,s("files/read"),lt("POST",r)),writeFile:r=>Le(t,s("files/write"),lt("POST",r)),createFileEntry:r=>Le(t,s("files/create"),lt("POST",r)),moveFileEntry:r=>Le(t,s("files/move"),lt("POST",r)),previewDeleteFileEntry:r=>Le(t,s("files/delete-preview"),lt("POST",r)),deleteFileEntry:r=>Le(t,s("files/delete"),lt("POST",r)),openFileInTerminal:r=>Le(t,s("files/open"),lt("POST",r)),previewFile:r=>b0(t,s("files/preview"),lt("POST",r)),createWebSocketUrl:(r,o=window.location.href)=>mE(s(`terminals/${encodeURIComponent(r)}/ws`),o)}}function mE(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 lt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Wo(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 Le(e,t,s){const r=await e(t,s??{credentials:"same-origin"});await Im(r);try{return await r.json()}catch{throw new os(r.status,"invalid_json_response")}}async function fl(e,t,s){const r=await e(t,s);await Im(r)}async function b0(e,t,s){const r=await e(t,s);return await Im(r),r.blob()}async function Im(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 os(e.status,t)}const Km="nterminal.theme.id",S0="nterminal.theme.accent",mp="nterminal:theme",Vu=[{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",...yb({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",...yb({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],bl="midnight";function mh(e){return Vu.some(t=>t.id===e)?e:bl}function Wm(e){return Vu.find(t=>t.id===e)??Vu[0]}function zr(){if(typeof window>"u")return bl;try{const e=window.localStorage.getItem(Km);return e?mh(e):bE(window.localStorage.getItem(S0))}catch{return bl}}function gE(e){const t=mh(e);if(typeof window<"u"){try{window.localStorage.setItem(Km,t)}catch{}Fm(t),window.dispatchEvent(new CustomEvent(mp,{detail:t}))}return t}function Fm(e=zr()){if(typeof document>"u")return;const t=Wm(mh(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 _E(e=zr()){return Wm(mh(e)).xterm}function qm(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===Km||s.key===S0)&&(Fm(zr()),e())};return window.addEventListener(mp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(mp,e),window.removeEventListener("storage",t)}}function Qe(e,t,s){e.style.setProperty(t,s)}function yb(e){const t=vE(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 vE(e){const t=[];for(let s=16;s<=e;s+=1)t.push(yE(s));return t}function yE(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 bb(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return bb(t,t,t)}return"#000000"}function bb(e,t,s){return`#${Hf(e)}${Hf(t)}${Hf(s)}`}function Hf(e){return e.toString(16).padStart(2,"0")}function bE(e){return e==="signal-red"?"signal-red":bl}function w0(){const e=v.useSyncExternalStore(qm,zr,()=>bl);return Wm(e).mode==="light"?"-light":""}function C0({size:e=22}){const t=w0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function x0({height:e=18}){const t=w0(),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 Lo=y0();const gh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function kl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function $m(e){return"nodeType"in e}function pn(e){var t,s;return e?kl(e)?e:$m(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Vm(e){const{Document:t}=pn(e);return e instanceof t}function oc(e){return kl(e)?!1:e instanceof pn(e).HTMLElement}function E0(e){return e instanceof pn(e).SVGElement}function Tl(e){return e?kl(e)?e.document:$m(e)?Vm(e)?e:oc(e)||E0(e)?e.ownerDocument:document:document:document}const jr=gh?v.useLayoutEffect:v.useEffect;function Ym(e){const t=v.useRef(e);return jr(()=>{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 SE(){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 Zo(e,t){t===void 0&&(t=[e]);const s=v.useRef(e);return jr(()=>{s.current!==e&&(s.current=e)},t),s}function cc(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 gp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Pf={};function _h(e,t){return v.useMemo(()=>{if(t)return t;const s=Pf[e]==null?0:Pf[e]+1;return Pf[e]=s,e+"-"+s},[e,t])}function k0(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 f=Object.entries(h);for(const[g,p]of f){const b=c[g];b!=null&&(c[g]=b+e*p)}return c},{...t})}}const vl=k0(1),Xu=k0(-1);function wE(e){return"clientX"in e&&"clientY"in e}function T0(e){if(!e)return!1;const{KeyboardEvent:t}=pn(e.target);return t&&e instanceof t}function CE(e){if(!e)return!1;const{TouchEvent:t}=pn(e.target);return t&&e instanceof t}function _p(e){if(CE(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 wE(e)?{x:e.clientX,y:e.clientY}:null}const vp=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[vp.Translate.toString(e),vp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:r}=e;return t+" "+s+"ms "+r}}}),Sb="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xE(e){return e.matches(Sb)?e:e.querySelector(Sb)}const EE={display:"none"};function kE(e){let{id:t,value:s}=e;return xi.createElement("div",{id:t,style:EE},s)}function TE(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 xi.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},s)}function DE(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const D0=v.createContext(null);function RE(e){const t=v.useContext(D0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ME(){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 f;return(f=h[o])==null?void 0:f.call(h,c)})},[e]),t]}const NE={draggable:`
|
|
11
|
+
To pick up a draggable item, press the space bar.
|
|
12
|
+
While dragging, use the arrow keys to move the item.
|
|
13
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
14
|
+
`},AE={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over: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 LE(e){let{announcements:t=AE,container:s,hiddenTextDescribedById:r,screenReaderInstructions:o=NE}=e;const{announce:c,announcement:h}=DE(),f=_h("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),RE(v.useMemo(()=>({onDragStart(y){let{active:S}=y;c(t.onDragStart({active:S}))},onDragMove(y){let{active:S,over:w}=y;t.onDragMove&&c(t.onDragMove({active:S,over:w}))},onDragOver(y){let{active:S,over:w}=y;c(t.onDragOver({active:S,over:w}))},onDragEnd(y){let{active:S,over:w}=y;c(t.onDragEnd({active:S,over:w}))},onDragCancel(y){let{active:S,over:w}=y;c(t.onDragCancel({active:S,over:w}))}}),[c,t])),!g)return null;const b=xi.createElement(xi.Fragment,null,xi.createElement(kE,{id:r,value:o.draggable}),xi.createElement(TE,{id:f,announcement:h}));return s?Lo.createPortal(b,s):b}var Ci;(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"})(Ci||(Ci={}));function Gu(){}function wb(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function BE(){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 cs=Object.freeze({x:0,y:0});function OE(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return r-s}function zE(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function jE(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,f=c-s;if(r<o&&s<c){const g=t.width*t.height,p=e.width*e.height,b=h*f,y=b/(g+p-b);return Number(y.toFixed(4))}return 0}const HE=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const o=[];for(const c of r){const{id:h}=c,f=s.get(h);if(f){const g=jE(f,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(OE)};function PE(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function R0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:cs}function UE(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,f)=>({...h,top:h.top+e*f.y,bottom:h.bottom+e*f.y,left:h.left+e*f.x,right:h.right+e*f.x}),{...s})}}const IE=UE(1);function KE(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 WE(e,t,s){const r=KE(t);if(!r)return e;const{scaleX:o,scaleY:c,x:h,y:f}=r,g=e.left-h-(1-o)*parseFloat(s),p=e.top-f-(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:p,right:g+b,bottom:p+y,left:g}}const FE={ignoreTransform:!1};function uc(e,t){t===void 0&&(t=FE);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:b}=pn(e).getComputedStyle(e);p&&(s=WE(s,p,b))}const{top:r,left:o,width:c,height:h,bottom:f,right:g}=s;return{top:r,left:o,width:c,height:h,bottom:f,right:g}}function Cb(e){return uc(e,{ignoreTransform:!0})}function qE(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function $E(e,t){return t===void 0&&(t=pn(e).getComputedStyle(e)),t.position==="fixed"}function VE(e,t){t===void 0&&(t=pn(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 Xm(e,t){const s=[];function r(o){if(t!=null&&s.length>=t||!o)return s;if(Vm(o)&&o.scrollingElement!=null&&!s.includes(o.scrollingElement))return s.push(o.scrollingElement),s;if(!oc(o)||E0(o)||s.includes(o))return s;const c=pn(e).getComputedStyle(o);return o!==e&&VE(o,c)&&s.push(o),$E(o,c)?s:r(o.parentNode)}return e?r(e):s}function M0(e){const[t]=Xm(e,1);return t??null}function Uf(e){return!gh||!e?null:kl(e)?e:$m(e)?Vm(e)||e===Tl(e).scrollingElement?window:oc(e)?e:null:null}function N0(e){return kl(e)?e.scrollX:e.scrollLeft}function A0(e){return kl(e)?e.scrollY:e.scrollTop}function yp(e){return{x:N0(e),y:A0(e)}}var Li;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Li||(Li={}));function L0(e){return!gh||!e?!1:e===document.scrollingElement}function B0(e){const t={x:0,y:0},s=L0(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,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:h,isRight:f,maxScroll:r,minScroll:t}}const YE={x:.2,y:.2};function XE(e,t,s,r,o){let{top:c,left:h,right:f,bottom:g}=s;r===void 0&&(r=10),o===void 0&&(o=YE);const{isTop:p,isBottom:b,isLeft:y,isRight:S}=B0(e),w={x:0,y:0},k={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+T.height?(w.y=Li.Backward,k.y=r*Math.abs((t.top+T.height-c)/T.height)):!b&&g>=t.bottom-T.height&&(w.y=Li.Forward,k.y=r*Math.abs((t.bottom-T.height-g)/T.height)),!S&&f>=t.right-T.width?(w.x=Li.Forward,k.x=r*Math.abs((t.right-T.width-f)/T.width)):!y&&h<=t.left+T.width&&(w.x=Li.Backward,k.x=r*Math.abs((t.left+T.width-h)/T.width)),{direction:w,speed:k}}function GE(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 O0(e){return e.reduce((t,s)=>vl(t,yp(s)),cs)}function ZE(e){return e.reduce((t,s)=>t+N0(s),0)}function QE(e){return e.reduce((t,s)=>t+A0(s),0)}function JE(e,t){if(t===void 0&&(t=uc),!e)return;const{top:s,left:r,bottom:o,right:c}=t(e);M0(e)&&(o<=0||c<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const e2=[["x",["left","right"],ZE],["y",["top","bottom"],QE]];class Gm{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=Xm(s),o=O0(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,f]of e2)for(const g of h)Object.defineProperty(this,g,{get:()=>{const p=f(r),b=o[c]-p;return this.rect[g]+b},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Fo{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 t2(e){const{EventTarget:t}=pn(e);return e instanceof t?e:Tl(e)}function If(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 xb(e){e.preventDefault()}function i2(e){e.stopPropagation()}var At;(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"})(At||(At={}));const z0={start:[At.Space,At.Enter],cancel:[At.Esc],end:[At.Space,At.Enter,At.Tab]},n2=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case At.Right:return{...s,x:s.x+25};case At.Left:return{...s,x:s.x-25};case At.Down:return{...s,y:s.y+25};case At.Up:return{...s,y:s.y-25}}};class j0{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 Fo(Tl(s)),this.windowListeners=new Fo(pn(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&&JE(r),s(cs)}handleKeyDown(t){if(T0(t)){const{active:s,context:r,options:o}=this.props,{keyboardCodes:c=z0,coordinateGetter:h=n2,scrollBehavior:f="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,b=p?{x:p.left,y:p.top}:cs;this.referenceCoordinates||(this.referenceCoordinates=b);const y=h(t,{active:s,context:r.current,currentCoordinates:b});if(y){const S=Xu(y,b),w={x:0,y:0},{scrollableAncestors:k}=r.current;for(const T of k){const B=t.code,{isTop:L,isRight:A,isLeft:W,isBottom:I,maxScroll:ee,minScroll:se}=B0(T),ae=GE(T),oe={x:Math.min(B===At.Right?ae.right-ae.width/2:ae.right,Math.max(B===At.Right?ae.left:ae.left+ae.width/2,y.x)),y:Math.min(B===At.Down?ae.bottom-ae.height/2:ae.bottom,Math.max(B===At.Down?ae.top:ae.top+ae.height/2,y.y))},ve=B===At.Right&&!A||B===At.Left&&!W,U=B===At.Down&&!I||B===At.Up&&!L;if(ve&&oe.x!==y.x){const K=T.scrollLeft+S.x,Y=B===At.Right&&K<=ee.x||B===At.Left&&K>=se.x;if(Y&&!S.y){T.scrollTo({left:K,behavior:f});return}Y?w.x=T.scrollLeft-K:w.x=B===At.Right?T.scrollLeft-ee.x:T.scrollLeft-se.x,w.x&&T.scrollBy({left:-w.x,behavior:f});break}else if(U&&oe.y!==y.y){const K=T.scrollTop+S.y,Y=B===At.Down&&K<=ee.y||B===At.Up&&K>=se.y;if(Y&&!S.x){T.scrollTo({top:K,behavior:f});return}Y?w.y=T.scrollTop-K:w.y=B===At.Down?T.scrollTop-ee.y:T.scrollTop-se.y,w.y&&T.scrollBy({top:-w.y,behavior:f});break}}this.handleMove(t,vl(Xu(y,this.referenceCoordinates),w))}}}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()}}j0.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:r=z0,onActivation:o}=t,{active:c}=s;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Eb(e){return!!(e&&"distance"in e)}function kb(e){return!!(e&&"delay"in e)}class Zm{constructor(t,s,r){var o;r===void 0&&(r=t2(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=Tl(h),this.documentListeners=new Fo(this.document),this.listeners=new Fo(r),this.windowListeners=new Fo(pn(h)),this.initialCoordinates=(o=_p(c))!=null?o:cs,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,xb),this.windowListeners.add($n.VisibilityChange,this.handleCancel),this.windowListeners.add($n.ContextMenu,xb),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(kb(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Eb(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,i2,{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:f}}=c;if(!o)return;const g=(s=_p(t))!=null?s:cs,p=Xu(o,g);if(!r&&f){if(Eb(f)){if(f.tolerance!=null&&If(p,f.tolerance))return this.handleCancel();if(If(p,f.distance))return this.handleStart()}if(kb(f)&&If(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);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===At.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const s2={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class H0 extends Zm{constructor(t){const{event:s}=t,r=Tl(s.target);super(t,s2,r)}}H0.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 r2={move:{name:"mousemove"},end:{name:"mouseup"}};var bp;(function(e){e[e.RightClick=2]="RightClick"})(bp||(bp={}));class P0 extends Zm{constructor(t){super(t,r2,Tl(t.event.target))}}P0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return s.button===bp.RightClick?!1:(r?.({event:s}),!0)}}];const Kf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class U0 extends Zm{constructor(t){super(t,Kf)}static setup(){return window.addEventListener(Kf.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Kf.move.name,t)};function t(){}}}U0.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 qo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qo||(qo={}));var Zu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Zu||(Zu={}));function a2(e){let{acceleration:t,activator:s=qo.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:h=5,order:f=Zu.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:b,delta:y,threshold:S}=e;const w=o2({delta:y,disabled:!c}),[k,T]=SE(),B=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),A=v.useMemo(()=>{switch(s){case qo.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case qo.DraggableRect:return o}},[s,o,g]),W=v.useRef(null),I=v.useCallback(()=>{const se=W.current;if(!se)return;const ae=B.current.x*L.current.x,oe=B.current.y*L.current.y;se.scrollBy(ae,oe)},[]),ee=v.useMemo(()=>f===Zu.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!c||!p.length||!A){T();return}for(const se of ee){if(r?.(se)===!1)continue;const ae=p.indexOf(se),oe=b[ae];if(!oe)continue;const{direction:ve,speed:U}=XE(se,oe,A,t,S);for(const K of["x","y"])w[K][ve[K]]||(U[K]=0,ve[K]=0);if(U.x>0||U.y>0){T(),W.current=se,k(I,h),B.current=U,L.current=ve;return}}B.current={x:0,y:0},L.current={x:0,y:0},T()},[t,I,r,T,c,h,JSON.stringify(A),JSON.stringify(w),k,p,ee,b,JSON.stringify(S)])}const l2={x:{[Li.Backward]:!1,[Li.Forward]:!1},y:{[Li.Backward]:!1,[Li.Forward]:!1}};function o2(e){let{delta:t,disabled:s}=e;const r=gp(t);return cc(o=>{if(s||!r||!o)return l2;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Li.Backward]:o.x[Li.Backward]||c.x===-1,[Li.Forward]:o.x[Li.Forward]||c.x===1},y:{[Li.Backward]:o.y[Li.Backward]||c.y===-1,[Li.Forward]:o.y[Li.Forward]||c.y===1}}},[s,t,r])}function c2(e,t){const s=t!=null?e.get(t):void 0,r=s?s.node.current:null;return cc(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function u2(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 Qo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Qo||(Qo={}));var Sp;(function(e){e.Optimized="optimized"})(Sp||(Sp={}));const Tb=new Map;function h2(e,t){let{dragging:s,dependencies:r,config:o}=t;const[c,h]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,b=v.useRef(e),y=B(),S=Zo(y),w=v.useCallback(function(L){L===void 0&&(L=[]),!S.current&&h(A=>A===null?L:A.concat(L.filter(W=>!A.includes(W))))},[S]),k=v.useRef(null),T=cc(L=>{if(y&&!s)return Tb;if(!L||L===Tb||b.current!==e||c!=null){const A=new Map;for(let W of e){if(!W)continue;if(c&&c.length>0&&!c.includes(W.id)&&W.rect.current){A.set(W.id,W.rect.current);continue}const I=W.node.current,ee=I?new Gm(g(I),I):null;W.rect.current=ee,ee&&A.set(W.id,ee)}return A}return L},[e,c,s,y,g]);return v.useEffect(()=>{b.current=e},[e]),v.useEffect(()=>{y||w()},[s,y]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{y||typeof f!="number"||k.current!==null||(k.current=setTimeout(()=>{w(),k.current=null},f))},[f,y,w,...r]),{droppableRects:T,measureDroppableContainers:w,measuringScheduled:c!=null};function B(){switch(p){case Qo.Always:return!1;case Qo.BeforeDragging:return s;default:return!s}}}function I0(e,t){return cc(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function d2(e,t){return I0(e,t)}function f2(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 vh(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 p2(e){return new Gm(uc(e),e)}function Db(e,t,s){t===void 0&&(t=p2);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??s)!=null?p:null}const b=t(e);return JSON.stringify(g)===JSON.stringify(b)?g:b})}const h=f2({callback(g){if(e)for(const p of g){const{type:b,target:y}=p;if(b==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),f=vh({callback:c});return jr(()=>{c(),e?(f?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),h?.disconnect())},[e]),r}function m2(e){const t=I0(e);return R0(e,t)}const Rb=[];function g2(e){const t=v.useRef(e),s=cc(r=>e?r&&r!==Rb&&e&&t.current&&e.parentNode===t.current.parentNode?r:Xm(e):Rb,[e]);return v.useEffect(()=>{t.current=e},[e]),s}function _2(e){const[t,s]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const h=Uf(c.target);h&&s(f=>f?(f.set(h,yp(h)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){h(c);const f=e.map(g=>{const p=Uf(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,yp(p)]):null}).filter(g=>g!=null);s(f.length?new Map(f):null),r.current=e}return()=>{h(e),h(c)};function h(f){f.forEach(g=>{const p=Uf(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>vl(c,h),cs):O0(e):cs,[e,t])}function Mb(e,t){t===void 0&&(t=[]);const s=v.useRef(null);return v.useEffect(()=>{s.current=null},t),v.useEffect(()=>{const r=e!==cs;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Xu(e,s.current):cs}function v2(e){v.useEffect(()=>{if(!gh)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 y2(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 K0(e){return v.useMemo(()=>e?qE(e):null,[e])}const Nb=[];function b2(e,t){t===void 0&&(t=uc);const[s]=e,r=K0(s?pn(s):null),[o,c]=v.useState(Nb);function h(){c(()=>e.length?e.map(g=>L0(g)?r:new Gm(t(g),g)):Nb)}const f=vh({callback:h});return jr(()=>{f?.disconnect(),h(),e.forEach(g=>f?.observe(g))},[e]),o}function S2(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return oc(t)?t:e}function w2(e){let{measure:t}=e;const[s,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:b}of p)if(oc(b)){r(y=>{const S=t(b);return y?{...y,width:S.width,height:S.height}:S});break}},[t]),c=vh({callback:o}),h=v.useCallback(p=>{const b=S2(p);c?.disconnect(),b&&c?.observe(b),r(b?t(b):null)},[t,c]),[f,g]=Yu(h);return v.useMemo(()=>({nodeRef:f,rect:s,setRef:g}),[s,f,g])}const C2=[{sensor:H0,options:{}},{sensor:j0,options:{}}],x2={current:{}},Bu={draggable:{measure:Cb},droppable:{measure:Cb,strategy:Qo.WhileDragging,frequency:Sp.Optimized},dragOverlay:{measure:uc}};class $o 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 E2={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new $o,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bu,measureDroppableContainers:Gu,windowRect:null,measuringScheduled:!1},k2={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Gu,draggableNodes:new Map,over:null,measureDroppableContainers:Gu},yh=v.createContext(k2),T2=v.createContext(E2);function D2(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new $o}}}function R2(e,t){switch(t.type){case Ci.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ci.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 Ci.DragEnd:case Ci.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ci.RegisterDroppable:{const{element:s}=t,{id:r}=s,o=new $o(e.droppable.containers);return o.set(r,s),{...e,droppable:{...e.droppable,containers:o}}}case Ci.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 $o(e.droppable.containers);return h.set(s,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case Ci.UnregisterDroppable:{const{id:s,key:r}=t,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const c=new $o(e.droppable.containers);return c.delete(s),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function M2(e){let{disabled:t}=e;const{active:s,activatorEvent:r,draggableNodes:o}=v.useContext(yh),c=gp(r),h=gp(s?.id);return v.useEffect(()=>{if(!t&&!r&&c&&h!=null){if(!T0(c)||document.activeElement===c.target)return;const f=o.get(h);if(!f)return;const{activatorNode:g,node:p}=f;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const b of[g.current,p.current]){if(!b)continue;const y=xE(b);if(y){y.focus();break}}})}},[r,t,o,h,c]),null}function N2(e,t){let{transform:s,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),s):s}function A2(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 L2(e){let{activeNode:t,measure:s,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:f}=typeof o=="boolean"?{x:o,y:o}:o;jr(()=>{if(!h&&!f||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const b=s(p),y=R0(b,r);if(h||(y.x=0),f||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const S=M0(p);S&&S.scrollBy({top:y.y,left:y.x})}},[t,h,f,r,s])}const W0=v.createContext({...cs,scaleX:1,scaleY:1});var Nr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Nr||(Nr={}));const B2=v.memo(function(t){var s,r,o,c;let{id:h,accessibility:f,autoScroll:g=!0,children:p,sensors:b=C2,collisionDetection:y=HE,measuring:S,modifiers:w,...k}=t;const T=v.useReducer(R2,void 0,D2),[B,L]=T,[A,W]=ME(),[I,ee]=v.useState(Nr.Uninitialized),se=I===Nr.Initialized,{draggable:{active:ae,nodes:oe,translate:ve},droppable:{containers:U}}=B,K=ae!=null?oe.get(ae):null,Y=v.useRef({initial:null,translated:null}),H=v.useMemo(()=>{var gt;return ae!=null?{id:ae,data:(gt=K?.data)!=null?gt:x2,rect:Y}:null},[ae,K]),j=v.useRef(null),[te,N]=v.useState(null),[$,X]=v.useState(null),Se=Zo(k,Object.values(k)),De=_h("DndDescribedBy",h),R=v.useMemo(()=>U.getEnabled(),[U]),G=A2(S),{droppableRects:ce,measureDroppableContainers:me,measuringScheduled:xe}=h2(R,{dragging:se,dependencies:[ve.x,ve.y],config:G.droppable}),Ee=c2(oe,ae),Me=v.useMemo(()=>$?_p($):null,[$]),qe=Pi(),ge=d2(Ee,G.draggable.measure);L2({activeNode:ae!=null?oe.get(ae):null,config:qe.layoutShiftCompensation,initialRect:ge,measure:G.draggable.measure});const Q=Db(Ee,G.draggable.measure,ge),he=Db(Ee?Ee.parentElement:null),we=v.useRef({activatorEvent:null,active:null,activeNode:Ee,collisionRect:null,collisions:null,droppableRects:ce,draggableNodes:oe,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),_e=U.getNodeFor((s=we.current.over)==null?void 0:s.id),Te=w2({measure:G.dragOverlay.measure}),Be=(r=Te.nodeRef.current)!=null?r:Ee,Ie=se?(o=Te.rect)!=null?o:Q:null,le=!!(Te.nodeRef.current&&Te.rect),Ce=m2(le?null:Q),Ne=K0(Be?pn(Be):null),Oe=g2(se?_e??Ee:null),je=b2(Oe),mt=N2(w,{transform:{x:ve.x-Ce.x,y:ve.y-Ce.y,scaleX:1,scaleY:1},activatorEvent:$,active:H,activeNodeRect:Q,containerNodeRect:he,draggingNodeRect:Ie,over:we.current.over,overlayNodeRect:Te.rect,scrollableAncestors:Oe,scrollableAncestorRects:je,windowRect:Ne}),Xe=Me?vl(Me,ve):null,st=_2(Oe),Qt=Mb(st),sn=Mb(st,[Q]),ki=vl(mt,Qt),Jt=Ie?IE(Ie,mt):null,Ti=H&&Jt?y({active:H,collisionRect:Jt,droppableRects:ce,droppableContainers:R,pointerCoordinates:Xe}):null,Gn=zE(Ti,"id"),[F,$e]=v.useState(null),ot=le?mt:vl(mt,sn),wt=PE(ot,(c=F?.rect)!=null?c:null,Q),li=v.useRef(null),Dt=v.useCallback((gt,_t)=>{let{sensor:Ct,options:Di}=_t;if(j.current==null)return;const oi=oe.get(j.current);if(!oi)return;const qt=gt.nativeEvent,ci=new Ct({active:j.current,activeNode:oi,event:qt,options:Di,context:we,onAbort(Ht){if(!oe.get(Ht))return;const{onDragAbort:ei}=Se.current,vi={id:Ht};ei?.(vi),A({type:"onDragAbort",event:vi})},onPending(Ht,Ri,ei,vi){if(!oe.get(Ht))return;const{onDragPending:Zi}=Se.current,Qi={id:Ht,constraint:Ri,initialCoordinates:ei,offset:vi};Zi?.(Qi),A({type:"onDragPending",event:Qi})},onStart(Ht){const Ri=j.current;if(Ri==null)return;const ei=oe.get(Ri);if(!ei)return;const{onDragStart:vi}=Se.current,mn={activatorEvent:qt,active:{id:Ri,data:ei.data,rect:Y}};Lo.unstable_batchedUpdates(()=>{vi?.(mn),ee(Nr.Initializing),L({type:Ci.DragStart,initialCoordinates:Ht,active:Ri}),A({type:"onDragStart",event:mn}),N(li.current),X(qt)})},onMove(Ht){L({type:Ci.DragMove,coordinates:Ht})},onEnd:_i(Ci.DragEnd),onCancel:_i(Ci.DragCancel)});li.current=ci;function _i(Ht){return async function(){const{active:ei,collisions:vi,over:mn,scrollAdjustedTranslate:Zi}=we.current;let Qi=null;if(ei&&Zi){const{cancelDrop:gn}=Se.current;Qi={activatorEvent:qt,active:ei,collisions:vi,delta:Zi,over:mn},Ht===Ci.DragEnd&&typeof gn=="function"&&await Promise.resolve(gn(Qi))&&(Ht=Ci.DragCancel)}j.current=null,Lo.unstable_batchedUpdates(()=>{L({type:Ht}),ee(Nr.Uninitialized),$e(null),N(null),X(null),li.current=null;const gn=Ht===Ci.DragEnd?"onDragEnd":"onDragCancel";if(Qi){const $i=Se.current[gn];$i?.(Qi),A({type:gn,event:Qi})}})}}},[oe]),rn=v.useCallback((gt,_t)=>(Ct,Di)=>{const oi=Ct.nativeEvent,qt=oe.get(Di);if(j.current!==null||!qt||oi.dndKit||oi.defaultPrevented)return;const ci={active:qt};gt(Ct,_t.options,ci)===!0&&(oi.dndKit={capturedBy:_t.sensor},j.current=Di,Dt(Ct,_t))},[oe,Dt]),Zn=u2(b,rn);v2(b),jr(()=>{Q&&I===Nr.Initializing&&ee(Nr.Initialized)},[Q,I]),v.useEffect(()=>{const{onDragMove:gt}=Se.current,{active:_t,activatorEvent:Ct,collisions:Di,over:oi}=we.current;if(!_t||!Ct)return;const qt={active:_t,activatorEvent:Ct,collisions:Di,delta:{x:ki.x,y:ki.y},over:oi};Lo.unstable_batchedUpdates(()=>{gt?.(qt),A({type:"onDragMove",event:qt})})},[ki.x,ki.y]),v.useEffect(()=>{const{active:gt,activatorEvent:_t,collisions:Ct,droppableContainers:Di,scrollAdjustedTranslate:oi}=we.current;if(!gt||j.current==null||!_t||!oi)return;const{onDragOver:qt}=Se.current,ci=Di.get(Gn),_i=ci&&ci.rect.current?{id:ci.id,rect:ci.rect.current,data:ci.data,disabled:ci.disabled}:null,Ht={active:gt,activatorEvent:_t,collisions:Ct,delta:{x:oi.x,y:oi.y},over:_i};Lo.unstable_batchedUpdates(()=>{$e(_i),qt?.(Ht),A({type:"onDragOver",event:Ht})})},[Gn]),jr(()=>{we.current={activatorEvent:$,active:H,activeNode:Ee,collisionRect:Jt,collisions:Ti,droppableRects:ce,draggableNodes:oe,draggingNode:Be,draggingNodeRect:Ie,droppableContainers:U,over:F,scrollableAncestors:Oe,scrollAdjustedTranslate:ki},Y.current={initial:Ie,translated:Jt}},[H,Ee,Ti,Jt,oe,Be,Ie,ce,U,F,Oe,ki]),a2({...qe,delta:ve,draggingRect:Jt,pointerCoordinates:Xe,scrollableAncestors:Oe,scrollableAncestorRects:je});const Qn=v.useMemo(()=>({active:H,activeNode:Ee,activeNodeRect:Q,activatorEvent:$,collisions:Ti,containerNodeRect:he,dragOverlay:Te,draggableNodes:oe,droppableContainers:U,droppableRects:ce,over:F,measureDroppableContainers:me,scrollableAncestors:Oe,scrollableAncestorRects:je,measuringConfiguration:G,measuringScheduled:xe,windowRect:Ne}),[H,Ee,Q,$,Ti,he,Te,oe,U,ce,F,me,Oe,je,G,xe,Ne]),Rt=v.useMemo(()=>({activatorEvent:$,activators:Zn,active:H,activeNodeRect:Q,ariaDescribedById:{draggable:De},dispatch:L,draggableNodes:oe,over:F,measureDroppableContainers:me}),[$,Zn,H,Q,L,De,oe,F,me]);return xi.createElement(D0.Provider,{value:W},xi.createElement(yh.Provider,{value:Rt},xi.createElement(T2.Provider,{value:Qn},xi.createElement(W0.Provider,{value:wt},p)),xi.createElement(M2,{disabled:f?.restoreFocus===!1})),xi.createElement(LE,{...f,hiddenTextDescribedById:De}));function Pi(){const gt=te?.autoScrollEnabled===!1,_t=typeof g=="object"?g.enabled===!1:g===!1,Ct=se&&!gt&&!_t;return typeof g=="object"?{...g,enabled:Ct}:{enabled:Ct}}}),O2=v.createContext(null),Ab="button",z2="Draggable";function F0(e){let{id:t,data:s,disabled:r=!1,attributes:o}=e;const c=_h(z2),{activators:h,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:b,draggableNodes:y,over:S}=v.useContext(yh),{role:w=Ab,roleDescription:k="draggable",tabIndex:T=0}=o??{},B=g?.id===t,L=v.useContext(B?W0:O2),[A,W]=Yu(),[I,ee]=Yu(),se=y2(h,t),ae=Zo(s);jr(()=>(y.set(t,{id:t,key:c,node:A,activatorNode:I,data:ae}),()=>{const ve=y.get(t);ve&&ve.key===c&&y.delete(t)}),[y,t]);const oe=v.useMemo(()=>({role:w,tabIndex:T,"aria-disabled":r,"aria-pressed":B&&w===Ab?!0:void 0,"aria-roledescription":k,"aria-describedby":b.draggable}),[r,w,T,B,k,b.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:oe,isDragging:B,listeners:r?void 0:se,node:A,over:S,setNodeRef:W,setActivatorNodeRef:ee,transform:L}}const j2="Droppable",H2={timeout:25};function Qm(e){let{data:t,disabled:s=!1,id:r,resizeObserverConfig:o}=e;const c=_h(j2),{active:h,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(yh),b=v.useRef({disabled:s}),y=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),{disabled:k,updateMeasurementsFor:T,timeout:B}={...H2,...o},L=Zo(T??r),A=v.useCallback(()=>{if(!y.current){y.current=!0;return}w.current!=null&&clearTimeout(w.current),w.current=setTimeout(()=>{p(Array.isArray(L.current)?L.current:[L.current]),w.current=null},B)},[B]),W=vh({callback:A,disabled:k||!h}),I=v.useCallback((oe,ve)=>{W&&(ve&&(W.unobserve(ve),y.current=!1),oe&&W.observe(oe))},[W]),[ee,se]=Yu(I),ae=Zo(t);return v.useEffect(()=>{!W||!ee.current||(W.disconnect(),y.current=!1,W.observe(ee.current))},[ee,W]),v.useEffect(()=>(f({type:Ci.RegisterDroppable,element:{id:r,key:c,disabled:s,node:ee,rect:S,data:ae}}),()=>f({type:Ci.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{s!==b.current.disabled&&(f({type:Ci.SetDroppableDisabled,id:r,key:c,disabled:s}),b.current.disabled=s)},[r,c,s,f]),{active:h,rect:S,isOver:g?.id===r,node:ee,over:g,setNodeRef:se}}const P2=128,U2=512,Dl=100,I2="too_many_detached_terminals",K2=64,W2=4096;function q0(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>P2)return null;const s=t.workspaces.map(F2);return s.some(r=>r===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}function $0(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>Dl}):!1}function F2(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>U2)return null;const s=t.tabs.map(q2);if(s.some(o=>o===null))return null;const r=X2(t.detachedTerminalIds,Dl);return r===null?null:{id:t.id,title:t.title,defaultCwd:Y2(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:s}}function q2(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=$2(t.root);return s?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:s}:null}function $2(e){if(!e||typeof e!="object")return null;let t=0;return wp(e,1,()=>(t+=1,t<=W2))}function wp(e,t,s){if(!e||typeof e!="object"||t>K2||!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=wp(r.first,t+1,s),c=wp(r.second,t+1,s);return!o||!c?null:{type:"split",direction:r.direction,ratio:V2(r.ratio),first:o,second:c}}function V2(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function Y2(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function X2(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 V0=[{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"}],pa="__main__";function G2(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Z2(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Lb="Local",Q2=3e4,J2=2,ek=6,Y0="nterminal.serverList.viewMode.v1";function tk(){try{return window.localStorage.getItem(Y0)==="list"?"list":"stats"}catch{return"stats"}}function ik(e){try{window.localStorage.setItem(Y0,e)}catch{}}function ua(e,t){const s=[pa,...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 nk(e,t){const s=new Map(e.map(r=>[r.id,r]));return ua(t,e).flatMap(r=>{if(r===pa)return[{kind:"main",id:pa}];const o=s.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function Bb(e,t){return e.length===t.length&&e.every((s,r)=>s===t[r])}function X0(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Yn(e.cpuPercent)} ${Jm(e)}`,`MEM ${Yn(e.memoryPercent)} ${Xs(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Yn(e.diskPercent)} ${Xs(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Yn(e.swapPercent)} ${Xs(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function sk(e){if(!(e===void 0||e==="error"))return[`CPU ${Yn(e.cpuPercent)} (${Jm(e)})`,`RAM ${Yn(e.memoryPercent)} (${Xs(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Yn(e.diskPercent)} (${Xs(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Yn(e.swapPercent)} (${Xs(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function rk(e,t){const s=X0(t);return`${e}${s?` — ${s}`:""}. Double-click to rename.`}function Yn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Jm(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`:`${Cp(e.cpuPercent/100*t)}/${t} cores`}function Xs(e,t){return!Ob(e)||!Ob(t)?"–/–":ak(e,t)}function ak(e,t){const s=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=s==="GB"?1024**3:s==="MB"?1024**2:1024;return`${Cp(e/r)}/${Cp(t/r)} ${s}`}function Cp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Ob(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 lk(e){return[{label:"CPU",percent:Yn(e.cpuPercent),detail:Jm(e),tone:Su(e.cpuPercent)},{label:"MEM",percent:Yn(e.memoryPercent),detail:Xs(e.memoryUsedBytes,e.memoryTotalBytes),tone:Su(e.memoryPercent)},{label:"DISK",percent:Yn(e.diskPercent),detail:Xs(e.diskUsedBytes,e.diskTotalBytes),tone:Su(e.diskPercent)},{label:"SWAP",percent:Yn(e.swapPercent),detail:Xs(e.swapUsedBytes,e.swapTotalBytes),tone:Su(e.swapPercent)}]}function ok({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:sk(e),children:lk(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 zb({api:e,activeAgentId:t,onSelectServer:s,onSessionInvalid:r,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[f,g]=v.useState([]),[p,b]=v.useState([pa]),[y,S]=v.useState(null),[w,k]=v.useState(null),[T,B]=v.useState(""),L=v.useRef(null),[A,W]=v.useState(()=>tk()),[I,ee]=v.useState(null),[se,ae]=v.useState(null),[oe,ve]=v.useState({}),U=v.useRef({}),K=v.useRef(0),Y=v.useRef([]),H=v.useRef([pa]),j=v.useRef(null);v.useEffect(()=>{Y.current=f},[f]),v.useEffect(()=>{const Q=ua(p,f);H.current=Q,Bb(Q,p)||b(Q)},[f,p]),v.useEffect(()=>{let Q=!1;return e.listAgents().then(he=>{Q||(g(he.agents),b(ua(he.serverOrder,he.agents)))}).catch(()=>{}),e.getMainInfo().then(he=>{Q||S(he.name)}).catch(()=>{}),()=>{Q=!0}},[e,o]),v.useEffect(()=>{w&&(L.current?.focus(),L.current?.select())},[w]),v.useEffect(()=>{let Q=!1;function he(){const _e=[{key:"__main__",load:()=>e.getMainStats()},...f.map(Be=>({key:Be.id,load:()=>e.getAgentStats(Be.id)}))],Te=new Set(_e.map(Be=>Be.key));for(const Be of Object.keys(U.current))Te.has(Be)||delete U.current[Be];ve(Be=>{const Ie={};for(const le of Te)le in Be&&(Ie[le]=Be[le]);return Ie});for(const Be of _e)Be.load().then(Ie=>{Q||(U.current[Be.key]=0,ve(le=>Te.has(Be.key)?{...le,[Be.key]:Ie}:le))}).catch(Ie=>{if(Q)return;if(Ie instanceof os&&Ie.status===401&&Be.key==="__main__"){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}const le=(U.current[Be.key]??0)+1;U.current[Be.key]=le,le>=J2&&ve(Ce=>Te.has(Be.key)?{...Ce,[Be.key]:"error"}:Ce)})}he();const we=window.setInterval(he,Q2);return()=>{Q=!0,window.clearInterval(we)}},[e,f,r]);function te(Q){Q==="main"?(B(y??""),k({kind:"main"})):(B(Q.name),k({kind:"agent",id:Q.id}))}async function N(){if(!w)return;const Q=T.trim(),he=w;if(k(null),he.kind==="main"){const we=Q||"";try{const _e=await e.renameMain(we);S(_e.name)}catch{}}else{if(!Q)return;const we=f.find(_e=>_e.id===he.id)?.name;g(_e=>_e.map(Te=>Te.id===he.id?{...Te,name:Q}:Te));try{await e.renameAgent(he.id,Q)}catch{we!==void 0&&g(_e=>_e.map(Te=>Te.id===he.id?{...Te,name:we}:Te))}}}function $(){k(null)}function X(Q){W(Q),ik(Q)}function Se(Q,he,we){if(Q===he)return;const _e=ua(H.current,Y.current),Te=_e.findIndex(je=>je===Q),Be=_e.findIndex(je=>je===he);if(Te<0||Be<0)return;const Ie=[..._e],[le]=Ie.splice(Te,1);if(!le)return;const Ce=Ie.findIndex(je=>je===he);if(Ce<0)return;const Ne=we==="before"?Ce:Ce+1;if(Ie.splice(Ne,0,le),Bb(Ie,_e))return;const Oe=K.current+1;K.current=Oe,H.current=Ie,b(Ie),e.reorderAgents(Ie).then(je=>{if(K.current===Oe){Y.current=je.agents;const mt=ua(je.serverOrder,je.agents);H.current=mt,g(je.agents),b(mt)}}).catch(async()=>{if(K.current===Oe)try{const je=await e.listAgents();if(K.current===Oe){Y.current=je.agents;const mt=ua(je.serverOrder,je.agents);H.current=mt,g(je.agents),b(mt)}}catch{K.current===Oe&&(H.current=_e,b(_e))}})}function De(Q,he){const we=ua(H.current,Y.current),_e=we.findIndex(Be=>Be===Q),Te=we[_e+he];_e<0||!Te||Se(Q,Te,he<0?"before":"after")}function R(Q,he){he.pointerType==="mouse"&&he.button!==0||(he.stopPropagation(),j.current={sourceId:Q,pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,active:!1,targetId:null,placement:"after"},he.currentTarget.setPointerCapture?.(he.pointerId))}function G(Q){const he=j.current;if(!he||he.pointerId!==Q.pointerId)return;const we=Math.hypot(Q.clientX-he.startX,Q.clientY-he.startY);if(!he.active){if(we<ek)return;he.active=!0,ee(he.sourceId)}const Te=document.elementFromPoint(Q.clientX,Q.clientY)?.closest("[data-server-id]"),Be=Te?.dataset.serverId??null;if(!Te||!Be||Be===he.sourceId){he.targetId=null,ae(null);return}const Ie=Te.getBoundingClientRect(),le=Q.clientY<Ie.top+Ie.height/2?"before":"after";he.targetId=Be,he.placement=le,ae({serverId:Be,placement:le})}function ce(Q){const he=j.current;!he||he.pointerId!==Q.pointerId||(Q.stopPropagation(),Q.currentTarget.releasePointerCapture?.(Q.pointerId),j.current=null,ee(null),ae(null),he.active&&he.targetId&&Se(he.sourceId,he.targetId,he.placement))}function me(Q){const he=j.current;he&&he.pointerId===Q.pointerId&&Q.currentTarget.releasePointerCapture?.(Q.pointerId),j.current=null,ee(null),ae(null)}const xe=y?.trim()||Lb,Ee=w?.kind==="main",Me=A==="stats",qe=nk(f,p),ge=qe.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:qe.map(Q=>{const he=Q.kind==="main",we=he?xe:Q.agent.name,_e=he?pa:Q.id,Te=oe[_e],Be=X0(Te);return m.jsxs("button",{type:"button",className:`server-list-chip${(he?t===null:t===Q.id)?" server-list-chip--active":""}`,onClick:()=>s(he?null:Q.id),"aria-label":we,title:`${we}${Be?` — ${Be}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:Z2(we)}),m.jsx("span",{className:"server-list-chip-pip","data-status":G2(Te)})]},Q.id)})}):m.jsxs("div",{className:`server-list server-list--${A}`,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":A==="list",onClick:()=>X("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":A==="stats",onClick:()=>X("stats"),title:"Show resource usage",children:"Stats"})]}),qe.map(Q=>{const he=Q.kind==="main",we=he?xe:Q.agent.name,_e=he?pa:Q.id,Te=he?t===null:t===Q.id,Be=he?Ee:w?.kind==="agent"&&w.id===Q.id,Ie=c?.({agentId:he?null:Q.id,serverId:Q.id,label:we,active:Te}),le=se?.serverId===Q.id&&I!==Q.id?` server-list-section--drop-target server-list-section--drop-${se.placement}`:"";return m.jsxs("section",{className:`server-list-section${le}`,"aria-label":`${we} server`,children:[m.jsx("div",{className:["server-list-row",I===Q.id?"server-list-row--dragging":"",se?.serverId===Q.id&&I!==Q.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":Q.id,children:Be?m.jsxs(m.Fragment,{children:[ge?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:Ce=>{Ce.preventDefault(),N()},children:m.jsx("input",{ref:L,"aria-label":he?"Rename main server":`Rename ${we}`,value:T,onChange:Ce=>B(Ce.target.value),onBlur:()=>{N()},onKeyDown:Ce=>{Ce.key==="Escape"&&(Ce.preventDefault(),$())},placeholder:he?Lb:void 0})})]}):m.jsxs(m.Fragment,{children:[ge?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":Q.id,title:"Drag to reorder","aria-label":`Reorder ${we}`,"aria-grabbed":I===Q.id,onPointerDown:Ce=>R(Q.id,Ce),onPointerMove:G,onPointerUp:ce,onPointerCancel:me,onKeyDown:Ce=>{(Ce.key==="ArrowUp"||Ce.key==="ArrowDown")&&(Ce.preventDefault(),Ce.stopPropagation(),De(Q.id,Ce.key==="ArrowUp"?-1:1))},onClick:Ce=>Ce.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${Te?" server-list-item--active":""}`,onClick:()=>s(he?null:Q.id),onDoubleClick:Ce=>{Ce.preventDefault(),te(he?"main":{id:Q.id,name:we})},title:rk(we,oe[_e]),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:he?void 0:Q.agent.url,children:we})]}),Me?m.jsx(ok,{entry:oe[_e]}):null]})]})}),Ie?m.jsx("div",{className:"server-list-children",children:Ie}):null]},Q.id)})]})}function ck({api:e}){const[t,s]=v.useState([]),[r,o]=v.useState([]),[c,h]=v.useState(!1),[f,g]=v.useState(null),[p,b]=v.useState(""),[y,S]=v.useState("");async function w(){try{const[L,A,W]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);s(L.devices),o(A.networks),h(W.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{w()},[]);async function k(L){await e.revokeDevice(L),await w()}async function T(L){await e.removeNetwork(L),await w()}async function B(L){L.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:y.trim()}),b(""),S(""),await w()}catch(A){g(A instanceof Error?A.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[f?m.jsx("p",{className:"form-error",children:f}):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(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[L.label,L.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(L.id)},children:"revoke"})]},L.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(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?m.jsx("span",{className:"security-item-meta",children:L.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(L.id)},children:"remove"})]},L.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:p,onChange:L=>b(L.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:L=>S(L.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await w()},children:"Disable 2FA"})]}):null]})}const eg="nterminal.clientDiagnostics.v1",G0=150,uk=24,hk=160;let jb=!1,wo=null;function dk(){jb||typeof window>"u"||(jb=!0,Rn("page.load",{navigation:Ek(),visibility:document.visibilityState,online:navigator.onLine,viewport:Q0(),standalone:xk()}),document.addEventListener("visibilitychange",()=>{Rn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Rn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Rn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Rn("network.online")),window.addEventListener("offline",()=>Rn("network.offline")),window.addEventListener("focus",()=>Rn("window.focus")),window.addEventListener("blur",()=>Rn("window.blur")),window.addEventListener("error",e=>{Rn("runtime.error",{message:e.message,source:kk(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Rn("runtime.unhandledrejection",{reason:Tk(e.reason)})}))}function Rn(e,t={}){const s={at:new Date().toISOString(),event:Sh(e,80),data:Z0({...t,visibility:t.visibility??wk(),online:t.online??Ck(),viewport:t.viewport??Q0()})},r=ma();return r.push(s),gk(r.slice(-G0)),s}function ma(){try{const e=window.localStorage.getItem(eg);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(_k).filter(s=>s!==null).slice(-G0):[]}catch{return[]}}function fk(){try{window.localStorage.removeItem(eg)}catch{}}function pk(){const e=ma();return JSON.stringify({generatedAt:new Date().toISOString(),eventCount:e.length,events:e},null,2)}async function mk(){const e=pk();return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):Dk(e)}async function bh(e,t=fetch){if(wo)return wo;const s=ma(),r={reason:Sh(e,80),events:s},o=JSON.stringify(r);wo=(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 wo}finally{wo=null}}function gk(e){try{window.localStorage.setItem(eg,JSON.stringify(e))}catch{}}function _k(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:Sh(t.event,80),...t.data&&typeof t.data=="object"?{data:Z0(t.data)}:{}}}function Z0(e){const t={};for(const[s,r]of Object.entries(e).slice(0,uk)){const o=Sh(s,64);if(!o||vk(o))continue;const c=yk(r);c!==void 0&&(t[o]=c)}return t}function vk(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function yk(e){if(typeof e=="string")return bk(e,hk);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Sh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function bk(e,t){return Sk(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function Sk(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 wk(){return typeof document>"u"?void 0:document.visibilityState}function Ck(){return typeof navigator>"u"?void 0:navigator.onLine}function Q0(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function xk(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function Ek(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function kk(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 Tk(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function Dk(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 J0="nterminal.notifications.completionEnabled",tg="nterminal.notifications.completionToastEnabled",ig="nterminal.notifications.completionToastDurationSeconds",ng="nterminal.notifications.completionToastPersistent",xp="nterminal:completion-toast-display",Vo=6.5,Ep=2,kp=60;function wh(){return typeof window<"u"&&"Notification"in window}function ew(){try{return window.localStorage.getItem(J0)==="true"}catch{return!1}}function Hb(e){try{window.localStorage.setItem(J0,e?"true":"false")}catch{}}function Sa(){return{enabled:Ak(),durationSeconds:Nk(),persistUntilDismissed:Lk()}}function Rk(e){if(typeof window<"u"){try{window.localStorage.setItem(tg,e?"true":"false")}catch{}rg()}return Sa()}function Pb(e){const t=iw(e);if(typeof window<"u"){try{window.localStorage.setItem(ig,String(t))}catch{}rg()}return Sa()}function Mk(e){if(typeof window<"u"){try{window.localStorage.setItem(ng,e?"true":"false")}catch{}rg()}return Sa()}function tw(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===tg||s.key===ig||s.key===ng)&&e()};return window.addEventListener(xp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(xp,e),window.removeEventListener("storage",t)}}function sg(){return wh()?window.Notification.permission:"unsupported"}function Nk(){if(typeof window>"u")return Vo;try{const e=window.localStorage.getItem(ig);return e===null?Vo:iw(Number(e))}catch{return Vo}}function Ak(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tg)!=="false"}catch{return!0}}function Lk(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ng)==="true"}catch{return!1}}function iw(e){if(!Number.isFinite(e))return Vo;const t=Math.round(e*2)/2;return Math.max(Ep,Math.min(kp,t))}function rg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(xp))}async function Bk(){if(!wh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return sg()}}function Ok(e){if(!wh()||sg()!=="granted"||!ew()||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 zk=1500,ag="nterminal.terminal.fontSize",lg="nterminal.terminal.fontFamily",Tp="nterminal:terminal-font-size",Dp="nterminal:terminal-font-family",Rp=11,Mp=20,_a=14,Qu=[{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:[]}],Sl="meslo";Np(Sl);async function Wf(e=_a,t=Sl){if(typeof document>"u"||!document.fonts)return;const s=rw(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,zk)})])}function nw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return _a;const s=Math.round(t);return Math.max(Rp,Math.min(Mp,s))}function sw(e){return Qu.some(t=>t.id===e)?e:Sl}function Np(e){return rw(e).cssFamily}function rw(e){return Qu.find(t=>t.id===e)??Qu[0]}function Ap(){if(typeof window>"u")return _a;try{const e=window.localStorage.getItem(ag);return e?nw(e):_a}catch{return _a}}function Lp(){if(typeof window>"u")return Sl;try{return sw(window.localStorage.getItem(lg))}catch{return Sl}}function wu(e){const t=nw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ag,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Tp,{detail:t})),t}function jk(e){const t=sw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lg,t)}catch{}return window.dispatchEvent(new CustomEvent(Dp,{detail:t})),t}function aw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===ag&&e()};return window.addEventListener(Tp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Tp,e),window.removeEventListener("storage",t)}}function lw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===lg&&e()};return window.addEventListener(Dp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Dp,e),window.removeEventListener("storage",t)}}const og="nterminal.terminal.showScrollProgress",Bp="nterminal:terminal-scroll-progress";function Op(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(og)!=="false"}catch{return!0}}function Hk(e){if(typeof window<"u"){try{window.localStorage.setItem(og,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Bp,{detail:e}))}return e}function ow(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===og&&e()};return window.addEventListener(Bp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bp,e),window.removeEventListener("storage",t)}}const cg="nterminal.shortcuts.workspace.v1",zp="nterminal:workspace-shortcuts",Jo=[{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}],Ch={"server.previous":Ai("ArrowUp",{ctrlKey:!0}),"server.next":Ai("ArrowDown",{ctrlKey:!0}),"tab.previous":Ai("ArrowLeft",{ctrlKey:!0}),"tab.next":Ai("ArrowRight",{ctrlKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ai("KeyH",{altKey:!0})},Pk={"server.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ai("KeyH",{altKey:!0})};function wa(){const e=hw(Ch);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cg);if(!t)return e;const s=JSON.parse(t);for(const r of Jo){const o=s[r.id];if(Vk(o)){const c=dw(o,r);$k(c,Pk[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Ub(){return JSON.stringify(wa())}function Uk(e,t){const s=wa(),r=Jo.find(o=>o.id===e);return r&&(s[e]=dw(t,r),dg(s)),s}function Ik(e){const t=wa();return t[e]={...Ch[e]},dg(t),t}function Kk(){const e=hw(Ch);return dg(e),e}function ug(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===cg&&e()};return window.addEventListener(zp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zp,e),window.removeEventListener("storage",t)}}function Wk(e,t){const s=mw(e);return!s||Xk(s)||t.indexed&&pw(e)===null||t.requiresPrimaryModifier&&!fw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":s}}function cw(e){const t=wa();for(const s of Jo){const r=t[s.id];if(!(!r||!Yk(e,r))){if(s.indexed){if(r.code!=="Digit")continue;const o=pw(e);if(o!==null)return{id:s.id,index:o};continue}if(mw(e)===r.code)return{id:s.id,index:null}}}return null}function hg(e){return uw(wa()[e])}function uw(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(Gk(e.code)),t.join("+")}const Fk=()=>hg("split.right"),qk=()=>hg("split.down");function Ai(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function hw(e){return Object.fromEntries(Object.entries(e).map(([t,s])=>[t,{...s}]))}function $k(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function dg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(zp))}}function dw(e,t){return t.requiresPrimaryModifier&&!fw(e)?{...Ch[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function fw(e){return e.ctrlKey||e.altKey||e.metaKey}function Vk(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 Yk(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function pw(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 mw(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 Xk(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function Gk(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 Zk="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 Qk(e="nterminal",t=new Date){return{reason:"permission",message:Zk,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function Jk(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 gw=3600*1e3,eT="local",jp=new Set,Br=new Map;let Hr={checking:!1,hasUpdates:!1,lastCheckedAt:null},fg=null,Yo=null,Ju=0,Mr=null;function tT(e){return jp.add(e),()=>{jp.delete(e)}}function Ib(){return Hr}function iT(e){const t=lT();fg=e,pg(),Hp(e,t);const s=()=>{if(document.visibilityState!=="visible"||!Pr(e,t))return;const r=Hr.lastCheckedAt;(r===null||Date.now()-r>=gw)&&Hp(e,t)};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),Pr(e,t)&&aT()}}function nT(e,t){Br.set(e,_w(t)),wl({...Hr,hasUpdates:mg(),lastCheckedAt:Date.now()})}function Ff(e){e===void 0?Br.clear():Br.set(e,!1),wl({...Hr,hasUpdates:mg()})}async function Hp(e,t){if(!Pr(e,t))return;if(Mr&&Mr.api===e&&Mr.runId===t)return Mr.promise;wl({...Hr,checking:!0});const s=sT(e,t).finally(()=>{Mr?.promise===s&&(Mr=null),Pr(e,t)&&(wl({...Hr,checking:!1,lastCheckedAt:Date.now()}),rT(e,t))});return Mr={api:e,runId:t,promise:s},s}async function sT(e,t){try{const s=await e.listAgents();if(!Pr(e,t))return;const r=[{key:eT,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,_w(h))}catch{o.set(c.key,Br.get(c.key)??!1)}})),!Pr(e,t))return;Br.clear();for(const[c,h]of o)Br.set(c,h);wl({...Hr,hasUpdates:mg()})}catch{}}function rT(e,t){Pr(e,t)&&(pg(),Yo=window.setTimeout(()=>{Yo=null,Pr(e,t)&&Hp(e,t)},gw))}function aT(){Ju+=1,pg(),fg=null,Mr=null,Br.clear(),wl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function pg(){Yo!==null&&(window.clearTimeout(Yo),Yo=null)}function lT(){return Ju+=1,Ju}function Pr(e,t){return fg===e&&Ju===t}function _w(e){return e.updateAvailable===!0}function mg(){return Array.from(Br.values()).some(Boolean)}function wl(e){Hr=e;for(const t of Array.from(jp))t()}const oT=e=>new Promise(t=>setTimeout(t,e));function cT({api:e,onAgentRemoved:t}){const[s,r]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,f]=v.useState(!1),[g,p]=v.useState(null),[b,y]=v.useState(!1);function S(U,K){c(Y=>({...Y,[U]:{...Y[U],...K}}))}const w=U=>U.id===null?e.getVersion():e.getAgentVersion(U.id),k=U=>U.id===null?e.checkUpdate():e.checkAgentUpdate(U.id),T=U=>U.id===null?e.runUpdate():e.runAgentUpdate(U.id);v.useEffect(()=>{let U=!1;return e.listAgents().then(K=>{if(U)return;const Y=[{key:"local",id:null,name:"Local (main)"},...K.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];r(Y);for(const H of Y)w(H).then(j=>S(H.key,{version:j,manualUpdate:j.manualUpdate??null})).catch(j=>S(H.key,{error:j instanceof Error?j.message:"unreachable"}))}).catch(()=>{}),()=>{U=!0}},[]);async function B(U){S(U.key,{busy:!0,status:"checking…",error:void 0});try{const K=await k(U);nT(U.key,K),S(U.key,{latestVersion:K.latestVersion,updateAvailable:K.updateAvailable,status:ae(K),...K.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(K){S(U.key,{busy:!1,error:K instanceof Error?K.message:"check failed"})}}async function L(){f(!0),await Promise.all(s.map(U=>B(U))),f(!1)}async function A(U,K){const Y=Date.now()+18e4;for(;Date.now()<Y;){await oT(3e3);try{const H=await w(U);if(K&&H.runningVersion!==K.runningVersion)return H}catch{}}return null}async function W(U){let K=o[U.key]?.version;if(!K)try{K=await w(U),S(U.key,{version:K,manualUpdate:K.manualUpdate??null})}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"version check failed"}),"failed"}S(U.key,{busy:!0,status:"updating…",error:void 0});let Y;try{Y=await T(U)}catch(j){return S(U.key,{busy:!1,error:j instanceof Error?j.message:"update failed"}),"failed"}if(!Y.ok){const j=Y.manualUpdate??(Jk(Y.message)?Qk():null);return j?(S(U.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:j}),"manual"):(S(U.key,{busy:!1,status:void 0,error:Y.message}),"failed")}if(!Y.changed)return S(U.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Ff(U.key),"unchanged";S(U.key,{status:"restarting…"});const H=await A(U,K);return H?(S(U.key,{busy:!1,version:H,updateAvailable:!1,status:"updated",manualUpdate:H.manualUpdate??null}),Ff(U.key),U.id===null&&(y(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(S(U.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function I(U){if(!(U.id===null||!window.confirm([`Delete secondary server "${U.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){S(U.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const Y=await e.uninstallAgent(U.id);r(H=>H.filter(j=>j.key!==U.key)),c(H=>{const j={...H};return delete j[U.key],j}),Ff(U.key),t?.(U.id),p(Y.message)}catch(Y){S(U.key,{busy:!1,status:void 0,error:Y instanceof Error?Y.message:"delete failed"})}}}async function ee(){f(!0),p(null);const U=s.filter(N=>N.id!==null),K=s.find(N=>N.id===null),Y=await Promise.all(U.map(N=>W(N))),H=Y.filter(N=>N==="failed").length;let j=Y.filter(N=>N==="manual").length,te=null;if(K&&(te=await W(K),te==="manual"&&(j+=1),te==="updated")){H>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),f(!1);return}H>0&&j>0?p("Some servers failed and some need manual update. Check each marked row."):H>0?p("Some secondary servers failed to update. Check their rows and retry."):j>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function se(U){return U?U.error?U.error:U.status?U.status:U.manualUpdate?"manual update required":U.version?`v${U.version.version}`:"…":"…"}function ae(U){return U.error?U.error:typeof U.updateAvailable=="boolean"?U.updateAvailable?`latest v${U.latestVersion??"available"}`:"up to date":"unknown"}function oe(U){const K=U?.version;return K?`npm package v${K.runningVersion}`:""}async function ve(U,K){try{await uT(K),S(U,{copiedCommand:!0}),window.setTimeout(()=>S(U,{copiedCommand:!1}),1800)}catch(Y){S(U,{error:Y instanceof Error?Y.message:"copy failed"})}}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{L()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{ee()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,b?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsx("ul",{className:"security-list",children:s.map(U=>{const K=o[U.key],Y=oe(K),H=K?.manualUpdate??null,j=K?.version!==void 0&&K?.updateAvailable!==!1&&!K?.busy&&!h,te=U.id!==null&&!K?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:U.name}),m.jsxs("span",{className:"security-item-meta",children:[Y?`${Y} — `:"",se(K)]})]}),H?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:H.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:H.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(U.key,H.command)},children:K?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{W(U)},disabled:!j,children:K?.busy?"…":"Update"}),U.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{I(U)},disabled:!te,children:"Delete"}):null]})]},U.key)})})]})}async function uT(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const 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 hT({onClose:e,api:t,updateAvailable:s=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??ph(),[t]),[h,f]=v.useState(()=>Ap()),[g,p]=v.useState(()=>Lp()),[b,y]=v.useState(()=>Op()),[S,w]=v.useState(()=>zr()),[k,T]=v.useState(()=>wa()),[B,L]=v.useState(null),[A,W]=v.useState(null),[I,ee]=v.useState("appearance"),[se,ae]=v.useState(()=>ew()),[oe,ve]=v.useState(()=>Sa()),[U,K]=v.useState(()=>sg()),[Y,H]=v.useState([]),[j,te]=v.useState([]),[N,$]=v.useState([]),[X,Se]=v.useState(5*1024*1024),[De,R]=v.useState(!1),[G,ce]=v.useState(null),[me,xe]=v.useState(()=>ma()),[Ee,Me]=v.useState(!1),[qe,ge]=v.useState(null),Q=v.useRef(null),he=v.useRef(null),we=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,diagnostics:null,servers:null}),_e=v.useMemo(()=>new Set(j),[j]),Te=!mT(j,N);v.useEffect(()=>aw(()=>f(Ap())),[]),v.useEffect(()=>lw(()=>p(Lp())),[]),v.useEffect(()=>ow(()=>y(Op())),[]),v.useEffect(()=>qm(()=>w(zr())),[]),v.useEffect(()=>ug(()=>T(wa())),[]),v.useEffect(()=>tw(()=>ve(Sa())),[]),v.useEffect(()=>{const F=()=>xe(ma());F();const $e=window.setInterval(F,1500);return()=>window.clearInterval($e)},[]),v.useEffect(()=>{if(!B)return;const F=Jo.find(ot=>ot.id===B);if(!F)return;const $e=ot=>{if(ot.preventDefault(),ot.stopPropagation(),ot.key==="Escape"){L(null),W(null);return}const wt=Wk(ot,F);if(!wt){W(pT(F));return}T(Uk(B,wt)),L(null),W(null)};return window.addEventListener("keydown",$e,!0),()=>window.removeEventListener("keydown",$e,!0)},[B]),v.useEffect(()=>{let F=!1;return c.listNotificationAssets().then($e=>{F||je($e)}).catch($e=>{F||ce(ul($e))}),()=>{F=!0}},[c]);function Be(F){f(wu(Number(F)))}function Ie(F){ve(Pb(Number(F)))}function le(F){ee(F);const $e=he.current,ot=we.current[F];if(!$e||!ot)return;const wt=Math.max(0,Kb(ot,$e)-12);typeof $e.scrollTo=="function"?$e.scrollTo({top:wt,behavior:"smooth"}):$e.scrollTop=wt}function Ce(){const F=he.current;if(!F)return;if(F.scrollTop+F.clientHeight>=F.scrollHeight-2){ee(Cu[Cu.length-1].id);return}let $e="appearance";const ot=F.scrollTop+Math.min(180,Math.max(48,F.clientHeight*.28));for(const wt of Cu){const li=we.current[wt.id];li&&Kb(li,F)<=ot&&($e=wt.id)}ee($e)}function Ne(F){T(Ik(F)),L(null),W(null)}function Oe(){T(Kk()),L(null),W(null)}function je(F){const $e=F.assets.filter(ot=>ot.enabled).map(ot=>ot.id);H(F.assets),te($e),$($e),Se(F.maxFileBytes),ce(null)}async function mt(){if(se){Hb(!1),ae(!1);return}let F=U;F==="default"&&(F=await Bk(),K(F)),F==="granted"&&(Hb(!0),ae(!0))}async function Xe(F){const $e=F?.[0];if($e){if($e.size>X){ce(`File must be ${qf(X)} or smaller.`),Qt();return}if($e.type!=="video/mp4"&&$e.type!=="video/webm"){ce("Upload an MP4 or WebM video."),Qt();return}R(!0),ce(null);try{await c.uploadNotificationAsset($e),je(await c.listNotificationAssets()),r?.()}catch(ot){ce(ul(ot))}finally{R(!1),Qt()}}}async function st(F){R(!0),ce(null);try{await c.deleteNotificationAsset(F),je(await c.listNotificationAssets()),r?.()}catch($e){ce(ul($e))}finally{R(!1)}}function Qt(){Q.current&&(Q.current.value="")}function sn(F,$e){const ot=new Set(j);if($e?ot.add(F):ot.delete(F),ot.size===0){ce("Keep at least one toast video selected.");return}ce(null),te(Array.from(ot))}async function ki(){if(j.length===0){ce("Keep at least one toast video selected.");return}R(!0),ce(null);try{const F=await c.updateNotificationAssetSelection({enabledAssetIds:j});je(F),r?.()}catch(F){ce(ul(F))}finally{R(!1)}}async function Jt(){ge(null),Me(!0);try{const F=await mk();ge(F?"Diagnostics copied.":"Copy failed in this browser."),xe(ma())}catch(F){ge(ul(F))}finally{Me(!1)}}async function Ti(){ge(null),Me(!0);try{const F=await bh("manual-settings");ge(`Sent ${F.accepted} diagnostic events.`),xe(ma())}catch(F){ge(ul(F))}finally{Me(!1)}}function Gn(){fk(),xe([]),ge("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:F=>F.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Cu.map(F=>m.jsxs("button",{type:"button","data-active":I===F.id?"true":"false","aria-current":I===F.id?"true":void 0,onClick:()=>le(F.id),children:[F.label,F.id==="servers"&&s?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},F.id))}),m.jsxs("div",{ref:he,className:"settings-content",onScroll:Ce,children:[m.jsxs("section",{id:"settings-appearance",ref:F=>{we.current.appearance=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Vu.map(F=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":S===F.id,"data-active":S===F.id?"true":"false",onClick:()=>w(gE(F.id)),style:{"--settings-theme-bg":F.tokens.bg,"--settings-theme-bg-2":F.tokens.bg2,"--settings-theme-sidebar":F.tokens.bgSidebar,"--settings-theme-line":F.tokens.line,"--settings-theme-fg":F.tokens.fg,"--settings-theme-fg-2":F.tokens.fg2,"--settings-theme-accent":F.tokens.accent,"--settings-theme-xterm-bg":F.xterm.background,"--settings-theme-xterm-fg":F.xterm.foreground,"--settings-theme-xterm-selection":F.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:F.label}),m.jsx("small",{children:F.description})]})]},F.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Rp,max:Mp,step:1,value:h,"aria-label":"Terminal font size",onChange:F=>Be(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(wu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Rp,max:Mp,step:1,value:h,"aria-label":"Terminal font size value",onChange:F=>Be(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(wu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(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:F=>p(jk(F.currentTarget.value)),children:Qu.map(F=>m.jsx("option",{value:F.id,children:F.label},F.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:F=>y(Hk(F.currentTarget.checked))}),"Show scroll progress"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:F=>{we.current.shortcuts=F},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick: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."}),A?m.jsx("p",{className:"settings-error",children:A}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Jo.map(F=>{const $e=B===F.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:F.label}),m.jsx("span",{className:"settings-shortcut-group",children:F.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":$e?"true":"false",onClick:()=>{L(F.id),W(null)},children:$e?"Press keys…":uw(k[F.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Ne(F.id),children:"Reset"})]})]},F.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:F=>{we.current.notifications=F},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),wh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:se&&U==="granted",onChange:()=>{mt()},disabled:U==="denied"}),"System notification when page is hidden"]}),U==="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:F=>ve(Rk(F.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:oe.persistUntilDismissed?"Until closed":`${oe.durationSeconds}s`}),m.jsx("input",{type:"range",min:Ep,max:kp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:F=>Ie(F.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Ep,max:kp,step:.5,value:oe.durationSeconds,disabled:!oe.enabled||oe.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:F=>Ie(F.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!oe.enabled||oe.persistUntilDismissed,onClick:()=>ve(Pb(Vo)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:oe.persistUntilDismissed,disabled:!oe.enabled,onChange:F=>ve(Mk(F.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[qf(X)," max"]})]}),m.jsx("input",{ref:Q,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:F=>{Xe(F.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:De,onClick:()=>Q.current?.click(),children:"Upload video"}),G?m.jsx("p",{className:"settings-error",children:G}):null,Y.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:Y.map(F=>m.jsxs("li",{"data-enabled":_e.has(F.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:_e.has(F.id),disabled:De,"aria-label":`Use ${F.filename}`,onChange:$e=>sn(F.id,$e.currentTarget.checked)}),m.jsx("video",{src:F.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:F.filename}),m.jsx("small",{children:F.source==="built-in"?"Built-in":qf(F.size)})]})]}),F.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:De,"aria-label":`Delete ${F.filename}`,onClick:()=>{st(F.id)},children:"x"}):null]},F.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:De||Y.length===0||!Te,onClick:()=>{ki()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:F=>{we.current.security=F},className:"settings-section-group",children:m.jsx(ck,{api:c})}),m.jsxs("section",{id:"settings-diagnostics",ref:F=>{we.current.diagnostics=F},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:me.length})]}),m.jsxs("div",{className:"settings-diagnostics-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",disabled:Ee||me.length===0,onClick:()=>{Jt()},children:"Copy"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:Ee||me.length===0,onClick:()=>{Ti()},children:"Send"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:Ee||me.length===0,onClick:Gn,children:"Clear"})]}),qe?m.jsx("p",{className:"settings-status",children:qe}):null,me.length>0?m.jsx("ol",{className:"settings-diagnostics-list","aria-label":"Recent diagnostics",children:me.slice(-8).reverse().map((F,$e)=>m.jsxs("li",{children:[m.jsx("span",{children:dT(F.at)}),m.jsx("strong",{children:F.event}),F.data?m.jsx("code",{children:fT(F.data)}):null]},`${F.at}:${F.event}:${$e}`))}):m.jsx("p",{className:"muted",children:"No diagnostics recorded yet."})]}),m.jsx("div",{id:"settings-servers",ref:F=>{we.current.servers=F},className:"settings-section-group",children:m.jsx(cT,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Kb(e,t){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();return s.top-r.top+t.scrollTop}function qf(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 ul(e){return e instanceof Error?e.message:"Request failed."}function dT(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function fT(e){return Object.entries(e).slice(0,5).map(([t,s])=>`${t}=${String(s)}`).join(" ")}function pT(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 mT(e,t){if(e.length!==t.length)return!1;const s=new Set(t);return e.every(r=>s.has(r))}class la extends Error{constructor(t,s){super(s),this.status=t,this.name="UploadClientError"}status}function gT(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 f=()=>{e.signal?.removeEventListener("abort",b)},g=y=>{h||(h=!0,f(),o(y))},p=y=>{h||(h=!0,f(),c(y))},b=()=>{t.abort(),p(new la(0,"Upload aborted."))};if(e.signal?.aborted){p(new la(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{p(new la(t.status,"Invalid upload response."))}return}p(new la(t.status,_T(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new la(0,"Upload failed.")),t.onabort=()=>p(new la(0,"Upload aborted.")),t.ontimeout=()=>p(new la(0,"Upload timed out.")),t.send(s)})}function _T(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 vT="modulepreload",yT=function(e){return"/"+e},Wb={},gg=function(t,s,r){let o=Promise.resolve();if(s&&s.length>0){let g=function(p){return Promise.all(p.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]"),f=h?.nonce||h?.getAttribute("nonce");o=g(s.map(p=>{if(p=yT(p),p in Wb)return;Wb[p]=!0;const b=p.endsWith(".css"),y=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${y}`))return;const S=document.createElement("link");if(S.rel=b?"stylesheet":vT,b||(S.as="script"),S.crossOrigin="",S.href=p,f&&S.setAttribute("nonce",f),document.head.appendChild(S),b)return new Promise((w,k)=>{S.addEventListener("load",w),S.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(h){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=h,window.dispatchEvent(f),!f.defaultPrevented)throw h}return o.then(h=>{for(const f of h||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},bT=v.lazy(()=>gg(()=>import("./MarkdownPreview-3F25Ss3Q.js"),__vite__mapDeps([0,1])));function ST({api:e,activeTerminalId:t,activeTerminalCwd:s,workspaceRootPath:r=null,onOpenFile:o}){const[c,h]=v.useState(null),[f,g]=v.useState(""),[p,b]=v.useState({}),[y,S]=v.useState(()=>new Set),[w,k]=v.useState(null),[T,B]=v.useState({type:"empty"}),[L,A]=v.useState("idle"),[W,I]=v.useState(null),ee=v.useRef(null),se=v.useRef(null),ae=v.useRef(!1),oe=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const U=ve.current,K=r?CT(r):t?Fb(t,s):null,Y=c?[c.rootPath,f].filter(Boolean).join("/"):"",H=w?.path??null;v.useEffect(()=>(ae.current=!0,()=>{ae.current=!1,oe.current+=1,he()}),[]),v.useEffect(()=>{ve.current=t,se.current=null,j(K)},[e]),v.useEffect(()=>{r&&K!==se.current&&te(r,K)},[r,K]),v.useEffect(()=>{if(r||!U||t!==U)return;const le=Fb(U,s);le!==se.current&&N(U,le)},[U,t,s,r]);async function j(le=K){if(r){await te(r,le);return}await N(t,le)}async function te(le,Ce=K){const Ne=we();if(se.current=Ce,he(),h(null),g(""),b({}),S(new Set),k(null),B({type:"empty"}),I(null),!le){A("idle");return}A("loading");try{const Oe=await e.createFileRoot({path:le});if(!_e(Ne))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const je=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!_e(Ne))return;Se(je),A("idle")}catch(Oe){_e(Ne)&&(I(Fs(Oe)),A("idle"))}}async function N(le,Ce=K){const Ne=we();if(se.current=Ce,he(),h(null),g(""),b({}),S(new Set),k(null),B({type:"empty"}),I(null),!le){A("idle");return}A("loading");try{const Oe=await e.createFileRoot({terminalId:le});if(!_e(Ne))return;h({rootToken:Oe.rootToken,rootPath:Oe.rootPath});const je=await e.listFiles({rootToken:Oe.rootToken,path:""});if(!_e(Ne))return;Se(je),A("idle")}catch(Oe){if(await Te(Oe,Ne))return;_e(Ne)&&(I(Fs(Oe)),A("idle"))}}async function $(le=f,Ce=c){if(!Ce)return;const Ne=we();A("loading"),I(null);try{const Oe=await e.listFiles({rootToken:Ce.rootToken,path:le});if(!_e(Ne))return;Se(Oe),A("idle")}catch(Oe){if(await Te(Oe,Ne))return;_e(Ne)&&(I(Fs(Oe)),A("idle"))}}async function X(){if(r){await te(r,K);return}ve.current=t,await N(t,K)}function Se(le){b(Ce=>({...Ce,[le.path]:xT(le.entries)}))}async function De(le){if(!(!$f(le)||!c)){if(k(le),I(null),le.kind==="directory"){g(le.path),Q(),await G(le);return}if(g(oa(le.path)),le.editable){await me(le);return}le.previewKind!=="none"&&await Ee(le,le.previewKind)}}async function R(le){if(!(!$f(le)||!c)){if(k(le),I(null),le.kind==="directory"){g(le.path),Q(),await G(le);return}if(g(oa(le.path)),le.editable){await xe(le);return}le.previewKind!=="none"&&await Ee(le,le.previewKind)}}async function G(le){if(y.has(le.path)){S(Ce=>{const Ne=new Set(Ce);return Ne.delete(le.path),Ne});return}S(Ce=>new Set(Ce).add(le.path)),await $(le.path)}function ce(le,Ce){le.key==="Enter"&&(le.preventDefault(),R(Ce))}async function me(le){if(!c)return;const Ce=we();A("loading"),he();try{const Ne=await e.readFile({rootToken:c.rootToken,path:le.path});if(!_e(Ce))return;B({type:"text-preview",file:le,read:Ne}),A("idle")}catch(Ne){if(await Te(Ne,Ce))return;_e(Ce)&&(I(Fs(Ne)),A("idle"))}}async function xe(le){if(!c)return;const Ce=we();A("loading");try{await o({rootToken:c.rootToken,path:le.path,...t?{terminalId:t}:{}}),_e(Ce)&&A("idle")}catch(Ne){if(await Te(Ne,Ce))return;_e(Ce)&&(I(Fs(Ne)),A("idle"))}}async function Ee(le,Ce){if(!c)return;const Ne=we();A("loading"),he();try{const Oe=await e.previewFile({rootToken:c.rootToken,path:le.path});if(!_e(Ne))return;const je=URL.createObjectURL(Oe);if(!_e(Ne)){URL.revokeObjectURL(je);return}ee.current=je,B({type:"preview",file:le,previewKind:Ce,url:je}),A("idle")}catch(Oe){if(await Te(Oe,Ne))return;_e(Ne)&&(I(Fs(Oe)),A("idle"))}}async function Me(le){if(!c)return;const Ce=le==="file"?"New file":"New folder",Ne=window.prompt(Ce,""),Oe=w?w.kind==="directory"?w.path:oa(w.path):f,je=qb(Ne,Oe);if(je){I(null);try{const mt=await e.createFileEntry({rootToken:c.rootToken,path:je,kind:le});k(mt.entry),await $(Oe)}catch(mt){if(await Te(mt))return;I(Fs(mt))}}}async function qe(){if(!c||!w)return;const le=window.prompt("Move selected entry",w.path),Ce=qb(le,"");if(!Ce||Ce===w.path)return;const Ne=oa(w.path),Oe=oa(Ce);I(null);try{const je=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:w.path,destinationPath:Ce});k(je.entry),g(je.entry.kind==="directory"?je.entry.path:oa(je.entry.path)),Q(),await $(Ne),Oe!==Ne&&await $(Oe)}catch(je){if(await Te(je))return;I(Fs(je))}}async function ge(){if(!c||!w)return;const le=w.path,Ce=oa(le);I(null);try{const Ne=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:w.path}),Oe=Ne.descendantCount>0?` and ${Ne.descendantCount} nested item${Ne.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Ne.path}${Oe}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:w.path,previewToken:Ne.previewToken}),k(null),g(Ce),S(je=>{const mt=new Set(je);for(const Xe of je)(Xe===le||Xe.startsWith(`${le}/`))&&mt.delete(Xe);return mt}),Q(),await $(Ce)}catch(Ne){if(await Te(Ne))return;I(Fs(Ne))}}function Q(){oe.current+=1,he(),B({type:"empty"})}function he(){ee.current&&(URL.revokeObjectURL(ee.current),ee.current=null)}function we(){return oe.current+=1,oe.current}function _e(le){return ae.current&&le===oe.current}async function Te(le,Ce){return ET(le)?(Ce!==void 0&&!_e(Ce)||await j(K),!0):!1}function Be(le,Ce){const Ne=$f(le),Oe=le.kind==="directory"&&y.has(le.path),je=p[le.path]??[],mt={"--file-tree-depth":Ce};return m.jsxs(xi.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":le.kind,"data-expanded":Oe,"data-active":H===le.path,disabled:!Ne,style:mt,"aria-expanded":le.kind==="directory"?Oe:void 0,"aria-label":`${le.kind==="directory"?"Open folder":"Open file"} ${le.name}`,title:le.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{De(le)},onDoubleClick:()=>{R(le)},onKeyDown:Xe=>ce(Xe,le),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:le.kind==="directory"?Oe?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:le.name}),m.jsx("small",{children:wT(le)})]}),Oe?m.jsx("div",{className:"file-tree-children",role:"group",children:je.map(Xe=>Be(Xe,Ce+1))}):null]},le.path)}const Ie=p[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:Y,children:Y||"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:()=>{X()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Me("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Me("directory")},children:"▣"})]})]}),W?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:W}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":Y?`Files in ${Y}`:"Files",children:Ie.map(le=>Be(le,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:w?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{qe()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{ge()},children:"Delete"})]})]}),L==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&L!=="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(bT,{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 $f(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function wT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Fb(e,t){return`${e}\0${t??""}`}function CT(e){return`workspace\0${e}`}function xT(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 oa(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function qb(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 Fs(e){return e instanceof Error?e.message:"Request failed"}function ET(e){return e instanceof os&&e.status===409&&e.message==="terminal_cwd_changed"}const kT=v.lazy(()=>gg(()=>import("./MarkdownPreview-3F25Ss3Q.js"),__vite__mapDeps([0,1])));function $b({api:e,editor:t,canClose:s,onClose:r}){const[o,c]=v.useState(t.read),[h,f]=v.useState(t.read.content),[g,p]=v.useState("idle"),[b,y]=v.useState(null),[S,w]=v.useState(!1),[k,T]=v.useState("edit"),B=v.useRef(t),L=v.useRef(t.read),A=v.useRef(t.read.content),W=v.useRef(!1),I=v.useRef(!1),ee=v.useRef(0),se=h!==o.content&&g!=="saving"&&!S;v.useEffect(()=>(I.current=!0,()=>{I.current=!1,ee.current+=1}),[]),v.useEffect(()=>{ee.current+=1,W.current=!1,B.current=t,L.current=t.read,A.current=t.read.content,c(t.read),f(t.read.content),p("idle"),y(null),w(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{B.current=t},[t]),v.useEffect(()=>{L.current=o},[o]),v.useEffect(()=>{A.current=h},[h]),v.useEffect(()=>{if(h===o.content||S)return;const K=window.setInterval(()=>{!W.current&&A.current!==L.current.content&&ae()},1e3);return()=>window.clearInterval(K)},[h===o.content,S,t.id]);async function ae(){if(W.current)return;const K=A.current,Y=L.current;if(K===Y.content)return;const H=B.current,j=ee.current;W.current=!0,p("saving"),y(null),w(!1);try{const te=await e.writeFile({rootToken:H.rootToken,path:H.path,content:K,expectedVersion:Y.version});if(!I.current||j!==ee.current)return;const N={...Y,content:K,version:te.version};L.current=N,c(N),p(A.current===K?"saved":"idle")}catch(te){if(!I.current||j!==ee.current)return;if(te instanceof os&&te.status===409){w(!0),p("idle");return}y(TT(te)),p("idle")}finally{j===ee.current&&(W.current=!1)}}const oe=g==="saving"?"saving":g==="saved"?"saved":o.language,ve=o.language==="markdown",U=ve&&k==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:oe}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!se,onClick:()=>{ae()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${U?"Edit":"Preview"} ${t.title}`,onClick:()=>T(K=>K==="preview"?"edit":"preview"),children:U?"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,S?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,U?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(kT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:K=>{const Y=K.target.value;A.current=Y,f(Y),p("idle"),y(null),w(!1)}})]})}function TT(e){return e instanceof Error?e.message:"Request failed"}var DT=2,RT=1,MT=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"))},f=h.top+h.bottom,g=h.right+h.left,p=r-f,b=o-g-t;return{cols:Math.max(DT,Math.floor(b/e.css.cell.width)),rows:Math.max(RT,Math.floor(p/e.css.cell.height))}}};var vw=Object.defineProperty,NT=Object.getOwnPropertyDescriptor,AT=(e,t)=>{for(var s in t)vw(e,s,{get:t[s],enumerable:!0})},Zt=(e,t,s,r)=>{for(var o=r>1?void 0:r?NT(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&&vw(t,s,o),o},Re=(e,t)=>(s,r)=>t(s,r,e),Vb="Terminal input",Pp={get:()=>Vb,set:e=>Vb=e},Yb="Too much output to announce, navigate to rows manually to read",Up={get:()=>Yb,set:e=>Yb=e};function LT(e){return e.replace(/\r?\n/g,"\r")}function BT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function OT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function zT(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");yw(o,t,s,r)}}function yw(e,t,s,r){e=LT(e),e=BT(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function bw(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 Xb(e,t,s,r,o){bw(e,t,s),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ar(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xh(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 jT=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 f=e.charCodeAt(c);56320<=f&&f<=57343?t[r++]=(h-55296)*1024+f-56320+65536:(t[r++]=h,t[r++]=f);continue}h!==65279&&(t[r++]=h)}return r}},HT=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,f,g=0,p=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let k=0,T;for(;(T=this.interim[++k]&63)&&k<4;)w<<=6,w|=T;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=B-k;for(;p<L;){if(p>=s)return 0;if(T=e[p++],(T&192)!==128){p--,S=!0;break}else this.interim[k++]=T,w<<=6,w|=T&63}S||(B===2?w<128?p--:t[r++]=w:B===3?w<2048||w>=55296&&w<=57343||w===65279||(t[r++]=w):w<65536||w>1114111||(t[r++]=w)),this.interim.fill(0)}let b=s-4,y=p;for(;y<s;){for(;y<b&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((h=e[y+2])&128)&&!((f=e[y+3])&128);)t[r++]=o,t[r++]=c,t[r++]=h,t[r++]=f,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(f=e[y++],(f&192)!==128){y--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|f&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},Sw="",Lr=" ",hc=class ww{constructor(){this.fg=0,this.bg=0,this.extended=new eh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new ww;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},eh=class Cw{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 Cw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xn=class xw extends hc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new eh,this.combinedData=""}static fromCharData(t){let s=new xw;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?Ar(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()]}},Gb="di$target",Ip="di$dependencies",Vf=new Map;function PT(e){return e[Ip]||[]}function Hi(e){if(Vf.has(e))return Vf.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");UT(t,s,o)};return t._id=e,Vf.set(e,t),t}function UT(e,t,s){t[Gb]===t?t[Ip].push({id:e,index:s}):(t[Ip]=[{id:e,index:s}],t[Gb]=t)}var tn=Hi("BufferService"),Ew=Hi("CoreMouseService"),ka=Hi("CoreService"),IT=Hi("CharsetService"),_g=Hi("InstantiationService"),kw=Hi("LogService"),nn=Hi("OptionsService"),Tw=Hi("OscLinkService"),KT=Hi("UnicodeService"),dc=Hi("DecorationService"),Kp=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(),f=-1,g=-1,p=!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,f=c.extended.urlId;continue}else p=c.extended.urlId!==f;else g!==-1&&(p=!0);if(p||g!==-1&&b===h-1){let y=this._oscLinkService.getLinkData(f)?.uri;if(y){let S={start:{x:g+1,y:e},end:{x:b+(!p&&b===h-1?1:0),y:e}},w=!1;if(!o?.allowNonHttpProtocols)try{let k=new URL(y);["http:","https:"].includes(k.protocol)||(w=!0)}catch{w=!0}w||r.push({text:y,range:S,activate:(k,T)=>o?o.activate(k,T,S):WT(k,T),hover:(k,T)=>o?.hover?.(k,T,S),leave:(k,T)=>o?.leave?.(k,T,S)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=b,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};Kp=Zt([Re(0,tn),Re(1,nn),Re(2,Tw)],Kp);function WT(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 Eh=Hi("CharSizeService"),Gs=Hi("CoreBrowserService"),vg=Hi("MouseService"),Zs=Hi("RenderService"),FT=Hi("SelectionService"),Dw=Hi("CharacterJoinerService"),Rl=Hi("ThemeService"),Rw=Hi("LinkProviderService"),qT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Zb.isErrorNoTelemetry(e)?new Zb(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)}},$T=new qT;function Ou(e){VT(e)||$T.onUnexpectedError(e)}var Wp="Canceled";function VT(e){return e instanceof YT?!0:e instanceof Error&&e.name===Wp&&e.message===Wp}var YT=class extends Error{constructor(){super(Wp),this.name=this.message}};function XT(e){return new Error(`Illegal argument: ${e}`)}var Zb=class Fp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Fp)return t;let s=new Fp;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},qp=class Mw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Mw.prototype)}};function Tn(e,t=0){return e[e.length-(1+t)]}var GT;(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})(GT||={});function ZT(e,t){let s=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(s,arguments))),o}}var Nw;(e=>{function t(I){return I&&typeof I=="object"&&typeof I[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*o(I){yield I}e.single=o;function c(I){return t(I)?I:o(I)}e.wrap=c;function h(I){return I||s}e.from=h;function*f(I){for(let ee=I.length-1;ee>=0;ee--)yield I[ee]}e.reverse=f;function g(I){return!I||I[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(I){return I[Symbol.iterator]().next().value}e.first=p;function b(I,ee){let se=0;for(let ae of I)if(ee(ae,se++))return!0;return!1}e.some=b;function y(I,ee){for(let se of I)if(ee(se))return se}e.find=y;function*S(I,ee){for(let se of I)ee(se)&&(yield se)}e.filter=S;function*w(I,ee){let se=0;for(let ae of I)yield ee(ae,se++)}e.map=w;function*k(I,ee){let se=0;for(let ae of I)yield*ee(ae,se++)}e.flatMap=k;function*T(...I){for(let ee of I)yield*ee}e.concat=T;function B(I,ee,se){let ae=se;for(let oe of I)ae=ee(ae,oe);return ae}e.reduce=B;function*L(I,ee,se=I.length){for(ee<0&&(ee+=I.length),se<0?se+=I.length:se>I.length&&(se=I.length);ee<se;ee++)yield I[ee]}e.slice=L;function A(I,ee=Number.POSITIVE_INFINITY){let se=[];if(ee===0)return[se,I];let ae=I[Symbol.iterator]();for(let oe=0;oe<ee;oe++){let ve=ae.next();if(ve.done)return[se,e.empty()];se.push(ve.value)}return[se,{[Symbol.iterator](){return ae}}]}e.consume=A;async function W(I){let ee=[];for await(let se of I)ee.push(se);return Promise.resolve(ee)}e.asyncToArray=W})(Nw||={});function Ca(e){if(Nw.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 QT(...e){return It(()=>Ca(e))}function It(e){return{dispose:ZT(()=>{e()})}}var Aw=class Lw{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{Ca(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?Lw.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)}};Aw.DISABLE_DISPOSED_WARNING=!1;var Or=Aw,tt=class{constructor(){this._store=new Or,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)}};tt.None=Object.freeze({dispose(){}});var Cl=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}},Ys=typeof window=="object"?window:globalThis,$p=class Vp{constructor(t){this.element=t,this.next=Vp.Undefined,this.prev=Vp.Undefined}};$p.Undefined=new $p(void 0);var Wt=$p,Qb=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}},JT=globalThis.performance&&typeof globalThis.performance.now=="function",eD=class Bw{static create(t){return new Bw(t)}constructor(t){this._now=JT&&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}},qi;(e=>{e.None=()=>tt.None;function t(Y,H){return y(Y,()=>{},0,void 0,!0,void 0,H)}e.defer=t;function s(Y){return(H,j=null,te)=>{let N=!1,$;return $=Y(X=>{if(!N)return $?$.dispose():N=!0,H.call(j,X)},null,te),N&&$.dispose(),$}}e.once=s;function r(Y,H,j){return p((te,N=null,$)=>Y(X=>te.call(N,H(X)),null,$),j)}e.map=r;function o(Y,H,j){return p((te,N=null,$)=>Y(X=>{H(X),te.call(N,X)},null,$),j)}e.forEach=o;function c(Y,H,j){return p((te,N=null,$)=>Y(X=>H(X)&&te.call(N,X),null,$),j)}e.filter=c;function h(Y){return Y}e.signal=h;function f(...Y){return(H,j=null,te)=>{let N=QT(...Y.map($=>$(X=>H.call(j,X))));return b(N,te)}}e.any=f;function g(Y,H,j,te){let N=j;return r(Y,$=>(N=H(N,$),N),te)}e.reduce=g;function p(Y,H){let j,te={onWillAddFirstListener(){j=Y(N.fire,N)},onDidRemoveLastListener(){j?.dispose()}},N=new ke(te);return H?.add(N),N.event}function b(Y,H){return H instanceof Array?H.push(Y):H&&H.add(Y),Y}function y(Y,H,j=100,te=!1,N=!1,$,X){let Se,De,R,G=0,ce,me={leakWarningThreshold:$,onWillAddFirstListener(){Se=Y(Ee=>{G++,De=H(De,Ee),te&&!R&&(xe.fire(De),De=void 0),ce=()=>{let Me=De;De=void 0,R=void 0,(!te||G>1)&&xe.fire(Me),G=0},typeof j=="number"?(clearTimeout(R),R=setTimeout(ce,j)):R===void 0&&(R=0,queueMicrotask(ce))})},onWillRemoveListener(){N&&G>0&&ce?.()},onDidRemoveLastListener(){ce=void 0,Se.dispose()}},xe=new ke(me);return X?.add(xe),xe.event}e.debounce=y;function S(Y,H=0,j){return e.debounce(Y,(te,N)=>te?(te.push(N),te):[N],H,void 0,!0,void 0,j)}e.accumulate=S;function w(Y,H=(te,N)=>te===N,j){let te=!0,N;return c(Y,$=>{let X=te||!H($,N);return te=!1,N=$,X},j)}e.latch=w;function k(Y,H,j){return[e.filter(Y,H,j),e.filter(Y,te=>!H(te),j)]}e.split=k;function T(Y,H=!1,j=[],te){let N=j.slice(),$=Y(De=>{N?N.push(De):Se.fire(De)});te&&te.add($);let X=()=>{N?.forEach(De=>Se.fire(De)),N=null},Se=new ke({onWillAddFirstListener(){$||($=Y(De=>Se.fire(De)),te&&te.add($))},onDidAddFirstListener(){N&&(H?setTimeout(X):X())},onDidRemoveLastListener(){$&&$.dispose(),$=null}});return te&&te.add(Se),Se.event}e.buffer=T;function B(Y,H){return(j,te,N)=>{let $=H(new A);return Y(function(X){let Se=$.evaluate(X);Se!==L&&j.call(te,Se)},void 0,N)}}e.chain=B;let L=Symbol("HaltChainable");class A{constructor(){this.steps=[]}map(H){return this.steps.push(H),this}forEach(H){return this.steps.push(j=>(H(j),j)),this}filter(H){return this.steps.push(j=>H(j)?j:L),this}reduce(H,j){let te=j;return this.steps.push(N=>(te=H(te,N),te)),this}latch(H=(j,te)=>j===te){let j=!0,te;return this.steps.push(N=>{let $=j||!H(N,te);return j=!1,te=N,$?N:L}),this}evaluate(H){for(let j of this.steps)if(H=j(H),H===L)break;return H}}function W(Y,H,j=te=>te){let te=(...Se)=>X.fire(j(...Se)),N=()=>Y.on(H,te),$=()=>Y.removeListener(H,te),X=new ke({onWillAddFirstListener:N,onDidRemoveLastListener:$});return X.event}e.fromNodeEventEmitter=W;function I(Y,H,j=te=>te){let te=(...Se)=>X.fire(j(...Se)),N=()=>Y.addEventListener(H,te),$=()=>Y.removeEventListener(H,te),X=new ke({onWillAddFirstListener:N,onDidRemoveLastListener:$});return X.event}e.fromDOMEventEmitter=I;function ee(Y){return new Promise(H=>s(Y)(H))}e.toPromise=ee;function se(Y){let H=new ke;return Y.then(j=>{H.fire(j)},()=>{H.fire(void 0)}).finally(()=>{H.dispose()}),H.event}e.fromPromise=se;function ae(Y,H){return Y(j=>H.fire(j))}e.forward=ae;function oe(Y,H,j){return H(j),Y(te=>H(te))}e.runAndSubscribe=oe;class ve{constructor(H,j){this._observable=H,this._counter=0,this._hasChanged=!1;let te={onWillAddFirstListener:()=>{H.addObserver(this)},onDidRemoveLastListener:()=>{H.removeObserver(this)}};this.emitter=new ke(te),j&&j.add(this.emitter)}beginUpdate(H){this._counter++}handlePossibleChange(H){}handleChange(H,j){this._hasChanged=!0}endUpdate(H){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(Y,H){return new ve(Y,H).emitter.event}e.fromObservable=U;function K(Y){return(H,j,te)=>{let N=0,$=!1,X={beginUpdate(){N++},endUpdate(){N--,N===0&&(Y.reportChanges(),$&&($=!1,H.call(j)))},handlePossibleChange(){},handleChange(){$=!0}};Y.addObserver(X),Y.reportChanges();let Se={dispose(){Y.removeObserver(X)}};return te instanceof Or?te.add(Se):Array.isArray(te)&&te.push(Se),Se}}e.fromObservableLight=K})(qi||={});var Yp=class Xp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Xp._idPool++}`,Xp.all.add(this)}start(t){this._stopWatch=new eD,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}}};Yp.all=new Set,Yp._idPool=0;var tD=Yp,iD=-1,Ow=class zw{constructor(t,s,r=(zw._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(),f=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${h}):`;console.warn(f),console.warn(c);let g=new rD(f,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}};Ow._idPool=1;var nD=Ow,sD=class jw{constructor(t){this.value=t}static create(){let t=new Error;return new jw(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},rD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},aD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},lD=0,Yf=class{constructor(e){this.value=e,this.id=lD++}},oD=2,cD,ke=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new nD(e?.onListenerError??Ou,this._options?.leakWarningThreshold??iD):void 0,this._perfMon=this._options?._profName?new tD(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 f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new aD(`${h}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||Ou)(g),tt.None}if(this._disposed)return tt.None;t&&(e=e.bind(t));let r=new Yf(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=sD.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Yf?(this._deliveryQueue??=new uD,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=It(()=>{o?.(),this._removeListener(r)});return s instanceof Or?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*oD<=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 Yf)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}},uD=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}},Gp=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}};Gp.INSTANCE=new Gp;var yg=Gp;function hD(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}yg.INSTANCE.onDidChangeZoomLevel;function dD(e){return yg.INSTANCE.getZoomFactor(e)}yg.INSTANCE.onDidChangeFullscreen;var Ml=typeof navigator=="object"?navigator.userAgent:"",Zp=Ml.indexOf("Firefox")>=0,fD=Ml.indexOf("AppleWebKit")>=0,bg=Ml.indexOf("Chrome")>=0,pD=!bg&&Ml.indexOf("Safari")>=0;Ml.indexOf("Electron/")>=0;Ml.indexOf("Android")>=0;var Xf=!1;if(typeof Ys.matchMedia=="function"){let e=Ys.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ys.matchMedia("(display-mode: fullscreen)");Xf=e.matches,hD(Ys,e,({matches:s})=>{Xf&&t.matches||(Xf=s)})}var pl="en",Qp=!1,Jp=!1,zu=!1,Hw=!1,xu,ju=pl,Jb=pl,mD,$s,va=globalThis,Mn;typeof va.vscode<"u"&&typeof va.vscode.process<"u"?Mn=va.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Mn=process);var gD=typeof Mn?.versions?.electron=="string",_D=gD&&Mn?.type==="renderer";if(typeof Mn=="object"){Qp=Mn.platform==="win32",Jp=Mn.platform==="darwin",zu=Mn.platform==="linux",zu&&Mn.env.SNAP&&Mn.env.SNAP_REVISION,Mn.env.CI||Mn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xu=pl,ju=pl;let e=Mn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);xu=t.userLocale,Jb=t.osLocale,ju=t.resolvedLanguage||pl,mD=t.languagePack?.translationsConfigFile}catch{}Hw=!0}else typeof navigator=="object"&&!_D?($s=navigator.userAgent,Qp=$s.indexOf("Windows")>=0,Jp=$s.indexOf("Macintosh")>=0,($s.indexOf("Macintosh")>=0||$s.indexOf("iPad")>=0||$s.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zu=$s.indexOf("Linux")>=0,$s?.indexOf("Mobi")>=0,ju=globalThis._VSCODE_NLS_LANGUAGE||pl,xu=navigator.language.toLowerCase(),Jb=xu):console.error("Unable to resolve platform.");var Pw=Qp,Cs=Jp,vD=zu,eS=Hw,xs=$s,Er=ju,yD;(e=>{function t(){return Er}e.value=t;function s(){return Er.length===2?Er==="en":Er.length>=3?Er[0]==="e"&&Er[1]==="n"&&Er[2]==="-":!1}e.isDefaultVariant=s;function r(){return Er==="en"}e.isDefault=r})(yD||={});var bD=typeof va.postMessage=="function"&&!va.importScripts;(()=>{if(bD){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 SD=!!(xs&&xs.indexOf("Chrome")>=0);xs&&xs.indexOf("Firefox")>=0;!SD&&xs&&xs.indexOf("Safari")>=0;xs&&xs.indexOf("Edg/")>=0;xs&&xs.indexOf("Android")>=0;var hl=typeof navigator=="object"?navigator:{};eS||document.queryCommandSupported&&document.queryCommandSupported("copy")||hl&&hl.clipboard&&hl.clipboard.writeText,eS||hl&&hl.clipboard&&hl.clipboard.readText;var Sg=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}},Gf=new Sg,tS=new Sg,iS=new Sg,wD=new Array(230),Uw;(e=>{function t(f){return Gf.keyCodeToStr(f)}e.toString=t;function s(f){return Gf.strToKeyCode(f)}e.fromString=s;function r(f){return tS.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return iS.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return tS.strToKeyCode(f)||iS.strToKeyCode(f)}e.fromUserSettings=c;function h(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Gf.keyCodeToStr(f)}e.toElectronAccelerator=h})(Uw||={});var CD=class Iw{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 Iw&&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 xD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},xD=class{constructor(e){if(e.length===0)throw XT("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 ED(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Uw.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Zp)switch(t){case 59:return 85;case 60:if(vD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Cs)return 57;break}else if(fD&&(Cs&&t===93||!Cs&&t===92))return 57;return wD[t]||0}var kD=Cs?256:2048,TD=512,DD=1024,RD=Cs?2048:256,nS=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=ED(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|=kD),this.altKey&&(t|=TD),this.shiftKey&&(t|=DD),this.metaKey&&(t|=RD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new CD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},sS=new WeakMap;function MD(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 ND=class{static getSameOriginWindowChain(e){let t=sS.get(e);if(!t){t=[],sS.set(e,t);let s=e,r;do r=MD(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 f=c.iframeElement.getBoundingClientRect();s+=f.top,r+=f.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=ND.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},rS=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(bg){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 f=e;f.deltaMode===f.DOM_DELTA_LINE?Zp&&!Cs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")pD&&Pw?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 f=e;f.deltaMode===f.DOM_DELTA_LINE?Zp&&!Cs?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()}},Kw=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),AD;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof LD?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Kw})})(AD||={});var LD=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?Kw:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},wg=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 qp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new qp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},BD=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 qp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=It(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},OD;(e=>{async function t(r){let o,c=await Promise.all(r.map(h=>h.then(f=>f,f=>{o||(o=f)})));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})(OD||={});var aS=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 qi.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())}};aS.EMPTY=aS.fromArray([]);var{getWindow:ws,getWindowId:zD,onDidRegisterWindow:jD}=(function(){let e=new Map,t={window:Ys,disposables:new Or};e.set(Ys.vscodeWindowId,t);let s=new ke,r=new ke,o=new ke;function c(h,f){return(typeof h=="number"?e.get(h):void 0)??(f?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(h){if(e.has(h.vscodeWindowId))return tt.None;let f=new Or,g={window:h,disposables:f.add(new Or)};return e.set(h.vscodeWindowId,g),f.add(It(()=>{e.delete(h.vscodeWindowId),r.fire(h)})),f.add(Ve(h,Ni.BEFORE_UNLOAD,()=>{o.fire(h)})),s.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let f=h;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:Ys},getDocument(h){return ws(h).document}}})(),HD=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 Ve(e,t,s,r){return new HD(e,t,s,r)}var lS=function(e,t,s,r){return Ve(e,t,s,r)},Cg,PD=class extends BD{constructor(e){super(),this.defaultTarget=e&&ws(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},oS=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){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(oS.sort),h.shift().execute();r.set(c,!1)};Cg=(c,h,f=0)=>{let g=zD(c),p=new oS(h,f),b=e.get(g);return b||(b=[],e.set(g,b)),b.push(p),s.get(g)||(s.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function UD(e){let t=e.getBoundingClientRect(),s=ws(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ni={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"},ID=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=dn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=dn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=dn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=dn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=dn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=dn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=dn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=dn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=dn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=dn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=dn(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=dn(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=dn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=dn(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 dn(e){return typeof e=="number"?`${e}px`:e}function Xo(e){return new ID(e)}var Ww=class{constructor(){this._hooks=new Or,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(It(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=ws(e)}this._hooks.add(Ve(c,Ni.POINTER_MOVE,h=>{if(h.buttons!==s){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Ve(c,Ni.POINTER_UP,h=>this.stopMonitoring(!0)))}};function KD(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 Ss;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ss||={});var Bo=class Gi extends tt{constructor(){super(),this.dispatched=!1,this.targets=new Qb,this.ignoreTargets=new Qb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qi.runAndSubscribe(jD,({window:t,disposables:s})=>{s.add(Ve(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(Ve(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(Ve(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Ys,disposables:this._store}))}static addTarget(t){if(!Gi.isTouchDevice())return tt.None;Gi.INSTANCE||(Gi.INSTANCE=new Gi);let s=Gi.INSTANCE.targets.push(t);return It(s)}static ignoreTarget(t){if(!Gi.isTouchDevice())return tt.None;Gi.INSTANCE||(Gi.INSTANCE=new Gi);let s=Gi.INSTANCE.ignoreTargets.push(t);return It(s)}static isTouchDevice(){return"ontouchstart"in Ys||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(Ss.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 f=s.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let g=this.activeTouches[f.identifier],p=Date.now()-g.initialTimeStamp;if(p<Gi.HOLD_DELAY&&Math.abs(g.initialPageX-Tn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Tn(g.rollingPageY))<30){let b=this.newGestureEvent(Ss.Tap,g.initialTarget);b.pageX=Tn(g.rollingPageX),b.pageY=Tn(g.rollingPageY),this.dispatchEvent(b)}else if(p>=Gi.HOLD_DELAY&&Math.abs(g.initialPageX-Tn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Tn(g.rollingPageY))<30){let b=this.newGestureEvent(Ss.Contextmenu,g.initialTarget);b.pageX=Tn(g.rollingPageX),b.pageY=Tn(g.rollingPageY),this.dispatchEvent(b)}else if(o===1){let b=Tn(g.rollingPageX),y=Tn(g.rollingPageY),S=Tn(g.rollingTimestamps)-g.rollingTimestamps[0],w=b-g.rollingPageX[0],k=y-g.rollingPageY[0],T=[...this.targets].filter(B=>g.initialTarget instanceof Node&&B.contains(g.initialTarget));this.inertia(t,T,r,Math.abs(w)/S,w>0?1:-1,b,Math.abs(k)/S,k>0?1:-1,y)}this.dispatchEvent(this.newGestureEvent(Ss.End,g.initialTarget)),delete this.activeTouches[f.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===Ss.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Gi.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Ss.Change||t.type===Ss.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,f,g,p){this.handle=Cg(t,()=>{let b=Date.now(),y=b-r,S=0,w=0,k=!0;o+=Gi.SCROLL_FRICTION*y,f+=Gi.SCROLL_FRICTION*y,o>0&&(k=!1,S=c*o*y),f>0&&(k=!1,w=g*f*y);let T=this.newGestureEvent(Ss.Change);T.translationX=S,T.translationY=w,s.forEach(B=>B.dispatchEvent(T)),k||this.inertia(t,s,b,o,c,h+S,f,g,p+w)})}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],f=this.newGestureEvent(Ss.Change,h.initialTarget);f.translationX=c.pageX-Tn(h.rollingPageX),f.translationY=c.pageY-Tn(h.rollingPageY),f.pageX=c.pageX,f.pageY=c.pageY,this.dispatchEvent(f),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)}};Bo.SCROLL_FRICTION=-.005,Bo.HOLD_DELAY=700,Bo.CLEAR_TAP_COUNT_TIME=400,Zt([KD],Bo,"isTouchDevice",1);var WD=Bo,xg=class extends tt{onclick(e,t){this._register(Ve(e,Ni.CLICK,s=>t(new Eu(ws(e),s))))}onmousedown(e,t){this._register(Ve(e,Ni.MOUSE_DOWN,s=>t(new Eu(ws(e),s))))}onmouseover(e,t){this._register(Ve(e,Ni.MOUSE_OVER,s=>t(new Eu(ws(e),s))))}onmouseleave(e,t){this._register(Ve(e,Ni.MOUSE_LEAVE,s=>t(new Eu(ws(e),s))))}onkeydown(e,t){this._register(Ve(e,Ni.KEY_DOWN,s=>t(new nS(s))))}onkeyup(e,t){this._register(Ve(e,Ni.KEY_UP,s=>t(new nS(s))))}oninput(e,t){this._register(Ve(e,Ni.INPUT,t))}onblur(e,t){this._register(Ve(e,Ni.BLUR,t))}onfocus(e,t){this._register(Ve(e,Ni.FOCUS,t))}onchange(e,t){this._register(Ve(e,Ni.CHANGE,t))}ignoreGesture(e){return WD.ignoreTarget(e)}},cS=11,FD=class extends xg{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=cS+"px",this.domNode.style.height=cS+"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 Ww),this._register(lS(this.bgDomNode,Ni.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(lS(this.domNode,Ni.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new PD),this._pointerdownScheduleRepeatTimer=this._register(new wg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ws(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()}},qD=class em{constructor(t,s,r,o,c,h,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,o=o|0,c=c|0,h=h|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,s<0&&(s=0),o+s>r&&(o=r-s),o<0&&(o=0),c<0&&(c=0),f+c>h&&(f=h-c),f<0&&(f=0),this.width=s,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=h,this.scrollTop=f}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 em(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 em(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,f=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:f,scrollTopChanged:g}}},$D=class extends tt{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 qD(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 hS(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=hS.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)))}},uS=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Zf(e,t){let s=t-e;return function(r){return e+s*XD(r)}}function VD(e,t,s){return function(r){return r<s?e(r/s):t((r-s)/(1-s))}}var hS=class tm{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),VD(Zf(t,o),Zf(c,s),.33)}return Zf(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 uS(r,o,!1)}return new uS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,r){return tm.start(t,s,r)}static start(t,s,r){r=r+10;let o=Date.now()-10;return new tm(t,s,o,r)}};function YD(e){return Math.pow(e,3)}function XD(e){return 1-YD(1-e)}var GD=class extends tt{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 wg)}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":"")))}},ZD=140,Fw=class extends xg{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 GD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ww),this._shouldRender=!0,this.domNode=Xo(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(Ve(this.domNode.domNode,Ni.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new FD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Xo(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(Ve(this.slider.domNode,Ni.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=UD(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(Pw&&h>ZD){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(f))},()=>{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()}},qw=class im{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 im(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),f=Math.max(0,h-2*s),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*f/o))),b=(f-p)/(o-r),y=c*b;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:b,computedSliderPosition:Math.round(y)}}_refreshComputedValues(){let t=im._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)}},QD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new qw(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}},JD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new qw(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}},eR=500,dS=50,tR=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},nm=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(bg){let s=ws(t.browserEvent),r=dD(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 tR(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),f=Math.abs(s.deltaY),g=Math.max(Math.min(o,h),1),p=Math.max(Math.min(c,f),1),b=Math.max(o,h),y=Math.max(c,f);b%g===0&&y%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};nm.INSTANCE=new nm;var iR=nm,nR=class extends xg{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=rR(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 JD(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new QD(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=Xo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Xo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Xo(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 wg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ca(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,Cs&&(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 rS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ca(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new rS(s))};this._mouseWheelToDispose.push(Ve(this._listenOnDomNode,Ni.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=iR.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=!Cs&&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 f=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=dS*o,b=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,b)}if(c){let p=dS*c,b=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,b)}g=this._scrollable.validateScrollPosition(g),(f.scrollLeft!==g.scrollLeft||f.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(),eR)}},sR=class extends nR{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 rR(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,Cs&&(t.className+=" mac"),t}var sm=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._bufferService=s,this._optionsService=h,this._renderService=f,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 $D({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Cg(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new sR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(qi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(It(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(It(()=>this._styleElement.remove())),this._register(qi.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(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};sm=Zt([Re(2,tn),Re(3,Gs),Re(4,Ew),Re(5,Rl),Re(6,nn),Re(7,Zs)],sm);var rm=class extends tt{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(It(()=>{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()}};rm=Zt([Re(1,tn),Re(2,Gs),Re(3,dc),Re(4,Zs)],rm);var aR=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)}},ys={full:0,left:0,center:0,right:0},kr={full:0,left:0,center:0,right:0},Co={full:0,left:0,center:0,right:0},th=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=f,this._colorZoneStore=new aR,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(It(()=>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);kr.full=this._canvas.width,kr.left=e,kr.center=t,kr.right=e,this._refreshDrawHeightConstants(),Co.full=1,Co.left=1,Co.center=1+kr.left,Co.right=1+kr.left+kr.center}_refreshDrawHeightConstants(){ys.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);ys.left=t,ys.center=t,ys.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ys.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(Co[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ys[e.position||"full"]/2),kr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ys[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};th=Zt([Re(2,tn),Re(3,dc),Re(4,Zs),Re(5,nn),Re(6,Rl),Re(7,Gs)],th);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 $w;(e=>e.ST=`${fe.ESC}\\`)($w||={});var am=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)}}};am=Zt([Re(2,tn),Re(3,nn),Re(4,ka),Re(5,Zs)],am);var Bi=0,Oi=0,zi=0,Gt=0,fS={css:"#00000000",rgba:0},gi;(e=>{function t(o,c,h,f){return f!==void 0?`#${ca(o)}${ca(c)}${ca(h)}${ca(f)}`:`#${ca(o)}${ca(c)}${ca(h)}`}e.toCss=t;function s(o,c,h,f=255){return(o<<24|c<<16|h<<8|f)>>>0}e.toRgba=s;function r(o,c,h,f){return{css:e.toCss(o,c,h,f),rgba:e.toRgba(o,c,h,f)}}e.toColor=r})(gi||={});var jt;(e=>{function t(g,p){if(Gt=(p.rgba&255)/255,Gt===1)return{css:p.css,rgba:p.rgba};let b=p.rgba>>24&255,y=p.rgba>>16&255,S=p.rgba>>8&255,w=g.rgba>>24&255,k=g.rgba>>16&255,T=g.rgba>>8&255;Bi=w+Math.round((b-w)*Gt),Oi=k+Math.round((y-k)*Gt),zi=T+Math.round((S-T)*Gt);let B=gi.toCss(Bi,Oi,zi),L=gi.toRgba(Bi,Oi,zi);return{css:B,rgba:L}}e.blend=t;function s(g){return(g.rgba&255)===255}e.isOpaque=s;function r(g,p,b){let y=Pu.ensureContrastRatio(g.rgba,p.rgba,b);if(y)return gi.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Bi,Oi,zi]=Pu.toChannels(p),{css:gi.toCss(Bi,Oi,zi),rgba:p}}e.opaque=o;function c(g,p){return Gt=Math.round(p*255),[Bi,Oi,zi]=Pu.toChannels(g.rgba),{css:gi.toCss(Bi,Oi,zi,Gt),rgba:gi.toRgba(Bi,Oi,zi,Gt)}}e.opacity=c;function h(g,p){return Gt=g.rgba&255,c(g,Gt*p/255)}e.multiplyOpacity=h;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(jt||={});var Ft;(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 Bi=parseInt(o.slice(1,2).repeat(2),16),Oi=parseInt(o.slice(2,3).repeat(2),16),zi=parseInt(o.slice(3,4).repeat(2),16),gi.toColor(Bi,Oi,zi);case 5:return Bi=parseInt(o.slice(1,2).repeat(2),16),Oi=parseInt(o.slice(2,3).repeat(2),16),zi=parseInt(o.slice(3,4).repeat(2),16),Gt=parseInt(o.slice(4,5).repeat(2),16),gi.toColor(Bi,Oi,zi,Gt);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 Bi=parseInt(c[1]),Oi=parseInt(c[2]),zi=parseInt(c[3]),Gt=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),gi.toColor(Bi,Oi,zi,Gt);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),[Bi,Oi,zi,Gt]=t.getImageData(0,0,1,1).data,Gt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:gi.toRgba(Bi,Oi,zi,Gt),css:o}}e.toColor=r})(Ft||={});var en;(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,f=o/255,g=c/255,p=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),y=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+b*.7152+y*.0722}e.relativeLuminance2=s})(en||={});var Pu;(e=>{function t(h,f){if(Gt=(f&255)/255,Gt===1)return f;let g=f>>24&255,p=f>>16&255,b=f>>8&255,y=h>>24&255,S=h>>16&255,w=h>>8&255;return Bi=y+Math.round((g-y)*Gt),Oi=S+Math.round((p-S)*Gt),zi=w+Math.round((b-w)*Gt),gi.toRgba(Bi,Oi,zi)}e.blend=t;function s(h,f,g){let p=en.relativeLuminance(h>>8),b=en.relativeLuminance(f>>8);if(qs(p,b)<g){if(b<p){let w=r(h,f,g),k=qs(p,en.relativeLuminance(w>>8));if(k<g){let T=o(h,f,g),B=qs(p,en.relativeLuminance(T>>8));return k>B?w:T}return w}let y=o(h,f,g),S=qs(p,en.relativeLuminance(y>>8));if(S<g){let w=r(h,f,g),k=qs(p,en.relativeLuminance(w>>8));return S>k?y:w}return y}}e.ensureContrastRatio=s;function r(h,f,g){let p=h>>24&255,b=h>>16&255,y=h>>8&255,S=f>>24&255,w=f>>16&255,k=f>>8&255,T=qs(en.relativeLuminance2(S,w,k),en.relativeLuminance2(p,b,y));for(;T<g&&(S>0||w>0||k>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),k-=Math.max(0,Math.ceil(k*.1)),T=qs(en.relativeLuminance2(S,w,k),en.relativeLuminance2(p,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.reduceLuminance=r;function o(h,f,g){let p=h>>24&255,b=h>>16&255,y=h>>8&255,S=f>>24&255,w=f>>16&255,k=f>>8&255,T=qs(en.relativeLuminance2(S,w,k),en.relativeLuminance2(p,b,y));for(;T<g&&(S<255||w<255||k<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),T=qs(en.relativeLuminance2(S,w,k),en.relativeLuminance2(p,b,y));return(S<<24|w<<16|k<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(Pu||={});function ca(e){let t=e.toString(16);return t.length<2?"0"+t:t}function qs(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var lR=class extends hc{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()]}},ih=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,f=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(p-o>1){let b=this._getJoinedRanges(r,h,c,t,o);for(let y=0;y<b.length;y++)s.push(b[y])}o=p,h=c,f=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Lr.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,h,c,t,o);for(let b=0;b<p.length;b++)s.push(p[b])}return s}_getJoinedRanges(e,t,s,r,o){let c=e.substring(t,s),h=[];try{h=this._characterJoiners[0].handler(c)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let g=this._characterJoiners[f].handler(c);for(let p=0;p<g.length;p++)ih._mergeRanges(h,g[p])}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 f=s;f<this._bufferService.cols;f++){let g=t.getWidth(f),p=t.getString(f).length||Lr.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=f,o=!0),h[1]<=c){if(h[1]=f,h=e[++r],!h)break;h[0]<=c?(h[0]=f,o=!0):o=!1}c+=p}}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}};ih=Zt([Re(0,tn)],ih);function oR(e){return 57508<=e&&e<=57558}function cR(e){return 9472<=e&&e<=9631}function uR(e){return oR(e)||cR(e)}function hR(){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 lm=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,f,g,p,b){let y=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,k=e.getNoBgTrimmedLength();s&&k<c+1&&(k=c+1);let T,B=0,L="",A=0,W=0,I=0,ee=0,se=!1,ae=0,oe=!1,ve=0,U=0,K=[],Y=p!==-1&&b!==-1;for(let H=0;H<k;H++){e.loadCell(H,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let te=!1,N=H>=U,$=H,X=this._workCell;if(S.length>0&&H===S[0][0]&&N){let _e=S.shift(),Te=this._isCellInSelection(_e[0],t);for(A=_e[0]+1;A<_e[1];A++)N&&=Te===this._isCellInSelection(A,t);N&&=!s||c<_e[0]||c>=_e[1],N?(te=!0,X=new lR(this._workCell,e.translateToString(!0,_e[0],_e[1]),_e[1]-_e[0]),$=_e[1]-1,j=X.getWidth()):U=_e[1]}let Se=this._isCellInSelection(H,t),De=s&&H===c,R=Y&&H>=p&&H<=b,G=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,_e=>{G=!0});let ce=X.getChars()||Lr;if(ce===" "&&(X.isUnderline()||X.isOverline())&&(ce=" "),ve=j*f-g.get(ce,X.isBold(),X.isItalic()),!T)T=this._document.createElement("span");else if(B&&(Se&&oe||!Se&&!oe&&X.bg===W)&&(Se&&oe&&w.selectionForeground||X.fg===I)&&X.extended.ext===ee&&R===se&&ve===ae&&!De&&!te&&!G&&N){X.isInvisible()?L+=Lr:L+=ce,B++;continue}else B&&(T.textContent=L),T=this._document.createElement("span"),B=0,L="";if(W=X.bg,I=X.fg,ee=X.extended.ext,se=R,ae=ve,oe=Se,te&&c>=H&&c<=$&&(c=H),!this._coreService.isCursorHidden&&De&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&K.push("xterm-cursor-blink"),K.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(X.isBold()&&K.push("xterm-bold"),X.isItalic()&&K.push("xterm-italic"),X.isDim()&&K.push("xterm-dim"),X.isInvisible()?L=Lr:L=X.getChars()||Lr,X.isUnderline()&&(K.push(`xterm-underline-${X.extended.underlineStyle}`),L===" "&&(L=" "),!X.isUnderlineColorDefault()))if(X.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${hc.toColorRGB(X.getUnderlineColor()).join(",")})`;else{let _e=X.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&X.isBold()&&_e<8&&(_e+=8),T.style.textDecorationColor=w.ansi[_e].css}X.isOverline()&&(K.push("xterm-overline"),L===" "&&(L=" ")),X.isStrikethrough()&&K.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let me=X.getFgColor(),xe=X.getFgColorMode(),Ee=X.getBgColor(),Me=X.getBgColorMode(),qe=!!X.isInverse();if(qe){let _e=me;me=Ee,Ee=_e;let Te=xe;xe=Me,Me=Te}let ge,Q,he=!1;this._decorationService.forEachDecorationAtCell(H,t,void 0,_e=>{_e.options.layer!=="top"&&he||(_e.backgroundColorRGB&&(Me=50331648,Ee=_e.backgroundColorRGB.rgba>>8&16777215,ge=_e.backgroundColorRGB),_e.foregroundColorRGB&&(xe=50331648,me=_e.foregroundColorRGB.rgba>>8&16777215,Q=_e.foregroundColorRGB),he=_e.options.layer==="top")}),!he&&Se&&(ge=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,Ee=ge.rgba>>8&16777215,Me=50331648,he=!0,w.selectionForeground&&(xe=50331648,me=w.selectionForeground.rgba>>8&16777215,Q=w.selectionForeground)),he&&K.push("xterm-decoration-top");let we;switch(Me){case 16777216:case 33554432:we=w.ansi[Ee],K.push(`xterm-bg-${Ee}`);break;case 50331648:we=gi.toColor(Ee>>16,Ee>>8&255,Ee&255),this._addStyle(T,`background-color:#${pS((Ee>>>0).toString(16),"0",6)}`);break;default:qe?(we=w.foreground,K.push("xterm-bg-257")):we=w.background}switch(ge||X.isDim()&&(ge=jt.multiplyOpacity(we,.5)),xe){case 16777216:case 33554432:X.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(T,we,w.ansi[me],X,ge,void 0)||K.push(`xterm-fg-${me}`);break;case 50331648:let _e=gi.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(T,we,_e,X,ge,Q)||this._addStyle(T,`color:#${pS(me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,we,w.foreground,X,ge,Q)||qe&&K.push("xterm-fg-257")}K.length&&(T.className=K.join(" "),K.length=0),!De&&!te&&!G&&N?B++:T.textContent=L,ve!==this.defaultSpacing&&(T.style.letterSpacing=`${ve}px`),y.push(T),H=$}return T&&B&&(T.textContent=L),y}_applyMinimumContrast(e,t,s,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||uR(r.getCode()))return!1;let h=this._getContrastCache(r),f;if(!o&&!c&&(f=h.getColor(t.rgba,s.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=jt.ensureContrastRatio(o||t,c||s,g),h.setColor((o||t).rgba,(c||s).rgba,f??null)}return f?(this._addStyle(e,`color:${f.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]}};lm=Zt([Re(1,Dw),Re(2,nn),Re(3,Gs),Re(4,ka),Re(5,dc),Re(6,Rl)],lm);function pS(e,t,s){for(;e.length<s;)e=t+e;return e}var dR=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}},fR=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,f=Math.max(c,0),g=Math.min(h,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=f,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 pR(){return new fR}var Qf="xterm-dom-renderer-owner-",Fn="xterm-rows",Tu="xterm-fg-",mS="xterm-bg-",xo="xterm-focus",Du="xterm-selection",mR=1,om=class extends tt{constructor(e,t,s,r,o,c,h,f,g,p,b,y,S,w){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=p,this._bufferService=b,this._coreService=y,this._coreBrowserService=S,this._themeService=w,this._terminalClass=mR++,this._rowElements=[],this._selectionRenderModel=pR(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fn),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=hR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(lm,document),this._element.classList.add(Qf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(It(()=>{this._element.classList.remove(Qf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new dR(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} .${Fn} 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} .${Fn} { 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} .${Fn} .xterm-dim { color: ${jt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let 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} .${Fn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Fn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Fn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fn} .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: ${jt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${mS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Tu}257 { color: ${jt.opaque(e.background).css}; }${this._terminalSelector} .${Tu}257.xterm-dim { color: ${jt.multiplyOpacity(jt.opaque(e.background),.5).css}; }${this._terminalSelector} .${mS}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(xo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(xo),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,f=this._document.createDocumentFragment();if(s){let g=e[0]>t[0];f.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,p=c===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,g,p));let b=h-c-1;if(f.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,b)),c!==h){let y=o===h?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(h,0,y))}}this._selectionContainer.appendChild(f)}_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,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+s.ydisp,b=this._rowElements[g],y=s.lines.get(p);if(!b||!y)break;b.replaceChildren(...this._rowFactory.createRow(y,p,p===r,h,f,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Qf}${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 f=this._bufferService.buffer,g=f.ybase+f.y,p=Math.min(f.x,o-1),b=this._optionsService.rawOptions.cursorBlink,y=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=s;w<=r;++w){let k=w+f.ydisp,T=this._rowElements[w],B=f.lines.get(k);if(!T||!B)break;T.replaceChildren(...this._rowFactory.createRow(B,k,k===g,y,S,p,b,this.dimensions.css.cell.width,this._widthCache,c?w===s?e:0:-1,c?(w===r?t:o)-1:-1))}}};om=Zt([Re(7,_g),Re(8,Eh),Re(9,nn),Re(10,tn),Re(11,ka),Re(12,Gs),Re(13,Rl)],om);var cm=class extends tt{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 _R(this._optionsService))}catch{this._measureStrategy=this._register(new gR(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())}};cm=Zt([Re(2,nn)],cm);var Vw=class extends tt{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)}},gR=class extends Vw{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}},_R=class extends Vw{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},vR=class extends tt{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 yR(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(qi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ve(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ve(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},yR=class extends tt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Cl),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(It(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ve(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)}},bR=class extends tt{constructor(){super(),this.linkProviders=[],this._register(It(()=>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 Eg(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 SR(e,t,s,r,o,c,h,f,g){if(!c)return;let p=Eg(e,t,s);if(p)return p[0]=Math.ceil((p[0]+(g?h/2:0))/h),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var um=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,o){return SR(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=Eg(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])}}};um=Zt([Re(0,Zs),Re(1,Eh)],um);var wR=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=[]}},Yw={};AT(Yw,{getSafariVersion:()=>xR,isChromeOS:()=>Qw,isFirefox:()=>Xw,isIpad:()=>ER,isIphone:()=>kR,isLegacyEdge:()=>CR,isLinux:()=>kg,isMac:()=>nh,isNode:()=>kh,isSafari:()=>Gw,isWindows:()=>Zw});var kh=typeof process<"u"&&"title"in process,fc=kh?"node":navigator.userAgent,pc=kh?"node":navigator.platform,Xw=fc.includes("Firefox"),CR=fc.includes("Edge"),Gw=/^((?!chrome|android).)*safari/i.test(fc);function xR(){if(!Gw)return 0;let e=fc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var nh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pc),ER=pc==="iPad",kR=pc==="iPhone",Zw=["Windows","Win16","Win32","WinCE"].includes(pc),kg=pc.indexOf("Linux")>=0,Qw=/\bCrOS\b/.test(fc),Jw=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()}},TR=class extends Jw{_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())}}},DR=class extends Jw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sh=!kh&&"requestIdleCallback"in window?DR:TR,RR=class{constructor(){this._queue=new sh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},hm=class extends tt{constructor(e,t,s,r,o,c,h,f,g){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Cl),this._pausedResizeTask=new RR,this._observerDisposable=this._register(new Cl),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 wR((p,b)=>this._renderRows(p,b),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new MR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(It(()=>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(p=>this._registerIntersectionObserver(p,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=It(()=>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()}};hm=Zt([Re(2,nn),Re(3,Eh),Re(4,ka),Re(5,dc),Re(6,tn),Re(7,Gs),Re(8,Rl)],hm);var MR=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 NR(e,t,s,r){let o=s.buffer.x,c=s.buffer.y;if(!s.buffer.hasScrollback)return BR(o,c,e,t,s,r)+Th(c,t,s,r)+OR(o,c,e,t,s,r);let h;if(c===t)return h=o>e?"D":"C",tc(Math.abs(o-e),ec(h,r));h=c>t?"D":"C";let f=Math.abs(c-t),g=LR(c>t?e:o,s)+(f-1)*s.cols+1+AR(c>t?o:e);return tc(g,ec(h,r))}function AR(e,t){return e-1}function LR(e,t){return t.cols-e}function BR(e,t,s,r,o,c){return Th(t,r,o,c).length===0?"":tc(t1(e,t,e,t-xa(t,o),!1,o).length,ec("D",c))}function Th(e,t,s,r){let o=e-xa(e,s),c=t-xa(t,s),h=Math.abs(o-c)-zR(e,t,s);return tc(h,ec(e1(e,t),r))}function OR(e,t,s,r,o,c){let h;Th(t,r,o,c).length>0?h=r-xa(r,o):h=t;let f=r,g=jR(e,t,s,r,o,c);return tc(t1(e,h,s,f,g==="C",o).length,ec(g,c))}function zR(e,t,s){let r=0,o=e-xa(e,s),c=t-xa(t,s);for(let h=0;h<Math.abs(o-c);h++){let f=e1(e,t)==="A"?-1:1;s.buffer.lines.get(o+f*h)?.isWrapped&&r++}return r}function xa(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 jR(e,t,s,r,o,c){let h;return Th(s,r,o,c).length>0?h=r-xa(r,o):h=t,e<s&&h<=r||e>=s&&h<r?"C":"D"}function e1(e,t){return e>t?"A":"B"}function t1(e,t,s,r,o,c){let h=e,f=t,g="";for(;(h!==s||f!==r)&&f>=0&&f<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(f,!1,e,h),h=0,e=0,f++):!o&&h<0&&(g+=c.buffer.translateBufferLineToString(f,!1,0,e+1),h=c.cols-1,e=h,f--);return g+c.buffer.translateBufferLineToString(f,!1,e,h)}function ec(e,t){let s=t?"O":"[";return fe.ESC+s+e}function tc(e,t){e=Math.floor(e);let s="";for(let r=0;r<e;r++)s+=t;return s}var HR=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function gS(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Jf=50,PR=15,UR=50,IR=500,KR=" ",WR=new RegExp(KR,"g"),dm=class extends tt{constructor(e,t,s,r,o,c,h,f,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=f,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=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new HR(this._bufferService),this._activeSelectionMode=0,this._register(It(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let 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 f=s.translateBufferLineToString(h,!0,o,c);r.push(f)}}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),f=s.translateBufferLineToString(c,!0);h?.isWrapped?r[r.length-1]+=f:r.push(f)}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(WR," ")).join(Zw?`\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())),kg&&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=gS(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=Eg(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,-Jf),Jf),t/=Jf,t/Math.abs(t)+Math.round(t*(PR-1)))}shouldForceSelection(e){return nh?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(),UR)}_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&&!(nh&&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<IR&&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=NR(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),f=this._convertViewportColToCharacterIndex(c,e[0]),g=f,p=e[0]-f,b=0,y=0,S=0,w=0;if(h.charAt(f)===" "){for(;f>0&&h.charAt(f-1)===" ";)f--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let B=e[0],L=e[0];c.getWidth(B)===0&&(b++,B--),c.getWidth(L)===2&&(y++,L++);let A=c.getString(L).length;for(A>1&&(w+=A-1,g+=A-1);B>0&&f>0&&!this._isCharWordSeparator(c.loadCell(B-1,this._workCell));){c.loadCell(B-1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===0?(b++,B--):W>1&&(S+=W-1,f-=W-1),f--,B--}for(;L<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let W=this._workCell.getChars().length;this._workCell.getWidth()===2?(y++,L++):W>1&&(w+=W-1,g+=W-1),g++,L++}}g++;let k=f+p-b+S,T=Math.min(this._bufferService.cols,g-f+b+y-S-w);if(!(!t&&h.slice(f,g).trim()==="")){if(s&&k===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 L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let A=this._bufferService.cols-L.start;k-=A,T+=A}}}if(r&&k+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 L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(T+=L.length)}}return{start:k,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=gS(s,this._bufferService.cols)}};dm=Zt([Re(3,tn),Re(4,ka),Re(5,vg),Re(6,nn),Re(7,Zs),Re(8,Gs)],dm);var _S=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={}}},vS=class{constructor(){this._color=new _S,this._css=new _S}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()}},Si=Object.freeze((()=>{let e=[Ft.toColor("#2e3436"),Ft.toColor("#cc0000"),Ft.toColor("#4e9a06"),Ft.toColor("#c4a000"),Ft.toColor("#3465a4"),Ft.toColor("#75507b"),Ft.toColor("#06989a"),Ft.toColor("#d3d7cf"),Ft.toColor("#555753"),Ft.toColor("#ef2929"),Ft.toColor("#8ae234"),Ft.toColor("#fce94f"),Ft.toColor("#729fcf"),Ft.toColor("#ad7fa8"),Ft.toColor("#34e2e2"),Ft.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:gi.toCss(r,o,c),rgba:gi.toRgba(r,o,c)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:gi.toCss(r,r,r),rgba:gi.toRgba(r,r,r)})}return e})()),ha=Ft.toColor("#ffffff"),Oo=Ft.toColor("#000000"),yS=Ft.toColor("#ffffff"),bS=Oo,Eo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},FR=ha,fm=class extends tt{constructor(e){super(),this._optionsService=e,this._contrastCache=new vS,this._halfContrastCache=new vS,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ha,background:Oo,cursor:yS,cursorAccent:bS,selectionForeground:void 0,selectionBackgroundTransparent:Eo,selectionBackgroundOpaque:jt.blend(Oo,Eo),selectionInactiveBackgroundTransparent:Eo,selectionInactiveBackgroundOpaque:jt.blend(Oo,Eo),scrollbarSliderBackground:jt.opacity(ha,.2),scrollbarSliderHoverBackground:jt.opacity(ha,.4),scrollbarSliderActiveBackground:jt.opacity(ha,.5),overviewRulerBorder:ha,ansi:Si.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=Tt(e.foreground,ha),t.background=Tt(e.background,Oo),t.cursor=jt.blend(t.background,Tt(e.cursor,yS)),t.cursorAccent=jt.blend(t.background,Tt(e.cursorAccent,bS)),t.selectionBackgroundTransparent=Tt(e.selectionBackground,Eo),t.selectionBackgroundOpaque=jt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Tt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=jt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Tt(e.selectionForeground,fS):void 0,t.selectionForeground===fS&&(t.selectionForeground=void 0),jt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=jt.opacity(t.selectionBackgroundTransparent,.3)),jt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=jt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Tt(e.scrollbarSliderBackground,jt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Tt(e.scrollbarSliderHoverBackground,jt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Tt(e.scrollbarSliderActiveBackground,jt.opacity(t.foreground,.5)),t.overviewRulerBorder=Tt(e.overviewRulerBorder,FR),t.ansi=Si.slice(),t.ansi[0]=Tt(e.black,Si[0]),t.ansi[1]=Tt(e.red,Si[1]),t.ansi[2]=Tt(e.green,Si[2]),t.ansi[3]=Tt(e.yellow,Si[3]),t.ansi[4]=Tt(e.blue,Si[4]),t.ansi[5]=Tt(e.magenta,Si[5]),t.ansi[6]=Tt(e.cyan,Si[6]),t.ansi[7]=Tt(e.white,Si[7]),t.ansi[8]=Tt(e.brightBlack,Si[8]),t.ansi[9]=Tt(e.brightRed,Si[9]),t.ansi[10]=Tt(e.brightGreen,Si[10]),t.ansi[11]=Tt(e.brightYellow,Si[11]),t.ansi[12]=Tt(e.brightBlue,Si[12]),t.ansi[13]=Tt(e.brightMagenta,Si[13]),t.ansi[14]=Tt(e.brightCyan,Si[14]),t.ansi[15]=Tt(e.brightWhite,Si[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]=Tt(e.extendedAnsi[r],Si[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()}}};fm=Zt([Re(0,nn)],fm);function Tt(e,t){if(e!==void 0)try{return Ft.toColor(e)}catch{}return t}var qR=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)}},$R=class{constructor(){this._services=new qR,this._services.set(_g,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=PT(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)}},VR={trace:0,debug:1,info:2,warn:3,error:4,off:5},YR="xterm.js: ",pm=class extends tt{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=VR[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?"":YR)+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)}};pm=Zt([Re(0,nn)],pm);var SS=class extends tt{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}},et=3,mi=Object.freeze(new hc),Ru=0,ep=2,zo=class i1{constructor(t,s,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*et);let o=s||Xn.fromCharData([0,Sw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let s=this._data[t*et+0],r=s&2097151;return[this._data[t*et+1],s&2097152?this._combined[t]:r?Ar(r):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*et+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*et+0]=t|2097152|s[2]<<22):this._data[t*et+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*et+0]>>22}hasWidth(t){return this._data[t*et+0]&12582912}getFg(t){return this._data[t*et+1]}getBg(t){return this._data[t*et+2]}hasContent(t){return this._data[t*et+0]&4194303}getCodePoint(t){let s=this._data[t*et+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*et+0]&2097152}getString(t){let s=this._data[t*et+0];return s&2097152?this._combined[t]:s&2097151?Ar(s&2097151):""}isProtected(t){return this._data[t*et+2]&536870912}loadCell(t,s){return Ru=t*et,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*et+0]=s.content,this._data[t*et+1]=s.fg,this._data[t*et+2]=s.bg}setCellFromCodepoint(t,s,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*et+0]=s|r<<22,this._data[t*et+1]=o.fg,this._data[t*et+2]=o.bg}addCodepointToCell(t,s,r){let o=this._data[t*et+0];o&2097152?this._combined[t]+=Ar(s):o&2097151?(this._combined[t]=Ar(o&2097151)+Ar(s),o&=-2097152,o|=2097152):o=s|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*et+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*ep<this._data.buffer.byteLength;let r=t*et;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 f=parseInt(o[h],10);f>=t&&delete this._combined[f]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let f=parseInt(c[h],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*ep<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ep<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 i1(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*et+0]&4194303)return t+(this._data[t*et+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*et+0]&4194303||this._data[t*et+2]&50331648)return t+(this._data[t*et+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 p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}else for(let g=0;g<o;g++){for(let p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let p=parseInt(f[g],10);p>=s&&(this._combined[p-s+r]=t._combined[p])}}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*et+0],f=h&2097151,g=h&2097152?this._combined[s]:f?Ar(f):Lr;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(s);s+=h>>22||1}return o&&o.push(s),c}};function XR(e,t,s,r,o,c){let h=[];for(let f=0;f<e.length-1;f++){let g=f,p=e.get(++g);if(!p.isWrapped)continue;let b=[e.get(f)];for(;g<e.length&&p.isWrapped;)b.push(p),p=e.get(++g);if(!c&&r>=f&&r<g){f+=b.length-1;continue}let y=0,S=ic(b,y,t),w=1,k=0;for(;w<b.length;){let B=ic(b,w,t),L=B-k,A=s-S,W=Math.min(L,A);b[y].copyCellsFrom(b[w],k,S,W,!1),S+=W,S===s&&(y++,S=0),k+=W,k===B&&(w++,k=0),S===0&&y!==0&&b[y-1].getWidth(s-1)===2&&(b[y].copyCellsFrom(b[y-1],s-1,S++,1,!1),b[y-1].setCell(s-1,o))}b[y].replaceCells(S,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(f+b.length-T),h.push(T)),f+=b.length-1}return h}function GR(e,t){let s=[],r=0,o=t[r],c=0;for(let h=0;h<e.length;h++)if(o===h){let f=t[++r];e.onDeleteEmitter.fire({index:h-c,amount:f}),h+=f-1,c+=f,o=t[++r]}else s.push(h);return{layout:s,countRemoved:c}}function ZR(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 QR(e,t,s){let r=[],o=e.map((g,p)=>ic(e,p,t)).reduce((g,p)=>g+p),c=0,h=0,f=0;for(;f<o;){if(o-f<s){r.push(o-f);break}c+=s;let g=ic(e,h,t);c>g&&(c-=g,h++);let p=e[h].getWidth(c-1)===2;p&&c--;let b=p?s-1:s;r.push(b),f+=b}return r}function ic(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 n1=class s1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=s1._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(),Ca(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};n1._nextId=1;var JR=n1,Ei={},da=Ei.B;Ei[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ei.A={"#":"£"};Ei.B=void 0;Ei[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ei.C=Ei[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ei.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ei.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ei.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ei.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ei.E=Ei[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ei.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ei.H=Ei[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ei["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var wS=4294967295,CS=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=mi.clone(),this.savedCharset=da,this.markers=[],this._nullCell=Xn.fromCharData([0,Sw,1,0]),this._whitespaceCell=Xn.fromCharData([0,Lr,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new SS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new eh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new eh),this._whitespaceCell}getBlankLine(e,t){return new zo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>wS?wS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=mi);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new SS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(mi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let 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 zo(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 zo(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=XR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(mi),s);if(r.length>0){let o=GR(this.lines,r);ZR(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(mi),o=s;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zo(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(mi),o=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let f=this.lines.get(h);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&h>0;)f=this.lines.get(--h),g.unshift(f);if(!s){let W=this.ybase+this.y;if(W>=h&&W<h+g.length)continue}let p=g[g.length-1].getTrimmedLength(),b=QR(g,this._cols,e),y=b.length-g.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+y):S=Math.max(0,this.lines.length-this.lines.maxLength+y);let w=[];for(let W=0;W<y;W++){let I=this.getBlankLine(mi,!0);w.push(I)}w.length>0&&(o.push({start:h+g.length+c,newLines:w}),c+=w.length),g.push(...w);let k=b.length-1,T=b[k];T===0&&(k--,T=b[k]);let B=g.length-y-1,L=p;for(;B>=0;){let W=Math.min(L,T);if(g[k]===void 0)break;if(g[k].copyCellsFrom(g[B],L-W,T-W,W,!0),T-=W,T===0&&(k--,T=b[k]),L-=W,L===0){B--;let I=Math.max(B,0);L=ic(g,I,this._cols)}}for(let W=0;W<g.length;W++)b[W]<e&&g[W].setCell(b[W],r);let A=y-S;for(;A-- >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=[],f=[];for(let T=0;T<this.lines.length;T++)f.push(this.lines.get(T));let g=this.lines.length,p=g-1,b=0,y=o[b];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let S=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(y&&y.start>p+S){for(let B=y.newLines.length-1;B>=0;B--)this.lines.set(T--,y.newLines[B]);T++,h.push({index:p+1,amount:y.newLines.length}),S+=y.newLines.length,y=o[++b]}else this.lines.set(T,f[p--]);let w=0;for(let T=h.length-1;T>=0;T--)h[T].index+=w,this.lines.onInsertEmitter.fire(h[T]),w+=h[T].amount;let k=Math.max(0,g+c-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,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 JR(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)}},eM=class extends tt{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 CS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new CS(!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)}},r1=2,a1=1,mm=class extends tt{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,r1),this.rows=Math.max(e.rawOptions.rows||0,a1),this.buffers=this._register(new eM(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))}};mm=Zt([Re(0,nn)],mm);var dl={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:nh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},tM=["normal","bold","100","200","300","400","500","600","700","800","900"],iM=class extends tt{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...dl};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(It(()=>{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 dl))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in dl))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=dl[e]),!nM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=dl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=tM.includes(t)?t:dl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function nM(e){return e==="block"||e==="underline"||e==="bar"}function jo(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]&&jo(e[r],t-1);return s}var xS=Object.freeze({insertMode:!1}),ES=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),gm=class extends tt{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=jo(xS),this.decPrivateModes=jo(ES)}reset(){this.modes=jo(xS),this.decPrivateModes=jo(ES)}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))}};gm=Zt([Re(0,tn),Re(1,kw),Re(2,nn)],gm);var kS={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 tp(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 ip=String.fromCharCode,TS={DEFAULT:e=>{let t=[tp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ip(t[0])}${ip(t[1])}${ip(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tp(e,!0)};${e.x};${e.y}${t}`}},_m=class extends tt{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(kS))this.addProtocol(r,kS[r]);for(let r of Object.keys(TS))this.addEncoding(r,TS[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)}};_m=Zt([Re(0,tn),Re(1,ka),Re(2,nn)],_m);var np=[[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]],sM=[[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]],wi;function rM(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 aM=class{constructor(){if(this.version="6",!wi){wi=new Uint8Array(65536),wi.fill(1),wi[0]=0,wi.fill(0,1,32),wi.fill(0,127,160),wi.fill(2,4352,4448),wi[9001]=2,wi[9002]=2,wi.fill(2,11904,42192),wi[12351]=1,wi.fill(2,44032,55204),wi.fill(2,63744,64256),wi.fill(2,65040,65050),wi.fill(2,65072,65136),wi.fill(2,65280,65377),wi.fill(2,65504,65511);for(let e=0;e<np.length;++e)wi.fill(0,np[e][0],np[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?wi[e]:rM(e,sM)?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 Uu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new aM;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 p=t.charCodeAt(c);56320<=p&&p<=57343?h=(h-55296)*1024+p-56320+65536:s+=this.wcwidth(p)}let f=this.charProperties(h,r),g=Uu.extractWidth(f);Uu.extractShouldJoin(f)&&(g-=Uu.extractWidth(r)),s+=g,r=f}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},lM=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 DS(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 ko=2147483647,oM=256,l1=class vm{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>oM)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 vm;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 vm(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let 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>ko?ko: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>ko?ko: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,ko):t}},To=[],cM=class{constructor(){this._state=0,this._active=To,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=To}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=To,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||To,!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",xh(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=To,this._id=-1,this._state=0}}},Dn=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+=xh(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}},Do=[],uM=class{constructor(){this._handlers=Object.create(null),this._active=Do,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Do}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=Do,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Do,!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",xh(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=Do,this._ident=0}},Ho=new l1;Ho.addParam(0);var RS=class{constructor(e){this._handler=e,this._data="",this._params=Ho,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ho,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xh(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=Ho,this._data="",this._hitLimit=!1,s));return this._params=Ho,this._data="",this._hitLimit=!1,t}},hM=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}},Vn=160,dM=(function(){let e=new hM(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),s=(f,g)=>t.slice(f,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(Vn,0,2,0),e.add(Vn,8,5,8),e.add(Vn,6,0,6),e.add(Vn,11,0,11),e.add(Vn,13,13,13),e})(),fM=class extends tt{constructor(e=dM){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 l1,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(It(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new cM),this._dcsParser=this._register(new uM),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 f=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&g>-1){for(;g>=0&&(h=f[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=f[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 f=c;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:Vn)],o>>4){case 2:for(let S=f+1;;++S){if(S>=t||(r=e[S])<32||r>126&&r<Vn){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<Vn){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<Vn){this._printHandler(e,f,S),f=S-1;break}if(++S>=t||(r=e[S])<32||r>126&&r<Vn){this._printHandler(e,f,S),f=S-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(h=g[p](this._params),h!==!0);p--)if(h instanceof Promise)return this._preserveStack(3,g,p,o,f),h;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++f<t&&(r=e[f])>47&&r<60);f--;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,f),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 S=f+1;;++S)if(S>=t||(r=e[S])===24||r===26||r===27||r>127&&r<Vn){this._dcsParser.put(e,f,S),f=S-1;break}break;case 14:if(h=this._dcsParser.unhook(r!==24&&r!==26),h)return this._preserveStack(6,[],0,o,f),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 S=f+1;;S++)if(S>=t||(r=e[S])<32||r>127&&r<Vn){this._oscParser.put(e,f,S),f=S-1;break}break;case 6:if(h=this._oscParser.end(r!==24&&r!==26),h)return this._preserveStack(5,[],0,o,f),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},pM=/^([\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})$/,mM=/^[\da-f]+$/;function MS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=pM.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),mM.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 sp(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 gM(e,t=16){let[s,r,o]=e;return`rgb:${sp(s,t)}/${sp(r,t)}/${sp(o,t)}`}var _M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Tr=131072,NS=10;function AS(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 LS=5e3,BS=0,vM=class extends tt{constructor(e,t,s,r,o,c,h,f,g=new fM){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new jT,this._utf8Decoder=new HT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=mi.clone(),this._eraseAttrDataInternal=mi.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new ym(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:b.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,b,y)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:b,data:y})}),this._parser.setDcsHandlerFallback((p,b,y)=>{b==="HOOK"&&(y=y.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:b,payload:y})}),this._parser.setPrintHandler((p,b,y)=>this.print(p,b,y)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(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 Dn(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new Dn(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new Dn(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new Dn(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new Dn(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new Dn(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new Dn(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new Dn(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new Dn(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new Dn(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new Dn(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new Dn(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Ei)this._parser.registerEscHandler({intermediates:"(",final:p},()=>this.selectCharset("("+p)),this._parser.registerEscHandler({intermediates:")",final:p},()=>this.selectCharset(")"+p)),this._parser.registerEscHandler({intermediates:"*",final:p},()=>this.selectCharset("*"+p)),this._parser.registerEscHandler({intermediates:"+",final:p},()=>this.selectCharset("+"+p)),this._parser.registerEscHandler({intermediates:"-",final:p},()=>this.selectCharset("-"+p)),this._parser.registerEscHandler({intermediates:".",final:p},()=>this.selectCharset("."+p)),this._parser.registerEscHandler({intermediates:"/",final:p},()=>this.selectCharset("/"+p));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(p=>(this._logService.error("Parsing error: ",p),p)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new RS((p,b)=>this.requestStatusString(p,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"),LS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${LS} 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>Tr&&(c=this._parseStack.position+Tr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Tr&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Tr))),h||this._dirtyRowTracker.clearRange(),e.length>Tr)for(let p=c;p<e.length;p+=Tr){let b=p+Tr<e.length?p+Tr:e.length,y=typeof e=="string"?this._stringDecoder.decode(e.substring(p,b),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,b),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,y))return this._preserveStack(r,o,y,p),this._logSlowResolvingAsync(s),s}else if(!h){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=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(f,this._bufferService.rows-1)})}print(e,t,s){let r,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=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 S=this._parser.precedingJoinState;for(let w=t;w<s;++w){if(r=e[w],r<127&&c){let L=c[String.fromCharCode(r)];L&&(r=L.charCodeAt(0))}let k=this._unicodeService.charProperties(r,S);o=ga.extractWidth(k);let T=ga.extractShouldJoin(k),B=T?ga.extractWidth(S):0;if(S=k,h&&this._onA11yChar.fire(Ar(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-B>f){if(g){let L=y,A=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 zo&&y.copyCellsFrom(L,A,0,B,!1);A<f;)L.setCellFromCodepoint(A++,0,1,b)}else if(this._activeBuffer.x=f-1,o===2)continue}if(T&&this._activeBuffer.x){let L=y.getWidth(this._activeBuffer.x-1)?1:2;y.addCodepointToCell(this._activeBuffer.x-L,r,o);for(let A=o-B;--A>=0;)y.setCellFromCodepoint(this._activeBuffer.x++,0,0,b);continue}if(p&&(y.insertCells(this._activeBuffer.x,o-B,this._activeBuffer.getNullCell(b)),y.getWidth(f-1)===2&&y.setCellFromCodepoint(f-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=S,this._activeBuffer.x<f&&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=>AS(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new RS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Dn(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(mi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let 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),f=0;for(let p=0;p<c.length;){let b=c.codePointAt(p)||0;h[f++]=b,p+=b>65535?2:1}let g=f;for(let p=1;p<s;++p)h.copyWithin(g,0,f),g+=f;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,da),this._charsetService.setgCharset(1,da),this._charsetService.setgCharset(2,da),this._charsetService.setgCharset(3,da);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:f,cols:g}=this._bufferService,{active:p,alt:b}=f,y=this._optionsService.rawOptions,S=(T,B)=>(h.triggerDataEvent(`${fe.ESC}[${t?"":"?"}${T};${B}$y`),!0),w=T=>T?1:2,k=e.params[0];return t?k===2?S(k,4):k===4?S(k,w(h.modes.insertMode)):k===12?S(k,3):k===20?S(k,w(y.convertEol)):S(k,0):k===1?S(k,w(r.applicationCursorKeys)):k===3?S(k,y.windowOptions.setWinLines?g===80?2:g===132?1:0:0):k===6?S(k,w(r.origin)):k===7?S(k,w(r.wraparound)):k===8?S(k,3):k===9?S(k,w(o==="X10")):k===12?S(k,w(y.cursorBlink)):k===25?S(k,w(!h.isCursorHidden)):k===45?S(k,w(r.reverseWraparound)):k===66?S(k,w(r.applicationKeypad)):k===67?S(k,4):k===1e3?S(k,w(o==="VT200")):k===1002?S(k,w(o==="DRAG")):k===1003?S(k,w(o==="ANY")):k===1004?S(k,w(r.sendFocus)):k===1005?S(k,4):k===1006?S(k,w(c==="SGR")):k===1015?S(k,4):k===1016?S(k,w(c==="SGR_PIXELS")):k===1048?S(k,1):k===47||k===1047||k===1049?S(k,w(p===b)):k===2004?S(k,w(r.bracketedPasteMode)):k===2026?S(k,w(r.synchronizedOutput)):S(k,0)}_updateAttrColor(e,t,s,r,o){return t===2?(e|=50331648,e&=-16777216,e|=hc.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),f=0;do r[1]===5&&(o=1),r[c+f+1+o]=h[f];while(++f<h.length&&f+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=mi.fg,e.bg=mi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,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|=mi.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=mi.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|=mi.fg&16777215,r.bg&=-67108864,r.bg|=mi.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=mi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let 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(!AS(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>NS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>NS&&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(OS(c))if(o==="?")t.push({type:0,index:c});else{let h=MS(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=MS(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]);OS(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,da),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(_M[e[0]],Ei[e[1]]||da),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=mi.clone(),this._eraseAttrDataInternal=mi.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new 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)}},ym=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(BS=e,e=t,t=BS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ym=Zt([Re(0,tn)],ym);function OS(e){return 0<=e&&e<256}var yM=5e7,zS=12,bM=50,SM=class extends tt{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>yM)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let 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=f=>performance.now()-s>=zS?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(s,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=zS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>bM&&(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()}},bm=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 f=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(g,f)),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)))}};bm=Zt([Re(0,tn)],bm);var jS=!1,wM=class extends tt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Cl),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 $R,this.optionsService=this._register(new iM(e)),this._instantiationService.setService(nn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(mm)),this._instantiationService.setService(tn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(pm)),this._instantiationService.setService(kw,this._logService),this.coreService=this._register(this._instantiationService.createInstance(gm)),this._instantiationService.setService(ka,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(_m)),this._instantiationService.setService(Ew,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ga)),this._instantiationService.setService(KT,this.unicodeService),this._charsetService=this._instantiationService.createInstance(lM),this._instantiationService.setService(IT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bm),this._instantiationService.setService(Tw,this._oscLinkService),this._inputHandler=this._register(new vM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qi.forward(this._bufferService.onResize,this._onResize)),this._register(qi.forward(this.coreService.onData,this._onData)),this._register(qi.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 SM((t,s)=>this._inputHandler.parse(t,s))),this._register(qi.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&&!jS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jS=!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,r1),t=Math.max(t,a1),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(DS.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(DS(this._bufferService),!1))),this._windowsWrappingHeuristics.value=It(()=>{for(let t of e)t.dispose()})}}},CM={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 xM(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=CM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.key=fe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(f);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 f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=fe.ESC+f,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 ai=0,EM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sh,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||(ai=this._search(t),ai===-1)||this._getKey(this._array[ai])!==t)return!1;do if(this._array[ai]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ai),!0;while(++ai<this._array.length&&this._getKey(this._array[ai])===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&&(ai=this._search(e),!(ai<0||ai>=this._array.length)&&this._getKey(this._array[ai])===e))do yield this._array[ai];while(++ai<this._array.length&&this._getKey(this._array[ai])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ai=this._search(e),!(ai<0||ai>=this._array.length)&&this._getKey(this._array[ai])===e))do t(this._array[ai]);while(++ai<this._array.length&&this._getKey(this._array[ai])===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}},rp=0,HS=0,kM=class extends tt{constructor(){super(),this._decorations=new EM(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(It(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new TM(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=>{rp=o.options.x??0,HS=rp+(o.options.width??1),e>=rp&&e<HS&&(!s||(o.options.layer??"bottom")===s)&&r(o)})}},TM=class extends Or{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=Ft.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ft.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},DM=1e3,RM=class{constructor(e,t=DM){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)}},PS=20,rh=class extends tt{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 RM(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(Ve(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(It(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<PS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===PS+1&&(this._liveRegion.textContent+=Up.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=[],f=c?.translateToString(!0,void 0,void 0,h)||"",g=(s.ydisp+o+1).toString(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,h)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let 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,f;if(t===0?(h=s,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(h=this._rowElements.shift(),f=s,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),f.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:f,offset:g})=>{let p=f instanceof Text?f.parentNode:f,b=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(p);if(!y)return console.warn("columns is null. Race condition?"),null;let S=g<y.length?y[g]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++b,S=0),{row:b,column:S}},c=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})`}};rh=Zt([Re(1,_g),Re(2,Gs),Re(3,Zs)],rh);var Sm=class extends tt{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(It(()=>{Ca(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(Ve(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ve(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ve(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ve(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(f=>({link:f}));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],f=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 p=f;p<=g;p++){if(s.has(p)){o.splice(c--,1);break}s.add(p)}}}}_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(f=>this._linkAtPosition(f.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&&MM(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,Ca(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}}};Sm=Zt([Re(1,vg),Re(2,Zs),Re(3,tn),Re(4,Rw)],Sm);function MM(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 NM=class extends wM{constructor(e={}){super(e),this._linkifier=this._register(new Cl),this.browser=Yw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Cl),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(kM),this._instantiationService.setService(dc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(bR),this._instantiationService.setService(Rw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Kp)),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(qi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(It(()=>{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=jt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${fe.ESC}]${r};${gM(o)}${$w.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=gi.toColor(...t.color));else{let c=s;this._themeService.modifyColors(h=>h[c]=gi.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(rh,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,f=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"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(Ve(this.element,"copy",t=>{this.hasSelection()&&OT(t,this._selectionService)}));let e=t=>zT(t,this.textarea,this.coreService,this.optionsService);this._register(Ve(this.textarea,"paste",e)),this._register(Ve(this.element,"paste",e)),Xw?this._register(Ve(this.element,"mousedown",t=>{t.button===2&&Xb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ve(this.element,"contextmenu",t=>{Xb(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),kg&&this._register(Ve(this.element,"auxclick",t=>{t.button===1&&bw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ve(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ve(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ve(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ve(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ve(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ve(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ve(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(Ve(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",Pp.get()),Qw||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(vR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Gs,this._coreBrowserService),this._register(Ve(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ve(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(cm,this._document,this._helperContainer),this._instantiationService.setService(Eh,this._charSizeService),this._themeService=this._instantiationService.createInstance(fm),this._instantiationService.setService(Rl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ih),this._instantiationService.setService(Dw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(hm,this.rows,this.screenElement)),this._instantiationService.setService(Zs,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(am,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(um),this._instantiationService.setService(vg,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Sm,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(sm,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(dm,this.element,this.screenElement,r)),this._instantiationService.setService(FT,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(qi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(rm,this.screenElement)),this._register(Ve(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(rh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(om,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 f,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(f=3,c.button!==void 0&&(f=c.button<3?c.button:3)):f=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,f=c.button<3?c.button:3;break;case"mousedown":g=1,f=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,f=4;break;default:return!1}return g===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:f,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(Ve(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(Ve(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){yw(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=xM(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)&&(AM(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(mi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(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 AM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var LM=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)}},BM=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)}},US=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 BM(t)}getNullCell(){return new Xn}},OM=class extends tt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new US(this._core.buffers.normal,"normal"),this._alternate=new US(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)}},zM=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)}},jM=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}},HM=["cols","rows"],bs=0,PM=class extends tt{constructor(e){super(),this._core=this._register(new NM(e)),this._addonManager=this._register(new LM),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(HM.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 zM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new jM(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 OM(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 Pp.get()},set promptLabel(e){Pp.set(e)},get tooMuchOutput(){return Up.get()},set tooMuchOutput(e){Up.set(e)}}}_verifyIntegers(...e){for(bs of e)if(bs===1/0||isNaN(bs)||bs%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(bs of e)if(bs&&(bs===1/0||isNaN(bs)||bs%1!==0||bs<0))throw new Error("This API only accepts positive integers")}};class UM{pending=null;accept(t){let s="";for(const r of t)s+=this.acceptChar(r);return s}acceptChar(t){return t===""?this.acceptBackspace():h1.has(t)?this.acceptConsonant(t):d1.has(t)?this.acceptVowel(t):FM(t)&&this.canReplacePendingWith(t)?(this.pending=KS(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(f1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const s=WM.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=KM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const s=IS.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=WS({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=IS.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=KS(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=WS(this.pending);return this.pending=null,t}}const ah=44032,lh=21,ml=28,IM=19*lh*ml,o1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],c1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],u1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h1=Tg(o1),d1=Tg(c1),f1=Tg(u1),KM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),p1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],WM=new Map(p1),IS=new Map(p1.map(([e,t])=>[t,[e[0],e[1]]]));function Tg(e){return new Map(e.map((t,s)=>[t,s]))}function FM(e){const t=e.codePointAt(0);return t!==void 0&&t>=ah&&t<ah+IM}function KS(e){const t=e.codePointAt(0)-ah,s=Math.floor(t/(lh*ml)),r=Math.floor(t%(lh*ml)/ml),o=t%ml,c={initial:o1[s],vowel:c1[r]};return o===0?c:{...c,final:u1[o]}}function WS(e){if(!e.vowel)return e.initial;const t=h1.get(e.initial),s=d1.get(e.vowel),r=e.final?f1.get(e.final):0;return t===void 0||s===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(ah+(t*lh+s)*ml+r)}const qM=[{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 $M({ctrlActive:e,onCtrl:t,onStandaloneKey:s,onPreserveFocus:r,onHide:o}){function c(h){h.preventDefault(),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"}),qM.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 VM={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function YM(e){return VM[e]}function XM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const m1="--nterminal-viewport-height",g1="--nterminal-keyboard-inset-bottom",_1="data-nterminal-keyboard-visible",Dh="data-nterminal-compose-open",oh="nterminal:viewport-refresh",GM=120;function ZM(e=window){const t=e.document.documentElement,s=e.visualViewport,r=nN(e);function o(){Dg(e)}return o(),s?.addEventListener("resize",o),s?.addEventListener("scroll",o),r?.addEventListener("geometrychange",o),e.addEventListener("resize",o),e.addEventListener(oh,o),e.addEventListener("orientationchange",o),e.addEventListener("pageshow",o),e.document.addEventListener("visibilitychange",o),()=>{s?.removeEventListener("resize",o),s?.removeEventListener("scroll",o),r?.removeEventListener("geometrychange",o),e.removeEventListener("resize",o),e.removeEventListener(oh,o),e.removeEventListener("orientationchange",o),e.removeEventListener("pageshow",o),e.document.removeEventListener("visibilitychange",o),t.style.removeProperty(m1),t.style.removeProperty(g1),t.removeAttribute(_1)}}function Dg(e=window){const t=e.document.documentElement,{keyboardInsetBottom:s,keyboardVisible:r}=v1(e),o=QM(e,r);return o!==null&&FS(t,m1,`${o}px`),FS(t,g1,`${s}px`),JM(t,_1,String(r)),{viewportHeight:o,keyboardInsetBottom:s,keyboardVisible:r}}function v1(e=window){const t=eN(e);return{keyboardInsetBottom:t,keyboardVisible:t>GM}}function QM(e,t){if((e.document.documentElement.hasAttribute(Dh)||t)&&ya(e.innerHeight))return e.innerHeight;const s=e.visualViewport?.height;return ya(s)?s:ya(e.innerHeight)?e.innerHeight:null}function ya(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function FS(e,t,s){e.style.getPropertyValue(t)!==s&&e.style.setProperty(t,s)}function JM(e,t,s){e.getAttribute(t)!==s&&e.setAttribute(t,s)}function eN(e){return Math.max(tN(e),iN(e))}function tN(e){const t=e.visualViewport?.height;if(!ya(t)||!ya(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))}function iN(e){if(!ya(e.innerHeight))return 0;const s=y1(e)?.boundingRect?.height;return!ya(s)||s>=e.innerHeight*.8?0:Math.round(s)}function y1(e){return e.navigator.virtualKeyboard}function nN(e){const t=y1(e);return!t||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"?null:t}const mc=new Map,nc=new Map,sN=Object.freeze({open:!1,text:""});function rN(e){let t=nc.get(e);return t||(t=new Set,nc.set(e,t)),t}function b1(e){const t=nc.get(e);if(t)for(const s of Array.from(t))s()}function Rg(e){return mc.get(e)??sN}function aN(e,t){const s=rN(e);return s.add(t),()=>{s.delete(t)}}function lN(e,t){const s=Rg(e);s.open!==t&&(mc.set(e,{...s,open:t}),b1(e))}function oN(e,t){const s=Rg(e);s.text!==t&&(mc.set(e,{...s,text:t}),b1(e))}function Mu(e){mc.delete(e),nc.delete(e)}function qS(){mc.clear(),nc.clear()}const S1=120,cN="\x1B[200~",uN="\x1B[201~";function $S(e,t){const s=t.stripTrailingLineBreaks===!1?e:Mg(e),r=dN(s);return r?t.bracketedPasteMode?`${cN}${r}${uN}`:r:""}function hN(e){return e==="queue"?" ":"\r"}function Mg(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function dN(e){return e.replace(/\r\n/g,`
|
|
31
|
+
`).replace(/\r/g,`
|
|
32
|
+
`).replace(/\n/g,"\r")}const fN=420,pN=3e3,VS=650,mN=80,gN=3,Iu=new Set;let yl=null;function _N({terminalId:e,onSubmit:t,queueAvailable:s=!1,disabled:r=!1}){const o=v.useMemo(()=>A=>aN(e,A),[e]),c=v.useMemo(()=>()=>Rg(e),[e]),h=v.useSyncExternalStore(o,c,c),{open:f,text:g}=h,p=v.useRef(null),b=v.useRef(null),y=v.useRef(null),S=v.useRef(null);v.useEffect(()=>()=>{S.current?.(),S.current=null},[]),v.useLayoutEffect(()=>{if(!(!f||!Ku()))return yN(e),()=>bN(e)},[f,e]),v.useLayoutEffect(()=>{const A=p.current?.closest(".terminal-pane");if(!A)return;function W(){A?.removeAttribute("data-compose-open"),A?.style.removeProperty("--compose-drawer-panel-height")}if(!f){W();return}const I=b.current;A.setAttribute("data-compose-open","true");function ee(){const ve=I?.getBoundingClientRect().height??0;ve>0&&A?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}ee();const se=[window.setTimeout(ee,0),window.setTimeout(ee,180),window.setTimeout(ee,260)],ae=window.requestAnimationFrame?.(ee)??null,oe=typeof ResizeObserver=="function"&&I?new ResizeObserver(ee):null;return oe&&I&&oe.observe(I),()=>{for(const ve of se)window.clearTimeout(ve);ae!==null&&window.cancelAnimationFrame?.(ae),oe?.disconnect(),W()}},[f]),v.useEffect(()=>{if(!f){S.current?.(),S.current=null;return}YS(y.current),L()},[f]);function w(A){lN(e,A)}function k(A){oN(e,A)}function T(){vN(p.current),w(!1),XS()}function B(A="send"){if(!(r||!g)){if(t(g,A),k(""),Ku()){y.current?.blur(),XS();return}window.setTimeout(()=>y.current?.focus(),S1+20)}}function L(){Ku()&&(S.current?.(),S.current=SN())}return m.jsxs("div",{ref:p,className:"compose-drawer","data-open":f?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":f?"true":void 0,tabIndex:f?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>w(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:b,className:"compose-drawer-panel","aria-hidden":f?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:f?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:T,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:s?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:y,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:f?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:A=>k(A.target.value),onFocus:L,onKeyDown:A=>{if(A.key==="Enter"&&(A.metaKey||A.ctrlKey)){if(A.preventDefault(),A.shiftKey){s&&B("queue");return}B("send");return}A.key==="Escape"&&(A.preventDefault(),T())},placeholder:s?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:f?0:-1,onClick:()=>{k(""),YS(y.current),L()},disabled:!g,children:"Clear"}),s?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:f?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>B("queue"),disabled:r||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:f?0:-1,onClick:()=>B("send"),disabled:r||!g,children:"Send"})]})]})]})}function vN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function YS(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Ku(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function XS(){if(!Ku())return;const e=gl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function yN(e){yl!==null&&(window.clearTimeout(yl),yl=null),Iu.add(e),document.documentElement.setAttribute(Dh,"true"),gl()}function bN(e){if(Iu.delete(e),Iu.size>0||yl!==null){gl();return}yl=window.setTimeout(()=>{if(yl=null,Iu.size>0){gl();return}document.documentElement.removeAttribute(Dh),gl()},fN),gl()}function SN(){let e=!1,t=null,s=null,r=null,o=0;const c=Date.now(),h=window.visualViewport,f=wN();function g(){t!==null&&(window.clearTimeout(t),t=null),s!==null&&(window.cancelAnimationFrame?.(s),s=null)}function p(){e||(e=!0,g(),h?.removeEventListener("resize",y),h?.removeEventListener("scroll",y),f?.removeEventListener("geometrychange",y))}function b(S){if(!e){if(S<VS&&typeof window.requestAnimationFrame=="function"){s=window.requestAnimationFrame(y);return}t=window.setTimeout(y,mN)}}function y(){if(e)return;g();const S=Dg(),w=Date.now()-c;if(S.keyboardInsetBottom>0&&S.keyboardInsetBottom===r?o+=1:(o=S.keyboardInsetBottom>0?1:0,r=S.keyboardInsetBottom),w>=pN||w>=VS&&o>=gN){p();return}b(w)}return h?.addEventListener("resize",y),h?.addEventListener("scroll",y),f?.addEventListener("geometrychange",y),y(),p}function gl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Dg()}function wN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function CN(e,t){e.attachCustomKeyEventHandler(c=>{if(xN(c)){const h=GS(e);return h?(c.preventDefault(),c.stopPropagation(),ZS(h),!1):!0}return EN(c)?(c.preventDefault(),c.stopPropagation(),kN(e,t),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const r=c=>{const h=GS(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),ZS(h)}},o=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const f=Mg(h);c.preventDefault(),c.stopImmediatePropagation(),w1(e,f,t)};return s.addEventListener("copy",r,!0),s.addEventListener("paste",o,!0),{dispose(){s.removeEventListener("copy",r,!0),s.removeEventListener("paste",o,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function xN(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 EN(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 kN(e,t){if(navigator.clipboard?.readText)try{const s=await navigator.clipboard.readText();if(!s)return;w1(e,Mg(s),t)}catch{}}function w1(e,t,s){if(t){if(s){s(t);return}e.paste(t)}}function GS(e){return e.hasSelection()?e.getSelection():""}async function ZS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}TN(e)}function TN(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 DN=[4,10,11,12];function RN(e,t){const s=[e.parser.registerCsiHandler({final:"c"},r=>QS(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>QS(r)),e.parser.registerCsiHandler({final:"n"},r=>MN(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>NN(r)),e.parser.registerCsiHandler({final:"t"},r=>AN(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...DN.map(r=>e.parser.registerOscHandler(r,o=>LN(o)))];return{dispose(){for(const r of s)r.dispose()}}}function QS(e){return Rh(e)===0}function MN(e){const t=Rh(e);return t===5||t===6}function NN(e){return Rh(e)===6}function AN(e){const t=Rh(e);return t===14||t===16||t===18}function LN(e){return e.split(";").some(t=>t==="?")}function Rh(e){const t=e[0];return typeof t=="number"?t:0}const Ea=new Map,BN=2*1024*1024,ON=1500,zN=25e3;function jN(e,t){let s=Ea.get(e);s||(s=UN(e),Ea.set(e,s),Mh(s)),s.listeners.add(t);const r=c=>$N(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 Po(e){const t=Ea.get(e);t&&(VN(t),Ea.delete(e))}function HN(e,t={}){const s=Ea.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),gc(s);const r=s.socket;return s.socket=null,fa(s,"reconnecting"),r&&(r.readyState===WebSocket.OPEN||r.readyState===WebSocket.CONNECTING)&&r.close(),Mh(s),!0}function PN(){for(const e of Ea.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),gc(e);const t=e.socket;e.socket=null,e.reconnectEnabled=!0,fa(e,"reconnecting"),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),Mh(e)}}function ap(){for(const e of Array.from(Ea.keys()))Po(e)}function UN(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 Mh(e){if(!e.reconnectEnabled)return;fa(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){fa(e,"connected");for(const s of e.pendingOut)t.send(JSON.stringify(s));e.pendingOut.length=0,e.isAlive=!0,IN(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);C1(e,{type:"message",message:c})}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,gc(e),s.code===1008){e.reconnectEnabled=!1,fa(e,KN(s.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){fa(e,"closed");return}fa(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Mh(e)},ON)}}),t.addEventListener("error",()=>{})}function IN(e){gc(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)}))}},zN)}function gc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function KN(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,FN(e,t.output),lp(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),lp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,lp(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 FN(e,t){const s=qN(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 qN(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 lp(e){for(;e.outputBytes>BN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function fa(e,t){e.status!==t&&(e.status=t,C1(e,{type:"status",status:t}))}function C1(e,t){for(const s of Array.from(e.listeners))s(t)}function $N(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 VN(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),gc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const YN=[0,50,150,350],XN=2,GN=[300,1200,2500],ZN=1e3,QN=1e5,wm="\x1B[?1049l\x1B[?1047l\x1B[?47l",JN=new Set(["47","1047","1049"]),e3=400,t3=3,i3=3,n3=32,s3=1.42,r3=2,a3=24,l3=240,o3=60,c3=420,u3=6,h3=2,JS=[500,1500,3e3,5e3,8e3],e0=15e3,d3=xi.lazy(()=>gg(()=>import("./TranscriptMarkdownBody-l6FWnQzY.js"),__vite__mapDeps([2,1])));function t0({terminal:e,serverApi:t,active:s,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:f,onClose:g,onExit:p,onSnapshot:b,onAuthClose:y}){const S=v.useSyncExternalStore(aw,Ap,()=>_a),w=v.useSyncExternalStore(lw,Lp,()=>Sl),k=v.useSyncExternalStore(ow,Op,()=>!0),T=v.useSyncExternalStore(qm,zr,()=>bl),B=v.useSyncExternalStore(ug,()=>hg("history.toggle"),()=>"Alt+H"),L=v.useRef(null),A=v.useRef(null),W=v.useRef(null),I=v.useRef(null),ee=v.useRef({onExit:p,onSnapshot:b}),se=v.useRef(t.createWebSocketUrl),ae=v.useRef(y),oe=v.useRef(null),ve=v.useRef(null),U=v.useRef(null),K=v.useRef(!1),Y=v.useRef(new Map),H=v.useRef([]),j=v.useRef([]),te=v.useRef([]),N=v.useRef(0),$=v.useRef(!1),X=v.useRef(null),Se=v.useRef(0),De=v.useRef(null),R=v.useRef(null),G=v.useRef(!1),ce=v.useRef(!1),me=v.useRef(!1),xe=v.useRef(!1),Ee=v.useRef(null),Me=v.useRef(null),qe=v.useRef(!1),ge=v.useRef(!1),Q=v.useRef(!1),he=v.useRef(!1),we=v.useRef(!1),_e=v.useRef(!1),Te=v.useRef(!1),Be=v.useRef(s),Ie=v.useRef(r),le=v.useRef(c),Ce=v.useRef(S),Ne=v.useRef(w),Oe=v.useRef(!1),je=v.useRef(null),mt=v.useRef(null),Xe=v.useRef(!1),st=v.useRef(null),[,Qt]=v.useState("connecting"),[sn,ki]=v.useState(!1),[Jt,Ti]=v.useState(null),[Gn,F]=v.useState(!1),[$e,ot]=v.useState(null),[wt,li]=v.useState(!1),[Dt,rn]=v.useState(!1),[Zn,Qn]=v.useState(!1),[Rt,Pi]=v.useState(null),[gt,_t]=v.useState(!1),Ct=!!Rt||Wu(e.currentCommand),[Di,oi]=v.useState(!1);v.useLayoutEffect(()=>{Be.current=s},[s]),v.useLayoutEffect(()=>{Ie.current=r},[r]),v.useLayoutEffect(()=>{le.current=c},[c]),v.useLayoutEffect(()=>{Ce.current=S},[S]),v.useLayoutEffect(()=>{Ne.current=w},[w]),v.useLayoutEffect(()=>{Oe.current=gt},[gt]),v.useLayoutEffect(()=>{je.current=Rt},[Rt]),v.useLayoutEffect(()=>{Xe.current=Ct},[Ct]),v.useEffect(()=>{r&&s&&e.status==="running"&&(Lt(),Yi())},[s,r,e.status]),v.useEffect(()=>{ee.current={onExit:p,onSnapshot:b}},[p,b]),v.useEffect(()=>{se.current=t.createWebSocketUrl,ae.current=y},[t,y]),v.useEffect(()=>{let D=!1,ie=null,He=0;const Ke=T3(e.currentCommand),We=Wu(e.currentCommand);function Je(){ie!==null&&(window.clearTimeout(ie),ie=null)}function Pt(vt){if(D)return;let yt;if(vt){if(!We)return;yt=e0}else if(He<JS.length){if(!Ke)return;yt=JS[He++]}else{if(!We)return;yt=e0}ie=window.setTimeout(()=>{ie=null,ii()},yt)}async function ii(){try{const vt=await t.getTerminalTranscriptSource(e.id);if(D)return;Pi(yt=>yt&&vt.source&&yt.provider===vt.source.provider&&yt.sessionId===vt.source.sessionId?yt:vt.source),Pt(!!vt.source)}catch(vt){if(D)return;op(vt)&&Pi(null),Pt(!1)}}return Pi(null),e.status!=="running"?()=>{D=!0,Je()}:(ii(),()=>{D=!0,Je()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const D=Rt?`${e.id}:${Rt.provider}:${Rt.sessionId}`:null,ie=mt.current;ie!==null&&D!==null&&ie!==D&&Oe.current&&_t(!1),mt.current=D},[e.id,Rt?.provider,Rt?.sessionId]),v.useEffect(()=>{function D(ie){!Be.current||!Ie.current||!je.current||ie.isComposing||ie.key==="Process"||m3(ie.target)||cw(ie)?.id!=="history.toggle"||(ie.preventDefault(),ie.stopPropagation(),_t(Ke=>!Ke))}return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[]),v.useEffect(()=>{const D=A.current;D&&(D.options.disableStdin=e.status==="exited"),e.status==="exited"&&Qt("closed")},[e.status]),v.useEffect(()=>{const D=A.current;D&&(D.options.fontSize=S,Wf(S,Ne.current).then(()=>{Ce.current===S&&Lt()}))},[S]),v.useEffect(()=>{const D=A.current;D&&(D.options.fontFamily=Np(w),Wf(Ce.current,w).then(()=>{Ne.current===w&&Lt()}))},[w]),v.useEffect(()=>{const D=A.current;D&&(D.options.theme=i0(T))},[T]),v.useEffect(()=>{const D=L.current;if(!D)return;let ie=!1,He=null,Ke=null,We=null,Je=null,Pt=null,ii=null,vt=null;oe.current=null,we.current=!1,_e.current=!1,xe.current=!1,Jn(),ci();const yt=Ce.current,Ui=Ne.current,$t=new PM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Np(Ui),fontSize:yt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:QN,theme:{...i0(zr())}}),yn=new MT;return $t.loadAddon(yn),Je=RN($t),A.current=$t,W.current=yn,Wf(yt,Ui).then(()=>{if(ie)return;$t.open(D),we.current=!0,He=CN($t,ps),Ie.current&&Be.current&&e.status==="running"&&Yi(),Lt(),Pt=z3(D,$t,()=>Ce.current*1.2,Bt,E=>{vi(E)},it,is),ii=L3(D,$t,Bt,E=>{vi(E)},it,is);const x=new UM;Ke=$t.onData(E=>{if(Te.current){const ne=XM(E);if(ne){Ts(!1),ns(ne);return}}const z=x.accept(E);z&&ns(z)}),We=$t.onScroll(E=>{if(ge.current||he.current||Q.current){ui();return}es(),ls($t)&&ts({scrollToBottom:!0}),Bt(),E<=3&&vi()}),vt=new ResizeObserver(()=>{Kt()}),vt.observe(D),_e.current&&(Ri(),_e.current=!1,Lt()),Bn()}),()=>{ie=!0,we.current=!1,_e.current=!1,Jn(),ve.current=null,U.current=null,K.current=!1,_n(),vn(),Q.current=!1,Pt?.(),ii?.(),vt?.disconnect(),He?.dispose(),Ke?.dispose(),We?.dispose(),Je?.dispose(),$t.dispose(),A.current=null,W.current=null}},[e.id]),v.useEffect(()=>{const D=se.current(e.id),ie=jN(D,qt);return I.current=ie.send,Qt(ie.status),ie.status==="connected"&&Lt(),ie.snapshot&&(ee.current.onSnapshot(ie.snapshot,{notifyCompletion:!1}),A.current&&(Lt(),_i(ie.output,ie.history),Lt())),()=>{ie.detach(),I.current=null}},[e.id,e.status]);function qt(D){if(D.type==="status"){Qt(D.status),D.status==="unauthorized"&&ae.current?.({source:"terminal-ws-1008",terminalId:e.id}),D.status==="connected"&&Lt();return}gn(D.message)}function ci(D=[],ie=null){j.current=[],te.current=Nu(D),N.current=0,$.current=!1,X.current=null,Q.current=!1,Se.current+=1,De.current=ie,R.current=null,G.current=!1,ce.current=!1,me.current=!1,_e.current=!1,st.current=null,Ee.current=null,qe.current=!1,ki(!1),Ti(null),F(!1),ot(null),li(!1),rn(!1)}function _i(D=[],ie=null){ci(D,ie),Ht()}function Ht(){if(!A.current||!we.current){_e.current=!0;return}_e.current=!1,Ri()}async function Ri(){const D=A.current;if(!D)return;const ie=Au(D,qe.current),He=ie?te.current.length:N.current;await ei(D,{liveOutputLimit:He,scrollToBottom:ie}),A.current===D&&ui()}function ei(D,ie={}){return new Promise(He=>{Q.current=!0,$.current=!1;const Ke=Se.current+1;Se.current=Ke;const We=Math.max(0,Math.min(ie.liveOutputLimit??te.current.length,te.current.length)),Je=ie.historyPages??j.current,Pt=()=>{if(A.current!==D||Se.current!==Ke){He(!1);return}try{N.current=We,ie.scrollToBottom&&Es(D)}finally{Q.current=!1;const vt=Kr();vt?ts(vt):ie.applyDeferredSnapshot!==!1&&Js(),He(!0)}},ii=()=>{if(A.current!==D||Se.current!==Ke){He(!1);return}D.clear();const vt=Nu([...Je,...te.current.slice(0,We)]);if(vt.length===0){Pt();return}for(let yt=0;yt<vt.length;yt+=1){const Ui=vt[yt];yt===vt.length-1?D.write(Ui,Pt):D.write(Ui)}};if(D.buffer.active.type==="alternate"){D.write(wm,ii);return}ii()})}async function vi(D=0){const ie=A.current;if(me.current||!ie)return;if(hs(ie)){ui();return}const He=De.current;me.current=!0,ki(!0);const Ke=ie.buffer.active.viewportY;try{let We=!!(He&&!He.hasMore);if(!We)try{const Je=await t.getTerminalHistory(e.id,{beforeLine:He?.startLine??0,limit:ZN}),Pt={startLine:Je.startLine,endLine:Je.endLine,hasMore:Je.hasMore};if(Je.output.length>0){await Zi(ie,Je.output,Ke,D)&&(De.current=Pt);return}De.current=Pt,We=!Je.hasMore}catch(Je){We=op(Je)}if(We){if(hs(ie)){ui();return}await mn(ie,Ke,D)}}catch{}finally{me.current=!1,ki(!1)}}async function mn(D,ie,He){if(!(G.current||ce.current))try{const Ke=R.current,We=await t.getTerminalTranscriptHistory(e.id,{...Ke?{cursor:Ke}:{},limit:e3}),Je=We.output.map(k1);if(!We.source)return;if(Je.length===0){Pi(We.source),R.current=We.cursor,ce.current=!We.hasMore||!We.cursor;return}await Zi(D,Je,ie,He)&&(Pi(We.source),R.current=We.cursor,ce.current=!We.hasMore||!We.cursor)}catch(Ke){op(Ke)&&(G.current=!0)}}async function Zi(D,ie,He,Ke){if(hs(D))return ui(),!1;const We=[...ie,...j.current],Je=N3(ie);return!await ei(D,{liveOutputLimit:N.current,scrollToBottom:!1,historyPages:We,applyDeferredSnapshot:!1})||A.current!==D?!1:(j.current=We,ks(D,Math.max(0,He+Je+Math.min(0,Ke))),qe.current=!ls(D),Bt(),!0)}v.useEffect(()=>{const D=window.visualViewport;function ie(){document.visibilityState==="visible"&&Lt()}function He(){Lt()}function Ke(){Kt()}function We(){Nn()}return document.addEventListener("visibilitychange",ie),window.addEventListener("pageshow",He),window.addEventListener("resize",Ke),window.addEventListener(oh,We),D?.addEventListener("resize",Ke),D?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",ie),window.removeEventListener("pageshow",He),window.removeEventListener("resize",Ke),window.removeEventListener(oh,We),D?.removeEventListener("resize",Ke),D?.removeEventListener("scroll",Ke)}},[e.id]);function Qi(){const D=se.current(e.id);xe.current=!0,st.current=null,Qt("reconnecting"),Lt(),HN(D,{preserveCachedOutputOnNextSnapshot:!0})}function gn(D){if(D.type==="snapshot"&&D.terminal.id===e.id){ee.current.onSnapshot(D.terminal,{notifyCompletion:!1});const He=A.current;if(!He)return;Lt();const Ke=xe.current;if(xe.current=!1,Ke){De.current=D.history??De.current,ui(),Lt();return}if(ds(He,D.terminal)){ti(D.output,D.history??null),ui(),Lt();return}_i(D.output,D.history??null),Lt();return}if(D.type==="terminal_updated"&&D.terminal.id===e.id){ee.current.onSnapshot(D.terminal,{notifyCompletion:!0});return}if(D.type==="output"&&D.terminalId===e.id){const He=R1(D.data);if(!He)return;te.current.push(He),A.current&&we.current?ts({scrollToBottom:!0}):_e.current=!0;return}const ie=A.current;if(ie){if(D.type==="exit"&&D.terminalId===e.id){ee.current.onExit(D.exitCode),Qt("closed");return}D.type==="error"&&ie.writeln(`\r
|
|
33
|
+
[nterminal] ${D.message}`)}}function $i(D=25){if(document.visibilityState==="hidden"||!Ie.current||Y.current.has(D))return;const ie=window.setTimeout(()=>{Y.current.delete(D),!yi()&&fs()},D);Y.current.set(D,ie)}function Kt(){yi()||Bn()}function yi(){const D=Qs();return D&&Ir(D)?(K.current=!0,U.current=D,!0):D&&Ll(D)?(K.current=!1,U.current=null,!0):((!D||!D.composeOpen&&!D.keyboardVisible)&&(K.current=!1,U.current=null),!1)}function Nn(){if(!K.current)return;const D=Qs();D&&(D.composeOpen||D.keyboardVisible)||(K.current=!1,U.current=null)}function Ir(D){if(!D.mobileLike||!D.composeOpen&&!D.keyboardVisible)return!1;const ie=ve.current;return ie?Ln(D.windowWidth,ie.windowWidth)&&Ln(D.visualViewportWidth,ie.visualViewportWidth)&&Ln(D.containerWidth,ie.containerWidth):!1}function Ll(D){if(!D.mobileLike||D.composeOpen||D.keyboardVisible)return!1;const ie=U.current;return!ie||!ie.composeOpen&&!ie.keyboardVisible?!1:Ln(D.windowWidth,ie.windowWidth)&&Ln(D.visualViewportWidth,ie.visualViewportWidth)&&Ln(D.containerWidth,ie.containerWidth)}function Qs(){const D=L.current;if(!D||D.isConnected===!1)return null;const ie=D.getBoundingClientRect(),He=An(window.innerWidth)??0,Ke=An(window.visualViewport?.width)??He,We=An(ie.width)??An(D.clientWidth)??He;if(He<=0||Ke<=0||We<=0)return null;const{keyboardVisible:Je}=v1(),Pt=document.documentElement.hasAttribute(Dh),ii=Ra()||Je;return{windowWidth:He,visualViewportWidth:Ke,containerWidth:We,composeOpen:Pt,keyboardVisible:Je,mobileLike:ii}}function Ra(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function An(D){return typeof D=="number"&&Number.isFinite(D)&&D>0?D:null}function Ln(D,ie){return Math.abs(D-ie)<=XN}function Bn(){for(const D of YN)$i(D)}function Lt(){oe.current=null,Bn()}function Jn(){for(const D of Y.current.values())window.clearTimeout(D);Y.current.clear()}function _n(){for(const D of H.current)window.clearTimeout(D);H.current=[]}function Bt(){if(ui(),!Ee.current){F(!1);return}F(!0),vn(),Me.current=window.setTimeout(()=>{Me.current=null,F(!1)},1200)}function ui(){const D=A.current,ie=D?A3(D):null;if(Ee.current=ie,Ti(ie),rn(!!(D&&ie)),li(!!(D&&ie&&!ls(D))),ie||!D||!Ma()){ot(null);return}ot({alternate:D.buffer.active.type==="alternate"})}function Ma(){const D=De.current;return j.current.length>0||!!D?.hasMore}function vn(){Me.current!==null&&(window.clearTimeout(Me.current),Me.current=null)}function es(){const D=A.current;D&&(qe.current=!ls(D),ui())}function Na(D){X.current=cp(X.current,D)}function Aa(D){const ie=X.current;return X.current=null,cp(ie,D)}function Kr(){const D=X.current;return X.current=null,D}function ts(D={}){const ie=A.current;if(!ie||!we.current){_e.current=!0;return}if(Q.current){Na(D);return}if($.current){Na(D);return}const He=Aa(D);if(!He.force&&!Au(ie,qe.current)){ui();return}$.current=!0;const Ke=Se.current,We=()=>{if(A.current!==ie||Se.current!==Ke){$.current=!1;return}if(!He.force&&!Au(ie,qe.current)){$.current=!1,ui();return}const Je=N.current,Pt=te.current[Je];if(Pt===void 0){$.current=!1,He.scrollToBottom&&Es(ie),ui();const ii=Kr();ii?ts(cp(He,ii)):Js();return}ie.write(Pt,()=>{if(A.current!==ie||Se.current!==Ke){$.current=!1;return}N.current=Je+1,We()})};We()}function hs(D){return!ls(D)&&(an()||$.current||Q.current)}function ds(D,ie){return(Xe.current||Wu(ie?.currentCommand))&&!ls(D)}function an(){return N.current<te.current.length}function ti(D,ie){st.current={output:D,history:ie,appendFromLiveOutputIndex:N.current}}function Js(){const D=A.current,ie=st.current;if(!D||!ie||!ls(D)||an()||$.current||Q.current)return;const He=Nu(ie.output),Ke=Nu(te.current.slice(ie.appendFromLiveOutputIndex));st.current=null,_i(M3(He,Ke),ie.history),Lt()}function it(){he.current=!0}function is(){es(),he.current=!1;const D=A.current;D&&ls(D)&&ts({scrollToBottom:!0})}function Es(D){Wr(()=>l0(D))&&(qe.current=!1)}function ks(D,ie){Wr(()=>(D.scrollToLine(ie),!0))}function Wr(D){ge.current=!0;try{return D()}finally{ge.current=!1}}function Vi(){const D=A.current;if(!D)return;const ie=()=>{l0(D),qe.current=!1,ui(),ts({force:!0,scrollToBottom:!0}),Yi()};if(D.buffer.active.type==="alternate"){D.write(wm,ie);return}ie()}function er(D){const ie=A.current,He=L.current;if(!ie||!He)return;const Ke=He.getBoundingClientRect();if(Ke.height<=0)return;const We=Math.max(0,Math.min(1,(D-Ke.top)/Ke.height)),Je=Math.round(ie.buffer.active.baseY*We);it();try{ie.scrollToLine(Je)}finally{is()}qe.current=!ls(ie),ui(),Bt(),Je<=3&&vi()}function Fr(D){D.preventDefault(),D.stopPropagation(),D.currentTarget.setPointerCapture?.(D.pointerId),er(D.clientY)}function qr(D){(D.buttons&1)!==0&&(D.preventDefault(),D.stopPropagation(),er(D.clientY))}function fs(){const D=A.current,ie=W.current;if(!(!D||!ie)&&!(document.visibilityState==="hidden"||!Ie.current||L.current?.isConnected===!1))try{const He=Au(D,qe.current),Ke=Qs();ie.fit(),Ke&&(ve.current=Ke),He&&Es(D),D.refresh(0,Math.max(0,D.rows-1)),ui();const We={cols:D.cols,rows:D.rows},Je=oe.current;if(Je&&Je.cols===We.cols&&Je.rows===We.rows)return;tr({type:"resize",terminalId:e.id,cols:We.cols,rows:We.rows})&&(oe.current=We)}catch{}}function tr(D){const ie=I.current;return ie?ie(D):!1}function ns(D){ts({force:!0,scrollToBottom:!0}),tr({type:"input",terminalId:e.id,data:D})&&E3(D)&&La()}function ps(D){const ie=$S(D,{bracketedPasteMode:A.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});ie&&ns(ie)}function Bl(D,ie){const He=$S(D,{bracketedPasteMode:A.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});He&&ns(He),window.setTimeout(()=>ns(hN(ie)),S1)}function La(){!le.current||!Be.current||(_n(),H.current=GN.map(D=>{const ie=window.setTimeout(()=>{H.current=H.current.filter(He=>He!==ie),le.current&&Be.current&&tr({type:"refresh_cwd",terminalId:e.id})},D);return ie}))}function Yi(){Oe.current||A.current?.focus()}const ir=v.useCallback(()=>{_t(!1)},[]);function On(){Qn(D=>{const ie=!D;return Te.current=ie,ie}),Yi()}function Ts(D){Te.current=D,Qn(D)}function Ds(D){Te.current&&Ts(!1),ns(YM(D)),Yi()}return m.jsxs("section",{className:"terminal-pane","data-active":s,onMouseDown:()=>{s||f()},children:[m.jsx(g3,{terminal:e,canClose:o,tabId:h,transcriptSource:Rt,transcriptShortcutLabel:B,onOpenTranscript:()=>_t(!0),onReload:Qi,onClose:g}),m.jsx("div",{className:"xterm-container",ref:L}),sn?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,k&&Jt?m.jsxs("div",{className:"terminal-scroll-progress","data-active":Gn,"aria-hidden":"true",children:[Jt.current,"/",Jt.total]}):k&&$e?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":$e.alternate?"alternate":"normal","aria-hidden":"true",children:[$e.alternate?"alt ":"","0/?"]}):null,wt?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:D=>D.stopPropagation(),onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),Vi()},children:"↓"}):null,Dt?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Fr,onPointerMove:qr,children:m.jsx("span",{"aria-hidden":"true"})}):null,s&&e.status==="running"?Di?m.jsx($M,{ctrlActive:Zn,onCtrl:On,onStandaloneKey:Ds,onPreserveFocus:Yi,onHide:()=>oi(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:D=>{D.stopPropagation(),Yi()},onPointerDown:D=>{D.stopPropagation(),Yi()},onClick:()=>oi(!0),children:"⌨"}):null,m.jsx(_N,{terminalId:e.id,onSubmit:Bl,queueAvailable:Rt?.provider==="codex"||E1(e.currentCommand),disabled:e.status!=="running"}),gt&&Rt?m.jsx(_3,{terminalId:e.id,serverApi:t,source:Rt,fontSize:S,onClose:ir}):null]})}function i0(e){return _E(e)}function f3(e,t,s){const r=p3(e,t),o=n0(r*Math.max(1,s),o3,c3);return{limit:n0(Math.ceil(o/r3),a3,l3),maxLines:o}}function p3(e,t){const s=e?.clientHeight??0;if(s<=0)return n3;const r=Math.max(10,t*s3);return Math.max(1,Math.floor(s/r))}function n0(e,t,s){return Math.max(t,Math.min(s,Math.floor(e)))}function m3(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function g3({terminal:e,canClose:t,tabId:s,transcriptSource:r,transcriptShortcutLabel:o,onOpenTranscript:c,onReload:h,onClose:f}){const g=F0({id:`pane-${e.id}`,disabled:!s,...s?{data:{kind:"pane",sourceTabId:s,terminalId:e.id}}:{}}),p={cursor:s?"grab":"default",opacity:g.isDragging?.5:void 0};return m.jsxs("header",{ref:g.setNodeRef,className:"terminal-pane-header",style:p,"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 ${ch(r.provider)} transcript history`,"aria-label":`View ${ch(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(),f()},children:"x"}):null]})}const _3=xi.memo(function({terminalId:t,serverApi:s,source:r,fontSize:o,onClose:c}){const h=v.useRef(null),f=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),b=v.useRef(null),y=v.useRef(""),[S,w]=v.useState([]),[k,T]=v.useState(!1),[B,L]=v.useState(""),[A,W]=v.useState(-1),[I,ee]=v.useState(null),[se,ae]=v.useState(!1),[oe,ve]=v.useState(!0),[U,K]=v.useState(!1),[Y,H]=v.useState(null);v.useEffect(()=>{function ge(Q){Q.key==="Escape"&&(Q.preventDefault(),Q.stopPropagation(),c())}return document.addEventListener("keydown",ge,!0),()=>document.removeEventListener("keydown",ge,!0)},[c]),v.useEffect(()=>{f.current+=1;const ge=f.current;return g.current=!1,p.current=!0,b.current=null,w([]),ee(null),ae(!1),H(null),me(null,"initial",ge),()=>{f.current===ge&&(f.current+=1)}},[s,k,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const ge=h.current;if(!ge)return;if(p.current){if(oe||S.length===0)return;p.current=!1;const he=()=>{ge.scrollTop=ge.scrollHeight};he(),window.requestAnimationFrame?.(he);return}const Q=b.current;Q!==null&&(b.current=null,ge.scrollTop+=ge.scrollHeight-Q)},[S,oe,k]);const j=ch(r.provider),te=a0(S,k),N=b3(te),$=C3(N,B),X=$.length,Se=X>0?A>=0&&A<X?A:0:-1,De=Se>=0?$[Se]?.entryIndex??null:null,R=Se>=0?$[Se]??null:null,G=te?te.split(`
|
|
34
|
+
`).length-1:0,ce=B.trim()?X>0?`${Se+1}/${X} ${X===1?"match":"matches"} · ${G} ${G===1?"line":"lines"}`:`0 matches · ${G} ${G===1?"line":"lines"}`:G>0?`${G} lines`:"0 lines";v.useEffect(()=>{const ge=B.trim().toLowerCase();W(Q=>!ge||X===0?-1:y.current!==ge?0:Q>=0&&Q<X?Q:0),y.current=ge},[B,X]);async function me(ge,Q,he=f.current){if(!g.current){g.current=!0,Q==="initial"?ve(!0):(K(!0),b.current=h.current?.scrollHeight??null),H(null);try{await xe(ge,Q,he)}catch(we){if(f.current!==he)return;H(we instanceof Error?we.message:"Failed to load transcript history.")}finally{f.current===he&&(g.current=!1,ve(!1),K(!1))}}}async function xe(ge,Q,he){let we=ge,_e=0,Te=[];const Be=Q==="initial"&&r.provider!=="claude"?h3:u3;for(;f.current===he;){const Ie=await s.getTerminalTranscriptHistory(t,{...we?{cursor:we}:{},...f3(h.current,o,Q==="initial"?t3:i3),includeTools:k});if(f.current!==he)return;const le=r0(Ie.output,r.provider,{includeTools:k}),Ce=Ee(Ie,Q,Te,le);if(le&&(Te=[le,...Te],Ce))return;if(!Ie.hasMore||!Ie.cursor||_e>=Be){Te.length>0&&w(Ne=>Q==="older"?[...Te,...Ne]:Te);return}we=Ie.cursor,_e+=1}}function Ee(ge,Q,he,we=r0(ge.output,r.provider,{includeTools:k})){if(ee(ge.cursor),ae(!!(ge.hasMore&&ge.cursor)),!we)return!1;const _e=[we,...he];return a0(_e,k)?(w(Te=>Q==="older"?[..._e,...Te]:_e),!0):!1}function Me(){const ge=h.current;!ge||ge.scrollTop>72||!se||!I||g.current||me(I,"older")}function qe(ge){X!==0&&W(Q=>{const he=Se>=0?Se:ge>0?-1:0;return((Q>=0&&Q<X?Q:he)+ge+X)%X})}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>{ge.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:ge=>ge.stopPropagation(),onMouseDown:ge=>ge.stopPropagation(),onClick:ge=>ge.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:[j," 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:k,onChange:ge=>T(ge.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:ge=>L(ge.currentTarget.value),onKeyDown:ge=>{ge.key==="Enter"&&(ge.preventDefault(),qe(ge.shiftKey?-1:1))}})]}),m.jsxs("div",{className:"transcript-search-actions","aria-label":"Search result navigation",children:[m.jsx("button",{type:"button",onClick:()=>qe(-1),disabled:X===0,children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>qe(1),disabled:X===0,children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:ce})]}),m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Me,children:[U?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!oe&&se?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,te?m.jsx(v3,{entries:N,searchQuery:B,activeEntryIndex:De,activeSearchMatch:R,fontSize:o}):null,oe?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!oe&&!te&&!Y?se&&I?m.jsxs("div",{className:"transcript-dialog-status",children:[k?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{me(I,"older")},disabled:U,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,Y?m.jsx("div",{className:"transcript-dialog-error",children:Y}):null]})]})})});function v3({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 f=h.querySelectorAll(".transcript-search-hit");((r?.entryIndex===s?f[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,f)=>m.jsxs("section",{ref:g=>{g?c.current.set(f,g):c.current.delete(f)},className:`transcript-entry transcript-entry-${h.kind}${s===f?" transcript-entry-search-active":""}`,children:[h.header?m.jsx("div",{className:"transcript-entry-header",children:x1(h.header,t)}):null,h.body?m.jsx("div",{className:"transcript-entry-body",children:h.kind==="tool"?m.jsx(s0,{text:h.body,searchQuery:t}):m.jsx(xi.Suspense,{fallback:m.jsx(s0,{text:h.body,searchQuery:t}),children:m.jsx(d3,{text:h.body,searchQuery:t})})}):null]},`${h.header??"plain"}-${f}`))})}function s0({text:e,searchQuery:t}){const s=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1).split(`
|
|
36
|
+
`):e.split(`
|
|
37
|
+
`);return m.jsx("pre",{className:"transcript-entry-pre",children:s.map((r,o)=>m.jsx("span",{className:`transcript-line transcript-line-${x3(r,o===0||s[o-1]?.trim()==="")}`,children:x1(r,t)},o))})}function x1(e,t){const s=t.trim();if(!s)return e||" ";const r=e.toLowerCase(),o=s.toLowerCase(),c=[];let h=0,f=r.indexOf(o);for(;f!==-1;){f>h&&c.push(e.slice(h,f));const g=f+s.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),h=g,f=r.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function y3(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 b3(e){const t=e.endsWith(`
|
|
38
|
+
`)?e.slice(0,-1):e;if(!t)return[];const s=[];let r=null,o="plain",c=[];function h(){const f=S3(c).join(`
|
|
39
|
+
`);(r||f)&&s.push({header:r,body:f,kind:o}),r=null,o="plain",c=[]}for(const f of t.split(`
|
|
40
|
+
`)){const g=w3(f);g?(h(),r=f,o=g):c.push(f)}return h(),s}function S3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function w3(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 C3(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}
|
|
41
|
+
${o.body}`:o.body,h=y3(c,t);for(let f=0;f<h;f+=1)s.push({entryIndex:r,matchIndexInEntry:f})}return s}function x3(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)||D1(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 E3(e){return e.includes("\r")||e.includes(`
|
|
42
|
+
`)}function op(e){return e instanceof os&&e.status===404}function Wu(e){return E1(e)||k3(e)}function E1(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function k3(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function T3(e){if(Wu(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function ch(e){return e==="codex"?"Codex":"Claude"}function r0(e,t,s={}){const r=`[nterminal] ${ch(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
43
|
+
`).replace(/\r/g,`
|
|
44
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
45
|
+
|
|
46
|
+
`).trimEnd(),c=k1(o),h=s.includeTools?c:T1(c);return h?`${h}
|
|
47
|
+
`:""}function k1(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=D3(s);return r?`[${r}]`:t})}function D3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const s=t.getFullYear(),r=Ro(t.getMonth()+1),o=Ro(t.getDate()),c=Ro(t.getHours()),h=Ro(t.getMinutes()),f=Ro(t.getSeconds());return`${s}-${r}-${o} ${c}:${h}:${f}`}function Ro(e){return e.toString().padStart(2,"0")}function a0(e,t){return e.map(s=>t?s:T1(s)).filter(Boolean).map(s=>s.endsWith(`
|
|
48
|
+
`)?s:`${s}
|
|
49
|
+
`).join("")}function T1(e){if(!e)return"";const t=e.split(`
|
|
50
|
+
`),s=[];let r=!1,o=!1,c=!0;for(const h of t){const f=h.trim()==="",g=c?R3(h):null;if(g&&(r=g==="tool",o=!1),D1(h)){o=!0,c=!1;continue}if(o){f?(o=!1,r||s.push(h),c=!0):c=!1;continue}r||s.push(h),c=f}return s.join(`
|
|
51
|
+
`).replace(/\n{3,}/g,`
|
|
52
|
+
|
|
53
|
+
`).trimEnd()}function R3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function D1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function M3(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 N3(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=R1(s);r&&t.push(r)}return t}function R1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,s,r)=>{const o=s.split(";").filter(Boolean).filter(c=>!JN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function cp(e,t={}){const s={};return(e?.force||t.force)&&(s.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(s.scrollToBottom=!0),s}function A3(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 ls(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Au(e,t){return!t||ls(e)}function l0(e){return ls(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function L3(e,t,s,r,o,c){const h=f=>{const g=O3(f);g!==0&&(f.cancelable&&f.preventDefault(),f.stopPropagation(),B3(t,g,s,r,o,c))};return e.addEventListener("wheel",h,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",h,{capture:!0})}}function B3(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(wm,h);return}h()}function O3(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 z3(e,t,s,r,o,c,h){let f=null,g=0;const p={passive:!1};function b(w){f=up(w),g=0}function y(w){const k=up(w);if(k===null){f=null,g=0;return}if(f===null){f=k;return}const T=k.clientY-f.clientY;if(f=k,w.cancelable&&w.preventDefault(),T===0)return;if(j3(t)&&H3(t,k,-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 S(w){if(w.touches.length>0){f=up(w);return}f=null,g=0}return e.addEventListener("touchstart",b,p),e.addEventListener("touchmove",y,p),e.addEventListener("touchend",S),e.addEventListener("touchcancel",S),()=>{e.removeEventListener("touchstart",b,p),e.removeEventListener("touchmove",y,p),e.removeEventListener("touchend",S),e.removeEventListener("touchcancel",S)}}function up(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function j3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function H3(e,t,s){const r=e.element;return r?(r.dispatchEvent(P3(t,s)),!0):!1}function P3(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 Cm({node:e,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:f,dropZoneActive:g=!1,draggingTerminalId:p=null,mobileFocusLeafKey:b=null,path:y=[],totalPanes:S,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,onAuthClose:W}){const I=S??xm(e);if(y.length===0&&b){const oe=Em(e),ve=oe.some(U=>U.key===b)?b:oe[0]?.key;if(oe.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:oe.map(U=>{const K=U.key===ve;if(U.type==="editor"){const H=s[U.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:H?m.jsx($b,{api:r,editor:H,canClose:I>1,onClose:()=>A(U.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},U.key)}const Y=t[U.terminalId];return Y?m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx(t0,{terminal:Y,serverApi:r,active:K,visible:c&&K,canClose:I>1,refreshCwdOnEnter:h&&K,tabId:f,onSelect:()=>w(U.terminalId),onClose:()=>k(U.terminalId),onExit:H=>B(U.terminalId,H),onSnapshot:L,...W?{onAuthClose:W}:{}})},U.key):m.jsx("div",{className:"mobile-focused-pane","data-active":K,"aria-hidden":!K,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},U.key)})})}if(e.type==="pane"){const oe=t[e.terminalId];if(!oe)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(t0,{terminal:oe,serverApi:r,active:e.terminalId===o,visible:c,canClose:I>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:f,onSelect:()=>w(e.terminalId),onClose:()=>k(e.terminalId),onExit:K=>B(e.terminalId,K),onSnapshot:L,...W?{onAuthClose:W}:{}});return g&&p!==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($b,{api:r,editor:oe,canClose:I>1,onClose:()=>A(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const ee=Math.max(.1,Math.min(.9,e.ratio)),se=1-ee,ae=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${ee}fr) 1px minmax(0, ${se}fr)`}:{gridTemplateRows:`minmax(0, ${ee}fr) 1px minmax(0, ${se}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:ae,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.first,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:b,path:[...y,0],totalPanes:I,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,...W?{onAuthClose:W}:{}})}),m.jsx(U3,{direction:e.direction,path:y,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.second,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:b,path:[...y,1],totalPanes:I,onSelect:w,onClose:k,onResize:T,onExit:B,onSnapshot:L,onCloseEditor:A,...W?{onAuthClose:W}:{}})})]})}function Lu({terminalId:e,side:t}){const{setNodeRef:s,isOver:r}=Qm({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 U3({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 f=h.getBoundingClientRect();function g(b){const y=e==="vertical"?(b.clientX-f.left)/f.width:(b.clientY-f.top)/f.height;s(t,Math.min(.9,Math.max(.1,y)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p)}return 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 xm(e){return e.type==="pane"||e.type==="editor"?1:xm(e.first)+xm(e.second)}function Em(e){return e.type==="pane"?[{key:I3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:K3(e.editorId),type:"editor",editorId:e.editorId}]:[...Em(e.first),...Em(e.second)]}function I3(e){return`terminal:${e}`}function K3(e){return`editor:${e}`}const Nh="workspace-default",W3="NTerminal";function F3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function q3(e,t){switch(t.type){case"workspace.hydrated":return km(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return $3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return G3(e,t.workspaceId);case"workspace.selected":return M1(e,t.workspaceId);case"workspace.renamed":return V3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return Y3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return X3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return N1(e,t.terminal);case"terminal.split":return Z3(e,t.terminal,t.direction);case"terminal.updated":return oA(e,t.terminal);case"terminal.exited":return cA(e,t.terminalId,t.exitCode);case"terminal.closed":return B1(e,t.terminalId);case"terminal.detached":return uA(e,t.terminalId,t.workspaceId);case"editor.split":return Q3(e,t.editorId,t.title,t.direction);case"editor.closed":return hA(e,t.editorId);case"pane.selected":return aA(e,t.terminalId);case"pane.resized":return lA(e,t.path,t.ratio);case"tab.selected":return eA(e,t.tabId);case"tab.renamed":return rA(e,t.tabId,t.title);case"tab.reordered":return Ng(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return tA(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return A1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return L1(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return iA(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return J3(e);default:return e}}function $3(e,t){if(e.workspaces.some(r=>r.id===t.id))return M1(e,t.id);const s={id:t.id,title:t.title,defaultCwd:us(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,s],activeWorkspaceId:s.id}}function M1(e,t){return e.workspaces.some(s=>s.id===t)?{...e,activeWorkspaceId:t}:e}function V3(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 Y3(e,t,s){const r=us(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 X3(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(),[f]=h.splice(o,1);if(!f)return e;const g=h.findIndex(y=>y.id===s);if(g<0)return e;const p=r==="before"?g:g+1,b=h.slice();return b.splice(p,0,f),sA(e.workspaces,b)?e:{...e,workspaces:b}}function G3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const s=e.workspaces.find(f=>f.id===t),r=new Set(s?uh(s):[]),o={...e.terminals};for(const f of r)delete o[f];const c=e.workspaces.filter(f=>f.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:o}}function N1(e,t){const s=z1(e),r=Ta(s)??Lh(),o=I1(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??us(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:U1(c,t.id))}}function Z3(e,t,s){const r=Ta(e),o=r?Ah(r):void 0;if(!r||!o)return N1(e,t);const c=o.activeTerminalId,h=rc(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(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??us(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:U1(f,t.id))}}function Q3(e,t,s,r){const o=Ta(e),c=o?Ah(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,f=rc(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(p=>p.id===c.id?{...p,root:f,activeTerminalId:h}:p)}:g)}}function J3(e){const t=Ta(e),s=t?Ah(t):void 0;return s?B1(e,s.activeTerminalId):e}function eA(e,t){const s=Ta(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 Ng(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(),[f]=h.splice(c,1);if(!f)return o;const g=Math.max(0,Math.min(h.length,s)),p=h.slice();return p.splice(g,0,f),nA(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function tA(e,t,s,r,o){if(s===r||!e.terminals[s]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(k=>k.id===t);if(p<0)return g;const b=g.tabs[p];if(!b)return g;const y=xl(b.root,s);if(!y){const k=g.tabs.filter((T,B)=>B!==p);return{...g,tabs:k}}const S={...b,root:y,activeTerminalId:ji(y)[0]??b.activeTerminalId},w=g.tabs.slice();return w[p]=S,{...g,tabs:w}});const h=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(T=>ji(T.root).includes(r));if(p<0)return g;const b=g.tabs[p];if(!b)return g;const y={type:"pane",terminalId:s},S={type:"split",direction:h,ratio:.5,first:f?y:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:y},w=rc(b.root,r,S),k=g.tabs.slice();return k[p]={...b,root:w,activeTerminalId:s},{...g,tabs:k,activeTabId:b.id}}),z1({...e,workspaces:c})}function A1(e,t,s,r){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const L=e.workspaces[B].tabs.findIndex(A=>A.id===t);if(L>=0){o=B,c=L;break}}if(o<0)return e;const h=e.workspaces[o],f=h.tabs[c],g=ji(f.root);if(!g.includes(s))return e;if(g.length===1)return Ng(e,t,r);const p=xl(f.root,s);if(!p)return e;const b={...f,root:p,activeTerminalId:ji(p)[0]??f.activeTerminalId},y=e.terminals[s],S={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:y?.title??"",activeTerminalId:s,root:{type:"pane",terminalId:s}},w=h.tabs.slice();w[c]=b;const k=Math.max(0,Math.min(w.length,r));w.splice(k,0,S);const T=e.workspaces.slice();return T[o]={...h,tabs:w,activeTabId:S.id},{...e,workspaces:T}}function L1(e,t,s,r=Number.MAX_SAFE_INTEGER){const o=j1(e.workspaces,t),c=e.workspaces.find(p=>p.id===s);if(!o||!c)return e;if(o.workspace.id===s)return r===Number.MAX_SAFE_INTEGER?e:Ng(e,t,r);const h=ji(o.tab.root),f=h.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return Da({...p,tabs:p.tabs.filter(b=>b.id!==t)});if(p.id===s){const b=p.tabs.slice(),y=Math.max(0,Math.min(b.length,r));return b.splice(y,0,o.tab),{...p,defaultCwd:p.defaultCwd??us(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(S=>!h.includes(S)),tabs:b,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:s}}function iA(e,t,s,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(w=>w.id===r),h=j1(e.workspaces,t);if(!c||!h||!e.terminals[s]||!ji(h.tab.root).includes(s))return e;if(h.workspace.id===r)return A1(e,t,s,o);if(ji(h.tab.root).length===1)return L1(e,t,r,o);const g=xl(h.tab.root,s);if(!g)return e;const p={...h.tab,root:g,activeTerminalId:ji(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}},S=e.workspaces.map(w=>{if(w.id===h.workspace.id)return Da({...w,tabs:w.tabs.map(k=>k.id===t?p:k)});if(w.id===r){const k=w.tabs.slice(),T=Math.max(0,Math.min(k.length,o));return k.splice(T,0,y),{...w,defaultCwd:w.defaultCwd??us(b.cwd),detachedTerminalIds:w.detachedTerminalIds.filter(B=>B!==s),tabs:k,activeTabId:y.id}}return w});return{...e,workspaces:S,activeWorkspaceId:r}}function nA(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 sA(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 rA(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>{let f=!1;const g=h.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,f=!0,{...p,title:r}));return f?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function aA(e,t){const s=e.workspaces.find(o=>o.tabs.some(c=>El(c.root,t))),r=s?.tabs.find(o=>El(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 lA(e,t,s){const r=Ta(e),o=r?Ah(r):void 0;if(!r||!o)return e;const c=Am(o.root,t,F1(s));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===r.id?{...h,tabs:h.tabs.map(f=>f.id===o.id?{...f,root:c}:f)}:h)}}function km(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,f=!!(s&&s.some(y=>K1(y))||t&&t.some(y=>W1(y)));let g=dA(t,s,c,h);g.length===0&&(g=[Lh()]);const p=typeof r=="string"&&g.some(y=>y.id===r)?r:g[0]?.id??null,b=p??g[0]?.id??Nh;for(const y of e)if(!h.has(y.id)){if(f)g=mA(g,b,y.id,y);else{const S=I1(y);g=_A(g,b,S,y)}h.add(y.id)}return{workspaces:g.map(y=>Da(gA(y,o))),activeWorkspaceId:p,terminals:o}}function sc(e){return ji(e.root)}function Tm(e){return Lm(e.root)}function uh(e){return Ag([...e.tabs.flatMap(t=>ji(t.root)),...e.detachedTerminalIds])}function hp(e){const t=e.workspaces.map(s=>{const r=s.tabs.flatMap(o=>{const c=Mm(o.root);return c?[{...o,root:c}]:[]});return Da({...s,tabs:r})});return{activeWorkspaceId:t.some(s=>s.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function oA(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(s=>({...s,tabs:s.tabs.map(r=>El(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function cA(e,t,s){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:s}}}:e}function B1(e,t){const s={...e.terminals};return delete s[t],O1(e,t,s)}function uA(e,t,s){if(!e.terminals[t])return e;const r=(s&&e.workspaces.some(c=>c.id===s)?s:null)??fA(e,t)?.id??pA(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Nh,o=e.workspaces.find(c=>c.id===r);return!o||!P1(o,t)?e:O1(e,t,{...e.terminals},{detachToWorkspaceId:r})}function O1(e,t,s,r={}){let o=e.workspaces.map(h=>{const f=[];for(const g of h.tabs){const p=xl(g.root,t);if(!p)continue;const b=ji(p),y=b.includes(g.activeTerminalId)?g.activeTerminalId:b[0];y&&f.push({...g,root:p,activeTerminalId:y})}return Da({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&s[t]&&(o=o.map(h=>h.id===r.detachToWorkspaceId?H1(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 hA(e,t){const s=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const f=Dm(h.root,t);if(!f)continue;const g=ji(f),p=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];p&&c.push({...h,root:f,activeTerminalId:p})}return Da({...o,tabs:c})}),r=s.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:s,activeWorkspaceId:r?e.activeWorkspaceId:s[0]?.id??null}}function dA(e,t,s,r){if(t&&t.length>0){const o=[];for(const c of t)K1(c)&&o.push(o0(c,s,r));if(o.length>0)return o}return[o0({...Lh(),tabs:e??[]},s,r)]}function o0(e,t,s){const r=[];for(const c of e.tabs){if(!W1(c))continue;const h=Rm(c.root,t);if(!h)continue;const f=ji(h);for(const p of f)s.add(p);const g=f.includes(c.activeTerminalId)?c.activeTerminalId:f[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 Da({...e,defaultCwd:us(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function z1(e){return Ta(e)?e:{...e,workspaces:[Lh()],activeWorkspaceId:Nh}}function Ta(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Ah(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function j1(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 fA(e,t){return e.workspaces.find(s=>s.tabs.some(r=>El(r.root,t)))}function pA(e,t){return e.workspaces.find(s=>s.detachedTerminalIds.includes(t))}function mA(e,t,s,r){return e.map(o=>o.id===t?H1(o,s,r):o)}function H1(e,t,s){return P1(e,t)?{...e,defaultCwd:e.defaultCwd??us(s?.cwd),detachedTerminalIds:Ag([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function P1(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Dl}function U1(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(s=>s!==t)}:e}function gA(e,t){if(e.defaultCwd)return e;const s=uh(e).find(o=>!!t[o]),r=s?us(t[s]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Lh(){return{id:Nh,title:W3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function Da(e){const t=e.tabs.some(s=>s.id===e.activeTabId);return{...e,defaultCwd:us(e.defaultCwd),detachedTerminalIds:Ag(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function _A(e,t,s,r){const o=ji(s.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??us(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,s],activeTabId:c.activeTabId??s.id}:c)}function I1(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function rc(e,t,s){return e.type==="pane"?e.terminalId===t?s:e:e.type==="editor"?e:{...e,first:rc(e.first,t,s),second:rc(e.second,t,s)}}function xl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const s=xl(e.first,t),r=xl(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Dm(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const s=Dm(e.first,t),r=Dm(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Rm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const s=Rm(e.first,t),r=Rm(e.second,t);return s&&r?{...e,ratio:F1(e.ratio),first:s,second:r}:s??r}function Mm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Mm(e.first),s=Mm(e.second);return t&&s?{...e,first:t,second:s}:t??s}function K1(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 W1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Nm(t.root)}function Nm(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")&&Nm(t.first)&&Nm(t.second):!1}function Am(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=Am(e.first,o,s);return c===e.first?e:{...e,first:c}}if(r===1){const c=Am(e.second,o,s);return c===e.second?e:{...e,second:c}}return e}function F1(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function us(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Ag(e){const t=new Set,s=[];for(const r of e)!r||t.has(r)||(t.add(r),s.push(r));return s}function El(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:El(e.first,t)||El(e.second,t)}function ji(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...ji(e.first),...ji(e.second)]}function Lm(e){return e.type==="pane"||e.type==="editor"?1:Lm(e.first)+Lm(e.second)}const Ur=new Map,ac=new Map,lc=new Map;function Nl(e){return e??"__local__"}function vA(e){return{agentId:e,state:F3(),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 Nt(e){const t=Nl(e);let s=Ur.get(t);return s||(s=vA(e),Ur.set(t,s)),s}function q1(e,t){const s=Nl(e);let r=ac.get(s);return r||(r=new Set,ac.set(s,r)),r.add(t),()=>{r.delete(t)}}function yA(e){const t=Nl(e),s=ac.get(t);if(s)for(const r of Array.from(s))r()}function Al(e,t){Ur.set(Nl(e),t),yA(e)}const Bm=new Set;function bA(e){return Bm.add(e),()=>{Bm.delete(e)}}function Mo(e,t){const s=Nt(e),r=Nl(e);t.type==="workspace.hydrated"&&lc.delete(r);const o=q3(s.state,t);let c=s.unreadCompletions,h=null;if(t.type==="terminal.updated"){const p=s.state.terminals[t.terminal.id],b=p?.activity==="busy",y=t.terminal.activity==="busy",S=t.terminal.activity==="idle",w=DA(r);if(t.notifyCompletion===!0&&y&&w.add(t.terminal.id),t.notifyCompletion===!0&&b&&S&&w.has(t.terminal.id)){const k=SA(o,t.terminal.id);k&&(h={terminalId:t.terminal.id,tabId:k.tab.id,commandName:p?.currentCommand??null},(k.workspace.activeTabId!==k.tab.id||k.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id))))}(S||t.terminal.status==="exited")&&w.delete(t.terminal.id)}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=wA(o,t.tabId)?.tab??null;else{const y=o.workspaces.find(S=>S.id===t.workspaceId);p=y?.tabs.find(S=>S.id===y.activeTabId)??null}const b=p?ji(p.root):[];if(b.some(y=>c.has(y))){const y=new Set(c);for(const S of b)y.delete(S);c=y}}const f=o!==s.state,g=c!==s.unreadCompletions;if((f||g)&&Al(e,{...s,state:o,unreadCompletions:c}),g&&Lg(),h)for(const p of Array.from(Bm))p({agentId:e,...h})}function SA(e,t){for(const s of e.workspaces)for(const r of s.tabs)if(ji(r.root).includes(t))return{workspace:s,tab:r};return null}function wA(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 Om=new Set;function CA(e){return Om.add(e),()=>{Om.delete(e)}}function xA(){let e=0;for(const t of Ur.values())e+=t.unreadCompletions.size;return e}function Lg(){for(const e of Array.from(Om))e()}function EA(e,t){const s=Nt(e);if(!s.unreadCompletions.has(t))return;const r=new Set(s.unreadCompletions);r.delete(t),Al(e,{...s,unreadCompletions:r}),Lg()}function c0(e,t){const s=Nt(e);t!==s.state&&Al(e,{...s,state:t})}function dp(e,t){const s=Nt(e),r=t(s.editors);r!==s.editors&&Al(e,{...s,editors:r})}function Dr(e,t,s){const r=Nt(e);r.loaded===t&&r.error===s||Al(e,{...r,loaded:t,error:s})}function No(e,t,s){const r=Nt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===s||Al(e,{...r,layoutRevision:t,lastPersistedLayoutJson:s})}function kA(e){const t=Nt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function TA(e){const t=Nl(e),s=Ur.get(t);s&&s.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(s.mutable.saveCoord.saveTimer);const r=s?s.unreadCompletions.size>0:!1;Ur.delete(t),ac.delete(t),lc.delete(t),r&&Lg()}function fp(){for(const e of Ur.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Ur.clear(),ac.clear(),lc.clear()}function DA(e){let t=lc.get(e);return t||(t=new Set,lc.set(e,t)),t}function zm(e,t){let s=!1,r=!1,o=null,c=!1;for(const h of sc(e)){const f=t[h];if(f){if(f.status==="exited"){c=!0,s=!0;continue}f.activity==="busy"?(r=!0,s=!0,!o&&f.currentCommand&&(o=f.currentCommand)):f.activity==="idle"&&(s=!0)}}return s?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Bg(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function jm(e,t){const s=t[e.activeTerminalId];return e.title||s?.title||e.activeTerminalId}function RA(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 MA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:f,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:b,onSplitVertical:y,onSplitHorizontal:S,onRenameTab:w,activePaneAvailable:k}){const[T,B]=v.useState(null),[L,A]=v.useState(!1),[W,I]=v.useState(null),ee=v.useRef(null),se=e.findIndex(j=>j.id===t),ae=se>=0?e[se]:e[0]??null,oe=ae?zm(ae,s):null,ve=ae?Tm(ae):0,U=ae?jm(ae,s):"No tab";v.useEffect(()=>{ee.current?.focus(),ee.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!L)return;const j=te=>{te.key==="Escape"&&A(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[L]),v.useEffect(()=>{L&&e.length===0&&A(!1)},[L,e.length]);function K(j,te){B({tabId:j,title:te})}function Y(){if(!T)return;const j=T.title.trim();j&&w(T.tabId,j),B(null)}function H(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${Fk()}`,onClick:y,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${qk()}`,onClick:S,disabled:!k,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:f,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:U,onClick:()=>A(!0),disabled:e.length===0,children:[oe?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":oe.state,"aria-hidden":"true",title:Bg(oe)}):null,m.jsx("span",{children:U}),m.jsxs("small",{children:[se>=0?se+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((j,te)=>{const N=sc(j),$=Tm(j),X=jm(j,s),Se=j.id===t,De=T?.tabId===j.id,R=zm(j,s),G=r?.has(j.id)??!1;return m.jsxs(xi.Fragment,{children:[m.jsx(u0,{index:te}),m.jsx(NA,{tab:j,active:Se,editing:De,title:X,paneCount:$,terminalIds:N,canClose:e.length>1,editValue:De?T.title:null,editInputRef:De?ee:null,activity:R,unread:G,onSelect:()=>c(j.id),onBeginRename:()=>K(j.id,X),onCloseAll:()=>g(N),onCommitRename:Y,onCancelRename:()=>B(null),onRenameChange:ce=>B({tabId:j.id,title:ce})})]},j.id)}),m.jsx(u0,{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(j=>m.jsx(LA,{terminal:j,onReattach:()=>p?.(j.id),onDelete:()=>I(j)},j.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),k?H():null]}),L?m.jsx(AA,{tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:T,editInputRef:ee,onClose:()=>A(!1),onSelectTab:j=>{c(j),A(!1)},onCreateTab:()=>{h(),A(!1)},onBeginRename:K,onCloseTerminals:j=>{g(j),A(!1)},onCommitRename:Y,onCancelRename:()=>B(null),onRenameChange:(j,te)=>B({tabId:j,title:te}),onReattachTerminal:j=>{p?.(j),A(!1)},onDeleteTerminal:j=>{I(j),A(!1)}}):null,W?m.jsx(BA,{terminal:W,onCancel:()=>I(null),onConfirm:()=>{b?.(W.id),I(null)}}):null]})}function NA({tab:e,active:t,editing:s,title:r,paneCount:o,canClose:c,editValue:h,editInputRef:f,activity:g,unread:p,onSelect:b,onBeginRename:y,onCloseAll:S,onCommitRename:w,onCancelRename:k,onRenameChange:T}){const{attributes:B,listeners:L,setNodeRef:A,transform:W,isDragging:I}=F0({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:s}),ee={transform:vp.Translate.toString(W),opacity:I?.4:void 0,zIndex:I?2:void 0};return m.jsxs("div",{ref:A,className:"terminal-tab","data-active":t,"data-dragging":I,"data-unread":p?"true":void 0,style:ee,...B,...L,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Bg(g)}):null,s&&f&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:se=>{se.preventDefault(),w()},children:[m.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:h,onBlur:w,onChange:se=>T(se.target.value),onKeyDown:se=>{if(se.key==="Enter"){se.preventDefault(),w();return}se.key==="Escape"&&(se.preventDefault(),k())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:b,onDoubleClick:se=>{se.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:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),S()},children:"x"}):null]})}function AA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:f,onSelectTab:g,onCreateTab:p,onBeginRename:b,onCloseTerminals:y,onCommitRename:S,onCancelRename:w,onRenameChange:k,onReattachTerminal:T,onDeleteTerminal:B}){const L=v.useRef(null);return v.useEffect(()=>{L.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:f,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:A=>A.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:p,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:f,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((A,W)=>{const I=sc(A),ee=Tm(A),se=jm(A,s),ae=A.id===t,oe=c?.tabId===A.id,ve=zm(A,s),U=r?.has(A.id)??!1;return m.jsxs("div",{ref:ae?L:null,className:"mobile-tab-sheet-row","data-active":ae,"data-unread":U?"true":void 0,children:[oe&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:K=>{K.preventDefault(),S()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${se}`,value:c.title,onBlur:S,onChange:K=>k(A.id,K.target.value),onKeyDown:K=>{if(K.key==="Enter"){K.preventDefault(),S();return}K.key==="Escape"&&(K.preventDefault(),w())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${se}`,onClick:()=>g(A.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:W+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:se}),m.jsx("small",{children:RA(A,s,ee,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:Bg(ve)}):null,m.jsx("span",{children:ee})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[oe?m.jsx("button",{type:"button","aria-label":`Done renaming ${se}`,onClick:S,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${se}`,onClick:()=>b(A.id,se),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${se}`,onClick:()=>y(I),children:"×"}):null]})]},A.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(A=>{const W=A.title||A.cwd||A.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 ${W}`,onClick:()=>T(A.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:W}),m.jsx("small",{children:A.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 ${W}`,onClick:()=>B(A),children:"×"})})]},A.id)})]}):null]})]})})}function u0({index:e}){const{setNodeRef:t,isOver:s}=Qm({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 LA({terminal:e,onReattach:t,onDelete:s}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
54
|
+
${e.cwd}
|
|
55
|
+
(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 BA({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 OA({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",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${UA(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 ${f>0?`(${f} 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(zA,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function zA({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",f=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:[f?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(jA,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(HA,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function jA({toast:e}){const t=e.percent===null?IA(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 HA({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,f)=>m.jsx(PA,{result:h},`${h.relativePath}-${f}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function PA({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 UA(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 IA(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function KA({toast:e,onActivate:t,onDismiss:s}){if(!e)return null;const r=e,o=r.commandName?`${r.commandName} finished`:"Command finished";function c(f){f.stopPropagation(),s()}function h(f){f.target===f.currentTarget&&(f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),t(r)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[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,onPointerDown:f=>f.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const WA=Io(0,0,1,1),Vs=1e-6;function FA(e){return $1(e).map(t=>t.terminalId)}function $1(e){return Uo(e,WA).sort(YA).map((t,s)=>({...t,index:s+1}))}function qA(e,t,s){const r=$1(e),o=r.find(h=>h.terminalId===t);return o?r.filter(h=>h.terminalId!==t).map(h=>VA(o,h,s)).filter(h=>h!==null).sort(XA)[0]?.entry.terminalId??null:null}function $A(e,t){return!Number.isInteger(t)||t<1?null:FA(e)[t-1]??null}function Uo(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const s=GA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*s;return[...Uo(e.first,Io(t.left,t.top,o,t.bottom)),...Uo(e.second,Io(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*s;return[...Uo(e.first,Io(t.left,t.top,t.right,r)),...Uo(e.second,Io(t.left,r,t.right,t.bottom))]}function VA(e,t,s){const r=e.bounds,o=t.bounds,c=h0(r.left,r.right,o.left,o.right),h=h0(r.top,r.bottom,o.top,o.bottom);switch(s){case"left":return o.centerX>=r.centerX-Vs||h<=Vs?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+Vs||h<=Vs?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-Vs||c<=Vs?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+Vs||c<=Vs?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function YA(e,t){return _l(e.bounds.top,t.bounds.top)||_l(e.bounds.left,t.bounds.left)}function XA(e,t){return _l(e.primaryDistance,t.primaryDistance)||_l(e.perpendicularDistance,t.perpendicularDistance)||_l(t.overlap,e.overlap)||_l(e.entry.index,t.entry.index)}function _l(e,t){const s=e-t;return Math.abs(s)<=Vs?0:s}function h0(e,t,s,r){return Math.max(0,Math.min(t,r)-Math.max(e,s))}function Io(e,t,s,r){return{left:e,top:t,right:s,bottom:r,centerX:e+(s-e)/2,centerY:t+(r-t)/2}}function GA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class ZA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function d0(e){return e?Array.from(e.types??[]).includes("Files")||G1(e.items).some(s=>s.kind==="file")?!0:Z1(e.files).length>0:!1}async function QA(e){const t=G1(e.items).filter(s=>s.kind==="file");return t.length>0?JA(t):e5(e.files)}async function JA(e){const t=[];for(const s of e){const r=s5(s);if(r){await V1(r,"",t);continue}const o=s.getAsFile();if(o){t.push({relativePath:Y1(o),file:o});continue}throw new ZA("Folder upload is not supported by this browser.")}return t}function e5(e){return Z1(e).map(t=>({relativePath:Y1(t),file:t}))}async function V1(e,t,s){const r=a5(t,e.name);if(e.isFile){const h=await t5(e);s.push({relativePath:r,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await i5(o);for(const h of c)await V1(h,r,s)}function t5(e){return new Promise((t,s)=>{e.file(t,r=>s(r))})}async function i5(e){const t=[];for(;;){const s=await n5(e);if(s.length===0)return t;t.push(...s)}}function n5(e){return new Promise((t,s)=>{e.readEntries(t,r=>s(r))})}function Y1(e){const t=e.webkitRelativePath;return X1(typeof t=="string"&&t?t:e.name)}function s5(e){const t=e.webkitGetAsEntry?.();return r5(t)?t:null}function r5(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 a5(e,t){return X1(e?`${e}/${t}`:t)}function X1(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function G1(e){return e?Array.from(e):[]}function Z1(e){return e?Array.from(e):[]}const f0="nterminal.terminalWorkspaces.v2",Q1="nterminal.sidebarCollapsed.v1",l5=75,p0=V0.map(e=>e.url),o5=V0[0].url,c5=6;function u5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:h}){const f=v.useMemo(()=>e??ph(),[e]),g=v.useMemo(()=>t??Go(null),[t]),p=v.useMemo(()=>D5(s),[s]),b=v.useMemo(()=>x=>q1(s,x),[s]),y=v.useMemo(()=>()=>Nt(s),[s]),S=v.useSyncExternalStore(b,y,y),w=S.state,k=S.editors,T=!S.loaded,B=S.error,[L,A]=v.useState(!1),[W,I]=v.useState(()=>O5()),[ee,se]=v.useState("servers"),[ae,oe]=v.useState(!1),ve=v.useSyncExternalStore(tT,Ib,Ib);v.useSyncExternalStore(ug,Ub,Ub);const[U,K]=v.useState(0),[Y,H]=v.useState(null),[j,te]=v.useState(()=>[null]),[N,$]=v.useState(0),[X,Se]=v.useState(()=>[s]),[De,R]=v.useState(()=>new Set),[G,ce]=v.useState({}),[me,xe]=v.useState(null),Ee=v.useRef(0),Me=v.useRef(0),[qe,ge]=v.useState(null),[Q,he]=v.useState(null),we=v.useRef(null),_e=v.useRef(0),Te=v.useRef(null),Be=v.useRef(null),Ie=v.useRef(null),[le,Ce]=v.useState(null),Ne=BE(wb(P0,{activationConstraint:{distance:8}}),wb(U0,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>iT(f),[f]);function Oe(x){const E=x.active.data.current;if(E){if(E.kind==="tab"&&typeof E.tabId=="string"&&typeof E.terminalId=="string"){Ce({tabId:E.tabId,terminalId:E.terminalId});return}E.kind==="pane"&&typeof E.sourceTabId=="string"&&typeof E.terminalId=="string"&&Ce({tabId:E.sourceTabId,terminalId:E.terminalId})}}function je(x){Ce(null);const E=x.active.data.current,z=x.over?.data.current;if(!(!E||!z||typeof E.terminalId!="string")){if(E.kind==="tab"&&typeof E.tabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){it({type:"tab.reordered",sourceTabId:E.tabId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){it({type:"tab.moved_to_workspace",sourceTabId:E.tabId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&it({type:"tab.dropped_into_pane",sourceTabId:E.tabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side});return}if(E.kind==="pane"&&typeof E.sourceTabId=="string"){if(z.kind==="tab-position"&&typeof z.index=="number"){it({type:"terminal.extracted_to_tab",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetIndex:z.index});return}if(z.kind==="workspace"&&typeof z.workspaceId=="string"){it({type:"terminal.extracted_to_workspace",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetWorkspaceId:z.workspaceId});return}z.kind==="pane-zone"&&typeof z.terminalId=="string"&&(z.side==="top"||z.side==="right"||z.side==="bottom"||z.side==="left")&&it({type:"tab.dropped_into_pane",sourceTabId:E.sourceTabId,sourceTerminalId:E.terminalId,targetTerminalId:z.terminalId,side:z.side})}}}function mt(){Ce(null)}const Xe=w.workspaces.find(x=>x.id===w.activeWorkspaceId)??w.workspaces[0],st=Xe?.tabs.find(x=>x.id===Xe.activeTabId)??Xe?.tabs[0],Qt=st?.activeTerminalId??null,sn=Qt?w.terminals[Qt]:void 0,ki=E5("(max-width: 760px)"),Jt=v.useMemo(()=>st?hh(st.root):[],[st]),Ti=Xe&&st?Ko(s,Xe.id,st.id):null,Gn=st?J1(Jt,st.activeTerminalId,Ti?G[Ti]:void 0):null,F=ki&&Jt.length>1,$e=v.useMemo(()=>(Xe?.detachedTerminalIds??[]).flatMap(x=>{const E=w.terminals[x];return E?[E]:[]}),[Xe?.detachedTerminalIds,w.terminals]),ot=v.useMemo(()=>{const x=new Set;for(const E of Xe?.tabs??[])sc(E).some(z=>S.unreadCompletions.has(z))&&x.add(E.id);return x},[Xe?.tabs,S.unreadCompletions]),[wt,li]=v.useState([]),Dt=v.useRef([]),rn=v.useRef(null),[Zn,Qn]=v.useState(null),[Rt,Pi]=v.useState(null),[gt,_t]=v.useState([]),[Ct,Di]=v.useState(()=>Sa()),oi=v.useRef(0),qt=v.useRef(s),ci=v.useRef(p0),_i=v.useRef(Ct),Ht=v.useRef(()=>{});Ht.current=er;const Ri=v.useCallback(async()=>{try{const x=await f.listNotificationAssets();_t(x.assets.filter(E=>E.enabled).map(E=>E.url))}catch{_t([])}},[f]);v.useEffect(()=>{Se(x=>x.some(E=>fn(E,s))?x:[...x,s])},[s]);const ei=v.useCallback(x=>{const E=Nt(x),z=Go(x);for(const ne of Object.keys(E.state.terminals))Po(z.createWebSocketUrl(ne)),Mu(ne);TA(x),Se(ne=>ne.filter(ye=>!fn(ye,x))),R(ne=>{const ye=`${$u(x)}:`;let pe=!1;const be=new Set;for(const Pe of ne){if(Pe.startsWith(ye)){pe=!0;continue}be.add(Pe)}return pe?be:ne}),ce(ne=>{const ye=`${$u(x)}:`;let pe=!1;const be={};for(const[Pe,nt]of Object.entries(ne)){if(Pe.startsWith(ye)){pe=!0;continue}be[Pe]=nt}return pe?be:ne})},[]);v.useEffect(()=>{let x=!1;return f.listAgents().then(E=>{if(!x){const z=E.agents.map(ye=>ye.id),ne=[null,...z];s!==null&&!z.includes(s)&&(ei(s),r?.(null)),te(ne)}}).catch(()=>{}),()=>{x=!0}},[s,f,ei,r,N]);const vi=v.useCallback(x=>{ei(x),$(E=>E+1),fn(x,qt.current)&&r?.(null)},[ei,r]);v.useEffect(()=>{te(x=>x.some(E=>fn(E,s))?x:[...x,s])},[s]),v.useEffect(()=>{qt.current=s},[s]),v.useEffect(()=>{H(null)},[s]),v.useEffect(()=>{const x=Te.current;if(!x)return;if(!fn(x.agentId,s)){Te.current=null;return}if(!S.loaded||w.workspaces.length===0)return;Te.current=null;const E=x.edge==="first"?w.workspaces[0]:w.workspaces[w.workspaces.length-1];E&&E.id!==w.activeWorkspaceId&&it({type:"workspace.selected",workspaceId:E.id})},[s,S.loaded,w.activeWorkspaceId,w.workspaces]),v.useEffect(()=>{const x=Be.current;if(x){if(!fn(x.agentId,s)){Be.current=null;return}S.loaded&&(Be.current=null,w.workspaces.some(E=>E.id===x.workspaceId)&&it({type:"workspace.selected",workspaceId:x.workspaceId}))}},[s,S.loaded,w.workspaces]),v.useEffect(()=>{const x=Ie.current;if(x){if(!fn(x.agentId,s)){Ie.current=null;return}S.loaded&&(Ie.current=null,S.error||gn())}},[s,S.error,S.loaded]),v.useEffect(()=>{Ri()},[Ri]),v.useEffect(()=>tw(()=>Di(Sa())),[]),v.useEffect(()=>{const x=E=>{Ht.current(E)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{ci.current=gt.length>0?gt:p0},[gt]),v.useEffect(()=>{_i.current=Ct},[Ct]),v.useEffect(()=>{if(!S.loaded||!Xe||!st)return;const x=Ko(s,Xe.id,st.id);R(E=>{if(E.has(x))return E;const z=new Set(E);return z.add(x),z})},[s,S.loaded,Xe?.id,st?.id]),v.useEffect(()=>()=>{Pt()},[]),v.useEffect(()=>bA(x=>{const E=Nt(x.agentId).state,z=E.workspaces.flatMap(be=>be.tabs).find(be=>be.id===x.tabId),ne=E.terminals[x.terminalId],ye=z?.title?.trim()||ne?.title||x.commandName||"terminal",pe=document.visibilityState==="visible"&&fn(x.agentId,qt.current)&&x.tabId===T5(E);if(pe||Ok({tabTitle:ye,commandName:x.commandName,terminalId:x.terminalId}),!pe&&document.visibilityState==="visible"&&_i.current.enabled){const be=oi.current+1;oi.current=be;const Pe=ci.current;Qn({id:be,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:ye,commandName:x.commandName,assetSrc:Pe[Math.floor(Math.random()*Pe.length)]??o5})}}),[]),v.useEffect(()=>{if(!Zn||Ct.persistUntilDismissed)return;const x=window.setTimeout(()=>{Qn(E=>E?.id===Zn.id?null:E)},Ct.durationSeconds*1e3);return()=>window.clearTimeout(x)},[Zn,Ct]),v.useEffect(()=>{z5(W),W&&Zi()},[W]),v.useEffect(()=>{let x=!1;async function E(){if(!Nt(s).loaded){Dr(s,!1,null);try{let ne=null,ye=null;try{ne=R5(p)}catch(nt){if(!(nt instanceof fh))throw nt;ye=nt}const[pe,be]=await Promise.all([g.listTerminals(),g.getTerminalLayout()]),Pe=pe.terminals.length>0?pe.terminals:[(await g.createTerminal({cols:80,rows:24})).terminal];if(!x){const nt=be.layout?tC(be.layout):null;if(!nt&&ye)throw ye;const Vt=nt??ne??{},ni=km(Pe,void 0,Vt.savedWorkspaces,Vt.savedActiveWorkspaceId),Ba=hp(ni);c0(s,ni),No(s,be.revision,JSON.stringify(Ba)),Dr(s,!0,null),!nt&&ne&&ii(Ba,{baseRevision:be.revision})}}catch(ne){!x&&!Js(ne)&&Dr(s,!0,Rr(ne))}}}return E(),()=>{x=!0}},[s,g,U]);function mn(){Dr(s,!1,null),K(x=>x+1)}function Zi(){Ee.current+=1,Me.current+=1,xe(null)}function Qi(x){Ee.current+=1,Me.current+=1,xe(E=>E&&{...E,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function gn(){Ee.current+=1,Me.current+=1;const x=w.workspaces.length+1,E=yi();xe({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:E,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),E&&Nn(E)}function $i(x){if(fn(x,s)){gn();return}Ie.current={agentId:x},r?.(x)}function Kt(x){if(W&&!L)return;const E=w.workspaces.find(ne=>ne.id===x);if(!E)return;Ee.current+=1,Me.current+=1;const z=E.defaultCwd??sn?.cwd??"";xe({mode:"edit",workspaceId:x,title:E.title,cwd:z,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),z&&Nn(z)}function yi(){return Xe?.defaultCwd??sn?.cwd??""}async function Nn(x){const E=Ee.current+1;Ee.current=E;const z=x.trim();if(xe(ne=>ne&&{...ne,cwd:x,browseStatus:z?"loading":"idle",browseRoot:null,browseEntries:[],error:z?null:"Choose a default working directory."}),!!z)try{const ne=await g.createFileRoot({path:z}),ye=await g.listFiles({rootToken:ne.rootToken,path:""});if(Ee.current!==E)return;xe(pe=>pe&&{...pe,cwd:ne.rootPath,browseRoot:{rootToken:ne.rootToken,rootPath:ne.rootPath},browseEntries:ye.entries.filter(be=>be.kind==="directory"),browseStatus:"idle",error:null})}catch(ne){if(Ee.current!==E)return;xe(ye=>ye&&{...ye,browseStatus:"idle",error:Rr(ne)})}}async function Ir(){const x=me;if(!x)return;const E=x.title.trim(),z=x.cwd.trim();if(!E||!z){xe({...x,submitStatus:"idle",error:E?"Choose a default working directory.":"Workspace name is required."});return}const ne=Me.current+1;Me.current=ne,xe({...x,submitStatus:"submitting",error:null});try{const ye=await g.createFileRoot({path:z});if(Me.current!==ne)return;if(x.mode==="create"){const pe=w.workspaces.length+1;it({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${pe}`,title:E,defaultCwd:ye.rootPath})}else x.workspaceId&&(it({type:"workspace.renamed",workspaceId:x.workspaceId,title:E}),it({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:ye.rootPath}));xe(null)}catch(ye){if(Me.current!==ne)return;xe(pe=>pe&&{...pe,submitStatus:"idle",error:Rr(ye)})}}function Ll(x){Me.current+=1,xe(x)}function Qs(x,E,z){if(x===E)return;const ne=w.workspaces.some(pe=>pe.id===x),ye=w.workspaces.some(pe=>pe.id===E);!ne||!ye||it({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:E,placement:z})}function Ra(x,E){const z=w.workspaces.findIndex(ye=>ye.id===x),ne=w.workspaces[z+E];z<0||!ne||Qs(x,ne.id,E<0?"before":"after")}function An(x,E){E.pointerType==="mouse"&&E.button!==0||(E.preventDefault(),E.stopPropagation(),we.current={sourceId:x,pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,active:!1,targetId:null,placement:"after"},E.currentTarget.setPointerCapture?.(E.pointerId))}function Ln(x){const E=we.current;if(!E||E.pointerId!==x.pointerId)return;const z=Math.hypot(x.clientX-E.startX,x.clientY-E.startY);if(!E.active){if(z<c5)return;E.active=!0,ge(E.sourceId)}const ye=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),pe=ye?.dataset.workspaceId??null;if(!ye||!pe||pe===E.sourceId||!w.workspaces.some(nt=>nt.id===pe)){E.targetId=null,he(null);return}const be=ye.getBoundingClientRect(),Pe=x.clientY<be.top+be.height/2?"before":"after";E.targetId=pe,E.placement=Pe,he({workspaceId:pe,placement:Pe})}function Bn(x){const E=we.current;!E||E.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),we.current=null,ge(null),he(null),E.active&&E.targetId&&Qs(E.sourceId,E.targetId,E.placement))}function Lt(x){const E=we.current;E&&E.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),we.current=null,ge(null),he(null)}async function Jn(){await ti(async()=>{const x=Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},E=await g.createTerminal(x);it({type:"terminal.created",terminal:E.terminal})})}async function _n(x){await ti(async()=>{const E=Qt?{parentTerminalId:Qt,cols:80,rows:24}:Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},z=await g.createTerminal(E);it({type:"terminal.split",terminal:z.terminal,direction:x})})}async function Bt(x){let E=Qt,z=Ti;const ne=Xe?.defaultCwd?.trim();if(!E&&!ne)throw new Error("No active pane is available.");const ye=await g.readFile(x);if(!E&&ne){const Pe=await g.createTerminal({cols:80,rows:24,cwd:ne});E=Pe.terminal.id,it({type:"terminal.created",terminal:Pe.terminal})}if(E){it({type:"pane.selected",terminalId:E});const Pe=Nt(s).state,nt=Pe.workspaces.find(ni=>ni.id===Pe.activeWorkspaceId)??Pe.workspaces[0],Vt=nt?.tabs.find(ni=>ni.id===nt.activeTabId)??nt?.tabs[0];z=nt&&Vt?Ko(s,nt.id,Vt.id):null}const pe=`editor-${Date.now().toString(36)}-${kA(s)}`,be=B5(ye.path);dp(s,Pe=>({...Pe,[pe]:{id:pe,title:be,rootToken:x.rootToken,path:ye.path,read:ye}})),z&&ce(Pe=>({...Pe,[z]:eC(pe)})),it({type:"editor.split",editorId:pe,title:be,direction:"vertical"})}function ui(x){dp(s,E=>{const z={...E};return delete z[x],z}),it({type:"editor.closed",editorId:x})}function Ma(x){vn([x])}function vn(x){const E=[...new Set(x)].filter(ne=>w.terminals[ne]);if(E.length===0)return;const z=E.length===1?w.terminals[E[0]]?.title||w.terminals[E[0]]?.cwd||E[0]:`${E.length} panes`;H(null),Pi({terminalIds:E,label:z,workspaceId:Xe?.id??w.activeWorkspaceId??null})}function es(x,E){const z=tr(x,E);if(!z)return!1;const ne=x.filter(ye=>!z.detachedTerminalIds.includes(ye));if(z.detachedTerminalIds.length+ne.length>Dl)return H(N5(z.detachedTerminalIds.length)),!1;H(null);for(const ye of x)it(z.id?{type:"terminal.detached",terminalId:ye,workspaceId:z.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Na(x){await ti(async()=>{for(const E of x)await ds(E),Po(g.createWebSocketUrl(E)),Mu(E),it({type:"terminal.closed",terminalId:E})})}async function Aa(x){const E=w.workspaces.find(z=>z.id===x);!E||w.workspaces.length<=1||window.confirm(`Delete workspace "${E.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await ti(async()=>{const z=uh(E),ne=[];let ye=null;for(const be of z)try{await ds(be)}catch(Pe){ne.push(Rr(Pe)),Pe instanceof os&&Pe.status===401&&!g.isAgent&&(ye=Pe)}finally{Po(g.createWebSocketUrl(be)),Mu(be)}const pe=E.tabs.flatMap(be=>Hm(be.root));if(pe.length>0){const be=new Set(pe);dp(s,Pe=>{const nt={...Pe};for(const Vt of be)delete nt[Vt];return nt})}if(it({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 Kr(x){await ti(async()=>{await ds(x),Po(g.createWebSocketUrl(x)),Mu(x),it({type:"terminal.closed",terminalId:x})})}async function ts(x,E){const z=E.trim();if(!z)return;let ne=null;for(const ye of w.workspaces){const pe=ye.tabs.find(be=>be.id===x);if(pe){ne=pe.activeTerminalId;break}}if(it({type:"tab.renamed",tabId:x,title:z}),!!ne)try{const ye=await g.renameTerminal(ne,z);is({type:"terminal.updated",terminal:ye.terminal})}catch(ye){Dr(s,!0,Rr(ye))}}function hs(x){const E=w.terminals[x];E&&it({type:"terminal.created",terminal:E})}async function ds(x){try{await g.closeTerminal(x)}catch(E){if(E instanceof os&&E.status===404)return;throw E}}async function an(){await ti(async()=>{await c()})}async function ti(x){Dr(s,!0,null);try{await x()}catch(E){if(Js(E))return;Dr(s,!0,Rr(E))}}function Js(x){return x instanceof os&&x.status===401&&!g.isAgent&&h?(h({source:"workspace-api-401",status:401,activeAgentId:s}),!0):!1}function it(x){Mo(s,x);const E=Nt(s),z=E.state;if(!E.loaded||z.workspaces.length===0)return;const ne=hp(z);JSON.stringify(ne)!==E.lastPersistedLayoutJson&&Je(ne)}function is(x){Mo(s,x)}function Es(x,E,z,ne){const ye=Ko(x,E,z);ce(pe=>({...pe,[ye]:ne}))}function ks(x){Ti&&ce(E=>({...E,[Ti]:x}))}function Wr(x,E){const z=dh(x);E?Es(s,E.workspaceId,E.tabId,z):ks(z),it({type:"pane.selected",terminalId:x})}function Vi(x){ks(x.key),x.type==="terminal"&&it({type:"pane.selected",terminalId:x.terminalId})}function er(x){if(ae||Rt||x.isComposing||x.key==="Process"||g5(x.target))return;const E=d5(x);if(!E)return;if(x.preventDefault(),x.stopPropagation(),E.type==="server.previous"||E.type==="server.next"){qr(E.type==="server.next"?1:-1);return}const z=Nt(s).state,ne=z.workspaces.find(be=>be.id===z.activeWorkspaceId)??z.workspaces[0],ye=ne?.tabs.find(be=>be.id===ne.activeTabId)??ne?.tabs[0];if(E.type==="split"){if(!ye)return;_n(E.direction);return}if(!ne||!ye)return;if(E.type==="tab.previous"||E.type==="tab.next"){const be=m5(ne.tabs,ye.id,E.type==="tab.next"?1:-1);be&&it({type:"tab.selected",tabId:be.id});return}if(E.type==="tab.index"){const be=ne.tabs[E.index-1];be&&it({type:"tab.selected",tabId:be.id});return}const pe=f5(ye.root,ye.activeTerminalId,E);pe&&Wr(pe,{workspaceId:ne.id,tabId:ye.id})}function Fr(x,E){if(!r||j.length===0)return;const z=j.findIndex(be=>fn(be,s)),ye=((z===-1?0:z)+x+j.length)%j.length,pe=j[ye]??null;fn(pe,s)||(E&&(Te.current={agentId:pe,edge:E}),r(pe))}function qr(x){const E=Nt(s).state,z=E.workspaces;if(z.length===0){Fr(x,x===1?"first":"last");return}const ne=z.findIndex(be=>be.id===E.activeWorkspaceId),pe=(ne===-1?0:ne)+x;if(pe>=0&&pe<z.length){it({type:"workspace.selected",workspaceId:z[pe].id});return}Fr(x,x===1?"first":"last")}function fs(x,E){if(fn(x,s)){it({type:"workspace.selected",workspaceId:E});return}Be.current={agentId:x,workspaceId:E},r?.(x)}function tr(x,E){if(E)return w.workspaces.find(z=>z.id===E)??null;for(const z of x){const ne=w.workspaces.find(pe=>pe.tabs.some(be=>sc(be).includes(z)));if(ne)return ne;const ye=w.workspaces.find(pe=>pe.detachedTerminalIds.includes(z));if(ye)return ye}return w.workspaces.find(z=>z.id===w.activeWorkspaceId)??w.workspaces[0]??null}function ns(x){d0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function ps(x){if(!d0(x.dataTransfer))return;x.preventDefault();const E=A5(Nt(s).state),z=_e.current+1;if(_e.current=z,!E){ir({id:z,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}ir({id:z,status:"queued",fileCount:0,terminalId:E.id,message:"Preparing upload..."}),Bl(z,E.id,x.dataTransfer)}async function Bl(x,E,z){try{const ne=await QA(z);if(ne.length===0)throw new Error("No files were found in the drop.");On(x,{id:x,status:"queued",fileCount:ne.length,message:"Queued"},{terminalId:E,files:ne})}catch(ne){On(x,{id:x,status:"failed",fileCount:0,message:Rr(ne)},{terminalId:E})}finally{Yi()}}async function La(x){const E=Dt.current.find(pe=>pe.id===x);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=E.terminalId,ne=E.files,ye=new AbortController;rn.current=x,On(x,{id:x,status:"uploading",fileCount:ne.length,loaded:0,total:null,percent:null},{terminalId:z,files:ne,abortController:ye});try{const pe=await gT({terminalId:z,files:ne,signal:ye.signal,onProgress:Vt=>{On(x,{id:x,status:"uploading",fileCount:ne.length,loaded:Vt.loaded,total:Vt.total,percent:Vt.percent},{terminalId:z,files:ne,abortController:ye})}}),be=pe.failed>0?pe.uploaded>0?"partial":"failed":"success",Pe=pe.failed>0?L5(pe):void 0,nt={id:x,status:be,fileCount:ne.length,response:pe};Pe&&(nt.message=Pe),On(x,nt,{terminalId:z,files:ne})}catch(pe){On(x,{id:x,status:"failed",fileCount:ne.length,message:ye.signal.aborted?"Upload canceled.":Rr(pe)},{terminalId:z,files:ne})}finally{rn.current===x&&(rn.current=null),Yi()}}function Yi(){if(rn.current!==null)return;const x=Dt.current.find(E=>E.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&La(x.id)}function ir(x){Ts(E=>[...E,x])}function On(x,E,z={}){Ts(ne=>ne.map(ye=>{if(ye.id!==x)return ye;const pe={...E},be=z.terminalId??ye.terminalId,Pe=z.files??ye.files;return be!==void 0&&(pe.terminalId=be),Pe!==void 0&&(pe.files=Pe),z.abortController!==void 0&&(pe.abortController=z.abortController),pe}))}function Ts(x){const E=x(Dt.current);Dt.current=E,li(E)}function Ds(x){Dt.current.find(z=>z.id===x)?.abortController?.abort(),rn.current===x&&(rn.current=null),Ts(z=>z.filter(ne=>ne.id!==x)),Yi()}function D(){for(const x of Dt.current)x.abortController?.abort();rn.current=null,Ts(()=>[])}function ie(x){const E=Dt.current.find(z=>z.id===x);if(E){if(E.status==="queued"){Ds(x);return}E.abortController?.abort()}}function He(x){const E=Dt.current.find(ne=>ne.id===x);if(!E?.terminalId||!E.files||E.files.length===0)return;const z=Ke(E);if(z.length===0){On(x,{id:x,status:"failed",fileCount:E.fileCount,message:"No failed files are available to retry."},{terminalId:E.terminalId,files:E.files});return}On(x,{id:x,status:"queued",fileCount:z.length,message:"Queued"},{terminalId:E.terminalId,files:z}),Yi()}function Ke(x){const E=x.files??[],z="response"in x?x.response:void 0;if(!z)return E;const ne=z.results.filter(be=>be.status==="failed").map(be=>be.relativePath);if(ne.length===0)return[];const ye=new Map;for(const be of E){const Pe=ye.get(be.relativePath)??[];Pe.push(be),ye.set(be.relativePath,Pe)}const pe=[];for(const be of ne){const nt=ye.get(be)?.shift();nt&&pe.push(nt)}return pe}function We(x){const z=Nt(x.agentId).state.workspaces.find(ne=>ne.tabs.some(ye=>ye.id===x.tabId));z&&Es(x.agentId,z.id,x.tabId,dh(x.terminalId)),Mo(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),EA(x.agentId,x.terminalId),fn(x.agentId,s)||r?.(x.agentId),Qn(null)}function Je(x){const E=Nt(s).mutable.saveCoord;E.pendingLayoutSave=x,Ao(x,p),E.saveTimer!==null&&window.clearTimeout(E.saveTimer),E.saveTimer=window.setTimeout(()=>{E.saveTimer=null;const z=E.pendingLayoutSave;E.pendingLayoutSave=null,z&&ii(z)},l5)}function Pt(){const x=Nt(s).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const E=x.pendingLayoutSave;x.pendingLayoutSave=null,E&&(Ao(E,p),ii(E))}function ii(x,E={}){const z=Nt(s).mutable.saveCoord;z.nextPersistLayout=x,E.baseRevision!==void 0&&(z.queuedBaseRevision=E.baseRevision),!z.nextPersistQueued&&(z.nextPersistQueued=!0,z.persistChain=z.persistChain.then(async()=>{z.nextPersistQueued=!1;const ne=z.nextPersistLayout,ye=z.queuedBaseRevision;z.nextPersistLayout=null,z.queuedBaseRevision=void 0,ne&&await vt(ne,ye!==void 0?{baseRevision:ye}:{})}))}async function vt(x,E={}){const z=Nt(s),ne=E.baseRevision??z.layoutRevision,ye={layout:x,...typeof ne=="number"?{baseRevision:ne}:{}};try{const pe=await g.saveTerminalLayout(ye),be=pe.layout??x;No(s,pe.revision,JSON.stringify(be)),Ao(be,p);return}catch(pe){if(pe instanceof os&&pe.status===400&&pe.message===I2){M5(s,p),Dr(s,!0,iC());return}if(pe instanceof os&&pe.status===409)try{const be=await g.getTerminalLayout(),Pe=Nt(s).mutable.saveCoord;if(Pe.nextPersistLayout||Pe.pendingLayoutSave){const nt=be.layout?JSON.stringify(be.layout):Nt(s).lastPersistedLayoutJson;No(s,be.revision,nt);return}if(be.layout){const nt=Nt(s).state,Vt=km(Object.values(nt.terminals),void 0,be.layout.workspaces,be.layout.activeWorkspaceId),ni=hp(Vt);c0(s,Vt),No(s,be.revision,JSON.stringify(ni)),Ao(ni,p)}else No(s,be.revision,z.lastPersistedLayoutJson);return}catch{}Ao(x,p)}}const yt=j5(o),Ui=!W||L,$t=Ui?ee:"servers";function yn(x){const E=x.active?S:Nt(x.agentId),z=x.active?w:E.state,ne=x.active?S.loaded:E.loaded,ye=x.active?B:E.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:()=>$i(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:z.workspaces.map(pe=>{const be=x.active&&pe.id===Xe?.id,Pe=uh(pe).length,nt=x.active&&z.workspaces.length>1,Vt=Q?.workspaceId===pe.id&&qe!==pe.id?Q.placement:null;return m.jsxs(S5,{workspaceId:pe.id,active:be,disabled:!x.active,reorderable:nt,dragging:qe===pe.id,dropPlacement:Vt,children:[nt?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":pe.id,title:"Drag to reorder","aria-label":`Reorder ${pe.title}`,"aria-grabbed":qe===pe.id,onPointerDown:ni=>An(pe.id,ni),onPointerMove:Ln,onPointerUp:Bn,onPointerCancel:Lt,onKeyDown:ni=>{(ni.key==="ArrowUp"||ni.key==="ArrowDown")&&(ni.preventDefault(),ni.stopPropagation(),Ra(pe.id,ni.key==="ArrowUp"?-1:1))},onClick:ni=>ni.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":be?"page":void 0,title:pe.defaultCwd??void 0,onClick:()=>fs(x.agentId,pe.id),onDoubleClick:()=>{x.active&&Kt(pe.id)},children:[m.jsx("span",{className:"workspace-list-name",children:pe.title}),m.jsxs("small",{children:[pe.defaultCwd??"No folder"," · ",Pe," ",Pe===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 ${pe.title}`,title:"Edit workspace",onClick:()=>Kt(pe.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${pe.title}`,title:"Delete workspace",disabled:z.workspaces.length<=1,onClick:()=>{Aa(pe.id)},children:"x"})]}):null]},pe.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(B2,{sensors:Ne,onDragStart:Oe,onDragEnd:je,onDragCancel:mt,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":W,"data-sidebar-open":L,onDragOver:ns,onDrop:ps,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>A(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[Ui?m.jsx(x0,{height:20}):m.jsx(C0,{size:24}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":W?"Expand sidebar":"Collapse sidebar",title:W?"Expand sidebar":"Collapse sidebar",onClick:()=>I(x=>!x),children:W?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>A(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${$t==="files"?"files":"servers"}`,children:[Ui?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":ee==="servers",onClick:()=>{se("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":ee==="files",onClick:()=>{se("files")},children:"Files"})]}):null,$t==="servers"&&Ui?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(zb,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:N,renderServerChildren:yn})}):null,Ui?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(zb,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:N,compact:!0})}),$t==="files"?m.jsx(ST,{api:g,activeTerminalId:Qt,activeTerminalCwd:sn?.cwd??null,workspaceRootPath:Xe?.defaultCwd??sn?.cwd??null,onOpenFile:Bt}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[Ui?m.jsx("span",{children:yt}):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(g0,{name:"settings"}),ve.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),Ui?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{an()},children:m.jsx(g0,{name:"logout"})}):null]})]})]}),ae?m.jsx(hT,{api:f,onClose:()=>oe(!1),updateAvailable:ve.hasUpdates,onNotificationAssetsChanged:()=>{Ri()},onAgentRemoved:vi}):null,me?m.jsx(_5,{dialog:me,activePaneCwd:sn?.cwd??null,activeWorkspaceCwd:Xe?.defaultCwd??null,onChange:Ll,onManualCwdChange:Qi,onBrowse:Nn,onCancel:Zi,onSubmit:()=>{Ir()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":F?"true":void 0,children:[m.jsx(MA,{tabs:Xe?.tabs??[],activeTabId:Xe?.activeTabId??null,terminals:w.terminals,unreadCompletionTabIds:ot,detachedTerminals:$e,onSelectTab:x=>it({type:"tab.selected",tabId:x}),onCreateTab:()=>{Jn()},onToggleWorkspaces:()=>A(x=>!x),onCloseTerminals:x=>vn(x),onReattachTerminal:x=>hs(x),onDeleteTerminal:x=>{Kr(x)},onSplitVertical:()=>{_n("vertical")},onSplitHorizontal:()=>{_n("horizontal")},onRenameTab:(x,E)=>{ts(x,E)},activePaneAvailable:!!Qt}),F?m.jsx(C5,{targets:Jt,activeLeafKey:Gn,terminals:w.terminals,editors:k,onSelect:Vi}):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:mn,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&&!st?m.jsx(b5,{onCreate:()=>{Jn()}}):null,X.map(x=>{const E=fn(x,s);return m.jsx(h5,{agentId:x,active:E,activeServerApi:E?g:void 0,visitedTabKeys:De,refreshCwdOnEnter:E&&$t==="files",draggingTab:E?le:null,mobileSplitFocus:ki,mobileFocusedLeafByTabKey:G,onSelect:z=>{E&&Wr(z)},onClose:z=>{E&&Ma(z)},onCloseEditor:z=>{E&&ui(z)},onResize:(z,ne)=>{E&&it({type:"pane.resized",path:z,ratio:ne})},onExit:(z,ne)=>{E?is({type:"terminal.exited",terminalId:z,exitCode:ne}):Mo(x,{type:"terminal.exited",terminalId:z,exitCode:ne})},onSnapshot:(z,ne)=>{const ye={type:"terminal.updated",terminal:z,notifyCompletion:ne?.notifyCompletion===!0};E?is(ye):Mo(x,ye)},...x===null&&h?{onAuthClose:z=>h({...z,source:z?.source??"terminal-ws-1008",activeAgentId:x})}:{}},$u(x))})]}),Rt?m.jsx(w5,{label:Rt.label,count:Rt.terminalIds.length,warning:Y,onCancel:()=>{H(null),Pi(null)},onHide:()=>{es(Rt.terminalIds,Rt.workspaceId)&&Pi(null)},onDelete:()=>{const x=Rt.terminalIds;H(null),Pi(null),Na(x)}}):null,m.jsx(KA,{toast:Zn,onActivate:We,onDismiss:()=>Qn(null)}),m.jsx(OA,{uploads:wt,onDismiss:Ds,onDismissAll:D,onRetry:He,onCancel:ie})]})]})})}function h5({agentId:e,active:t,activeServerApi:s,visitedTabKeys:r,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:f,onSelect:g,onClose:p,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,onAuthClose:k}){const T=v.useMemo(()=>ve=>q1(e,ve),[e]),B=v.useMemo(()=>()=>Nt(e),[e]),L=v.useSyncExternalStore(T,B,B),A=v.useMemo(()=>Go(e),[e]),W=s??A,I=L.state,ee=I.workspaces.find(ve=>ve.id===I.activeWorkspaceId)??I.workspaces[0],se=ee?.id??null,oe=(ee?.tabs.find(ve=>ve.id===ee.activeTabId)??ee?.tabs[0])?.id??null;return!L.loaded||I.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:I.workspaces.flatMap(ve=>ve.tabs.map(U=>{const K=t&&ve.id===se&&U.id===oe,Y=Ko(e,ve.id,U.id),H=hh(U.root),j=h&&H.length>1?J1(H,U.activeTerminalId,f[Y]):null;return!K&&!r.has(Y)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":K,"aria-hidden":!K,children:m.jsx(Cm,{node:U.root,terminals:I.terminals,editors:L.editors,api:W,activeTerminalId:U.activeTerminalId,visible:K,refreshCwdOnEnter:K&&o,tabId:U.id,dropZoneActive:K&&c!==null,draggingTerminalId:K?c?.terminalId??null:null,mobileFocusLeafKey:j,onSelect:g,onClose:p,onCloseEditor:b,onResize:y,onExit:S,onSnapshot:w,...k?{onAuthClose:k}:{}})},`${ve.id}:${U.id}`)}))})}function d5(e){const t=cw(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=p5(e.key);return s?{type:"pane.direction",direction:s}:null}return null}function f5(e,t,s){switch(s.type){case"pane.direction":return qA(e,t,s.direction);case"pane.index":return $A(e,s.index);default:return null}}function p5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function m5(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 hh(e){return e.type==="pane"?[{key:dh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:eC(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...hh(e.first),...hh(e.second)]}function Hm(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Hm(e.first),...Hm(e.second)]}function J1(e,t,s){if(s&&e.some(o=>o.key===s))return s;const r=t?dh(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function dh(e){return`terminal:${e}`}function eC(e){return`editor:${e}`}function g5(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function _5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:s,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(w=>w.kind==="directory"),b=e.submitStatus==="submitting";function y(w){r(k=>k&&{...k,...w})}function S(w){w&&(y({cwd:w,error:null}),c(w))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:w=>w.stopPropagation(),onSubmit:w=>{w.preventDefault(),b||f()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:b,onChange:w=>y({title:w.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:b,onChange:w=>o(w.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:b||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>S(t),disabled:b||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>S(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(y5(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"&&p.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(w=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${w.name}`,disabled:b,onClick:()=>{c(v5(g,w.path))},children:[m.jsx("span",{children:w.name}),m.jsx("small",{children:w.path})]},w.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:b||e.browseStatus==="loading",children:b?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function v5(e,t){return t?t.startsWith("/")?qu(t):qu(`${e||"/"}/${t}`):qu(e)}function y5(e){const t=qu(e);if(!t||t==="/")return"/";const s=t.lastIndexOf("/");return s<=0?"/":t.slice(0,s)}function qu(e){const t=e.trim();if(!t)return"";const s=t.replace(/\/+/g,"/");return s==="/"?"/":s.endsWith("/")?s.slice(0,-1):s}function b5({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 S5({workspaceId:e,active:t,disabled:s=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:f,isOver:g}=Qm({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:s}),p=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:f,className:p,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function w5({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 C5({targets:e,activeLeafKey:t,terminals:s,editors:r,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(S=>S.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],b=m0(p,s,r);function y(S){const w=(g+S+e.length)%e.length,k=e[w];k&&o(k)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:b,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",b]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:S=>S.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((S,w)=>{const k=m0(S,s,r),T=x5(S,s,r),B=S.key===p.key;return m.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(S),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:w+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:k}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:S.type})]},S.key)})})]})}):null]})}function m0(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 x5(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 E5(e){const[t,s]=v.useState(()=>k5(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 k5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function fn(e,t){return e===t}function T5(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 $u(e){return e??"__local__"}function Ko(e,t,s){return`${$u(e)}:${t}:${s}`}class fh extends Error{constructor(){super(iC())}}function D5(e){return e?{workspaceKey:`${f0}:${e}`}:{workspaceKey:f0}}function R5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const s=JSON.parse(t);if($0(s))throw new fh;const r=q0(s);return r?tC(r):null}catch(s){if(s instanceof fh)throw s;return null}}function tC(e){if($0(e))throw new fh;const t=q0(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Ao(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function M5(e,t){const s=Nt(e).lastPersistedLayoutJson;if(s){localStorage.setItem(t.workspaceKey,s);return}localStorage.removeItem(t.workspaceKey)}function N5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Dl}. Re-open or delete hidden sessions before hiding more.`}function iC(){return`A saved terminal layout has more than ${Dl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function A5(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 L5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function B5(e){return e.split("/").filter(Boolean).pop()??e}function O5(){try{return localStorage.getItem(Q1)==="true"}catch{return!1}}function z5(e){try{localStorage.setItem(Q1,e?"true":"false")}catch{}}function j5(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 g0({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 Rr(e){return e instanceof Error?e.message:"Request failed"}function H5({api:e,onDone:t}){const[s,r]=v.useState(null),[o,c]=v.useState(null),[h,f]=v.useState(""),[g,p]=v.useState(!1),[b,y]=v.useState(null),[S,w]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(B=>{T||(r(B.qrDataUrl),c(B.secret))}).catch(B=>{T||w(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function k(T){if(T.preventDefault(),!!o){p(!0),y(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(B){y(B instanceof Error?B.message:"Verification failed")}finally{p(!1)}}}return S?m.jsx("p",{className:"form-error",children:S}):!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:k,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>f(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 P5(e){return{source:pp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:pp(e.terminalId)}:{},...e?.detail?{detail:pp(e.detail)}:{}}}function U5(e){return{invalidationSource:e.source}}function I5(e){Rn("auth.session_invalid.request",nC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),bh("session-invalid-request").catch(()=>{}))}function K5(e,t){Rn("auth.session_invalid.result",{...nC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),bh("session-invalid-result").catch(()=>{}))}function nC(e){return{source:e.source,...typeof e.status=="number"?{status:e.status}:{},...e.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e.terminalId?{terminalId:e.terminalId}:{},...e.detail?{detail:e.detail}:{}}}function pp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function W5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r}){const o=v.useMemo(()=>e??ph(),[e]),c=v.useMemo(()=>t??Go(null),[t]),[h,f]=v.useState(null),[g,p]=v.useState(null),b=v.useRef(null),y=v.useRef("loading");v.useEffect(()=>{let L=!1;return o.getSession().then(A=>{L||(f(A),p(null))}).catch(A=>{L||(p(ba(A)),f(null))}),()=>{L=!0}},[o]);const S=V5(h);v.useEffect(()=>{const L=y.current;Rn("auth.view",{view:S,previousView:L,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),L==="workspace"&&S!=="workspace"&&bh(`auth-left-workspace-${S}`).catch(()=>{}),y.current=S},[h,S]);async function w(){const L=await o.getSession();f(L),p(null)}async function k(){ap(),fp(),qS(),p(null),f(null);try{await w()}catch(L){p(ba(L))}}function T(L){const A=P5(L);if(I5(A),b.current)return b.current;const W=(async()=>{p(null);try{const I=await o.getSession(U5(A));if(K5(A,I.authenticated),f(I),I.authenticated){PN();return}ap(),fp(),qS()}catch(I){p(ba(I))}finally{b.current=null}})();return b.current=W,W}if(S==="workspace")return m.jsx(u5,{api:o,serverApi:c,activeAgentId:s,onSelectServer:r,sessionExpiresAt:h?.expiresAt??null,onSessionInvalid:L=>{T(L)},onLogout:async()=>{ap(),fp();const L=await o.logout();f(L)}});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":S==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(C0,{size:26}),m.jsxs("div",{children:[m.jsx(x0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:B[S]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,S==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},children:"Retry"}):null,S==="setup_password"?m.jsx(F5,{api:o,onSession:L=>{f(L)}}):null,S==="setup_totp"?m.jsx(H5,{api:o,onDone:()=>{w()}}):null,S==="login"?m.jsx(q5,{api:o,session:h,onSession:f,onRefresh:w}):null,S==="reauth"?m.jsx($5,{api:o,session:h,onSession:f,onFullLogin:()=>f(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function F5({api:e,onSession:t}){const[s,r]=v.useState(""),[o,c]=v.useState(""),[h,f]=v.useState(!1),[g,p]=v.useState(null);async function b(y){y.preventDefault(),f(!0),p(null);try{if(s!==o){p("Passwords do not match");return}t(await e.setupPassword({password:s}))}catch(S){p(ba(S))}finally{f(!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 q5({api:e,session:t,onSession:s,onRefresh:r}){const[o,c]=v.useState(""),[h,f]=v.useState(""),[g,p]=v.useState(!1),[b,y]=v.useState(!1),[S,w]=v.useState(null),k=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function B(L){L.preventDefault(),y(!0),w(null);try{s(await e.login({password:o,...k?{otp:h}:{},rememberNetwork:g}))}catch(A){w(ba(A))}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:L=>c(L.currentTarget.value),required:!0})]}),k?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:L=>f(L.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:L=>p(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),S?m.jsx("p",{className:"form-error",children:S}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:b||o.length===0||k&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:b,children:"Refresh"})]})]})}function $5({api:e,session:t,onSession:s,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[f,g]=v.useState(!1),[p,b]=v.useState(!1),[y,S]=v.useState(!1),[w,k]=v.useState(!1),[T,B]=v.useState(null),L=xi.useCallback(async(W,I)=>{b(!0),B(null);try{s(await e.reauth({...W?{otp:W}:{},rememberNetwork:I}))}catch(ee){B(ba(ee))}finally{b(!1)}},[e,s]);v.useEffect(()=>{if(o){let W=!1;S(!0),k(!1),B(null);const I=window.setTimeout(()=>{W||k(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(ee=>{W||s(ee)}).catch(ee=>{W||(B(ba(ee)),k(!0))}).finally(()=>{window.clearTimeout(I),W||S(!1)}),()=>{W=!0,window.clearTimeout(I)}}},[e,o,s]);async function A(W){W.preventDefault(),await L(c,f)}return o&&y&&!w&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:A,children:[o&&w&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:W=>h(W.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:f,onChange:W=>g(W.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:p||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function V5(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function ba(e){return e instanceof Error?e.message:"Request failed"}const _0="NTerminal",Pm="nterminal.activeAgentId";function Y5(){const[e,t]=v.useState(()=>X5()),s=v.useMemo(()=>ph(),[]),r=v.useMemo(()=>Go(e),[e]);v.useEffect(()=>{const c=()=>{const h=xA();document.title=h>0?`(${h}) ${_0}`:_0};return c(),CA(c)},[]);function o(c){G5(c),t(c)}return m.jsx(W5,{api:s,activeAgentId:e,serverApi:r,onSelectServer:o})}function X5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Pm);return e&&e.trim()?e:null}catch{return null}}function G5(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Pm,e);return}window.localStorage.removeItem(Pm)}catch{}}const v0=["gesturestart","gesturechange","gestureend"],Z5=[".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 Q5(e=window){if(!eL(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||!J5(c.target))&&r(c)}for(const c of v0)s.addEventListener(c,r,t);return s.addEventListener("touchmove",o,t),s.addEventListener("dblclick",r,t),()=>{for(const c of v0)s.removeEventListener(c,r,t);s.removeEventListener("touchmove",o,t),s.removeEventListener("dblclick",r,t)}}function J5(e){return e instanceof Element&&e.closest(Z5)!==null}function eL(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}dk();ZM();Q5();Fm();pE.createRoot(document.getElementById("root")).render(m.jsx(xi.StrictMode,{children:m.jsx(Y5,{})}));export{xi as R,rE as g,m as j};
|