@mmmbuto/nexuscrew 0.8.52-rc.22 → 0.8.52-rc.23

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.
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ug;function s0(){if(ug)return rt;ug=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=S&&A[S]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,k={};function C(A,W,X){this.props=A,this.context=W,this.refs=k,this.updater=X||b}C.prototype.isReactComponent={},C.prototype.setState=function(A,W){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,W,"setState")},C.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function R(){}R.prototype=C.prototype;function E(A,W,X){this.props=A,this.context=W,this.refs=k,this.updater=X||b}var F=E.prototype=new R;F.constructor=E,w(F,C.prototype),F.isPureReactComponent=!0;var I=Array.isArray,K=Object.prototype.hasOwnProperty,Y={current:null},z={key:!0,ref:!0,__self:!0,__source:!0};function Z(A,W,X){var ie,ue={},fe=null,we=null;if(W!=null)for(ie in W.ref!==void 0&&(we=W.ref),W.key!==void 0&&(fe=""+W.key),W)K.call(W,ie)&&!z.hasOwnProperty(ie)&&(ue[ie]=W[ie]);var me=arguments.length-2;if(me===1)ue.children=X;else if(1<me){for(var xe=Array(me),$e=0;$e<me;$e++)xe[$e]=arguments[$e+2];ue.children=xe}if(A&&A.defaultProps)for(ie in me=A.defaultProps,me)ue[ie]===void 0&&(ue[ie]=me[ie]);return{$$typeof:e,type:A,key:fe,ref:we,props:ue,_owner:Y.current}}function G(A,W){return{$$typeof:e,type:A.type,key:W,ref:A.ref,props:A.props,_owner:A._owner}}function Q(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function B(A){var W={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(X){return W[X]})}var M=/\/+/g;function j(A,W){return typeof A=="object"&&A!==null&&A.key!=null?B(""+A.key):W.toString(36)}function T(A,W,X,ie,ue){var fe=typeof A;(fe==="undefined"||fe==="boolean")&&(A=null);var we=!1;if(A===null)we=!0;else switch(fe){case"string":case"number":we=!0;break;case"object":switch(A.$$typeof){case e:case t:we=!0}}if(we)return we=A,ue=ue(we),A=ie===""?"."+j(we,0):ie,I(ue)?(X="",A!=null&&(X=A.replace(M,"$&/")+"/"),T(ue,W,X,"",function($e){return $e})):ue!=null&&(Q(ue)&&(ue=G(ue,X+(!ue.key||we&&we.key===ue.key?"":(""+ue.key).replace(M,"$&/")+"/")+A)),W.push(ue)),1;if(we=0,ie=ie===""?".":ie+":",I(A))for(var me=0;me<A.length;me++){fe=A[me];var xe=ie+j(fe,me);we+=T(fe,W,X,xe,ue)}else if(xe=y(A),typeof xe=="function")for(A=xe.call(A),me=0;!(fe=A.next()).done;)fe=fe.value,xe=ie+j(fe,me++),we+=T(fe,W,X,xe,ue);else if(fe==="object")throw W=String(A),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return we}function L(A,W,X){if(A==null)return A;var ie=[],ue=0;return T(A,ie,"","",function(fe){return W.call(X,fe,ue++)}),ie}function $(A){if(A._status===-1){var W=A._result;W=W(),W.then(function(X){(A._status===0||A._status===-1)&&(A._status=1,A._result=X)},function(X){(A._status===0||A._status===-1)&&(A._status=2,A._result=X)}),A._status===-1&&(A._status=0,A._result=W)}if(A._status===1)return A._result.default;throw A._result}var H={current:null},x={transition:null},O={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:x,ReactCurrentOwner:Y};function D(){throw Error("act(...) is not supported in production builds of React.")}return rt.Children={map:L,forEach:function(A,W,X){L(A,function(){W.apply(this,arguments)},X)},count:function(A){var W=0;return L(A,function(){W++}),W},toArray:function(A){return L(A,function(W){return W})||[]},only:function(A){if(!Q(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},rt.Component=C,rt.Fragment=n,rt.Profiler=o,rt.PureComponent=E,rt.StrictMode=s,rt.Suspense=f,rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O,rt.act=D,rt.cloneElement=function(A,W,X){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var ie=w({},A.props),ue=A.key,fe=A.ref,we=A._owner;if(W!=null){if(W.ref!==void 0&&(fe=W.ref,we=Y.current),W.key!==void 0&&(ue=""+W.key),A.type&&A.type.defaultProps)var me=A.type.defaultProps;for(xe in W)K.call(W,xe)&&!z.hasOwnProperty(xe)&&(ie[xe]=W[xe]===void 0&&me!==void 0?me[xe]:W[xe])}var xe=arguments.length-2;if(xe===1)ie.children=X;else if(1<xe){me=Array(xe);for(var $e=0;$e<xe;$e++)me[$e]=arguments[$e+2];ie.children=me}return{$$typeof:e,type:A.type,key:ue,ref:fe,props:ie,_owner:we}},rt.createContext=function(A){return A={$$typeof:u,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:a,_context:A},A.Consumer=A},rt.createElement=Z,rt.createFactory=function(A){var W=Z.bind(null,A);return W.type=A,W},rt.createRef=function(){return{current:null}},rt.forwardRef=function(A){return{$$typeof:h,render:A}},rt.isValidElement=Q,rt.lazy=function(A){return{$$typeof:v,_payload:{_status:-1,_result:A},_init:$}},rt.memo=function(A,W){return{$$typeof:m,type:A,compare:W===void 0?null:W}},rt.startTransition=function(A){var W=x.transition;x.transition={};try{A()}finally{x.transition=W}},rt.unstable_act=D,rt.useCallback=function(A,W){return H.current.useCallback(A,W)},rt.useContext=function(A){return H.current.useContext(A)},rt.useDebugValue=function(){},rt.useDeferredValue=function(A){return H.current.useDeferredValue(A)},rt.useEffect=function(A,W){return H.current.useEffect(A,W)},rt.useId=function(){return H.current.useId()},rt.useImperativeHandle=function(A,W,X){return H.current.useImperativeHandle(A,W,X)},rt.useInsertionEffect=function(A,W){return H.current.useInsertionEffect(A,W)},rt.useLayoutEffect=function(A,W){return H.current.useLayoutEffect(A,W)},rt.useMemo=function(A,W){return H.current.useMemo(A,W)},rt.useReducer=function(A,W,X){return H.current.useReducer(A,W,X)},rt.useRef=function(A){return H.current.useRef(A)},rt.useState=function(A){return H.current.useState(A)},rt.useSyncExternalStore=function(A,W,X){return H.current.useSyncExternalStore(A,W,X)},rt.useTransition=function(){return H.current.useTransition()},rt.version="18.3.1",rt}var dg;function Yh(){return dg||(dg=1,qu.exports=s0()),qu.exports}/**
9
+ */var ug;function s0(){if(ug)return rt;ug=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=S&&A[S]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,k={};function C(A,W,X){this.props=A,this.context=W,this.refs=k,this.updater=X||b}C.prototype.isReactComponent={},C.prototype.setState=function(A,W){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,W,"setState")},C.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function R(){}R.prototype=C.prototype;function E(A,W,X){this.props=A,this.context=W,this.refs=k,this.updater=X||b}var F=E.prototype=new R;F.constructor=E,w(F,C.prototype),F.isPureReactComponent=!0;var I=Array.isArray,K=Object.prototype.hasOwnProperty,Y={current:null},z={key:!0,ref:!0,__self:!0,__source:!0};function Z(A,W,X){var ie,ce={},fe=null,we=null;if(W!=null)for(ie in W.ref!==void 0&&(we=W.ref),W.key!==void 0&&(fe=""+W.key),W)K.call(W,ie)&&!z.hasOwnProperty(ie)&&(ce[ie]=W[ie]);var me=arguments.length-2;if(me===1)ce.children=X;else if(1<me){for(var xe=Array(me),$e=0;$e<me;$e++)xe[$e]=arguments[$e+2];ce.children=xe}if(A&&A.defaultProps)for(ie in me=A.defaultProps,me)ce[ie]===void 0&&(ce[ie]=me[ie]);return{$$typeof:e,type:A,key:fe,ref:we,props:ce,_owner:Y.current}}function G(A,W){return{$$typeof:e,type:A.type,key:W,ref:A.ref,props:A.props,_owner:A._owner}}function Q(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function B(A){var W={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(X){return W[X]})}var M=/\/+/g;function j(A,W){return typeof A=="object"&&A!==null&&A.key!=null?B(""+A.key):W.toString(36)}function T(A,W,X,ie,ce){var fe=typeof A;(fe==="undefined"||fe==="boolean")&&(A=null);var we=!1;if(A===null)we=!0;else switch(fe){case"string":case"number":we=!0;break;case"object":switch(A.$$typeof){case e:case t:we=!0}}if(we)return we=A,ce=ce(we),A=ie===""?"."+j(we,0):ie,I(ce)?(X="",A!=null&&(X=A.replace(M,"$&/")+"/"),T(ce,W,X,"",function($e){return $e})):ce!=null&&(Q(ce)&&(ce=G(ce,X+(!ce.key||we&&we.key===ce.key?"":(""+ce.key).replace(M,"$&/")+"/")+A)),W.push(ce)),1;if(we=0,ie=ie===""?".":ie+":",I(A))for(var me=0;me<A.length;me++){fe=A[me];var xe=ie+j(fe,me);we+=T(fe,W,X,xe,ce)}else if(xe=y(A),typeof xe=="function")for(A=xe.call(A),me=0;!(fe=A.next()).done;)fe=fe.value,xe=ie+j(fe,me++),we+=T(fe,W,X,xe,ce);else if(fe==="object")throw W=String(A),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return we}function L(A,W,X){if(A==null)return A;var ie=[],ce=0;return T(A,ie,"","",function(fe){return W.call(X,fe,ce++)}),ie}function $(A){if(A._status===-1){var W=A._result;W=W(),W.then(function(X){(A._status===0||A._status===-1)&&(A._status=1,A._result=X)},function(X){(A._status===0||A._status===-1)&&(A._status=2,A._result=X)}),A._status===-1&&(A._status=0,A._result=W)}if(A._status===1)return A._result.default;throw A._result}var H={current:null},x={transition:null},O={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:x,ReactCurrentOwner:Y};function D(){throw Error("act(...) is not supported in production builds of React.")}return rt.Children={map:L,forEach:function(A,W,X){L(A,function(){W.apply(this,arguments)},X)},count:function(A){var W=0;return L(A,function(){W++}),W},toArray:function(A){return L(A,function(W){return W})||[]},only:function(A){if(!Q(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},rt.Component=C,rt.Fragment=n,rt.Profiler=o,rt.PureComponent=E,rt.StrictMode=s,rt.Suspense=f,rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O,rt.act=D,rt.cloneElement=function(A,W,X){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var ie=w({},A.props),ce=A.key,fe=A.ref,we=A._owner;if(W!=null){if(W.ref!==void 0&&(fe=W.ref,we=Y.current),W.key!==void 0&&(ce=""+W.key),A.type&&A.type.defaultProps)var me=A.type.defaultProps;for(xe in W)K.call(W,xe)&&!z.hasOwnProperty(xe)&&(ie[xe]=W[xe]===void 0&&me!==void 0?me[xe]:W[xe])}var xe=arguments.length-2;if(xe===1)ie.children=X;else if(1<xe){me=Array(xe);for(var $e=0;$e<xe;$e++)me[$e]=arguments[$e+2];ie.children=me}return{$$typeof:e,type:A.type,key:ce,ref:fe,props:ie,_owner:we}},rt.createContext=function(A){return A={$$typeof:u,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:a,_context:A},A.Consumer=A},rt.createElement=Z,rt.createFactory=function(A){var W=Z.bind(null,A);return W.type=A,W},rt.createRef=function(){return{current:null}},rt.forwardRef=function(A){return{$$typeof:h,render:A}},rt.isValidElement=Q,rt.lazy=function(A){return{$$typeof:v,_payload:{_status:-1,_result:A},_init:$}},rt.memo=function(A,W){return{$$typeof:m,type:A,compare:W===void 0?null:W}},rt.startTransition=function(A){var W=x.transition;x.transition={};try{A()}finally{x.transition=W}},rt.unstable_act=D,rt.useCallback=function(A,W){return H.current.useCallback(A,W)},rt.useContext=function(A){return H.current.useContext(A)},rt.useDebugValue=function(){},rt.useDeferredValue=function(A){return H.current.useDeferredValue(A)},rt.useEffect=function(A,W){return H.current.useEffect(A,W)},rt.useId=function(){return H.current.useId()},rt.useImperativeHandle=function(A,W,X){return H.current.useImperativeHandle(A,W,X)},rt.useInsertionEffect=function(A,W){return H.current.useInsertionEffect(A,W)},rt.useLayoutEffect=function(A,W){return H.current.useLayoutEffect(A,W)},rt.useMemo=function(A,W){return H.current.useMemo(A,W)},rt.useReducer=function(A,W,X){return H.current.useReducer(A,W,X)},rt.useRef=function(A){return H.current.useRef(A)},rt.useState=function(A){return H.current.useState(A)},rt.useSyncExternalStore=function(A,W,X){return H.current.useSyncExternalStore(A,W,X)},rt.useTransition=function(){return H.current.useTransition()},rt.version="18.3.1",rt}var dg;function Yh(){return dg||(dg=1,qu.exports=s0()),qu.exports}/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */var pg;function l0(){return pg||(pg=1,(function(e){function t(x,O){var D=x.length;x.push(O);e:for(;0<D;){var A=D-1>>>1,W=x[A];if(0<o(W,O))x[A]=O,x[D]=W,D=A;else break e}}function n(x){return x.length===0?null:x[0]}function s(x){if(x.length===0)return null;var O=x[0],D=x.pop();if(D!==O){x[0]=D;e:for(var A=0,W=x.length,X=W>>>1;A<X;){var ie=2*(A+1)-1,ue=x[ie],fe=ie+1,we=x[fe];if(0>o(ue,D))fe<W&&0>o(we,ue)?(x[A]=we,x[fe]=D,A=fe):(x[A]=ue,x[ie]=D,A=ie);else if(fe<W&&0>o(we,D))x[A]=we,x[fe]=D,A=fe;else break e}}return O}function o(x,O){var D=x.sortIndex-O.sortIndex;return D!==0?D:x.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var f=[],m=[],v=1,S=null,y=3,b=!1,w=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function F(x){for(var O=n(m);O!==null;){if(O.callback===null)s(m);else if(O.startTime<=x)s(m),O.sortIndex=O.expirationTime,t(f,O);else break;O=n(m)}}function I(x){if(k=!1,F(x),!w)if(n(f)!==null)w=!0,$(K);else{var O=n(m);O!==null&&H(I,O.startTime-x)}}function K(x,O){w=!1,k&&(k=!1,R(Z),Z=-1),b=!0;var D=y;try{for(F(O),S=n(f);S!==null&&(!(S.expirationTime>O)||x&&!B());){var A=S.callback;if(typeof A=="function"){S.callback=null,y=S.priorityLevel;var W=A(S.expirationTime<=O);O=e.unstable_now(),typeof W=="function"?S.callback=W:S===n(f)&&s(f),F(O)}else s(f);S=n(f)}if(S!==null)var X=!0;else{var ie=n(m);ie!==null&&H(I,ie.startTime-O),X=!1}return X}finally{S=null,y=D,b=!1}}var Y=!1,z=null,Z=-1,G=5,Q=-1;function B(){return!(e.unstable_now()-Q<G)}function M(){if(z!==null){var x=e.unstable_now();Q=x;var O=!0;try{O=z(!0,x)}finally{O?j():(Y=!1,z=null)}}else Y=!1}var j;if(typeof E=="function")j=function(){E(M)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,L=T.port2;T.port1.onmessage=M,j=function(){L.postMessage(null)}}else j=function(){C(M,0)};function $(x){z=x,Y||(Y=!0,j())}function H(x,O){Z=C(function(){x(e.unstable_now())},O)}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(x){x.callback=null},e.unstable_continueExecution=function(){w||b||(w=!0,$(K))},e.unstable_forceFrameRate=function(x){0>x||125<x?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<x?Math.floor(1e3/x):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(x){switch(y){case 1:case 2:case 3:var O=3;break;default:O=y}var D=y;y=O;try{return x()}finally{y=D}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(x,O){switch(x){case 1:case 2:case 3:case 4:case 5:break;default:x=3}var D=y;y=x;try{return O()}finally{y=D}},e.unstable_scheduleCallback=function(x,O,D){var A=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?A+D:A):D=A,x){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=D+W,x={id:v++,callback:O,priorityLevel:x,startTime:D,expirationTime:W,sortIndex:-1},D>A?(x.sortIndex=D,t(m,x),n(f)===null&&x===n(m)&&(k?(R(Z),Z=-1):k=!0,H(I,D-A))):(x.sortIndex=W,t(f,x),w||b||(w=!0,$(K))),x},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(x){var O=y;return function(){var D=y;y=O;try{return x.apply(this,arguments)}finally{y=D}}}})(Gu)),Gu}var mg;function c0(){return mg||(mg=1,Yu.exports=l0()),Yu.exports}/**
25
+ */var pg;function l0(){return pg||(pg=1,(function(e){function t(x,O){var D=x.length;x.push(O);e:for(;0<D;){var A=D-1>>>1,W=x[A];if(0<o(W,O))x[A]=O,x[D]=W,D=A;else break e}}function n(x){return x.length===0?null:x[0]}function s(x){if(x.length===0)return null;var O=x[0],D=x.pop();if(D!==O){x[0]=D;e:for(var A=0,W=x.length,X=W>>>1;A<X;){var ie=2*(A+1)-1,ce=x[ie],fe=ie+1,we=x[fe];if(0>o(ce,D))fe<W&&0>o(we,ce)?(x[A]=we,x[fe]=D,A=fe):(x[A]=ce,x[ie]=D,A=ie);else if(fe<W&&0>o(we,D))x[A]=we,x[fe]=D,A=fe;else break e}}return O}function o(x,O){var D=x.sortIndex-O.sortIndex;return D!==0?D:x.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var f=[],m=[],v=1,S=null,y=3,b=!1,w=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function F(x){for(var O=n(m);O!==null;){if(O.callback===null)s(m);else if(O.startTime<=x)s(m),O.sortIndex=O.expirationTime,t(f,O);else break;O=n(m)}}function I(x){if(k=!1,F(x),!w)if(n(f)!==null)w=!0,$(K);else{var O=n(m);O!==null&&H(I,O.startTime-x)}}function K(x,O){w=!1,k&&(k=!1,R(Z),Z=-1),b=!0;var D=y;try{for(F(O),S=n(f);S!==null&&(!(S.expirationTime>O)||x&&!B());){var A=S.callback;if(typeof A=="function"){S.callback=null,y=S.priorityLevel;var W=A(S.expirationTime<=O);O=e.unstable_now(),typeof W=="function"?S.callback=W:S===n(f)&&s(f),F(O)}else s(f);S=n(f)}if(S!==null)var X=!0;else{var ie=n(m);ie!==null&&H(I,ie.startTime-O),X=!1}return X}finally{S=null,y=D,b=!1}}var Y=!1,z=null,Z=-1,G=5,Q=-1;function B(){return!(e.unstable_now()-Q<G)}function M(){if(z!==null){var x=e.unstable_now();Q=x;var O=!0;try{O=z(!0,x)}finally{O?j():(Y=!1,z=null)}}else Y=!1}var j;if(typeof E=="function")j=function(){E(M)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,L=T.port2;T.port1.onmessage=M,j=function(){L.postMessage(null)}}else j=function(){C(M,0)};function $(x){z=x,Y||(Y=!0,j())}function H(x,O){Z=C(function(){x(e.unstable_now())},O)}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(x){x.callback=null},e.unstable_continueExecution=function(){w||b||(w=!0,$(K))},e.unstable_forceFrameRate=function(x){0>x||125<x?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<x?Math.floor(1e3/x):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(x){switch(y){case 1:case 2:case 3:var O=3;break;default:O=y}var D=y;y=O;try{return x()}finally{y=D}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(x,O){switch(x){case 1:case 2:case 3:case 4:case 5:break;default:x=3}var D=y;y=x;try{return O()}finally{y=D}},e.unstable_scheduleCallback=function(x,O,D){var A=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?A+D:A):D=A,x){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=D+W,x={id:v++,callback:O,priorityLevel:x,startTime:D,expirationTime:W,sortIndex:-1},D>A?(x.sortIndex=D,t(m,x),n(f)===null&&x===n(m)&&(k?(R(Z),Z=-1):k=!0,H(I,D-A))):(x.sortIndex=W,t(f,x),w||b||(w=!0,$(K))),x},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(x){var O=y;return function(){var D=y;y=O;try{return x.apply(this,arguments)}finally{y=D}}}})(Gu)),Gu}var mg;function c0(){return mg||(mg=1,Yu.exports=l0()),Yu.exports}/**
26
26
  * @license React
27
27
  * react-dom.production.min.js
28
28
  *
@@ -34,10 +34,10 @@
34
34
  `+A+i}var X=!1;function ie(i,r){if(!i||X)return"";X=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(le){var d=le}Reflect.construct(i,[],r)}else{try{r.call()}catch(le){d=le}i.call(r.prototype)}else{try{throw Error()}catch(le){d=le}i()}}catch(le){if(le&&d&&typeof le.stack=="string"){for(var g=le.stack.split(`
35
35
  `),_=d.stack.split(`
36
36
  `),P=g.length-1,V=_.length-1;1<=P&&0<=V&&g[P]!==_[V];)V--;for(;1<=P&&0<=V;P--,V--)if(g[P]!==_[V]){if(P!==1||V!==1)do if(P--,V--,0>V||g[P]!==_[V]){var J=`
37
- `+g[P].replace(" at new "," at ");return i.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",i.displayName)),J}while(1<=P&&0<=V);break}}}finally{X=!1,Error.prepareStackTrace=l}return(i=i?i.displayName||i.name:"")?W(i):""}function ue(i){switch(i.tag){case 5:return W(i.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return i=ie(i.type,!1),i;case 11:return i=ie(i.type.render,!1),i;case 1:return i=ie(i.type,!0),i;default:return""}}function fe(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case z:return"Fragment";case Y:return"Portal";case G:return"Profiler";case Z:return"StrictMode";case j:return"Suspense";case T:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case B:return(i.displayName||"Context")+".Consumer";case Q:return(i._context.displayName||"Context")+".Provider";case M:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return r=i.displayName||null,r!==null?r:fe(i.type)||"Memo";case $:r=i._payload,i=i._init;try{return fe(i(r))}catch{}}return null}function we(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(r);case 8:return r===Z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function me(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function xe(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function $e(i){var r=xe(i)?"checked":"value",l=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),d=""+i[r];if(!i.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var g=l.get,_=l.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return g.call(this)},set:function(P){d=""+P,_.call(this,P)}}),Object.defineProperty(i,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(P){d=""+P},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ft(i){i._valueTracker||(i._valueTracker=$e(i))}function qe(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return i&&(d=xe(i)?i.checked?"true":"false":i.value),i=d,i!==l?(r.setValue(i),!0):!1}function Ae(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}}function Rt(i,r){var l=r.checked;return D({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??i._wrapperState.initialChecked})}function Jt(i,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=me(r.value!=null?r.value:l),i._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Oe(i,r){r=r.checked,r!=null&&F(i,"checked",r,!1)}function Pt(i,r){Oe(i,r);var l=me(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+l):i.value!==""+l&&(i.value=""+l);else if(d==="submit"||d==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?dt(i,r.type,l):r.hasOwnProperty("defaultValue")&&dt(i,r.type,me(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function bt(i,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,l||r===i.value||(i.value=r),i.defaultValue=r}l=i.name,l!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,l!==""&&(i.name=l)}function dt(i,r,l){(r!=="number"||Ae(i.ownerDocument)!==i)&&(l==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+l&&(i.defaultValue=""+l))}var ht=Array.isArray;function Qe(i,r,l,d){if(i=i.options,r){r={};for(var g=0;g<l.length;g++)r["$"+l[g]]=!0;for(l=0;l<i.length;l++)g=r.hasOwnProperty("$"+i[l].value),i[l].selected!==g&&(i[l].selected=g),g&&d&&(i[l].defaultSelected=!0)}else{for(l=""+me(l),r=null,g=0;g<i.length;g++){if(i[g].value===l){i[g].selected=!0,d&&(i[g].defaultSelected=!0);return}r!==null||i[g].disabled||(r=i[g])}r!==null&&(r.selected=!0)}}function ot(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return D({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function oe(i,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(n(92));if(ht(l)){if(1<l.length)throw Error(n(93));l=l[0]}r=l}r==null&&(r=""),l=r}i._wrapperState={initialValue:me(l)}}function ke(i,r){var l=me(r.value),d=me(r.defaultValue);l!=null&&(l=""+l,l!==i.value&&(i.value=l),r.defaultValue==null&&i.defaultValue!==l&&(i.defaultValue=l)),d!=null&&(i.defaultValue=""+d)}function Te(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function ae(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function re(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?ae(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Pe,q=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,g){MSApp.execUnsafeLocalFunction(function(){return i(r,l,d,g)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(Pe=Pe||document.createElement("div"),Pe.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Pe.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function te(i,r){if(r){var l=i.firstChild;if(l&&l===i.lastChild&&l.nodeType===3){l.nodeValue=r;return}}i.textContent=r}var U={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ce=["Webkit","ms","Moz","O"];Object.keys(U).forEach(function(i){ce.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),U[r]=U[i]})});function de(i,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||U.hasOwnProperty(i)&&U[i]?(""+r).trim():r+"px"}function ge(i,r){i=i.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,g=de(l,r[l],d);l==="float"&&(l="cssFloat"),d?i.setProperty(l,g):i[l]=g}}var De=D({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function _e(i,r){if(r){if(De[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function Ee(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";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 nt=null;function at(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Je=null,Mt=null,ct=null;function et(i){if(i=mo(i)){if(typeof Je!="function")throw Error(n(280));var r=i.stateNode;r&&(r=ja(r),Je(i.stateNode,i.type,r))}}function Zt(i){Mt?ct?ct.push(i):ct=[i]:Mt=i}function ni(){if(Mt){var i=Mt,r=ct;if(ct=Mt=null,et(i),r)for(i=0;i<r.length;i++)et(r[i])}}function Wn(i,r){return i(r)}function ui(){}var he=!1;function je(i,r,l){if(he)return i(r,l);he=!0;try{return Wn(i,r,l)}finally{he=!1,(Mt!==null||ct!==null)&&(ui(),ni())}}function Ke(i,r){var l=i.stateNode;if(l===null)return null;var d=ja(l);if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(l&&typeof l!="function")throw Error(n(231,r,typeof l));return l}var pt=!1;if(h)try{var vt={};Object.defineProperty(vt,"passive",{get:function(){pt=!0}}),window.addEventListener("test",vt,vt),window.removeEventListener("test",vt,vt)}catch{pt=!1}function bs(i,r,l,d,g,_,P,V,J){var le=Array.prototype.slice.call(arguments,3);try{r.apply(l,le)}catch(be){this.onError(be)}}var Ui=!1,Ss=null,xs=!1,di=null,Kn={onError:function(i){Ui=!0,Ss=i}};function Kr(i,r,l,d,g,_,P,V,J){Ui=!1,Ss=null,bs.apply(Kn,arguments)}function la(i,r,l,d,g,_,P,V,J){if(Kr.apply(this,arguments),Ui){if(Ui){var le=Ss;Ui=!1,Ss=null}else throw Error(n(198));xs||(xs=!0,di=le)}}function zt(i){var r=i,l=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(l=r.return),i=r.return;while(i)}return r.tag===3?l:null}function qr(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function ks(i){if(zt(i)!==i)throw Error(n(188))}function Cs(i){var r=i.alternate;if(!r){if(r=zt(i),r===null)throw Error(n(188));return r!==i?null:i}for(var l=i,d=r;;){var g=l.return;if(g===null)break;var _=g.alternate;if(_===null){if(d=g.return,d!==null){l=d;continue}break}if(g.child===_.child){for(_=g.child;_;){if(_===l)return ks(g),i;if(_===d)return ks(g),r;_=_.sibling}throw Error(n(188))}if(l.return!==d.return)l=g,d=_;else{for(var P=!1,V=g.child;V;){if(V===l){P=!0,l=g,d=_;break}if(V===d){P=!0,d=g,l=_;break}V=V.sibling}if(!P){for(V=_.child;V;){if(V===l){P=!0,l=_,d=g;break}if(V===d){P=!0,d=_,l=g;break}V=V.sibling}if(!P)throw Error(n(189))}}if(l.alternate!==d)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?i:r}function Es(i){return i=Cs(i),i!==null?Vr(i):null}function Vr(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=Vr(i);if(r!==null)return r;i=i.sibling}return null}var Ns=t.unstable_scheduleCallback,Yr=t.unstable_cancelCallback,tr=t.unstable_shouldYield,ca=t.unstable_requestPaint,Et=t.unstable_now,pe=t.unstable_getCurrentPriorityLevel,He=t.unstable_ImmediatePriority,Ye=t.unstable_UserBlockingPriority,Ve=t.unstable_NormalPriority,_t=t.unstable_LowPriority,St=t.unstable_IdlePriority,Ut=null,en=null;function dc(i){if(en&&typeof en.onCommitFiberRoot=="function")try{en.onCommitFiberRoot(Ut,i,void 0,(i.current.flags&128)===128)}catch{}}var Nn=Math.clz32?Math.clz32:Sb,Gr=Math.log,bb=Math.LN2;function Sb(i){return i>>>=0,i===0?32:31-(Gr(i)/bb|0)|0}var ua=64,da=4194304;function Xr(i){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: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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ha(i,r){var l=i.pendingLanes;if(l===0)return 0;var d=0,g=i.suspendedLanes,_=i.pingedLanes,P=l&268435455;if(P!==0){var V=P&~g;V!==0?d=Xr(V):(_&=P,_!==0&&(d=Xr(_)))}else P=l&~g,P!==0?d=Xr(P):_!==0&&(d=Xr(_));if(d===0)return 0;if(r!==0&&r!==d&&(r&g)===0&&(g=d&-d,_=r&-r,g>=_||g===16&&(_&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=d;0<r;)l=31-Nn(r),g=1<<l,d|=i[l],r&=~g;return d}function xb(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function kb(i,r){for(var l=i.suspendedLanes,d=i.pingedLanes,g=i.expirationTimes,_=i.pendingLanes;0<_;){var P=31-Nn(_),V=1<<P,J=g[P];J===-1?((V&l)===0||(V&d)!==0)&&(g[P]=xb(V,r)):J<=r&&(i.expiredLanes|=V),_&=~V}}function hc(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function $f(){var i=ua;return ua<<=1,(ua&4194240)===0&&(ua=64),i}function fc(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Qr(i,r,l){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Nn(r),i[r]=l}function Cb(i,r){var l=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var d=i.eventTimes;for(i=i.expirationTimes;0<l;){var g=31-Nn(l),_=1<<g;r[g]=0,d[g]=-1,i[g]=-1,l&=~_}}function pc(i,r){var l=i.entangledLanes|=r;for(i=i.entanglements;l;){var d=31-Nn(l),g=1<<d;g&r|i[d]&r&&(i[d]|=r),l&=~g}}var mt=0;function Hf(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Uf,mc,Wf,Kf,qf,gc=!1,fa=[],Wi=null,Ki=null,qi=null,Jr=new Map,Zr=new Map,Vi=[],Eb="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 submit".split(" ");function Vf(i,r){switch(i){case"focusin":case"focusout":Wi=null;break;case"dragenter":case"dragleave":Ki=null;break;case"mouseover":case"mouseout":qi=null;break;case"pointerover":case"pointerout":Jr.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zr.delete(r.pointerId)}}function eo(i,r,l,d,g,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:_,targetContainers:[g]},r!==null&&(r=mo(r),r!==null&&mc(r)),i):(i.eventSystemFlags|=d,r=i.targetContainers,g!==null&&r.indexOf(g)===-1&&r.push(g),i)}function Nb(i,r,l,d,g){switch(r){case"focusin":return Wi=eo(Wi,i,r,l,d,g),!0;case"dragenter":return Ki=eo(Ki,i,r,l,d,g),!0;case"mouseover":return qi=eo(qi,i,r,l,d,g),!0;case"pointerover":var _=g.pointerId;return Jr.set(_,eo(Jr.get(_)||null,i,r,l,d,g)),!0;case"gotpointercapture":return _=g.pointerId,Zr.set(_,eo(Zr.get(_)||null,i,r,l,d,g)),!0}return!1}function Yf(i){var r=js(i.target);if(r!==null){var l=zt(r);if(l!==null){if(r=l.tag,r===13){if(r=qr(l),r!==null){i.blockedOn=r,qf(i.priority,function(){Wf(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){i.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}i.blockedOn=null}function pa(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var l=_c(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(l===null){l=i.nativeEvent;var d=new l.constructor(l.type,l);nt=d,l.target.dispatchEvent(d),nt=null}else return r=mo(l),r!==null&&mc(r),i.blockedOn=l,!1;r.shift()}return!0}function Gf(i,r,l){pa(i)&&l.delete(r)}function jb(){gc=!1,Wi!==null&&pa(Wi)&&(Wi=null),Ki!==null&&pa(Ki)&&(Ki=null),qi!==null&&pa(qi)&&(qi=null),Jr.forEach(Gf),Zr.forEach(Gf)}function to(i,r){i.blockedOn===r&&(i.blockedOn=null,gc||(gc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jb)))}function no(i){function r(g){return to(g,i)}if(0<fa.length){to(fa[0],i);for(var l=1;l<fa.length;l++){var d=fa[l];d.blockedOn===i&&(d.blockedOn=null)}}for(Wi!==null&&to(Wi,i),Ki!==null&&to(Ki,i),qi!==null&&to(qi,i),Jr.forEach(r),Zr.forEach(r),l=0;l<Vi.length;l++)d=Vi[l],d.blockedOn===i&&(d.blockedOn=null);for(;0<Vi.length&&(l=Vi[0],l.blockedOn===null);)Yf(l),l.blockedOn===null&&Vi.shift()}var nr=I.ReactCurrentBatchConfig,ma=!0;function Rb(i,r,l,d){var g=mt,_=nr.transition;nr.transition=null;try{mt=1,vc(i,r,l,d)}finally{mt=g,nr.transition=_}}function Pb(i,r,l,d){var g=mt,_=nr.transition;nr.transition=null;try{mt=4,vc(i,r,l,d)}finally{mt=g,nr.transition=_}}function vc(i,r,l,d){if(ma){var g=_c(i,r,l,d);if(g===null)Mc(i,r,d,ga,l),Vf(i,d);else if(Nb(g,i,r,l,d))d.stopPropagation();else if(Vf(i,d),r&4&&-1<Eb.indexOf(i)){for(;g!==null;){var _=mo(g);if(_!==null&&Uf(_),_=_c(i,r,l,d),_===null&&Mc(i,r,d,ga,l),_===g)break;g=_}g!==null&&d.stopPropagation()}else Mc(i,r,d,null,l)}}var ga=null;function _c(i,r,l,d){if(ga=null,i=at(d),i=js(i),i!==null)if(r=zt(i),r===null)i=null;else if(l=r.tag,l===13){if(i=qr(r),i!==null)return i;i=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return ga=i,null}function Xf(i){switch(i){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(pe()){case He:return 1;case Ye:return 4;case Ve:case _t:return 16;case St:return 536870912;default:return 16}default:return 16}}var Yi=null,yc=null,va=null;function Qf(){if(va)return va;var i,r=yc,l=r.length,d,g="value"in Yi?Yi.value:Yi.textContent,_=g.length;for(i=0;i<l&&r[i]===g[i];i++);var P=l-i;for(d=1;d<=P&&r[l-d]===g[_-d];d++);return va=g.slice(i,1<d?1-d:void 0)}function _a(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function ya(){return!0}function Jf(){return!1}function Mn(i){function r(l,d,g,_,P){this._reactName=l,this._targetInst=g,this.type=d,this.nativeEvent=_,this.target=P,this.currentTarget=null;for(var V in i)i.hasOwnProperty(V)&&(l=i[V],this[V]=l?l(_):_[V]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?ya:Jf,this.isPropagationStopped=Jf,this}return D(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ya)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ya)},persist:function(){},isPersistent:ya}),r}var ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wc=Mn(ir),io=D({},ir,{view:0,detail:0}),Lb=Mn(io),bc,Sc,so,wa=D({},io,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kc,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!==so&&(so&&i.type==="mousemove"?(bc=i.screenX-so.screenX,Sc=i.screenY-so.screenY):Sc=bc=0,so=i),bc)},movementY:function(i){return"movementY"in i?i.movementY:Sc}}),Zf=Mn(wa),Ab=D({},wa,{dataTransfer:0}),Tb=Mn(Ab),Db=D({},io,{relatedTarget:0}),xc=Mn(Db),Mb=D({},ir,{animationName:0,elapsedTime:0,pseudoElement:0}),Ib=Mn(Mb),Ob=D({},ir,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Bb=Mn(Ob),zb=D({},ir,{data:0}),ep=Mn(zb),Fb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$b={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"},Hb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ub(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Hb[i])?!!r[i]:!1}function kc(){return Ub}var Wb=D({},io,{key:function(i){if(i.key){var r=Fb[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=_a(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?$b[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kc,charCode:function(i){return i.type==="keypress"?_a(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?_a(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Kb=Mn(Wb),qb=D({},wa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tp=Mn(qb),Vb=D({},io,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kc}),Yb=Mn(Vb),Gb=D({},ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xb=Mn(Gb),Qb=D({},wa,{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}),Jb=Mn(Qb),Zb=[9,13,27,32],Cc=h&&"CompositionEvent"in window,ro=null;h&&"documentMode"in document&&(ro=document.documentMode);var eS=h&&"TextEvent"in window&&!ro,np=h&&(!Cc||ro&&8<ro&&11>=ro),ip=" ",sp=!1;function rp(i,r){switch(i){case"keyup":return Zb.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function op(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var sr=!1;function tS(i,r){switch(i){case"compositionend":return op(r);case"keypress":return r.which!==32?null:(sp=!0,ip);case"textInput":return i=r.data,i===ip&&sp?null:i;default:return null}}function nS(i,r){if(sr)return i==="compositionend"||!Cc&&rp(i,r)?(i=Qf(),va=yc=Yi=null,sr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return np&&r.locale!=="ko"?null:r.data;default:return null}}var iS={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 ap(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!iS[i.type]:r==="textarea"}function lp(i,r,l,d){Zt(d),r=Ca(r,"onChange"),0<r.length&&(l=new wc("onChange","change",null,l,d),i.push({event:l,listeners:r}))}var oo=null,ao=null;function sS(i){Ep(i,0)}function ba(i){var r=cr(i);if(qe(r))return i}function rS(i,r){if(i==="change")return r}var cp=!1;if(h){var Ec;if(h){var Nc="oninput"in document;if(!Nc){var up=document.createElement("div");up.setAttribute("oninput","return;"),Nc=typeof up.oninput=="function"}Ec=Nc}else Ec=!1;cp=Ec&&(!document.documentMode||9<document.documentMode)}function dp(){oo&&(oo.detachEvent("onpropertychange",hp),ao=oo=null)}function hp(i){if(i.propertyName==="value"&&ba(ao)){var r=[];lp(r,ao,i,at(i)),je(sS,r)}}function oS(i,r,l){i==="focusin"?(dp(),oo=r,ao=l,oo.attachEvent("onpropertychange",hp)):i==="focusout"&&dp()}function aS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return ba(ao)}function lS(i,r){if(i==="click")return ba(r)}function cS(i,r){if(i==="input"||i==="change")return ba(r)}function uS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var ii=typeof Object.is=="function"?Object.is:uS;function lo(i,r){if(ii(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var l=Object.keys(i),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var g=l[d];if(!f.call(r,g)||!ii(i[g],r[g]))return!1}return!0}function fp(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function pp(i,r){var l=fp(i);i=0;for(var d;l;){if(l.nodeType===3){if(d=i+l.textContent.length,i<=r&&d>=r)return{node:l,offset:r-i};i=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=fp(l)}}function mp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?mp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function gp(){for(var i=window,r=Ae();r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ae(i.document)}return r}function jc(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function dS(i){var r=gp(),l=i.focusedElem,d=i.selectionRange;if(r!==l&&l&&l.ownerDocument&&mp(l.ownerDocument.documentElement,l)){if(d!==null&&jc(l)){if(r=d.start,i=d.end,i===void 0&&(i=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(i,l.value.length);else if(i=(r=l.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var g=l.textContent.length,_=Math.min(d.start,g);d=d.end===void 0?_:Math.min(d.end,g),!i.extend&&_>d&&(g=d,d=_,_=g),g=pp(l,_);var P=pp(l,d);g&&P&&(i.rangeCount!==1||i.anchorNode!==g.node||i.anchorOffset!==g.offset||i.focusNode!==P.node||i.focusOffset!==P.offset)&&(r=r.createRange(),r.setStart(g.node,g.offset),i.removeAllRanges(),_>d?(i.addRange(r),i.extend(P.node,P.offset)):(r.setEnd(P.node,P.offset),i.addRange(r)))}}for(r=[],i=l;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)i=r[l],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var hS=h&&"documentMode"in document&&11>=document.documentMode,rr=null,Rc=null,co=null,Pc=!1;function vp(i,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Pc||rr==null||rr!==Ae(d)||(d=rr,"selectionStart"in d&&jc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),co&&lo(co,d)||(co=d,d=Ca(Rc,"onSelect"),0<d.length&&(r=new wc("onSelect","select",null,r,l),i.push({event:r,listeners:d}),r.target=rr)))}function Sa(i,r){var l={};return l[i.toLowerCase()]=r.toLowerCase(),l["Webkit"+i]="webkit"+r,l["Moz"+i]="moz"+r,l}var or={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionend:Sa("Transition","TransitionEnd")},Lc={},_p={};h&&(_p=document.createElement("div").style,"AnimationEvent"in window||(delete or.animationend.animation,delete or.animationiteration.animation,delete or.animationstart.animation),"TransitionEvent"in window||delete or.transitionend.transition);function xa(i){if(Lc[i])return Lc[i];if(!or[i])return i;var r=or[i],l;for(l in r)if(r.hasOwnProperty(l)&&l in _p)return Lc[i]=r[l];return i}var yp=xa("animationend"),wp=xa("animationiteration"),bp=xa("animationstart"),Sp=xa("transitionend"),xp=new Map,kp="abort auxClick 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(" ");function Gi(i,r){xp.set(i,r),a(r,[i])}for(var Ac=0;Ac<kp.length;Ac++){var Tc=kp[Ac],fS=Tc.toLowerCase(),pS=Tc[0].toUpperCase()+Tc.slice(1);Gi(fS,"on"+pS)}Gi(yp,"onAnimationEnd"),Gi(wp,"onAnimationIteration"),Gi(bp,"onAnimationStart"),Gi("dblclick","onDoubleClick"),Gi("focusin","onFocus"),Gi("focusout","onBlur"),Gi(Sp,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("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(" "),mS=new Set("cancel close invalid load scroll toggle".split(" ").concat(uo));function Cp(i,r,l){var d=i.type||"unknown-event";i.currentTarget=l,la(d,r,void 0,i),i.currentTarget=null}function Ep(i,r){r=(r&4)!==0;for(var l=0;l<i.length;l++){var d=i[l],g=d.event;d=d.listeners;e:{var _=void 0;if(r)for(var P=d.length-1;0<=P;P--){var V=d[P],J=V.instance,le=V.currentTarget;if(V=V.listener,J!==_&&g.isPropagationStopped())break e;Cp(g,V,le),_=J}else for(P=0;P<d.length;P++){if(V=d[P],J=V.instance,le=V.currentTarget,V=V.listener,J!==_&&g.isPropagationStopped())break e;Cp(g,V,le),_=J}}}if(xs)throw i=di,xs=!1,di=null,i}function xt(i,r){var l=r[$c];l===void 0&&(l=r[$c]=new Set);var d=i+"__bubble";l.has(d)||(Np(r,i,2,!1),l.add(d))}function Dc(i,r,l){var d=0;r&&(d|=4),Np(l,i,d,r)}var ka="_reactListening"+Math.random().toString(36).slice(2);function ho(i){if(!i[ka]){i[ka]=!0,s.forEach(function(l){l!=="selectionchange"&&(mS.has(l)||Dc(l,!1,i),Dc(l,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[ka]||(r[ka]=!0,Dc("selectionchange",!1,r))}}function Np(i,r,l,d){switch(Xf(r)){case 1:var g=Rb;break;case 4:g=Pb;break;default:g=vc}l=g.bind(null,r,l,i),g=void 0,!pt||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(g=!0),d?g!==void 0?i.addEventListener(r,l,{capture:!0,passive:g}):i.addEventListener(r,l,!0):g!==void 0?i.addEventListener(r,l,{passive:g}):i.addEventListener(r,l,!1)}function Mc(i,r,l,d,g){var _=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var P=d.tag;if(P===3||P===4){var V=d.stateNode.containerInfo;if(V===g||V.nodeType===8&&V.parentNode===g)break;if(P===4)for(P=d.return;P!==null;){var J=P.tag;if((J===3||J===4)&&(J=P.stateNode.containerInfo,J===g||J.nodeType===8&&J.parentNode===g))return;P=P.return}for(;V!==null;){if(P=js(V),P===null)return;if(J=P.tag,J===5||J===6){d=_=P;continue e}V=V.parentNode}}d=d.return}je(function(){var le=_,be=at(l),Se=[];e:{var ye=xp.get(i);if(ye!==void 0){var Le=wc,Be=i;switch(i){case"keypress":if(_a(l)===0)break e;case"keydown":case"keyup":Le=Kb;break;case"focusin":Be="focus",Le=xc;break;case"focusout":Be="blur",Le=xc;break;case"beforeblur":case"afterblur":Le=xc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Le=Zf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Le=Tb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Le=Yb;break;case yp:case wp:case bp:Le=Ib;break;case Sp:Le=Xb;break;case"scroll":Le=Lb;break;case"wheel":Le=Jb;break;case"copy":case"cut":case"paste":Le=Bb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Le=tp}var ze=(r&4)!==0,Ft=!ze&&i==="scroll",ne=ze?ye!==null?ye+"Capture":null:ye;ze=[];for(var ee=le,se;ee!==null;){se=ee;var Ce=se.stateNode;if(se.tag===5&&Ce!==null&&(se=Ce,ne!==null&&(Ce=Ke(ee,ne),Ce!=null&&ze.push(fo(ee,Ce,se)))),Ft)break;ee=ee.return}0<ze.length&&(ye=new Le(ye,Be,null,l,be),Se.push({event:ye,listeners:ze}))}}if((r&7)===0){e:{if(ye=i==="mouseover"||i==="pointerover",Le=i==="mouseout"||i==="pointerout",ye&&l!==nt&&(Be=l.relatedTarget||l.fromElement)&&(js(Be)||Be[ji]))break e;if((Le||ye)&&(ye=be.window===be?be:(ye=be.ownerDocument)?ye.defaultView||ye.parentWindow:window,Le?(Be=l.relatedTarget||l.toElement,Le=le,Be=Be?js(Be):null,Be!==null&&(Ft=zt(Be),Be!==Ft||Be.tag!==5&&Be.tag!==6)&&(Be=null)):(Le=null,Be=le),Le!==Be)){if(ze=Zf,Ce="onMouseLeave",ne="onMouseEnter",ee="mouse",(i==="pointerout"||i==="pointerover")&&(ze=tp,Ce="onPointerLeave",ne="onPointerEnter",ee="pointer"),Ft=Le==null?ye:cr(Le),se=Be==null?ye:cr(Be),ye=new ze(Ce,ee+"leave",Le,l,be),ye.target=Ft,ye.relatedTarget=se,Ce=null,js(be)===le&&(ze=new ze(ne,ee+"enter",Be,l,be),ze.target=se,ze.relatedTarget=Ft,Ce=ze),Ft=Ce,Le&&Be)t:{for(ze=Le,ne=Be,ee=0,se=ze;se;se=ar(se))ee++;for(se=0,Ce=ne;Ce;Ce=ar(Ce))se++;for(;0<ee-se;)ze=ar(ze),ee--;for(;0<se-ee;)ne=ar(ne),se--;for(;ee--;){if(ze===ne||ne!==null&&ze===ne.alternate)break t;ze=ar(ze),ne=ar(ne)}ze=null}else ze=null;Le!==null&&jp(Se,ye,Le,ze,!1),Be!==null&&Ft!==null&&jp(Se,Ft,Be,ze,!0)}}e:{if(ye=le?cr(le):window,Le=ye.nodeName&&ye.nodeName.toLowerCase(),Le==="select"||Le==="input"&&ye.type==="file")var Fe=rS;else if(ap(ye))if(cp)Fe=cS;else{Fe=aS;var Ue=oS}else(Le=ye.nodeName)&&Le.toLowerCase()==="input"&&(ye.type==="checkbox"||ye.type==="radio")&&(Fe=lS);if(Fe&&(Fe=Fe(i,le))){lp(Se,Fe,l,be);break e}Ue&&Ue(i,ye,le),i==="focusout"&&(Ue=ye._wrapperState)&&Ue.controlled&&ye.type==="number"&&dt(ye,"number",ye.value)}switch(Ue=le?cr(le):window,i){case"focusin":(ap(Ue)||Ue.contentEditable==="true")&&(rr=Ue,Rc=le,co=null);break;case"focusout":co=Rc=rr=null;break;case"mousedown":Pc=!0;break;case"contextmenu":case"mouseup":case"dragend":Pc=!1,vp(Se,l,be);break;case"selectionchange":if(hS)break;case"keydown":case"keyup":vp(Se,l,be)}var We;if(Cc)e:{switch(i){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else sr?rp(i,l)&&(Ge="onCompositionEnd"):i==="keydown"&&l.keyCode===229&&(Ge="onCompositionStart");Ge&&(np&&l.locale!=="ko"&&(sr||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&sr&&(We=Qf()):(Yi=be,yc="value"in Yi?Yi.value:Yi.textContent,sr=!0)),Ue=Ca(le,Ge),0<Ue.length&&(Ge=new ep(Ge,i,null,l,be),Se.push({event:Ge,listeners:Ue}),We?Ge.data=We:(We=op(l),We!==null&&(Ge.data=We)))),(We=eS?tS(i,l):nS(i,l))&&(le=Ca(le,"onBeforeInput"),0<le.length&&(be=new ep("onBeforeInput","beforeinput",null,l,be),Se.push({event:be,listeners:le}),be.data=We))}Ep(Se,r)})}function fo(i,r,l){return{instance:i,listener:r,currentTarget:l}}function Ca(i,r){for(var l=r+"Capture",d=[];i!==null;){var g=i,_=g.stateNode;g.tag===5&&_!==null&&(g=_,_=Ke(i,l),_!=null&&d.unshift(fo(i,_,g)),_=Ke(i,r),_!=null&&d.push(fo(i,_,g))),i=i.return}return d}function ar(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function jp(i,r,l,d,g){for(var _=r._reactName,P=[];l!==null&&l!==d;){var V=l,J=V.alternate,le=V.stateNode;if(J!==null&&J===d)break;V.tag===5&&le!==null&&(V=le,g?(J=Ke(l,_),J!=null&&P.unshift(fo(l,J,V))):g||(J=Ke(l,_),J!=null&&P.push(fo(l,J,V)))),l=l.return}P.length!==0&&i.push({event:r,listeners:P})}var gS=/\r\n?/g,vS=/\u0000|\uFFFD/g;function Rp(i){return(typeof i=="string"?i:""+i).replace(gS,`
38
- `).replace(vS,"")}function Ea(i,r,l){if(r=Rp(r),Rp(i)!==r&&l)throw Error(n(425))}function Na(){}var Ic=null,Oc=null;function Bc(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var zc=typeof setTimeout=="function"?setTimeout:void 0,_S=typeof clearTimeout=="function"?clearTimeout:void 0,Pp=typeof Promise=="function"?Promise:void 0,yS=typeof queueMicrotask=="function"?queueMicrotask:typeof Pp<"u"?function(i){return Pp.resolve(null).then(i).catch(wS)}:zc;function wS(i){setTimeout(function(){throw i})}function Fc(i,r){var l=r,d=0;do{var g=l.nextSibling;if(i.removeChild(l),g&&g.nodeType===8)if(l=g.data,l==="/$"){if(d===0){i.removeChild(g),no(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=g}while(l);no(r)}function Xi(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function Lp(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return i;r--}else l==="/$"&&r++}i=i.previousSibling}return null}var lr=Math.random().toString(36).slice(2),hi="__reactFiber$"+lr,po="__reactProps$"+lr,ji="__reactContainer$"+lr,$c="__reactEvents$"+lr,bS="__reactListeners$"+lr,SS="__reactHandles$"+lr;function js(i){var r=i[hi];if(r)return r;for(var l=i.parentNode;l;){if(r=l[ji]||l[hi]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(i=Lp(i);i!==null;){if(l=i[hi])return l;i=Lp(i)}return r}i=l,l=i.parentNode}return null}function mo(i){return i=i[hi]||i[ji],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function cr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function ja(i){return i[po]||null}var Hc=[],ur=-1;function Qi(i){return{current:i}}function kt(i){0>ur||(i.current=Hc[ur],Hc[ur]=null,ur--)}function yt(i,r){ur++,Hc[ur]=i.current,i.current=r}var Ji={},gn=Qi(Ji),jn=Qi(!1),Rs=Ji;function dr(i,r){var l=i.type.contextTypes;if(!l)return Ji;var d=i.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var g={},_;for(_ in l)g[_]=r[_];return d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=g),g}function Rn(i){return i=i.childContextTypes,i!=null}function Ra(){kt(jn),kt(gn)}function Ap(i,r,l){if(gn.current!==Ji)throw Error(n(168));yt(gn,r),yt(jn,l)}function Tp(i,r,l){var d=i.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var g in d)if(!(g in r))throw Error(n(108,we(i)||"Unknown",g));return D({},l,d)}function Pa(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ji,Rs=gn.current,yt(gn,i),yt(jn,jn.current),!0}function Dp(i,r,l){var d=i.stateNode;if(!d)throw Error(n(169));l?(i=Tp(i,r,Rs),d.__reactInternalMemoizedMergedChildContext=i,kt(jn),kt(gn),yt(gn,i)):kt(jn),yt(jn,l)}var Ri=null,La=!1,Uc=!1;function Mp(i){Ri===null?Ri=[i]:Ri.push(i)}function xS(i){La=!0,Mp(i)}function Zi(){if(!Uc&&Ri!==null){Uc=!0;var i=0,r=mt;try{var l=Ri;for(mt=1;i<l.length;i++){var d=l[i];do d=d(!0);while(d!==null)}Ri=null,La=!1}catch(g){throw Ri!==null&&(Ri=Ri.slice(i+1)),Ns(He,Zi),g}finally{mt=r,Uc=!1}}return null}var hr=[],fr=0,Aa=null,Ta=0,qn=[],Vn=0,Ps=null,Pi=1,Li="";function Ls(i,r){hr[fr++]=Ta,hr[fr++]=Aa,Aa=i,Ta=r}function Ip(i,r,l){qn[Vn++]=Pi,qn[Vn++]=Li,qn[Vn++]=Ps,Ps=i;var d=Pi;i=Li;var g=32-Nn(d)-1;d&=~(1<<g),l+=1;var _=32-Nn(r)+g;if(30<_){var P=g-g%5;_=(d&(1<<P)-1).toString(32),d>>=P,g-=P,Pi=1<<32-Nn(r)+g|l<<g|d,Li=_+i}else Pi=1<<_|l<<g|d,Li=i}function Wc(i){i.return!==null&&(Ls(i,1),Ip(i,1,0))}function Kc(i){for(;i===Aa;)Aa=hr[--fr],hr[fr]=null,Ta=hr[--fr],hr[fr]=null;for(;i===Ps;)Ps=qn[--Vn],qn[Vn]=null,Li=qn[--Vn],qn[Vn]=null,Pi=qn[--Vn],qn[Vn]=null}var In=null,On=null,Nt=!1,si=null;function Op(i,r){var l=Qn(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=i,r=i.deletions,r===null?(i.deletions=[l],i.flags|=16):r.push(l)}function Bp(i,r){switch(i.tag){case 5:var l=i.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,In=i,On=Xi(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,In=i,On=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Ps!==null?{id:Pi,overflow:Li}:null,i.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Qn(18,null,null,0),l.stateNode=r,l.return=i,i.child=l,In=i,On=null,!0):!1;default:return!1}}function qc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Vc(i){if(Nt){var r=On;if(r){var l=r;if(!Bp(i,r)){if(qc(i))throw Error(n(418));r=Xi(l.nextSibling);var d=In;r&&Bp(i,r)?Op(d,l):(i.flags=i.flags&-4097|2,Nt=!1,In=i)}}else{if(qc(i))throw Error(n(418));i.flags=i.flags&-4097|2,Nt=!1,In=i}}}function zp(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;In=i}function Da(i){if(i!==In)return!1;if(!Nt)return zp(i),Nt=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Bc(i.type,i.memoizedProps)),r&&(r=On)){if(qc(i))throw Fp(),Error(n(418));for(;r;)Op(i,r),r=Xi(r.nextSibling)}if(zp(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="/$"){if(r===0){On=Xi(i.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}i=i.nextSibling}On=null}}else On=In?Xi(i.stateNode.nextSibling):null;return!0}function Fp(){for(var i=On;i;)i=Xi(i.nextSibling)}function pr(){On=In=null,Nt=!1}function Yc(i){si===null?si=[i]:si.push(i)}var kS=I.ReactCurrentBatchConfig;function go(i,r,l){if(i=l.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var d=l.stateNode}if(!d)throw Error(n(147,i));var g=d,_=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===_?r.ref:(r=function(P){var V=g.refs;P===null?delete V[_]:V[_]=P},r._stringRef=_,r)}if(typeof i!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,i))}return i}function Ma(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function $p(i){var r=i._init;return r(i._payload)}function Hp(i){function r(ne,ee){if(i){var se=ne.deletions;se===null?(ne.deletions=[ee],ne.flags|=16):se.push(ee)}}function l(ne,ee){if(!i)return null;for(;ee!==null;)r(ne,ee),ee=ee.sibling;return null}function d(ne,ee){for(ne=new Map;ee!==null;)ee.key!==null?ne.set(ee.key,ee):ne.set(ee.index,ee),ee=ee.sibling;return ne}function g(ne,ee){return ne=as(ne,ee),ne.index=0,ne.sibling=null,ne}function _(ne,ee,se){return ne.index=se,i?(se=ne.alternate,se!==null?(se=se.index,se<ee?(ne.flags|=2,ee):se):(ne.flags|=2,ee)):(ne.flags|=1048576,ee)}function P(ne){return i&&ne.alternate===null&&(ne.flags|=2),ne}function V(ne,ee,se,Ce){return ee===null||ee.tag!==6?(ee=zu(se,ne.mode,Ce),ee.return=ne,ee):(ee=g(ee,se),ee.return=ne,ee)}function J(ne,ee,se,Ce){var Fe=se.type;return Fe===z?be(ne,ee,se.props.children,Ce,se.key):ee!==null&&(ee.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===$&&$p(Fe)===ee.type)?(Ce=g(ee,se.props),Ce.ref=go(ne,ee,se),Ce.return=ne,Ce):(Ce=rl(se.type,se.key,se.props,null,ne.mode,Ce),Ce.ref=go(ne,ee,se),Ce.return=ne,Ce)}function le(ne,ee,se,Ce){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==se.containerInfo||ee.stateNode.implementation!==se.implementation?(ee=Fu(se,ne.mode,Ce),ee.return=ne,ee):(ee=g(ee,se.children||[]),ee.return=ne,ee)}function be(ne,ee,se,Ce,Fe){return ee===null||ee.tag!==7?(ee=zs(se,ne.mode,Ce,Fe),ee.return=ne,ee):(ee=g(ee,se),ee.return=ne,ee)}function Se(ne,ee,se){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=zu(""+ee,ne.mode,se),ee.return=ne,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case K:return se=rl(ee.type,ee.key,ee.props,null,ne.mode,se),se.ref=go(ne,null,ee),se.return=ne,se;case Y:return ee=Fu(ee,ne.mode,se),ee.return=ne,ee;case $:var Ce=ee._init;return Se(ne,Ce(ee._payload),se)}if(ht(ee)||O(ee))return ee=zs(ee,ne.mode,se,null),ee.return=ne,ee;Ma(ne,ee)}return null}function ye(ne,ee,se,Ce){var Fe=ee!==null?ee.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Fe!==null?null:V(ne,ee,""+se,Ce);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case K:return se.key===Fe?J(ne,ee,se,Ce):null;case Y:return se.key===Fe?le(ne,ee,se,Ce):null;case $:return Fe=se._init,ye(ne,ee,Fe(se._payload),Ce)}if(ht(se)||O(se))return Fe!==null?null:be(ne,ee,se,Ce,null);Ma(ne,se)}return null}function Le(ne,ee,se,Ce,Fe){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number")return ne=ne.get(se)||null,V(ee,ne,""+Ce,Fe);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case K:return ne=ne.get(Ce.key===null?se:Ce.key)||null,J(ee,ne,Ce,Fe);case Y:return ne=ne.get(Ce.key===null?se:Ce.key)||null,le(ee,ne,Ce,Fe);case $:var Ue=Ce._init;return Le(ne,ee,se,Ue(Ce._payload),Fe)}if(ht(Ce)||O(Ce))return ne=ne.get(se)||null,be(ee,ne,Ce,Fe,null);Ma(ee,Ce)}return null}function Be(ne,ee,se,Ce){for(var Fe=null,Ue=null,We=ee,Ge=ee=0,sn=null;We!==null&&Ge<se.length;Ge++){We.index>Ge?(sn=We,We=null):sn=We.sibling;var ut=ye(ne,We,se[Ge],Ce);if(ut===null){We===null&&(We=sn);break}i&&We&&ut.alternate===null&&r(ne,We),ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut,We=sn}if(Ge===se.length)return l(ne,We),Nt&&Ls(ne,Ge),Fe;if(We===null){for(;Ge<se.length;Ge++)We=Se(ne,se[Ge],Ce),We!==null&&(ee=_(We,ee,Ge),Ue===null?Fe=We:Ue.sibling=We,Ue=We);return Nt&&Ls(ne,Ge),Fe}for(We=d(ne,We);Ge<se.length;Ge++)sn=Le(We,ne,Ge,se[Ge],Ce),sn!==null&&(i&&sn.alternate!==null&&We.delete(sn.key===null?Ge:sn.key),ee=_(sn,ee,Ge),Ue===null?Fe=sn:Ue.sibling=sn,Ue=sn);return i&&We.forEach(function(ls){return r(ne,ls)}),Nt&&Ls(ne,Ge),Fe}function ze(ne,ee,se,Ce){var Fe=O(se);if(typeof Fe!="function")throw Error(n(150));if(se=Fe.call(se),se==null)throw Error(n(151));for(var Ue=Fe=null,We=ee,Ge=ee=0,sn=null,ut=se.next();We!==null&&!ut.done;Ge++,ut=se.next()){We.index>Ge?(sn=We,We=null):sn=We.sibling;var ls=ye(ne,We,ut.value,Ce);if(ls===null){We===null&&(We=sn);break}i&&We&&ls.alternate===null&&r(ne,We),ee=_(ls,ee,Ge),Ue===null?Fe=ls:Ue.sibling=ls,Ue=ls,We=sn}if(ut.done)return l(ne,We),Nt&&Ls(ne,Ge),Fe;if(We===null){for(;!ut.done;Ge++,ut=se.next())ut=Se(ne,ut.value,Ce),ut!==null&&(ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut);return Nt&&Ls(ne,Ge),Fe}for(We=d(ne,We);!ut.done;Ge++,ut=se.next())ut=Le(We,ne,Ge,ut.value,Ce),ut!==null&&(i&&ut.alternate!==null&&We.delete(ut.key===null?Ge:ut.key),ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut);return i&&We.forEach(function(i0){return r(ne,i0)}),Nt&&Ls(ne,Ge),Fe}function Ft(ne,ee,se,Ce){if(typeof se=="object"&&se!==null&&se.type===z&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case K:e:{for(var Fe=se.key,Ue=ee;Ue!==null;){if(Ue.key===Fe){if(Fe=se.type,Fe===z){if(Ue.tag===7){l(ne,Ue.sibling),ee=g(Ue,se.props.children),ee.return=ne,ne=ee;break e}}else if(Ue.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===$&&$p(Fe)===Ue.type){l(ne,Ue.sibling),ee=g(Ue,se.props),ee.ref=go(ne,Ue,se),ee.return=ne,ne=ee;break e}l(ne,Ue);break}else r(ne,Ue);Ue=Ue.sibling}se.type===z?(ee=zs(se.props.children,ne.mode,Ce,se.key),ee.return=ne,ne=ee):(Ce=rl(se.type,se.key,se.props,null,ne.mode,Ce),Ce.ref=go(ne,ee,se),Ce.return=ne,ne=Ce)}return P(ne);case Y:e:{for(Ue=se.key;ee!==null;){if(ee.key===Ue)if(ee.tag===4&&ee.stateNode.containerInfo===se.containerInfo&&ee.stateNode.implementation===se.implementation){l(ne,ee.sibling),ee=g(ee,se.children||[]),ee.return=ne,ne=ee;break e}else{l(ne,ee);break}else r(ne,ee);ee=ee.sibling}ee=Fu(se,ne.mode,Ce),ee.return=ne,ne=ee}return P(ne);case $:return Ue=se._init,Ft(ne,ee,Ue(se._payload),Ce)}if(ht(se))return Be(ne,ee,se,Ce);if(O(se))return ze(ne,ee,se,Ce);Ma(ne,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,ee!==null&&ee.tag===6?(l(ne,ee.sibling),ee=g(ee,se),ee.return=ne,ne=ee):(l(ne,ee),ee=zu(se,ne.mode,Ce),ee.return=ne,ne=ee),P(ne)):l(ne,ee)}return Ft}var mr=Hp(!0),Up=Hp(!1),Ia=Qi(null),Oa=null,gr=null,Gc=null;function Xc(){Gc=gr=Oa=null}function Qc(i){var r=Ia.current;kt(Ia),i._currentValue=r}function Jc(i,r,l){for(;i!==null;){var d=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),i===l)break;i=i.return}}function vr(i,r){Oa=i,Gc=gr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(Pn=!0),i.firstContext=null)}function Yn(i){var r=i._currentValue;if(Gc!==i)if(i={context:i,memoizedValue:r,next:null},gr===null){if(Oa===null)throw Error(n(308));gr=i,Oa.dependencies={lanes:0,firstContext:i}}else gr=gr.next=i;return r}var As=null;function Zc(i){As===null?As=[i]:As.push(i)}function Wp(i,r,l,d){var g=r.interleaved;return g===null?(l.next=l,Zc(r)):(l.next=g.next,g.next=l),r.interleaved=l,Ai(i,d)}function Ai(i,r){i.lanes|=r;var l=i.alternate;for(l!==null&&(l.lanes|=r),l=i,i=i.return;i!==null;)i.childLanes|=r,l=i.alternate,l!==null&&(l.childLanes|=r),l=i,i=i.return;return l.tag===3?l.stateNode:null}var es=!1;function eu(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kp(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ti(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function ts(i,r,l){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(lt&2)!==0){var g=d.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),d.pending=r,Ai(i,l)}return g=d.interleaved,g===null?(r.next=r,Zc(d)):(r.next=g.next,g.next=r),d.interleaved=r,Ai(i,l)}function Ba(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,pc(i,l)}}function qp(i,r){var l=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var g=null,_=null;if(l=l.firstBaseUpdate,l!==null){do{var P={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};_===null?g=_=P:_=_.next=P,l=l.next}while(l!==null);_===null?g=_=r:_=_.next=r}else g=_=r;l={baseState:d.baseState,firstBaseUpdate:g,lastBaseUpdate:_,shared:d.shared,effects:d.effects},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}function za(i,r,l,d){var g=i.updateQueue;es=!1;var _=g.firstBaseUpdate,P=g.lastBaseUpdate,V=g.shared.pending;if(V!==null){g.shared.pending=null;var J=V,le=J.next;J.next=null,P===null?_=le:P.next=le,P=J;var be=i.alternate;be!==null&&(be=be.updateQueue,V=be.lastBaseUpdate,V!==P&&(V===null?be.firstBaseUpdate=le:V.next=le,be.lastBaseUpdate=J))}if(_!==null){var Se=g.baseState;P=0,be=le=J=null,V=_;do{var ye=V.lane,Le=V.eventTime;if((d&ye)===ye){be!==null&&(be=be.next={eventTime:Le,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Be=i,ze=V;switch(ye=r,Le=l,ze.tag){case 1:if(Be=ze.payload,typeof Be=="function"){Se=Be.call(Le,Se,ye);break e}Se=Be;break e;case 3:Be.flags=Be.flags&-65537|128;case 0:if(Be=ze.payload,ye=typeof Be=="function"?Be.call(Le,Se,ye):Be,ye==null)break e;Se=D({},Se,ye);break e;case 2:es=!0}}V.callback!==null&&V.lane!==0&&(i.flags|=64,ye=g.effects,ye===null?g.effects=[V]:ye.push(V))}else Le={eventTime:Le,lane:ye,tag:V.tag,payload:V.payload,callback:V.callback,next:null},be===null?(le=be=Le,J=Se):be=be.next=Le,P|=ye;if(V=V.next,V===null){if(V=g.shared.pending,V===null)break;ye=V,V=ye.next,ye.next=null,g.lastBaseUpdate=ye,g.shared.pending=null}}while(!0);if(be===null&&(J=Se),g.baseState=J,g.firstBaseUpdate=le,g.lastBaseUpdate=be,r=g.shared.interleaved,r!==null){g=r;do P|=g.lane,g=g.next;while(g!==r)}else _===null&&(g.shared.lanes=0);Ms|=P,i.lanes=P,i.memoizedState=Se}}function Vp(i,r,l){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var d=i[r],g=d.callback;if(g!==null){if(d.callback=null,d=l,typeof g!="function")throw Error(n(191,g));g.call(d)}}}var vo={},fi=Qi(vo),_o=Qi(vo),yo=Qi(vo);function Ts(i){if(i===vo)throw Error(n(174));return i}function tu(i,r){switch(yt(yo,r),yt(_o,i),yt(fi,vo),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:re(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=re(r,i)}kt(fi),yt(fi,r)}function _r(){kt(fi),kt(_o),kt(yo)}function Yp(i){Ts(yo.current);var r=Ts(fi.current),l=re(r,i.type);r!==l&&(yt(_o,i),yt(fi,l))}function nu(i){_o.current===i&&(kt(fi),kt(_o))}var Lt=Qi(0);function Fa(i){for(var r=i;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var iu=[];function su(){for(var i=0;i<iu.length;i++)iu[i]._workInProgressVersionPrimary=null;iu.length=0}var $a=I.ReactCurrentDispatcher,ru=I.ReactCurrentBatchConfig,Ds=0,At=null,Vt=null,tn=null,Ha=!1,wo=!1,bo=0,CS=0;function vn(){throw Error(n(321))}function ou(i,r){if(r===null)return!1;for(var l=0;l<r.length&&l<i.length;l++)if(!ii(i[l],r[l]))return!1;return!0}function au(i,r,l,d,g,_){if(Ds=_,At=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,$a.current=i===null||i.memoizedState===null?RS:PS,i=l(d,g),wo){_=0;do{if(wo=!1,bo=0,25<=_)throw Error(n(301));_+=1,tn=Vt=null,r.updateQueue=null,$a.current=LS,i=l(d,g)}while(wo)}if($a.current=Ka,r=Vt!==null&&Vt.next!==null,Ds=0,tn=Vt=At=null,Ha=!1,r)throw Error(n(300));return i}function lu(){var i=bo!==0;return bo=0,i}function pi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?At.memoizedState=tn=i:tn=tn.next=i,tn}function Gn(){if(Vt===null){var i=At.alternate;i=i!==null?i.memoizedState:null}else i=Vt.next;var r=tn===null?At.memoizedState:tn.next;if(r!==null)tn=r,Vt=i;else{if(i===null)throw Error(n(310));Vt=i,i={memoizedState:Vt.memoizedState,baseState:Vt.baseState,baseQueue:Vt.baseQueue,queue:Vt.queue,next:null},tn===null?At.memoizedState=tn=i:tn=tn.next=i}return tn}function So(i,r){return typeof r=="function"?r(i):r}function cu(i){var r=Gn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=Vt,g=d.baseQueue,_=l.pending;if(_!==null){if(g!==null){var P=g.next;g.next=_.next,_.next=P}d.baseQueue=g=_,l.pending=null}if(g!==null){_=g.next,d=d.baseState;var V=P=null,J=null,le=_;do{var be=le.lane;if((Ds&be)===be)J!==null&&(J=J.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),d=le.hasEagerState?le.eagerState:i(d,le.action);else{var Se={lane:be,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};J===null?(V=J=Se,P=d):J=J.next=Se,At.lanes|=be,Ms|=be}le=le.next}while(le!==null&&le!==_);J===null?P=d:J.next=V,ii(d,r.memoizedState)||(Pn=!0),r.memoizedState=d,r.baseState=P,r.baseQueue=J,l.lastRenderedState=d}if(i=l.interleaved,i!==null){g=i;do _=g.lane,At.lanes|=_,Ms|=_,g=g.next;while(g!==i)}else g===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function uu(i){var r=Gn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=l.dispatch,g=l.pending,_=r.memoizedState;if(g!==null){l.pending=null;var P=g=g.next;do _=i(_,P.action),P=P.next;while(P!==g);ii(_,r.memoizedState)||(Pn=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),l.lastRenderedState=_}return[_,d]}function Gp(){}function Xp(i,r){var l=At,d=Gn(),g=r(),_=!ii(d.memoizedState,g);if(_&&(d.memoizedState=g,Pn=!0),d=d.queue,du(Zp.bind(null,l,d,i),[i]),d.getSnapshot!==r||_||tn!==null&&tn.memoizedState.tag&1){if(l.flags|=2048,xo(9,Jp.bind(null,l,d,g,r),void 0,null),nn===null)throw Error(n(349));(Ds&30)!==0||Qp(l,r,g)}return g}function Qp(i,r,l){i.flags|=16384,i={getSnapshot:r,value:l},r=At.updateQueue,r===null?(r={lastEffect:null,stores:null},At.updateQueue=r,r.stores=[i]):(l=r.stores,l===null?r.stores=[i]:l.push(i))}function Jp(i,r,l,d){r.value=l,r.getSnapshot=d,em(r)&&tm(i)}function Zp(i,r,l){return l(function(){em(r)&&tm(i)})}function em(i){var r=i.getSnapshot;i=i.value;try{var l=r();return!ii(i,l)}catch{return!0}}function tm(i){var r=Ai(i,1);r!==null&&li(r,i,1,-1)}function nm(i){var r=pi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:So,lastRenderedState:i},r.queue=i,i=i.dispatch=jS.bind(null,At,i),[r.memoizedState,i]}function xo(i,r,l,d){return i={tag:i,create:r,destroy:l,deps:d,next:null},r=At.updateQueue,r===null?(r={lastEffect:null,stores:null},At.updateQueue=r,r.lastEffect=i.next=i):(l=r.lastEffect,l===null?r.lastEffect=i.next=i:(d=l.next,l.next=i,i.next=d,r.lastEffect=i)),i}function im(){return Gn().memoizedState}function Ua(i,r,l,d){var g=pi();At.flags|=i,g.memoizedState=xo(1|r,l,void 0,d===void 0?null:d)}function Wa(i,r,l,d){var g=Gn();d=d===void 0?null:d;var _=void 0;if(Vt!==null){var P=Vt.memoizedState;if(_=P.destroy,d!==null&&ou(d,P.deps)){g.memoizedState=xo(r,l,_,d);return}}At.flags|=i,g.memoizedState=xo(1|r,l,_,d)}function sm(i,r){return Ua(8390656,8,i,r)}function du(i,r){return Wa(2048,8,i,r)}function rm(i,r){return Wa(4,2,i,r)}function om(i,r){return Wa(4,4,i,r)}function am(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function lm(i,r,l){return l=l!=null?l.concat([i]):null,Wa(4,4,am.bind(null,r,i),l)}function hu(){}function cm(i,r){var l=Gn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(l.memoizedState=[i,r],i)}function um(i,r){var l=Gn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(i=i(),l.memoizedState=[i,r],i)}function dm(i,r,l){return(Ds&21)===0?(i.baseState&&(i.baseState=!1,Pn=!0),i.memoizedState=l):(ii(l,r)||(l=$f(),At.lanes|=l,Ms|=l,i.baseState=!0),r)}function ES(i,r){var l=mt;mt=l!==0&&4>l?l:4,i(!0);var d=ru.transition;ru.transition={};try{i(!1),r()}finally{mt=l,ru.transition=d}}function hm(){return Gn().memoizedState}function NS(i,r,l){var d=rs(i);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},fm(i))pm(r,l);else if(l=Wp(i,r,l,d),l!==null){var g=Sn();li(l,i,d,g),mm(l,r,d)}}function jS(i,r,l){var d=rs(i),g={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(fm(i))pm(r,g);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var P=r.lastRenderedState,V=_(P,l);if(g.hasEagerState=!0,g.eagerState=V,ii(V,P)){var J=r.interleaved;J===null?(g.next=g,Zc(r)):(g.next=J.next,J.next=g),r.interleaved=g;return}}catch{}finally{}l=Wp(i,r,g,d),l!==null&&(g=Sn(),li(l,i,d,g),mm(l,r,d))}}function fm(i){var r=i.alternate;return i===At||r!==null&&r===At}function pm(i,r){wo=Ha=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function mm(i,r,l){if((l&4194240)!==0){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,pc(i,l)}}var Ka={readContext:Yn,useCallback:vn,useContext:vn,useEffect:vn,useImperativeHandle:vn,useInsertionEffect:vn,useLayoutEffect:vn,useMemo:vn,useReducer:vn,useRef:vn,useState:vn,useDebugValue:vn,useDeferredValue:vn,useTransition:vn,useMutableSource:vn,useSyncExternalStore:vn,useId:vn,unstable_isNewReconciler:!1},RS={readContext:Yn,useCallback:function(i,r){return pi().memoizedState=[i,r===void 0?null:r],i},useContext:Yn,useEffect:sm,useImperativeHandle:function(i,r,l){return l=l!=null?l.concat([i]):null,Ua(4194308,4,am.bind(null,r,i),l)},useLayoutEffect:function(i,r){return Ua(4194308,4,i,r)},useInsertionEffect:function(i,r){return Ua(4,2,i,r)},useMemo:function(i,r){var l=pi();return r=r===void 0?null:r,i=i(),l.memoizedState=[i,r],i},useReducer:function(i,r,l){var d=pi();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},d.queue=i,i=i.dispatch=NS.bind(null,At,i),[d.memoizedState,i]},useRef:function(i){var r=pi();return i={current:i},r.memoizedState=i},useState:nm,useDebugValue:hu,useDeferredValue:function(i){return pi().memoizedState=i},useTransition:function(){var i=nm(!1),r=i[0];return i=ES.bind(null,i[1]),pi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,l){var d=At,g=pi();if(Nt){if(l===void 0)throw Error(n(407));l=l()}else{if(l=r(),nn===null)throw Error(n(349));(Ds&30)!==0||Qp(d,r,l)}g.memoizedState=l;var _={value:l,getSnapshot:r};return g.queue=_,sm(Zp.bind(null,d,_,i),[i]),d.flags|=2048,xo(9,Jp.bind(null,d,_,l,r),void 0,null),l},useId:function(){var i=pi(),r=nn.identifierPrefix;if(Nt){var l=Li,d=Pi;l=(d&~(1<<32-Nn(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=bo++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=CS++,r=":"+r+"r"+l.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},PS={readContext:Yn,useCallback:cm,useContext:Yn,useEffect:du,useImperativeHandle:lm,useInsertionEffect:rm,useLayoutEffect:om,useMemo:um,useReducer:cu,useRef:im,useState:function(){return cu(So)},useDebugValue:hu,useDeferredValue:function(i){var r=Gn();return dm(r,Vt.memoizedState,i)},useTransition:function(){var i=cu(So)[0],r=Gn().memoizedState;return[i,r]},useMutableSource:Gp,useSyncExternalStore:Xp,useId:hm,unstable_isNewReconciler:!1},LS={readContext:Yn,useCallback:cm,useContext:Yn,useEffect:du,useImperativeHandle:lm,useInsertionEffect:rm,useLayoutEffect:om,useMemo:um,useReducer:uu,useRef:im,useState:function(){return uu(So)},useDebugValue:hu,useDeferredValue:function(i){var r=Gn();return Vt===null?r.memoizedState=i:dm(r,Vt.memoizedState,i)},useTransition:function(){var i=uu(So)[0],r=Gn().memoizedState;return[i,r]},useMutableSource:Gp,useSyncExternalStore:Xp,useId:hm,unstable_isNewReconciler:!1};function ri(i,r){if(i&&i.defaultProps){r=D({},r),i=i.defaultProps;for(var l in i)r[l]===void 0&&(r[l]=i[l]);return r}return r}function fu(i,r,l,d){r=i.memoizedState,l=l(d,r),l=l==null?r:D({},r,l),i.memoizedState=l,i.lanes===0&&(i.updateQueue.baseState=l)}var qa={isMounted:function(i){return(i=i._reactInternals)?zt(i)===i:!1},enqueueSetState:function(i,r,l){i=i._reactInternals;var d=Sn(),g=rs(i),_=Ti(d,g);_.payload=r,l!=null&&(_.callback=l),r=ts(i,_,g),r!==null&&(li(r,i,g,d),Ba(r,i,g))},enqueueReplaceState:function(i,r,l){i=i._reactInternals;var d=Sn(),g=rs(i),_=Ti(d,g);_.tag=1,_.payload=r,l!=null&&(_.callback=l),r=ts(i,_,g),r!==null&&(li(r,i,g,d),Ba(r,i,g))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var l=Sn(),d=rs(i),g=Ti(l,d);g.tag=2,r!=null&&(g.callback=r),r=ts(i,g,d),r!==null&&(li(r,i,d,l),Ba(r,i,d))}};function gm(i,r,l,d,g,_,P){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,_,P):r.prototype&&r.prototype.isPureReactComponent?!lo(l,d)||!lo(g,_):!0}function vm(i,r,l){var d=!1,g=Ji,_=r.contextType;return typeof _=="object"&&_!==null?_=Yn(_):(g=Rn(r)?Rs:gn.current,d=r.contextTypes,_=(d=d!=null)?dr(i,g):Ji),r=new r(l,_),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qa,i.stateNode=r,r._reactInternals=i,d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=g,i.__reactInternalMemoizedMaskedChildContext=_),r}function _m(i,r,l,d){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==i&&qa.enqueueReplaceState(r,r.state,null)}function pu(i,r,l,d){var g=i.stateNode;g.props=l,g.state=i.memoizedState,g.refs={},eu(i);var _=r.contextType;typeof _=="object"&&_!==null?g.context=Yn(_):(_=Rn(r)?Rs:gn.current,g.context=dr(i,_)),g.state=i.memoizedState,_=r.getDerivedStateFromProps,typeof _=="function"&&(fu(i,r,_,l),g.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(r=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),r!==g.state&&qa.enqueueReplaceState(g,g.state,null),za(i,l,g,d),g.state=i.memoizedState),typeof g.componentDidMount=="function"&&(i.flags|=4194308)}function yr(i,r){try{var l="",d=r;do l+=ue(d),d=d.return;while(d);var g=l}catch(_){g=`
37
+ `+g[P].replace(" at new "," at ");return i.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",i.displayName)),J}while(1<=P&&0<=V);break}}}finally{X=!1,Error.prepareStackTrace=l}return(i=i?i.displayName||i.name:"")?W(i):""}function ce(i){switch(i.tag){case 5:return W(i.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return i=ie(i.type,!1),i;case 11:return i=ie(i.type.render,!1),i;case 1:return i=ie(i.type,!0),i;default:return""}}function fe(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case z:return"Fragment";case Y:return"Portal";case G:return"Profiler";case Z:return"StrictMode";case j:return"Suspense";case T:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case B:return(i.displayName||"Context")+".Consumer";case Q:return(i._context.displayName||"Context")+".Provider";case M:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case L:return r=i.displayName||null,r!==null?r:fe(i.type)||"Memo";case $:r=i._payload,i=i._init;try{return fe(i(r))}catch{}}return null}function we(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(r);case 8:return r===Z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function me(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function xe(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function $e(i){var r=xe(i)?"checked":"value",l=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),d=""+i[r];if(!i.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var g=l.get,_=l.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return g.call(this)},set:function(P){d=""+P,_.call(this,P)}}),Object.defineProperty(i,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(P){d=""+P},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function ft(i){i._valueTracker||(i._valueTracker=$e(i))}function qe(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return i&&(d=xe(i)?i.checked?"true":"false":i.value),i=d,i!==l?(r.setValue(i),!0):!1}function Ae(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}}function Rt(i,r){var l=r.checked;return D({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??i._wrapperState.initialChecked})}function Vt(i,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=me(r.value!=null?r.value:l),i._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Oe(i,r){r=r.checked,r!=null&&F(i,"checked",r,!1)}function Pt(i,r){Oe(i,r);var l=me(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+l):i.value!==""+l&&(i.value=""+l);else if(d==="submit"||d==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?dt(i,r.type,l):r.hasOwnProperty("defaultValue")&&dt(i,r.type,me(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function bt(i,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,l||r===i.value||(i.value=r),i.defaultValue=r}l=i.name,l!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,l!==""&&(i.name=l)}function dt(i,r,l){(r!=="number"||Ae(i.ownerDocument)!==i)&&(l==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+l&&(i.defaultValue=""+l))}var ht=Array.isArray;function Qe(i,r,l,d){if(i=i.options,r){r={};for(var g=0;g<l.length;g++)r["$"+l[g]]=!0;for(l=0;l<i.length;l++)g=r.hasOwnProperty("$"+i[l].value),i[l].selected!==g&&(i[l].selected=g),g&&d&&(i[l].defaultSelected=!0)}else{for(l=""+me(l),r=null,g=0;g<i.length;g++){if(i[g].value===l){i[g].selected=!0,d&&(i[g].defaultSelected=!0);return}r!==null||i[g].disabled||(r=i[g])}r!==null&&(r.selected=!0)}}function ot(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return D({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function oe(i,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(n(92));if(ht(l)){if(1<l.length)throw Error(n(93));l=l[0]}r=l}r==null&&(r=""),l=r}i._wrapperState={initialValue:me(l)}}function ke(i,r){var l=me(r.value),d=me(r.defaultValue);l!=null&&(l=""+l,l!==i.value&&(i.value=l),r.defaultValue==null&&i.defaultValue!==l&&(i.defaultValue=l)),d!=null&&(i.defaultValue=""+d)}function Te(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function ae(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function re(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?ae(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Pe,q=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,g){MSApp.execUnsafeLocalFunction(function(){return i(r,l,d,g)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(Pe=Pe||document.createElement("div"),Pe.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Pe.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function te(i,r){if(r){var l=i.firstChild;if(l&&l===i.lastChild&&l.nodeType===3){l.nodeValue=r;return}}i.textContent=r}var U={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ue=["Webkit","ms","Moz","O"];Object.keys(U).forEach(function(i){ue.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),U[r]=U[i]})});function de(i,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||U.hasOwnProperty(i)&&U[i]?(""+r).trim():r+"px"}function ge(i,r){i=i.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,g=de(l,r[l],d);l==="float"&&(l="cssFloat"),d?i.setProperty(l,g):i[l]=g}}var De=D({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function _e(i,r){if(r){if(De[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function Ee(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";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 nt=null;function at(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Je=null,Mt=null,ct=null;function et(i){if(i=mo(i)){if(typeof Je!="function")throw Error(n(280));var r=i.stateNode;r&&(r=ja(r),Je(i.stateNode,i.type,r))}}function Zt(i){Mt?ct?ct.push(i):ct=[i]:Mt=i}function ni(){if(Mt){var i=Mt,r=ct;if(ct=Mt=null,et(i),r)for(i=0;i<r.length;i++)et(r[i])}}function Wn(i,r){return i(r)}function ui(){}var he=!1;function je(i,r,l){if(he)return i(r,l);he=!0;try{return Wn(i,r,l)}finally{he=!1,(Mt!==null||ct!==null)&&(ui(),ni())}}function Ke(i,r){var l=i.stateNode;if(l===null)return null;var d=ja(l);if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(l&&typeof l!="function")throw Error(n(231,r,typeof l));return l}var pt=!1;if(h)try{var vt={};Object.defineProperty(vt,"passive",{get:function(){pt=!0}}),window.addEventListener("test",vt,vt),window.removeEventListener("test",vt,vt)}catch{pt=!1}function bs(i,r,l,d,g,_,P,V,J){var le=Array.prototype.slice.call(arguments,3);try{r.apply(l,le)}catch(be){this.onError(be)}}var Ui=!1,Ss=null,xs=!1,di=null,Kn={onError:function(i){Ui=!0,Ss=i}};function Kr(i,r,l,d,g,_,P,V,J){Ui=!1,Ss=null,bs.apply(Kn,arguments)}function la(i,r,l,d,g,_,P,V,J){if(Kr.apply(this,arguments),Ui){if(Ui){var le=Ss;Ui=!1,Ss=null}else throw Error(n(198));xs||(xs=!0,di=le)}}function zt(i){var r=i,l=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(l=r.return),i=r.return;while(i)}return r.tag===3?l:null}function qr(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function ks(i){if(zt(i)!==i)throw Error(n(188))}function Cs(i){var r=i.alternate;if(!r){if(r=zt(i),r===null)throw Error(n(188));return r!==i?null:i}for(var l=i,d=r;;){var g=l.return;if(g===null)break;var _=g.alternate;if(_===null){if(d=g.return,d!==null){l=d;continue}break}if(g.child===_.child){for(_=g.child;_;){if(_===l)return ks(g),i;if(_===d)return ks(g),r;_=_.sibling}throw Error(n(188))}if(l.return!==d.return)l=g,d=_;else{for(var P=!1,V=g.child;V;){if(V===l){P=!0,l=g,d=_;break}if(V===d){P=!0,d=g,l=_;break}V=V.sibling}if(!P){for(V=_.child;V;){if(V===l){P=!0,l=_,d=g;break}if(V===d){P=!0,d=_,l=g;break}V=V.sibling}if(!P)throw Error(n(189))}}if(l.alternate!==d)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?i:r}function Es(i){return i=Cs(i),i!==null?Vr(i):null}function Vr(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=Vr(i);if(r!==null)return r;i=i.sibling}return null}var Ns=t.unstable_scheduleCallback,Yr=t.unstable_cancelCallback,tr=t.unstable_shouldYield,ca=t.unstable_requestPaint,Et=t.unstable_now,pe=t.unstable_getCurrentPriorityLevel,He=t.unstable_ImmediatePriority,Ye=t.unstable_UserBlockingPriority,Ve=t.unstable_NormalPriority,_t=t.unstable_LowPriority,St=t.unstable_IdlePriority,Ut=null,en=null;function dc(i){if(en&&typeof en.onCommitFiberRoot=="function")try{en.onCommitFiberRoot(Ut,i,void 0,(i.current.flags&128)===128)}catch{}}var Nn=Math.clz32?Math.clz32:Sb,Gr=Math.log,bb=Math.LN2;function Sb(i){return i>>>=0,i===0?32:31-(Gr(i)/bb|0)|0}var ua=64,da=4194304;function Xr(i){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: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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ha(i,r){var l=i.pendingLanes;if(l===0)return 0;var d=0,g=i.suspendedLanes,_=i.pingedLanes,P=l&268435455;if(P!==0){var V=P&~g;V!==0?d=Xr(V):(_&=P,_!==0&&(d=Xr(_)))}else P=l&~g,P!==0?d=Xr(P):_!==0&&(d=Xr(_));if(d===0)return 0;if(r!==0&&r!==d&&(r&g)===0&&(g=d&-d,_=r&-r,g>=_||g===16&&(_&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=d;0<r;)l=31-Nn(r),g=1<<l,d|=i[l],r&=~g;return d}function xb(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function kb(i,r){for(var l=i.suspendedLanes,d=i.pingedLanes,g=i.expirationTimes,_=i.pendingLanes;0<_;){var P=31-Nn(_),V=1<<P,J=g[P];J===-1?((V&l)===0||(V&d)!==0)&&(g[P]=xb(V,r)):J<=r&&(i.expiredLanes|=V),_&=~V}}function hc(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function $f(){var i=ua;return ua<<=1,(ua&4194240)===0&&(ua=64),i}function fc(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Qr(i,r,l){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Nn(r),i[r]=l}function Cb(i,r){var l=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var d=i.eventTimes;for(i=i.expirationTimes;0<l;){var g=31-Nn(l),_=1<<g;r[g]=0,d[g]=-1,i[g]=-1,l&=~_}}function pc(i,r){var l=i.entangledLanes|=r;for(i=i.entanglements;l;){var d=31-Nn(l),g=1<<d;g&r|i[d]&r&&(i[d]|=r),l&=~g}}var mt=0;function Hf(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Uf,mc,Wf,Kf,qf,gc=!1,fa=[],Wi=null,Ki=null,qi=null,Jr=new Map,Zr=new Map,Vi=[],Eb="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 submit".split(" ");function Vf(i,r){switch(i){case"focusin":case"focusout":Wi=null;break;case"dragenter":case"dragleave":Ki=null;break;case"mouseover":case"mouseout":qi=null;break;case"pointerover":case"pointerout":Jr.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Zr.delete(r.pointerId)}}function eo(i,r,l,d,g,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:_,targetContainers:[g]},r!==null&&(r=mo(r),r!==null&&mc(r)),i):(i.eventSystemFlags|=d,r=i.targetContainers,g!==null&&r.indexOf(g)===-1&&r.push(g),i)}function Nb(i,r,l,d,g){switch(r){case"focusin":return Wi=eo(Wi,i,r,l,d,g),!0;case"dragenter":return Ki=eo(Ki,i,r,l,d,g),!0;case"mouseover":return qi=eo(qi,i,r,l,d,g),!0;case"pointerover":var _=g.pointerId;return Jr.set(_,eo(Jr.get(_)||null,i,r,l,d,g)),!0;case"gotpointercapture":return _=g.pointerId,Zr.set(_,eo(Zr.get(_)||null,i,r,l,d,g)),!0}return!1}function Yf(i){var r=js(i.target);if(r!==null){var l=zt(r);if(l!==null){if(r=l.tag,r===13){if(r=qr(l),r!==null){i.blockedOn=r,qf(i.priority,function(){Wf(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){i.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}i.blockedOn=null}function pa(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var l=_c(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(l===null){l=i.nativeEvent;var d=new l.constructor(l.type,l);nt=d,l.target.dispatchEvent(d),nt=null}else return r=mo(l),r!==null&&mc(r),i.blockedOn=l,!1;r.shift()}return!0}function Gf(i,r,l){pa(i)&&l.delete(r)}function jb(){gc=!1,Wi!==null&&pa(Wi)&&(Wi=null),Ki!==null&&pa(Ki)&&(Ki=null),qi!==null&&pa(qi)&&(qi=null),Jr.forEach(Gf),Zr.forEach(Gf)}function to(i,r){i.blockedOn===r&&(i.blockedOn=null,gc||(gc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,jb)))}function no(i){function r(g){return to(g,i)}if(0<fa.length){to(fa[0],i);for(var l=1;l<fa.length;l++){var d=fa[l];d.blockedOn===i&&(d.blockedOn=null)}}for(Wi!==null&&to(Wi,i),Ki!==null&&to(Ki,i),qi!==null&&to(qi,i),Jr.forEach(r),Zr.forEach(r),l=0;l<Vi.length;l++)d=Vi[l],d.blockedOn===i&&(d.blockedOn=null);for(;0<Vi.length&&(l=Vi[0],l.blockedOn===null);)Yf(l),l.blockedOn===null&&Vi.shift()}var nr=I.ReactCurrentBatchConfig,ma=!0;function Rb(i,r,l,d){var g=mt,_=nr.transition;nr.transition=null;try{mt=1,vc(i,r,l,d)}finally{mt=g,nr.transition=_}}function Pb(i,r,l,d){var g=mt,_=nr.transition;nr.transition=null;try{mt=4,vc(i,r,l,d)}finally{mt=g,nr.transition=_}}function vc(i,r,l,d){if(ma){var g=_c(i,r,l,d);if(g===null)Mc(i,r,d,ga,l),Vf(i,d);else if(Nb(g,i,r,l,d))d.stopPropagation();else if(Vf(i,d),r&4&&-1<Eb.indexOf(i)){for(;g!==null;){var _=mo(g);if(_!==null&&Uf(_),_=_c(i,r,l,d),_===null&&Mc(i,r,d,ga,l),_===g)break;g=_}g!==null&&d.stopPropagation()}else Mc(i,r,d,null,l)}}var ga=null;function _c(i,r,l,d){if(ga=null,i=at(d),i=js(i),i!==null)if(r=zt(i),r===null)i=null;else if(l=r.tag,l===13){if(i=qr(r),i!==null)return i;i=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return ga=i,null}function Xf(i){switch(i){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(pe()){case He:return 1;case Ye:return 4;case Ve:case _t:return 16;case St:return 536870912;default:return 16}default:return 16}}var Yi=null,yc=null,va=null;function Qf(){if(va)return va;var i,r=yc,l=r.length,d,g="value"in Yi?Yi.value:Yi.textContent,_=g.length;for(i=0;i<l&&r[i]===g[i];i++);var P=l-i;for(d=1;d<=P&&r[l-d]===g[_-d];d++);return va=g.slice(i,1<d?1-d:void 0)}function _a(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function ya(){return!0}function Jf(){return!1}function Mn(i){function r(l,d,g,_,P){this._reactName=l,this._targetInst=g,this.type=d,this.nativeEvent=_,this.target=P,this.currentTarget=null;for(var V in i)i.hasOwnProperty(V)&&(l=i[V],this[V]=l?l(_):_[V]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?ya:Jf,this.isPropagationStopped=Jf,this}return D(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ya)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ya)},persist:function(){},isPersistent:ya}),r}var ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wc=Mn(ir),io=D({},ir,{view:0,detail:0}),Lb=Mn(io),bc,Sc,so,wa=D({},io,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kc,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!==so&&(so&&i.type==="mousemove"?(bc=i.screenX-so.screenX,Sc=i.screenY-so.screenY):Sc=bc=0,so=i),bc)},movementY:function(i){return"movementY"in i?i.movementY:Sc}}),Zf=Mn(wa),Ab=D({},wa,{dataTransfer:0}),Tb=Mn(Ab),Db=D({},io,{relatedTarget:0}),xc=Mn(Db),Mb=D({},ir,{animationName:0,elapsedTime:0,pseudoElement:0}),Ib=Mn(Mb),Ob=D({},ir,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Bb=Mn(Ob),zb=D({},ir,{data:0}),ep=Mn(zb),Fb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$b={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"},Hb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ub(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Hb[i])?!!r[i]:!1}function kc(){return Ub}var Wb=D({},io,{key:function(i){if(i.key){var r=Fb[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=_a(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?$b[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kc,charCode:function(i){return i.type==="keypress"?_a(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?_a(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Kb=Mn(Wb),qb=D({},wa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tp=Mn(qb),Vb=D({},io,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kc}),Yb=Mn(Vb),Gb=D({},ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xb=Mn(Gb),Qb=D({},wa,{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}),Jb=Mn(Qb),Zb=[9,13,27,32],Cc=h&&"CompositionEvent"in window,ro=null;h&&"documentMode"in document&&(ro=document.documentMode);var eS=h&&"TextEvent"in window&&!ro,np=h&&(!Cc||ro&&8<ro&&11>=ro),ip=" ",sp=!1;function rp(i,r){switch(i){case"keyup":return Zb.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function op(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var sr=!1;function tS(i,r){switch(i){case"compositionend":return op(r);case"keypress":return r.which!==32?null:(sp=!0,ip);case"textInput":return i=r.data,i===ip&&sp?null:i;default:return null}}function nS(i,r){if(sr)return i==="compositionend"||!Cc&&rp(i,r)?(i=Qf(),va=yc=Yi=null,sr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return np&&r.locale!=="ko"?null:r.data;default:return null}}var iS={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 ap(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!iS[i.type]:r==="textarea"}function lp(i,r,l,d){Zt(d),r=Ca(r,"onChange"),0<r.length&&(l=new wc("onChange","change",null,l,d),i.push({event:l,listeners:r}))}var oo=null,ao=null;function sS(i){Ep(i,0)}function ba(i){var r=cr(i);if(qe(r))return i}function rS(i,r){if(i==="change")return r}var cp=!1;if(h){var Ec;if(h){var Nc="oninput"in document;if(!Nc){var up=document.createElement("div");up.setAttribute("oninput","return;"),Nc=typeof up.oninput=="function"}Ec=Nc}else Ec=!1;cp=Ec&&(!document.documentMode||9<document.documentMode)}function dp(){oo&&(oo.detachEvent("onpropertychange",hp),ao=oo=null)}function hp(i){if(i.propertyName==="value"&&ba(ao)){var r=[];lp(r,ao,i,at(i)),je(sS,r)}}function oS(i,r,l){i==="focusin"?(dp(),oo=r,ao=l,oo.attachEvent("onpropertychange",hp)):i==="focusout"&&dp()}function aS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return ba(ao)}function lS(i,r){if(i==="click")return ba(r)}function cS(i,r){if(i==="input"||i==="change")return ba(r)}function uS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var ii=typeof Object.is=="function"?Object.is:uS;function lo(i,r){if(ii(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var l=Object.keys(i),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var g=l[d];if(!f.call(r,g)||!ii(i[g],r[g]))return!1}return!0}function fp(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function pp(i,r){var l=fp(i);i=0;for(var d;l;){if(l.nodeType===3){if(d=i+l.textContent.length,i<=r&&d>=r)return{node:l,offset:r-i};i=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=fp(l)}}function mp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?mp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function gp(){for(var i=window,r=Ae();r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ae(i.document)}return r}function jc(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function dS(i){var r=gp(),l=i.focusedElem,d=i.selectionRange;if(r!==l&&l&&l.ownerDocument&&mp(l.ownerDocument.documentElement,l)){if(d!==null&&jc(l)){if(r=d.start,i=d.end,i===void 0&&(i=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(i,l.value.length);else if(i=(r=l.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var g=l.textContent.length,_=Math.min(d.start,g);d=d.end===void 0?_:Math.min(d.end,g),!i.extend&&_>d&&(g=d,d=_,_=g),g=pp(l,_);var P=pp(l,d);g&&P&&(i.rangeCount!==1||i.anchorNode!==g.node||i.anchorOffset!==g.offset||i.focusNode!==P.node||i.focusOffset!==P.offset)&&(r=r.createRange(),r.setStart(g.node,g.offset),i.removeAllRanges(),_>d?(i.addRange(r),i.extend(P.node,P.offset)):(r.setEnd(P.node,P.offset),i.addRange(r)))}}for(r=[],i=l;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)i=r[l],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var hS=h&&"documentMode"in document&&11>=document.documentMode,rr=null,Rc=null,co=null,Pc=!1;function vp(i,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Pc||rr==null||rr!==Ae(d)||(d=rr,"selectionStart"in d&&jc(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),co&&lo(co,d)||(co=d,d=Ca(Rc,"onSelect"),0<d.length&&(r=new wc("onSelect","select",null,r,l),i.push({event:r,listeners:d}),r.target=rr)))}function Sa(i,r){var l={};return l[i.toLowerCase()]=r.toLowerCase(),l["Webkit"+i]="webkit"+r,l["Moz"+i]="moz"+r,l}var or={animationend:Sa("Animation","AnimationEnd"),animationiteration:Sa("Animation","AnimationIteration"),animationstart:Sa("Animation","AnimationStart"),transitionend:Sa("Transition","TransitionEnd")},Lc={},_p={};h&&(_p=document.createElement("div").style,"AnimationEvent"in window||(delete or.animationend.animation,delete or.animationiteration.animation,delete or.animationstart.animation),"TransitionEvent"in window||delete or.transitionend.transition);function xa(i){if(Lc[i])return Lc[i];if(!or[i])return i;var r=or[i],l;for(l in r)if(r.hasOwnProperty(l)&&l in _p)return Lc[i]=r[l];return i}var yp=xa("animationend"),wp=xa("animationiteration"),bp=xa("animationstart"),Sp=xa("transitionend"),xp=new Map,kp="abort auxClick 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(" ");function Gi(i,r){xp.set(i,r),a(r,[i])}for(var Ac=0;Ac<kp.length;Ac++){var Tc=kp[Ac],fS=Tc.toLowerCase(),pS=Tc[0].toUpperCase()+Tc.slice(1);Gi(fS,"on"+pS)}Gi(yp,"onAnimationEnd"),Gi(wp,"onAnimationIteration"),Gi(bp,"onAnimationStart"),Gi("dblclick","onDoubleClick"),Gi("focusin","onFocus"),Gi("focusout","onBlur"),Gi(Sp,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("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(" "),mS=new Set("cancel close invalid load scroll toggle".split(" ").concat(uo));function Cp(i,r,l){var d=i.type||"unknown-event";i.currentTarget=l,la(d,r,void 0,i),i.currentTarget=null}function Ep(i,r){r=(r&4)!==0;for(var l=0;l<i.length;l++){var d=i[l],g=d.event;d=d.listeners;e:{var _=void 0;if(r)for(var P=d.length-1;0<=P;P--){var V=d[P],J=V.instance,le=V.currentTarget;if(V=V.listener,J!==_&&g.isPropagationStopped())break e;Cp(g,V,le),_=J}else for(P=0;P<d.length;P++){if(V=d[P],J=V.instance,le=V.currentTarget,V=V.listener,J!==_&&g.isPropagationStopped())break e;Cp(g,V,le),_=J}}}if(xs)throw i=di,xs=!1,di=null,i}function xt(i,r){var l=r[$c];l===void 0&&(l=r[$c]=new Set);var d=i+"__bubble";l.has(d)||(Np(r,i,2,!1),l.add(d))}function Dc(i,r,l){var d=0;r&&(d|=4),Np(l,i,d,r)}var ka="_reactListening"+Math.random().toString(36).slice(2);function ho(i){if(!i[ka]){i[ka]=!0,s.forEach(function(l){l!=="selectionchange"&&(mS.has(l)||Dc(l,!1,i),Dc(l,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[ka]||(r[ka]=!0,Dc("selectionchange",!1,r))}}function Np(i,r,l,d){switch(Xf(r)){case 1:var g=Rb;break;case 4:g=Pb;break;default:g=vc}l=g.bind(null,r,l,i),g=void 0,!pt||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(g=!0),d?g!==void 0?i.addEventListener(r,l,{capture:!0,passive:g}):i.addEventListener(r,l,!0):g!==void 0?i.addEventListener(r,l,{passive:g}):i.addEventListener(r,l,!1)}function Mc(i,r,l,d,g){var _=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var P=d.tag;if(P===3||P===4){var V=d.stateNode.containerInfo;if(V===g||V.nodeType===8&&V.parentNode===g)break;if(P===4)for(P=d.return;P!==null;){var J=P.tag;if((J===3||J===4)&&(J=P.stateNode.containerInfo,J===g||J.nodeType===8&&J.parentNode===g))return;P=P.return}for(;V!==null;){if(P=js(V),P===null)return;if(J=P.tag,J===5||J===6){d=_=P;continue e}V=V.parentNode}}d=d.return}je(function(){var le=_,be=at(l),Se=[];e:{var ye=xp.get(i);if(ye!==void 0){var Le=wc,Be=i;switch(i){case"keypress":if(_a(l)===0)break e;case"keydown":case"keyup":Le=Kb;break;case"focusin":Be="focus",Le=xc;break;case"focusout":Be="blur",Le=xc;break;case"beforeblur":case"afterblur":Le=xc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Le=Zf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Le=Tb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Le=Yb;break;case yp:case wp:case bp:Le=Ib;break;case Sp:Le=Xb;break;case"scroll":Le=Lb;break;case"wheel":Le=Jb;break;case"copy":case"cut":case"paste":Le=Bb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Le=tp}var ze=(r&4)!==0,Ft=!ze&&i==="scroll",ne=ze?ye!==null?ye+"Capture":null:ye;ze=[];for(var ee=le,se;ee!==null;){se=ee;var Ce=se.stateNode;if(se.tag===5&&Ce!==null&&(se=Ce,ne!==null&&(Ce=Ke(ee,ne),Ce!=null&&ze.push(fo(ee,Ce,se)))),Ft)break;ee=ee.return}0<ze.length&&(ye=new Le(ye,Be,null,l,be),Se.push({event:ye,listeners:ze}))}}if((r&7)===0){e:{if(ye=i==="mouseover"||i==="pointerover",Le=i==="mouseout"||i==="pointerout",ye&&l!==nt&&(Be=l.relatedTarget||l.fromElement)&&(js(Be)||Be[ji]))break e;if((Le||ye)&&(ye=be.window===be?be:(ye=be.ownerDocument)?ye.defaultView||ye.parentWindow:window,Le?(Be=l.relatedTarget||l.toElement,Le=le,Be=Be?js(Be):null,Be!==null&&(Ft=zt(Be),Be!==Ft||Be.tag!==5&&Be.tag!==6)&&(Be=null)):(Le=null,Be=le),Le!==Be)){if(ze=Zf,Ce="onMouseLeave",ne="onMouseEnter",ee="mouse",(i==="pointerout"||i==="pointerover")&&(ze=tp,Ce="onPointerLeave",ne="onPointerEnter",ee="pointer"),Ft=Le==null?ye:cr(Le),se=Be==null?ye:cr(Be),ye=new ze(Ce,ee+"leave",Le,l,be),ye.target=Ft,ye.relatedTarget=se,Ce=null,js(be)===le&&(ze=new ze(ne,ee+"enter",Be,l,be),ze.target=se,ze.relatedTarget=Ft,Ce=ze),Ft=Ce,Le&&Be)t:{for(ze=Le,ne=Be,ee=0,se=ze;se;se=ar(se))ee++;for(se=0,Ce=ne;Ce;Ce=ar(Ce))se++;for(;0<ee-se;)ze=ar(ze),ee--;for(;0<se-ee;)ne=ar(ne),se--;for(;ee--;){if(ze===ne||ne!==null&&ze===ne.alternate)break t;ze=ar(ze),ne=ar(ne)}ze=null}else ze=null;Le!==null&&jp(Se,ye,Le,ze,!1),Be!==null&&Ft!==null&&jp(Se,Ft,Be,ze,!0)}}e:{if(ye=le?cr(le):window,Le=ye.nodeName&&ye.nodeName.toLowerCase(),Le==="select"||Le==="input"&&ye.type==="file")var Fe=rS;else if(ap(ye))if(cp)Fe=cS;else{Fe=aS;var Ue=oS}else(Le=ye.nodeName)&&Le.toLowerCase()==="input"&&(ye.type==="checkbox"||ye.type==="radio")&&(Fe=lS);if(Fe&&(Fe=Fe(i,le))){lp(Se,Fe,l,be);break e}Ue&&Ue(i,ye,le),i==="focusout"&&(Ue=ye._wrapperState)&&Ue.controlled&&ye.type==="number"&&dt(ye,"number",ye.value)}switch(Ue=le?cr(le):window,i){case"focusin":(ap(Ue)||Ue.contentEditable==="true")&&(rr=Ue,Rc=le,co=null);break;case"focusout":co=Rc=rr=null;break;case"mousedown":Pc=!0;break;case"contextmenu":case"mouseup":case"dragend":Pc=!1,vp(Se,l,be);break;case"selectionchange":if(hS)break;case"keydown":case"keyup":vp(Se,l,be)}var We;if(Cc)e:{switch(i){case"compositionstart":var Ge="onCompositionStart";break e;case"compositionend":Ge="onCompositionEnd";break e;case"compositionupdate":Ge="onCompositionUpdate";break e}Ge=void 0}else sr?rp(i,l)&&(Ge="onCompositionEnd"):i==="keydown"&&l.keyCode===229&&(Ge="onCompositionStart");Ge&&(np&&l.locale!=="ko"&&(sr||Ge!=="onCompositionStart"?Ge==="onCompositionEnd"&&sr&&(We=Qf()):(Yi=be,yc="value"in Yi?Yi.value:Yi.textContent,sr=!0)),Ue=Ca(le,Ge),0<Ue.length&&(Ge=new ep(Ge,i,null,l,be),Se.push({event:Ge,listeners:Ue}),We?Ge.data=We:(We=op(l),We!==null&&(Ge.data=We)))),(We=eS?tS(i,l):nS(i,l))&&(le=Ca(le,"onBeforeInput"),0<le.length&&(be=new ep("onBeforeInput","beforeinput",null,l,be),Se.push({event:be,listeners:le}),be.data=We))}Ep(Se,r)})}function fo(i,r,l){return{instance:i,listener:r,currentTarget:l}}function Ca(i,r){for(var l=r+"Capture",d=[];i!==null;){var g=i,_=g.stateNode;g.tag===5&&_!==null&&(g=_,_=Ke(i,l),_!=null&&d.unshift(fo(i,_,g)),_=Ke(i,r),_!=null&&d.push(fo(i,_,g))),i=i.return}return d}function ar(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function jp(i,r,l,d,g){for(var _=r._reactName,P=[];l!==null&&l!==d;){var V=l,J=V.alternate,le=V.stateNode;if(J!==null&&J===d)break;V.tag===5&&le!==null&&(V=le,g?(J=Ke(l,_),J!=null&&P.unshift(fo(l,J,V))):g||(J=Ke(l,_),J!=null&&P.push(fo(l,J,V)))),l=l.return}P.length!==0&&i.push({event:r,listeners:P})}var gS=/\r\n?/g,vS=/\u0000|\uFFFD/g;function Rp(i){return(typeof i=="string"?i:""+i).replace(gS,`
38
+ `).replace(vS,"")}function Ea(i,r,l){if(r=Rp(r),Rp(i)!==r&&l)throw Error(n(425))}function Na(){}var Ic=null,Oc=null;function Bc(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var zc=typeof setTimeout=="function"?setTimeout:void 0,_S=typeof clearTimeout=="function"?clearTimeout:void 0,Pp=typeof Promise=="function"?Promise:void 0,yS=typeof queueMicrotask=="function"?queueMicrotask:typeof Pp<"u"?function(i){return Pp.resolve(null).then(i).catch(wS)}:zc;function wS(i){setTimeout(function(){throw i})}function Fc(i,r){var l=r,d=0;do{var g=l.nextSibling;if(i.removeChild(l),g&&g.nodeType===8)if(l=g.data,l==="/$"){if(d===0){i.removeChild(g),no(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=g}while(l);no(r)}function Xi(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function Lp(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return i;r--}else l==="/$"&&r++}i=i.previousSibling}return null}var lr=Math.random().toString(36).slice(2),hi="__reactFiber$"+lr,po="__reactProps$"+lr,ji="__reactContainer$"+lr,$c="__reactEvents$"+lr,bS="__reactListeners$"+lr,SS="__reactHandles$"+lr;function js(i){var r=i[hi];if(r)return r;for(var l=i.parentNode;l;){if(r=l[ji]||l[hi]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(i=Lp(i);i!==null;){if(l=i[hi])return l;i=Lp(i)}return r}i=l,l=i.parentNode}return null}function mo(i){return i=i[hi]||i[ji],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function cr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function ja(i){return i[po]||null}var Hc=[],ur=-1;function Qi(i){return{current:i}}function kt(i){0>ur||(i.current=Hc[ur],Hc[ur]=null,ur--)}function yt(i,r){ur++,Hc[ur]=i.current,i.current=r}var Ji={},gn=Qi(Ji),jn=Qi(!1),Rs=Ji;function dr(i,r){var l=i.type.contextTypes;if(!l)return Ji;var d=i.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var g={},_;for(_ in l)g[_]=r[_];return d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=g),g}function Rn(i){return i=i.childContextTypes,i!=null}function Ra(){kt(jn),kt(gn)}function Ap(i,r,l){if(gn.current!==Ji)throw Error(n(168));yt(gn,r),yt(jn,l)}function Tp(i,r,l){var d=i.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var g in d)if(!(g in r))throw Error(n(108,we(i)||"Unknown",g));return D({},l,d)}function Pa(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ji,Rs=gn.current,yt(gn,i),yt(jn,jn.current),!0}function Dp(i,r,l){var d=i.stateNode;if(!d)throw Error(n(169));l?(i=Tp(i,r,Rs),d.__reactInternalMemoizedMergedChildContext=i,kt(jn),kt(gn),yt(gn,i)):kt(jn),yt(jn,l)}var Ri=null,La=!1,Uc=!1;function Mp(i){Ri===null?Ri=[i]:Ri.push(i)}function xS(i){La=!0,Mp(i)}function Zi(){if(!Uc&&Ri!==null){Uc=!0;var i=0,r=mt;try{var l=Ri;for(mt=1;i<l.length;i++){var d=l[i];do d=d(!0);while(d!==null)}Ri=null,La=!1}catch(g){throw Ri!==null&&(Ri=Ri.slice(i+1)),Ns(He,Zi),g}finally{mt=r,Uc=!1}}return null}var hr=[],fr=0,Aa=null,Ta=0,qn=[],Vn=0,Ps=null,Pi=1,Li="";function Ls(i,r){hr[fr++]=Ta,hr[fr++]=Aa,Aa=i,Ta=r}function Ip(i,r,l){qn[Vn++]=Pi,qn[Vn++]=Li,qn[Vn++]=Ps,Ps=i;var d=Pi;i=Li;var g=32-Nn(d)-1;d&=~(1<<g),l+=1;var _=32-Nn(r)+g;if(30<_){var P=g-g%5;_=(d&(1<<P)-1).toString(32),d>>=P,g-=P,Pi=1<<32-Nn(r)+g|l<<g|d,Li=_+i}else Pi=1<<_|l<<g|d,Li=i}function Wc(i){i.return!==null&&(Ls(i,1),Ip(i,1,0))}function Kc(i){for(;i===Aa;)Aa=hr[--fr],hr[fr]=null,Ta=hr[--fr],hr[fr]=null;for(;i===Ps;)Ps=qn[--Vn],qn[Vn]=null,Li=qn[--Vn],qn[Vn]=null,Pi=qn[--Vn],qn[Vn]=null}var In=null,On=null,Nt=!1,si=null;function Op(i,r){var l=Qn(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=i,r=i.deletions,r===null?(i.deletions=[l],i.flags|=16):r.push(l)}function Bp(i,r){switch(i.tag){case 5:var l=i.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,In=i,On=Xi(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,In=i,On=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Ps!==null?{id:Pi,overflow:Li}:null,i.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Qn(18,null,null,0),l.stateNode=r,l.return=i,i.child=l,In=i,On=null,!0):!1;default:return!1}}function qc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Vc(i){if(Nt){var r=On;if(r){var l=r;if(!Bp(i,r)){if(qc(i))throw Error(n(418));r=Xi(l.nextSibling);var d=In;r&&Bp(i,r)?Op(d,l):(i.flags=i.flags&-4097|2,Nt=!1,In=i)}}else{if(qc(i))throw Error(n(418));i.flags=i.flags&-4097|2,Nt=!1,In=i}}}function zp(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;In=i}function Da(i){if(i!==In)return!1;if(!Nt)return zp(i),Nt=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Bc(i.type,i.memoizedProps)),r&&(r=On)){if(qc(i))throw Fp(),Error(n(418));for(;r;)Op(i,r),r=Xi(r.nextSibling)}if(zp(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var l=i.data;if(l==="/$"){if(r===0){On=Xi(i.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}i=i.nextSibling}On=null}}else On=In?Xi(i.stateNode.nextSibling):null;return!0}function Fp(){for(var i=On;i;)i=Xi(i.nextSibling)}function pr(){On=In=null,Nt=!1}function Yc(i){si===null?si=[i]:si.push(i)}var kS=I.ReactCurrentBatchConfig;function go(i,r,l){if(i=l.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var d=l.stateNode}if(!d)throw Error(n(147,i));var g=d,_=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===_?r.ref:(r=function(P){var V=g.refs;P===null?delete V[_]:V[_]=P},r._stringRef=_,r)}if(typeof i!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,i))}return i}function Ma(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function $p(i){var r=i._init;return r(i._payload)}function Hp(i){function r(ne,ee){if(i){var se=ne.deletions;se===null?(ne.deletions=[ee],ne.flags|=16):se.push(ee)}}function l(ne,ee){if(!i)return null;for(;ee!==null;)r(ne,ee),ee=ee.sibling;return null}function d(ne,ee){for(ne=new Map;ee!==null;)ee.key!==null?ne.set(ee.key,ee):ne.set(ee.index,ee),ee=ee.sibling;return ne}function g(ne,ee){return ne=as(ne,ee),ne.index=0,ne.sibling=null,ne}function _(ne,ee,se){return ne.index=se,i?(se=ne.alternate,se!==null?(se=se.index,se<ee?(ne.flags|=2,ee):se):(ne.flags|=2,ee)):(ne.flags|=1048576,ee)}function P(ne){return i&&ne.alternate===null&&(ne.flags|=2),ne}function V(ne,ee,se,Ce){return ee===null||ee.tag!==6?(ee=zu(se,ne.mode,Ce),ee.return=ne,ee):(ee=g(ee,se),ee.return=ne,ee)}function J(ne,ee,se,Ce){var Fe=se.type;return Fe===z?be(ne,ee,se.props.children,Ce,se.key):ee!==null&&(ee.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===$&&$p(Fe)===ee.type)?(Ce=g(ee,se.props),Ce.ref=go(ne,ee,se),Ce.return=ne,Ce):(Ce=rl(se.type,se.key,se.props,null,ne.mode,Ce),Ce.ref=go(ne,ee,se),Ce.return=ne,Ce)}function le(ne,ee,se,Ce){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==se.containerInfo||ee.stateNode.implementation!==se.implementation?(ee=Fu(se,ne.mode,Ce),ee.return=ne,ee):(ee=g(ee,se.children||[]),ee.return=ne,ee)}function be(ne,ee,se,Ce,Fe){return ee===null||ee.tag!==7?(ee=zs(se,ne.mode,Ce,Fe),ee.return=ne,ee):(ee=g(ee,se),ee.return=ne,ee)}function Se(ne,ee,se){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=zu(""+ee,ne.mode,se),ee.return=ne,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case K:return se=rl(ee.type,ee.key,ee.props,null,ne.mode,se),se.ref=go(ne,null,ee),se.return=ne,se;case Y:return ee=Fu(ee,ne.mode,se),ee.return=ne,ee;case $:var Ce=ee._init;return Se(ne,Ce(ee._payload),se)}if(ht(ee)||O(ee))return ee=zs(ee,ne.mode,se,null),ee.return=ne,ee;Ma(ne,ee)}return null}function ye(ne,ee,se,Ce){var Fe=ee!==null?ee.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Fe!==null?null:V(ne,ee,""+se,Ce);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case K:return se.key===Fe?J(ne,ee,se,Ce):null;case Y:return se.key===Fe?le(ne,ee,se,Ce):null;case $:return Fe=se._init,ye(ne,ee,Fe(se._payload),Ce)}if(ht(se)||O(se))return Fe!==null?null:be(ne,ee,se,Ce,null);Ma(ne,se)}return null}function Le(ne,ee,se,Ce,Fe){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number")return ne=ne.get(se)||null,V(ee,ne,""+Ce,Fe);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case K:return ne=ne.get(Ce.key===null?se:Ce.key)||null,J(ee,ne,Ce,Fe);case Y:return ne=ne.get(Ce.key===null?se:Ce.key)||null,le(ee,ne,Ce,Fe);case $:var Ue=Ce._init;return Le(ne,ee,se,Ue(Ce._payload),Fe)}if(ht(Ce)||O(Ce))return ne=ne.get(se)||null,be(ee,ne,Ce,Fe,null);Ma(ee,Ce)}return null}function Be(ne,ee,se,Ce){for(var Fe=null,Ue=null,We=ee,Ge=ee=0,sn=null;We!==null&&Ge<se.length;Ge++){We.index>Ge?(sn=We,We=null):sn=We.sibling;var ut=ye(ne,We,se[Ge],Ce);if(ut===null){We===null&&(We=sn);break}i&&We&&ut.alternate===null&&r(ne,We),ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut,We=sn}if(Ge===se.length)return l(ne,We),Nt&&Ls(ne,Ge),Fe;if(We===null){for(;Ge<se.length;Ge++)We=Se(ne,se[Ge],Ce),We!==null&&(ee=_(We,ee,Ge),Ue===null?Fe=We:Ue.sibling=We,Ue=We);return Nt&&Ls(ne,Ge),Fe}for(We=d(ne,We);Ge<se.length;Ge++)sn=Le(We,ne,Ge,se[Ge],Ce),sn!==null&&(i&&sn.alternate!==null&&We.delete(sn.key===null?Ge:sn.key),ee=_(sn,ee,Ge),Ue===null?Fe=sn:Ue.sibling=sn,Ue=sn);return i&&We.forEach(function(ls){return r(ne,ls)}),Nt&&Ls(ne,Ge),Fe}function ze(ne,ee,se,Ce){var Fe=O(se);if(typeof Fe!="function")throw Error(n(150));if(se=Fe.call(se),se==null)throw Error(n(151));for(var Ue=Fe=null,We=ee,Ge=ee=0,sn=null,ut=se.next();We!==null&&!ut.done;Ge++,ut=se.next()){We.index>Ge?(sn=We,We=null):sn=We.sibling;var ls=ye(ne,We,ut.value,Ce);if(ls===null){We===null&&(We=sn);break}i&&We&&ls.alternate===null&&r(ne,We),ee=_(ls,ee,Ge),Ue===null?Fe=ls:Ue.sibling=ls,Ue=ls,We=sn}if(ut.done)return l(ne,We),Nt&&Ls(ne,Ge),Fe;if(We===null){for(;!ut.done;Ge++,ut=se.next())ut=Se(ne,ut.value,Ce),ut!==null&&(ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut);return Nt&&Ls(ne,Ge),Fe}for(We=d(ne,We);!ut.done;Ge++,ut=se.next())ut=Le(We,ne,Ge,ut.value,Ce),ut!==null&&(i&&ut.alternate!==null&&We.delete(ut.key===null?Ge:ut.key),ee=_(ut,ee,Ge),Ue===null?Fe=ut:Ue.sibling=ut,Ue=ut);return i&&We.forEach(function(i0){return r(ne,i0)}),Nt&&Ls(ne,Ge),Fe}function Ft(ne,ee,se,Ce){if(typeof se=="object"&&se!==null&&se.type===z&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case K:e:{for(var Fe=se.key,Ue=ee;Ue!==null;){if(Ue.key===Fe){if(Fe=se.type,Fe===z){if(Ue.tag===7){l(ne,Ue.sibling),ee=g(Ue,se.props.children),ee.return=ne,ne=ee;break e}}else if(Ue.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===$&&$p(Fe)===Ue.type){l(ne,Ue.sibling),ee=g(Ue,se.props),ee.ref=go(ne,Ue,se),ee.return=ne,ne=ee;break e}l(ne,Ue);break}else r(ne,Ue);Ue=Ue.sibling}se.type===z?(ee=zs(se.props.children,ne.mode,Ce,se.key),ee.return=ne,ne=ee):(Ce=rl(se.type,se.key,se.props,null,ne.mode,Ce),Ce.ref=go(ne,ee,se),Ce.return=ne,ne=Ce)}return P(ne);case Y:e:{for(Ue=se.key;ee!==null;){if(ee.key===Ue)if(ee.tag===4&&ee.stateNode.containerInfo===se.containerInfo&&ee.stateNode.implementation===se.implementation){l(ne,ee.sibling),ee=g(ee,se.children||[]),ee.return=ne,ne=ee;break e}else{l(ne,ee);break}else r(ne,ee);ee=ee.sibling}ee=Fu(se,ne.mode,Ce),ee.return=ne,ne=ee}return P(ne);case $:return Ue=se._init,Ft(ne,ee,Ue(se._payload),Ce)}if(ht(se))return Be(ne,ee,se,Ce);if(O(se))return ze(ne,ee,se,Ce);Ma(ne,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,ee!==null&&ee.tag===6?(l(ne,ee.sibling),ee=g(ee,se),ee.return=ne,ne=ee):(l(ne,ee),ee=zu(se,ne.mode,Ce),ee.return=ne,ne=ee),P(ne)):l(ne,ee)}return Ft}var mr=Hp(!0),Up=Hp(!1),Ia=Qi(null),Oa=null,gr=null,Gc=null;function Xc(){Gc=gr=Oa=null}function Qc(i){var r=Ia.current;kt(Ia),i._currentValue=r}function Jc(i,r,l){for(;i!==null;){var d=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),i===l)break;i=i.return}}function vr(i,r){Oa=i,Gc=gr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(Pn=!0),i.firstContext=null)}function Yn(i){var r=i._currentValue;if(Gc!==i)if(i={context:i,memoizedValue:r,next:null},gr===null){if(Oa===null)throw Error(n(308));gr=i,Oa.dependencies={lanes:0,firstContext:i}}else gr=gr.next=i;return r}var As=null;function Zc(i){As===null?As=[i]:As.push(i)}function Wp(i,r,l,d){var g=r.interleaved;return g===null?(l.next=l,Zc(r)):(l.next=g.next,g.next=l),r.interleaved=l,Ai(i,d)}function Ai(i,r){i.lanes|=r;var l=i.alternate;for(l!==null&&(l.lanes|=r),l=i,i=i.return;i!==null;)i.childLanes|=r,l=i.alternate,l!==null&&(l.childLanes|=r),l=i,i=i.return;return l.tag===3?l.stateNode:null}var es=!1;function eu(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kp(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ti(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function ts(i,r,l){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(lt&2)!==0){var g=d.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),d.pending=r,Ai(i,l)}return g=d.interleaved,g===null?(r.next=r,Zc(d)):(r.next=g.next,g.next=r),d.interleaved=r,Ai(i,l)}function Ba(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,pc(i,l)}}function qp(i,r){var l=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var g=null,_=null;if(l=l.firstBaseUpdate,l!==null){do{var P={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};_===null?g=_=P:_=_.next=P,l=l.next}while(l!==null);_===null?g=_=r:_=_.next=r}else g=_=r;l={baseState:d.baseState,firstBaseUpdate:g,lastBaseUpdate:_,shared:d.shared,effects:d.effects},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}function za(i,r,l,d){var g=i.updateQueue;es=!1;var _=g.firstBaseUpdate,P=g.lastBaseUpdate,V=g.shared.pending;if(V!==null){g.shared.pending=null;var J=V,le=J.next;J.next=null,P===null?_=le:P.next=le,P=J;var be=i.alternate;be!==null&&(be=be.updateQueue,V=be.lastBaseUpdate,V!==P&&(V===null?be.firstBaseUpdate=le:V.next=le,be.lastBaseUpdate=J))}if(_!==null){var Se=g.baseState;P=0,be=le=J=null,V=_;do{var ye=V.lane,Le=V.eventTime;if((d&ye)===ye){be!==null&&(be=be.next={eventTime:Le,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var Be=i,ze=V;switch(ye=r,Le=l,ze.tag){case 1:if(Be=ze.payload,typeof Be=="function"){Se=Be.call(Le,Se,ye);break e}Se=Be;break e;case 3:Be.flags=Be.flags&-65537|128;case 0:if(Be=ze.payload,ye=typeof Be=="function"?Be.call(Le,Se,ye):Be,ye==null)break e;Se=D({},Se,ye);break e;case 2:es=!0}}V.callback!==null&&V.lane!==0&&(i.flags|=64,ye=g.effects,ye===null?g.effects=[V]:ye.push(V))}else Le={eventTime:Le,lane:ye,tag:V.tag,payload:V.payload,callback:V.callback,next:null},be===null?(le=be=Le,J=Se):be=be.next=Le,P|=ye;if(V=V.next,V===null){if(V=g.shared.pending,V===null)break;ye=V,V=ye.next,ye.next=null,g.lastBaseUpdate=ye,g.shared.pending=null}}while(!0);if(be===null&&(J=Se),g.baseState=J,g.firstBaseUpdate=le,g.lastBaseUpdate=be,r=g.shared.interleaved,r!==null){g=r;do P|=g.lane,g=g.next;while(g!==r)}else _===null&&(g.shared.lanes=0);Ms|=P,i.lanes=P,i.memoizedState=Se}}function Vp(i,r,l){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var d=i[r],g=d.callback;if(g!==null){if(d.callback=null,d=l,typeof g!="function")throw Error(n(191,g));g.call(d)}}}var vo={},fi=Qi(vo),_o=Qi(vo),yo=Qi(vo);function Ts(i){if(i===vo)throw Error(n(174));return i}function tu(i,r){switch(yt(yo,r),yt(_o,i),yt(fi,vo),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:re(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=re(r,i)}kt(fi),yt(fi,r)}function _r(){kt(fi),kt(_o),kt(yo)}function Yp(i){Ts(yo.current);var r=Ts(fi.current),l=re(r,i.type);r!==l&&(yt(_o,i),yt(fi,l))}function nu(i){_o.current===i&&(kt(fi),kt(_o))}var Lt=Qi(0);function Fa(i){for(var r=i;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var iu=[];function su(){for(var i=0;i<iu.length;i++)iu[i]._workInProgressVersionPrimary=null;iu.length=0}var $a=I.ReactCurrentDispatcher,ru=I.ReactCurrentBatchConfig,Ds=0,At=null,Yt=null,tn=null,Ha=!1,wo=!1,bo=0,CS=0;function vn(){throw Error(n(321))}function ou(i,r){if(r===null)return!1;for(var l=0;l<r.length&&l<i.length;l++)if(!ii(i[l],r[l]))return!1;return!0}function au(i,r,l,d,g,_){if(Ds=_,At=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,$a.current=i===null||i.memoizedState===null?RS:PS,i=l(d,g),wo){_=0;do{if(wo=!1,bo=0,25<=_)throw Error(n(301));_+=1,tn=Yt=null,r.updateQueue=null,$a.current=LS,i=l(d,g)}while(wo)}if($a.current=Ka,r=Yt!==null&&Yt.next!==null,Ds=0,tn=Yt=At=null,Ha=!1,r)throw Error(n(300));return i}function lu(){var i=bo!==0;return bo=0,i}function pi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?At.memoizedState=tn=i:tn=tn.next=i,tn}function Gn(){if(Yt===null){var i=At.alternate;i=i!==null?i.memoizedState:null}else i=Yt.next;var r=tn===null?At.memoizedState:tn.next;if(r!==null)tn=r,Yt=i;else{if(i===null)throw Error(n(310));Yt=i,i={memoizedState:Yt.memoizedState,baseState:Yt.baseState,baseQueue:Yt.baseQueue,queue:Yt.queue,next:null},tn===null?At.memoizedState=tn=i:tn=tn.next=i}return tn}function So(i,r){return typeof r=="function"?r(i):r}function cu(i){var r=Gn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=Yt,g=d.baseQueue,_=l.pending;if(_!==null){if(g!==null){var P=g.next;g.next=_.next,_.next=P}d.baseQueue=g=_,l.pending=null}if(g!==null){_=g.next,d=d.baseState;var V=P=null,J=null,le=_;do{var be=le.lane;if((Ds&be)===be)J!==null&&(J=J.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),d=le.hasEagerState?le.eagerState:i(d,le.action);else{var Se={lane:be,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};J===null?(V=J=Se,P=d):J=J.next=Se,At.lanes|=be,Ms|=be}le=le.next}while(le!==null&&le!==_);J===null?P=d:J.next=V,ii(d,r.memoizedState)||(Pn=!0),r.memoizedState=d,r.baseState=P,r.baseQueue=J,l.lastRenderedState=d}if(i=l.interleaved,i!==null){g=i;do _=g.lane,At.lanes|=_,Ms|=_,g=g.next;while(g!==i)}else g===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function uu(i){var r=Gn(),l=r.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=i;var d=l.dispatch,g=l.pending,_=r.memoizedState;if(g!==null){l.pending=null;var P=g=g.next;do _=i(_,P.action),P=P.next;while(P!==g);ii(_,r.memoizedState)||(Pn=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),l.lastRenderedState=_}return[_,d]}function Gp(){}function Xp(i,r){var l=At,d=Gn(),g=r(),_=!ii(d.memoizedState,g);if(_&&(d.memoizedState=g,Pn=!0),d=d.queue,du(Zp.bind(null,l,d,i),[i]),d.getSnapshot!==r||_||tn!==null&&tn.memoizedState.tag&1){if(l.flags|=2048,xo(9,Jp.bind(null,l,d,g,r),void 0,null),nn===null)throw Error(n(349));(Ds&30)!==0||Qp(l,r,g)}return g}function Qp(i,r,l){i.flags|=16384,i={getSnapshot:r,value:l},r=At.updateQueue,r===null?(r={lastEffect:null,stores:null},At.updateQueue=r,r.stores=[i]):(l=r.stores,l===null?r.stores=[i]:l.push(i))}function Jp(i,r,l,d){r.value=l,r.getSnapshot=d,em(r)&&tm(i)}function Zp(i,r,l){return l(function(){em(r)&&tm(i)})}function em(i){var r=i.getSnapshot;i=i.value;try{var l=r();return!ii(i,l)}catch{return!0}}function tm(i){var r=Ai(i,1);r!==null&&li(r,i,1,-1)}function nm(i){var r=pi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:So,lastRenderedState:i},r.queue=i,i=i.dispatch=jS.bind(null,At,i),[r.memoizedState,i]}function xo(i,r,l,d){return i={tag:i,create:r,destroy:l,deps:d,next:null},r=At.updateQueue,r===null?(r={lastEffect:null,stores:null},At.updateQueue=r,r.lastEffect=i.next=i):(l=r.lastEffect,l===null?r.lastEffect=i.next=i:(d=l.next,l.next=i,i.next=d,r.lastEffect=i)),i}function im(){return Gn().memoizedState}function Ua(i,r,l,d){var g=pi();At.flags|=i,g.memoizedState=xo(1|r,l,void 0,d===void 0?null:d)}function Wa(i,r,l,d){var g=Gn();d=d===void 0?null:d;var _=void 0;if(Yt!==null){var P=Yt.memoizedState;if(_=P.destroy,d!==null&&ou(d,P.deps)){g.memoizedState=xo(r,l,_,d);return}}At.flags|=i,g.memoizedState=xo(1|r,l,_,d)}function sm(i,r){return Ua(8390656,8,i,r)}function du(i,r){return Wa(2048,8,i,r)}function rm(i,r){return Wa(4,2,i,r)}function om(i,r){return Wa(4,4,i,r)}function am(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function lm(i,r,l){return l=l!=null?l.concat([i]):null,Wa(4,4,am.bind(null,r,i),l)}function hu(){}function cm(i,r){var l=Gn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(l.memoizedState=[i,r],i)}function um(i,r){var l=Gn();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&ou(r,d[1])?d[0]:(i=i(),l.memoizedState=[i,r],i)}function dm(i,r,l){return(Ds&21)===0?(i.baseState&&(i.baseState=!1,Pn=!0),i.memoizedState=l):(ii(l,r)||(l=$f(),At.lanes|=l,Ms|=l,i.baseState=!0),r)}function ES(i,r){var l=mt;mt=l!==0&&4>l?l:4,i(!0);var d=ru.transition;ru.transition={};try{i(!1),r()}finally{mt=l,ru.transition=d}}function hm(){return Gn().memoizedState}function NS(i,r,l){var d=rs(i);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},fm(i))pm(r,l);else if(l=Wp(i,r,l,d),l!==null){var g=Sn();li(l,i,d,g),mm(l,r,d)}}function jS(i,r,l){var d=rs(i),g={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(fm(i))pm(r,g);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var P=r.lastRenderedState,V=_(P,l);if(g.hasEagerState=!0,g.eagerState=V,ii(V,P)){var J=r.interleaved;J===null?(g.next=g,Zc(r)):(g.next=J.next,J.next=g),r.interleaved=g;return}}catch{}finally{}l=Wp(i,r,g,d),l!==null&&(g=Sn(),li(l,i,d,g),mm(l,r,d))}}function fm(i){var r=i.alternate;return i===At||r!==null&&r===At}function pm(i,r){wo=Ha=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function mm(i,r,l){if((l&4194240)!==0){var d=r.lanes;d&=i.pendingLanes,l|=d,r.lanes=l,pc(i,l)}}var Ka={readContext:Yn,useCallback:vn,useContext:vn,useEffect:vn,useImperativeHandle:vn,useInsertionEffect:vn,useLayoutEffect:vn,useMemo:vn,useReducer:vn,useRef:vn,useState:vn,useDebugValue:vn,useDeferredValue:vn,useTransition:vn,useMutableSource:vn,useSyncExternalStore:vn,useId:vn,unstable_isNewReconciler:!1},RS={readContext:Yn,useCallback:function(i,r){return pi().memoizedState=[i,r===void 0?null:r],i},useContext:Yn,useEffect:sm,useImperativeHandle:function(i,r,l){return l=l!=null?l.concat([i]):null,Ua(4194308,4,am.bind(null,r,i),l)},useLayoutEffect:function(i,r){return Ua(4194308,4,i,r)},useInsertionEffect:function(i,r){return Ua(4,2,i,r)},useMemo:function(i,r){var l=pi();return r=r===void 0?null:r,i=i(),l.memoizedState=[i,r],i},useReducer:function(i,r,l){var d=pi();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},d.queue=i,i=i.dispatch=NS.bind(null,At,i),[d.memoizedState,i]},useRef:function(i){var r=pi();return i={current:i},r.memoizedState=i},useState:nm,useDebugValue:hu,useDeferredValue:function(i){return pi().memoizedState=i},useTransition:function(){var i=nm(!1),r=i[0];return i=ES.bind(null,i[1]),pi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,l){var d=At,g=pi();if(Nt){if(l===void 0)throw Error(n(407));l=l()}else{if(l=r(),nn===null)throw Error(n(349));(Ds&30)!==0||Qp(d,r,l)}g.memoizedState=l;var _={value:l,getSnapshot:r};return g.queue=_,sm(Zp.bind(null,d,_,i),[i]),d.flags|=2048,xo(9,Jp.bind(null,d,_,l,r),void 0,null),l},useId:function(){var i=pi(),r=nn.identifierPrefix;if(Nt){var l=Li,d=Pi;l=(d&~(1<<32-Nn(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=bo++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=CS++,r=":"+r+"r"+l.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},PS={readContext:Yn,useCallback:cm,useContext:Yn,useEffect:du,useImperativeHandle:lm,useInsertionEffect:rm,useLayoutEffect:om,useMemo:um,useReducer:cu,useRef:im,useState:function(){return cu(So)},useDebugValue:hu,useDeferredValue:function(i){var r=Gn();return dm(r,Yt.memoizedState,i)},useTransition:function(){var i=cu(So)[0],r=Gn().memoizedState;return[i,r]},useMutableSource:Gp,useSyncExternalStore:Xp,useId:hm,unstable_isNewReconciler:!1},LS={readContext:Yn,useCallback:cm,useContext:Yn,useEffect:du,useImperativeHandle:lm,useInsertionEffect:rm,useLayoutEffect:om,useMemo:um,useReducer:uu,useRef:im,useState:function(){return uu(So)},useDebugValue:hu,useDeferredValue:function(i){var r=Gn();return Yt===null?r.memoizedState=i:dm(r,Yt.memoizedState,i)},useTransition:function(){var i=uu(So)[0],r=Gn().memoizedState;return[i,r]},useMutableSource:Gp,useSyncExternalStore:Xp,useId:hm,unstable_isNewReconciler:!1};function ri(i,r){if(i&&i.defaultProps){r=D({},r),i=i.defaultProps;for(var l in i)r[l]===void 0&&(r[l]=i[l]);return r}return r}function fu(i,r,l,d){r=i.memoizedState,l=l(d,r),l=l==null?r:D({},r,l),i.memoizedState=l,i.lanes===0&&(i.updateQueue.baseState=l)}var qa={isMounted:function(i){return(i=i._reactInternals)?zt(i)===i:!1},enqueueSetState:function(i,r,l){i=i._reactInternals;var d=Sn(),g=rs(i),_=Ti(d,g);_.payload=r,l!=null&&(_.callback=l),r=ts(i,_,g),r!==null&&(li(r,i,g,d),Ba(r,i,g))},enqueueReplaceState:function(i,r,l){i=i._reactInternals;var d=Sn(),g=rs(i),_=Ti(d,g);_.tag=1,_.payload=r,l!=null&&(_.callback=l),r=ts(i,_,g),r!==null&&(li(r,i,g,d),Ba(r,i,g))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var l=Sn(),d=rs(i),g=Ti(l,d);g.tag=2,r!=null&&(g.callback=r),r=ts(i,g,d),r!==null&&(li(r,i,d,l),Ba(r,i,d))}};function gm(i,r,l,d,g,_,P){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,_,P):r.prototype&&r.prototype.isPureReactComponent?!lo(l,d)||!lo(g,_):!0}function vm(i,r,l){var d=!1,g=Ji,_=r.contextType;return typeof _=="object"&&_!==null?_=Yn(_):(g=Rn(r)?Rs:gn.current,d=r.contextTypes,_=(d=d!=null)?dr(i,g):Ji),r=new r(l,_),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=qa,i.stateNode=r,r._reactInternals=i,d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=g,i.__reactInternalMemoizedMaskedChildContext=_),r}function _m(i,r,l,d){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==i&&qa.enqueueReplaceState(r,r.state,null)}function pu(i,r,l,d){var g=i.stateNode;g.props=l,g.state=i.memoizedState,g.refs={},eu(i);var _=r.contextType;typeof _=="object"&&_!==null?g.context=Yn(_):(_=Rn(r)?Rs:gn.current,g.context=dr(i,_)),g.state=i.memoizedState,_=r.getDerivedStateFromProps,typeof _=="function"&&(fu(i,r,_,l),g.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(r=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),r!==g.state&&qa.enqueueReplaceState(g,g.state,null),za(i,l,g,d),g.state=i.memoizedState),typeof g.componentDidMount=="function"&&(i.flags|=4194308)}function yr(i,r){try{var l="",d=r;do l+=ce(d),d=d.return;while(d);var g=l}catch(_){g=`
39
39
  Error generating stack: `+_.message+`
40
- `+_.stack}return{value:i,source:r,stack:g,digest:null}}function mu(i,r,l){return{value:i,source:null,stack:l??null,digest:r??null}}function gu(i,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var AS=typeof WeakMap=="function"?WeakMap:Map;function ym(i,r,l){l=Ti(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){Za||(Za=!0,Lu=d),gu(i,r)},l}function wm(i,r,l){l=Ti(-1,l),l.tag=3;var d=i.type.getDerivedStateFromError;if(typeof d=="function"){var g=r.value;l.payload=function(){return d(g)},l.callback=function(){gu(i,r)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(l.callback=function(){gu(i,r),typeof d!="function"&&(is===null?is=new Set([this]):is.add(this));var P=r.stack;this.componentDidCatch(r.value,{componentStack:P!==null?P:""})}),l}function bm(i,r,l){var d=i.pingCache;if(d===null){d=i.pingCache=new AS;var g=new Set;d.set(r,g)}else g=d.get(r),g===void 0&&(g=new Set,d.set(r,g));g.has(l)||(g.add(l),i=qS.bind(null,i,r,l),r.then(i,i))}function Sm(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function xm(i,r,l,d,g){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=Ti(-1,1),r.tag=2,ts(l,r,1))),l.lanes|=1),i):(i.flags|=65536,i.lanes=g,i)}var TS=I.ReactCurrentOwner,Pn=!1;function bn(i,r,l,d){r.child=i===null?Up(r,null,l,d):mr(r,i.child,l,d)}function km(i,r,l,d,g){l=l.render;var _=r.ref;return vr(r,g),d=au(i,r,l,d,_,g),l=lu(),i!==null&&!Pn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Di(i,r,g)):(Nt&&l&&Wc(r),r.flags|=1,bn(i,r,d,g),r.child)}function Cm(i,r,l,d,g){if(i===null){var _=l.type;return typeof _=="function"&&!Bu(_)&&_.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=_,Em(i,r,_,d,g)):(i=rl(l.type,null,d,r,r.mode,g),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,(i.lanes&g)===0){var P=_.memoizedProps;if(l=l.compare,l=l!==null?l:lo,l(P,d)&&i.ref===r.ref)return Di(i,r,g)}return r.flags|=1,i=as(_,d),i.ref=r.ref,i.return=r,r.child=i}function Em(i,r,l,d,g){if(i!==null){var _=i.memoizedProps;if(lo(_,d)&&i.ref===r.ref)if(Pn=!1,r.pendingProps=d=_,(i.lanes&g)!==0)(i.flags&131072)!==0&&(Pn=!0);else return r.lanes=i.lanes,Di(i,r,g)}return vu(i,r,l,d,g)}function Nm(i,r,l){var d=r.pendingProps,g=d.children,_=i!==null?i.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},yt(br,Bn),Bn|=l;else{if((l&1073741824)===0)return i=_!==null?_.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,yt(br,Bn),Bn|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=_!==null?_.baseLanes:l,yt(br,Bn),Bn|=d}else _!==null?(d=_.baseLanes|l,r.memoizedState=null):d=l,yt(br,Bn),Bn|=d;return bn(i,r,g,l),r.child}function jm(i,r){var l=r.ref;(i===null&&l!==null||i!==null&&i.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function vu(i,r,l,d,g){var _=Rn(l)?Rs:gn.current;return _=dr(r,_),vr(r,g),l=au(i,r,l,d,_,g),d=lu(),i!==null&&!Pn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Di(i,r,g)):(Nt&&d&&Wc(r),r.flags|=1,bn(i,r,l,g),r.child)}function Rm(i,r,l,d,g){if(Rn(l)){var _=!0;Pa(r)}else _=!1;if(vr(r,g),r.stateNode===null)Ya(i,r),vm(r,l,d),pu(r,l,d,g),d=!0;else if(i===null){var P=r.stateNode,V=r.memoizedProps;P.props=V;var J=P.context,le=l.contextType;typeof le=="object"&&le!==null?le=Yn(le):(le=Rn(l)?Rs:gn.current,le=dr(r,le));var be=l.getDerivedStateFromProps,Se=typeof be=="function"||typeof P.getSnapshotBeforeUpdate=="function";Se||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==d||J!==le)&&_m(r,P,d,le),es=!1;var ye=r.memoizedState;P.state=ye,za(r,d,P,g),J=r.memoizedState,V!==d||ye!==J||jn.current||es?(typeof be=="function"&&(fu(r,l,be,d),J=r.memoizedState),(V=es||gm(r,l,V,d,ye,J,le))?(Se||typeof P.UNSAFE_componentWillMount!="function"&&typeof P.componentWillMount!="function"||(typeof P.componentWillMount=="function"&&P.componentWillMount(),typeof P.UNSAFE_componentWillMount=="function"&&P.UNSAFE_componentWillMount()),typeof P.componentDidMount=="function"&&(r.flags|=4194308)):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=J),P.props=d,P.state=J,P.context=le,d=V):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{P=r.stateNode,Kp(i,r),V=r.memoizedProps,le=r.type===r.elementType?V:ri(r.type,V),P.props=le,Se=r.pendingProps,ye=P.context,J=l.contextType,typeof J=="object"&&J!==null?J=Yn(J):(J=Rn(l)?Rs:gn.current,J=dr(r,J));var Le=l.getDerivedStateFromProps;(be=typeof Le=="function"||typeof P.getSnapshotBeforeUpdate=="function")||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==Se||ye!==J)&&_m(r,P,d,J),es=!1,ye=r.memoizedState,P.state=ye,za(r,d,P,g);var Be=r.memoizedState;V!==Se||ye!==Be||jn.current||es?(typeof Le=="function"&&(fu(r,l,Le,d),Be=r.memoizedState),(le=es||gm(r,l,le,d,ye,Be,J)||!1)?(be||typeof P.UNSAFE_componentWillUpdate!="function"&&typeof P.componentWillUpdate!="function"||(typeof P.componentWillUpdate=="function"&&P.componentWillUpdate(d,Be,J),typeof P.UNSAFE_componentWillUpdate=="function"&&P.UNSAFE_componentWillUpdate(d,Be,J)),typeof P.componentDidUpdate=="function"&&(r.flags|=4),typeof P.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=Be),P.props=d,P.state=Be,P.context=J,d=le):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=1024),d=!1)}return _u(i,r,l,d,_,g)}function _u(i,r,l,d,g,_){jm(i,r);var P=(r.flags&128)!==0;if(!d&&!P)return g&&Dp(r,l,!1),Di(i,r,_);d=r.stateNode,TS.current=r;var V=P&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,i!==null&&P?(r.child=mr(r,i.child,null,_),r.child=mr(r,null,V,_)):bn(i,r,V,_),r.memoizedState=d.state,g&&Dp(r,l,!0),r.child}function Pm(i){var r=i.stateNode;r.pendingContext?Ap(i,r.pendingContext,r.pendingContext!==r.context):r.context&&Ap(i,r.context,!1),tu(i,r.containerInfo)}function Lm(i,r,l,d,g){return pr(),Yc(g),r.flags|=256,bn(i,r,l,d),r.child}var yu={dehydrated:null,treeContext:null,retryLane:0};function wu(i){return{baseLanes:i,cachePool:null,transitions:null}}function Am(i,r,l){var d=r.pendingProps,g=Lt.current,_=!1,P=(r.flags&128)!==0,V;if((V=P)||(V=i!==null&&i.memoizedState===null?!1:(g&2)!==0),V?(_=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(g|=1),yt(Lt,g&1),i===null)return Vc(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(P=d.children,i=d.fallback,_?(d=r.mode,_=r.child,P={mode:"hidden",children:P},(d&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=P):_=ol(P,d,0,null),i=zs(i,d,l,null),_.return=r,i.return=r,_.sibling=i,r.child=_,r.child.memoizedState=wu(l),r.memoizedState=yu,i):bu(r,P));if(g=i.memoizedState,g!==null&&(V=g.dehydrated,V!==null))return DS(i,r,P,d,V,g,l);if(_){_=d.fallback,P=r.mode,g=i.child,V=g.sibling;var J={mode:"hidden",children:d.children};return(P&1)===0&&r.child!==g?(d=r.child,d.childLanes=0,d.pendingProps=J,r.deletions=null):(d=as(g,J),d.subtreeFlags=g.subtreeFlags&14680064),V!==null?_=as(V,_):(_=zs(_,P,l,null),_.flags|=2),_.return=r,d.return=r,d.sibling=_,r.child=d,d=_,_=r.child,P=i.child.memoizedState,P=P===null?wu(l):{baseLanes:P.baseLanes|l,cachePool:null,transitions:P.transitions},_.memoizedState=P,_.childLanes=i.childLanes&~l,r.memoizedState=yu,d}return _=i.child,i=_.sibling,d=as(_,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,i!==null&&(l=r.deletions,l===null?(r.deletions=[i],r.flags|=16):l.push(i)),r.child=d,r.memoizedState=null,d}function bu(i,r){return r=ol({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Va(i,r,l,d){return d!==null&&Yc(d),mr(r,i.child,null,l),i=bu(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function DS(i,r,l,d,g,_,P){if(l)return r.flags&256?(r.flags&=-257,d=mu(Error(n(422))),Va(i,r,P,d)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(_=d.fallback,g=r.mode,d=ol({mode:"visible",children:d.children},g,0,null),_=zs(_,g,P,null),_.flags|=2,d.return=r,_.return=r,d.sibling=_,r.child=d,(r.mode&1)!==0&&mr(r,i.child,null,P),r.child.memoizedState=wu(P),r.memoizedState=yu,_);if((r.mode&1)===0)return Va(i,r,P,null);if(g.data==="$!"){if(d=g.nextSibling&&g.nextSibling.dataset,d)var V=d.dgst;return d=V,_=Error(n(419)),d=mu(_,d,void 0),Va(i,r,P,d)}if(V=(P&i.childLanes)!==0,Pn||V){if(d=nn,d!==null){switch(P&-P){case 4:g=2;break;case 16:g=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(d.suspendedLanes|P))!==0?0:g,g!==0&&g!==_.retryLane&&(_.retryLane=g,Ai(i,g),li(d,i,g,-1))}return Ou(),d=mu(Error(n(421))),Va(i,r,P,d)}return g.data==="$?"?(r.flags|=128,r.child=i.child,r=VS.bind(null,i),g._reactRetry=r,null):(i=_.treeContext,On=Xi(g.nextSibling),In=r,Nt=!0,si=null,i!==null&&(qn[Vn++]=Pi,qn[Vn++]=Li,qn[Vn++]=Ps,Pi=i.id,Li=i.overflow,Ps=r),r=bu(r,d.children),r.flags|=4096,r)}function Tm(i,r,l){i.lanes|=r;var d=i.alternate;d!==null&&(d.lanes|=r),Jc(i.return,r,l)}function Su(i,r,l,d,g){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:g}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=d,_.tail=l,_.tailMode=g)}function Dm(i,r,l){var d=r.pendingProps,g=d.revealOrder,_=d.tail;if(bn(i,r,d.children,l),d=Lt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Tm(i,l,r);else if(i.tag===19)Tm(i,l,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}d&=1}if(yt(Lt,d),(r.mode&1)===0)r.memoizedState=null;else switch(g){case"forwards":for(l=r.child,g=null;l!==null;)i=l.alternate,i!==null&&Fa(i)===null&&(g=l),l=l.sibling;l=g,l===null?(g=r.child,r.child=null):(g=l.sibling,l.sibling=null),Su(r,!1,g,l,_);break;case"backwards":for(l=null,g=r.child,r.child=null;g!==null;){if(i=g.alternate,i!==null&&Fa(i)===null){r.child=g;break}i=g.sibling,g.sibling=l,l=g,g=i}Su(r,!0,l,null,_);break;case"together":Su(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ya(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function Di(i,r,l){if(i!==null&&(r.dependencies=i.dependencies),Ms|=r.lanes,(l&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,l=as(i,i.pendingProps),r.child=l,l.return=r;i.sibling!==null;)i=i.sibling,l=l.sibling=as(i,i.pendingProps),l.return=r;l.sibling=null}return r.child}function MS(i,r,l){switch(r.tag){case 3:Pm(r),pr();break;case 5:Yp(r);break;case 1:Rn(r.type)&&Pa(r);break;case 4:tu(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,g=r.memoizedProps.value;yt(Ia,d._currentValue),d._currentValue=g;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(yt(Lt,Lt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Am(i,r,l):(yt(Lt,Lt.current&1),i=Di(i,r,l),i!==null?i.sibling:null);yt(Lt,Lt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(i.flags&128)!==0){if(d)return Dm(i,r,l);r.flags|=128}if(g=r.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),yt(Lt,Lt.current),d)break;return null;case 22:case 23:return r.lanes=0,Nm(i,r,l)}return Di(i,r,l)}var Mm,xu,Im,Om;Mm=function(i,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)i.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},xu=function(){},Im=function(i,r,l,d){var g=i.memoizedProps;if(g!==d){i=r.stateNode,Ts(fi.current);var _=null;switch(l){case"input":g=Rt(i,g),d=Rt(i,d),_=[];break;case"select":g=D({},g,{value:void 0}),d=D({},d,{value:void 0}),_=[];break;case"textarea":g=ot(i,g),d=ot(i,d),_=[];break;default:typeof g.onClick!="function"&&typeof d.onClick=="function"&&(i.onclick=Na)}_e(l,d);var P;l=null;for(le in g)if(!d.hasOwnProperty(le)&&g.hasOwnProperty(le)&&g[le]!=null)if(le==="style"){var V=g[le];for(P in V)V.hasOwnProperty(P)&&(l||(l={}),l[P]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(o.hasOwnProperty(le)?_||(_=[]):(_=_||[]).push(le,null));for(le in d){var J=d[le];if(V=g!=null?g[le]:void 0,d.hasOwnProperty(le)&&J!==V&&(J!=null||V!=null))if(le==="style")if(V){for(P in V)!V.hasOwnProperty(P)||J&&J.hasOwnProperty(P)||(l||(l={}),l[P]="");for(P in J)J.hasOwnProperty(P)&&V[P]!==J[P]&&(l||(l={}),l[P]=J[P])}else l||(_||(_=[]),_.push(le,l)),l=J;else le==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,V=V?V.__html:void 0,J!=null&&V!==J&&(_=_||[]).push(le,J)):le==="children"?typeof J!="string"&&typeof J!="number"||(_=_||[]).push(le,""+J):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(o.hasOwnProperty(le)?(J!=null&&le==="onScroll"&&xt("scroll",i),_||V===J||(_=[])):(_=_||[]).push(le,J))}l&&(_=_||[]).push("style",l);var le=_;(r.updateQueue=le)&&(r.flags|=4)}},Om=function(i,r,l,d){l!==d&&(r.flags|=4)};function ko(i,r){if(!Nt)switch(i.tailMode){case"hidden":r=i.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?i.tail=null:l.sibling=null;break;case"collapsed":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function _n(i){var r=i.alternate!==null&&i.alternate.child===i.child,l=0,d=0;if(r)for(var g=i.child;g!==null;)l|=g.lanes|g.childLanes,d|=g.subtreeFlags&14680064,d|=g.flags&14680064,g.return=i,g=g.sibling;else for(g=i.child;g!==null;)l|=g.lanes|g.childLanes,d|=g.subtreeFlags,d|=g.flags,g.return=i,g=g.sibling;return i.subtreeFlags|=d,i.childLanes=l,r}function IS(i,r,l){var d=r.pendingProps;switch(Kc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _n(r),null;case 1:return Rn(r.type)&&Ra(),_n(r),null;case 3:return d=r.stateNode,_r(),kt(jn),kt(gn),su(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(Da(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,si!==null&&(Du(si),si=null))),xu(i,r),_n(r),null;case 5:nu(r);var g=Ts(yo.current);if(l=r.type,i!==null&&r.stateNode!=null)Im(i,r,l,d,g),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(n(166));return _n(r),null}if(i=Ts(fi.current),Da(r)){d=r.stateNode,l=r.type;var _=r.memoizedProps;switch(d[hi]=r,d[po]=_,i=(r.mode&1)!==0,l){case"dialog":xt("cancel",d),xt("close",d);break;case"iframe":case"object":case"embed":xt("load",d);break;case"video":case"audio":for(g=0;g<uo.length;g++)xt(uo[g],d);break;case"source":xt("error",d);break;case"img":case"image":case"link":xt("error",d),xt("load",d);break;case"details":xt("toggle",d);break;case"input":Jt(d,_),xt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!_.multiple},xt("invalid",d);break;case"textarea":oe(d,_),xt("invalid",d)}_e(l,_),g=null;for(var P in _)if(_.hasOwnProperty(P)){var V=_[P];P==="children"?typeof V=="string"?d.textContent!==V&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,V,i),g=["children",V]):typeof V=="number"&&d.textContent!==""+V&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,V,i),g=["children",""+V]):o.hasOwnProperty(P)&&V!=null&&P==="onScroll"&&xt("scroll",d)}switch(l){case"input":ft(d),bt(d,_,!0);break;case"textarea":ft(d),Te(d);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(d.onclick=Na)}d=g,r.updateQueue=d,d!==null&&(r.flags|=4)}else{P=g.nodeType===9?g:g.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=ae(l)),i==="http://www.w3.org/1999/xhtml"?l==="script"?(i=P.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof d.is=="string"?i=P.createElement(l,{is:d.is}):(i=P.createElement(l),l==="select"&&(P=i,d.multiple?P.multiple=!0:d.size&&(P.size=d.size))):i=P.createElementNS(i,l),i[hi]=r,i[po]=d,Mm(i,r,!1,!1),r.stateNode=i;e:{switch(P=Ee(l,d),l){case"dialog":xt("cancel",i),xt("close",i),g=d;break;case"iframe":case"object":case"embed":xt("load",i),g=d;break;case"video":case"audio":for(g=0;g<uo.length;g++)xt(uo[g],i);g=d;break;case"source":xt("error",i),g=d;break;case"img":case"image":case"link":xt("error",i),xt("load",i),g=d;break;case"details":xt("toggle",i),g=d;break;case"input":Jt(i,d),g=Rt(i,d),xt("invalid",i);break;case"option":g=d;break;case"select":i._wrapperState={wasMultiple:!!d.multiple},g=D({},d,{value:void 0}),xt("invalid",i);break;case"textarea":oe(i,d),g=ot(i,d),xt("invalid",i);break;default:g=d}_e(l,g),V=g;for(_ in V)if(V.hasOwnProperty(_)){var J=V[_];_==="style"?ge(i,J):_==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&q(i,J)):_==="children"?typeof J=="string"?(l!=="textarea"||J!=="")&&te(i,J):typeof J=="number"&&te(i,""+J):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?J!=null&&_==="onScroll"&&xt("scroll",i):J!=null&&F(i,_,J,P))}switch(l){case"input":ft(i),bt(i,d,!1);break;case"textarea":ft(i),Te(i);break;case"option":d.value!=null&&i.setAttribute("value",""+me(d.value));break;case"select":i.multiple=!!d.multiple,_=d.value,_!=null?Qe(i,!!d.multiple,_,!1):d.defaultValue!=null&&Qe(i,!!d.multiple,d.defaultValue,!0);break;default:typeof g.onClick=="function"&&(i.onclick=Na)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return _n(r),null;case 6:if(i&&r.stateNode!=null)Om(i,r,i.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(n(166));if(l=Ts(yo.current),Ts(fi.current),Da(r)){if(d=r.stateNode,l=r.memoizedProps,d[hi]=r,(_=d.nodeValue!==l)&&(i=In,i!==null))switch(i.tag){case 3:Ea(d.nodeValue,l,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Ea(d.nodeValue,l,(i.mode&1)!==0)}_&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[hi]=r,r.stateNode=d}return _n(r),null;case 13:if(kt(Lt),d=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Nt&&On!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Fp(),pr(),r.flags|=98560,_=!1;else if(_=Da(r),d!==null&&d.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=r.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[hi]=r}else pr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;_n(r),_=!1}else si!==null&&(Du(si),si=null),_=!0;if(!_)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(i!==null&&i.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Lt.current&1)!==0?Yt===0&&(Yt=3):Ou())),r.updateQueue!==null&&(r.flags|=4),_n(r),null);case 4:return _r(),xu(i,r),i===null&&ho(r.stateNode.containerInfo),_n(r),null;case 10:return Qc(r.type._context),_n(r),null;case 17:return Rn(r.type)&&Ra(),_n(r),null;case 19:if(kt(Lt),_=r.memoizedState,_===null)return _n(r),null;if(d=(r.flags&128)!==0,P=_.rendering,P===null)if(d)ko(_,!1);else{if(Yt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(P=Fa(i),P!==null){for(r.flags|=128,ko(_,!1),d=P.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)_=l,i=d,_.flags&=14680066,P=_.alternate,P===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=P.childLanes,_.lanes=P.lanes,_.child=P.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=P.memoizedProps,_.memoizedState=P.memoizedState,_.updateQueue=P.updateQueue,_.type=P.type,i=P.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),l=l.sibling;return yt(Lt,Lt.current&1|2),r.child}i=i.sibling}_.tail!==null&&Et()>Sr&&(r.flags|=128,d=!0,ko(_,!1),r.lanes=4194304)}else{if(!d)if(i=Fa(P),i!==null){if(r.flags|=128,d=!0,l=i.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),ko(_,!0),_.tail===null&&_.tailMode==="hidden"&&!P.alternate&&!Nt)return _n(r),null}else 2*Et()-_.renderingStartTime>Sr&&l!==1073741824&&(r.flags|=128,d=!0,ko(_,!1),r.lanes=4194304);_.isBackwards?(P.sibling=r.child,r.child=P):(l=_.last,l!==null?l.sibling=P:r.child=P,_.last=P)}return _.tail!==null?(r=_.tail,_.rendering=r,_.tail=r.sibling,_.renderingStartTime=Et(),r.sibling=null,l=Lt.current,yt(Lt,d?l&1|2:l&1),r):(_n(r),null);case 22:case 23:return Iu(),d=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Bn&1073741824)!==0&&(_n(r),r.subtreeFlags&6&&(r.flags|=8192)):_n(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function OS(i,r){switch(Kc(r),r.tag){case 1:return Rn(r.type)&&Ra(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return _r(),kt(jn),kt(gn),su(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return nu(r),null;case 13:if(kt(Lt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));pr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return kt(Lt),null;case 4:return _r(),null;case 10:return Qc(r.type._context),null;case 22:case 23:return Iu(),null;case 24:return null;default:return null}}var Ga=!1,yn=!1,BS=typeof WeakSet=="function"?WeakSet:Set,Me=null;function wr(i,r){var l=i.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){It(i,r,d)}else l.current=null}function ku(i,r,l){try{l()}catch(d){It(i,r,d)}}var Bm=!1;function zS(i,r){if(Ic=ma,i=gp(),jc(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var g=d.anchorOffset,_=d.focusNode;d=d.focusOffset;try{l.nodeType,_.nodeType}catch{l=null;break e}var P=0,V=-1,J=-1,le=0,be=0,Se=i,ye=null;t:for(;;){for(var Le;Se!==l||g!==0&&Se.nodeType!==3||(V=P+g),Se!==_||d!==0&&Se.nodeType!==3||(J=P+d),Se.nodeType===3&&(P+=Se.nodeValue.length),(Le=Se.firstChild)!==null;)ye=Se,Se=Le;for(;;){if(Se===i)break t;if(ye===l&&++le===g&&(V=P),ye===_&&++be===d&&(J=P),(Le=Se.nextSibling)!==null)break;Se=ye,ye=Se.parentNode}Se=Le}l=V===-1||J===-1?null:{start:V,end:J}}else l=null}l=l||{start:0,end:0}}else l=null;for(Oc={focusedElem:i,selectionRange:l},ma=!1,Me=r;Me!==null;)if(r=Me,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Me=i;else for(;Me!==null;){r=Me;try{var Be=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Be!==null){var ze=Be.memoizedProps,Ft=Be.memoizedState,ne=r.stateNode,ee=ne.getSnapshotBeforeUpdate(r.elementType===r.type?ze:ri(r.type,ze),Ft);ne.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var se=r.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ce){It(r,r.return,Ce)}if(i=r.sibling,i!==null){i.return=r.return,Me=i;break}Me=r.return}return Be=Bm,Bm=!1,Be}function Co(i,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var g=d=d.next;do{if((g.tag&i)===i){var _=g.destroy;g.destroy=void 0,_!==void 0&&ku(r,l,_)}g=g.next}while(g!==d)}}function Xa(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&i)===i){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function Cu(i){var r=i.ref;if(r!==null){var l=i.stateNode;switch(i.tag){case 5:i=l;break;default:i=l}typeof r=="function"?r(i):r.current=i}}function zm(i){var r=i.alternate;r!==null&&(i.alternate=null,zm(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[hi],delete r[po],delete r[$c],delete r[bS],delete r[SS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function Fm(i){return i.tag===5||i.tag===3||i.tag===4}function $m(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Fm(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.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 Eu(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(i,r):l.insertBefore(i,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(i,l)):(r=l,r.appendChild(i)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Na));else if(d!==4&&(i=i.child,i!==null))for(Eu(i,r,l),i=i.sibling;i!==null;)Eu(i,r,l),i=i.sibling}function Nu(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(d!==4&&(i=i.child,i!==null))for(Nu(i,r,l),i=i.sibling;i!==null;)Nu(i,r,l),i=i.sibling}var hn=null,oi=!1;function ns(i,r,l){for(l=l.child;l!==null;)Hm(i,r,l),l=l.sibling}function Hm(i,r,l){if(en&&typeof en.onCommitFiberUnmount=="function")try{en.onCommitFiberUnmount(Ut,l)}catch{}switch(l.tag){case 5:yn||wr(l,r);case 6:var d=hn,g=oi;hn=null,ns(i,r,l),hn=d,oi=g,hn!==null&&(oi?(i=hn,l=l.stateNode,i.nodeType===8?i.parentNode.removeChild(l):i.removeChild(l)):hn.removeChild(l.stateNode));break;case 18:hn!==null&&(oi?(i=hn,l=l.stateNode,i.nodeType===8?Fc(i.parentNode,l):i.nodeType===1&&Fc(i,l),no(i)):Fc(hn,l.stateNode));break;case 4:d=hn,g=oi,hn=l.stateNode.containerInfo,oi=!0,ns(i,r,l),hn=d,oi=g;break;case 0:case 11:case 14:case 15:if(!yn&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){g=d=d.next;do{var _=g,P=_.destroy;_=_.tag,P!==void 0&&((_&2)!==0||(_&4)!==0)&&ku(l,r,P),g=g.next}while(g!==d)}ns(i,r,l);break;case 1:if(!yn&&(wr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(V){It(l,r,V)}ns(i,r,l);break;case 21:ns(i,r,l);break;case 22:l.mode&1?(yn=(d=yn)||l.memoizedState!==null,ns(i,r,l),yn=d):ns(i,r,l);break;default:ns(i,r,l)}}function Um(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var l=i.stateNode;l===null&&(l=i.stateNode=new BS),r.forEach(function(d){var g=YS.bind(null,i,d);l.has(d)||(l.add(d),d.then(g,g))})}}function ai(i,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var g=l[d];try{var _=i,P=r,V=P;e:for(;V!==null;){switch(V.tag){case 5:hn=V.stateNode,oi=!1;break e;case 3:hn=V.stateNode.containerInfo,oi=!0;break e;case 4:hn=V.stateNode.containerInfo,oi=!0;break e}V=V.return}if(hn===null)throw Error(n(160));Hm(_,P,g),hn=null,oi=!1;var J=g.alternate;J!==null&&(J.return=null),g.return=null}catch(le){It(g,r,le)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Wm(r,i),r=r.sibling}function Wm(i,r){var l=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(ai(r,i),mi(i),d&4){try{Co(3,i,i.return),Xa(3,i)}catch(ze){It(i,i.return,ze)}try{Co(5,i,i.return)}catch(ze){It(i,i.return,ze)}}break;case 1:ai(r,i),mi(i),d&512&&l!==null&&wr(l,l.return);break;case 5:if(ai(r,i),mi(i),d&512&&l!==null&&wr(l,l.return),i.flags&32){var g=i.stateNode;try{te(g,"")}catch(ze){It(i,i.return,ze)}}if(d&4&&(g=i.stateNode,g!=null)){var _=i.memoizedProps,P=l!==null?l.memoizedProps:_,V=i.type,J=i.updateQueue;if(i.updateQueue=null,J!==null)try{V==="input"&&_.type==="radio"&&_.name!=null&&Oe(g,_),Ee(V,P);var le=Ee(V,_);for(P=0;P<J.length;P+=2){var be=J[P],Se=J[P+1];be==="style"?ge(g,Se):be==="dangerouslySetInnerHTML"?q(g,Se):be==="children"?te(g,Se):F(g,be,Se,le)}switch(V){case"input":Pt(g,_);break;case"textarea":ke(g,_);break;case"select":var ye=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!_.multiple;var Le=_.value;Le!=null?Qe(g,!!_.multiple,Le,!1):ye!==!!_.multiple&&(_.defaultValue!=null?Qe(g,!!_.multiple,_.defaultValue,!0):Qe(g,!!_.multiple,_.multiple?[]:"",!1))}g[po]=_}catch(ze){It(i,i.return,ze)}}break;case 6:if(ai(r,i),mi(i),d&4){if(i.stateNode===null)throw Error(n(162));g=i.stateNode,_=i.memoizedProps;try{g.nodeValue=_}catch(ze){It(i,i.return,ze)}}break;case 3:if(ai(r,i),mi(i),d&4&&l!==null&&l.memoizedState.isDehydrated)try{no(r.containerInfo)}catch(ze){It(i,i.return,ze)}break;case 4:ai(r,i),mi(i);break;case 13:ai(r,i),mi(i),g=i.child,g.flags&8192&&(_=g.memoizedState!==null,g.stateNode.isHidden=_,!_||g.alternate!==null&&g.alternate.memoizedState!==null||(Pu=Et())),d&4&&Um(i);break;case 22:if(be=l!==null&&l.memoizedState!==null,i.mode&1?(yn=(le=yn)||be,ai(r,i),yn=le):ai(r,i),mi(i),d&8192){if(le=i.memoizedState!==null,(i.stateNode.isHidden=le)&&!be&&(i.mode&1)!==0)for(Me=i,be=i.child;be!==null;){for(Se=Me=be;Me!==null;){switch(ye=Me,Le=ye.child,ye.tag){case 0:case 11:case 14:case 15:Co(4,ye,ye.return);break;case 1:wr(ye,ye.return);var Be=ye.stateNode;if(typeof Be.componentWillUnmount=="function"){d=ye,l=ye.return;try{r=d,Be.props=r.memoizedProps,Be.state=r.memoizedState,Be.componentWillUnmount()}catch(ze){It(d,l,ze)}}break;case 5:wr(ye,ye.return);break;case 22:if(ye.memoizedState!==null){Vm(Se);continue}}Le!==null?(Le.return=ye,Me=Le):Vm(Se)}be=be.sibling}e:for(be=null,Se=i;;){if(Se.tag===5){if(be===null){be=Se;try{g=Se.stateNode,le?(_=g.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(V=Se.stateNode,J=Se.memoizedProps.style,P=J!=null&&J.hasOwnProperty("display")?J.display:null,V.style.display=de("display",P))}catch(ze){It(i,i.return,ze)}}}else if(Se.tag===6){if(be===null)try{Se.stateNode.nodeValue=le?"":Se.memoizedProps}catch(ze){It(i,i.return,ze)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===i)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===i)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===i)break e;be===Se&&(be=null),Se=Se.return}be===Se&&(be=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:ai(r,i),mi(i),d&4&&Um(i);break;case 21:break;default:ai(r,i),mi(i)}}function mi(i){var r=i.flags;if(r&2){try{e:{for(var l=i.return;l!==null;){if(Fm(l)){var d=l;break e}l=l.return}throw Error(n(160))}switch(d.tag){case 5:var g=d.stateNode;d.flags&32&&(te(g,""),d.flags&=-33);var _=$m(i);Nu(i,_,g);break;case 3:case 4:var P=d.stateNode.containerInfo,V=$m(i);Eu(i,V,P);break;default:throw Error(n(161))}}catch(J){It(i,i.return,J)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function FS(i,r,l){Me=i,Km(i)}function Km(i,r,l){for(var d=(i.mode&1)!==0;Me!==null;){var g=Me,_=g.child;if(g.tag===22&&d){var P=g.memoizedState!==null||Ga;if(!P){var V=g.alternate,J=V!==null&&V.memoizedState!==null||yn;V=Ga;var le=yn;if(Ga=P,(yn=J)&&!le)for(Me=g;Me!==null;)P=Me,J=P.child,P.tag===22&&P.memoizedState!==null?Ym(g):J!==null?(J.return=P,Me=J):Ym(g);for(;_!==null;)Me=_,Km(_),_=_.sibling;Me=g,Ga=V,yn=le}qm(i)}else(g.subtreeFlags&8772)!==0&&_!==null?(_.return=g,Me=_):qm(i)}}function qm(i){for(;Me!==null;){var r=Me;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:yn||Xa(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!yn)if(l===null)d.componentDidMount();else{var g=r.elementType===r.type?l.memoizedProps:ri(r.type,l.memoizedProps);d.componentDidUpdate(g,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var _=r.updateQueue;_!==null&&Vp(r,_,d);break;case 3:var P=r.updateQueue;if(P!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Vp(r,P,l)}break;case 5:var V=r.stateNode;if(l===null&&r.flags&4){l=V;var J=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&l.focus();break;case"img":J.src&&(l.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var le=r.alternate;if(le!==null){var be=le.memoizedState;if(be!==null){var Se=be.dehydrated;Se!==null&&no(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}yn||r.flags&512&&Cu(r)}catch(ye){It(r,r.return,ye)}}if(r===i){Me=null;break}if(l=r.sibling,l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Vm(i){for(;Me!==null;){var r=Me;if(r===i){Me=null;break}var l=r.sibling;if(l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Ym(i){for(;Me!==null;){var r=Me;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{Xa(4,r)}catch(J){It(r,l,J)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var g=r.return;try{d.componentDidMount()}catch(J){It(r,g,J)}}var _=r.return;try{Cu(r)}catch(J){It(r,_,J)}break;case 5:var P=r.return;try{Cu(r)}catch(J){It(r,P,J)}}}catch(J){It(r,r.return,J)}if(r===i){Me=null;break}var V=r.sibling;if(V!==null){V.return=r.return,Me=V;break}Me=r.return}}var $S=Math.ceil,Qa=I.ReactCurrentDispatcher,ju=I.ReactCurrentOwner,Xn=I.ReactCurrentBatchConfig,lt=0,nn=null,Wt=null,fn=0,Bn=0,br=Qi(0),Yt=0,Eo=null,Ms=0,Ja=0,Ru=0,No=null,Ln=null,Pu=0,Sr=1/0,Mi=null,Za=!1,Lu=null,is=null,el=!1,ss=null,tl=0,jo=0,Au=null,nl=-1,il=0;function Sn(){return(lt&6)!==0?Et():nl!==-1?nl:nl=Et()}function rs(i){return(i.mode&1)===0?1:(lt&2)!==0&&fn!==0?fn&-fn:kS.transition!==null?(il===0&&(il=$f()),il):(i=mt,i!==0||(i=window.event,i=i===void 0?16:Xf(i.type)),i)}function li(i,r,l,d){if(50<jo)throw jo=0,Au=null,Error(n(185));Qr(i,l,d),((lt&2)===0||i!==nn)&&(i===nn&&((lt&2)===0&&(Ja|=l),Yt===4&&os(i,fn)),An(i,d),l===1&&lt===0&&(r.mode&1)===0&&(Sr=Et()+500,La&&Zi()))}function An(i,r){var l=i.callbackNode;kb(i,r);var d=ha(i,i===nn?fn:0);if(d===0)l!==null&&Yr(l),i.callbackNode=null,i.callbackPriority=0;else if(r=d&-d,i.callbackPriority!==r){if(l!=null&&Yr(l),r===1)i.tag===0?xS(Xm.bind(null,i)):Mp(Xm.bind(null,i)),yS(function(){(lt&6)===0&&Zi()}),l=null;else{switch(Hf(d)){case 1:l=He;break;case 4:l=Ye;break;case 16:l=Ve;break;case 536870912:l=St;break;default:l=Ve}l=sg(l,Gm.bind(null,i))}i.callbackPriority=r,i.callbackNode=l}}function Gm(i,r){if(nl=-1,il=0,(lt&6)!==0)throw Error(n(327));var l=i.callbackNode;if(xr()&&i.callbackNode!==l)return null;var d=ha(i,i===nn?fn:0);if(d===0)return null;if((d&30)!==0||(d&i.expiredLanes)!==0||r)r=sl(i,d);else{r=d;var g=lt;lt|=2;var _=Jm();(nn!==i||fn!==r)&&(Mi=null,Sr=Et()+500,Os(i,r));do try{WS();break}catch(V){Qm(i,V)}while(!0);Xc(),Qa.current=_,lt=g,Wt!==null?r=0:(nn=null,fn=0,r=Yt)}if(r!==0){if(r===2&&(g=hc(i),g!==0&&(d=g,r=Tu(i,g))),r===1)throw l=Eo,Os(i,0),os(i,d),An(i,Et()),l;if(r===6)os(i,d);else{if(g=i.current.alternate,(d&30)===0&&!HS(g)&&(r=sl(i,d),r===2&&(_=hc(i),_!==0&&(d=_,r=Tu(i,_))),r===1))throw l=Eo,Os(i,0),os(i,d),An(i,Et()),l;switch(i.finishedWork=g,i.finishedLanes=d,r){case 0:case 1:throw Error(n(345));case 2:Bs(i,Ln,Mi);break;case 3:if(os(i,d),(d&130023424)===d&&(r=Pu+500-Et(),10<r)){if(ha(i,0)!==0)break;if(g=i.suspendedLanes,(g&d)!==d){Sn(),i.pingedLanes|=i.suspendedLanes&g;break}i.timeoutHandle=zc(Bs.bind(null,i,Ln,Mi),r);break}Bs(i,Ln,Mi);break;case 4:if(os(i,d),(d&4194240)===d)break;for(r=i.eventTimes,g=-1;0<d;){var P=31-Nn(d);_=1<<P,P=r[P],P>g&&(g=P),d&=~_}if(d=g,d=Et()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*$S(d/1960))-d,10<d){i.timeoutHandle=zc(Bs.bind(null,i,Ln,Mi),d);break}Bs(i,Ln,Mi);break;case 5:Bs(i,Ln,Mi);break;default:throw Error(n(329))}}}return An(i,Et()),i.callbackNode===l?Gm.bind(null,i):null}function Tu(i,r){var l=No;return i.current.memoizedState.isDehydrated&&(Os(i,r).flags|=256),i=sl(i,r),i!==2&&(r=Ln,Ln=l,r!==null&&Du(r)),i}function Du(i){Ln===null?Ln=i:Ln.push.apply(Ln,i)}function HS(i){for(var r=i;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var g=l[d],_=g.getSnapshot;g=g.value;try{if(!ii(_(),g))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function os(i,r){for(r&=~Ru,r&=~Ja,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var l=31-Nn(r),d=1<<l;i[l]=-1,r&=~d}}function Xm(i){if((lt&6)!==0)throw Error(n(327));xr();var r=ha(i,0);if((r&1)===0)return An(i,Et()),null;var l=sl(i,r);if(i.tag!==0&&l===2){var d=hc(i);d!==0&&(r=d,l=Tu(i,d))}if(l===1)throw l=Eo,Os(i,0),os(i,r),An(i,Et()),l;if(l===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Bs(i,Ln,Mi),An(i,Et()),null}function Mu(i,r){var l=lt;lt|=1;try{return i(r)}finally{lt=l,lt===0&&(Sr=Et()+500,La&&Zi())}}function Is(i){ss!==null&&ss.tag===0&&(lt&6)===0&&xr();var r=lt;lt|=1;var l=Xn.transition,d=mt;try{if(Xn.transition=null,mt=1,i)return i()}finally{mt=d,Xn.transition=l,lt=r,(lt&6)===0&&Zi()}}function Iu(){Bn=br.current,kt(br)}function Os(i,r){i.finishedWork=null,i.finishedLanes=0;var l=i.timeoutHandle;if(l!==-1&&(i.timeoutHandle=-1,_S(l)),Wt!==null)for(l=Wt.return;l!==null;){var d=l;switch(Kc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Ra();break;case 3:_r(),kt(jn),kt(gn),su();break;case 5:nu(d);break;case 4:_r();break;case 13:kt(Lt);break;case 19:kt(Lt);break;case 10:Qc(d.type._context);break;case 22:case 23:Iu()}l=l.return}if(nn=i,Wt=i=as(i.current,null),fn=Bn=r,Yt=0,Eo=null,Ru=Ja=Ms=0,Ln=No=null,As!==null){for(r=0;r<As.length;r++)if(l=As[r],d=l.interleaved,d!==null){l.interleaved=null;var g=d.next,_=l.pending;if(_!==null){var P=_.next;_.next=g,d.next=P}l.pending=d}As=null}return i}function Qm(i,r){do{var l=Wt;try{if(Xc(),$a.current=Ka,Ha){for(var d=At.memoizedState;d!==null;){var g=d.queue;g!==null&&(g.pending=null),d=d.next}Ha=!1}if(Ds=0,tn=Vt=At=null,wo=!1,bo=0,ju.current=null,l===null||l.return===null){Yt=1,Eo=r,Wt=null;break}e:{var _=i,P=l.return,V=l,J=r;if(r=fn,V.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var le=J,be=V,Se=be.tag;if((be.mode&1)===0&&(Se===0||Se===11||Se===15)){var ye=be.alternate;ye?(be.updateQueue=ye.updateQueue,be.memoizedState=ye.memoizedState,be.lanes=ye.lanes):(be.updateQueue=null,be.memoizedState=null)}var Le=Sm(P);if(Le!==null){Le.flags&=-257,xm(Le,P,V,_,r),Le.mode&1&&bm(_,le,r),r=Le,J=le;var Be=r.updateQueue;if(Be===null){var ze=new Set;ze.add(J),r.updateQueue=ze}else Be.add(J);break e}else{if((r&1)===0){bm(_,le,r),Ou();break e}J=Error(n(426))}}else if(Nt&&V.mode&1){var Ft=Sm(P);if(Ft!==null){(Ft.flags&65536)===0&&(Ft.flags|=256),xm(Ft,P,V,_,r),Yc(yr(J,V));break e}}_=J=yr(J,V),Yt!==4&&(Yt=2),No===null?No=[_]:No.push(_),_=P;do{switch(_.tag){case 3:_.flags|=65536,r&=-r,_.lanes|=r;var ne=ym(_,J,r);qp(_,ne);break e;case 1:V=J;var ee=_.type,se=_.stateNode;if((_.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(is===null||!is.has(se)))){_.flags|=65536,r&=-r,_.lanes|=r;var Ce=wm(_,V,r);qp(_,Ce);break e}}_=_.return}while(_!==null)}eg(l)}catch(Fe){r=Fe,Wt===l&&l!==null&&(Wt=l=l.return);continue}break}while(!0)}function Jm(){var i=Qa.current;return Qa.current=Ka,i===null?Ka:i}function Ou(){(Yt===0||Yt===3||Yt===2)&&(Yt=4),nn===null||(Ms&268435455)===0&&(Ja&268435455)===0||os(nn,fn)}function sl(i,r){var l=lt;lt|=2;var d=Jm();(nn!==i||fn!==r)&&(Mi=null,Os(i,r));do try{US();break}catch(g){Qm(i,g)}while(!0);if(Xc(),lt=l,Qa.current=d,Wt!==null)throw Error(n(261));return nn=null,fn=0,Yt}function US(){for(;Wt!==null;)Zm(Wt)}function WS(){for(;Wt!==null&&!tr();)Zm(Wt)}function Zm(i){var r=ig(i.alternate,i,Bn);i.memoizedProps=i.pendingProps,r===null?eg(i):Wt=r,ju.current=null}function eg(i){var r=i;do{var l=r.alternate;if(i=r.return,(r.flags&32768)===0){if(l=IS(l,r,Bn),l!==null){Wt=l;return}}else{if(l=OS(l,r),l!==null){l.flags&=32767,Wt=l;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Yt=6,Wt=null;return}}if(r=r.sibling,r!==null){Wt=r;return}Wt=r=i}while(r!==null);Yt===0&&(Yt=5)}function Bs(i,r,l){var d=mt,g=Xn.transition;try{Xn.transition=null,mt=1,KS(i,r,l,d)}finally{Xn.transition=g,mt=d}return null}function KS(i,r,l,d){do xr();while(ss!==null);if((lt&6)!==0)throw Error(n(327));l=i.finishedWork;var g=i.finishedLanes;if(l===null)return null;if(i.finishedWork=null,i.finishedLanes=0,l===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=l.lanes|l.childLanes;if(Cb(i,_),i===nn&&(Wt=nn=null,fn=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||el||(el=!0,sg(Ve,function(){return xr(),null})),_=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||_){_=Xn.transition,Xn.transition=null;var P=mt;mt=1;var V=lt;lt|=4,ju.current=null,zS(i,l),Wm(l,i),dS(Oc),ma=!!Ic,Oc=Ic=null,i.current=l,FS(l),ca(),lt=V,mt=P,Xn.transition=_}else i.current=l;if(el&&(el=!1,ss=i,tl=g),_=i.pendingLanes,_===0&&(is=null),dc(l.stateNode),An(i,Et()),r!==null)for(d=i.onRecoverableError,l=0;l<r.length;l++)g=r[l],d(g.value,{componentStack:g.stack,digest:g.digest});if(Za)throw Za=!1,i=Lu,Lu=null,i;return(tl&1)!==0&&i.tag!==0&&xr(),_=i.pendingLanes,(_&1)!==0?i===Au?jo++:(jo=0,Au=i):jo=0,Zi(),null}function xr(){if(ss!==null){var i=Hf(tl),r=Xn.transition,l=mt;try{if(Xn.transition=null,mt=16>i?16:i,ss===null)var d=!1;else{if(i=ss,ss=null,tl=0,(lt&6)!==0)throw Error(n(331));var g=lt;for(lt|=4,Me=i.current;Me!==null;){var _=Me,P=_.child;if((Me.flags&16)!==0){var V=_.deletions;if(V!==null){for(var J=0;J<V.length;J++){var le=V[J];for(Me=le;Me!==null;){var be=Me;switch(be.tag){case 0:case 11:case 15:Co(8,be,_)}var Se=be.child;if(Se!==null)Se.return=be,Me=Se;else for(;Me!==null;){be=Me;var ye=be.sibling,Le=be.return;if(zm(be),be===le){Me=null;break}if(ye!==null){ye.return=Le,Me=ye;break}Me=Le}}}var Be=_.alternate;if(Be!==null){var ze=Be.child;if(ze!==null){Be.child=null;do{var Ft=ze.sibling;ze.sibling=null,ze=Ft}while(ze!==null)}}Me=_}}if((_.subtreeFlags&2064)!==0&&P!==null)P.return=_,Me=P;else e:for(;Me!==null;){if(_=Me,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Co(9,_,_.return)}var ne=_.sibling;if(ne!==null){ne.return=_.return,Me=ne;break e}Me=_.return}}var ee=i.current;for(Me=ee;Me!==null;){P=Me;var se=P.child;if((P.subtreeFlags&2064)!==0&&se!==null)se.return=P,Me=se;else e:for(P=ee;Me!==null;){if(V=Me,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:Xa(9,V)}}catch(Fe){It(V,V.return,Fe)}if(V===P){Me=null;break e}var Ce=V.sibling;if(Ce!==null){Ce.return=V.return,Me=Ce;break e}Me=V.return}}if(lt=g,Zi(),en&&typeof en.onPostCommitFiberRoot=="function")try{en.onPostCommitFiberRoot(Ut,i)}catch{}d=!0}return d}finally{mt=l,Xn.transition=r}}return!1}function tg(i,r,l){r=yr(l,r),r=ym(i,r,1),i=ts(i,r,1),r=Sn(),i!==null&&(Qr(i,1,r),An(i,r))}function It(i,r,l){if(i.tag===3)tg(i,i,l);else for(;r!==null;){if(r.tag===3){tg(r,i,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(is===null||!is.has(d))){i=yr(l,i),i=wm(r,i,1),r=ts(r,i,1),i=Sn(),r!==null&&(Qr(r,1,i),An(r,i));break}}r=r.return}}function qS(i,r,l){var d=i.pingCache;d!==null&&d.delete(r),r=Sn(),i.pingedLanes|=i.suspendedLanes&l,nn===i&&(fn&l)===l&&(Yt===4||Yt===3&&(fn&130023424)===fn&&500>Et()-Pu?Os(i,0):Ru|=l),An(i,r)}function ng(i,r){r===0&&((i.mode&1)===0?r=1:(r=da,da<<=1,(da&130023424)===0&&(da=4194304)));var l=Sn();i=Ai(i,r),i!==null&&(Qr(i,r,l),An(i,l))}function VS(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),ng(i,l)}function YS(i,r){var l=0;switch(i.tag){case 13:var d=i.stateNode,g=i.memoizedState;g!==null&&(l=g.retryLane);break;case 19:d=i.stateNode;break;default:throw Error(n(314))}d!==null&&d.delete(r),ng(i,l)}var ig;ig=function(i,r,l){if(i!==null)if(i.memoizedProps!==r.pendingProps||jn.current)Pn=!0;else{if((i.lanes&l)===0&&(r.flags&128)===0)return Pn=!1,MS(i,r,l);Pn=(i.flags&131072)!==0}else Pn=!1,Nt&&(r.flags&1048576)!==0&&Ip(r,Ta,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;Ya(i,r),i=r.pendingProps;var g=dr(r,gn.current);vr(r,l),g=au(null,r,d,i,g,l);var _=lu();return r.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Rn(d)?(_=!0,Pa(r)):_=!1,r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,eu(r),g.updater=qa,r.stateNode=g,g._reactInternals=r,pu(r,d,i,l),r=_u(null,r,d,!0,_,l)):(r.tag=0,Nt&&_&&Wc(r),bn(null,r,g,l),r=r.child),r;case 16:d=r.elementType;e:{switch(Ya(i,r),i=r.pendingProps,g=d._init,d=g(d._payload),r.type=d,g=r.tag=XS(d),i=ri(d,i),g){case 0:r=vu(null,r,d,i,l);break e;case 1:r=Rm(null,r,d,i,l);break e;case 11:r=km(null,r,d,i,l);break e;case 14:r=Cm(null,r,d,ri(d.type,i),l);break e}throw Error(n(306,d,""))}return r;case 0:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),vu(i,r,d,g,l);case 1:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),Rm(i,r,d,g,l);case 3:e:{if(Pm(r),i===null)throw Error(n(387));d=r.pendingProps,_=r.memoizedState,g=_.element,Kp(i,r),za(r,d,null,l);var P=r.memoizedState;if(d=P.element,_.isDehydrated)if(_={element:d,isDehydrated:!1,cache:P.cache,pendingSuspenseBoundaries:P.pendingSuspenseBoundaries,transitions:P.transitions},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){g=yr(Error(n(423)),r),r=Lm(i,r,d,l,g);break e}else if(d!==g){g=yr(Error(n(424)),r),r=Lm(i,r,d,l,g);break e}else for(On=Xi(r.stateNode.containerInfo.firstChild),In=r,Nt=!0,si=null,l=Up(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(pr(),d===g){r=Di(i,r,l);break e}bn(i,r,d,l)}r=r.child}return r;case 5:return Yp(r),i===null&&Vc(r),d=r.type,g=r.pendingProps,_=i!==null?i.memoizedProps:null,P=g.children,Bc(d,g)?P=null:_!==null&&Bc(d,_)&&(r.flags|=32),jm(i,r),bn(i,r,P,l),r.child;case 6:return i===null&&Vc(r),null;case 13:return Am(i,r,l);case 4:return tu(r,r.stateNode.containerInfo),d=r.pendingProps,i===null?r.child=mr(r,null,d,l):bn(i,r,d,l),r.child;case 11:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),km(i,r,d,g,l);case 7:return bn(i,r,r.pendingProps,l),r.child;case 8:return bn(i,r,r.pendingProps.children,l),r.child;case 12:return bn(i,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,g=r.pendingProps,_=r.memoizedProps,P=g.value,yt(Ia,d._currentValue),d._currentValue=P,_!==null)if(ii(_.value,P)){if(_.children===g.children&&!jn.current){r=Di(i,r,l);break e}}else for(_=r.child,_!==null&&(_.return=r);_!==null;){var V=_.dependencies;if(V!==null){P=_.child;for(var J=V.firstContext;J!==null;){if(J.context===d){if(_.tag===1){J=Ti(-1,l&-l),J.tag=2;var le=_.updateQueue;if(le!==null){le=le.shared;var be=le.pending;be===null?J.next=J:(J.next=be.next,be.next=J),le.pending=J}}_.lanes|=l,J=_.alternate,J!==null&&(J.lanes|=l),Jc(_.return,l,r),V.lanes|=l;break}J=J.next}}else if(_.tag===10)P=_.type===r.type?null:_.child;else if(_.tag===18){if(P=_.return,P===null)throw Error(n(341));P.lanes|=l,V=P.alternate,V!==null&&(V.lanes|=l),Jc(P,l,r),P=_.sibling}else P=_.child;if(P!==null)P.return=_;else for(P=_;P!==null;){if(P===r){P=null;break}if(_=P.sibling,_!==null){_.return=P.return,P=_;break}P=P.return}_=P}bn(i,r,g.children,l),r=r.child}return r;case 9:return g=r.type,d=r.pendingProps.children,vr(r,l),g=Yn(g),d=d(g),r.flags|=1,bn(i,r,d,l),r.child;case 14:return d=r.type,g=ri(d,r.pendingProps),g=ri(d.type,g),Cm(i,r,d,g,l);case 15:return Em(i,r,r.type,r.pendingProps,l);case 17:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),Ya(i,r),r.tag=1,Rn(d)?(i=!0,Pa(r)):i=!1,vr(r,l),vm(r,d,g),pu(r,d,g,l),_u(null,r,d,!0,i,l);case 19:return Dm(i,r,l);case 22:return Nm(i,r,l)}throw Error(n(156,r.tag))};function sg(i,r){return Ns(i,r)}function GS(i,r,l,d){this.tag=i,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qn(i,r,l,d){return new GS(i,r,l,d)}function Bu(i){return i=i.prototype,!(!i||!i.isReactComponent)}function XS(i){if(typeof i=="function")return Bu(i)?1:0;if(i!=null){if(i=i.$$typeof,i===M)return 11;if(i===L)return 14}return 2}function as(i,r){var l=i.alternate;return l===null?(l=Qn(i.tag,r,i.key,i.mode),l.elementType=i.elementType,l.type=i.type,l.stateNode=i.stateNode,l.alternate=i,i.alternate=l):(l.pendingProps=r,l.type=i.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=i.flags&14680064,l.childLanes=i.childLanes,l.lanes=i.lanes,l.child=i.child,l.memoizedProps=i.memoizedProps,l.memoizedState=i.memoizedState,l.updateQueue=i.updateQueue,r=i.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=i.sibling,l.index=i.index,l.ref=i.ref,l}function rl(i,r,l,d,g,_){var P=2;if(d=i,typeof i=="function")Bu(i)&&(P=1);else if(typeof i=="string")P=5;else e:switch(i){case z:return zs(l.children,g,_,r);case Z:P=8,g|=8;break;case G:return i=Qn(12,l,r,g|2),i.elementType=G,i.lanes=_,i;case j:return i=Qn(13,l,r,g),i.elementType=j,i.lanes=_,i;case T:return i=Qn(19,l,r,g),i.elementType=T,i.lanes=_,i;case H:return ol(l,g,_,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Q:P=10;break e;case B:P=9;break e;case M:P=11;break e;case L:P=14;break e;case $:P=16,d=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Qn(P,l,r,g),r.elementType=i,r.type=d,r.lanes=_,r}function zs(i,r,l,d){return i=Qn(7,i,d,r),i.lanes=l,i}function ol(i,r,l,d){return i=Qn(22,i,d,r),i.elementType=H,i.lanes=l,i.stateNode={isHidden:!1},i}function zu(i,r,l){return i=Qn(6,i,null,r),i.lanes=l,i}function Fu(i,r,l){return r=Qn(4,i.children!==null?i.children:[],i.key,r),r.lanes=l,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function QS(i,r,l,d,g){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fc(0),this.expirationTimes=fc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fc(0),this.identifierPrefix=d,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function $u(i,r,l,d,g,_,P,V,J){return i=new QS(i,r,l,V,J),r===1?(r=1,_===!0&&(r|=8)):r=0,_=Qn(3,null,null,r),i.current=_,_.stateNode=i,_.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},eu(_),i}function JS(i,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Y,key:d==null?null:""+d,children:i,containerInfo:r,implementation:l}}function rg(i){if(!i)return Ji;i=i._reactInternals;e:{if(zt(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Rn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var l=i.type;if(Rn(l))return Tp(i,l,r)}return r}function og(i,r,l,d,g,_,P,V,J){return i=$u(l,d,!0,i,g,_,P,V,J),i.context=rg(null),l=i.current,d=Sn(),g=rs(l),_=Ti(d,g),_.callback=r??null,ts(l,_,g),i.current.lanes=g,Qr(i,g,d),An(i,d),i}function al(i,r,l,d){var g=r.current,_=Sn(),P=rs(g);return l=rg(l),r.context===null?r.context=l:r.pendingContext=l,r=Ti(_,P),r.payload={element:i},d=d===void 0?null:d,d!==null&&(r.callback=d),i=ts(g,r,P),i!==null&&(li(i,g,P,_),Ba(i,g,P)),P}function ll(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function ag(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var l=i.retryLane;i.retryLane=l!==0&&l<r?l:r}}function Hu(i,r){ag(i,r),(i=i.alternate)&&ag(i,r)}function ZS(){return null}var lg=typeof reportError=="function"?reportError:function(i){console.error(i)};function Uu(i){this._internalRoot=i}cl.prototype.render=Uu.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));al(i,r,null,null)},cl.prototype.unmount=Uu.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Is(function(){al(null,i,null,null)}),r[ji]=null}};function cl(i){this._internalRoot=i}cl.prototype.unstable_scheduleHydration=function(i){if(i){var r=Kf();i={blockedOn:null,target:i,priority:r};for(var l=0;l<Vi.length&&r!==0&&r<Vi[l].priority;l++);Vi.splice(l,0,i),l===0&&Yf(i)}};function Wu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ul(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function cg(){}function e0(i,r,l,d,g){if(g){if(typeof d=="function"){var _=d;d=function(){var le=ll(P);_.call(le)}}var P=og(r,d,i,0,null,!1,!1,"",cg);return i._reactRootContainer=P,i[ji]=P.current,ho(i.nodeType===8?i.parentNode:i),Is(),P}for(;g=i.lastChild;)i.removeChild(g);if(typeof d=="function"){var V=d;d=function(){var le=ll(J);V.call(le)}}var J=$u(i,0,!1,null,null,!1,!1,"",cg);return i._reactRootContainer=J,i[ji]=J.current,ho(i.nodeType===8?i.parentNode:i),Is(function(){al(r,J,l,d)}),J}function dl(i,r,l,d,g){var _=l._reactRootContainer;if(_){var P=_;if(typeof g=="function"){var V=g;g=function(){var J=ll(P);V.call(J)}}al(r,P,i,g)}else P=e0(l,r,i,g,d);return ll(P)}Uf=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var l=Xr(r.pendingLanes);l!==0&&(pc(r,l|1),An(r,Et()),(lt&6)===0&&(Sr=Et()+500,Zi()))}break;case 13:Is(function(){var d=Ai(i,1);if(d!==null){var g=Sn();li(d,i,1,g)}}),Hu(i,1)}},mc=function(i){if(i.tag===13){var r=Ai(i,134217728);if(r!==null){var l=Sn();li(r,i,134217728,l)}Hu(i,134217728)}},Wf=function(i){if(i.tag===13){var r=rs(i),l=Ai(i,r);if(l!==null){var d=Sn();li(l,i,r,d)}Hu(i,r)}},Kf=function(){return mt},qf=function(i,r){var l=mt;try{return mt=i,r()}finally{mt=l}},Je=function(i,r,l){switch(r){case"input":if(Pt(i,l),r=l.name,l.type==="radio"&&r!=null){for(l=i;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==i&&d.form===i.form){var g=ja(d);if(!g)throw Error(n(90));qe(d),Pt(d,g)}}}break;case"textarea":ke(i,l);break;case"select":r=l.value,r!=null&&Qe(i,!!l.multiple,r,!1)}},Wn=Mu,ui=Is;var t0={usingClientEntryPoint:!1,Events:[mo,cr,ja,Zt,ni,Mu]},Ro={findFiberByHostInstance:js,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},n0={bundleType:Ro.bundleType,version:Ro.version,rendererPackageName:Ro.rendererPackageName,rendererConfig:Ro.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Es(i),i===null?null:i.stateNode},findFiberByHostInstance:Ro.findFiberByHostInstance||ZS,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var hl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hl.isDisabled&&hl.supportsFiber)try{Ut=hl.inject(n0),en=hl}catch{}}return Tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=t0,Tn.createPortal=function(i,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wu(r))throw Error(n(200));return JS(i,r,null,l)},Tn.createRoot=function(i,r){if(!Wu(i))throw Error(n(299));var l=!1,d="",g=lg;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(g=r.onRecoverableError)),r=$u(i,1,!1,null,null,l,!1,d,g),i[ji]=r.current,ho(i.nodeType===8?i.parentNode:i),new Uu(r)},Tn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Es(r),i=i===null?null:i.stateNode,i},Tn.flushSync=function(i){return Is(i)},Tn.hydrate=function(i,r,l){if(!ul(r))throw Error(n(200));return dl(null,i,r,!0,l)},Tn.hydrateRoot=function(i,r,l){if(!Wu(i))throw Error(n(405));var d=l!=null&&l.hydratedSources||null,g=!1,_="",P=lg;if(l!=null&&(l.unstable_strictMode===!0&&(g=!0),l.identifierPrefix!==void 0&&(_=l.identifierPrefix),l.onRecoverableError!==void 0&&(P=l.onRecoverableError)),r=og(r,null,i,1,l??null,g,!1,_,P),i[ji]=r.current,ho(i),d)for(i=0;i<d.length;i++)l=d[i],g=l._getVersion,g=g(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,g]:r.mutableSourceEagerHydrationData.push(l,g);return new cl(r)},Tn.render=function(i,r,l){if(!ul(r))throw Error(n(200));return dl(null,i,r,!1,l)},Tn.unmountComponentAtNode=function(i){if(!ul(i))throw Error(n(40));return i._reactRootContainer?(Is(function(){dl(null,null,i,!1,function(){i._reactRootContainer=null,i[ji]=null})}),!0):!1},Tn.unstable_batchedUpdates=Mu,Tn.unstable_renderSubtreeIntoContainer=function(i,r,l,d){if(!ul(l))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return dl(i,r,l,!1,d)},Tn.version="18.3.1-next-f1338f8080-20240426",Tn}var vg;function d0(){if(vg)return Vu.exports;vg=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(),Vu.exports=u0(),Vu.exports}var _g;function h0(){if(_g)return fl;_g=1;var e=d0();return fl.createRoot=e.createRoot,fl.hydrateRoot=e.hydrateRoot,fl}var f0=h0();const p0=Vh(f0);function Ht(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const X_=e=>`nc_seen_${e}`;async function Ie(e,t,n={}){const s=await Ht(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const cn=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",un=(e,t)=>`${cn(e)}/fleet/${t}`,ws=(e,t)=>Ie(un(t,"status"),e),Gh=(e,t,n)=>Ie(un(n,"up"),e,{method:"POST",body:t}),Il=(e,t,n)=>Ie(un(n,"down"),e,{method:"POST",body:t}),Q_=(e,t,n)=>Ie(un(n,"boot"),e,{method:"POST",body:t}),Fo=(e,t,n)=>Ie(un(n,"restart"),e,{method:"POST",body:{cell:t}}),Jl=(e,t)=>Ie(un(t,"definitions"),e),m0=(e,t)=>Ie(un(t,"credentials/status"),e),yg=(e,t,n,s)=>Ie(un(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),g0=(e,t,n)=>Ie(un(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),v0=(e,t,n)=>Ie(un(n,"define-engine"),e,{method:"POST",body:{def:t}}),_0=(e,t,n,s,o)=>Ie(un(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),y0=(e,t,n)=>Ie(un(n,"remove-engine"),e,{method:"POST",body:{id:t}}),w0=(e,t,n)=>Ie(un(n,"define-cell"),e,{method:"POST",body:{def:t}}),J_=(e,t,n,s)=>Ie(un(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),Z_=(e,t,n=!1,s)=>Ie(un(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),b0=(e,t,n)=>Ie(un(n,"import-cell"),e,{method:"POST",body:t}),S0=(e,t,n)=>Ie(un(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),x0=(e,t,n,s)=>Ie(un(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Xh=(e,t,n)=>Ie(`${cn(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ey=(e,t,n,s)=>Ie(`${cn(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),Qh=(e,t,n)=>Ie(`${cn(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),ty=e=>Ie("/api/settings",e),k0=e=>Ie("/api/nodes",e),C0=e=>Ie("/api/peers",e),ny=(e,t=[])=>Ie(`${cn(t)}/vl-nodes`,e),wg=(e,t,n,s={},o=[])=>Ie(`${cn(o)}/vl-nodes/${encodeURIComponent(t)}/commands`,e,{method:"POST",body:{kind:n,args:s}}),E0=(e,t,n=0,s=[])=>Ie(`${cn(s)}/vl-nodes/${encodeURIComponent(t)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,e),iy=e=>Ie("/api/topology",e),Jh=(e,t)=>Ie(`${cn(t)}/sessions`,e),Zh=(e,t)=>Ie(`${cn(t)}/config`,e),bg=(e,t)=>Ie(`${cn(t)}/topology`,e),Wd=(e,t)=>Ie("/api/settings/config",e,{method:"POST",body:t}),N0=e=>Ie("/api/settings/token/rotate",e,{method:"POST"}),j0=(e,t)=>Ie("/api/settings/nodes/pair",e,{method:"POST",body:t}),R0=(e,t,n=[])=>Ie(`${cn(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),sy=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),P0=e=>Ie("/api/settings/node-aliases",e),L0=(e,t,n)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),Sg=(e,t)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),xg=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),A0=(e,t)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ef=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),T0=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),D0=(e,t,n,s=[])=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),M0=e=>Ie("/api/settings/audio",e),I0=(e,t)=>Ie("/api/settings/audio/consent",e,{method:"PATCH",body:{consent:t}}),O0=e=>Ie("/api/settings/audio/test",e,{method:"POST",body:{}}),B0=e=>Ie("/api/settings/audio/stop",e,{method:"POST",body:{}}),z0=e=>Ie("/api/settings/audio/groups",e),F0=(e,t,n)=>Ie(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"PUT",body:n}),$0=(e,t)=>Ie(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"DELETE"}),H0=e=>Ie("/api/settings/service/regenerate",e,{method:"POST"}),U0=e=>Ie("/api/settings/update/check",e,{method:"POST"}),W0=e=>Ie("/api/settings/update/apply",e,{method:"POST"}),Zl=(e,t)=>`${cn(e)}/diagnostics/${t}`,K0=(e,t=[])=>Ie(Zl(t,"status"),e),q0=(e,{after:t=0,limit:n=200}={},s=[])=>Ie(`${Zl(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),kg=(e,t,n,s=[])=>Ie(Zl(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),V0=(e,t=[])=>Ie(Zl(t,"logs"),e,{method:"DELETE"}),Y0=(e,t=!0)=>Ie(`/api/asks${t?"?open=1":""}`,e),G0=(e,t,n)=>Ie(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),X0=(e,t)=>Ie(`/api/asks/${encodeURIComponent(t)}`,e,{method:"DELETE"}),pl=(e,t=[])=>Ie(`${cn(t)}/decks`,e),Cg=(e,t,n=[])=>Ie(`${cn(n)}/decks`,e,{method:"POST",body:{name:t}}),ml=(e,t,n,s,o=[])=>Ie(`${cn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Q0=(e,t,n,s,o=[])=>Ie(`${cn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),J0=(e,t,n,s=[])=>Ie(`${cn(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Z0={power:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 3v8"}),c.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:c.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),c.jsx("path",{d:"M12 18v3"})]}),enter:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),c.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),c.jsx("path",{d:"M22 2 11 13"})]}),trash:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),c.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),c.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:c.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),c.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),c.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),c.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 16V5"}),c.jsx("polyline",{points:"8 9 12 5 16 9"}),c.jsx("path",{d:"M5 20h14"})]}),chevronLeft:c.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:c.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:c.jsx("polyline",{points:"6 10 12 16 18 10"}),history:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("polyline",{points:"3 3 3 8 8 8"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),attach:c.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),c.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6"})]}),gear:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function Ze({name:e,size:t=20}){return c.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Z0[e]||null})}const ex=["all","pinned","active","off","technical"],ry="nc_sidebar_views_v1",oy="nc_sidebar_order_v1";function ay(e){return ex.includes(e)?e:"all"}function tx(e,t=[],n="all"){const s=ay(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function nx(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,f=s.indexOf(e.key),m=s.indexOf(t.key),v=f===-1?Number.MAX_SAFE_INTEGER:f,S=m===-1?Number.MAX_SAFE_INTEGER:m;return u-h||v-S||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function ix(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(oy));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}catch{return{}}}function Fi(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function sx(e,t=globalThis.localStorage){try{t.setItem(oy,JSON.stringify(e))}catch{}return e}function rx(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(n)||!a.includes(s))return e;const u=Fi(e,t).filter(y=>a.includes(y)),h=[...u,...a.filter(y=>!u.includes(y))],f=h.indexOf(n),m=h.indexOf(s);h.splice(f,1);const v=h.indexOf(s),S=f<m?v+1:v;return h.splice(S,0,n),{...e,[t]:h}}function ox(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(ry));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Eg(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:ay((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function ax(e,t=globalThis.localStorage){try{t.setItem(ry,JSON.stringify(e))}catch{}return e}function Ng(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function gs(e=[],t=[],n="all",s=[]){return[...e].filter(o=>tx(o,t,n)).sort((o,a)=>nx(o,a,t,s))}const tf=["it","en","es"];function lx(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return tf.includes(t)?t:"en"}catch{return"en"}}const jl=lx(),ly="nc_lang",Kd="nc-lang";function cy(){return typeof localStorage<"u"?localStorage:null}const gl={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","tab-audio":"audio","system-general":"generale","system-diagnostics":"diagnostica","system-this-node":"questo nodo","system-updates":"aggiornamenti","system-security":"sicurezza","system-local-data":"dati locali del browser","system-terminal":"terminale","alternate-screen":"schermo alternato","alternate-screen-help":"Mantiene il comportamento tmux standard per le nuove sessioni NexusCrew. Un’applicazione che segue il mouse scorre da sé; le altre fanno scorrere la storia di tmux. Non modifica le celle già attive.","tab-input":"input","tab-diagnostics":"diagnostica","input-settings-local":"Preferenze locali di questo browser. Si applicano subito a vista singola e deck, senza modificare il nodo remoto.","terminal-keyboard-gesture":"Apertura tastiera virtuale dal terminale","terminal-keyboard-double-tap":"Doppio tap (predefinito)","terminal-keyboard-single-tap":"Tap singolo","terminal-keyboard-never":"Mai dal terminale","terminal-keyboard-gesture-help":"Il tastierino e STT seguono i controlli separati sotto. Mouse e tastiera fisica restano utilizzabili.","keybar-ime-lock":"Tastierino: mantieni chiusa la tastiera virtuale","keybar-ime-lock-help":"ESC, frecce, PgUp/PgDn, Enter e menu inviano direttamente al PTY senza dare focus a un campo di testo.","voice-ime-lock":"Microfono STT: mantieni chiusa la tastiera virtuale","voice-ime-lock-help":"Il tap sul microfono avvia o ferma la voce senza focalizzare il composer.","keybar-enter-show":"Mostra Enter verticale nel tastierino","keybar-enter-show-help":"Enter resta a destra di PgUp/PgDn ed è alto quanto entrambe le righe.","keybar-layout":"Layout tastierino","keybar-layout-full":"Esteso (predefinito)","keybar-layout-compact":"Compatto","keybar-layout-help":"Compatto: una riga con expand ⊞ per accedere al set completo senza cambiare la preferenza.","input-settings-reset":"ripristina predefiniti input","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-credential-source-policy":"origine credenziale","fleet-credential-source-policy-auto":"auto (precedenza legacy)","fleet-credential-source-policy-nexuscrew-store":"solo store NexusCrew","fleet-credential-source-policy-environment":"solo ambiente","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max-preview è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa il login del CLI (device-code) e la propria configurazione: NexusCrew non legge né copia credenziali. Distinto dal provider "Kimi Code" di Claude Code, che resta il percorso K3 gestito.',"fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-recovery-client-terminal-dialog":"Completa il dialogo mostrato nel terminale della cella, poi riavvia la cella.","settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-group-vl":"Nodi VL","vl-owners-unavailable":"Owner VL non raggiunti","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-off-hub-reconcile-pending":"Stato privato salvato; la revoca sull’hub è ancora in attesa.","fleet-cell-label":"nome leggibile (facoltativo)","share-off-local-reconcile-pending":"Revoca confermata dall’hub; il tunnel locale deve ancora riconciliarsi.","share-reverse-pool-pending":"Il canale reverse non risulta spento in modo dimostrabile: resta in quarantena, non chiuso.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","peer-vl-federated":"Nodo VL: federato","row-vl-federated":"federato","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","vl-poll-online":"online (poll)","vl-poll-offline":"non risponde","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-needs-test":"Per questa sessione dell’app, premi “prova voce” prima di ricevere annunci vocali.","notification-speech-unsupported":"Sintesi vocale non supportata in questo browser.","audio-title":"Audio nativo del nodo","audio-help":"Consenso e controlli valgono solo per questo dispositivo. Share e visibilità non autorizzano suoni.","audio-consent":"consenti TTS su questo nodo","audio-consent-help":"Permette a celle autorizzate, locali o remote, di consegnare un comando vocale. Puoi revocarlo in ogni momento.","audio-capability":"Capability locale","audio-loading":"leggo lo stato audio locale…","audio-adapter":"adapter","audio-adapter-none":"nessuno","audio-installed":"installato","audio-installed-yes":"sì","audio-installed-no":"no","audio-liveness":"disponibilità","audio-liveness-ready":"pronto ad accettare","audio-liveness-unavailable":"non disponibile","audio-languages":"lingue dichiarate","audio-limits":"limiti","audio-test":"prova audio locale","audio-testing":"prova in corso…","audio-stop":"ferma audio locale","audio-stopping":"stop in corso…","audio-test-needs-consent":"Attiva il consenso locale prima di provare la voce.","audio-unavailable":"Nessun adapter TTS nativo disponibile su questo nodo.","audio-test-accepted":"Il nodo ha accettato la prova. Non dimostra che qualcuno l’abbia udita.","audio-test-refused":"Il nodo ha rifiutato la prova.","audio-test-unknown":"Esito della prova sconosciuto: il nodo non può confermare l’avvio.","audio-stop-stopped":"Audio locale fermato.","audio-stop-idle":"Nessun enunciato locale da fermare.","audio-groups-title":"Gruppi audio condivisi","audio-groups-help":"Decide su quali dispositivi si sente la voce quando una cella parla. Il gruppo è una preferenza locale di consegna, non un consenso. Ogni nodo conserva consenso, ACL, disponibilità e Stop locale.","audio-groups-empty":"Nessun gruppo: la voce esce solo su questo nodo.","audio-group-name":"nome gruppo","audio-group-mode":"modalità consegna","audio-group-primary":"primo disponibile (in ordine)","audio-group-fanout":"tutti i nodi elencati","audio-group-targets":"nodi target esatti","audio-group-local":"questo nodo","audio-group-unavailable-target":"non rilevato ora","audio-group-no-targets":"Nessun nodo con instanceId disponibile. Il gruppo non può usare nomi, wildcard o “tutti”.","audio-group-new":"nuovo gruppo","audio-group-edit":"modifica","audio-group-delete":"elimina","audio-group-save":"salva gruppo","audio-group-cancel":"annulla","audio-group-invalid":"Il gruppo richiede un nome valido e almeno un nodeId esatto.","audio-group-save-failed":"Salvataggio gruppo audio non riuscito.","node-display-label":"Nome (etichetta)","routed-node-aliases":"Alias nodi instradati","routed-node-aliases-help":"Visibili solo su questo dispositivo; route e nome remoto non cambiano.","node-local-alias":"Alias su questo dispositivo","alias-on-device":"Alias su questo dispositivo","reset-alias":"Ripristina nome remoto","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","cell-switcher-refreshing":"aggiorno le celle…","cell-switcher-empty-active":"nessuna cella attiva verificata","cell-switcher-not-confirmed":"stato non confermato","cell-switcher-not-active":"questa cella non è più attiva","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","selection-held":"evidenziazione persa, testo ancora in mano","invite-hub-only":"Un invito si conia sull’hub. Ammettere un nodo nuovo è la sola cosa che un nodo collegato non può chiedere per conto di un altro: apri NexusCrew sull’hub e crea l’invito da lì.","row-private":"privato","node-detail-open":"apri il dettaglio","node-detail-reach":"Raggiungibilità","node-detail-route":"percorso","node-detail-ssh":"SSH","node-detail-transport":"trasporto","node-detail-owner":"owner","node-detail-authority":"Cosa può fare questo nodo","authority-owner-equivalent":"Autorità pari alla tua: un nodo accoppiato può fare su questa macchina tutto quello che puoi fare tu.","authority-routed":"Non è accoppiato con questa macchina: la sua autorità vive presso l’hub che lo instrada.","authority-no-grants":"I poteri per-nodo non esistono ancora: qui non c’è niente da concedere o togliere.","node-detail-network-view":"Cosa vede di questa rete","node-detail-command":"Comando","vl-no-commands":"Il device non dichiara comandi disponibili.","vl-events-title":"Sessione","vl-events-empty":"Nessun evento in memoria: la sessione non ha ancora parlato, oppure quello che ha detto è uscito dal buffer. La storia resta sul device.","vl-events-gap":"eventi non ricevuti:","vl-events-truncated":"contenuto troncato dal device","vl-events-turn-end":"— fine turno —","vl-events-done":"— fine risposta —","vl-events-writer-epoch":"— cambio scrittore —","vl-events-tool":"strumento","vl-events-tool-ok":"concluso","vl-events-tool-failed":"fallito","vl-events-usage":"consumo aggiornato","vl-events-stale":"Aggiornamento non riuscito: quello che vedi potrebbe non essere l’ultimo.","vl-cmd-phase-submitted":"inviato, in attesa di conferma","vl-cmd-phase-inflight":"in corso","vl-cmd-phase-done-ok":"completato","vl-cmd-phase-done-error":"fallito","vl-cmd-status":"stato","vl-cmd-health":"salute","vl-cmd-start":"avvia","vl-cmd-stop":"ferma","vl-cmd-restart":"riavvia","vl-cmd-version":"versione","vl-cmd-capabilities":"capacità","vl-cmd-logs":"log","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"scrivi il prompt per la sessione del device…","vl-prompt-send":"invia prompt","vl-cmd-unpair":"disaccoppia","node-grant-none":"Nessun nodo scelto: condiviso, ma verso nessuno.","node-grant-unknown":"non più in inventario","node-grant-remove":"togli","node-grant-add":"Aggiungi un nodo","node-grant-search":"Cerca fra i nodi","node-grant-no-candidates":"Nessun nodo corrisponde.","cell-scope":"Celle visibili a questo nodo","cell-scope-help":"Vale su cio’ che questo nodo elenca e su cio’ che può toccare, terminale compreso. Dentro le celle concesse resta un nodo accoppiato a pieno titolo: non è una sandbox.","cell-scope-all":"tutte le celle","cell-scope-none":"nessuna cella","cell-scope-selected":"celle selezionate","cell-scope-none-granted":"Nessuna cella scelta: questo nodo non ne vede nessuna.","cell-scope-unknown":"cella non più esistente","cell-scope-add":"Aggiungi una cella","cell-scope-search":"Cerca fra le celle","cell-scope-no-candidates":"Nessuna cella corrisponde.","cell-scope-reset-warning":"Cambiando modo l’elenco viene azzerato: tornando a «celle selezionate» andrà rifatto.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnostics","system-this-node":"this node","system-updates":"updates","system-security":"security","system-local-data":"local browser data","system-terminal":"terminal","alternate-screen":"alternate screen","alternate-screen-help":"Keeps standard tmux behaviour for new NexusCrew sessions. An application that tracks the mouse scrolls on its own; the others browse the tmux scrollback. It does not change cells already running.","tab-input":"input","tab-diagnostics":"diagnostics","input-settings-local":"Local preferences for this browser. They apply immediately to single view and decks without changing the remote node.","terminal-keyboard-gesture":"Open the virtual keyboard from the terminal","terminal-keyboard-double-tap":"Double tap (default)","terminal-keyboard-single-tap":"Single tap","terminal-keyboard-never":"Never from terminal","terminal-keyboard-gesture-help":"The keypad and STT use the separate controls below. Mouse and physical keyboard remain available.","keybar-ime-lock":"Keypad: keep the virtual keyboard closed","keybar-ime-lock-help":"ESC, arrows, PgUp/PgDn, Enter and menu send directly to the PTY without focusing a text field.","voice-ime-lock":"STT microphone: keep the virtual keyboard closed","voice-ime-lock-help":"Tapping the microphone starts or stops voice without focusing the composer.","keybar-enter-show":"Show the tall Enter keypad key","keybar-enter-show-help":"Enter stays to the right of PgUp/PgDn and spans both rows.","keybar-layout":"Keypad layout","keybar-layout-full":"Full (default)","keybar-layout-compact":"Compact","keybar-layout-help":"Compact: one row with an expand toggle that reaches the full key set without changing the preference.","input-settings-reset":"restore input defaults","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-credential-source-policy":"credential source","fleet-credential-source-policy-auto":"auto (legacy precedence)","fleet-credential-source-policy-nexuscrew-store":"NexusCrew store only","fleet-credential-source-policy-environment":"environment only","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max-preview is the default and no OpenAI/PAYG fallback is used.","fleet-provider-notice-kimi-native":'Native Kimi Code CLI uses the CLI login (device code) and its own configuration: NexusCrew never reads or copies credentials. Distinct from the Claude Code "Kimi Code" provider, which remains the managed K3 path.',"fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-recovery-client-terminal-dialog":"Complete the dialog shown in the cell terminal, then restart the cell.","settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-group-vl":"VL nodes","vl-owners-unavailable":"VL owners unreachable","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-off-hub-reconcile-pending":"Private state saved; hub revocation is still pending.","fleet-cell-label":"readable name (optional)","share-off-local-reconcile-pending":"Hub revocation confirmed; the local tunnel still needs reconciliation.","share-reverse-pool-pending":"The reverse channel was not demonstrably shut down: it is quarantined, not closed.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","peer-vl-federated":"VL node: federated","row-vl-federated":"federated","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","vl-poll-online":"online (poll)","vl-poll-offline":"not responding","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-needs-test":"For this app session, select “test voice” before spoken alerts can play.","notification-speech-unsupported":"Speech synthesis is not supported in this browser.","audio-title":"Native node audio","audio-help":"Consent and controls apply only to this device. Share and visibility do not authorize sounds.","audio-consent":"allow TTS on this node","audio-consent-help":"Allows authorized local or remote cells to deliver a voice command. You can revoke it at any time.","audio-capability":"Local capability","audio-loading":"reading local audio state…","audio-adapter":"adapter","audio-adapter-none":"none","audio-installed":"installed","audio-installed-yes":"yes","audio-installed-no":"no","audio-liveness":"availability","audio-liveness-ready":"ready to accept","audio-liveness-unavailable":"unavailable","audio-languages":"declared languages","audio-limits":"limits","audio-test":"test local audio","audio-testing":"testing audio…","audio-stop":"stop local audio","audio-stopping":"stopping audio…","audio-test-needs-consent":"Enable local consent before testing the voice.","audio-unavailable":"No native TTS adapter is available on this node.","audio-test-accepted":"The node accepted the test. It does not prove that anyone heard it.","audio-test-refused":"The node refused the test.","audio-test-unknown":"Test outcome unknown: the node could not confirm startup.","audio-stop-stopped":"Local audio stopped.","audio-stop-idle":"No local utterance to stop.","audio-groups-title":"Shared audio groups","audio-groups-help":"Chooses which devices play the voice when a cell speaks. A group is a local delivery preference, not consent. Each node keeps its own consent, ACL, availability and local Stop.","audio-groups-empty":"No group: voice plays only on this node.","audio-group-name":"group name","audio-group-mode":"delivery mode","audio-group-primary":"first available (in order)","audio-group-fanout":"all listed nodes","audio-group-targets":"exact target nodes","audio-group-local":"this node","audio-group-unavailable-target":"not currently discovered","audio-group-no-targets":"No node with an available instanceId. A group cannot use names, wildcards, or “all”.","audio-group-new":"new group","audio-group-edit":"edit","audio-group-delete":"delete","audio-group-save":"save group","audio-group-cancel":"cancel","audio-group-invalid":"A group needs a valid name and at least one exact nodeId.","audio-group-save-failed":"Could not save audio group.","node-display-label":"Name (label)","routed-node-aliases":"Routed node aliases","routed-node-aliases-help":"Visible only on this device; the route and remote name do not change.","node-local-alias":"Alias on this device","alias-on-device":"Alias on this device","reset-alias":"Reset remote name","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","cell-switcher-refreshing":"refreshing cells…","cell-switcher-empty-active":"no verified active cells","cell-switcher-not-confirmed":"status not confirmed","cell-switcher-not-active":"this cell is no longer active","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","selection-held":"highlight gone, text still held","invite-hub-only":"An invite is minted on the hub. Admitting a new node is the one thing a connected node cannot ask on another’s behalf: open NexusCrew on the hub and create the invite there.","row-private":"private","node-detail-open":"open details","node-detail-reach":"Reachability","node-detail-route":"path","node-detail-ssh":"SSH","node-detail-transport":"transport","node-detail-owner":"owner","node-detail-authority":"What this node can do","authority-owner-equivalent":"Authority equal to yours: a paired node can do on this machine everything you can do.","authority-routed":"Not paired with this machine: its authority lives on the hub that routes it.","authority-no-grants":"Per-node powers do not exist yet: there is nothing to grant or withdraw here.","node-detail-network-view":"What it sees of this network","node-detail-command":"Command","vl-no-commands":"The device declares no commands available.","vl-events-title":"Session","vl-events-empty":"No events in memory: the session has not spoken yet, or what it said has left the buffer. The history stays on the device.","vl-events-gap":"events not received:","vl-events-truncated":"content truncated by the device","vl-events-turn-end":"— end of turn —","vl-events-done":"— turn complete —","vl-events-writer-epoch":"— writer changed —","vl-events-tool":"tool","vl-events-tool-ok":"finished","vl-events-tool-failed":"failed","vl-events-usage":"usage updated","vl-events-stale":"Refresh failed: what you see may not be the latest.","vl-cmd-phase-submitted":"sent, awaiting confirmation","vl-cmd-phase-inflight":"in progress","vl-cmd-phase-done-ok":"completed","vl-cmd-phase-done-error":"failed","vl-cmd-status":"status","vl-cmd-health":"health","vl-cmd-start":"start","vl-cmd-stop":"stop","vl-cmd-restart":"restart","vl-cmd-version":"version","vl-cmd-capabilities":"capabilities","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"write the prompt for the device session…","vl-prompt-send":"send prompt","vl-cmd-unpair":"unpair","node-grant-none":"No node chosen: shared, but towards nobody.","node-grant-unknown":"no longer in the inventory","node-grant-remove":"remove","node-grant-add":"Add a node","node-grant-search":"Search the nodes","node-grant-no-candidates":"No node matches.","cell-scope":"Cells this node can see","cell-scope-help":"Applies to what this node lists and to what it can act on, terminal included. Within the granted cells it remains a fully paired node: this is not a sandbox.","cell-scope-all":"every cell","cell-scope-none":"no cell","cell-scope-selected":"selected cells","cell-scope-none-granted":"No cell chosen: this node sees none of them.","cell-scope-unknown":"cell no longer exists","cell-scope-add":"Add a cell","cell-scope-search":"Search the cells","cell-scope-no-candidates":"No cell matches.","cell-scope-reset-warning":"Switching mode clears the list: coming back to “selected cells” means choosing them again.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnóstico","system-this-node":"este nodo","system-updates":"actualizaciones","system-security":"seguridad","system-local-data":"datos locales del navegador","system-terminal":"terminal","alternate-screen":"pantalla alternativa","alternate-screen-help":"Mantiene el comportamiento estándar de tmux para las nuevas sesiones NexusCrew. Una aplicación que sigue el ratón se desplaza sola; las demás recorren el historial de tmux. No modifica las celdas ya activas.","tab-input":"entrada","tab-diagnostics":"diagnóstico","input-settings-local":"Preferencias locales de este navegador. Se aplican de inmediato a la vista única y a los decks sin cambiar el nodo remoto.","terminal-keyboard-gesture":"Abrir el teclado virtual desde el terminal","terminal-keyboard-double-tap":"Doble toque (predeterminado)","terminal-keyboard-single-tap":"Toque único","terminal-keyboard-never":"Nunca desde el terminal","terminal-keyboard-gesture-help":"El teclado auxiliar y STT usan los controles separados de abajo. El ratón y el teclado físico siguen disponibles.","keybar-ime-lock":"Teclado auxiliar: mantener cerrado el teclado virtual","keybar-ime-lock-help":"ESC, flechas, PgUp/PgDn, Enter y menú envían directamente al PTY sin enfocar un campo de texto.","voice-ime-lock":"Micrófono STT: mantener cerrado el teclado virtual","voice-ime-lock-help":"Tocar el micrófono inicia o detiene la voz sin enfocar el compositor.","keybar-enter-show":"Mostrar Enter vertical en el teclado auxiliar","keybar-enter-show-help":"Enter queda a la derecha de PgUp/PgDn y ocupa las dos filas.","keybar-layout":"Distribución del teclado auxiliar","keybar-layout-full":"Completo (predeterminado)","keybar-layout-compact":"Compacto","keybar-layout-help":"Compacto: una fila con un botón expandir que alcanza el conjunto completo sin cambiar la preferencia.","input-settings-reset":"restaurar valores de entrada","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-credential-source-policy":"origen de credencial","fleet-credential-source-policy-auto":"auto (precedencia legacy)","fleet-credential-source-policy-nexuscrew-store":"solo almacén NexusCrew","fleet-credential-source-policy-environment":"solo entorno","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max-preview es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa el login del CLI (device-code) y su propia configuración: NexusCrew no lee ni copia credenciales. Distinto del proveedor "Kimi Code" de Claude Code, que sigue siendo la ruta K3 gestionada.',"fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirma la clave API personalizada (Yes) en el terminal de la celda, luego reinicia la celda.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: en el terminal de la celda abre /config y activa "Use custom API key", luego reinicia la celda. Si la clave cambió, actualiza la credencial y reintenta.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: en el terminal de la celda ejecuta /login (código de dispositivo Kimi) o /provider, luego reinicia la celda.","fleet-recovery-client-terminal-dialog":"Completa el diálogo mostrado en el terminal de la celda, luego reinicia la celda.","settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-group-vl":"Nodos VL","vl-owners-unavailable":"Owners VL no alcanzados","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-off-hub-reconcile-pending":"Estado privado guardado; la revocación en el hub sigue pendiente.","fleet-cell-label":"nombre legible (opcional)","share-off-local-reconcile-pending":"Revocación confirmada por el hub; el túnel local aún debe reconciliarse.","share-reverse-pool-pending":"El canal inverso no se apagó de forma demostrable: queda en cuarentena, no cerrado.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","peer-vl-federated":"Nodo VL: federado","row-vl-federated":"federado","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","vl-poll-online":"en línea (poll)","vl-poll-offline":"sin respuesta","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-needs-test":"Para esta sesión de la aplicación, pulsa “probar voz” antes de recibir avisos hablados.","notification-speech-unsupported":"La síntesis de voz no está disponible en este navegador.","audio-title":"Audio nativo del nodo","audio-help":"El consentimiento y los controles valen solo para este dispositivo. Compartir y visibilidad no autorizan sonidos.","audio-consent":"permitir TTS en este nodo","audio-consent-help":"Permite que celdas autorizadas, locales o remotas, entreguen un comando de voz. Puedes revocarlo en cualquier momento.","audio-capability":"Capacidad local","audio-loading":"leyendo el estado de audio local…","audio-adapter":"adaptador","audio-adapter-none":"ninguno","audio-installed":"instalado","audio-installed-yes":"sí","audio-installed-no":"no","audio-liveness":"disponibilidad","audio-liveness-ready":"listo para aceptar","audio-liveness-unavailable":"no disponible","audio-languages":"idiomas declarados","audio-limits":"límites","audio-test":"probar audio local","audio-testing":"probando audio…","audio-stop":"detener audio local","audio-stopping":"deteniendo audio…","audio-test-needs-consent":"Activa el consentimiento local antes de probar la voz.","audio-unavailable":"No hay un adaptador TTS nativo disponible en este nodo.","audio-test-accepted":"El nodo aceptó la prueba. No demuestra que alguien la haya oído.","audio-test-refused":"El nodo rechazó la prueba.","audio-test-unknown":"Resultado de prueba desconocido: el nodo no pudo confirmar el inicio.","audio-stop-stopped":"Audio local detenido.","audio-stop-idle":"No hay enunciado local que detener.","audio-groups-title":"Grupos de audio compartido","audio-groups-help":"Decide en qué dispositivos se oye la voz cuando habla una celda. Un grupo es una preferencia local de entrega, no un consentimiento. Cada nodo conserva su consentimiento, ACL, disponibilidad y Stop local.","audio-groups-empty":"Sin grupos: la voz sale solo por este nodo.","audio-group-name":"nombre del grupo","audio-group-mode":"modo de entrega","audio-group-primary":"primero disponible (en orden)","audio-group-fanout":"todos los nodos enumerados","audio-group-targets":"nodos destino exactos","audio-group-local":"este nodo","audio-group-unavailable-target":"no detectado ahora","audio-group-no-targets":"No hay ningún nodo con instanceId disponible. Un grupo no puede usar nombres, comodines ni “todos”.","audio-group-new":"nuevo grupo","audio-group-edit":"editar","audio-group-delete":"eliminar","audio-group-save":"guardar grupo","audio-group-cancel":"cancelar","audio-group-invalid":"El grupo necesita un nombre válido y al menos un nodeId exacto.","audio-group-save-failed":"No se pudo guardar el grupo de audio.","node-display-label":"Nombre (etiqueta)","routed-node-aliases":"Alias de nodos enrutados","routed-node-aliases-help":"Visibles solo en este dispositivo; la ruta y el nombre remoto no cambian.","node-local-alias":"Alias en este dispositivo","alias-on-device":"Alias en este dispositivo","reset-alias":"Restablecer nombre remoto","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","cell-switcher-refreshing":"actualizando celdas…","cell-switcher-empty-active":"no hay celdas activas verificadas","cell-switcher-not-confirmed":"estado sin confirmar","cell-switcher-not-active":"esta celda ya no está activa","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","selection-held":"resaltado perdido, texto aún retenido","invite-hub-only":"Una invitación se acuña en el hub. Admitir un nodo nuevo es lo único que un nodo conectado no puede pedir en nombre de otro: abre NexusCrew en el hub y créala allí.","row-private":"privado","node-detail-open":"abrir el detalle","node-detail-reach":"Alcanzabilidad","node-detail-route":"ruta","node-detail-ssh":"SSH","node-detail-transport":"transporte","node-detail-owner":"propietario","node-detail-authority":"Qué puede hacer este nodo","authority-owner-equivalent":"Autoridad igual a la tuya: un nodo emparejado puede hacer en esta máquina todo lo que puedes hacer tú.","authority-routed":"No está emparejado con esta máquina: su autoridad vive en el hub que lo enruta.","authority-no-grants":"Los poderes por nodo aún no existen: aquí no hay nada que conceder ni retirar.","node-detail-network-view":"Qué ve de esta red","node-detail-command":"Comando","vl-no-commands":"El dispositivo no declara comandos disponibles.","vl-events-title":"Sesión","vl-events-empty":"Ningún evento en memoria: la sesión aún no ha hablado, o lo que dijo ha salido del búfer. El historial queda en el dispositivo.","vl-events-gap":"eventos no recibidos:","vl-events-truncated":"contenido truncado por el dispositivo","vl-events-turn-end":"— fin del turno —","vl-events-done":"— fin de la respuesta —","vl-events-writer-epoch":"— cambio de escritor —","vl-events-tool":"herramienta","vl-events-tool-ok":"terminada","vl-events-tool-failed":"fallida","vl-events-usage":"consumo actualizado","vl-events-stale":"Actualización fallida: puede que no estés viendo lo último.","vl-cmd-phase-submitted":"enviado, a la espera de confirmación","vl-cmd-phase-inflight":"en curso","vl-cmd-phase-done-ok":"completado","vl-cmd-phase-done-error":"fallido","vl-cmd-status":"estado","vl-cmd-health":"salud","vl-cmd-start":"iniciar","vl-cmd-stop":"detener","vl-cmd-restart":"reiniciar","vl-cmd-version":"versión","vl-cmd-capabilities":"capacidades","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"escribe el prompt para la sesión del dispositivo…","vl-prompt-send":"enviar prompt","vl-cmd-unpair":"desemparejar","node-grant-none":"Ningún nodo elegido: compartido, pero hacia nadie.","node-grant-unknown":"ya no está en el inventario","node-grant-remove":"quitar","node-grant-add":"Añadir un nodo","node-grant-search":"Buscar entre los nodos","node-grant-no-candidates":"Ningún nodo coincide.","cell-scope":"Celdas visibles para este nodo","cell-scope-help":"Se aplica a lo que este nodo lista y a lo que puede tocar, incluido el terminal. Dentro de las celdas concedidas sigue siendo un nodo emparejado por completo: no es un sandbox.","cell-scope-all":"todas las celdas","cell-scope-none":"ninguna celda","cell-scope-selected":"celdas seleccionadas","cell-scope-none-granted":"Ninguna celda elegida: este nodo no ve ninguna.","cell-scope-unknown":"la celda ya no existe","cell-scope-add":"Añadir una celda","cell-scope-search":"Buscar entre las celdas","cell-scope-no-candidates":"Ninguna celda coincide.","cell-scope-reset-warning":"Al cambiar de modo la lista se borra: volver a «celdas seleccionadas» obliga a elegirlas de nuevo.","single-view":"vista única",retract:"reducir","keybar-expand":"ampliar la barra de teclas","keybar-retract":"reducir la barra de teclas","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación de un solo uso. Hace falta la dirección SSH de este dispositivo, alcanzable por quien la use.","invite-target-local":"El nuevo dispositivo entrará en","invite-target-this":"este dispositivo","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Ol(){const e=cy(),t=e?e.getItem(ly):null;return tf.includes(t)?t:jl}function cx(e){const t=cy();if(t)try{t.setItem(ly,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Kd))}function p(e){const t=Ol(),n=gl[t]||gl[jl];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(gl[jl],e)?gl[jl][e]:e}function ux(e){return typeof window>"u"?()=>{}:(window.addEventListener(Kd,e),()=>window.removeEventListener(Kd,e))}const uy=tf;function kn(){return[N.useSyncExternalStore(ux,Ol,Ol),cx]}function Bl({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var $,H;kn();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[h,f]=N.useState([]),[m,v]=N.useState(!1);N.useEffect(()=>{let x=!0;return(async()=>{if(t)try{const O=await ws(t,u?u.split("/"):[]);if(!x)return;if(v(O.provider==="builtin"&&(O.capabilities||[]).includes("edit")),O.provider==="builtin"&&(O.capabilities||[]).includes("definitions")){const D=await Jl(t,u?u.split("/"):[]);if(!x)return;const A=new Map((O.engines||[]).map(W=>[W.id,W]));f((D.engines||[]).map(W=>{var X,ie,ue,fe,we,me,xe;return{id:W.id,label:W.label||W.id,client:((X=W.managed)==null?void 0:X.client)||"",models:[...new Set([...((ie=A.get(W.id))==null?void 0:ie.models)||[],...((ue=W.managedInfo)==null?void 0:ue.models)||[]])].filter(Boolean),defaultModel:((fe=W.managed)==null?void 0:fe.model)||((we=W.managedInfo)==null?void 0:we.defaultModel)||"",policyDefault:((me=W.managed)==null?void 0:me.permissionPolicy)||((xe=W.managed)!=null&&xe.client&&W.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{x=!1}},[t,u]);const S=(e==null?void 0:e.engine)||(($=h[0])==null?void 0:$.id)||"",y=x=>(e==null?void 0:e.models)&&e.models[x]||"",b=x=>{const O=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[x];if(O==="standard"||O==="unsafe")return O;const D=h.find(A=>A.id===x);return D?D.policyDefault:"standard"},[w,k]=N.useState(S),[C,R]=N.useState((e==null?void 0:e.model)||""),E=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((H=e==null?void 0:e.permissionPolicies)==null?void 0:H[e==null?void 0:e.engine])||"",[F,I]=N.useState(E),[K,Y]=N.useState((e==null?void 0:e.boot)??!0),[z,Z]=N.useState(!1),[G,Q]=N.useState(null);N.useEffect(()=>{h.length&&(k(x=>x||S),R(x=>x||y((e==null?void 0:e.engine)||S)||""),I(x=>x==="standard"||x==="unsafe"?x:b((e==null?void 0:e.engine)||S)))},[h.length]);const B=N.useMemo(()=>h.find(x=>x.id===w)||null,[h,w]),M=!!(B&&["claude","codex","codex-vl","agy","kimi"].includes(B.client)),j=(B==null?void 0:B.client)==="shell";function T(x){k(x);const O=h.find(D=>D.id===x);R(y(x)||(O==null?void 0:O.defaultModel)||""),I(b(x))}async function L(x){x.preventDefault(),Z(!0),Q(null);try{if(a)await s({action:"down",boot:K});else{const O=F==="standard"||F==="unsafe"?F:(B==null?void 0:B.policyDefault)||"standard";await s({action:"up",...m?{engine:w,model:C||"",...M?{permissionPolicy:O}:(B==null?void 0:B.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:K})}o()}catch(O){Q(String(O&&O.message||O)),Z(!1)}}return c.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:c.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:x=>x.stopPropagation(),onSubmit:L,children:[c.jsxs("div",{className:"nc-sheet-head",children:[c.jsx("b",{children:e==null?void 0:e.cell}),c.jsx("span",{className:"nc-sheet-state",children:p(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:p("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[p("model"),": ",e.model]}),c.jsx("small",{children:p("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:K,onChange:x=>Y(x.target.checked)}),p("remove-boot")]})]}):c.jsxs(c.Fragment,{children:[m&&h.length>0?c.jsxs("div",{className:"nc-launch-fields",children:[c.jsxs("label",{className:"nc-field",children:[p("engine"),c.jsx("select",{value:w,onChange:x=>T(x.target.value),children:h.map(x=>c.jsx("option",{value:x.id,children:x.label},x.id))})]}),!j&&c.jsxs("label",{className:"nc-field",children:[p("model"),c.jsx("input",{value:C,list:"nc-launch-models",placeholder:p("model-default"),onChange:x=>R(x.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:((B==null?void 0:B.models)||[]).map(x=>c.jsx("option",{value:x},x))})]}),M?c.jsxs("label",{className:"nc-field",children:[p("permissions"),c.jsxs("select",{value:F,onChange:x=>I(x.target.value),children:[c.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:p("fleet-standard-permissions")}),M&&F==="unsafe"&&c.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:p(j?"fleet-shell-launch-help":"launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:p("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[p("model"),": ",e.model]}),c.jsx("small",{children:p("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:K,onChange:x=>Y(x.target.checked)}),p("boot-persist")]})]}),G&&c.jsx("div",{className:"nc-err",children:G}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:z,children:p("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:z,children:p(a?"power-off":"save-and-start")})]})]})})}const jg=/^[a-z0-9-]{1,32}$/;function Go(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function dx(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",f=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!f&&(s[u]=e&&e[u]||n)}return s}function Rg(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Pg({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var m,v,S,y;const u=[],h=new Set,f=new Set;for(const b of Array.isArray(e)?e:[]){if(!b||typeof b.name!="string"||!jg.test(b.name)||b.direction==="inbound"&&b.shared!==!0)continue;const w=[b.name],k=b.name;h.add(k);const C=((m=b.tunnel)==null?void 0:m.status)||"unknown",R=C==="up",E={name:b.name,label:b.label||b.name,originalLabel:b.label||b.name,alias:null,route:w,direct:!0,instanceId:b.nodeId||null,shared:b.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,direction:b.direction||"outbound",roles:b.roles||null,rolesKnown:b.rolesKnown===!0};if(b.nodeId&&f.add(b.nodeId),!b.nodeId&&b.paired===!1){u.push({...E,status:"needs-repair",downSince:s&&s[k]||null});continue}if(((v=b.health)==null?void 0:v.auth)==="failed"||C==="degraded"&&((S=b.health)==null?void 0:S.status)==="degraded"){u.push({...E,status:"needs-repair",downSince:s&&s[k]||null});continue}if(C==="passive"||((y=b.health)==null?void 0:y.status)==="passive"){u.push({...E,status:"passive",downSince:null});continue}if(!R){u.push({...E,status:"down",downSince:s&&s[k]||null});continue}const F=n&&(n[k]||n[b.name])||null,I=o&&(o[k]||o[b.name]),K=!!(F&&!F.error&&Array.isArray(F.sessions)),Y=!!(I&&I.available===!0&&Array.isArray(I.cells));if(!K&&!Y){u.push({...E,status:"unreachable"});continue}const z=(K?F.sessions:[]).filter(Q=>Q&&typeof Q.name=="string"&&Q.name).map(Q=>({...Q,node:k,route:w,key:`${k}:${Q.name}`})),Z=Rg(I,w,k),G=new Set(Z.map(Q=>Q.tmuxSession).filter(Boolean));u.push({...E,status:"up",sessions:z,cells:Z,unmanaged:z.filter(Q=>!G.has(Q.name)),fleetAvailable:!!(I&&I.available),capabilities:I&&I.capabilities||[],engines:I&&I.engines||[],fleetProvider:I&&I.provider||null,sessionsAvailable:K,inventoryPartial:!K})}for(const b of Array.isArray(t)?t:[]){if(!b||!Array.isArray(b.route)||b.route.length<1||b.route.some(G=>!jg.test(G)))continue;const w=b.route.join("/");if(h.has(w)||b.instanceId&&f.has(b.instanceId))continue;b.instanceId&&f.add(b.instanceId);const k=b.label||b.route.join(" › "),C=b.instanceId&&a&&typeof a[b.instanceId]=="string"?a[b.instanceId]:null,R={name:b.name,label:C||k,originalLabel:k,alias:C,route:[...b.route],direct:!1,instanceId:b.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,lastSeen:b.lastSeen||null};if(b.stale){u.push({...R,status:"offline",downSince:s&&s[w]||b.lastSeen||null});continue}const E=n&&n[w]||null,F=o&&o[w],I=!!(E&&!E.error&&Array.isArray(E.sessions)),K=!!(F&&F.available===!0&&Array.isArray(F.cells));if(!I&&!K){u.push({...R,status:"unreachable",downSince:s&&s[w]||null});continue}const Y=(I?E.sessions:[]).filter(G=>G&&typeof G.name=="string"&&G.name).map(G=>({...G,node:w,route:b.route,key:`${w}:${G.name}`})),z=Rg(F,b.route,w),Z=new Set(z.map(G=>G.tmuxSession).filter(Boolean));u.push({...R,status:"up",sessions:Y,cells:z,unmanaged:Y.filter(G=>!Z.has(G.name)),fleetAvailable:!!(F&&F.available),capabilities:F&&F.capabilities||[],engines:F&&F.engines||[],fleetProvider:F&&F.provider||null,lastSeen:b.lastSeen||null,sessionsAvailable:I,inventoryPartial:!I})}return u.sort((b,w)=>b.label.localeCompare(w.label))}function dy(e,t={}){if(!e||typeof e!="object")return null;const n=typeof e.nodeId=="string"?e.nodeId:"";if(!n)return null;const s=typeof e.label=="string"&&e.label.trim()||typeof e.cell=="string"&&e.cell.trim()||n,o=Array.isArray(t.route)?[...t.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:e.cell??null,paired:!!e.pairedAt,online:!!e.online,lastSeen:e.lastSeen??null,generation:e.generation??null,version:e.version??null,health:e.health??null,session:e.session??null,capabilities:Array.isArray(e.capabilities)?e.capabilities:[],inflight:e.inflight??null,lastAck:e.lastAck??null,canManage:!!e.canManage,route:o,isLocal:o.length===0,ownerInstanceId:typeof t.instanceId=="string"?t.instanceId:null,ownerLabel:typeof t.label=="string"&&t.label?t.label:null}}function hx(e){var n;const t=[];for(const s of Array.isArray(e)?e:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const o=s.online===!0,a=o&&((n=s.session)==null?void 0:n.attached)===!0,u=s.ownerInstanceId||"local";t.push({kind:"vl",name:`vl-${s.nodeId.slice(0,8)}`,label:s.label,route:Array.isArray(s.route)?[...s.route]:[],instanceId:null,direct:!1,status:o?"up":"offline",downSince:o?null:s.lastSeen??null,sessions:a?[{key:`vl:${u}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,peer:s})}return t}function hy(e,t){const n=e&&Array.isArray(e.nodes)?e.nodes:[],s=new Set([t]),o=[];for(const a of n){const u=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!u||s.has(u)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(u);const h=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");o.push({instanceId:u,route:[...a.route],label:h})}return o}const fx=4e3;function nf(e,t=!0,n=0){const[s,o]=N.useState([]),a=N.useRef({});return N.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var I;let m=[],v=[],S={},y="";if(await Promise.all([k0(e).then(K=>{m=Array.isArray(K.nodes)?K.nodes:[]}).catch(()=>{}),iy(e).then(K=>{v=Array.isArray(K.nodes)?K.nodes:[]}).catch(()=>{}),P0(e).then(K=>{S=K&&typeof K.aliasesByInstanceId=="object"?K.aliasesByInstanceId:{}}).catch(()=>{}),Ht("/api/config",e).then(K=>K.json()).then(K=>{y=K&&typeof K.instanceId=="string"?K.instanceId:""}).catch(()=>{})]),!u)return;const b=[{instanceId:y||null,route:[],label:null},...hy({nodes:v},y)],w=[];if(await Promise.all(b.map(async K=>{try{const Y=await ny(e,K.route);for(const z of Y.nodes||[]){const Z=dy(z,K);Z&&w.push(Z)}}catch{}})),!u)return;const k={},C={},R=new Set(m.map(K=>K.name)),E=[];for(const K of m)((I=K.tunnel)==null?void 0:I.status)==="up"&&(K.nodeId||K.paired!==!1)&&(K.direction!=="inbound"||K.shared===!0)&&E.push([K.name]);for(const K of v)!K.stale&&Array.isArray(K.route)&&K.route.length>0&&!(K.route.length===1&&R.has(K.route[0]))&&E.push(K.route);if(await Promise.all(E.map(async K=>{const Y=K.join("/");try{k[Y]=await Jh(e,K)}catch{k[Y]={error:"unreachable"}}try{C[Y]=await ws(e,K)}catch{C[Y]={available:!1}}})),!u)return;const F=Pg({nodes:m,topology:v,remote:k,fleet:C,aliases:S,down:a.current});a.current=dx(a.current,F,Math.floor(Date.now()/1e3)),o([...Pg({nodes:m,topology:v,remote:k,fleet:C,aliases:S,down:a.current}),...hx(w)])}h();const f=setInterval(h,fx);return()=>{u=!1,clearInterval(f)}},[e,t,n]),s}const Lg=52,Ag=14;function bi({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=N.useRef(null),f=N.useRef(0),[m,v]=N.useState(!1),S=()=>{var R,E,F,I;const C=h.current;(E=(R=C==null?void 0:C.over)==null?void 0:R.classList)==null||E.remove("nc-roster-over"),(I=(F=C==null?void 0:C.source)==null?void 0:F.classList)==null||I.remove("nc-roster-dragging"),f.current&&cancelAnimationFrame(f.current),f.current=0},y=(C=!1)=>{const R=h.current;if(!R)return;const E=R.target;S(),h.current=null,v(!1);try{R.handle.releasePointerCapture(R.pointerId)}catch{}C&&E&&E!==t&&a(t,E)&&s(t,E)},b=(C,R)=>{var Z,G,Q,B,M,j,T,L,$;const E=h.current;if(!E)return;E.x=C,E.y=R;const F=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",I=(G=(Z=document.elementFromPoint(C,R))==null?void 0:Z.closest)==null?void 0:G.call(Z,F),K=u==="node"?(Q=I==null?void 0:I.dataset)==null?void 0:Q.nodeOrderKey:(B=I==null?void 0:I.dataset)==null?void 0:B.rosterKey,z=(u==="node"||((M=I==null?void 0:I.dataset)==null?void 0:M.position)===e)&&K&&K!==t&&a(t,K);E.over!==(z?I:null)&&((T=(j=E.over)==null?void 0:j.classList)==null||T.remove("nc-roster-over"),E.over=z?I:null,($=(L=E.over)==null?void 0:L.classList)==null||$.add("nc-roster-over")),E.target=z?K:null},w=()=>{const C=h.current;if(!C){f.current=0;return}const R=C.container;if(R){const E=R.getBoundingClientRect(),F=C.y<E.top+Lg?-Ag:C.y>E.bottom-Lg?Ag:0;F&&(R.scrollTop+=F,b(C.x,C.y))}f.current=requestAnimationFrame(w)};N.useEffect(()=>{const C=E=>{E.key==="Escape"&&h.current&&(E.preventDefault(),y(!1))},R=()=>y(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",R),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",R),S(),h.current=null}},[t,e,u]);const k=C=>{var I;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const R=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",E=C.currentTarget.closest(R),F=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");h.current={pointerId:C.pointerId,handle:C.currentTarget,source:E,container:F,target:null,over:null,x:C.clientX,y:C.clientY},(I=E==null?void 0:E.classList)==null||I.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}v(!0),f.current=requestAnimationFrame(w)};return c.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:p("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:k,onPointerMove:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),b(C.clientX,C.clientY))},onPointerUp:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{h.current&&y(!1)},children:"↕"})}const sf="nc_pins";function px(){try{const e=JSON.parse(localStorage.getItem(sf));return Array.isArray(e)?e:[]}catch{return[]}}function mx(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(sf,JSON.stringify(n))}catch{}return n}function gx(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(sf,JSON.stringify(s))}catch{}return s}function vx(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function _x(e,t){return e[0]-t[0]||e[1]-t[1]}function rf(){const[e,t]=N.useState(px),[n,s]=N.useState(ox),[o,a]=N.useState(ix),u=y=>t(b=>mx(b,y)),h=y=>Eg(n,y),f=(y,b)=>s(w=>{const k={...w,[y]:{...Eg(w,y),...b}};return ax(k)}),m=(y,b)=>e.includes(y)===e.includes(b);function v(y,b,w,k){const C=e.includes(b),R=e.includes(w);if(C===R){if(C){t(E=>gx(E,b,w));return}a(E=>{var K;const F=((K=k.find(Y=>Y.key===b))==null?void 0:K.technical)===!0,I=gs(k,e,F?"technical":"all",Fi(E,y)).map(Y=>Y.key);return sx(rx(E,y,b,w,I))})}}function S(y,b,w,k){var K;const C=((K=k.find(Y=>Y.key===b))==null?void 0:K.technical)===!0,R=e.includes(b),E=gs(k,e,C?"technical":"all",Fi(o,y)).map(Y=>Y.key).filter(Y=>e.includes(Y)===R),F=E.indexOf(b),I=E[F+w];F>=0&&I&&v(y,b,I,k)}return{pins:e,views:n,orders:o,togglePin:u,viewFor:h,updateView:f,canMoveRoster:m,moveRoster:v,stepRoster:S}}const fy="nc_node_order_v1",yx=/^[a-f0-9]{16,64}$/;function qs(e){if(yx.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(n=>typeof n=="string"&&n):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Tg(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(fy));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function wx(e,t=globalThis.localStorage){try{t.setItem(fy,JSON.stringify(e))}catch{}return e}function Dg(e=[],t=[]){const n=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=n.has(qs(s.group))?n.get(qs(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(qs(o.group))?n.get(qs(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function bx(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(qs).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(m=>o.includes(m)),...o.filter(m=>!e.includes(m))],u=a.indexOf(t),h=a.indexOf(n);a.splice(u,1);const f=a.indexOf(n);return a.splice(u<h?f+1:f,0,t),a}const qd="nexuscrew-node-preferences";function Sx(){try{window.dispatchEvent(new Event(qd))}catch{}}function py(){const[e,t]=N.useState(Tg);N.useEffect(()=>{const a=()=>t(Tg());return window.addEventListener("storage",a),window.addEventListener(qd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(qd,a)}},[]);const n=a=>Dg(a,e),s=(a,u,h)=>t(f=>{const m=bx(f,a,u,h);return wx(m),Sx(),m});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,h)=>{const f=Dg(h,e).map(qs),m=f.indexOf(a),v=f[m+u];m>=0&&v&&s(a,v,h)},nodeKey:qs}}function Dr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Bi(e){return e.status==="passive"?p("node-passive"):e.status==="down"?e.downSince?p("tunnel-down-since").replace("{t}",Dr(e.downSince)):p("tunnel-down"):e.status==="unreachable"?p("node-unreachable"):e.status==="offline"?e.lastSeen?p("node-offline-seen").replace("{t}",Dr(e.lastSeen)):p("node-offline"):e.status==="needs-repair"?p("node-needs-repair"):""}function my(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function qo(e){return e&&(e.detail||e.status)||""}function zl(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(X_(t))||0);return e.outbox.latest>s}function of(e,t={}){const n=e||{};if(!n.tmux){const s=`${n.engine||""}${n.key?`·${n.key}`:""}`,o=[s,n.model&&n.model!==s?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||p("cell-off")).trim()}}if(t.working===!0){const s=p("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:p("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||p("cell-on")).trim()}}function gy(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function af(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=Go([],o.tmuxSession),h=of(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:zl(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:gy(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Go([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:zl(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Fl(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},f=Go(s,u.tmuxSession||u.cell),m=of(u,h);return{type:"cell",value:u,key:f,label:u.cell,live:!!u.tmux,fresh:zl(h,f,t),activity:h.activity||u.activity||0,working:m.working,subtitle:m.subtitle,searchText:gy(u,h)}}),...(n.unmanaged||[]).map(u=>{const h=Go(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:zl(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const lf=9,$l=.2,xx=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Mr=/^[a-f0-9]{16,64}$/,Vd=e=>xx.test(e)&&new Set(e.split("/")).size===e.split("/").length;function ys(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!Vd(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Mr.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&Vd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function $n(e){const t=ys(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const vy=9,_y=24,ta=11,kx=e=>{const t=Number(e);return t>=vy&&t<=_y?t:ta};function Lr(){return{columns:[]}}function ki(e){return e.columns.flatMap(t=>t.tiles.map(n=>$n(n)))}function Cx(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push($n(o.tiles[s]));return t}const Fr=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function cf(e,t,n,s){const o=ys(t);if(!o||ki(e).includes($n(o))||ki(e).length>=lf)return e;const a=Fr(e),u={session:o.session,height:1,fontSize:ta,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const h=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function yy(e,t){const n=$n(t);if(!n||ki(e).includes(n)||ki(e).length>=lf)return e;const s=ki(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let v=0;for(let S=1;S<e.columns.length;S+=1)e.columns[S].tiles.length<e.columns[v].tiles.length&&(v=S);return cf(e,t,{col:v,row:e.columns[v].tiles.length})}const a=[...Cx(e),n],u=new Map(e.columns.flatMap(v=>v.tiles.map(S=>[$n(S),S]))),h=ys(t),f=e.columns.length?e.columns.reduce((v,S)=>v+(Number(S.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(v,S)=>{var y;return{width:((y=e.columns[S])==null?void 0:y.width)||f,tiles:[]}});return a.forEach((v,S)=>{const y=ys(v);if(!y)return;const b=u.get(v)||(v===n?h:{})||{},w={session:y.session,height:b.height||1,fontSize:b.fontSize||ta};y.node&&(w.node=y.node),b.ownerId&&(w.ownerId=b.ownerId),b.unavailable===!0&&(w.unavailable=!0),m[S%o].tiles.push(w)}),{columns:m.filter(v=>v.tiles.length)}}function Hl(e,t){const n=$n(t),s=Fr(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>$n(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function Ex(e,t,n){const s=$n(t);if(!ki(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>$n(a)===s);return cf(Hl(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function Nx(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Fr(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get($n(a));if(!u)continue;const h=ys(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),n=!0)}return n?Ys(s):e}function jx(e,t,n){const s=Fr(e);return s.columns[t]&&(s.columns[t].width=Math.max($l,Number(n)||1)),s}function Rx(e,t,n,s){const o=Fr(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max($l,Number(s)||1)),o}function Px(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=Fr(e),u=a.columns[t].tiles[n],h=Number(u.fontSize)||ta;return u.fontSize=Math.max(vy,Math.min(_y,h+(Number(s)||0))),a}function Lx(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function Mg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Ys(e){if(!e||!Array.isArray(e.columns))return Lr();const t=e.columns.map(s=>({width:Math.max($l,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&Vd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Mr.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max($l,Number(o.height)||1),fontSize:kx(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has($n(o))&&n.add($n(o))&&n.size<=lf);return{columns:t.filter(s=>s.tiles.length>0)}}const wy=/^[a-z0-9-]{1,32}$/,Ax=/^[A-Za-z0-9._-]{1,32}$/,Tx=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,Dx=320;function Yd(e){return typeof e=="string"&&wy.test(e)}const Mx=64;function Ir(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=Mx&&!/[\x00-\x1f\x7f]/.test(t)}function vs(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function by(e){if(typeof e!="string"||!e||e.length>Dx||e.startsWith("-")||/[\0-\x20\x7f]/.test(e))return!1;if(!e.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(e);const t=e.indexOf("@");return t<=0||t!==e.lastIndexOf("@")?!1:Ax.test(e.slice(0,t))&&Tx.test(e.slice(t+1))}function Ig(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function Ix({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!Yd(o))return{ok:!1,error:"err-node-name"};if(!by(a))return{ok:!1,error:"err-ssh"};const u=Ig(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=Ig(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const f={name:o,ssh:a};return u!==null&&(f.sshPort=u),h!==null&&(f.remotePort=h),{ok:!0,value:f}}function Ox(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Gd(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?Ox(e.since,t):null}}const Bx=new Set(["v","instanceId","port","label","invite"]),zx=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Fx(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function $x(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let n;try{n=JSON.parse(Fx(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?Bx:n.v===2?zx:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!wy.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!by(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function Hx(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||n.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?vs(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const Ux=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],Wx=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function uf(e){const t=e&&typeof e=="object"?e.actionRequired:null;return!t||typeof t!="object"||!Ux.includes(t.code)||!Wx.includes(t.recovery)?null:{code:t.code,recovery:t.recovery,text:p(`fleet-recovery-${t.recovery}`)}}let Xd={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function Og(){return Xd}function Sy(e={}){return Xd={sessions:Array.isArray(e.sessions)?e.sessions:[],cells:Array.isArray(e.cells)?e.cells:[],nodeGroups:Array.isArray(e.nodeGroups)?e.nodeGroups:[],localNodeId:typeof e.localNodeId=="string"?e.localNodeId:"",localFresh:e.localFresh===!0,refreshedAt:Number.isFinite(e.refreshedAt)?e.refreshedAt:0},Xd}const kr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function Kx({onPick:e,token:t,onSettings:n,onOpenVlSession:s}){const[o,a]=kn(),u=nf(t),[h,f]=N.useState(null),[m,v]=N.useState(null),[S,y]=N.useState(""),[b,w]=N.useState(""),[k,C]=N.useState({bind:"127.0.0.1",port:""}),[R,E]=N.useState(""),[F,I]=N.useState([]),[K,Y]=N.useState([]),[z,Z]=N.useState({}),[G,Q]=N.useState(new Set),[B,M]=N.useState(null),[j,T]=N.useState(null),{pins:L,orders:$,togglePin:H,viewFor:x,updateView:O,canMoveRoster:D,moveRoster:A,stepRoster:W}=rf(),{groupsFor:X,moveNode:ie,stepNode:ue,nodeKey:fe}=py(),we=X(u);N.useEffect(()=>{Sy({sessions:h||[],cells:F,nodeGroups:u,localNodeId:R})},[h,F,u,R]),N.useEffect(()=>{const U=new Map;for(const ce of F)U.set(kr(ce.cell),!!ce.boot);for(const ce of u){const de=ce.route||[ce.name];for(const ge of ce.cells||[])U.set(kr(ge.cell,de),!!ge.boot)}Z(ce=>{let de=!1;const ge={...ce};for(const[De,_e]of Object.entries(ce))U.has(De)&&U.get(De)===_e&&(delete ge[De],de=!0);return de?ge:ce})},[F,u]);async function me(){try{const ce=await(await Ht("/api/sessions",t)).json();ce.error?(v(ce.error),f([])):(v(null),f(ce.sessions||[]))}catch(U){v(String(U)),f([])}try{const U=await ws(t);I(U.available?U.cells||[]:[]),Y(U.available?U.capabilities||[]:[])}catch{I([]),Y([])}}N.useEffect(()=>{me(),Ht("/api/config",t).then(ce=>ce.json()).then(ce=>{w(ce.version||""),C({bind:ce.bind||"127.0.0.1",port:ce.port||""}),E(Mr.test(String(ce.instanceId||""))?ce.instanceId:"")}).catch(()=>{});const U=setInterval(me,4e3);return()=>clearInterval(U)},[]);async function xe(){if(!k.port)return;const U=`http://${k.bind}:${k.port}/#token=${t}`;try{await navigator.clipboard.writeText(U)}catch{}}function $e(U,ce,de){const ge=kr(U,ce);Z(De=>({...De,[ge]:!!de}))}function ft(U,ce=[]){const de=kr(U.cell,ce);return Object.prototype.hasOwnProperty.call(z,de)?z[de]:!!U.boot}async function qe(U,ce,de=[]){U.stopPropagation();const ge=kr(ce.cell,de),De=!ft(ce,de);$e(ce.cell,de,De),Q(_e=>new Set(_e).add(ge));try{await Q_(t,{cell:ce.cell,enabled:De},de),de.length||I(_e=>_e.map(Ee=>Ee.cell===ce.cell?{...Ee,boot:De}:Ee))}catch(_e){Z(Ee=>{const nt={...Ee};return delete nt[ge],nt}),v(String((_e==null?void 0:_e.message)||_e))}finally{Q(_e=>{const Ee=new Set(_e);return Ee.delete(ge),Ee})}}async function Ae(U){if(!B)return;const{cell:ce}=B,de=Array.isArray(B.route)?B.route:[];if(U.action==="up"){const ge=await Gh(t,{cell:ce,boot:!!U.boot,...U.engine?{engine:U.engine}:{},...U.model!==void 0?{model:U.model}:{},...U.permissionPolicy?{permissionPolicy:U.permissionPolicy}:{}},de),De=uf(ge);De&&v(De.text),$e(ce,de,!!U.boot)}else await Il(t,{cell:ce,boot:!!U.boot},de),U.boot&&$e(ce,de,!1);me()}async function Rt(U,ce=[]){try{await Xh(t,U,ce)}catch{return}me()}async function Jt(U,ce,de=[]){try{await ey(t,U,ce,de)}catch{return}me()}async function Oe(U){if(!(!(U!=null&&U.direct)||j)){T(U.name);try{await ef(t,U.name,U.tunnelStatus==="up"?"down":"up")}catch{}T(null)}}async function Pt(U){if(!(U!=null&&U.direct))return;const ce=window.prompt(p("rename-node-prompt"),U.label||U.name);if(ce===null)return;const de=String(ce).trim();if(!Ir(de)){window.alert(p("rename-node-invalid"));return}try{await sy(t,U.name,de)}catch(ge){window.alert(String((ge==null?void 0:ge.message)||ge))}}const bt=N.useMemo(()=>new Map((h||[]).map(U=>[U.name,U])),[h]),dt=N.useMemo(()=>new Set(F.map(U=>U.tmuxSession)),[F]),ht=N.useMemo(()=>(h||[]).filter(U=>!dt.has(U.name)),[h,dt]),Qe=N.useMemo(()=>af(F,ht,bt),[F,ht,bt]),ot=x("local"),oe=N.useMemo(()=>gs(Qe,L,ot.filter,Fi($,"local")).filter(U=>Ng(U,S)),[Qe,L,ot.filter,S,$]),ke=we.reduce((U,ce)=>U+(ce.cells||[]).length+(ce.unmanaged||[]).filter(de=>!de.technical).length,0),Te=gs(Qe,L,"all",Fi($,"local")).length+ke,ae=Qe.filter(U=>U.live).length+we.reduce((U,ce)=>U+Fl(ce).rawItems.filter(de=>de.live).length,0),re=(h||[]).filter(U=>U.attached).length+we.reduce((U,ce)=>U+(ce.sessions||[]).filter(de=>de.attached).length,0),Pe=Math.min(re,ae),q=k.port?`${k.bind}:${k.port}`:k.bind;function te(U,ce=null,de=Qe){var Mt,ct;const ge=Array.isArray(ce==null?void 0:ce.route)?ce.route:[],De=ge.join("/"),_e=De||"local",Ee=ge.length?ce==null?void 0:ce.instanceId:R,nt=(et,Zt)=>e({session:et,...De?{node:De}:{},...Mr.test(String(Ee||""))?{ownerId:Ee}:{},...typeof Zt=="string"&&Zt?{cellName:Zt}:{}}),at=D;if(U.type==="cell"){const et=U.value,Zt=ge.length?((ce==null?void 0:ce.sessions)||[]).find(pt=>pt.name===et.tmuxSession):bt.get(et.tmuxSession),ni=et.degraded?p("cell-degraded"):U.working?U.subtitle:et.tmux?p("cell-idle"):p("cell-off"),Wn=ge.length===0||((ce==null?void 0:ce.capabilities)||[]).includes(et.active?"down":"up"),ui=ge.length===0?K.includes("boot"):((ce==null?void 0:ce.capabilities)||[]).includes("boot"),he=ft(et,ge),je=kr(et.cell,ge),Ke=`${p(he?"boot-disable":"boot-enable")} ${et.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":U.key,"data-position":_e,children:[c.jsx(bi,{position:_e,itemKey:U.key,label:et.cell,canMove:at,onMove:(pt,vt)=>A(_e,pt,vt,de),onStep:pt=>W(_e,U.key,pt,de)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>et.tmux&&nt(et.tmuxSession,et.cell),title:ni,"aria-label":`${et.cell}, ${ni}`,children:[c.jsx("span",{className:`dot ${et.degraded?"warn":et.tmux?`on${U.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:et.cell}),c.jsx("small",{title:U.subtitle,children:U.subtitle})]})]}),U.activity?c.jsx("span",{className:"nc-rel",children:Dr(U.activity)}):null,U.fresh&&((Mt=Zt==null?void 0:Zt.outbox)==null?void 0:Mt.count)>0&&c.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Zt.outbox.count}),c.jsx("button",{className:`nc-act pin${L.includes(U.key)?" on":""}`,"aria-label":`${p("pin")} ${et.cell}`,title:p("pin"),onClick:()=>H(U.key),children:L.includes(U.key)?"★":"☆"}),ui&&c.jsx("button",{className:`nc-act boot${he?" on":""}`,disabled:G.has(je),onClick:pt=>qe(pt,et,ge),title:Ke,"aria-label":Ke,children:c.jsx(Ze,{name:"boot",size:16})}),Wn&&c.jsx("button",{className:`nc-act power${et.tmux?" on":""}${et.degraded?" warn":""}`,onClick:()=>M(ge.length?{...et,boot:he,route:ge,availableEngines:(ce==null?void 0:ce.engines)||[]}:{...et,boot:he}),title:et.active?p("power-off"):p("power-on"),"aria-label":`${et.active?p("power-off"):p("power-on")} ${et.cell}`,children:c.jsx(Ze,{name:"power",size:16})})]},U.key)}const Je=U.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":U.key,"data-position":_e,children:[c.jsx(bi,{position:_e,itemKey:U.key,label:Je.name,canMove:at,onMove:(et,Zt)=>A(_e,et,Zt,de),onStep:et=>W(_e,U.key,et,de)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>nt(Je.name),children:[c.jsx("span",{className:Je.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Je.name}),c.jsx("small",{children:Je.preview?Je.preview:Je.cmd?Je.cmd:p("windows").replace("{n}",String(Je.windows||0))})]})]}),U.activity?c.jsx("span",{className:"nc-rel",children:Dr(U.activity)}):null,U.fresh&&((ct=Je.outbox)==null?void 0:ct.count)>0&&c.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Je.outbox.count}),c.jsx("button",{className:`nc-act pin${L.includes(U.key)?" on":""}`,"aria-label":`${p("pin")} ${Je.name}`,title:p("pin"),onClick:()=>H(U.key),children:L.includes(U.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${Je.technical?" on":""}`,title:Je.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${Je.technical?p("mark-normal"):p("mark-technical")} ${Je.name}`,onClick:()=>Jt(Je.name,!Je.technical,ge),children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),"aria-label":`${p("terminate")} ${Je.name}`,onClick:()=>{window.confirm(p("terminate-confirm").replace("{name}",Je.name))&&Rt(Je.name,ge)},children:"⋯"})]},U.key)}return c.jsxs("div",{className:"nc-home",children:[c.jsxs("header",{className:"nc-home-head",children:[c.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",c.jsx("span",{className:"nc-cursor"})]}),c.jsxs("div",{className:"nc-home-sub",children:[p("fleet-tmux")," · ",ae," ",p("sessions"),Pe>0&&` · ${Pe} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:p("settings"),children:c.jsx(Ze,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:me,title:p("refresh"),children:c.jsx(Ze,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[Te>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:p("filter-placeholder"),"aria-label":p("filter-placeholder"),value:S,onChange:U=>y(U.target.value)}),m&&c.jsx("div",{className:"nc-err",children:m}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(Xu,{label:p("position-local"),count:oe.length,state:ot,dotClass:"on",onToggle:()=>O("local",{open:!ot.open}),onFilter:U=>O("local",{filter:U})}),ot.open&&oe.map(U=>te(U,null,Qe)),ot.open&&h===null&&c.jsx("div",{className:"nc-empty",children:p("loading-fleet")}),ot.open&&h!==null&&oe.length===0&&!m&&c.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]}),we.map(U=>{const de=my(U.health,{passive:"warn"})||(U.status==="up"?"on":U.status==="passive"?"":"warn"),ge=U.health?qo(U.health):U.status==="up"?"":Bi(U),_e=(U.route&&U.route.length?U.route:[U.name]).join("/"),Ee=x(_e);if(U.kind==="vl")return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":_e,"data-node-order-key":fe(U),children:[c.jsx(Xu,{label:U.label||U.name,count:U.sessions.length,state:Ee,dotClass:de,dotTitle:ge,detail:U.status==="up"?"":Bi(U),onToggle:()=>O(_e,{open:!Ee.open}),onFilter:ct=>O(_e,{filter:ct})}),U.status==="up"&&Ee.open&&U.sessions.map(ct=>c.jsx("div",{className:"nc-mcard nc-vl-session-row",children:c.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(U.peer),"aria-label":`${U.label||U.name}: ${ct.name}`,children:[c.jsx("span",{className:"dot on"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:ct.name}),c.jsx("small",{children:p("vl-events-title")})]})]})},ct.key)),U.status==="up"&&Ee.open&&U.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]},`nodo-vl-${_e}-${U.name}`);const{rawItems:nt}=Fl(U),at=gs(nt,L,Ee.filter,Fi($,_e)).filter(ct=>Ng(ct,S)),Je=U.direct&&U.health&&U.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${U.tunnelStatus==="up"?" on":""}`,disabled:j===U.name,title:U.tunnelStatus==="up"?p("power-off"):p("power-on"),"aria-label":`${U.tunnelStatus==="up"?p("power-off"):p("power-on")} ${U.label||U.name}`,onClick:()=>Oe(U),children:c.jsx(Ze,{name:"power",size:15})}):null,Mt=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:fe(U),label:U.label||U.name,onMove:(ct,et)=>ie(ct,et,u),onStep:ct=>ue(fe(U),ct,u)}),U.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${U.label||U.name}`,onClick:()=>Pt(U),children:"✎"}),Je]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":_e,"data-node-order-key":fe(U),children:[c.jsx(Xu,{label:U.label||U.name,count:at.length,state:Ee,dotClass:de,dotTitle:ge,detail:U.status==="up"?"":U.health&&qo(U.health)||Bi(U),onToggle:()=>O(_e,{open:!Ee.open}),onFilter:ct=>O(_e,{filter:ct}),onRename:U.direct?()=>Pt(U):null,action:Mt}),U.status==="up"&&Ee.open&&at.map(ct=>te(ct,U,nt)),U.status==="up"&&Ee.open&&at.length===0&&c.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]},`nodo-${_e}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:xe,title:p("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[b&&c.jsxs("span",{className:"nc-home-version",children:["v",b]}),c.jsxs("span",{className:"nc-home-endpoint",children:[q," · ",p("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:U=>U.stopPropagation(),children:uy.map((U,ce)=>c.jsxs("span",{children:[ce>0&&" · ",c.jsx("button",{className:`nc-lang-btn${o===U?" on":""}`,onClick:()=>a(U),title:U,children:U.toUpperCase()})]},U))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:p("fleet-new-cell"),"aria-label":p("fleet-new-cell"),children:"+"}),B&&c.jsx(Bl,{cell:B,token:t,route:Array.isArray(B.route)?B.route:[],onConfirm:Ae,onClose:()=>M(null)})]})}function Xu({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:f=null,action:m=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:f?v=>{v.preventDefault(),f()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${p("node-sessions").replace("{n}",String(t))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),c.jsx("span",{className:`dot ${s}`,title:o}),c.jsxs("span",{className:"nc-mobile-position-copy",children:[c.jsx("b",{children:e}),c.jsx("small",{children:a||p("node-sessions").replace("{n}",String(t))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${p("filter-placeholder")}`,title:p(`view-${n.filter}`),onChange:v=>h(v.target.value),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]}),m]})}/**
40
+ `+_.stack}return{value:i,source:r,stack:g,digest:null}}function mu(i,r,l){return{value:i,source:null,stack:l??null,digest:r??null}}function gu(i,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var AS=typeof WeakMap=="function"?WeakMap:Map;function ym(i,r,l){l=Ti(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){Za||(Za=!0,Lu=d),gu(i,r)},l}function wm(i,r,l){l=Ti(-1,l),l.tag=3;var d=i.type.getDerivedStateFromError;if(typeof d=="function"){var g=r.value;l.payload=function(){return d(g)},l.callback=function(){gu(i,r)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(l.callback=function(){gu(i,r),typeof d!="function"&&(is===null?is=new Set([this]):is.add(this));var P=r.stack;this.componentDidCatch(r.value,{componentStack:P!==null?P:""})}),l}function bm(i,r,l){var d=i.pingCache;if(d===null){d=i.pingCache=new AS;var g=new Set;d.set(r,g)}else g=d.get(r),g===void 0&&(g=new Set,d.set(r,g));g.has(l)||(g.add(l),i=qS.bind(null,i,r,l),r.then(i,i))}function Sm(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function xm(i,r,l,d,g){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=Ti(-1,1),r.tag=2,ts(l,r,1))),l.lanes|=1),i):(i.flags|=65536,i.lanes=g,i)}var TS=I.ReactCurrentOwner,Pn=!1;function bn(i,r,l,d){r.child=i===null?Up(r,null,l,d):mr(r,i.child,l,d)}function km(i,r,l,d,g){l=l.render;var _=r.ref;return vr(r,g),d=au(i,r,l,d,_,g),l=lu(),i!==null&&!Pn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Di(i,r,g)):(Nt&&l&&Wc(r),r.flags|=1,bn(i,r,d,g),r.child)}function Cm(i,r,l,d,g){if(i===null){var _=l.type;return typeof _=="function"&&!Bu(_)&&_.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=_,Em(i,r,_,d,g)):(i=rl(l.type,null,d,r,r.mode,g),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,(i.lanes&g)===0){var P=_.memoizedProps;if(l=l.compare,l=l!==null?l:lo,l(P,d)&&i.ref===r.ref)return Di(i,r,g)}return r.flags|=1,i=as(_,d),i.ref=r.ref,i.return=r,r.child=i}function Em(i,r,l,d,g){if(i!==null){var _=i.memoizedProps;if(lo(_,d)&&i.ref===r.ref)if(Pn=!1,r.pendingProps=d=_,(i.lanes&g)!==0)(i.flags&131072)!==0&&(Pn=!0);else return r.lanes=i.lanes,Di(i,r,g)}return vu(i,r,l,d,g)}function Nm(i,r,l){var d=r.pendingProps,g=d.children,_=i!==null?i.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},yt(br,Bn),Bn|=l;else{if((l&1073741824)===0)return i=_!==null?_.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,yt(br,Bn),Bn|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=_!==null?_.baseLanes:l,yt(br,Bn),Bn|=d}else _!==null?(d=_.baseLanes|l,r.memoizedState=null):d=l,yt(br,Bn),Bn|=d;return bn(i,r,g,l),r.child}function jm(i,r){var l=r.ref;(i===null&&l!==null||i!==null&&i.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function vu(i,r,l,d,g){var _=Rn(l)?Rs:gn.current;return _=dr(r,_),vr(r,g),l=au(i,r,l,d,_,g),d=lu(),i!==null&&!Pn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,Di(i,r,g)):(Nt&&d&&Wc(r),r.flags|=1,bn(i,r,l,g),r.child)}function Rm(i,r,l,d,g){if(Rn(l)){var _=!0;Pa(r)}else _=!1;if(vr(r,g),r.stateNode===null)Ya(i,r),vm(r,l,d),pu(r,l,d,g),d=!0;else if(i===null){var P=r.stateNode,V=r.memoizedProps;P.props=V;var J=P.context,le=l.contextType;typeof le=="object"&&le!==null?le=Yn(le):(le=Rn(l)?Rs:gn.current,le=dr(r,le));var be=l.getDerivedStateFromProps,Se=typeof be=="function"||typeof P.getSnapshotBeforeUpdate=="function";Se||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==d||J!==le)&&_m(r,P,d,le),es=!1;var ye=r.memoizedState;P.state=ye,za(r,d,P,g),J=r.memoizedState,V!==d||ye!==J||jn.current||es?(typeof be=="function"&&(fu(r,l,be,d),J=r.memoizedState),(V=es||gm(r,l,V,d,ye,J,le))?(Se||typeof P.UNSAFE_componentWillMount!="function"&&typeof P.componentWillMount!="function"||(typeof P.componentWillMount=="function"&&P.componentWillMount(),typeof P.UNSAFE_componentWillMount=="function"&&P.UNSAFE_componentWillMount()),typeof P.componentDidMount=="function"&&(r.flags|=4194308)):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=J),P.props=d,P.state=J,P.context=le,d=V):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{P=r.stateNode,Kp(i,r),V=r.memoizedProps,le=r.type===r.elementType?V:ri(r.type,V),P.props=le,Se=r.pendingProps,ye=P.context,J=l.contextType,typeof J=="object"&&J!==null?J=Yn(J):(J=Rn(l)?Rs:gn.current,J=dr(r,J));var Le=l.getDerivedStateFromProps;(be=typeof Le=="function"||typeof P.getSnapshotBeforeUpdate=="function")||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==Se||ye!==J)&&_m(r,P,d,J),es=!1,ye=r.memoizedState,P.state=ye,za(r,d,P,g);var Be=r.memoizedState;V!==Se||ye!==Be||jn.current||es?(typeof Le=="function"&&(fu(r,l,Le,d),Be=r.memoizedState),(le=es||gm(r,l,le,d,ye,Be,J)||!1)?(be||typeof P.UNSAFE_componentWillUpdate!="function"&&typeof P.componentWillUpdate!="function"||(typeof P.componentWillUpdate=="function"&&P.componentWillUpdate(d,Be,J),typeof P.UNSAFE_componentWillUpdate=="function"&&P.UNSAFE_componentWillUpdate(d,Be,J)),typeof P.componentDidUpdate=="function"&&(r.flags|=4),typeof P.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=Be),P.props=d,P.state=Be,P.context=J,d=le):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&ye===i.memoizedState||(r.flags|=1024),d=!1)}return _u(i,r,l,d,_,g)}function _u(i,r,l,d,g,_){jm(i,r);var P=(r.flags&128)!==0;if(!d&&!P)return g&&Dp(r,l,!1),Di(i,r,_);d=r.stateNode,TS.current=r;var V=P&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,i!==null&&P?(r.child=mr(r,i.child,null,_),r.child=mr(r,null,V,_)):bn(i,r,V,_),r.memoizedState=d.state,g&&Dp(r,l,!0),r.child}function Pm(i){var r=i.stateNode;r.pendingContext?Ap(i,r.pendingContext,r.pendingContext!==r.context):r.context&&Ap(i,r.context,!1),tu(i,r.containerInfo)}function Lm(i,r,l,d,g){return pr(),Yc(g),r.flags|=256,bn(i,r,l,d),r.child}var yu={dehydrated:null,treeContext:null,retryLane:0};function wu(i){return{baseLanes:i,cachePool:null,transitions:null}}function Am(i,r,l){var d=r.pendingProps,g=Lt.current,_=!1,P=(r.flags&128)!==0,V;if((V=P)||(V=i!==null&&i.memoizedState===null?!1:(g&2)!==0),V?(_=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(g|=1),yt(Lt,g&1),i===null)return Vc(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(P=d.children,i=d.fallback,_?(d=r.mode,_=r.child,P={mode:"hidden",children:P},(d&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=P):_=ol(P,d,0,null),i=zs(i,d,l,null),_.return=r,i.return=r,_.sibling=i,r.child=_,r.child.memoizedState=wu(l),r.memoizedState=yu,i):bu(r,P));if(g=i.memoizedState,g!==null&&(V=g.dehydrated,V!==null))return DS(i,r,P,d,V,g,l);if(_){_=d.fallback,P=r.mode,g=i.child,V=g.sibling;var J={mode:"hidden",children:d.children};return(P&1)===0&&r.child!==g?(d=r.child,d.childLanes=0,d.pendingProps=J,r.deletions=null):(d=as(g,J),d.subtreeFlags=g.subtreeFlags&14680064),V!==null?_=as(V,_):(_=zs(_,P,l,null),_.flags|=2),_.return=r,d.return=r,d.sibling=_,r.child=d,d=_,_=r.child,P=i.child.memoizedState,P=P===null?wu(l):{baseLanes:P.baseLanes|l,cachePool:null,transitions:P.transitions},_.memoizedState=P,_.childLanes=i.childLanes&~l,r.memoizedState=yu,d}return _=i.child,i=_.sibling,d=as(_,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,i!==null&&(l=r.deletions,l===null?(r.deletions=[i],r.flags|=16):l.push(i)),r.child=d,r.memoizedState=null,d}function bu(i,r){return r=ol({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Va(i,r,l,d){return d!==null&&Yc(d),mr(r,i.child,null,l),i=bu(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function DS(i,r,l,d,g,_,P){if(l)return r.flags&256?(r.flags&=-257,d=mu(Error(n(422))),Va(i,r,P,d)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(_=d.fallback,g=r.mode,d=ol({mode:"visible",children:d.children},g,0,null),_=zs(_,g,P,null),_.flags|=2,d.return=r,_.return=r,d.sibling=_,r.child=d,(r.mode&1)!==0&&mr(r,i.child,null,P),r.child.memoizedState=wu(P),r.memoizedState=yu,_);if((r.mode&1)===0)return Va(i,r,P,null);if(g.data==="$!"){if(d=g.nextSibling&&g.nextSibling.dataset,d)var V=d.dgst;return d=V,_=Error(n(419)),d=mu(_,d,void 0),Va(i,r,P,d)}if(V=(P&i.childLanes)!==0,Pn||V){if(d=nn,d!==null){switch(P&-P){case 4:g=2;break;case 16:g=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(d.suspendedLanes|P))!==0?0:g,g!==0&&g!==_.retryLane&&(_.retryLane=g,Ai(i,g),li(d,i,g,-1))}return Ou(),d=mu(Error(n(421))),Va(i,r,P,d)}return g.data==="$?"?(r.flags|=128,r.child=i.child,r=VS.bind(null,i),g._reactRetry=r,null):(i=_.treeContext,On=Xi(g.nextSibling),In=r,Nt=!0,si=null,i!==null&&(qn[Vn++]=Pi,qn[Vn++]=Li,qn[Vn++]=Ps,Pi=i.id,Li=i.overflow,Ps=r),r=bu(r,d.children),r.flags|=4096,r)}function Tm(i,r,l){i.lanes|=r;var d=i.alternate;d!==null&&(d.lanes|=r),Jc(i.return,r,l)}function Su(i,r,l,d,g){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:g}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=d,_.tail=l,_.tailMode=g)}function Dm(i,r,l){var d=r.pendingProps,g=d.revealOrder,_=d.tail;if(bn(i,r,d.children,l),d=Lt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Tm(i,l,r);else if(i.tag===19)Tm(i,l,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}d&=1}if(yt(Lt,d),(r.mode&1)===0)r.memoizedState=null;else switch(g){case"forwards":for(l=r.child,g=null;l!==null;)i=l.alternate,i!==null&&Fa(i)===null&&(g=l),l=l.sibling;l=g,l===null?(g=r.child,r.child=null):(g=l.sibling,l.sibling=null),Su(r,!1,g,l,_);break;case"backwards":for(l=null,g=r.child,r.child=null;g!==null;){if(i=g.alternate,i!==null&&Fa(i)===null){r.child=g;break}i=g.sibling,g.sibling=l,l=g,g=i}Su(r,!0,l,null,_);break;case"together":Su(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ya(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function Di(i,r,l){if(i!==null&&(r.dependencies=i.dependencies),Ms|=r.lanes,(l&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,l=as(i,i.pendingProps),r.child=l,l.return=r;i.sibling!==null;)i=i.sibling,l=l.sibling=as(i,i.pendingProps),l.return=r;l.sibling=null}return r.child}function MS(i,r,l){switch(r.tag){case 3:Pm(r),pr();break;case 5:Yp(r);break;case 1:Rn(r.type)&&Pa(r);break;case 4:tu(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,g=r.memoizedProps.value;yt(Ia,d._currentValue),d._currentValue=g;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(yt(Lt,Lt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Am(i,r,l):(yt(Lt,Lt.current&1),i=Di(i,r,l),i!==null?i.sibling:null);yt(Lt,Lt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(i.flags&128)!==0){if(d)return Dm(i,r,l);r.flags|=128}if(g=r.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),yt(Lt,Lt.current),d)break;return null;case 22:case 23:return r.lanes=0,Nm(i,r,l)}return Di(i,r,l)}var Mm,xu,Im,Om;Mm=function(i,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)i.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},xu=function(){},Im=function(i,r,l,d){var g=i.memoizedProps;if(g!==d){i=r.stateNode,Ts(fi.current);var _=null;switch(l){case"input":g=Rt(i,g),d=Rt(i,d),_=[];break;case"select":g=D({},g,{value:void 0}),d=D({},d,{value:void 0}),_=[];break;case"textarea":g=ot(i,g),d=ot(i,d),_=[];break;default:typeof g.onClick!="function"&&typeof d.onClick=="function"&&(i.onclick=Na)}_e(l,d);var P;l=null;for(le in g)if(!d.hasOwnProperty(le)&&g.hasOwnProperty(le)&&g[le]!=null)if(le==="style"){var V=g[le];for(P in V)V.hasOwnProperty(P)&&(l||(l={}),l[P]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(o.hasOwnProperty(le)?_||(_=[]):(_=_||[]).push(le,null));for(le in d){var J=d[le];if(V=g!=null?g[le]:void 0,d.hasOwnProperty(le)&&J!==V&&(J!=null||V!=null))if(le==="style")if(V){for(P in V)!V.hasOwnProperty(P)||J&&J.hasOwnProperty(P)||(l||(l={}),l[P]="");for(P in J)J.hasOwnProperty(P)&&V[P]!==J[P]&&(l||(l={}),l[P]=J[P])}else l||(_||(_=[]),_.push(le,l)),l=J;else le==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,V=V?V.__html:void 0,J!=null&&V!==J&&(_=_||[]).push(le,J)):le==="children"?typeof J!="string"&&typeof J!="number"||(_=_||[]).push(le,""+J):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(o.hasOwnProperty(le)?(J!=null&&le==="onScroll"&&xt("scroll",i),_||V===J||(_=[])):(_=_||[]).push(le,J))}l&&(_=_||[]).push("style",l);var le=_;(r.updateQueue=le)&&(r.flags|=4)}},Om=function(i,r,l,d){l!==d&&(r.flags|=4)};function ko(i,r){if(!Nt)switch(i.tailMode){case"hidden":r=i.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?i.tail=null:l.sibling=null;break;case"collapsed":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function _n(i){var r=i.alternate!==null&&i.alternate.child===i.child,l=0,d=0;if(r)for(var g=i.child;g!==null;)l|=g.lanes|g.childLanes,d|=g.subtreeFlags&14680064,d|=g.flags&14680064,g.return=i,g=g.sibling;else for(g=i.child;g!==null;)l|=g.lanes|g.childLanes,d|=g.subtreeFlags,d|=g.flags,g.return=i,g=g.sibling;return i.subtreeFlags|=d,i.childLanes=l,r}function IS(i,r,l){var d=r.pendingProps;switch(Kc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _n(r),null;case 1:return Rn(r.type)&&Ra(),_n(r),null;case 3:return d=r.stateNode,_r(),kt(jn),kt(gn),su(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(Da(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,si!==null&&(Du(si),si=null))),xu(i,r),_n(r),null;case 5:nu(r);var g=Ts(yo.current);if(l=r.type,i!==null&&r.stateNode!=null)Im(i,r,l,d,g),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(n(166));return _n(r),null}if(i=Ts(fi.current),Da(r)){d=r.stateNode,l=r.type;var _=r.memoizedProps;switch(d[hi]=r,d[po]=_,i=(r.mode&1)!==0,l){case"dialog":xt("cancel",d),xt("close",d);break;case"iframe":case"object":case"embed":xt("load",d);break;case"video":case"audio":for(g=0;g<uo.length;g++)xt(uo[g],d);break;case"source":xt("error",d);break;case"img":case"image":case"link":xt("error",d),xt("load",d);break;case"details":xt("toggle",d);break;case"input":Vt(d,_),xt("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!_.multiple},xt("invalid",d);break;case"textarea":oe(d,_),xt("invalid",d)}_e(l,_),g=null;for(var P in _)if(_.hasOwnProperty(P)){var V=_[P];P==="children"?typeof V=="string"?d.textContent!==V&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,V,i),g=["children",V]):typeof V=="number"&&d.textContent!==""+V&&(_.suppressHydrationWarning!==!0&&Ea(d.textContent,V,i),g=["children",""+V]):o.hasOwnProperty(P)&&V!=null&&P==="onScroll"&&xt("scroll",d)}switch(l){case"input":ft(d),bt(d,_,!0);break;case"textarea":ft(d),Te(d);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(d.onclick=Na)}d=g,r.updateQueue=d,d!==null&&(r.flags|=4)}else{P=g.nodeType===9?g:g.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=ae(l)),i==="http://www.w3.org/1999/xhtml"?l==="script"?(i=P.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof d.is=="string"?i=P.createElement(l,{is:d.is}):(i=P.createElement(l),l==="select"&&(P=i,d.multiple?P.multiple=!0:d.size&&(P.size=d.size))):i=P.createElementNS(i,l),i[hi]=r,i[po]=d,Mm(i,r,!1,!1),r.stateNode=i;e:{switch(P=Ee(l,d),l){case"dialog":xt("cancel",i),xt("close",i),g=d;break;case"iframe":case"object":case"embed":xt("load",i),g=d;break;case"video":case"audio":for(g=0;g<uo.length;g++)xt(uo[g],i);g=d;break;case"source":xt("error",i),g=d;break;case"img":case"image":case"link":xt("error",i),xt("load",i),g=d;break;case"details":xt("toggle",i),g=d;break;case"input":Vt(i,d),g=Rt(i,d),xt("invalid",i);break;case"option":g=d;break;case"select":i._wrapperState={wasMultiple:!!d.multiple},g=D({},d,{value:void 0}),xt("invalid",i);break;case"textarea":oe(i,d),g=ot(i,d),xt("invalid",i);break;default:g=d}_e(l,g),V=g;for(_ in V)if(V.hasOwnProperty(_)){var J=V[_];_==="style"?ge(i,J):_==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&q(i,J)):_==="children"?typeof J=="string"?(l!=="textarea"||J!=="")&&te(i,J):typeof J=="number"&&te(i,""+J):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?J!=null&&_==="onScroll"&&xt("scroll",i):J!=null&&F(i,_,J,P))}switch(l){case"input":ft(i),bt(i,d,!1);break;case"textarea":ft(i),Te(i);break;case"option":d.value!=null&&i.setAttribute("value",""+me(d.value));break;case"select":i.multiple=!!d.multiple,_=d.value,_!=null?Qe(i,!!d.multiple,_,!1):d.defaultValue!=null&&Qe(i,!!d.multiple,d.defaultValue,!0);break;default:typeof g.onClick=="function"&&(i.onclick=Na)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return _n(r),null;case 6:if(i&&r.stateNode!=null)Om(i,r,i.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(n(166));if(l=Ts(yo.current),Ts(fi.current),Da(r)){if(d=r.stateNode,l=r.memoizedProps,d[hi]=r,(_=d.nodeValue!==l)&&(i=In,i!==null))switch(i.tag){case 3:Ea(d.nodeValue,l,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Ea(d.nodeValue,l,(i.mode&1)!==0)}_&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[hi]=r,r.stateNode=d}return _n(r),null;case 13:if(kt(Lt),d=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Nt&&On!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Fp(),pr(),r.flags|=98560,_=!1;else if(_=Da(r),d!==null&&d.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=r.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[hi]=r}else pr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;_n(r),_=!1}else si!==null&&(Du(si),si=null),_=!0;if(!_)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(i!==null&&i.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Lt.current&1)!==0?Gt===0&&(Gt=3):Ou())),r.updateQueue!==null&&(r.flags|=4),_n(r),null);case 4:return _r(),xu(i,r),i===null&&ho(r.stateNode.containerInfo),_n(r),null;case 10:return Qc(r.type._context),_n(r),null;case 17:return Rn(r.type)&&Ra(),_n(r),null;case 19:if(kt(Lt),_=r.memoizedState,_===null)return _n(r),null;if(d=(r.flags&128)!==0,P=_.rendering,P===null)if(d)ko(_,!1);else{if(Gt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(P=Fa(i),P!==null){for(r.flags|=128,ko(_,!1),d=P.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)_=l,i=d,_.flags&=14680066,P=_.alternate,P===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=P.childLanes,_.lanes=P.lanes,_.child=P.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=P.memoizedProps,_.memoizedState=P.memoizedState,_.updateQueue=P.updateQueue,_.type=P.type,i=P.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),l=l.sibling;return yt(Lt,Lt.current&1|2),r.child}i=i.sibling}_.tail!==null&&Et()>Sr&&(r.flags|=128,d=!0,ko(_,!1),r.lanes=4194304)}else{if(!d)if(i=Fa(P),i!==null){if(r.flags|=128,d=!0,l=i.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),ko(_,!0),_.tail===null&&_.tailMode==="hidden"&&!P.alternate&&!Nt)return _n(r),null}else 2*Et()-_.renderingStartTime>Sr&&l!==1073741824&&(r.flags|=128,d=!0,ko(_,!1),r.lanes=4194304);_.isBackwards?(P.sibling=r.child,r.child=P):(l=_.last,l!==null?l.sibling=P:r.child=P,_.last=P)}return _.tail!==null?(r=_.tail,_.rendering=r,_.tail=r.sibling,_.renderingStartTime=Et(),r.sibling=null,l=Lt.current,yt(Lt,d?l&1|2:l&1),r):(_n(r),null);case 22:case 23:return Iu(),d=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(Bn&1073741824)!==0&&(_n(r),r.subtreeFlags&6&&(r.flags|=8192)):_n(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function OS(i,r){switch(Kc(r),r.tag){case 1:return Rn(r.type)&&Ra(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return _r(),kt(jn),kt(gn),su(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return nu(r),null;case 13:if(kt(Lt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));pr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return kt(Lt),null;case 4:return _r(),null;case 10:return Qc(r.type._context),null;case 22:case 23:return Iu(),null;case 24:return null;default:return null}}var Ga=!1,yn=!1,BS=typeof WeakSet=="function"?WeakSet:Set,Me=null;function wr(i,r){var l=i.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){It(i,r,d)}else l.current=null}function ku(i,r,l){try{l()}catch(d){It(i,r,d)}}var Bm=!1;function zS(i,r){if(Ic=ma,i=gp(),jc(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var g=d.anchorOffset,_=d.focusNode;d=d.focusOffset;try{l.nodeType,_.nodeType}catch{l=null;break e}var P=0,V=-1,J=-1,le=0,be=0,Se=i,ye=null;t:for(;;){for(var Le;Se!==l||g!==0&&Se.nodeType!==3||(V=P+g),Se!==_||d!==0&&Se.nodeType!==3||(J=P+d),Se.nodeType===3&&(P+=Se.nodeValue.length),(Le=Se.firstChild)!==null;)ye=Se,Se=Le;for(;;){if(Se===i)break t;if(ye===l&&++le===g&&(V=P),ye===_&&++be===d&&(J=P),(Le=Se.nextSibling)!==null)break;Se=ye,ye=Se.parentNode}Se=Le}l=V===-1||J===-1?null:{start:V,end:J}}else l=null}l=l||{start:0,end:0}}else l=null;for(Oc={focusedElem:i,selectionRange:l},ma=!1,Me=r;Me!==null;)if(r=Me,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Me=i;else for(;Me!==null;){r=Me;try{var Be=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Be!==null){var ze=Be.memoizedProps,Ft=Be.memoizedState,ne=r.stateNode,ee=ne.getSnapshotBeforeUpdate(r.elementType===r.type?ze:ri(r.type,ze),Ft);ne.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var se=r.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ce){It(r,r.return,Ce)}if(i=r.sibling,i!==null){i.return=r.return,Me=i;break}Me=r.return}return Be=Bm,Bm=!1,Be}function Co(i,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var g=d=d.next;do{if((g.tag&i)===i){var _=g.destroy;g.destroy=void 0,_!==void 0&&ku(r,l,_)}g=g.next}while(g!==d)}}function Xa(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&i)===i){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function Cu(i){var r=i.ref;if(r!==null){var l=i.stateNode;switch(i.tag){case 5:i=l;break;default:i=l}typeof r=="function"?r(i):r.current=i}}function zm(i){var r=i.alternate;r!==null&&(i.alternate=null,zm(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[hi],delete r[po],delete r[$c],delete r[bS],delete r[SS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function Fm(i){return i.tag===5||i.tag===3||i.tag===4}function $m(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Fm(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.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 Eu(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(i,r):l.insertBefore(i,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(i,l)):(r=l,r.appendChild(i)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Na));else if(d!==4&&(i=i.child,i!==null))for(Eu(i,r,l),i=i.sibling;i!==null;)Eu(i,r,l),i=i.sibling}function Nu(i,r,l){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(d!==4&&(i=i.child,i!==null))for(Nu(i,r,l),i=i.sibling;i!==null;)Nu(i,r,l),i=i.sibling}var hn=null,oi=!1;function ns(i,r,l){for(l=l.child;l!==null;)Hm(i,r,l),l=l.sibling}function Hm(i,r,l){if(en&&typeof en.onCommitFiberUnmount=="function")try{en.onCommitFiberUnmount(Ut,l)}catch{}switch(l.tag){case 5:yn||wr(l,r);case 6:var d=hn,g=oi;hn=null,ns(i,r,l),hn=d,oi=g,hn!==null&&(oi?(i=hn,l=l.stateNode,i.nodeType===8?i.parentNode.removeChild(l):i.removeChild(l)):hn.removeChild(l.stateNode));break;case 18:hn!==null&&(oi?(i=hn,l=l.stateNode,i.nodeType===8?Fc(i.parentNode,l):i.nodeType===1&&Fc(i,l),no(i)):Fc(hn,l.stateNode));break;case 4:d=hn,g=oi,hn=l.stateNode.containerInfo,oi=!0,ns(i,r,l),hn=d,oi=g;break;case 0:case 11:case 14:case 15:if(!yn&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){g=d=d.next;do{var _=g,P=_.destroy;_=_.tag,P!==void 0&&((_&2)!==0||(_&4)!==0)&&ku(l,r,P),g=g.next}while(g!==d)}ns(i,r,l);break;case 1:if(!yn&&(wr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(V){It(l,r,V)}ns(i,r,l);break;case 21:ns(i,r,l);break;case 22:l.mode&1?(yn=(d=yn)||l.memoizedState!==null,ns(i,r,l),yn=d):ns(i,r,l);break;default:ns(i,r,l)}}function Um(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var l=i.stateNode;l===null&&(l=i.stateNode=new BS),r.forEach(function(d){var g=YS.bind(null,i,d);l.has(d)||(l.add(d),d.then(g,g))})}}function ai(i,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var g=l[d];try{var _=i,P=r,V=P;e:for(;V!==null;){switch(V.tag){case 5:hn=V.stateNode,oi=!1;break e;case 3:hn=V.stateNode.containerInfo,oi=!0;break e;case 4:hn=V.stateNode.containerInfo,oi=!0;break e}V=V.return}if(hn===null)throw Error(n(160));Hm(_,P,g),hn=null,oi=!1;var J=g.alternate;J!==null&&(J.return=null),g.return=null}catch(le){It(g,r,le)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Wm(r,i),r=r.sibling}function Wm(i,r){var l=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(ai(r,i),mi(i),d&4){try{Co(3,i,i.return),Xa(3,i)}catch(ze){It(i,i.return,ze)}try{Co(5,i,i.return)}catch(ze){It(i,i.return,ze)}}break;case 1:ai(r,i),mi(i),d&512&&l!==null&&wr(l,l.return);break;case 5:if(ai(r,i),mi(i),d&512&&l!==null&&wr(l,l.return),i.flags&32){var g=i.stateNode;try{te(g,"")}catch(ze){It(i,i.return,ze)}}if(d&4&&(g=i.stateNode,g!=null)){var _=i.memoizedProps,P=l!==null?l.memoizedProps:_,V=i.type,J=i.updateQueue;if(i.updateQueue=null,J!==null)try{V==="input"&&_.type==="radio"&&_.name!=null&&Oe(g,_),Ee(V,P);var le=Ee(V,_);for(P=0;P<J.length;P+=2){var be=J[P],Se=J[P+1];be==="style"?ge(g,Se):be==="dangerouslySetInnerHTML"?q(g,Se):be==="children"?te(g,Se):F(g,be,Se,le)}switch(V){case"input":Pt(g,_);break;case"textarea":ke(g,_);break;case"select":var ye=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!_.multiple;var Le=_.value;Le!=null?Qe(g,!!_.multiple,Le,!1):ye!==!!_.multiple&&(_.defaultValue!=null?Qe(g,!!_.multiple,_.defaultValue,!0):Qe(g,!!_.multiple,_.multiple?[]:"",!1))}g[po]=_}catch(ze){It(i,i.return,ze)}}break;case 6:if(ai(r,i),mi(i),d&4){if(i.stateNode===null)throw Error(n(162));g=i.stateNode,_=i.memoizedProps;try{g.nodeValue=_}catch(ze){It(i,i.return,ze)}}break;case 3:if(ai(r,i),mi(i),d&4&&l!==null&&l.memoizedState.isDehydrated)try{no(r.containerInfo)}catch(ze){It(i,i.return,ze)}break;case 4:ai(r,i),mi(i);break;case 13:ai(r,i),mi(i),g=i.child,g.flags&8192&&(_=g.memoizedState!==null,g.stateNode.isHidden=_,!_||g.alternate!==null&&g.alternate.memoizedState!==null||(Pu=Et())),d&4&&Um(i);break;case 22:if(be=l!==null&&l.memoizedState!==null,i.mode&1?(yn=(le=yn)||be,ai(r,i),yn=le):ai(r,i),mi(i),d&8192){if(le=i.memoizedState!==null,(i.stateNode.isHidden=le)&&!be&&(i.mode&1)!==0)for(Me=i,be=i.child;be!==null;){for(Se=Me=be;Me!==null;){switch(ye=Me,Le=ye.child,ye.tag){case 0:case 11:case 14:case 15:Co(4,ye,ye.return);break;case 1:wr(ye,ye.return);var Be=ye.stateNode;if(typeof Be.componentWillUnmount=="function"){d=ye,l=ye.return;try{r=d,Be.props=r.memoizedProps,Be.state=r.memoizedState,Be.componentWillUnmount()}catch(ze){It(d,l,ze)}}break;case 5:wr(ye,ye.return);break;case 22:if(ye.memoizedState!==null){Vm(Se);continue}}Le!==null?(Le.return=ye,Me=Le):Vm(Se)}be=be.sibling}e:for(be=null,Se=i;;){if(Se.tag===5){if(be===null){be=Se;try{g=Se.stateNode,le?(_=g.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(V=Se.stateNode,J=Se.memoizedProps.style,P=J!=null&&J.hasOwnProperty("display")?J.display:null,V.style.display=de("display",P))}catch(ze){It(i,i.return,ze)}}}else if(Se.tag===6){if(be===null)try{Se.stateNode.nodeValue=le?"":Se.memoizedProps}catch(ze){It(i,i.return,ze)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===i)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===i)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===i)break e;be===Se&&(be=null),Se=Se.return}be===Se&&(be=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:ai(r,i),mi(i),d&4&&Um(i);break;case 21:break;default:ai(r,i),mi(i)}}function mi(i){var r=i.flags;if(r&2){try{e:{for(var l=i.return;l!==null;){if(Fm(l)){var d=l;break e}l=l.return}throw Error(n(160))}switch(d.tag){case 5:var g=d.stateNode;d.flags&32&&(te(g,""),d.flags&=-33);var _=$m(i);Nu(i,_,g);break;case 3:case 4:var P=d.stateNode.containerInfo,V=$m(i);Eu(i,V,P);break;default:throw Error(n(161))}}catch(J){It(i,i.return,J)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function FS(i,r,l){Me=i,Km(i)}function Km(i,r,l){for(var d=(i.mode&1)!==0;Me!==null;){var g=Me,_=g.child;if(g.tag===22&&d){var P=g.memoizedState!==null||Ga;if(!P){var V=g.alternate,J=V!==null&&V.memoizedState!==null||yn;V=Ga;var le=yn;if(Ga=P,(yn=J)&&!le)for(Me=g;Me!==null;)P=Me,J=P.child,P.tag===22&&P.memoizedState!==null?Ym(g):J!==null?(J.return=P,Me=J):Ym(g);for(;_!==null;)Me=_,Km(_),_=_.sibling;Me=g,Ga=V,yn=le}qm(i)}else(g.subtreeFlags&8772)!==0&&_!==null?(_.return=g,Me=_):qm(i)}}function qm(i){for(;Me!==null;){var r=Me;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:yn||Xa(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!yn)if(l===null)d.componentDidMount();else{var g=r.elementType===r.type?l.memoizedProps:ri(r.type,l.memoizedProps);d.componentDidUpdate(g,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var _=r.updateQueue;_!==null&&Vp(r,_,d);break;case 3:var P=r.updateQueue;if(P!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Vp(r,P,l)}break;case 5:var V=r.stateNode;if(l===null&&r.flags&4){l=V;var J=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&l.focus();break;case"img":J.src&&(l.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var le=r.alternate;if(le!==null){var be=le.memoizedState;if(be!==null){var Se=be.dehydrated;Se!==null&&no(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}yn||r.flags&512&&Cu(r)}catch(ye){It(r,r.return,ye)}}if(r===i){Me=null;break}if(l=r.sibling,l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Vm(i){for(;Me!==null;){var r=Me;if(r===i){Me=null;break}var l=r.sibling;if(l!==null){l.return=r.return,Me=l;break}Me=r.return}}function Ym(i){for(;Me!==null;){var r=Me;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{Xa(4,r)}catch(J){It(r,l,J)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var g=r.return;try{d.componentDidMount()}catch(J){It(r,g,J)}}var _=r.return;try{Cu(r)}catch(J){It(r,_,J)}break;case 5:var P=r.return;try{Cu(r)}catch(J){It(r,P,J)}}}catch(J){It(r,r.return,J)}if(r===i){Me=null;break}var V=r.sibling;if(V!==null){V.return=r.return,Me=V;break}Me=r.return}}var $S=Math.ceil,Qa=I.ReactCurrentDispatcher,ju=I.ReactCurrentOwner,Xn=I.ReactCurrentBatchConfig,lt=0,nn=null,Wt=null,fn=0,Bn=0,br=Qi(0),Gt=0,Eo=null,Ms=0,Ja=0,Ru=0,No=null,Ln=null,Pu=0,Sr=1/0,Mi=null,Za=!1,Lu=null,is=null,el=!1,ss=null,tl=0,jo=0,Au=null,nl=-1,il=0;function Sn(){return(lt&6)!==0?Et():nl!==-1?nl:nl=Et()}function rs(i){return(i.mode&1)===0?1:(lt&2)!==0&&fn!==0?fn&-fn:kS.transition!==null?(il===0&&(il=$f()),il):(i=mt,i!==0||(i=window.event,i=i===void 0?16:Xf(i.type)),i)}function li(i,r,l,d){if(50<jo)throw jo=0,Au=null,Error(n(185));Qr(i,l,d),((lt&2)===0||i!==nn)&&(i===nn&&((lt&2)===0&&(Ja|=l),Gt===4&&os(i,fn)),An(i,d),l===1&&lt===0&&(r.mode&1)===0&&(Sr=Et()+500,La&&Zi()))}function An(i,r){var l=i.callbackNode;kb(i,r);var d=ha(i,i===nn?fn:0);if(d===0)l!==null&&Yr(l),i.callbackNode=null,i.callbackPriority=0;else if(r=d&-d,i.callbackPriority!==r){if(l!=null&&Yr(l),r===1)i.tag===0?xS(Xm.bind(null,i)):Mp(Xm.bind(null,i)),yS(function(){(lt&6)===0&&Zi()}),l=null;else{switch(Hf(d)){case 1:l=He;break;case 4:l=Ye;break;case 16:l=Ve;break;case 536870912:l=St;break;default:l=Ve}l=sg(l,Gm.bind(null,i))}i.callbackPriority=r,i.callbackNode=l}}function Gm(i,r){if(nl=-1,il=0,(lt&6)!==0)throw Error(n(327));var l=i.callbackNode;if(xr()&&i.callbackNode!==l)return null;var d=ha(i,i===nn?fn:0);if(d===0)return null;if((d&30)!==0||(d&i.expiredLanes)!==0||r)r=sl(i,d);else{r=d;var g=lt;lt|=2;var _=Jm();(nn!==i||fn!==r)&&(Mi=null,Sr=Et()+500,Os(i,r));do try{WS();break}catch(V){Qm(i,V)}while(!0);Xc(),Qa.current=_,lt=g,Wt!==null?r=0:(nn=null,fn=0,r=Gt)}if(r!==0){if(r===2&&(g=hc(i),g!==0&&(d=g,r=Tu(i,g))),r===1)throw l=Eo,Os(i,0),os(i,d),An(i,Et()),l;if(r===6)os(i,d);else{if(g=i.current.alternate,(d&30)===0&&!HS(g)&&(r=sl(i,d),r===2&&(_=hc(i),_!==0&&(d=_,r=Tu(i,_))),r===1))throw l=Eo,Os(i,0),os(i,d),An(i,Et()),l;switch(i.finishedWork=g,i.finishedLanes=d,r){case 0:case 1:throw Error(n(345));case 2:Bs(i,Ln,Mi);break;case 3:if(os(i,d),(d&130023424)===d&&(r=Pu+500-Et(),10<r)){if(ha(i,0)!==0)break;if(g=i.suspendedLanes,(g&d)!==d){Sn(),i.pingedLanes|=i.suspendedLanes&g;break}i.timeoutHandle=zc(Bs.bind(null,i,Ln,Mi),r);break}Bs(i,Ln,Mi);break;case 4:if(os(i,d),(d&4194240)===d)break;for(r=i.eventTimes,g=-1;0<d;){var P=31-Nn(d);_=1<<P,P=r[P],P>g&&(g=P),d&=~_}if(d=g,d=Et()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*$S(d/1960))-d,10<d){i.timeoutHandle=zc(Bs.bind(null,i,Ln,Mi),d);break}Bs(i,Ln,Mi);break;case 5:Bs(i,Ln,Mi);break;default:throw Error(n(329))}}}return An(i,Et()),i.callbackNode===l?Gm.bind(null,i):null}function Tu(i,r){var l=No;return i.current.memoizedState.isDehydrated&&(Os(i,r).flags|=256),i=sl(i,r),i!==2&&(r=Ln,Ln=l,r!==null&&Du(r)),i}function Du(i){Ln===null?Ln=i:Ln.push.apply(Ln,i)}function HS(i){for(var r=i;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var g=l[d],_=g.getSnapshot;g=g.value;try{if(!ii(_(),g))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function os(i,r){for(r&=~Ru,r&=~Ja,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var l=31-Nn(r),d=1<<l;i[l]=-1,r&=~d}}function Xm(i){if((lt&6)!==0)throw Error(n(327));xr();var r=ha(i,0);if((r&1)===0)return An(i,Et()),null;var l=sl(i,r);if(i.tag!==0&&l===2){var d=hc(i);d!==0&&(r=d,l=Tu(i,d))}if(l===1)throw l=Eo,Os(i,0),os(i,r),An(i,Et()),l;if(l===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Bs(i,Ln,Mi),An(i,Et()),null}function Mu(i,r){var l=lt;lt|=1;try{return i(r)}finally{lt=l,lt===0&&(Sr=Et()+500,La&&Zi())}}function Is(i){ss!==null&&ss.tag===0&&(lt&6)===0&&xr();var r=lt;lt|=1;var l=Xn.transition,d=mt;try{if(Xn.transition=null,mt=1,i)return i()}finally{mt=d,Xn.transition=l,lt=r,(lt&6)===0&&Zi()}}function Iu(){Bn=br.current,kt(br)}function Os(i,r){i.finishedWork=null,i.finishedLanes=0;var l=i.timeoutHandle;if(l!==-1&&(i.timeoutHandle=-1,_S(l)),Wt!==null)for(l=Wt.return;l!==null;){var d=l;switch(Kc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Ra();break;case 3:_r(),kt(jn),kt(gn),su();break;case 5:nu(d);break;case 4:_r();break;case 13:kt(Lt);break;case 19:kt(Lt);break;case 10:Qc(d.type._context);break;case 22:case 23:Iu()}l=l.return}if(nn=i,Wt=i=as(i.current,null),fn=Bn=r,Gt=0,Eo=null,Ru=Ja=Ms=0,Ln=No=null,As!==null){for(r=0;r<As.length;r++)if(l=As[r],d=l.interleaved,d!==null){l.interleaved=null;var g=d.next,_=l.pending;if(_!==null){var P=_.next;_.next=g,d.next=P}l.pending=d}As=null}return i}function Qm(i,r){do{var l=Wt;try{if(Xc(),$a.current=Ka,Ha){for(var d=At.memoizedState;d!==null;){var g=d.queue;g!==null&&(g.pending=null),d=d.next}Ha=!1}if(Ds=0,tn=Yt=At=null,wo=!1,bo=0,ju.current=null,l===null||l.return===null){Gt=1,Eo=r,Wt=null;break}e:{var _=i,P=l.return,V=l,J=r;if(r=fn,V.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var le=J,be=V,Se=be.tag;if((be.mode&1)===0&&(Se===0||Se===11||Se===15)){var ye=be.alternate;ye?(be.updateQueue=ye.updateQueue,be.memoizedState=ye.memoizedState,be.lanes=ye.lanes):(be.updateQueue=null,be.memoizedState=null)}var Le=Sm(P);if(Le!==null){Le.flags&=-257,xm(Le,P,V,_,r),Le.mode&1&&bm(_,le,r),r=Le,J=le;var Be=r.updateQueue;if(Be===null){var ze=new Set;ze.add(J),r.updateQueue=ze}else Be.add(J);break e}else{if((r&1)===0){bm(_,le,r),Ou();break e}J=Error(n(426))}}else if(Nt&&V.mode&1){var Ft=Sm(P);if(Ft!==null){(Ft.flags&65536)===0&&(Ft.flags|=256),xm(Ft,P,V,_,r),Yc(yr(J,V));break e}}_=J=yr(J,V),Gt!==4&&(Gt=2),No===null?No=[_]:No.push(_),_=P;do{switch(_.tag){case 3:_.flags|=65536,r&=-r,_.lanes|=r;var ne=ym(_,J,r);qp(_,ne);break e;case 1:V=J;var ee=_.type,se=_.stateNode;if((_.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(is===null||!is.has(se)))){_.flags|=65536,r&=-r,_.lanes|=r;var Ce=wm(_,V,r);qp(_,Ce);break e}}_=_.return}while(_!==null)}eg(l)}catch(Fe){r=Fe,Wt===l&&l!==null&&(Wt=l=l.return);continue}break}while(!0)}function Jm(){var i=Qa.current;return Qa.current=Ka,i===null?Ka:i}function Ou(){(Gt===0||Gt===3||Gt===2)&&(Gt=4),nn===null||(Ms&268435455)===0&&(Ja&268435455)===0||os(nn,fn)}function sl(i,r){var l=lt;lt|=2;var d=Jm();(nn!==i||fn!==r)&&(Mi=null,Os(i,r));do try{US();break}catch(g){Qm(i,g)}while(!0);if(Xc(),lt=l,Qa.current=d,Wt!==null)throw Error(n(261));return nn=null,fn=0,Gt}function US(){for(;Wt!==null;)Zm(Wt)}function WS(){for(;Wt!==null&&!tr();)Zm(Wt)}function Zm(i){var r=ig(i.alternate,i,Bn);i.memoizedProps=i.pendingProps,r===null?eg(i):Wt=r,ju.current=null}function eg(i){var r=i;do{var l=r.alternate;if(i=r.return,(r.flags&32768)===0){if(l=IS(l,r,Bn),l!==null){Wt=l;return}}else{if(l=OS(l,r),l!==null){l.flags&=32767,Wt=l;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Gt=6,Wt=null;return}}if(r=r.sibling,r!==null){Wt=r;return}Wt=r=i}while(r!==null);Gt===0&&(Gt=5)}function Bs(i,r,l){var d=mt,g=Xn.transition;try{Xn.transition=null,mt=1,KS(i,r,l,d)}finally{Xn.transition=g,mt=d}return null}function KS(i,r,l,d){do xr();while(ss!==null);if((lt&6)!==0)throw Error(n(327));l=i.finishedWork;var g=i.finishedLanes;if(l===null)return null;if(i.finishedWork=null,i.finishedLanes=0,l===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=l.lanes|l.childLanes;if(Cb(i,_),i===nn&&(Wt=nn=null,fn=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||el||(el=!0,sg(Ve,function(){return xr(),null})),_=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||_){_=Xn.transition,Xn.transition=null;var P=mt;mt=1;var V=lt;lt|=4,ju.current=null,zS(i,l),Wm(l,i),dS(Oc),ma=!!Ic,Oc=Ic=null,i.current=l,FS(l),ca(),lt=V,mt=P,Xn.transition=_}else i.current=l;if(el&&(el=!1,ss=i,tl=g),_=i.pendingLanes,_===0&&(is=null),dc(l.stateNode),An(i,Et()),r!==null)for(d=i.onRecoverableError,l=0;l<r.length;l++)g=r[l],d(g.value,{componentStack:g.stack,digest:g.digest});if(Za)throw Za=!1,i=Lu,Lu=null,i;return(tl&1)!==0&&i.tag!==0&&xr(),_=i.pendingLanes,(_&1)!==0?i===Au?jo++:(jo=0,Au=i):jo=0,Zi(),null}function xr(){if(ss!==null){var i=Hf(tl),r=Xn.transition,l=mt;try{if(Xn.transition=null,mt=16>i?16:i,ss===null)var d=!1;else{if(i=ss,ss=null,tl=0,(lt&6)!==0)throw Error(n(331));var g=lt;for(lt|=4,Me=i.current;Me!==null;){var _=Me,P=_.child;if((Me.flags&16)!==0){var V=_.deletions;if(V!==null){for(var J=0;J<V.length;J++){var le=V[J];for(Me=le;Me!==null;){var be=Me;switch(be.tag){case 0:case 11:case 15:Co(8,be,_)}var Se=be.child;if(Se!==null)Se.return=be,Me=Se;else for(;Me!==null;){be=Me;var ye=be.sibling,Le=be.return;if(zm(be),be===le){Me=null;break}if(ye!==null){ye.return=Le,Me=ye;break}Me=Le}}}var Be=_.alternate;if(Be!==null){var ze=Be.child;if(ze!==null){Be.child=null;do{var Ft=ze.sibling;ze.sibling=null,ze=Ft}while(ze!==null)}}Me=_}}if((_.subtreeFlags&2064)!==0&&P!==null)P.return=_,Me=P;else e:for(;Me!==null;){if(_=Me,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Co(9,_,_.return)}var ne=_.sibling;if(ne!==null){ne.return=_.return,Me=ne;break e}Me=_.return}}var ee=i.current;for(Me=ee;Me!==null;){P=Me;var se=P.child;if((P.subtreeFlags&2064)!==0&&se!==null)se.return=P,Me=se;else e:for(P=ee;Me!==null;){if(V=Me,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:Xa(9,V)}}catch(Fe){It(V,V.return,Fe)}if(V===P){Me=null;break e}var Ce=V.sibling;if(Ce!==null){Ce.return=V.return,Me=Ce;break e}Me=V.return}}if(lt=g,Zi(),en&&typeof en.onPostCommitFiberRoot=="function")try{en.onPostCommitFiberRoot(Ut,i)}catch{}d=!0}return d}finally{mt=l,Xn.transition=r}}return!1}function tg(i,r,l){r=yr(l,r),r=ym(i,r,1),i=ts(i,r,1),r=Sn(),i!==null&&(Qr(i,1,r),An(i,r))}function It(i,r,l){if(i.tag===3)tg(i,i,l);else for(;r!==null;){if(r.tag===3){tg(r,i,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(is===null||!is.has(d))){i=yr(l,i),i=wm(r,i,1),r=ts(r,i,1),i=Sn(),r!==null&&(Qr(r,1,i),An(r,i));break}}r=r.return}}function qS(i,r,l){var d=i.pingCache;d!==null&&d.delete(r),r=Sn(),i.pingedLanes|=i.suspendedLanes&l,nn===i&&(fn&l)===l&&(Gt===4||Gt===3&&(fn&130023424)===fn&&500>Et()-Pu?Os(i,0):Ru|=l),An(i,r)}function ng(i,r){r===0&&((i.mode&1)===0?r=1:(r=da,da<<=1,(da&130023424)===0&&(da=4194304)));var l=Sn();i=Ai(i,r),i!==null&&(Qr(i,r,l),An(i,l))}function VS(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),ng(i,l)}function YS(i,r){var l=0;switch(i.tag){case 13:var d=i.stateNode,g=i.memoizedState;g!==null&&(l=g.retryLane);break;case 19:d=i.stateNode;break;default:throw Error(n(314))}d!==null&&d.delete(r),ng(i,l)}var ig;ig=function(i,r,l){if(i!==null)if(i.memoizedProps!==r.pendingProps||jn.current)Pn=!0;else{if((i.lanes&l)===0&&(r.flags&128)===0)return Pn=!1,MS(i,r,l);Pn=(i.flags&131072)!==0}else Pn=!1,Nt&&(r.flags&1048576)!==0&&Ip(r,Ta,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;Ya(i,r),i=r.pendingProps;var g=dr(r,gn.current);vr(r,l),g=au(null,r,d,i,g,l);var _=lu();return r.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Rn(d)?(_=!0,Pa(r)):_=!1,r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,eu(r),g.updater=qa,r.stateNode=g,g._reactInternals=r,pu(r,d,i,l),r=_u(null,r,d,!0,_,l)):(r.tag=0,Nt&&_&&Wc(r),bn(null,r,g,l),r=r.child),r;case 16:d=r.elementType;e:{switch(Ya(i,r),i=r.pendingProps,g=d._init,d=g(d._payload),r.type=d,g=r.tag=XS(d),i=ri(d,i),g){case 0:r=vu(null,r,d,i,l);break e;case 1:r=Rm(null,r,d,i,l);break e;case 11:r=km(null,r,d,i,l);break e;case 14:r=Cm(null,r,d,ri(d.type,i),l);break e}throw Error(n(306,d,""))}return r;case 0:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),vu(i,r,d,g,l);case 1:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),Rm(i,r,d,g,l);case 3:e:{if(Pm(r),i===null)throw Error(n(387));d=r.pendingProps,_=r.memoizedState,g=_.element,Kp(i,r),za(r,d,null,l);var P=r.memoizedState;if(d=P.element,_.isDehydrated)if(_={element:d,isDehydrated:!1,cache:P.cache,pendingSuspenseBoundaries:P.pendingSuspenseBoundaries,transitions:P.transitions},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){g=yr(Error(n(423)),r),r=Lm(i,r,d,l,g);break e}else if(d!==g){g=yr(Error(n(424)),r),r=Lm(i,r,d,l,g);break e}else for(On=Xi(r.stateNode.containerInfo.firstChild),In=r,Nt=!0,si=null,l=Up(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(pr(),d===g){r=Di(i,r,l);break e}bn(i,r,d,l)}r=r.child}return r;case 5:return Yp(r),i===null&&Vc(r),d=r.type,g=r.pendingProps,_=i!==null?i.memoizedProps:null,P=g.children,Bc(d,g)?P=null:_!==null&&Bc(d,_)&&(r.flags|=32),jm(i,r),bn(i,r,P,l),r.child;case 6:return i===null&&Vc(r),null;case 13:return Am(i,r,l);case 4:return tu(r,r.stateNode.containerInfo),d=r.pendingProps,i===null?r.child=mr(r,null,d,l):bn(i,r,d,l),r.child;case 11:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),km(i,r,d,g,l);case 7:return bn(i,r,r.pendingProps,l),r.child;case 8:return bn(i,r,r.pendingProps.children,l),r.child;case 12:return bn(i,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,g=r.pendingProps,_=r.memoizedProps,P=g.value,yt(Ia,d._currentValue),d._currentValue=P,_!==null)if(ii(_.value,P)){if(_.children===g.children&&!jn.current){r=Di(i,r,l);break e}}else for(_=r.child,_!==null&&(_.return=r);_!==null;){var V=_.dependencies;if(V!==null){P=_.child;for(var J=V.firstContext;J!==null;){if(J.context===d){if(_.tag===1){J=Ti(-1,l&-l),J.tag=2;var le=_.updateQueue;if(le!==null){le=le.shared;var be=le.pending;be===null?J.next=J:(J.next=be.next,be.next=J),le.pending=J}}_.lanes|=l,J=_.alternate,J!==null&&(J.lanes|=l),Jc(_.return,l,r),V.lanes|=l;break}J=J.next}}else if(_.tag===10)P=_.type===r.type?null:_.child;else if(_.tag===18){if(P=_.return,P===null)throw Error(n(341));P.lanes|=l,V=P.alternate,V!==null&&(V.lanes|=l),Jc(P,l,r),P=_.sibling}else P=_.child;if(P!==null)P.return=_;else for(P=_;P!==null;){if(P===r){P=null;break}if(_=P.sibling,_!==null){_.return=P.return,P=_;break}P=P.return}_=P}bn(i,r,g.children,l),r=r.child}return r;case 9:return g=r.type,d=r.pendingProps.children,vr(r,l),g=Yn(g),d=d(g),r.flags|=1,bn(i,r,d,l),r.child;case 14:return d=r.type,g=ri(d,r.pendingProps),g=ri(d.type,g),Cm(i,r,d,g,l);case 15:return Em(i,r,r.type,r.pendingProps,l);case 17:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:ri(d,g),Ya(i,r),r.tag=1,Rn(d)?(i=!0,Pa(r)):i=!1,vr(r,l),vm(r,d,g),pu(r,d,g,l),_u(null,r,d,!0,i,l);case 19:return Dm(i,r,l);case 22:return Nm(i,r,l)}throw Error(n(156,r.tag))};function sg(i,r){return Ns(i,r)}function GS(i,r,l,d){this.tag=i,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qn(i,r,l,d){return new GS(i,r,l,d)}function Bu(i){return i=i.prototype,!(!i||!i.isReactComponent)}function XS(i){if(typeof i=="function")return Bu(i)?1:0;if(i!=null){if(i=i.$$typeof,i===M)return 11;if(i===L)return 14}return 2}function as(i,r){var l=i.alternate;return l===null?(l=Qn(i.tag,r,i.key,i.mode),l.elementType=i.elementType,l.type=i.type,l.stateNode=i.stateNode,l.alternate=i,i.alternate=l):(l.pendingProps=r,l.type=i.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=i.flags&14680064,l.childLanes=i.childLanes,l.lanes=i.lanes,l.child=i.child,l.memoizedProps=i.memoizedProps,l.memoizedState=i.memoizedState,l.updateQueue=i.updateQueue,r=i.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=i.sibling,l.index=i.index,l.ref=i.ref,l}function rl(i,r,l,d,g,_){var P=2;if(d=i,typeof i=="function")Bu(i)&&(P=1);else if(typeof i=="string")P=5;else e:switch(i){case z:return zs(l.children,g,_,r);case Z:P=8,g|=8;break;case G:return i=Qn(12,l,r,g|2),i.elementType=G,i.lanes=_,i;case j:return i=Qn(13,l,r,g),i.elementType=j,i.lanes=_,i;case T:return i=Qn(19,l,r,g),i.elementType=T,i.lanes=_,i;case H:return ol(l,g,_,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Q:P=10;break e;case B:P=9;break e;case M:P=11;break e;case L:P=14;break e;case $:P=16,d=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Qn(P,l,r,g),r.elementType=i,r.type=d,r.lanes=_,r}function zs(i,r,l,d){return i=Qn(7,i,d,r),i.lanes=l,i}function ol(i,r,l,d){return i=Qn(22,i,d,r),i.elementType=H,i.lanes=l,i.stateNode={isHidden:!1},i}function zu(i,r,l){return i=Qn(6,i,null,r),i.lanes=l,i}function Fu(i,r,l){return r=Qn(4,i.children!==null?i.children:[],i.key,r),r.lanes=l,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function QS(i,r,l,d,g){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=fc(0),this.expirationTimes=fc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fc(0),this.identifierPrefix=d,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function $u(i,r,l,d,g,_,P,V,J){return i=new QS(i,r,l,V,J),r===1?(r=1,_===!0&&(r|=8)):r=0,_=Qn(3,null,null,r),i.current=_,_.stateNode=i,_.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},eu(_),i}function JS(i,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Y,key:d==null?null:""+d,children:i,containerInfo:r,implementation:l}}function rg(i){if(!i)return Ji;i=i._reactInternals;e:{if(zt(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Rn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var l=i.type;if(Rn(l))return Tp(i,l,r)}return r}function og(i,r,l,d,g,_,P,V,J){return i=$u(l,d,!0,i,g,_,P,V,J),i.context=rg(null),l=i.current,d=Sn(),g=rs(l),_=Ti(d,g),_.callback=r??null,ts(l,_,g),i.current.lanes=g,Qr(i,g,d),An(i,d),i}function al(i,r,l,d){var g=r.current,_=Sn(),P=rs(g);return l=rg(l),r.context===null?r.context=l:r.pendingContext=l,r=Ti(_,P),r.payload={element:i},d=d===void 0?null:d,d!==null&&(r.callback=d),i=ts(g,r,P),i!==null&&(li(i,g,P,_),Ba(i,g,P)),P}function ll(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function ag(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var l=i.retryLane;i.retryLane=l!==0&&l<r?l:r}}function Hu(i,r){ag(i,r),(i=i.alternate)&&ag(i,r)}function ZS(){return null}var lg=typeof reportError=="function"?reportError:function(i){console.error(i)};function Uu(i){this._internalRoot=i}cl.prototype.render=Uu.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));al(i,r,null,null)},cl.prototype.unmount=Uu.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Is(function(){al(null,i,null,null)}),r[ji]=null}};function cl(i){this._internalRoot=i}cl.prototype.unstable_scheduleHydration=function(i){if(i){var r=Kf();i={blockedOn:null,target:i,priority:r};for(var l=0;l<Vi.length&&r!==0&&r<Vi[l].priority;l++);Vi.splice(l,0,i),l===0&&Yf(i)}};function Wu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ul(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function cg(){}function e0(i,r,l,d,g){if(g){if(typeof d=="function"){var _=d;d=function(){var le=ll(P);_.call(le)}}var P=og(r,d,i,0,null,!1,!1,"",cg);return i._reactRootContainer=P,i[ji]=P.current,ho(i.nodeType===8?i.parentNode:i),Is(),P}for(;g=i.lastChild;)i.removeChild(g);if(typeof d=="function"){var V=d;d=function(){var le=ll(J);V.call(le)}}var J=$u(i,0,!1,null,null,!1,!1,"",cg);return i._reactRootContainer=J,i[ji]=J.current,ho(i.nodeType===8?i.parentNode:i),Is(function(){al(r,J,l,d)}),J}function dl(i,r,l,d,g){var _=l._reactRootContainer;if(_){var P=_;if(typeof g=="function"){var V=g;g=function(){var J=ll(P);V.call(J)}}al(r,P,i,g)}else P=e0(l,r,i,g,d);return ll(P)}Uf=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var l=Xr(r.pendingLanes);l!==0&&(pc(r,l|1),An(r,Et()),(lt&6)===0&&(Sr=Et()+500,Zi()))}break;case 13:Is(function(){var d=Ai(i,1);if(d!==null){var g=Sn();li(d,i,1,g)}}),Hu(i,1)}},mc=function(i){if(i.tag===13){var r=Ai(i,134217728);if(r!==null){var l=Sn();li(r,i,134217728,l)}Hu(i,134217728)}},Wf=function(i){if(i.tag===13){var r=rs(i),l=Ai(i,r);if(l!==null){var d=Sn();li(l,i,r,d)}Hu(i,r)}},Kf=function(){return mt},qf=function(i,r){var l=mt;try{return mt=i,r()}finally{mt=l}},Je=function(i,r,l){switch(r){case"input":if(Pt(i,l),r=l.name,l.type==="radio"&&r!=null){for(l=i;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==i&&d.form===i.form){var g=ja(d);if(!g)throw Error(n(90));qe(d),Pt(d,g)}}}break;case"textarea":ke(i,l);break;case"select":r=l.value,r!=null&&Qe(i,!!l.multiple,r,!1)}},Wn=Mu,ui=Is;var t0={usingClientEntryPoint:!1,Events:[mo,cr,ja,Zt,ni,Mu]},Ro={findFiberByHostInstance:js,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},n0={bundleType:Ro.bundleType,version:Ro.version,rendererPackageName:Ro.rendererPackageName,rendererConfig:Ro.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Es(i),i===null?null:i.stateNode},findFiberByHostInstance:Ro.findFiberByHostInstance||ZS,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var hl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!hl.isDisabled&&hl.supportsFiber)try{Ut=hl.inject(n0),en=hl}catch{}}return Tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=t0,Tn.createPortal=function(i,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Wu(r))throw Error(n(200));return JS(i,r,null,l)},Tn.createRoot=function(i,r){if(!Wu(i))throw Error(n(299));var l=!1,d="",g=lg;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(g=r.onRecoverableError)),r=$u(i,1,!1,null,null,l,!1,d,g),i[ji]=r.current,ho(i.nodeType===8?i.parentNode:i),new Uu(r)},Tn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Es(r),i=i===null?null:i.stateNode,i},Tn.flushSync=function(i){return Is(i)},Tn.hydrate=function(i,r,l){if(!ul(r))throw Error(n(200));return dl(null,i,r,!0,l)},Tn.hydrateRoot=function(i,r,l){if(!Wu(i))throw Error(n(405));var d=l!=null&&l.hydratedSources||null,g=!1,_="",P=lg;if(l!=null&&(l.unstable_strictMode===!0&&(g=!0),l.identifierPrefix!==void 0&&(_=l.identifierPrefix),l.onRecoverableError!==void 0&&(P=l.onRecoverableError)),r=og(r,null,i,1,l??null,g,!1,_,P),i[ji]=r.current,ho(i),d)for(i=0;i<d.length;i++)l=d[i],g=l._getVersion,g=g(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,g]:r.mutableSourceEagerHydrationData.push(l,g);return new cl(r)},Tn.render=function(i,r,l){if(!ul(r))throw Error(n(200));return dl(null,i,r,!1,l)},Tn.unmountComponentAtNode=function(i){if(!ul(i))throw Error(n(40));return i._reactRootContainer?(Is(function(){dl(null,null,i,!1,function(){i._reactRootContainer=null,i[ji]=null})}),!0):!1},Tn.unstable_batchedUpdates=Mu,Tn.unstable_renderSubtreeIntoContainer=function(i,r,l,d){if(!ul(l))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return dl(i,r,l,!1,d)},Tn.version="18.3.1-next-f1338f8080-20240426",Tn}var vg;function d0(){if(vg)return Vu.exports;vg=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(),Vu.exports=u0(),Vu.exports}var _g;function h0(){if(_g)return fl;_g=1;var e=d0();return fl.createRoot=e.createRoot,fl.hydrateRoot=e.hydrateRoot,fl}var f0=h0();const p0=Vh(f0);function Ht(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const X_=e=>`nc_seen_${e}`;async function Ie(e,t,n={}){const s=await Ht(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const cn=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",un=(e,t)=>`${cn(e)}/fleet/${t}`,ws=(e,t)=>Ie(un(t,"status"),e),Gh=(e,t,n)=>Ie(un(n,"up"),e,{method:"POST",body:t}),Il=(e,t,n)=>Ie(un(n,"down"),e,{method:"POST",body:t}),Q_=(e,t,n)=>Ie(un(n,"boot"),e,{method:"POST",body:t}),Fo=(e,t,n)=>Ie(un(n,"restart"),e,{method:"POST",body:{cell:t}}),Jl=(e,t)=>Ie(un(t,"definitions"),e),m0=(e,t)=>Ie(un(t,"credentials/status"),e),yg=(e,t,n,s)=>Ie(un(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),g0=(e,t,n)=>Ie(un(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),v0=(e,t,n)=>Ie(un(n,"define-engine"),e,{method:"POST",body:{def:t}}),_0=(e,t,n,s,o)=>Ie(un(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),y0=(e,t,n)=>Ie(un(n,"remove-engine"),e,{method:"POST",body:{id:t}}),w0=(e,t,n)=>Ie(un(n,"define-cell"),e,{method:"POST",body:{def:t}}),J_=(e,t,n,s)=>Ie(un(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),Z_=(e,t,n=!1,s)=>Ie(un(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),b0=(e,t,n)=>Ie(un(n,"import-cell"),e,{method:"POST",body:t}),S0=(e,t,n)=>Ie(un(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),x0=(e,t,n,s)=>Ie(un(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Xh=(e,t,n)=>Ie(`${cn(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ey=(e,t,n,s)=>Ie(`${cn(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),Qh=(e,t,n)=>Ie(`${cn(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),ty=e=>Ie("/api/settings",e),k0=e=>Ie("/api/nodes",e),C0=e=>Ie("/api/peers",e),ny=(e,t=[])=>Ie(`${cn(t)}/vl-nodes`,e),wg=(e,t,n,s={},o=[])=>Ie(`${cn(o)}/vl-nodes/${encodeURIComponent(t)}/commands`,e,{method:"POST",body:{kind:n,args:s}}),E0=(e,t,n=0,s=[])=>Ie(`${cn(s)}/vl-nodes/${encodeURIComponent(t)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,e),iy=e=>Ie("/api/topology",e),Jh=(e,t)=>Ie(`${cn(t)}/sessions`,e),Zh=(e,t)=>Ie(`${cn(t)}/config`,e),bg=(e,t)=>Ie(`${cn(t)}/topology`,e),Wd=(e,t)=>Ie("/api/settings/config",e,{method:"POST",body:t}),N0=e=>Ie("/api/settings/token/rotate",e,{method:"POST"}),j0=(e,t)=>Ie("/api/settings/nodes/pair",e,{method:"POST",body:t}),R0=(e,t,n=[])=>Ie(`${cn(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),sy=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),P0=e=>Ie("/api/settings/node-aliases",e),L0=(e,t,n)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),Sg=(e,t)=>Ie(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),xg=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),A0=(e,t)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ef=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),T0=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),D0=(e,t,n,s=[])=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),M0=e=>Ie("/api/settings/audio",e),I0=(e,t)=>Ie("/api/settings/audio/consent",e,{method:"PATCH",body:{consent:t}}),O0=e=>Ie("/api/settings/audio/test",e,{method:"POST",body:{}}),B0=e=>Ie("/api/settings/audio/stop",e,{method:"POST",body:{}}),z0=e=>Ie("/api/settings/audio/groups",e),F0=(e,t,n)=>Ie(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"PUT",body:n}),$0=(e,t)=>Ie(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"DELETE"}),H0=e=>Ie("/api/settings/service/regenerate",e,{method:"POST"}),U0=e=>Ie("/api/settings/update/check",e,{method:"POST"}),W0=e=>Ie("/api/settings/update/apply",e,{method:"POST"}),Zl=(e,t)=>`${cn(e)}/diagnostics/${t}`,K0=(e,t=[])=>Ie(Zl(t,"status"),e),q0=(e,{after:t=0,limit:n=200}={},s=[])=>Ie(`${Zl(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),kg=(e,t,n,s=[])=>Ie(Zl(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),V0=(e,t=[])=>Ie(Zl(t,"logs"),e,{method:"DELETE"}),Y0=(e,t=!0)=>Ie(`/api/asks${t?"?open=1":""}`,e),G0=(e,t,n)=>Ie(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),X0=(e,t)=>Ie(`/api/asks/${encodeURIComponent(t)}`,e,{method:"DELETE"}),pl=(e,t=[])=>Ie(`${cn(t)}/decks`,e),Cg=(e,t,n=[])=>Ie(`${cn(n)}/decks`,e,{method:"POST",body:{name:t}}),ml=(e,t,n,s,o=[])=>Ie(`${cn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Q0=(e,t,n,s,o=[])=>Ie(`${cn(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),J0=(e,t,n,s=[])=>Ie(`${cn(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Z0={power:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 3v8"}),c.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:c.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),c.jsx("path",{d:"M12 18v3"})]}),enter:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),c.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),c.jsx("path",{d:"M22 2 11 13"})]}),trash:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),c.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),c.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:c.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),c.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),c.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),c.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 16V5"}),c.jsx("polyline",{points:"8 9 12 5 16 9"}),c.jsx("path",{d:"M5 20h14"})]}),chevronLeft:c.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:c.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:c.jsx("polyline",{points:"6 10 12 16 18 10"}),history:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("polyline",{points:"3 3 3 8 8 8"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),attach:c.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),c.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6"})]}),gear:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function Ze({name:e,size:t=20}){return c.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Z0[e]||null})}const ex=["all","pinned","active","off","technical"],ry="nc_sidebar_views_v1",oy="nc_sidebar_order_v1";function ay(e){return ex.includes(e)?e:"all"}function tx(e,t=[],n="all"){const s=ay(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function nx(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,f=s.indexOf(e.key),m=s.indexOf(t.key),v=f===-1?Number.MAX_SAFE_INTEGER:f,S=m===-1?Number.MAX_SAFE_INTEGER:m;return u-h||v-S||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function ix(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(oy));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}catch{return{}}}function Fi(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function sx(e,t=globalThis.localStorage){try{t.setItem(oy,JSON.stringify(e))}catch{}return e}function rx(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(n)||!a.includes(s))return e;const u=Fi(e,t).filter(y=>a.includes(y)),h=[...u,...a.filter(y=>!u.includes(y))],f=h.indexOf(n),m=h.indexOf(s);h.splice(f,1);const v=h.indexOf(s),S=f<m?v+1:v;return h.splice(S,0,n),{...e,[t]:h}}function ox(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(ry));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Eg(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:ay((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function ax(e,t=globalThis.localStorage){try{t.setItem(ry,JSON.stringify(e))}catch{}return e}function Ng(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function gs(e=[],t=[],n="all",s=[]){return[...e].filter(o=>tx(o,t,n)).sort((o,a)=>nx(o,a,t,s))}const tf=["it","en","es"];function lx(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return tf.includes(t)?t:"en"}catch{return"en"}}const jl=lx(),ly="nc_lang",Kd="nc-lang";function cy(){return typeof localStorage<"u"?localStorage:null}const gl={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","tab-audio":"audio","system-general":"generale","system-diagnostics":"diagnostica","system-this-node":"questo nodo","system-updates":"aggiornamenti","system-security":"sicurezza","system-local-data":"dati locali del browser","system-terminal":"terminale","alternate-screen":"schermo alternato","alternate-screen-help":"Mantiene il comportamento tmux standard per le nuove sessioni NexusCrew. Un’applicazione che segue il mouse scorre da sé; le altre fanno scorrere la storia di tmux. Non modifica le celle già attive.","tab-input":"input","tab-diagnostics":"diagnostica","input-settings-local":"Preferenze locali di questo browser. Si applicano subito a vista singola e deck, senza modificare il nodo remoto.","terminal-keyboard-gesture":"Apertura tastiera virtuale dal terminale","terminal-keyboard-double-tap":"Doppio tap (predefinito)","terminal-keyboard-single-tap":"Tap singolo","terminal-keyboard-never":"Mai dal terminale","terminal-keyboard-gesture-help":"Il tastierino e STT seguono i controlli separati sotto. Mouse e tastiera fisica restano utilizzabili.","keybar-ime-lock":"Tastierino: mantieni chiusa la tastiera virtuale","keybar-ime-lock-help":"ESC, frecce, PgUp/PgDn, Enter e menu inviano direttamente al PTY senza dare focus a un campo di testo.","voice-ime-lock":"Microfono STT: mantieni chiusa la tastiera virtuale","voice-ime-lock-help":"Il tap sul microfono avvia o ferma la voce senza focalizzare il composer.","keybar-enter-show":"Mostra Enter verticale nel tastierino","keybar-enter-show-help":"Enter resta a destra di PgUp/PgDn ed è alto quanto entrambe le righe.","keybar-layout":"Layout tastierino","keybar-layout-full":"Esteso (predefinito)","keybar-layout-compact":"Compatto","keybar-layout-help":"Compatto: una riga con expand ⊞ per accedere al set completo senza cambiare la preferenza.","input-settings-reset":"ripristina predefiniti input","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-credential-source-policy":"origine credenziale","fleet-credential-source-policy-auto":"auto (precedenza legacy)","fleet-credential-source-policy-nexuscrew-store":"solo store NexusCrew","fleet-credential-source-policy-environment":"solo ambiente","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max-preview è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa il login del CLI (device-code) e la propria configurazione: NexusCrew non legge né copia credenziali. Distinto dal provider "Kimi Code" di Claude Code, che resta il percorso K3 gestito.',"fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-recovery-client-terminal-dialog":"Completa il dialogo mostrato nel terminale della cella, poi riavvia la cella.","settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-group-vl":"Nodi VL","vl-owners-unavailable":"Owner VL non raggiunti","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-off-hub-reconcile-pending":"Stato privato salvato; la revoca sull’hub è ancora in attesa.","fleet-cell-label":"nome leggibile (facoltativo)","share-off-local-reconcile-pending":"Revoca confermata dall’hub; il tunnel locale deve ancora riconciliarsi.","share-reverse-pool-pending":"Il canale reverse non risulta spento in modo dimostrabile: resta in quarantena, non chiuso.","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","peer-vl-federated":"Nodo VL: federato","row-vl-federated":"federato","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","vl-poll-online":"online (poll)","vl-poll-offline":"non risponde","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-dismiss":"Scarta la domanda","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-needs-test":"Per questa sessione dell’app, premi “prova voce” prima di ricevere annunci vocali.","notification-speech-unsupported":"Sintesi vocale non supportata in questo browser.","audio-title":"Audio nativo del nodo","audio-help":"Consenso e controlli valgono solo per questo dispositivo. Share e visibilità non autorizzano suoni.","audio-consent":"consenti TTS su questo nodo","audio-consent-help":"Permette a celle autorizzate, locali o remote, di consegnare un comando vocale. Puoi revocarlo in ogni momento.","audio-capability":"Capability locale","audio-loading":"leggo lo stato audio locale…","audio-adapter":"adapter","audio-adapter-none":"nessuno","audio-installed":"installato","audio-installed-yes":"sì","audio-installed-no":"no","audio-liveness":"disponibilità","audio-liveness-ready":"pronto ad accettare","audio-liveness-unavailable":"non disponibile","audio-languages":"lingue dichiarate","audio-limits":"limiti","audio-test":"prova audio locale","audio-testing":"prova in corso…","audio-stop":"ferma audio locale","audio-stopping":"stop in corso…","audio-test-needs-consent":"Attiva il consenso locale prima di provare la voce.","audio-unavailable":"Nessun adapter TTS nativo disponibile su questo nodo.","audio-test-accepted":"Il nodo ha accettato la prova. Non dimostra che qualcuno l’abbia udita.","audio-test-refused":"Il nodo ha rifiutato la prova.","audio-test-unknown":"Esito della prova sconosciuto: il nodo non può confermare l’avvio.","audio-stop-stopped":"Audio locale fermato.","audio-stop-idle":"Nessun enunciato locale da fermare.","audio-groups-title":"Gruppi audio condivisi","audio-groups-help":"Decide su quali dispositivi si sente la voce quando una cella parla. Il gruppo è una preferenza locale di consegna, non un consenso. Ogni nodo conserva consenso, ACL, disponibilità e Stop locale.","audio-groups-empty":"Nessun gruppo: la voce esce solo su questo nodo.","audio-group-name":"nome gruppo","audio-group-mode":"modalità consegna","audio-group-primary":"primo disponibile (in ordine)","audio-group-fanout":"tutti i nodi elencati","audio-group-targets":"nodi target esatti","audio-group-local":"questo nodo","audio-group-unavailable-target":"non rilevato ora","audio-group-no-targets":"Nessun nodo con instanceId disponibile. Il gruppo non può usare nomi, wildcard o “tutti”.","audio-group-new":"nuovo gruppo","audio-group-edit":"modifica","audio-group-delete":"elimina","audio-group-save":"salva gruppo","audio-group-cancel":"annulla","audio-group-invalid":"Il gruppo richiede un nome valido e almeno un nodeId esatto.","audio-group-save-failed":"Salvataggio gruppo audio non riuscito.","node-display-label":"Nome (etichetta)","routed-node-aliases":"Alias nodi instradati","routed-node-aliases-help":"Visibili solo su questo dispositivo; route e nome remoto non cambiano.","node-local-alias":"Alias su questo dispositivo","alias-on-device":"Alias su questo dispositivo","reset-alias":"Ripristina nome remoto","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","cell-switcher-refreshing":"aggiorno le celle…","cell-switcher-empty-active":"nessuna cella attiva verificata","cell-switcher-not-confirmed":"stato non confermato","cell-switcher-not-active":"questa cella non è più attiva","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","selection-held":"evidenziazione persa, testo ancora in mano","invite-hub-only":"Un invito si conia sull’hub. Ammettere un nodo nuovo è la sola cosa che un nodo collegato non può chiedere per conto di un altro: apri NexusCrew sull’hub e crea l’invito da lì.","row-private":"privato","node-detail-open":"apri il dettaglio","node-detail-reach":"Raggiungibilità","node-detail-route":"percorso","node-detail-ssh":"SSH","node-detail-transport":"trasporto","node-detail-owner":"owner","node-detail-authority":"Cosa può fare questo nodo","authority-owner-equivalent":"Autorità pari alla tua: un nodo accoppiato può fare su questa macchina tutto quello che puoi fare tu.","authority-routed":"Non è accoppiato con questa macchina: la sua autorità vive presso l’hub che lo instrada.","authority-no-grants":"L’unico potere per-nodo che esiste è la scelta delle celle, qui sotto. Dentro quelle celle l’autorità resta piena.","authority-no-grants-elsewhere":"L’unico potere per-nodo che esiste è la scelta delle celle, e si imposta sull’installazione che le possiede — non da qui.","node-detail-network-view":"Cosa vede di questa rete","node-detail-command":"Comando","vl-no-commands":"Il device non dichiara comandi disponibili.","vl-events-title":"Sessione","vl-events-empty":"Nessun evento in memoria: la sessione non ha ancora parlato, oppure quello che ha detto è uscito dal buffer. La storia resta sul device.","vl-events-gap":"eventi non ricevuti:","vl-events-truncated":"contenuto troncato dal device","vl-events-turn-end":"— fine turno —","vl-events-done":"— fine risposta —","vl-events-writer-epoch":"— cambio scrittore —","vl-events-tool":"strumento","vl-events-tool-ok":"concluso","vl-events-tool-failed":"fallito","vl-events-usage":"consumo aggiornato","vl-events-stale":"Aggiornamento non riuscito: quello che vedi potrebbe non essere l’ultimo.","vl-cmd-phase-submitted":"inviato, in attesa di conferma","vl-cmd-phase-inflight":"in corso","vl-cmd-phase-done-ok":"completato","vl-cmd-phase-done-error":"fallito","vl-cmd-status":"stato","vl-cmd-health":"salute","vl-cmd-start":"avvia","vl-cmd-stop":"ferma","vl-cmd-restart":"riavvia","vl-cmd-version":"versione","vl-cmd-capabilities":"capacità","vl-cmd-logs":"log","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"scrivi il prompt per la sessione del device…","vl-prompt-send":"invia prompt","vl-cmd-unpair":"disaccoppia","node-grant-none":"Nessun nodo scelto: condiviso, ma verso nessuno.","node-grant-unknown":"non più in inventario","node-grant-remove":"togli","node-grant-add":"Aggiungi un nodo","node-grant-search":"Cerca fra i nodi","node-grant-no-candidates":"Nessun nodo corrisponde.","cell-scope":"Celle visibili a questo nodo","cell-scope-help":"Vale su cio’ che questo nodo elenca e su cio’ che può toccare, terminale compreso. Dentro le celle concesse resta un nodo accoppiato a pieno titolo: non è una sandbox.","cell-scope-all":"tutte le celle","cell-scope-none":"nessuna cella","cell-scope-selected":"celle selezionate","cell-scope-none-granted":"Nessuna cella scelta: questo nodo non ne vede nessuna.","cell-scope-unknown":"cella non più esistente","cell-scope-add":"Aggiungi una cella","cell-scope-search":"Cerca fra le celle","cell-scope-no-candidates":"Nessuna cella corrisponde.","cell-scope-reset-warning":"Cambiando modo l’elenco viene azzerato: tornando a «celle selezionate» andrà rifatto.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnostics","system-this-node":"this node","system-updates":"updates","system-security":"security","system-local-data":"local browser data","system-terminal":"terminal","alternate-screen":"alternate screen","alternate-screen-help":"Keeps standard tmux behaviour for new NexusCrew sessions. An application that tracks the mouse scrolls on its own; the others browse the tmux scrollback. It does not change cells already running.","tab-input":"input","tab-diagnostics":"diagnostics","input-settings-local":"Local preferences for this browser. They apply immediately to single view and decks without changing the remote node.","terminal-keyboard-gesture":"Open the virtual keyboard from the terminal","terminal-keyboard-double-tap":"Double tap (default)","terminal-keyboard-single-tap":"Single tap","terminal-keyboard-never":"Never from terminal","terminal-keyboard-gesture-help":"The keypad and STT use the separate controls below. Mouse and physical keyboard remain available.","keybar-ime-lock":"Keypad: keep the virtual keyboard closed","keybar-ime-lock-help":"ESC, arrows, PgUp/PgDn, Enter and menu send directly to the PTY without focusing a text field.","voice-ime-lock":"STT microphone: keep the virtual keyboard closed","voice-ime-lock-help":"Tapping the microphone starts or stops voice without focusing the composer.","keybar-enter-show":"Show the tall Enter keypad key","keybar-enter-show-help":"Enter stays to the right of PgUp/PgDn and spans both rows.","keybar-layout":"Keypad layout","keybar-layout-full":"Full (default)","keybar-layout-compact":"Compact","keybar-layout-help":"Compact: one row with an expand toggle that reaches the full key set without changing the preference.","input-settings-reset":"restore input defaults","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-credential-source-policy":"credential source","fleet-credential-source-policy-auto":"auto (legacy precedence)","fleet-credential-source-policy-nexuscrew-store":"NexusCrew store only","fleet-credential-source-policy-environment":"environment only","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max-preview is the default and no OpenAI/PAYG fallback is used.","fleet-provider-notice-kimi-native":'Native Kimi Code CLI uses the CLI login (device code) and its own configuration: NexusCrew never reads or copies credentials. Distinct from the Claude Code "Kimi Code" provider, which remains the managed K3 path.',"fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-recovery-client-terminal-dialog":"Complete the dialog shown in the cell terminal, then restart the cell.","settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-group-vl":"VL nodes","vl-owners-unavailable":"VL owners unreachable","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-off-hub-reconcile-pending":"Private state saved; hub revocation is still pending.","fleet-cell-label":"readable name (optional)","share-off-local-reconcile-pending":"Hub revocation confirmed; the local tunnel still needs reconciliation.","share-reverse-pool-pending":"The reverse channel was not demonstrably shut down: it is quarantined, not closed.","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","peer-vl-federated":"VL node: federated","row-vl-federated":"federated","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","vl-poll-online":"online (poll)","vl-poll-offline":"not responding","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-dismiss":"Dismiss question","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-needs-test":"For this app session, select “test voice” before spoken alerts can play.","notification-speech-unsupported":"Speech synthesis is not supported in this browser.","audio-title":"Native node audio","audio-help":"Consent and controls apply only to this device. Share and visibility do not authorize sounds.","audio-consent":"allow TTS on this node","audio-consent-help":"Allows authorized local or remote cells to deliver a voice command. You can revoke it at any time.","audio-capability":"Local capability","audio-loading":"reading local audio state…","audio-adapter":"adapter","audio-adapter-none":"none","audio-installed":"installed","audio-installed-yes":"yes","audio-installed-no":"no","audio-liveness":"availability","audio-liveness-ready":"ready to accept","audio-liveness-unavailable":"unavailable","audio-languages":"declared languages","audio-limits":"limits","audio-test":"test local audio","audio-testing":"testing audio…","audio-stop":"stop local audio","audio-stopping":"stopping audio…","audio-test-needs-consent":"Enable local consent before testing the voice.","audio-unavailable":"No native TTS adapter is available on this node.","audio-test-accepted":"The node accepted the test. It does not prove that anyone heard it.","audio-test-refused":"The node refused the test.","audio-test-unknown":"Test outcome unknown: the node could not confirm startup.","audio-stop-stopped":"Local audio stopped.","audio-stop-idle":"No local utterance to stop.","audio-groups-title":"Shared audio groups","audio-groups-help":"Chooses which devices play the voice when a cell speaks. A group is a local delivery preference, not consent. Each node keeps its own consent, ACL, availability and local Stop.","audio-groups-empty":"No group: voice plays only on this node.","audio-group-name":"group name","audio-group-mode":"delivery mode","audio-group-primary":"first available (in order)","audio-group-fanout":"all listed nodes","audio-group-targets":"exact target nodes","audio-group-local":"this node","audio-group-unavailable-target":"not currently discovered","audio-group-no-targets":"No node with an available instanceId. A group cannot use names, wildcards, or “all”.","audio-group-new":"new group","audio-group-edit":"edit","audio-group-delete":"delete","audio-group-save":"save group","audio-group-cancel":"cancel","audio-group-invalid":"A group needs a valid name and at least one exact nodeId.","audio-group-save-failed":"Could not save audio group.","node-display-label":"Name (label)","routed-node-aliases":"Routed node aliases","routed-node-aliases-help":"Visible only on this device; the route and remote name do not change.","node-local-alias":"Alias on this device","alias-on-device":"Alias on this device","reset-alias":"Reset remote name","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","cell-switcher-refreshing":"refreshing cells…","cell-switcher-empty-active":"no verified active cells","cell-switcher-not-confirmed":"status not confirmed","cell-switcher-not-active":"this cell is no longer active","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","selection-held":"highlight gone, text still held","invite-hub-only":"An invite is minted on the hub. Admitting a new node is the one thing a connected node cannot ask on another’s behalf: open NexusCrew on the hub and create the invite there.","row-private":"private","node-detail-open":"open details","node-detail-reach":"Reachability","node-detail-route":"path","node-detail-ssh":"SSH","node-detail-transport":"transport","node-detail-owner":"owner","node-detail-authority":"What this node can do","authority-owner-equivalent":"Authority equal to yours: a paired node can do on this machine everything you can do.","authority-routed":"Not paired with this machine: its authority lives on the hub that routes it.","authority-no-grants":"The only per-node power that exists is the choice of cells, below. Within those cells the authority stays full.","authority-no-grants-elsewhere":"The only per-node power that exists is the choice of cells, and it is set on the installation that owns them — not here.","node-detail-network-view":"What it sees of this network","node-detail-command":"Command","vl-no-commands":"The device declares no commands available.","vl-events-title":"Session","vl-events-empty":"No events in memory: the session has not spoken yet, or what it said has left the buffer. The history stays on the device.","vl-events-gap":"events not received:","vl-events-truncated":"content truncated by the device","vl-events-turn-end":"— end of turn —","vl-events-done":"— turn complete —","vl-events-writer-epoch":"— writer changed —","vl-events-tool":"tool","vl-events-tool-ok":"finished","vl-events-tool-failed":"failed","vl-events-usage":"usage updated","vl-events-stale":"Refresh failed: what you see may not be the latest.","vl-cmd-phase-submitted":"sent, awaiting confirmation","vl-cmd-phase-inflight":"in progress","vl-cmd-phase-done-ok":"completed","vl-cmd-phase-done-error":"failed","vl-cmd-status":"status","vl-cmd-health":"health","vl-cmd-start":"start","vl-cmd-stop":"stop","vl-cmd-restart":"restart","vl-cmd-version":"version","vl-cmd-capabilities":"capabilities","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"write the prompt for the device session…","vl-prompt-send":"send prompt","vl-cmd-unpair":"unpair","node-grant-none":"No node chosen: shared, but towards nobody.","node-grant-unknown":"no longer in the inventory","node-grant-remove":"remove","node-grant-add":"Add a node","node-grant-search":"Search the nodes","node-grant-no-candidates":"No node matches.","cell-scope":"Cells this node can see","cell-scope-help":"Applies to what this node lists and to what it can act on, terminal included. Within the granted cells it remains a fully paired node: this is not a sandbox.","cell-scope-all":"every cell","cell-scope-none":"no cell","cell-scope-selected":"selected cells","cell-scope-none-granted":"No cell chosen: this node sees none of them.","cell-scope-unknown":"cell no longer exists","cell-scope-add":"Add a cell","cell-scope-search":"Search the cells","cell-scope-no-candidates":"No cell matches.","cell-scope-reset-warning":"Switching mode clears the list: coming back to “selected cells” means choosing them again.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnóstico","system-this-node":"este nodo","system-updates":"actualizaciones","system-security":"seguridad","system-local-data":"datos locales del navegador","system-terminal":"terminal","alternate-screen":"pantalla alternativa","alternate-screen-help":"Mantiene el comportamiento estándar de tmux para las nuevas sesiones NexusCrew. Una aplicación que sigue el ratón se desplaza sola; las demás recorren el historial de tmux. No modifica las celdas ya activas.","tab-input":"entrada","tab-diagnostics":"diagnóstico","input-settings-local":"Preferencias locales de este navegador. Se aplican de inmediato a la vista única y a los decks sin cambiar el nodo remoto.","terminal-keyboard-gesture":"Abrir el teclado virtual desde el terminal","terminal-keyboard-double-tap":"Doble toque (predeterminado)","terminal-keyboard-single-tap":"Toque único","terminal-keyboard-never":"Nunca desde el terminal","terminal-keyboard-gesture-help":"El teclado auxiliar y STT usan los controles separados de abajo. El ratón y el teclado físico siguen disponibles.","keybar-ime-lock":"Teclado auxiliar: mantener cerrado el teclado virtual","keybar-ime-lock-help":"ESC, flechas, PgUp/PgDn, Enter y menú envían directamente al PTY sin enfocar un campo de texto.","voice-ime-lock":"Micrófono STT: mantener cerrado el teclado virtual","voice-ime-lock-help":"Tocar el micrófono inicia o detiene la voz sin enfocar el compositor.","keybar-enter-show":"Mostrar Enter vertical en el teclado auxiliar","keybar-enter-show-help":"Enter queda a la derecha de PgUp/PgDn y ocupa las dos filas.","keybar-layout":"Distribución del teclado auxiliar","keybar-layout-full":"Completo (predeterminado)","keybar-layout-compact":"Compacto","keybar-layout-help":"Compacto: una fila con un botón expandir que alcanza el conjunto completo sin cambiar la preferencia.","input-settings-reset":"restaurar valores de entrada","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-credential-source-policy":"origen de credencial","fleet-credential-source-policy-auto":"auto (precedencia legacy)","fleet-credential-source-policy-nexuscrew-store":"solo almacén NexusCrew","fleet-credential-source-policy-environment":"solo entorno","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max-preview es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa el login del CLI (device-code) y su propia configuración: NexusCrew no lee ni copia credenciales. Distinto del proveedor "Kimi Code" de Claude Code, que sigue siendo la ruta K3 gestionada.',"fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirma la clave API personalizada (Yes) en el terminal de la celda, luego reinicia la celda.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: en el terminal de la celda abre /config y activa "Use custom API key", luego reinicia la celda. Si la clave cambió, actualiza la credencial y reintenta.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: en el terminal de la celda ejecuta /login (código de dispositivo Kimi) o /provider, luego reinicia la celda.","fleet-recovery-client-terminal-dialog":"Completa el diálogo mostrado en el terminal de la celda, luego reinicia la celda.","settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-group-vl":"Nodos VL","vl-owners-unavailable":"Owners VL no alcanzados","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-off-hub-reconcile-pending":"Estado privado guardado; la revocación en el hub sigue pendiente.","fleet-cell-label":"nombre legible (opcional)","share-off-local-reconcile-pending":"Revocación confirmada por el hub; el túnel local aún debe reconciliarse.","share-reverse-pool-pending":"El canal inverso no se apagó de forma demostrable: queda en cuarentena, no cerrado.","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","peer-vl-federated":"Nodo VL: federado","row-vl-federated":"federado","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","vl-poll-online":"en línea (poll)","vl-poll-offline":"sin respuesta","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-dismiss":"Descartar la pregunta","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-needs-test":"Para esta sesión de la aplicación, pulsa “probar voz” antes de recibir avisos hablados.","notification-speech-unsupported":"La síntesis de voz no está disponible en este navegador.","audio-title":"Audio nativo del nodo","audio-help":"El consentimiento y los controles valen solo para este dispositivo. Compartir y visibilidad no autorizan sonidos.","audio-consent":"permitir TTS en este nodo","audio-consent-help":"Permite que celdas autorizadas, locales o remotas, entreguen un comando de voz. Puedes revocarlo en cualquier momento.","audio-capability":"Capacidad local","audio-loading":"leyendo el estado de audio local…","audio-adapter":"adaptador","audio-adapter-none":"ninguno","audio-installed":"instalado","audio-installed-yes":"sí","audio-installed-no":"no","audio-liveness":"disponibilidad","audio-liveness-ready":"listo para aceptar","audio-liveness-unavailable":"no disponible","audio-languages":"idiomas declarados","audio-limits":"límites","audio-test":"probar audio local","audio-testing":"probando audio…","audio-stop":"detener audio local","audio-stopping":"deteniendo audio…","audio-test-needs-consent":"Activa el consentimiento local antes de probar la voz.","audio-unavailable":"No hay un adaptador TTS nativo disponible en este nodo.","audio-test-accepted":"El nodo aceptó la prueba. No demuestra que alguien la haya oído.","audio-test-refused":"El nodo rechazó la prueba.","audio-test-unknown":"Resultado de prueba desconocido: el nodo no pudo confirmar el inicio.","audio-stop-stopped":"Audio local detenido.","audio-stop-idle":"No hay enunciado local que detener.","audio-groups-title":"Grupos de audio compartido","audio-groups-help":"Decide en qué dispositivos se oye la voz cuando habla una celda. Un grupo es una preferencia local de entrega, no un consentimiento. Cada nodo conserva su consentimiento, ACL, disponibilidad y Stop local.","audio-groups-empty":"Sin grupos: la voz sale solo por este nodo.","audio-group-name":"nombre del grupo","audio-group-mode":"modo de entrega","audio-group-primary":"primero disponible (en orden)","audio-group-fanout":"todos los nodos enumerados","audio-group-targets":"nodos destino exactos","audio-group-local":"este nodo","audio-group-unavailable-target":"no detectado ahora","audio-group-no-targets":"No hay ningún nodo con instanceId disponible. Un grupo no puede usar nombres, comodines ni “todos”.","audio-group-new":"nuevo grupo","audio-group-edit":"editar","audio-group-delete":"eliminar","audio-group-save":"guardar grupo","audio-group-cancel":"cancelar","audio-group-invalid":"El grupo necesita un nombre válido y al menos un nodeId exacto.","audio-group-save-failed":"No se pudo guardar el grupo de audio.","node-display-label":"Nombre (etiqueta)","routed-node-aliases":"Alias de nodos enrutados","routed-node-aliases-help":"Visibles solo en este dispositivo; la ruta y el nombre remoto no cambian.","node-local-alias":"Alias en este dispositivo","alias-on-device":"Alias en este dispositivo","reset-alias":"Restablecer nombre remoto","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","cell-switcher-refreshing":"actualizando celdas…","cell-switcher-empty-active":"no hay celdas activas verificadas","cell-switcher-not-confirmed":"estado sin confirmar","cell-switcher-not-active":"esta celda ya no está activa","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","selection-held":"resaltado perdido, texto aún retenido","invite-hub-only":"Una invitación se acuña en el hub. Admitir un nodo nuevo es lo único que un nodo conectado no puede pedir en nombre de otro: abre NexusCrew en el hub y créala allí.","row-private":"privado","node-detail-open":"abrir el detalle","node-detail-reach":"Alcanzabilidad","node-detail-route":"ruta","node-detail-ssh":"SSH","node-detail-transport":"transporte","node-detail-owner":"propietario","node-detail-authority":"Qué puede hacer este nodo","authority-owner-equivalent":"Autoridad igual a la tuya: un nodo emparejado puede hacer en esta máquina todo lo que puedes hacer tú.","authority-routed":"No está emparejado con esta máquina: su autoridad vive en el hub que lo enruta.","authority-no-grants":"El único poder por nodo que existe es la elección de celdas, más abajo. Dentro de esas celdas la autoridad sigue siendo plena.","authority-no-grants-elsewhere":"El único poder por nodo que existe es la elección de celdas, y se configura en la instalación que las posee — no aquí.","node-detail-network-view":"Qué ve de esta red","node-detail-command":"Comando","vl-no-commands":"El dispositivo no declara comandos disponibles.","vl-events-title":"Sesión","vl-events-empty":"Ningún evento en memoria: la sesión aún no ha hablado, o lo que dijo ha salido del búfer. El historial queda en el dispositivo.","vl-events-gap":"eventos no recibidos:","vl-events-truncated":"contenido truncado por el dispositivo","vl-events-turn-end":"— fin del turno —","vl-events-done":"— fin de la respuesta —","vl-events-writer-epoch":"— cambio de escritor —","vl-events-tool":"herramienta","vl-events-tool-ok":"terminada","vl-events-tool-failed":"fallida","vl-events-usage":"consumo actualizado","vl-events-stale":"Actualización fallida: puede que no estés viendo lo último.","vl-cmd-phase-submitted":"enviado, a la espera de confirmación","vl-cmd-phase-inflight":"en curso","vl-cmd-phase-done-ok":"completado","vl-cmd-phase-done-error":"fallido","vl-cmd-status":"estado","vl-cmd-health":"salud","vl-cmd-start":"iniciar","vl-cmd-stop":"detener","vl-cmd-restart":"reiniciar","vl-cmd-version":"versión","vl-cmd-capabilities":"capacidades","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"escribe el prompt para la sesión del dispositivo…","vl-prompt-send":"enviar prompt","vl-cmd-unpair":"desemparejar","node-grant-none":"Ningún nodo elegido: compartido, pero hacia nadie.","node-grant-unknown":"ya no está en el inventario","node-grant-remove":"quitar","node-grant-add":"Añadir un nodo","node-grant-search":"Buscar entre los nodos","node-grant-no-candidates":"Ningún nodo coincide.","cell-scope":"Celdas visibles para este nodo","cell-scope-help":"Se aplica a lo que este nodo lista y a lo que puede tocar, incluido el terminal. Dentro de las celdas concedidas sigue siendo un nodo emparejado por completo: no es un sandbox.","cell-scope-all":"todas las celdas","cell-scope-none":"ninguna celda","cell-scope-selected":"celdas seleccionadas","cell-scope-none-granted":"Ninguna celda elegida: este nodo no ve ninguna.","cell-scope-unknown":"la celda ya no existe","cell-scope-add":"Añadir una celda","cell-scope-search":"Buscar entre las celdas","cell-scope-no-candidates":"Ninguna celda coincide.","cell-scope-reset-warning":"Al cambiar de modo la lista se borra: volver a «celdas seleccionadas» obliga a elegirlas de nuevo.","single-view":"vista única",retract:"reducir","keybar-expand":"ampliar la barra de teclas","keybar-retract":"reducir la barra de teclas","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación de un solo uso. Hace falta la dirección SSH de este dispositivo, alcanzable por quien la use.","invite-target-local":"El nuevo dispositivo entrará en","invite-target-this":"este dispositivo","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Ol(){const e=cy(),t=e?e.getItem(ly):null;return tf.includes(t)?t:jl}function cx(e){const t=cy();if(t)try{t.setItem(ly,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Kd))}function p(e){const t=Ol(),n=gl[t]||gl[jl];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(gl[jl],e)?gl[jl][e]:e}function ux(e){return typeof window>"u"?()=>{}:(window.addEventListener(Kd,e),()=>window.removeEventListener(Kd,e))}const uy=tf;function kn(){return[N.useSyncExternalStore(ux,Ol,Ol),cx]}function Bl({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var $,H;kn();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[h,f]=N.useState([]),[m,v]=N.useState(!1);N.useEffect(()=>{let x=!0;return(async()=>{if(t)try{const O=await ws(t,u?u.split("/"):[]);if(!x)return;if(v(O.provider==="builtin"&&(O.capabilities||[]).includes("edit")),O.provider==="builtin"&&(O.capabilities||[]).includes("definitions")){const D=await Jl(t,u?u.split("/"):[]);if(!x)return;const A=new Map((O.engines||[]).map(W=>[W.id,W]));f((D.engines||[]).map(W=>{var X,ie,ce,fe,we,me,xe;return{id:W.id,label:W.label||W.id,client:((X=W.managed)==null?void 0:X.client)||"",models:[...new Set([...((ie=A.get(W.id))==null?void 0:ie.models)||[],...((ce=W.managedInfo)==null?void 0:ce.models)||[]])].filter(Boolean),defaultModel:((fe=W.managed)==null?void 0:fe.model)||((we=W.managedInfo)==null?void 0:we.defaultModel)||"",policyDefault:((me=W.managed)==null?void 0:me.permissionPolicy)||((xe=W.managed)!=null&&xe.client&&W.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{x=!1}},[t,u]);const S=(e==null?void 0:e.engine)||(($=h[0])==null?void 0:$.id)||"",y=x=>(e==null?void 0:e.models)&&e.models[x]||"",b=x=>{const O=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[x];if(O==="standard"||O==="unsafe")return O;const D=h.find(A=>A.id===x);return D?D.policyDefault:"standard"},[w,k]=N.useState(S),[C,R]=N.useState((e==null?void 0:e.model)||""),E=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((H=e==null?void 0:e.permissionPolicies)==null?void 0:H[e==null?void 0:e.engine])||"",[F,I]=N.useState(E),[K,Y]=N.useState((e==null?void 0:e.boot)??!0),[z,Z]=N.useState(!1),[G,Q]=N.useState(null);N.useEffect(()=>{h.length&&(k(x=>x||S),R(x=>x||y((e==null?void 0:e.engine)||S)||""),I(x=>x==="standard"||x==="unsafe"?x:b((e==null?void 0:e.engine)||S)))},[h.length]);const B=N.useMemo(()=>h.find(x=>x.id===w)||null,[h,w]),M=!!(B&&["claude","codex","codex-vl","agy","kimi"].includes(B.client)),j=(B==null?void 0:B.client)==="shell";function T(x){k(x);const O=h.find(D=>D.id===x);R(y(x)||(O==null?void 0:O.defaultModel)||""),I(b(x))}async function L(x){x.preventDefault(),Z(!0),Q(null);try{if(a)await s({action:"down",boot:K});else{const O=F==="standard"||F==="unsafe"?F:(B==null?void 0:B.policyDefault)||"standard";await s({action:"up",...m?{engine:w,model:C||"",...M?{permissionPolicy:O}:(B==null?void 0:B.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:K})}o()}catch(O){Q(String(O&&O.message||O)),Z(!1)}}return c.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:c.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:x=>x.stopPropagation(),onSubmit:L,children:[c.jsxs("div",{className:"nc-sheet-head",children:[c.jsx("b",{children:e==null?void 0:e.cell}),c.jsx("span",{className:"nc-sheet-state",children:p(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:p("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[p("model"),": ",e.model]}),c.jsx("small",{children:p("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:K,onChange:x=>Y(x.target.checked)}),p("remove-boot")]})]}):c.jsxs(c.Fragment,{children:[m&&h.length>0?c.jsxs("div",{className:"nc-launch-fields",children:[c.jsxs("label",{className:"nc-field",children:[p("engine"),c.jsx("select",{value:w,onChange:x=>T(x.target.value),children:h.map(x=>c.jsx("option",{value:x.id,children:x.label},x.id))})]}),!j&&c.jsxs("label",{className:"nc-field",children:[p("model"),c.jsx("input",{value:C,list:"nc-launch-models",placeholder:p("model-default"),onChange:x=>R(x.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:((B==null?void 0:B.models)||[]).map(x=>c.jsx("option",{value:x},x))})]}),M?c.jsxs("label",{className:"nc-field",children:[p("permissions"),c.jsxs("select",{value:F,onChange:x=>I(x.target.value),children:[c.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:p("fleet-standard-permissions")}),M&&F==="unsafe"&&c.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:p(j?"fleet-shell-launch-help":"launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:p("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[p("model"),": ",e.model]}),c.jsx("small",{children:p("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:K,onChange:x=>Y(x.target.checked)}),p("boot-persist")]})]}),G&&c.jsx("div",{className:"nc-err",children:G}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:z,children:p("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:z,children:p(a?"power-off":"save-and-start")})]})]})})}const jg=/^[a-z0-9-]{1,32}$/;function Go(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function dx(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",f=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!f&&(s[u]=e&&e[u]||n)}return s}function Rg(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Pg({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var m,v,S,y;const u=[],h=new Set,f=new Set;for(const b of Array.isArray(e)?e:[]){if(!b||typeof b.name!="string"||!jg.test(b.name)||b.direction==="inbound"&&b.shared!==!0)continue;const w=[b.name],k=b.name;h.add(k);const C=((m=b.tunnel)==null?void 0:m.status)||"unknown",R=C==="up",E={name:b.name,label:b.label||b.name,originalLabel:b.label||b.name,alias:null,route:w,direct:!0,instanceId:b.nodeId||null,shared:b.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,direction:b.direction||"outbound",roles:b.roles||null,rolesKnown:b.rolesKnown===!0};if(b.nodeId&&f.add(b.nodeId),!b.nodeId&&b.paired===!1){u.push({...E,status:"needs-repair",downSince:s&&s[k]||null});continue}if(((v=b.health)==null?void 0:v.auth)==="failed"||C==="degraded"&&((S=b.health)==null?void 0:S.status)==="degraded"){u.push({...E,status:"needs-repair",downSince:s&&s[k]||null});continue}if(C==="passive"||((y=b.health)==null?void 0:y.status)==="passive"){u.push({...E,status:"passive",downSince:null});continue}if(!R){u.push({...E,status:"down",downSince:s&&s[k]||null});continue}const F=n&&(n[k]||n[b.name])||null,I=o&&(o[k]||o[b.name]),K=!!(F&&!F.error&&Array.isArray(F.sessions)),Y=!!(I&&I.available===!0&&Array.isArray(I.cells));if(!K&&!Y){u.push({...E,status:"unreachable"});continue}const z=(K?F.sessions:[]).filter(Q=>Q&&typeof Q.name=="string"&&Q.name).map(Q=>({...Q,node:k,route:w,key:`${k}:${Q.name}`})),Z=Rg(I,w,k),G=new Set(Z.map(Q=>Q.tmuxSession).filter(Boolean));u.push({...E,status:"up",sessions:z,cells:Z,unmanaged:z.filter(Q=>!G.has(Q.name)),fleetAvailable:!!(I&&I.available),capabilities:I&&I.capabilities||[],engines:I&&I.engines||[],fleetProvider:I&&I.provider||null,sessionsAvailable:K,inventoryPartial:!K})}for(const b of Array.isArray(t)?t:[]){if(!b||!Array.isArray(b.route)||b.route.length<1||b.route.some(G=>!jg.test(G)))continue;const w=b.route.join("/");if(h.has(w)||b.instanceId&&f.has(b.instanceId))continue;b.instanceId&&f.add(b.instanceId);const k=b.label||b.route.join(" › "),C=b.instanceId&&a&&typeof a[b.instanceId]=="string"?a[b.instanceId]:null,R={name:b.name,label:C||k,originalLabel:k,alias:C,route:[...b.route],direct:!1,instanceId:b.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:b.health||null,lastSeen:b.lastSeen||null};if(b.stale){u.push({...R,status:"offline",downSince:s&&s[w]||b.lastSeen||null});continue}const E=n&&n[w]||null,F=o&&o[w],I=!!(E&&!E.error&&Array.isArray(E.sessions)),K=!!(F&&F.available===!0&&Array.isArray(F.cells));if(!I&&!K){u.push({...R,status:"unreachable",downSince:s&&s[w]||null});continue}const Y=(I?E.sessions:[]).filter(G=>G&&typeof G.name=="string"&&G.name).map(G=>({...G,node:w,route:b.route,key:`${w}:${G.name}`})),z=Rg(F,b.route,w),Z=new Set(z.map(G=>G.tmuxSession).filter(Boolean));u.push({...R,status:"up",sessions:Y,cells:z,unmanaged:Y.filter(G=>!Z.has(G.name)),fleetAvailable:!!(F&&F.available),capabilities:F&&F.capabilities||[],engines:F&&F.engines||[],fleetProvider:F&&F.provider||null,lastSeen:b.lastSeen||null,sessionsAvailable:I,inventoryPartial:!I})}return u.sort((b,w)=>b.label.localeCompare(w.label))}function dy(e,t={}){if(!e||typeof e!="object")return null;const n=typeof e.nodeId=="string"?e.nodeId:"";if(!n)return null;const s=typeof e.label=="string"&&e.label.trim()||typeof e.cell=="string"&&e.cell.trim()||n,o=Array.isArray(t.route)?[...t.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:e.cell??null,paired:!!e.pairedAt,online:!!e.online,lastSeen:e.lastSeen??null,generation:e.generation??null,version:e.version??null,health:e.health??null,session:e.session??null,capabilities:Array.isArray(e.capabilities)?e.capabilities:[],inflight:e.inflight??null,lastAck:e.lastAck??null,canManage:!!e.canManage,route:o,isLocal:o.length===0,ownerInstanceId:typeof t.instanceId=="string"?t.instanceId:null,ownerLabel:typeof t.label=="string"&&t.label?t.label:null}}function hx(e){var n;const t=[];for(const s of Array.isArray(e)?e:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const o=s.online===!0,a=o&&((n=s.session)==null?void 0:n.attached)===!0,u=s.ownerInstanceId||"local";t.push({kind:"vl",name:`vl-${s.nodeId.slice(0,8)}`,label:s.label,route:Array.isArray(s.route)?[...s.route]:[],instanceId:null,direct:!1,status:o?"up":"offline",downSince:o?null:s.lastSeen??null,sessions:a?[{key:`vl:${u}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,peer:s})}return t}function hy(e,t){const n=e&&Array.isArray(e.nodes)?e.nodes:[],s=new Set([t]),o=[];for(const a of n){const u=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!u||s.has(u)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(u);const h=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");o.push({instanceId:u,route:[...a.route],label:h})}return o}const fx=4e3;function nf(e,t=!0,n=0){const[s,o]=N.useState([]),a=N.useRef({});return N.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var I;let m=[],v=[],S={},y="";if(await Promise.all([k0(e).then(K=>{m=Array.isArray(K.nodes)?K.nodes:[]}).catch(()=>{}),iy(e).then(K=>{v=Array.isArray(K.nodes)?K.nodes:[]}).catch(()=>{}),P0(e).then(K=>{S=K&&typeof K.aliasesByInstanceId=="object"?K.aliasesByInstanceId:{}}).catch(()=>{}),Ht("/api/config",e).then(K=>K.json()).then(K=>{y=K&&typeof K.instanceId=="string"?K.instanceId:""}).catch(()=>{})]),!u)return;const b=[{instanceId:y||null,route:[],label:null},...hy({nodes:v},y)],w=[];if(await Promise.all(b.map(async K=>{try{const Y=await ny(e,K.route);for(const z of Y.nodes||[]){const Z=dy(z,K);Z&&w.push(Z)}}catch{}})),!u)return;const k={},C={},R=new Set(m.map(K=>K.name)),E=[];for(const K of m)((I=K.tunnel)==null?void 0:I.status)==="up"&&(K.nodeId||K.paired!==!1)&&(K.direction!=="inbound"||K.shared===!0)&&E.push([K.name]);for(const K of v)!K.stale&&Array.isArray(K.route)&&K.route.length>0&&!(K.route.length===1&&R.has(K.route[0]))&&E.push(K.route);if(await Promise.all(E.map(async K=>{const Y=K.join("/");try{k[Y]=await Jh(e,K)}catch{k[Y]={error:"unreachable"}}try{C[Y]=await ws(e,K)}catch{C[Y]={available:!1}}})),!u)return;const F=Pg({nodes:m,topology:v,remote:k,fleet:C,aliases:S,down:a.current});a.current=dx(a.current,F,Math.floor(Date.now()/1e3)),o([...Pg({nodes:m,topology:v,remote:k,fleet:C,aliases:S,down:a.current}),...hx(w)])}h();const f=setInterval(h,fx);return()=>{u=!1,clearInterval(f)}},[e,t,n]),s}const Lg=52,Ag=14;function bi({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=N.useRef(null),f=N.useRef(0),[m,v]=N.useState(!1),S=()=>{var R,E,F,I;const C=h.current;(E=(R=C==null?void 0:C.over)==null?void 0:R.classList)==null||E.remove("nc-roster-over"),(I=(F=C==null?void 0:C.source)==null?void 0:F.classList)==null||I.remove("nc-roster-dragging"),f.current&&cancelAnimationFrame(f.current),f.current=0},y=(C=!1)=>{const R=h.current;if(!R)return;const E=R.target;S(),h.current=null,v(!1);try{R.handle.releasePointerCapture(R.pointerId)}catch{}C&&E&&E!==t&&a(t,E)&&s(t,E)},b=(C,R)=>{var Z,G,Q,B,M,j,T,L,$;const E=h.current;if(!E)return;E.x=C,E.y=R;const F=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",I=(G=(Z=document.elementFromPoint(C,R))==null?void 0:Z.closest)==null?void 0:G.call(Z,F),K=u==="node"?(Q=I==null?void 0:I.dataset)==null?void 0:Q.nodeOrderKey:(B=I==null?void 0:I.dataset)==null?void 0:B.rosterKey,z=(u==="node"||((M=I==null?void 0:I.dataset)==null?void 0:M.position)===e)&&K&&K!==t&&a(t,K);E.over!==(z?I:null)&&((T=(j=E.over)==null?void 0:j.classList)==null||T.remove("nc-roster-over"),E.over=z?I:null,($=(L=E.over)==null?void 0:L.classList)==null||$.add("nc-roster-over")),E.target=z?K:null},w=()=>{const C=h.current;if(!C){f.current=0;return}const R=C.container;if(R){const E=R.getBoundingClientRect(),F=C.y<E.top+Lg?-Ag:C.y>E.bottom-Lg?Ag:0;F&&(R.scrollTop+=F,b(C.x,C.y))}f.current=requestAnimationFrame(w)};N.useEffect(()=>{const C=E=>{E.key==="Escape"&&h.current&&(E.preventDefault(),y(!1))},R=()=>y(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",R),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",R),S(),h.current=null}},[t,e,u]);const k=C=>{var I;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const R=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",E=C.currentTarget.closest(R),F=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");h.current={pointerId:C.pointerId,handle:C.currentTarget,source:E,container:F,target:null,over:null,x:C.clientX,y:C.clientY},(I=E==null?void 0:E.classList)==null||I.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}v(!0),f.current=requestAnimationFrame(w)};return c.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:p("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:k,onPointerMove:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),b(C.clientX,C.clientY))},onPointerUp:C=>{!h.current||C.pointerId!==h.current.pointerId||(C.preventDefault(),C.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{h.current&&y(!1)},children:"↕"})}const sf="nc_pins";function px(){try{const e=JSON.parse(localStorage.getItem(sf));return Array.isArray(e)?e:[]}catch{return[]}}function mx(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(sf,JSON.stringify(n))}catch{}return n}function gx(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(sf,JSON.stringify(s))}catch{}return s}function vx(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function _x(e,t){return e[0]-t[0]||e[1]-t[1]}function rf(){const[e,t]=N.useState(px),[n,s]=N.useState(ox),[o,a]=N.useState(ix),u=y=>t(b=>mx(b,y)),h=y=>Eg(n,y),f=(y,b)=>s(w=>{const k={...w,[y]:{...Eg(w,y),...b}};return ax(k)}),m=(y,b)=>e.includes(y)===e.includes(b);function v(y,b,w,k){const C=e.includes(b),R=e.includes(w);if(C===R){if(C){t(E=>gx(E,b,w));return}a(E=>{var K;const F=((K=k.find(Y=>Y.key===b))==null?void 0:K.technical)===!0,I=gs(k,e,F?"technical":"all",Fi(E,y)).map(Y=>Y.key);return sx(rx(E,y,b,w,I))})}}function S(y,b,w,k){var K;const C=((K=k.find(Y=>Y.key===b))==null?void 0:K.technical)===!0,R=e.includes(b),E=gs(k,e,C?"technical":"all",Fi(o,y)).map(Y=>Y.key).filter(Y=>e.includes(Y)===R),F=E.indexOf(b),I=E[F+w];F>=0&&I&&v(y,b,I,k)}return{pins:e,views:n,orders:o,togglePin:u,viewFor:h,updateView:f,canMoveRoster:m,moveRoster:v,stepRoster:S}}const fy="nc_node_order_v1",yx=/^[a-f0-9]{16,64}$/;function qs(e){if(yx.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(n=>typeof n=="string"&&n):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Tg(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(fy));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function wx(e,t=globalThis.localStorage){try{t.setItem(fy,JSON.stringify(e))}catch{}return e}function Dg(e=[],t=[]){const n=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=n.has(qs(s.group))?n.get(qs(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(qs(o.group))?n.get(qs(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function bx(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(qs).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(m=>o.includes(m)),...o.filter(m=>!e.includes(m))],u=a.indexOf(t),h=a.indexOf(n);a.splice(u,1);const f=a.indexOf(n);return a.splice(u<h?f+1:f,0,t),a}const qd="nexuscrew-node-preferences";function Sx(){try{window.dispatchEvent(new Event(qd))}catch{}}function py(){const[e,t]=N.useState(Tg);N.useEffect(()=>{const a=()=>t(Tg());return window.addEventListener("storage",a),window.addEventListener(qd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(qd,a)}},[]);const n=a=>Dg(a,e),s=(a,u,h)=>t(f=>{const m=bx(f,a,u,h);return wx(m),Sx(),m});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,h)=>{const f=Dg(h,e).map(qs),m=f.indexOf(a),v=f[m+u];m>=0&&v&&s(a,v,h)},nodeKey:qs}}function Dr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Bi(e){return e.status==="passive"?p("node-passive"):e.status==="down"?e.downSince?p("tunnel-down-since").replace("{t}",Dr(e.downSince)):p("tunnel-down"):e.status==="unreachable"?p("node-unreachable"):e.status==="offline"?e.lastSeen?p("node-offline-seen").replace("{t}",Dr(e.lastSeen)):p("node-offline"):e.status==="needs-repair"?p("node-needs-repair"):""}function my(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function qo(e){return e&&(e.detail||e.status)||""}function zl(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(X_(t))||0);return e.outbox.latest>s}function of(e,t={}){const n=e||{};if(!n.tmux){const s=`${n.engine||""}${n.key?`·${n.key}`:""}`,o=[s,n.model&&n.model!==s?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||p("cell-off")).trim()}}if(t.working===!0){const s=p("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:p("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||p("cell-on")).trim()}}function gy(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function af(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=Go([],o.tmuxSession),h=of(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:zl(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:gy(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Go([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:zl(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Fl(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},f=Go(s,u.tmuxSession||u.cell),m=of(u,h);return{type:"cell",value:u,key:f,label:u.cell,live:!!u.tmux,fresh:zl(h,f,t),activity:h.activity||u.activity||0,working:m.working,subtitle:m.subtitle,searchText:gy(u,h)}}),...(n.unmanaged||[]).map(u=>{const h=Go(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:zl(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const lf=9,$l=.2,xx=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Mr=/^[a-f0-9]{16,64}$/,Vd=e=>xx.test(e)&&new Set(e.split("/")).size===e.split("/").length;function ys(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!Vd(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Mr.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&Vd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function $n(e){const t=ys(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const vy=9,_y=24,ta=11,kx=e=>{const t=Number(e);return t>=vy&&t<=_y?t:ta};function Lr(){return{columns:[]}}function ki(e){return e.columns.flatMap(t=>t.tiles.map(n=>$n(n)))}function Cx(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push($n(o.tiles[s]));return t}const Fr=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function cf(e,t,n,s){const o=ys(t);if(!o||ki(e).includes($n(o))||ki(e).length>=lf)return e;const a=Fr(e),u={session:o.session,height:1,fontSize:ta,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const h=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function yy(e,t){const n=$n(t);if(!n||ki(e).includes(n)||ki(e).length>=lf)return e;const s=ki(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let v=0;for(let S=1;S<e.columns.length;S+=1)e.columns[S].tiles.length<e.columns[v].tiles.length&&(v=S);return cf(e,t,{col:v,row:e.columns[v].tiles.length})}const a=[...Cx(e),n],u=new Map(e.columns.flatMap(v=>v.tiles.map(S=>[$n(S),S]))),h=ys(t),f=e.columns.length?e.columns.reduce((v,S)=>v+(Number(S.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(v,S)=>{var y;return{width:((y=e.columns[S])==null?void 0:y.width)||f,tiles:[]}});return a.forEach((v,S)=>{const y=ys(v);if(!y)return;const b=u.get(v)||(v===n?h:{})||{},w={session:y.session,height:b.height||1,fontSize:b.fontSize||ta};y.node&&(w.node=y.node),b.ownerId&&(w.ownerId=b.ownerId),b.unavailable===!0&&(w.unavailable=!0),m[S%o].tiles.push(w)}),{columns:m.filter(v=>v.tiles.length)}}function Hl(e,t){const n=$n(t),s=Fr(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>$n(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function Ex(e,t,n){const s=$n(t);if(!ki(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>$n(a)===s);return cf(Hl(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function Nx(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Fr(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get($n(a));if(!u)continue;const h=ys(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),n=!0)}return n?Ys(s):e}function jx(e,t,n){const s=Fr(e);return s.columns[t]&&(s.columns[t].width=Math.max($l,Number(n)||1)),s}function Rx(e,t,n,s){const o=Fr(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max($l,Number(s)||1)),o}function Px(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=Fr(e),u=a.columns[t].tiles[n],h=Number(u.fontSize)||ta;return u.fontSize=Math.max(vy,Math.min(_y,h+(Number(s)||0))),a}function Lx(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function Mg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Ys(e){if(!e||!Array.isArray(e.columns))return Lr();const t=e.columns.map(s=>({width:Math.max($l,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&Vd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Mr.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max($l,Number(o.height)||1),fontSize:kx(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has($n(o))&&n.add($n(o))&&n.size<=lf);return{columns:t.filter(s=>s.tiles.length>0)}}const wy=/^[a-z0-9-]{1,32}$/,Ax=/^[A-Za-z0-9._-]{1,32}$/,Tx=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,Dx=320;function Yd(e){return typeof e=="string"&&wy.test(e)}const Mx=64;function Ir(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=Mx&&!/[\x00-\x1f\x7f]/.test(t)}function vs(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function by(e){if(typeof e!="string"||!e||e.length>Dx||e.startsWith("-")||/[\0-\x20\x7f]/.test(e))return!1;if(!e.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(e);const t=e.indexOf("@");return t<=0||t!==e.lastIndexOf("@")?!1:Ax.test(e.slice(0,t))&&Tx.test(e.slice(t+1))}function Ig(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function Ix({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!Yd(o))return{ok:!1,error:"err-node-name"};if(!by(a))return{ok:!1,error:"err-ssh"};const u=Ig(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=Ig(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const f={name:o,ssh:a};return u!==null&&(f.sshPort=u),h!==null&&(f.remotePort=h),{ok:!0,value:f}}function Ox(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Gd(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?Ox(e.since,t):null}}const Bx=new Set(["v","instanceId","port","label","invite"]),zx=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Fx(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function $x(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let n;try{n=JSON.parse(Fx(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?Bx:n.v===2?zx:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!wy.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!by(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function Hx(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||n.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?vs(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const Ux=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],Wx=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function uf(e){const t=e&&typeof e=="object"?e.actionRequired:null;return!t||typeof t!="object"||!Ux.includes(t.code)||!Wx.includes(t.recovery)?null:{code:t.code,recovery:t.recovery,text:p(`fleet-recovery-${t.recovery}`)}}let Xd={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function Og(){return Xd}function Sy(e={}){return Xd={sessions:Array.isArray(e.sessions)?e.sessions:[],cells:Array.isArray(e.cells)?e.cells:[],nodeGroups:Array.isArray(e.nodeGroups)?e.nodeGroups:[],localNodeId:typeof e.localNodeId=="string"?e.localNodeId:"",localFresh:e.localFresh===!0,refreshedAt:Number.isFinite(e.refreshedAt)?e.refreshedAt:0},Xd}const kr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function Kx({onPick:e,token:t,onSettings:n,onOpenVlSession:s}){const[o,a]=kn(),u=nf(t),[h,f]=N.useState(null),[m,v]=N.useState(null),[S,y]=N.useState(""),[b,w]=N.useState(""),[k,C]=N.useState({bind:"127.0.0.1",port:""}),[R,E]=N.useState(""),[F,I]=N.useState([]),[K,Y]=N.useState([]),[z,Z]=N.useState({}),[G,Q]=N.useState(new Set),[B,M]=N.useState(null),[j,T]=N.useState(null),{pins:L,orders:$,togglePin:H,viewFor:x,updateView:O,canMoveRoster:D,moveRoster:A,stepRoster:W}=rf(),{groupsFor:X,moveNode:ie,stepNode:ce,nodeKey:fe}=py(),we=X(u);N.useEffect(()=>{Sy({sessions:h||[],cells:F,nodeGroups:u,localNodeId:R})},[h,F,u,R]),N.useEffect(()=>{const U=new Map;for(const ue of F)U.set(kr(ue.cell),!!ue.boot);for(const ue of u){const de=ue.route||[ue.name];for(const ge of ue.cells||[])U.set(kr(ge.cell,de),!!ge.boot)}Z(ue=>{let de=!1;const ge={...ue};for(const[De,_e]of Object.entries(ue))U.has(De)&&U.get(De)===_e&&(delete ge[De],de=!0);return de?ge:ue})},[F,u]);async function me(){try{const ue=await(await Ht("/api/sessions",t)).json();ue.error?(v(ue.error),f([])):(v(null),f(ue.sessions||[]))}catch(U){v(String(U)),f([])}try{const U=await ws(t);I(U.available?U.cells||[]:[]),Y(U.available?U.capabilities||[]:[])}catch{I([]),Y([])}}N.useEffect(()=>{me(),Ht("/api/config",t).then(ue=>ue.json()).then(ue=>{w(ue.version||""),C({bind:ue.bind||"127.0.0.1",port:ue.port||""}),E(Mr.test(String(ue.instanceId||""))?ue.instanceId:"")}).catch(()=>{});const U=setInterval(me,4e3);return()=>clearInterval(U)},[]);async function xe(){if(!k.port)return;const U=`http://${k.bind}:${k.port}/#token=${t}`;try{await navigator.clipboard.writeText(U)}catch{}}function $e(U,ue,de){const ge=kr(U,ue);Z(De=>({...De,[ge]:!!de}))}function ft(U,ue=[]){const de=kr(U.cell,ue);return Object.prototype.hasOwnProperty.call(z,de)?z[de]:!!U.boot}async function qe(U,ue,de=[]){U.stopPropagation();const ge=kr(ue.cell,de),De=!ft(ue,de);$e(ue.cell,de,De),Q(_e=>new Set(_e).add(ge));try{await Q_(t,{cell:ue.cell,enabled:De},de),de.length||I(_e=>_e.map(Ee=>Ee.cell===ue.cell?{...Ee,boot:De}:Ee))}catch(_e){Z(Ee=>{const nt={...Ee};return delete nt[ge],nt}),v(String((_e==null?void 0:_e.message)||_e))}finally{Q(_e=>{const Ee=new Set(_e);return Ee.delete(ge),Ee})}}async function Ae(U){if(!B)return;const{cell:ue}=B,de=Array.isArray(B.route)?B.route:[];if(U.action==="up"){const ge=await Gh(t,{cell:ue,boot:!!U.boot,...U.engine?{engine:U.engine}:{},...U.model!==void 0?{model:U.model}:{},...U.permissionPolicy?{permissionPolicy:U.permissionPolicy}:{}},de),De=uf(ge);De&&v(De.text),$e(ue,de,!!U.boot)}else await Il(t,{cell:ue,boot:!!U.boot},de),U.boot&&$e(ue,de,!1);me()}async function Rt(U,ue=[]){try{await Xh(t,U,ue)}catch{return}me()}async function Vt(U,ue,de=[]){try{await ey(t,U,ue,de)}catch{return}me()}async function Oe(U){if(!(!(U!=null&&U.direct)||j)){T(U.name);try{await ef(t,U.name,U.tunnelStatus==="up"?"down":"up")}catch{}T(null)}}async function Pt(U){if(!(U!=null&&U.direct))return;const ue=window.prompt(p("rename-node-prompt"),U.label||U.name);if(ue===null)return;const de=String(ue).trim();if(!Ir(de)){window.alert(p("rename-node-invalid"));return}try{await sy(t,U.name,de)}catch(ge){window.alert(String((ge==null?void 0:ge.message)||ge))}}const bt=N.useMemo(()=>new Map((h||[]).map(U=>[U.name,U])),[h]),dt=N.useMemo(()=>new Set(F.map(U=>U.tmuxSession)),[F]),ht=N.useMemo(()=>(h||[]).filter(U=>!dt.has(U.name)),[h,dt]),Qe=N.useMemo(()=>af(F,ht,bt),[F,ht,bt]),ot=x("local"),oe=N.useMemo(()=>gs(Qe,L,ot.filter,Fi($,"local")).filter(U=>Ng(U,S)),[Qe,L,ot.filter,S,$]),ke=we.reduce((U,ue)=>U+(ue.cells||[]).length+(ue.unmanaged||[]).filter(de=>!de.technical).length,0),Te=gs(Qe,L,"all",Fi($,"local")).length+ke,ae=Qe.filter(U=>U.live).length+we.reduce((U,ue)=>U+Fl(ue).rawItems.filter(de=>de.live).length,0),re=(h||[]).filter(U=>U.attached).length+we.reduce((U,ue)=>U+(ue.sessions||[]).filter(de=>de.attached).length,0),Pe=Math.min(re,ae),q=k.port?`${k.bind}:${k.port}`:k.bind;function te(U,ue=null,de=Qe){var Mt,ct;const ge=Array.isArray(ue==null?void 0:ue.route)?ue.route:[],De=ge.join("/"),_e=De||"local",Ee=ge.length?ue==null?void 0:ue.instanceId:R,nt=(et,Zt)=>e({session:et,...De?{node:De}:{},...Mr.test(String(Ee||""))?{ownerId:Ee}:{},...typeof Zt=="string"&&Zt?{cellName:Zt}:{}}),at=D;if(U.type==="cell"){const et=U.value,Zt=ge.length?((ue==null?void 0:ue.sessions)||[]).find(pt=>pt.name===et.tmuxSession):bt.get(et.tmuxSession),ni=et.degraded?p("cell-degraded"):U.working?U.subtitle:et.tmux?p("cell-idle"):p("cell-off"),Wn=ge.length===0||((ue==null?void 0:ue.capabilities)||[]).includes(et.active?"down":"up"),ui=ge.length===0?K.includes("boot"):((ue==null?void 0:ue.capabilities)||[]).includes("boot"),he=ft(et,ge),je=kr(et.cell,ge),Ke=`${p(he?"boot-disable":"boot-enable")} ${et.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":U.key,"data-position":_e,children:[c.jsx(bi,{position:_e,itemKey:U.key,label:et.cell,canMove:at,onMove:(pt,vt)=>A(_e,pt,vt,de),onStep:pt=>W(_e,U.key,pt,de)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>et.tmux&&nt(et.tmuxSession,et.cell),title:ni,"aria-label":`${et.cell}, ${ni}`,children:[c.jsx("span",{className:`dot ${et.degraded?"warn":et.tmux?`on${U.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:et.cell}),c.jsx("small",{title:U.subtitle,children:U.subtitle})]})]}),U.activity?c.jsx("span",{className:"nc-rel",children:Dr(U.activity)}):null,U.fresh&&((Mt=Zt==null?void 0:Zt.outbox)==null?void 0:Mt.count)>0&&c.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Zt.outbox.count}),c.jsx("button",{className:`nc-act pin${L.includes(U.key)?" on":""}`,"aria-label":`${p("pin")} ${et.cell}`,title:p("pin"),onClick:()=>H(U.key),children:L.includes(U.key)?"★":"☆"}),ui&&c.jsx("button",{className:`nc-act boot${he?" on":""}`,disabled:G.has(je),onClick:pt=>qe(pt,et,ge),title:Ke,"aria-label":Ke,children:c.jsx(Ze,{name:"boot",size:16})}),Wn&&c.jsx("button",{className:`nc-act power${et.tmux?" on":""}${et.degraded?" warn":""}`,onClick:()=>M(ge.length?{...et,boot:he,route:ge,availableEngines:(ue==null?void 0:ue.engines)||[]}:{...et,boot:he}),title:et.active?p("power-off"):p("power-on"),"aria-label":`${et.active?p("power-off"):p("power-on")} ${et.cell}`,children:c.jsx(Ze,{name:"power",size:16})})]},U.key)}const Je=U.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":U.key,"data-position":_e,children:[c.jsx(bi,{position:_e,itemKey:U.key,label:Je.name,canMove:at,onMove:(et,Zt)=>A(_e,et,Zt,de),onStep:et=>W(_e,U.key,et,de)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>nt(Je.name),children:[c.jsx("span",{className:Je.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Je.name}),c.jsx("small",{children:Je.preview?Je.preview:Je.cmd?Je.cmd:p("windows").replace("{n}",String(Je.windows||0))})]})]}),U.activity?c.jsx("span",{className:"nc-rel",children:Dr(U.activity)}):null,U.fresh&&((ct=Je.outbox)==null?void 0:ct.count)>0&&c.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Je.outbox.count}),c.jsx("button",{className:`nc-act pin${L.includes(U.key)?" on":""}`,"aria-label":`${p("pin")} ${Je.name}`,title:p("pin"),onClick:()=>H(U.key),children:L.includes(U.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${Je.technical?" on":""}`,title:Je.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${Je.technical?p("mark-normal"):p("mark-technical")} ${Je.name}`,onClick:()=>Vt(Je.name,!Je.technical,ge),children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),"aria-label":`${p("terminate")} ${Je.name}`,onClick:()=>{window.confirm(p("terminate-confirm").replace("{name}",Je.name))&&Rt(Je.name,ge)},children:"⋯"})]},U.key)}return c.jsxs("div",{className:"nc-home",children:[c.jsxs("header",{className:"nc-home-head",children:[c.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",c.jsx("span",{className:"nc-cursor"})]}),c.jsxs("div",{className:"nc-home-sub",children:[p("fleet-tmux")," · ",ae," ",p("sessions"),Pe>0&&` · ${Pe} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:p("settings"),children:c.jsx(Ze,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:me,title:p("refresh"),children:c.jsx(Ze,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[Te>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:p("filter-placeholder"),"aria-label":p("filter-placeholder"),value:S,onChange:U=>y(U.target.value)}),m&&c.jsx("div",{className:"nc-err",children:m}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(Xu,{label:p("position-local"),count:oe.length,state:ot,dotClass:"on",onToggle:()=>O("local",{open:!ot.open}),onFilter:U=>O("local",{filter:U})}),ot.open&&oe.map(U=>te(U,null,Qe)),ot.open&&h===null&&c.jsx("div",{className:"nc-empty",children:p("loading-fleet")}),ot.open&&h!==null&&oe.length===0&&!m&&c.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]}),we.map(U=>{const de=my(U.health,{passive:"warn"})||(U.status==="up"?"on":U.status==="passive"?"":"warn"),ge=U.health?qo(U.health):U.status==="up"?"":Bi(U),_e=(U.route&&U.route.length?U.route:[U.name]).join("/"),Ee=x(_e);if(U.kind==="vl")return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":_e,"data-node-order-key":fe(U),children:[c.jsx(Xu,{label:U.label||U.name,count:U.sessions.length,state:Ee,dotClass:de,dotTitle:ge,detail:U.status==="up"?"":Bi(U),onToggle:()=>O(_e,{open:!Ee.open}),onFilter:ct=>O(_e,{filter:ct})}),U.status==="up"&&Ee.open&&U.sessions.map(ct=>c.jsx("div",{className:"nc-mcard nc-vl-session-row",children:c.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(U.peer),"aria-label":`${U.label||U.name}: ${ct.name}`,children:[c.jsx("span",{className:"dot on"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:ct.name}),c.jsx("small",{children:p("vl-events-title")})]})]})},ct.key)),U.status==="up"&&Ee.open&&U.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]},`nodo-vl-${_e}-${U.name}`);const{rawItems:nt}=Fl(U),at=gs(nt,L,Ee.filter,Fi($,_e)).filter(ct=>Ng(ct,S)),Je=U.direct&&U.health&&U.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${U.tunnelStatus==="up"?" on":""}`,disabled:j===U.name,title:U.tunnelStatus==="up"?p("power-off"):p("power-on"),"aria-label":`${U.tunnelStatus==="up"?p("power-off"):p("power-on")} ${U.label||U.name}`,onClick:()=>Oe(U),children:c.jsx(Ze,{name:"power",size:15})}):null,Mt=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:fe(U),label:U.label||U.name,onMove:(ct,et)=>ie(ct,et,u),onStep:ct=>ce(fe(U),ct,u)}),U.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${U.label||U.name}`,onClick:()=>Pt(U),children:"✎"}),Je]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":_e,"data-node-order-key":fe(U),children:[c.jsx(Xu,{label:U.label||U.name,count:at.length,state:Ee,dotClass:de,dotTitle:ge,detail:U.status==="up"?"":U.health&&qo(U.health)||Bi(U),onToggle:()=>O(_e,{open:!Ee.open}),onFilter:ct=>O(_e,{filter:ct}),onRename:U.direct?()=>Pt(U):null,action:Mt}),U.status==="up"&&Ee.open&&at.map(ct=>te(ct,U,nt)),U.status==="up"&&Ee.open&&at.length===0&&c.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]},`nodo-${_e}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:xe,title:p("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[b&&c.jsxs("span",{className:"nc-home-version",children:["v",b]}),c.jsxs("span",{className:"nc-home-endpoint",children:[q," · ",p("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:U=>U.stopPropagation(),children:uy.map((U,ue)=>c.jsxs("span",{children:[ue>0&&" · ",c.jsx("button",{className:`nc-lang-btn${o===U?" on":""}`,onClick:()=>a(U),title:U,children:U.toUpperCase()})]},U))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:p("fleet-new-cell"),"aria-label":p("fleet-new-cell"),children:"+"}),B&&c.jsx(Bl,{cell:B,token:t,route:Array.isArray(B.route)?B.route:[],onConfirm:Ae,onClose:()=>M(null)})]})}function Xu({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:f=null,action:m=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:f?v=>{v.preventDefault(),f()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${p("node-sessions").replace("{n}",String(t))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),c.jsx("span",{className:`dot ${s}`,title:o}),c.jsxs("span",{className:"nc-mobile-position-copy",children:[c.jsx("b",{children:e}),c.jsx("small",{children:a||p("node-sessions").replace("{n}",String(t))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${p("filter-placeholder")}`,title:p(`view-${n.filter}`),onChange:v=>h(v.target.value),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]}),m]})}/**
41
41
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
42
42
  * @license MIT
43
43
  *
@@ -54,13 +54,13 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
54
54
 
55
55
  `+e.stack):new Error(e.message+`
56
56
 
57
- `+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)}},ak=new ok;function Rl(e){lk(e)||ak.onUnexpectedError(e)}var th="Canceled";function lk(e){return e instanceof ck?!0:e instanceof Error&&e.name===th&&e.message===th}var ck=class extends Error{constructor(){super(th),this.name=this.message}};function uk(e){return new Error(`Illegal argument: ${e}`)}var Hg=class nh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof nh)return t;let n=new nh;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ih=class My extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,My.prototype)}};function zn(e,t=0){return e[e.length-(1+t)]}var dk;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(dk||(dk={}));function hk(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var Iy;(e=>{function t(I){return I&&typeof I=="object"&&typeof I[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(I){yield I}e.single=o;function a(I){return t(I)?I:o(I)}e.wrap=a;function u(I){return I||n}e.from=u;function*h(I){for(let K=I.length-1;K>=0;K--)yield I[K]}e.reverse=h;function f(I){return!I||I[Symbol.iterator]().next().done===!0}e.isEmpty=f;function m(I){return I[Symbol.iterator]().next().value}e.first=m;function v(I,K){let Y=0;for(let z of I)if(K(z,Y++))return!0;return!1}e.some=v;function S(I,K){for(let Y of I)if(K(Y))return Y}e.find=S;function*y(I,K){for(let Y of I)K(Y)&&(yield Y)}e.filter=y;function*b(I,K){let Y=0;for(let z of I)yield K(z,Y++)}e.map=b;function*w(I,K){let Y=0;for(let z of I)yield*K(z,Y++)}e.flatMap=w;function*k(...I){for(let K of I)yield*K}e.concat=k;function C(I,K,Y){let z=Y;for(let Z of I)z=K(z,Z);return z}e.reduce=C;function*R(I,K,Y=I.length){for(K<0&&(K+=I.length),Y<0?Y+=I.length:Y>I.length&&(Y=I.length);K<Y;K++)yield I[K]}e.slice=R;function E(I,K=Number.POSITIVE_INFINITY){let Y=[];if(K===0)return[Y,I];let z=I[Symbol.iterator]();for(let Z=0;Z<K;Z++){let G=z.next();if(G.done)return[Y,e.empty()];Y.push(G.value)}return[Y,{[Symbol.iterator](){return z}}]}e.consume=E;async function F(I){let K=[];for await(let Y of I)K.push(Y);return Promise.resolve(K)}e.asyncToArray=F})(Iy||(Iy={}));function Xs(e){if(Iy.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function fk(...e){return jt(()=>Xs(e))}function jt(e){return{dispose:hk(()=>{e()})}}var Oy=class By{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{Xs(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?By.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)}};Oy.DISABLE_DISPOSED_WARNING=!1;var _s=Oy,st=class{constructor(){this._store=new _s,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)}};st.None=Object.freeze({dispose(){}});var Or=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},zi=typeof window=="object"?window:globalThis,sh=class rh{constructor(t){this.element=t,this.next=rh.Undefined,this.prev=rh.Undefined}};sh.Undefined=new sh(void 0);var Tt=sh,Ug=class{constructor(){this._first=Tt.Undefined,this._last=Tt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Tt.Undefined}clear(){let e=this._first;for(;e!==Tt.Undefined;){let t=e.next;e.prev=Tt.Undefined,e.next=Tt.Undefined,e=t}this._first=Tt.Undefined,this._last=Tt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Tt(e);if(this._first===Tt.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Tt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Tt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Tt.Undefined&&e.next!==Tt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Tt.Undefined&&e.next===Tt.Undefined?(this._first=Tt.Undefined,this._last=Tt.Undefined):e.next===Tt.Undefined?(this._last=this._last.prev,this._last.next=Tt.Undefined):e.prev===Tt.Undefined&&(this._first=this._first.next,this._first.prev=Tt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Tt.Undefined;)yield e.element,e=e.next}},pk=globalThis.performance&&typeof globalThis.performance.now=="function",mk=class zy{static create(t){return new zy(t)}constructor(t){this._now=pk&&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}},mn;(e=>{e.None=()=>st.None;function t(M,j){return S(M,()=>{},0,void 0,!0,void 0,j)}e.defer=t;function n(M){return(j,T=null,L)=>{let $=!1,H;return H=M(x=>{if(!$)return H?H.dispose():$=!0,j.call(T,x)},null,L),$&&H.dispose(),H}}e.once=n;function s(M,j,T){return m((L,$=null,H)=>M(x=>L.call($,j(x)),null,H),T)}e.map=s;function o(M,j,T){return m((L,$=null,H)=>M(x=>{j(x),L.call($,x)},null,H),T)}e.forEach=o;function a(M,j,T){return m((L,$=null,H)=>M(x=>j(x)&&L.call($,x),null,H),T)}e.filter=a;function u(M){return M}e.signal=u;function h(...M){return(j,T=null,L)=>{let $=fk(...M.map(H=>H(x=>j.call(T,x))));return v($,L)}}e.any=h;function f(M,j,T,L){let $=T;return s(M,H=>($=j($,H),$),L)}e.reduce=f;function m(M,j){let T,L={onWillAddFirstListener(){T=M($.fire,$)},onDidRemoveLastListener(){T==null||T.dispose()}},$=new Ne(L);return j==null||j.add($),$.event}function v(M,j){return j instanceof Array?j.push(M):j&&j.add(M),M}function S(M,j,T=100,L=!1,$=!1,H,x){let O,D,A,W=0,X,ie={leakWarningThreshold:H,onWillAddFirstListener(){O=M(fe=>{W++,D=j(D,fe),L&&!A&&(ue.fire(D),D=void 0),X=()=>{let we=D;D=void 0,A=void 0,(!L||W>1)&&ue.fire(we),W=0},typeof T=="number"?(clearTimeout(A),A=setTimeout(X,T)):A===void 0&&(A=0,queueMicrotask(X))})},onWillRemoveListener(){$&&W>0&&(X==null||X())},onDidRemoveLastListener(){X=void 0,O.dispose()}},ue=new Ne(ie);return x==null||x.add(ue),ue.event}e.debounce=S;function y(M,j=0,T){return e.debounce(M,(L,$)=>L?(L.push($),L):[$],j,void 0,!0,void 0,T)}e.accumulate=y;function b(M,j=(L,$)=>L===$,T){let L=!0,$;return a(M,H=>{let x=L||!j(H,$);return L=!1,$=H,x},T)}e.latch=b;function w(M,j,T){return[e.filter(M,j,T),e.filter(M,L=>!j(L),T)]}e.split=w;function k(M,j=!1,T=[],L){let $=T.slice(),H=M(D=>{$?$.push(D):O.fire(D)});L&&L.add(H);let x=()=>{$==null||$.forEach(D=>O.fire(D)),$=null},O=new Ne({onWillAddFirstListener(){H||(H=M(D=>O.fire(D)),L&&L.add(H))},onDidAddFirstListener(){$&&(j?setTimeout(x):x())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return L&&L.add(O),O.event}e.buffer=k;function C(M,j){return(T,L,$)=>{let H=j(new E);return M(function(x){let O=H.evaluate(x);O!==R&&T.call(L,O)},void 0,$)}}e.chain=C;let R=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(j){return this.steps.push(j),this}forEach(j){return this.steps.push(T=>(j(T),T)),this}filter(j){return this.steps.push(T=>j(T)?T:R),this}reduce(j,T){let L=T;return this.steps.push($=>(L=j(L,$),L)),this}latch(j=(T,L)=>T===L){let T=!0,L;return this.steps.push($=>{let H=T||!j($,L);return T=!1,L=$,H?$:R}),this}evaluate(j){for(let T of this.steps)if(j=T(j),j===R)break;return j}}function F(M,j,T=L=>L){let L=(...O)=>x.fire(T(...O)),$=()=>M.on(j,L),H=()=>M.removeListener(j,L),x=new Ne({onWillAddFirstListener:$,onDidRemoveLastListener:H});return x.event}e.fromNodeEventEmitter=F;function I(M,j,T=L=>L){let L=(...O)=>x.fire(T(...O)),$=()=>M.addEventListener(j,L),H=()=>M.removeEventListener(j,L),x=new Ne({onWillAddFirstListener:$,onDidRemoveLastListener:H});return x.event}e.fromDOMEventEmitter=I;function K(M){return new Promise(j=>n(M)(j))}e.toPromise=K;function Y(M){let j=new Ne;return M.then(T=>{j.fire(T)},()=>{j.fire(void 0)}).finally(()=>{j.dispose()}),j.event}e.fromPromise=Y;function z(M,j){return M(T=>j.fire(T))}e.forward=z;function Z(M,j,T){return j(T),M(L=>j(L))}e.runAndSubscribe=Z;class G{constructor(j,T){this._observable=j,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{j.addObserver(this)},onDidRemoveLastListener:()=>{j.removeObserver(this)}};this.emitter=new Ne(L),T&&T.add(this.emitter)}beginUpdate(j){this._counter++}handlePossibleChange(j){}handleChange(j,T){this._hasChanged=!0}endUpdate(j){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Q(M,j){return new G(M,j).emitter.event}e.fromObservable=Q;function B(M){return(j,T,L)=>{let $=0,H=!1,x={beginUpdate(){$++},endUpdate(){$--,$===0&&(M.reportChanges(),H&&(H=!1,j.call(T)))},handlePossibleChange(){},handleChange(){H=!0}};M.addObserver(x),M.reportChanges();let O={dispose(){M.removeObserver(x)}};return L instanceof _s?L.add(O):Array.isArray(L)&&L.push(O),O}}e.fromObservableLight=B})(mn||(mn={}));var oh=class ah{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ah._idPool++}`,ah.all.add(this)}start(t){this._stopWatch=new mk,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}}};oh.all=new Set,oh._idPool=0;var gk=oh,vk=-1,Fy=class $y{constructor(t,n,s=($y._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)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=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let f=new wk(h,a);this._errorHandler(f)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};Fy._idPool=1;var _k=Fy,yk=class Hy{constructor(t){this.value=t}static create(){let t=new Error;return new Hy(t.stack??"")}print(){console.warn(this.value.split(`
57
+ `+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)}},ak=new ok;function Rl(e){lk(e)||ak.onUnexpectedError(e)}var th="Canceled";function lk(e){return e instanceof ck?!0:e instanceof Error&&e.name===th&&e.message===th}var ck=class extends Error{constructor(){super(th),this.name=this.message}};function uk(e){return new Error(`Illegal argument: ${e}`)}var Hg=class nh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof nh)return t;let n=new nh;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ih=class My extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,My.prototype)}};function zn(e,t=0){return e[e.length-(1+t)]}var dk;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(dk||(dk={}));function hk(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var Iy;(e=>{function t(I){return I&&typeof I=="object"&&typeof I[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(I){yield I}e.single=o;function a(I){return t(I)?I:o(I)}e.wrap=a;function u(I){return I||n}e.from=u;function*h(I){for(let K=I.length-1;K>=0;K--)yield I[K]}e.reverse=h;function f(I){return!I||I[Symbol.iterator]().next().done===!0}e.isEmpty=f;function m(I){return I[Symbol.iterator]().next().value}e.first=m;function v(I,K){let Y=0;for(let z of I)if(K(z,Y++))return!0;return!1}e.some=v;function S(I,K){for(let Y of I)if(K(Y))return Y}e.find=S;function*y(I,K){for(let Y of I)K(Y)&&(yield Y)}e.filter=y;function*b(I,K){let Y=0;for(let z of I)yield K(z,Y++)}e.map=b;function*w(I,K){let Y=0;for(let z of I)yield*K(z,Y++)}e.flatMap=w;function*k(...I){for(let K of I)yield*K}e.concat=k;function C(I,K,Y){let z=Y;for(let Z of I)z=K(z,Z);return z}e.reduce=C;function*R(I,K,Y=I.length){for(K<0&&(K+=I.length),Y<0?Y+=I.length:Y>I.length&&(Y=I.length);K<Y;K++)yield I[K]}e.slice=R;function E(I,K=Number.POSITIVE_INFINITY){let Y=[];if(K===0)return[Y,I];let z=I[Symbol.iterator]();for(let Z=0;Z<K;Z++){let G=z.next();if(G.done)return[Y,e.empty()];Y.push(G.value)}return[Y,{[Symbol.iterator](){return z}}]}e.consume=E;async function F(I){let K=[];for await(let Y of I)K.push(Y);return Promise.resolve(K)}e.asyncToArray=F})(Iy||(Iy={}));function Xs(e){if(Iy.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function fk(...e){return jt(()=>Xs(e))}function jt(e){return{dispose:hk(()=>{e()})}}var Oy=class By{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{Xs(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?By.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)}};Oy.DISABLE_DISPOSED_WARNING=!1;var _s=Oy,st=class{constructor(){this._store=new _s,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)}};st.None=Object.freeze({dispose(){}});var Or=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},zi=typeof window=="object"?window:globalThis,sh=class rh{constructor(t){this.element=t,this.next=rh.Undefined,this.prev=rh.Undefined}};sh.Undefined=new sh(void 0);var Tt=sh,Ug=class{constructor(){this._first=Tt.Undefined,this._last=Tt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Tt.Undefined}clear(){let e=this._first;for(;e!==Tt.Undefined;){let t=e.next;e.prev=Tt.Undefined,e.next=Tt.Undefined,e=t}this._first=Tt.Undefined,this._last=Tt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Tt(e);if(this._first===Tt.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Tt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Tt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Tt.Undefined&&e.next!==Tt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Tt.Undefined&&e.next===Tt.Undefined?(this._first=Tt.Undefined,this._last=Tt.Undefined):e.next===Tt.Undefined?(this._last=this._last.prev,this._last.next=Tt.Undefined):e.prev===Tt.Undefined&&(this._first=this._first.next,this._first.prev=Tt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Tt.Undefined;)yield e.element,e=e.next}},pk=globalThis.performance&&typeof globalThis.performance.now=="function",mk=class zy{static create(t){return new zy(t)}constructor(t){this._now=pk&&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}},mn;(e=>{e.None=()=>st.None;function t(M,j){return S(M,()=>{},0,void 0,!0,void 0,j)}e.defer=t;function n(M){return(j,T=null,L)=>{let $=!1,H;return H=M(x=>{if(!$)return H?H.dispose():$=!0,j.call(T,x)},null,L),$&&H.dispose(),H}}e.once=n;function s(M,j,T){return m((L,$=null,H)=>M(x=>L.call($,j(x)),null,H),T)}e.map=s;function o(M,j,T){return m((L,$=null,H)=>M(x=>{j(x),L.call($,x)},null,H),T)}e.forEach=o;function a(M,j,T){return m((L,$=null,H)=>M(x=>j(x)&&L.call($,x),null,H),T)}e.filter=a;function u(M){return M}e.signal=u;function h(...M){return(j,T=null,L)=>{let $=fk(...M.map(H=>H(x=>j.call(T,x))));return v($,L)}}e.any=h;function f(M,j,T,L){let $=T;return s(M,H=>($=j($,H),$),L)}e.reduce=f;function m(M,j){let T,L={onWillAddFirstListener(){T=M($.fire,$)},onDidRemoveLastListener(){T==null||T.dispose()}},$=new Ne(L);return j==null||j.add($),$.event}function v(M,j){return j instanceof Array?j.push(M):j&&j.add(M),M}function S(M,j,T=100,L=!1,$=!1,H,x){let O,D,A,W=0,X,ie={leakWarningThreshold:H,onWillAddFirstListener(){O=M(fe=>{W++,D=j(D,fe),L&&!A&&(ce.fire(D),D=void 0),X=()=>{let we=D;D=void 0,A=void 0,(!L||W>1)&&ce.fire(we),W=0},typeof T=="number"?(clearTimeout(A),A=setTimeout(X,T)):A===void 0&&(A=0,queueMicrotask(X))})},onWillRemoveListener(){$&&W>0&&(X==null||X())},onDidRemoveLastListener(){X=void 0,O.dispose()}},ce=new Ne(ie);return x==null||x.add(ce),ce.event}e.debounce=S;function y(M,j=0,T){return e.debounce(M,(L,$)=>L?(L.push($),L):[$],j,void 0,!0,void 0,T)}e.accumulate=y;function b(M,j=(L,$)=>L===$,T){let L=!0,$;return a(M,H=>{let x=L||!j(H,$);return L=!1,$=H,x},T)}e.latch=b;function w(M,j,T){return[e.filter(M,j,T),e.filter(M,L=>!j(L),T)]}e.split=w;function k(M,j=!1,T=[],L){let $=T.slice(),H=M(D=>{$?$.push(D):O.fire(D)});L&&L.add(H);let x=()=>{$==null||$.forEach(D=>O.fire(D)),$=null},O=new Ne({onWillAddFirstListener(){H||(H=M(D=>O.fire(D)),L&&L.add(H))},onDidAddFirstListener(){$&&(j?setTimeout(x):x())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return L&&L.add(O),O.event}e.buffer=k;function C(M,j){return(T,L,$)=>{let H=j(new E);return M(function(x){let O=H.evaluate(x);O!==R&&T.call(L,O)},void 0,$)}}e.chain=C;let R=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(j){return this.steps.push(j),this}forEach(j){return this.steps.push(T=>(j(T),T)),this}filter(j){return this.steps.push(T=>j(T)?T:R),this}reduce(j,T){let L=T;return this.steps.push($=>(L=j(L,$),L)),this}latch(j=(T,L)=>T===L){let T=!0,L;return this.steps.push($=>{let H=T||!j($,L);return T=!1,L=$,H?$:R}),this}evaluate(j){for(let T of this.steps)if(j=T(j),j===R)break;return j}}function F(M,j,T=L=>L){let L=(...O)=>x.fire(T(...O)),$=()=>M.on(j,L),H=()=>M.removeListener(j,L),x=new Ne({onWillAddFirstListener:$,onDidRemoveLastListener:H});return x.event}e.fromNodeEventEmitter=F;function I(M,j,T=L=>L){let L=(...O)=>x.fire(T(...O)),$=()=>M.addEventListener(j,L),H=()=>M.removeEventListener(j,L),x=new Ne({onWillAddFirstListener:$,onDidRemoveLastListener:H});return x.event}e.fromDOMEventEmitter=I;function K(M){return new Promise(j=>n(M)(j))}e.toPromise=K;function Y(M){let j=new Ne;return M.then(T=>{j.fire(T)},()=>{j.fire(void 0)}).finally(()=>{j.dispose()}),j.event}e.fromPromise=Y;function z(M,j){return M(T=>j.fire(T))}e.forward=z;function Z(M,j,T){return j(T),M(L=>j(L))}e.runAndSubscribe=Z;class G{constructor(j,T){this._observable=j,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{j.addObserver(this)},onDidRemoveLastListener:()=>{j.removeObserver(this)}};this.emitter=new Ne(L),T&&T.add(this.emitter)}beginUpdate(j){this._counter++}handlePossibleChange(j){}handleChange(j,T){this._hasChanged=!0}endUpdate(j){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Q(M,j){return new G(M,j).emitter.event}e.fromObservable=Q;function B(M){return(j,T,L)=>{let $=0,H=!1,x={beginUpdate(){$++},endUpdate(){$--,$===0&&(M.reportChanges(),H&&(H=!1,j.call(T)))},handlePossibleChange(){},handleChange(){H=!0}};M.addObserver(x),M.reportChanges();let O={dispose(){M.removeObserver(x)}};return L instanceof _s?L.add(O):Array.isArray(L)&&L.push(O),O}}e.fromObservableLight=B})(mn||(mn={}));var oh=class ah{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ah._idPool++}`,ah.all.add(this)}start(t){this._stopWatch=new mk,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}}};oh.all=new Set,oh._idPool=0;var gk=oh,vk=-1,Fy=class $y{constructor(t,n,s=($y._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)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=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let f=new wk(h,a);this._errorHandler(f)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};Fy._idPool=1;var _k=Fy,yk=class Hy{constructor(t){this.value=t}static create(){let t=new Error;return new Hy(t.stack??"")}print(){console.warn(this.value.split(`
58
58
  `).slice(2).join(`
59
59
  `))}},wk=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},bk=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Sk=0,Ju=class{constructor(e){this.value=e,this.id=Sk++}},xk=2,kk,Ne=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new _k((e==null?void 0:e.onListenerError)??Rl,((n=this._options)==null?void 0:n.leakWarningThreshold)??vk):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new gk(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,h,f,m,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let S=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(S);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new bk(`${S}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Rl)(b),st.None}if(this._disposed)return st.None;t&&(e=e.bind(t));let s=new Ju(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=yk.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ju?(this._deliveryQueue??(this._deliveryQueue=new Ck),this._listeners=[this._listeners,s]):this._listeners.push(s):((f=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||f.call(h,this),this._listeners=s,(v=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||v.call(m,this)),this._size++;let a=jt(()=>{o==null||o(),this._removeListener(s)});return n instanceof _s?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(e){var o,a,u,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||h.call(u,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*xk<=t.length){let f=0;for(let m=0;m<t.length;m++)t[m]?t[f++]=t[m]:s&&(this._deliveryQueue.end--,f<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=f}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||Rl;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Ju)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Ck=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},lh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ne,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ne,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};lh.INSTANCE=new lh;var ff=lh;function Ek(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}ff.INSTANCE.onDidChangeZoomLevel;function Nk(e){return ff.INSTANCE.getZoomFactor(e)}ff.INSTANCE.onDidChangeFullscreen;var Hr=typeof navigator=="object"?navigator.userAgent:"",ch=Hr.indexOf("Firefox")>=0,jk=Hr.indexOf("AppleWebKit")>=0,pf=Hr.indexOf("Chrome")>=0,Rk=!pf&&Hr.indexOf("Safari")>=0;Hr.indexOf("Electron/")>=0;Hr.indexOf("Android")>=0;var Zu=!1;if(typeof zi.matchMedia=="function"){let e=zi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=zi.matchMedia("(display-mode: fullscreen)");Zu=e.matches,Ek(zi,e,({matches:n})=>{Zu&&t.matches||(Zu=n)})}var Pr="en",uh=!1,dh=!1,Pl=!1,Uy=!1,vl,Ll=Pr,Wg=Pr,Pk,ci,Gs=globalThis,pn,V_;typeof Gs.vscode<"u"&&typeof Gs.vscode.process<"u"?pn=Gs.vscode.process:typeof process<"u"&&typeof((V_=process==null?void 0:process.versions)==null?void 0:V_.node)=="string"&&(pn=process);var Y_,Lk=typeof((Y_=pn==null?void 0:pn.versions)==null?void 0:Y_.electron)=="string",Ak=Lk&&(pn==null?void 0:pn.type)==="renderer",G_;if(typeof pn=="object"){uh=pn.platform==="win32",dh=pn.platform==="darwin",Pl=pn.platform==="linux",Pl&&pn.env.SNAP&&pn.env.SNAP_REVISION,pn.env.CI||pn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,vl=Pr,Ll=Pr;let e=pn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);vl=t.userLocale,Wg=t.osLocale,Ll=t.resolvedLanguage||Pr,Pk=(G_=t.languagePack)==null?void 0:G_.translationsConfigFile}catch{}Uy=!0}else typeof navigator=="object"&&!Ak?(ci=navigator.userAgent,uh=ci.indexOf("Windows")>=0,dh=ci.indexOf("Macintosh")>=0,(ci.indexOf("Macintosh")>=0||ci.indexOf("iPad")>=0||ci.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Pl=ci.indexOf("Linux")>=0,(ci==null?void 0:ci.indexOf("Mobi"))>=0,Ll=globalThis._VSCODE_NLS_LANGUAGE||Pr,vl=navigator.language.toLowerCase(),Wg=vl):console.error("Unable to resolve platform.");var Wy=uh,Ci=dh,Tk=Pl,Kg=Uy,Ni=ci,cs=Ll,Dk;(e=>{function t(){return cs}e.value=t;function n(){return cs.length===2?cs==="en":cs.length>=3?cs[0]==="e"&&cs[1]==="n"&&cs[2]==="-":!1}e.isDefaultVariant=n;function s(){return cs==="en"}e.isDefault=s})(Dk||(Dk={}));var Mk=typeof Gs.postMessage=="function"&&!Gs.importScripts;(()=>{if(Mk){let e=[];Gs.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),Gs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Ik=!!(Ni&&Ni.indexOf("Chrome")>=0);Ni&&Ni.indexOf("Firefox")>=0;!Ik&&Ni&&Ni.indexOf("Safari")>=0;Ni&&Ni.indexOf("Edg/")>=0;Ni&&Ni.indexOf("Android")>=0;var Cr=typeof navigator=="object"?navigator:{};Kg||document.queryCommandSupported&&document.queryCommandSupported("copy")||Cr&&Cr.clipboard&&Cr.clipboard.writeText,Kg||Cr&&Cr.clipboard&&Cr.clipboard.readText;var mf=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}},ed=new mf,qg=new mf,Vg=new mf,Ok=new Array(230),Ky;(e=>{function t(h){return ed.keyCodeToStr(h)}e.toString=t;function n(h){return ed.strToKeyCode(h)}e.fromString=n;function s(h){return qg.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return Vg.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return qg.strToKeyCode(h)||Vg.strToKeyCode(h)}e.fromUserSettings=a;function u(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ed.keyCodeToStr(h)}e.toElectronAccelerator=u})(Ky||(Ky={}));var Bk=class qy{constructor(t,n,s,o,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof qy&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new zk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},zk=class{constructor(e){if(e.length===0)throw uk("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Fk(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Ky.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(ch)switch(t){case 59:return 85;case 60:if(Tk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ci)return 57;break}else if(jk&&(Ci&&t===93||!Ci&&t===92))return 57;return Ok[t]||0}var $k=Ci?256:2048,Hk=512,Uk=1024,Wk=Ci?2048:256,Yg=class{constructor(e){var n;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=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=Fk(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|=$k),this.altKey&&(t|=Hk),this.shiftKey&&(t|=Uk),this.metaKey&&(t|=Wk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Bk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Gg=new WeakMap;function Kk(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var qk=class{static getSameOriginWindowChain(e){let t=Gg.get(e);if(!t){t=[],Gg.set(e,t);let n=e,s;do s=Kk(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(n+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!a.iframeElement)break;let h=a.iframeElement.getBoundingClientRect();n+=h.top,s+=h.left}return{top:n,left:s}}},_l=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=qk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Xg=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(pf){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,u=e,h=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*h):this.deltaY=a.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?ch&&!Ci?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Rk&&Wy?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*h):this.deltaX=a.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?ch&&!Ci?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Vy=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Vk;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Yk?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vy})})(Vk||(Vk={}));var Yk=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?Vy:(this._emitter||(this._emitter=new Ne),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},gf=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 ih("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ih("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Gk=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new ih("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=jt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Xk;(e=>{async function t(s){let o,a=await Promise.all(s.map(u=>u.then(h=>h,h=>{o||(o=h)})));if(typeof o<"u")throw o;return a}e.settled=t;function n(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=n})(Xk||(Xk={}));var Qg=class Zn{static fromArray(t){return new Zn(n=>{n.emitMany(t)})}static fromPromise(t){return new Zn(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Zn(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Zn(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Ne,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Zn(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Zn.map(this,t)}static filter(t,n){return new Zn(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Zn.filter(this,t)}static coalesce(t){return Zn.filter(t,n=>!!n)}coalesce(){return Zn.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Zn.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())}};Qg.EMPTY=Qg.fromArray([]);var{getWindow:xi,getWindowId:Qk,onDidRegisterWindow:Jk}=(function(){let e=new Map,t={window:zi,disposables:new _s};e.set(zi.vscodeWindowId,t);let n=new Ne,s=new Ne,o=new Ne;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return st.None;let h=new _s,f={window:u,disposables:h.add(new _s)};return e.set(u.vscodeWindowId,f),h.add(jt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(Xe(u,rn.BEFORE_UNLOAD,()=>{o.fire(u)})),n.fire(f),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:a,getWindow(u){var m;let h=u;if((m=h==null?void 0:h.ownerDocument)!=null&&m.defaultView)return h.ownerDocument.defaultView.window;let f=u;return f!=null&&f.view?f.view.window:zi},getDocument(u){return xi(u).document}}})(),Zk=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Xe(e,t,n,s){return new Zk(e,t,n,s)}var Jg=function(e,t,n,s){return Xe(e,t,n,s)},vf,e1=class extends Gk{constructor(e){super(),this.defaultTarget=e&&xi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Zg=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){Rl(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=a=>{n.set(a,!1);let u=e.get(a)??[];for(t.set(a,u),e.set(a,[]),s.set(a,!0);u.length>0;)u.sort(Zg.sort),u.shift().execute();s.set(a,!1)};vf=(a,u,h=0)=>{let f=Qk(a),m=new Zg(u,h),v=e.get(f);return v||(v=[],e.set(f,v)),v.push(m),n.get(f)||(n.set(f,!0),a.requestAnimationFrame(()=>o(f))),m}})();function t1(e){let t=e.getBoundingClientRect(),n=xi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var rn={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"},n1=class{constructor(t){this.domNode=t,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(t){let n=Dn(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=Dn(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=Dn(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=Dn(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=Dn(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=Dn(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=Dn(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=Dn(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=Dn(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=Dn(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=Dn(t);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let n=Dn(t);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let n=Dn(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=Dn(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Dn(e){return typeof e=="number"?`${e}px`:e}function Vo(e){return new n1(e)}var Yy=class{constructor(){this._hooks=new _s,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(jt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=xi(e)}this._hooks.add(Xe(a,rn.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Xe(a,rn.POINTER_UP,u=>this.stopMonitoring(!0)))}};function i1(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;n[s]=function(...u){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[a]}}var yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(yi||(yi={}));var $o=class wn extends st{constructor(){super(),this.dispatched=!1,this.targets=new Ug,this.ignoreTargets=new Ug,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(mn.runAndSubscribe(Jk,({window:t,disposables:n})=>{n.add(Xe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Xe(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Xe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:zi,disposables:this._store}))}static addTarget(t){if(!wn.isTouchDevice())return st.None;wn.INSTANCE||(wn.INSTANCE=new wn);let n=wn.INSTANCE.targets.push(t);return jt(n)}static ignoreTarget(t){if(!wn.isTouchDevice())return st.None;wn.INSTANCE||(wn.INSTANCE=new wn);let n=wn.INSTANCE.ignoreTargets.push(t);return jt(n)}static isTouchDevice(){return"ontouchstart"in zi||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(yi.Start,a.target);u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=n.changedTouches.length;a<u;a++){let h=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let f=this.activeTouches[h.identifier],m=Date.now()-f.initialTimeStamp;if(m<wn.HOLD_DELAY&&Math.abs(f.initialPageX-zn(f.rollingPageX))<30&&Math.abs(f.initialPageY-zn(f.rollingPageY))<30){let v=this.newGestureEvent(yi.Tap,f.initialTarget);v.pageX=zn(f.rollingPageX),v.pageY=zn(f.rollingPageY),this.dispatchEvent(v)}else if(m>=wn.HOLD_DELAY&&Math.abs(f.initialPageX-zn(f.rollingPageX))<30&&Math.abs(f.initialPageY-zn(f.rollingPageY))<30){let v=this.newGestureEvent(yi.Contextmenu,f.initialTarget);v.pageX=zn(f.rollingPageX),v.pageY=zn(f.rollingPageY),this.dispatchEvent(v)}else if(o===1){let v=zn(f.rollingPageX),S=zn(f.rollingPageY),y=zn(f.rollingTimestamps)-f.rollingTimestamps[0],b=v-f.rollingPageX[0],w=S-f.rollingPageY[0],k=[...this.targets].filter(C=>f.initialTarget instanceof Node&&C.contains(f.initialTarget));this.inertia(t,k,s,Math.abs(b)/y,b>0?1:-1,v,Math.abs(w)/y,w>0?1:-1,S)}this.dispatchEvent(this.newGestureEvent(yi.End,f.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===yi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>wn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===yi.Change||t.type===yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,a,u,h,f,m){this.handle=vf(t,()=>{let v=Date.now(),S=v-s,y=0,b=0,w=!0;o+=wn.SCROLL_FRICTION*S,h+=wn.SCROLL_FRICTION*S,o>0&&(w=!1,y=a*o*S),h>0&&(w=!1,b=f*h*S);let k=this.newGestureEvent(yi.Change);k.translationX=y,k.translationY=b,n.forEach(C=>C.dispatchEvent(k)),w||this.inertia(t,n,v,o,a,u+y,h,f,m+b)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],h=this.newGestureEvent(yi.Change,u.initialTarget);h.translationX=a.pageX-zn(u.rollingPageX),h.translationY=a.pageY-zn(u.rollingPageY),h.pageX=a.pageX,h.pageY=a.pageY,this.dispatchEvent(h),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(a.pageX),u.rollingPageY.push(a.pageY),u.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};$o.SCROLL_FRICTION=-.005,$o.HOLD_DELAY=700,$o.CLEAR_TAP_COUNT_TIME=400,Bt([i1],$o,"isTouchDevice",1);var s1=$o,_f=class extends st{onclick(e,t){this._register(Xe(e,rn.CLICK,n=>t(new _l(xi(e),n))))}onmousedown(e,t){this._register(Xe(e,rn.MOUSE_DOWN,n=>t(new _l(xi(e),n))))}onmouseover(e,t){this._register(Xe(e,rn.MOUSE_OVER,n=>t(new _l(xi(e),n))))}onmouseleave(e,t){this._register(Xe(e,rn.MOUSE_LEAVE,n=>t(new _l(xi(e),n))))}onkeydown(e,t){this._register(Xe(e,rn.KEY_DOWN,n=>t(new Yg(n))))}onkeyup(e,t){this._register(Xe(e,rn.KEY_UP,n=>t(new Yg(n))))}oninput(e,t){this._register(Xe(e,rn.INPUT,t))}onblur(e,t){this._register(Xe(e,rn.BLUR,t))}onfocus(e,t){this._register(Xe(e,rn.FOCUS,t))}onchange(e,t){this._register(Xe(e,rn.CHANGE,t))}ignoreGesture(e){return s1.ignoreTarget(e)}},ev=11,r1=class extends _f{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=ev+"px",this.domNode.style.height=ev+"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 Yy),this._register(Jg(this.bgDomNode,rn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Jg(this.domNode,rn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new e1),this._pointerdownScheduleRepeatTimer=this._register(new gf)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,xi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},o1=class hh{constructor(t,n,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=u,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,n){return new hh(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new hh(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,f=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:u,scrollHeightChanged:h,scrollTopChanged:f}}},a1=class extends st{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new o1(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){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new nv(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=nv.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},tv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function td(e,t){let n=t-e;return function(s){return e+n*u1(s)}}function l1(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var nv=class fh{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,a;return t<n?(o=t+.75*s,a=n-.75*s):(o=t-.75*s,a=n+.75*s),l1(td(t,o),td(a,n),.33)}return td(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new tv(s,o,!1)}return new tv(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return fh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new fh(t,n,o,s)}};function c1(e){return Math.pow(e,3)}function u1(e){return 1-c1(1-e)}var d1=class extends st{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new gf)}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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},h1=140,Gy=class extends _f{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 d1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Yy),this._shouldRender=!0,this.domNode=Vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Xe(this.domNode.domNode,rn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new r1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Xe(this.slider.domNode,rn.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=t1(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-n);if(Wy&&u>h1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{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()}},Xy=class ph{constructor(t,n,s,o,a,u){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new ph(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*n),f=o>0&&o>s;if(!f)return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*h/o))),v=(h-m)/(o-s),S=a*v;return{computedAvailableSize:Math.round(u),computedIsNeeded:f,computedSliderSize:Math.round(m),computedSliderRatio:v,computedSliderPosition:Math.round(S)}}_refreshComputedValues(){let t=ph._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},f1=class extends Gy{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Xy(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.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}},p1=class extends Gy{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Xy(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.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}},m1=500,iv=50,g1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},mh=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,n+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(pf){let n=xi(t.browserEvent),s=Nk(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,a=new g1(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,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]=a),a.score=this._computeScore(a,o)}_computeScore(t,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(n.deltaX),h=Math.abs(n.deltaY),f=Math.max(Math.min(o,u),1),m=Math.max(Math.min(a,h),1),v=Math.max(o,u),S=Math.max(a,h);v%f===0&&S%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};mh.INSTANCE=new mh;var v1=mh,_1=class extends _f{constructor(e,t,n){super(),this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ne),this.onWillScroll=this._onWillScroll.event,this._options=w1(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new p1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new f1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Vo(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 gf),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Xs(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,Ci&&(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 Xg(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Xs(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new Xg(n))};this._mouseWheelToDispose.push(Xe(this._listenOnDomNode,rn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=v1.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+a===0?u=a=0:Math.abs(a)>=Math.abs(u)?u=0:a=0),this._options.flipAxes&&([a,u]=[u,a]);let h=!Ci&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!u&&(u=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),m={};if(a){let v=iv*a,S=f.scrollTop-(v<0?Math.floor(v):Math.ceil(v));this._verticalScrollbar.writeScrollPosition(m,S)}if(u){let v=iv*u,S=f.scrollLeft-(v<0?Math.floor(v):Math.ceil(v));this._horizontalScrollbar.writeScrollPosition(m,S)}m=this._scrollable.validateScrollPosition(m),(f.scrollLeft!==m.scrollLeft||f.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",a=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),m1)}},y1=class extends _1{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function w1(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,Ci&&(t.className+=" mac"),t}var gh=class extends st{constructor(e,t,n,s,o,a,u,h){super(),this._bufferService=n,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new Ne),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new a1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>vf(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new y1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(mn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(jt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(jt(()=>this._styleElement.remove())),this._register(mn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
60
60
  `)})),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(m=>this._handleScroll(m)))}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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};gh=Bt([Re(2,Cn),Re(3,$i),Re(4,Py),Re(5,$r),Re(6,En),Re(7,Hi)],gh);var vh=class extends st{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,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(a=>this._removeDecoration(a))),this._register(jt(()=>{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){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};vh=Bt([Re(1,Cn),Re(2,$i),Re(3,ia),Re(4,Hi)],vh);var b1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},gi={full:0,left:0,center:0,right:0},us={full:0,left:0,center:0,right:0},Lo={full:0,left:0,center:0,right:0},Wl=class extends st{constructor(e,t,n,s,o,a,u,h){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new b1,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(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(jt(()=>{var v;return(v=this._canvas)==null?void 0:v.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);us.full=this._canvas.width,us.left=e,us.center=t,us.right=e,this._refreshDrawHeightConstants(),Lo.full=1,Lo.left=1,Lo.center=1+us.left,Lo.right=1+us.left+us.center}_refreshDrawHeightConstants(){gi.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);gi.left=t,gi.center=t,gi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*gi.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(Lo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-gi[e.position||"full"]/2),us[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+gi[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}))}};Wl=Bt([Re(2,Cn),Re(3,ia),Re(4,Hi),Re(5,En),Re(6,$r),Re(7,$i)],Wl);var ve;(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=`
61
- `,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=""))(ve||(ve={}));var Al;(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="Ÿ"))(Al||(Al={}));var Qy;(e=>e.ST=`${ve.ESC}\\`)(Qy||(Qy={}));var _h=class{constructor(e,t,n,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ve.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};_h=Bt([Re(2,Cn),Re(3,En),Re(4,Js),Re(5,Hi)],_h);var on=0,an=0,ln=0,Ot=0,sv={css:"#00000000",rgba:0},qt;(e=>{function t(o,a,u,h){return h!==void 0?`#${Fs(o)}${Fs(a)}${Fs(u)}${Fs(h)}`:`#${Fs(o)}${Fs(a)}${Fs(u)}`}e.toCss=t;function n(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=n;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(qt||(qt={}));var Ct;(e=>{function t(f,m){if(Ot=(m.rgba&255)/255,Ot===1)return{css:m.css,rgba:m.rgba};let v=m.rgba>>24&255,S=m.rgba>>16&255,y=m.rgba>>8&255,b=f.rgba>>24&255,w=f.rgba>>16&255,k=f.rgba>>8&255;on=b+Math.round((v-b)*Ot),an=w+Math.round((S-w)*Ot),ln=k+Math.round((y-k)*Ot);let C=qt.toCss(on,an,ln),R=qt.toRgba(on,an,ln);return{css:C,rgba:R}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,m,v){let S=Tl.ensureContrastRatio(f.rgba,m.rgba,v);if(S)return qt.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(f){let m=(f.rgba|255)>>>0;return[on,an,ln]=Tl.toChannels(m),{css:qt.toCss(on,an,ln),rgba:m}}e.opaque=o;function a(f,m){return Ot=Math.round(m*255),[on,an,ln]=Tl.toChannels(f.rgba),{css:qt.toCss(on,an,ln,Ot),rgba:qt.toRgba(on,an,ln,Ot)}}e.opacity=a;function u(f,m){return Ot=f.rgba&255,a(f,Ot*m/255)}e.multiplyOpacity=u;function h(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=h})(Ct||(Ct={}));var Dt;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return on=parseInt(o.slice(1,2).repeat(2),16),an=parseInt(o.slice(2,3).repeat(2),16),ln=parseInt(o.slice(3,4).repeat(2),16),qt.toColor(on,an,ln);case 5:return on=parseInt(o.slice(1,2).repeat(2),16),an=parseInt(o.slice(2,3).repeat(2),16),ln=parseInt(o.slice(3,4).repeat(2),16),Ot=parseInt(o.slice(4,5).repeat(2),16),qt.toColor(on,an,ln,Ot);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 a=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(a)return on=parseInt(a[1]),an=parseInt(a[2]),ln=parseInt(a[3]),Ot=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),qt.toColor(on,an,ln,Ot);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[on,an,ln,Ot]=t.getImageData(0,0,1,1).data,Ot!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:qt.toRgba(on,an,ln,Ot),css:o}}e.toColor=s})(Dt||(Dt={}));var xn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,h=o/255,f=a/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),v=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),S=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+v*.7152+S*.0722}e.relativeLuminance2=n})(xn||(xn={}));var Tl;(e=>{function t(u,h){if(Ot=(h&255)/255,Ot===1)return h;let f=h>>24&255,m=h>>16&255,v=h>>8&255,S=u>>24&255,y=u>>16&255,b=u>>8&255;return on=S+Math.round((f-S)*Ot),an=y+Math.round((m-y)*Ot),ln=b+Math.round((v-b)*Ot),qt.toRgba(on,an,ln)}e.blend=t;function n(u,h,f){let m=xn.relativeLuminance(u>>8),v=xn.relativeLuminance(h>>8);if(Ii(m,v)<f){if(v<m){let b=s(u,h,f),w=Ii(m,xn.relativeLuminance(b>>8));if(w<f){let k=o(u,h,f),C=Ii(m,xn.relativeLuminance(k>>8));return w>C?b:k}return b}let S=o(u,h,f),y=Ii(m,xn.relativeLuminance(S>>8));if(y<f){let b=s(u,h,f),w=Ii(m,xn.relativeLuminance(b>>8));return y>w?S:b}return S}}e.ensureContrastRatio=n;function s(u,h,f){let m=u>>24&255,v=u>>16&255,S=u>>8&255,y=h>>24&255,b=h>>16&255,w=h>>8&255,k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));for(;k<f&&(y>0||b>0||w>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),w-=Math.max(0,Math.ceil(w*.1)),k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));return(y<<24|b<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,f){let m=u>>24&255,v=u>>16&255,S=u>>8&255,y=h>>24&255,b=h>>16&255,w=h>>8&255,k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));for(;k<f&&(y<255||b<255||w<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));return(y<<24|b<<16|w<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(Tl||(Tl={}));function Fs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ii(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var S1=class extends na{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ti}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),f=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==f){if(m-o>1){let v=this._getJoinedRanges(s,u,a,t,o);for(let S=0;S<v.length;S++)n.push(v[S])}o=m,u=a,h=this._workCell.fg,f=this._workCell.bg}a+=this._workCell.getChars().length||ms.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,a,t,o);for(let v=0;v<m.length;v++)n.push(m[v])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let f=this._characterJoiners[h].handler(a);for(let m=0;m<f.length;m++)Kl._mergeRanges(u,f[m])}catch(f){console.error(f)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=n;h<this._bufferService.cols;h++){let f=t.getWidth(h),m=t.getString(h).length||ms.length;if(f!==0){if(!o&&u[0]<=a&&(u[0]=h,o=!0),u[1]<=a){if(u[1]=h,u=e[++s],!u)break;u[0]<=a?(u[0]=h,o=!0):o=!1}a+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Kl=Bt([Re(0,Cn)],Kl);function x1(e){return 57508<=e&&e<=57558}function k1(e){return 9472<=e&&e<=9631}function C1(e){return x1(e)||k1(e)}function E1(){return{css:{canvas:yl(),cell:yl()},device:{canvas:yl(),cell:yl(),char:{width:0,height:0,left:0,top:0}}}}function yl(){return{width:0,height:0}}var yh=class{constructor(e,t,n,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new ti,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,h,f,m,v){let S=[],y=this._characterJoinerService.getJoinedCharacters(t),b=this._themeService.colors,w=e.getNoBgTrimmedLength();n&&w<a+1&&(w=a+1);let k,C=0,R="",E=0,F=0,I=0,K=0,Y=!1,z=0,Z=!1,G=0,Q=0,B=[],M=m!==-1&&v!==-1;for(let j=0;j<w;j++){e.loadCell(j,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let L=!1,$=j>=Q,H=j,x=this._workCell;if(y.length>0&&j===y[0][0]&&$){let Ae=y.shift(),Rt=this._isCellInSelection(Ae[0],t);for(E=Ae[0]+1;E<Ae[1];E++)$&&($=Rt===this._isCellInSelection(E,t));$&&($=!n||a<Ae[0]||a>=Ae[1]),$?(L=!0,x=new S1(this._workCell,e.translateToString(!0,Ae[0],Ae[1]),Ae[1]-Ae[0]),H=Ae[1]-1,T=x.getWidth()):Q=Ae[1]}let O=this._isCellInSelection(j,t),D=n&&j===a,A=M&&j>=m&&j<=v,W=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Ae=>{W=!0});let X=x.getChars()||ms;if(X===" "&&(x.isUnderline()||x.isOverline())&&(X=" "),G=T*h-f.get(X,x.isBold(),x.isItalic()),!k)k=this._document.createElement("span");else if(C&&(O&&Z||!O&&!Z&&x.bg===F)&&(O&&Z&&b.selectionForeground||x.fg===I)&&x.extended.ext===K&&A===Y&&G===z&&!D&&!L&&!W&&$){x.isInvisible()?R+=ms:R+=X,C++;continue}else C&&(k.textContent=R),k=this._document.createElement("span"),C=0,R="";if(F=x.bg,I=x.fg,K=x.extended.ext,Y=A,z=G,Z=O,L&&a>=j&&a<=H&&(a=j),!this._coreService.isCursorHidden&&D&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&B.push("xterm-cursor-blink"),B.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(x.isBold()&&B.push("xterm-bold"),x.isItalic()&&B.push("xterm-italic"),x.isDim()&&B.push("xterm-dim"),x.isInvisible()?R=ms:R=x.getChars()||ms,x.isUnderline()&&(B.push(`xterm-underline-${x.extended.underlineStyle}`),R===" "&&(R=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${na.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let Ae=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&Ae<8&&(Ae+=8),k.style.textDecorationColor=b.ansi[Ae].css}x.isOverline()&&(B.push("xterm-overline"),R===" "&&(R=" ")),x.isStrikethrough()&&B.push("xterm-strikethrough"),A&&(k.style.textDecoration="underline");let ie=x.getFgColor(),ue=x.getFgColorMode(),fe=x.getBgColor(),we=x.getBgColorMode(),me=!!x.isInverse();if(me){let Ae=ie;ie=fe,fe=Ae;let Rt=ue;ue=we,we=Rt}let xe,$e,ft=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Ae=>{Ae.options.layer!=="top"&&ft||(Ae.backgroundColorRGB&&(we=50331648,fe=Ae.backgroundColorRGB.rgba>>8&16777215,xe=Ae.backgroundColorRGB),Ae.foregroundColorRGB&&(ue=50331648,ie=Ae.foregroundColorRGB.rgba>>8&16777215,$e=Ae.foregroundColorRGB),ft=Ae.options.layer==="top")}),!ft&&O&&(xe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,fe=xe.rgba>>8&16777215,we=50331648,ft=!0,b.selectionForeground&&(ue=50331648,ie=b.selectionForeground.rgba>>8&16777215,$e=b.selectionForeground)),ft&&B.push("xterm-decoration-top");let qe;switch(we){case 16777216:case 33554432:qe=b.ansi[fe],B.push(`xterm-bg-${fe}`);break;case 50331648:qe=qt.toColor(fe>>16,fe>>8&255,fe&255),this._addStyle(k,`background-color:#${rv((fe>>>0).toString(16),"0",6)}`);break;case 0:default:me?(qe=b.foreground,B.push("xterm-bg-257")):qe=b.background}switch(xe||x.isDim()&&(xe=Ct.multiplyOpacity(qe,.5)),ue){case 16777216:case 33554432:x.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(k,qe,b.ansi[ie],x,xe,void 0)||B.push(`xterm-fg-${ie}`);break;case 50331648:let Ae=qt.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(k,qe,Ae,x,xe,$e)||this._addStyle(k,`color:#${rv(ie.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,qe,b.foreground,x,xe,$e)||me&&B.push("xterm-fg-257")}B.length&&(k.className=B.join(" "),B.length=0),!D&&!L&&!W&&$?C++:k.textContent=R,G!==this.defaultSpacing&&(k.style.letterSpacing=`${G}px`),S.push(k),j=H}return k&&C&&(k.textContent=R),S}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||C1(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,n.rgba)),h===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Ct.ensureContrastRatio(o||t,a||n,f),u.setColor((o||t).rgba,(a||n).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};yh=Bt([Re(1,Ty),Re(2,En),Re(3,$i),Re(4,Js),Re(5,ia),Re(6,$r)],yh);function rv(e,t,n){for(;e.length<n;)e=t+e;return e}var N1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,s,o,a],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),n&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},j1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[1]-o,h=Math.max(a,0),f=Math.min(u,e.rows-1);if(h>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=f,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function R1(){return new j1}var nd="xterm-dom-renderer-owner-",Jn="xterm-rows",wl="xterm-fg-",ov="xterm-bg-",Ao="xterm-focus",bl="xterm-selection",P1=1,wh=class extends st{constructor(e,t,n,s,o,a,u,h,f,m,v,S,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=f,this._optionsService=m,this._bufferService=v,this._coreService=S,this._coreBrowserService=y,this._themeService=b,this._terminalClass=P1++,this._rowElements=[],this._selectionRenderModel=R1(),this.onRequestRedraw=this._register(new Ne).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Jn),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(bl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=E1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(yh,document),this._element.classList.add(nd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(jt(()=>{this._element.classList.remove(nd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new N1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Jn} 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} .${Jn} { 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} .${Jn} .xterm-dim { color: ${Ct.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${bl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${bl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${bl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${wl}${a} { color: ${u.css}; }${this._terminalSelector} .${wl}${a}.xterm-dim { color: ${Ct.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${ov}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${wl}257 { color: ${Ct.opaque(e.background).css}; }${this._terminalSelector} .${wl}257.xterm-dim { color: ${Ct.multiplyOpacity(Ct.opaque(e.background),.5).css}; }${this._terminalSelector} .${ov}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ao),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ao),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];h.appendChild(this._createSelectionElement(a,f?t[0]:e[0],f?e[0]:t[0],u-a+1))}else{let f=s===a?e[0]:0,m=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,f,m));let v=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,v)),a!==u){let S=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,S))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let m=f+n.ydisp,v=this._rowElements[f],S=n.lines.get(m);if(!v||!S)break;v.replaceChildren(...this._rowFactory.createRow(S,m,m===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${nd}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,f=h.ybase+h.y,m=Math.min(h.x,o-1),v=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let w=b+h.ydisp,k=this._rowElements[b],C=h.lines.get(w);if(!k||!C)break;k.replaceChildren(...this._rowFactory.createRow(C,w,w===f,S,y,m,v,this.dimensions.css.cell.width,this._widthCache,a?b===n?e:0:-1,a?(b===s?t:o)-1:-1))}}};wh=Bt([Re(7,df),Re(8,tc),Re(9,En),Re(10,Cn),Re(11,Js),Re(12,$i),Re(13,$r)],wh);var bh=class extends st{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ne),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new A1(this._optionsService))}catch{this._measureStrategy=this._register(new L1(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())}};bh=Bt([Re(2,En)],bh);var Jy=class extends st{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)}},L1=class extends Jy{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},A1=class extends Jy{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}},T1=class extends st{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new D1(this._window)),this._onDprChange=this._register(new Ne),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ne),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},D1=class extends st{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Or),this._onDprChange=this._register(new Ne),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(jt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},M1=class extends st{constructor(){super(),this.linkProviders=[],this._register(jt(()=>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 yf(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function I1(e,t,n,s,o,a,u,h,f){if(!a)return;let m=yf(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(f?u/2:0))/u),m[1]=Math.ceil(m[1]/h),m[0]=Math.min(Math.max(m[0],1),s+(f?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var Sh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return I1(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=yf(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Sh=Bt([Re(0,Hi),Re(1,tc)],Sh);var O1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Zy={};Vx(Zy,{getSafariVersion:()=>z1,isChromeOS:()=>iw,isFirefox:()=>ew,isIpad:()=>F1,isIphone:()=>$1,isLegacyEdge:()=>B1,isLinux:()=>wf,isMac:()=>ql,isNode:()=>nc,isSafari:()=>tw,isWindows:()=>nw});var nc=typeof process<"u"&&"title"in process,sa=nc?"node":navigator.userAgent,ra=nc?"node":navigator.platform,ew=sa.includes("Firefox"),B1=sa.includes("Edge"),tw=/^((?!chrome|android).)*safari/i.test(sa);function z1(){if(!tw)return 0;let e=sa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ql=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ra),F1=ra==="iPad",$1=ra==="iPhone",nw=["Windows","Win16","Win32","WinCE"].includes(ra),wf=ra.indexOf("Linux")>=0,iw=/\bCrOS\b/.test(sa),sw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},H1=class extends sw{_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())}}},U1=class extends sw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Vl=!nc&&"requestIdleCallback"in window?U1:H1,W1=class{constructor(){this._queue=new Vl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},xh=class extends st{constructor(e,t,n,s,o,a,u,h,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new Or),this._pausedResizeTask=new W1,this._observerDisposable=this._register(new Or),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 Ne),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ne),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ne),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ne),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new O1((m,v)=>this._renderRows(m,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new K1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(jt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=jt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};xh=Bt([Re(2,En),Re(3,tc),Re(4,Js),Re(5,ia),Re(6,Cn),Re(7,$i),Re(8,$r)],xh);var K1=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function q1(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return G1(o,a,e,t,n,s)+ic(a,t,n,s)+X1(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",Qo(Math.abs(o-e),Xo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),f=Y1(a>t?e:o,n)+(h-1)*n.cols+1+V1(a>t?o:e);return Qo(f,Xo(u,s))}function V1(e,t){return e-1}function Y1(e,t){return t.cols-e}function G1(e,t,n,s,o,a){return ic(t,s,o,a).length===0?"":Qo(ow(e,t,e,t-Qs(t,o),!1,o).length,Xo("D",a))}function ic(e,t,n,s){let o=e-Qs(e,n),a=t-Qs(t,n),u=Math.abs(o-a)-Q1(e,t,n);return Qo(u,Xo(rw(e,t),s))}function X1(e,t,n,s,o,a){let u;ic(t,s,o,a).length>0?u=s-Qs(s,o):u=t;let h=s,f=J1(e,t,n,s,o,a);return Qo(ow(e,u,n,h,f==="C",o).length,Xo(f,a))}function Q1(e,t,n){var u;let s=0,o=e-Qs(e,n),a=t-Qs(t,n);for(let h=0;h<Math.abs(o-a);h++){let f=rw(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+f*h))!=null&&u.isWrapped&&s++}return s}function Qs(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function J1(e,t,n,s,o,a){let u;return ic(n,s,o,a).length>0?u=s-Qs(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function rw(e,t){return e>t?"A":"B"}function ow(e,t,n,s,o,a){let u=e,h=t,f="";for(;(u!==n||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(f+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(f+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return f+a.buffer.translateBufferLineToString(h,!1,e,u)}function Xo(e,t){let n=t?"O":"[";return ve.ESC+n+e}function Qo(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var Z1=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 av(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 id=50,eC=15,tC=50,nC=500,iC=" ",sC=new RegExp(iC,"g"),kh=class extends st{constructor(e,t,n,s,o,a,u,h,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=h,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ti,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ne),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ne),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ne),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ne),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new Z1(this._bufferService),this._activeSelectionMode=0,this._register(jt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=n.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),h=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(sC," ")).join(nw?`\r
61
+ `,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=""))(ve||(ve={}));var Al;(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="Ÿ"))(Al||(Al={}));var Qy;(e=>e.ST=`${ve.ESC}\\`)(Qy||(Qy={}));var _h=class{constructor(e,t,n,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ve.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};_h=Bt([Re(2,Cn),Re(3,En),Re(4,Js),Re(5,Hi)],_h);var on=0,an=0,ln=0,Ot=0,sv={css:"#00000000",rgba:0},qt;(e=>{function t(o,a,u,h){return h!==void 0?`#${Fs(o)}${Fs(a)}${Fs(u)}${Fs(h)}`:`#${Fs(o)}${Fs(a)}${Fs(u)}`}e.toCss=t;function n(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=n;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(qt||(qt={}));var Ct;(e=>{function t(f,m){if(Ot=(m.rgba&255)/255,Ot===1)return{css:m.css,rgba:m.rgba};let v=m.rgba>>24&255,S=m.rgba>>16&255,y=m.rgba>>8&255,b=f.rgba>>24&255,w=f.rgba>>16&255,k=f.rgba>>8&255;on=b+Math.round((v-b)*Ot),an=w+Math.round((S-w)*Ot),ln=k+Math.round((y-k)*Ot);let C=qt.toCss(on,an,ln),R=qt.toRgba(on,an,ln);return{css:C,rgba:R}}e.blend=t;function n(f){return(f.rgba&255)===255}e.isOpaque=n;function s(f,m,v){let S=Tl.ensureContrastRatio(f.rgba,m.rgba,v);if(S)return qt.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(f){let m=(f.rgba|255)>>>0;return[on,an,ln]=Tl.toChannels(m),{css:qt.toCss(on,an,ln),rgba:m}}e.opaque=o;function a(f,m){return Ot=Math.round(m*255),[on,an,ln]=Tl.toChannels(f.rgba),{css:qt.toCss(on,an,ln,Ot),rgba:qt.toRgba(on,an,ln,Ot)}}e.opacity=a;function u(f,m){return Ot=f.rgba&255,a(f,Ot*m/255)}e.multiplyOpacity=u;function h(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=h})(Ct||(Ct={}));var Dt;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return on=parseInt(o.slice(1,2).repeat(2),16),an=parseInt(o.slice(2,3).repeat(2),16),ln=parseInt(o.slice(3,4).repeat(2),16),qt.toColor(on,an,ln);case 5:return on=parseInt(o.slice(1,2).repeat(2),16),an=parseInt(o.slice(2,3).repeat(2),16),ln=parseInt(o.slice(3,4).repeat(2),16),Ot=parseInt(o.slice(4,5).repeat(2),16),qt.toColor(on,an,ln,Ot);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 a=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(a)return on=parseInt(a[1]),an=parseInt(a[2]),ln=parseInt(a[3]),Ot=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),qt.toColor(on,an,ln,Ot);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[on,an,ln,Ot]=t.getImageData(0,0,1,1).data,Ot!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:qt.toRgba(on,an,ln,Ot),css:o}}e.toColor=s})(Dt||(Dt={}));var xn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,h=o/255,f=a/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),v=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),S=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+v*.7152+S*.0722}e.relativeLuminance2=n})(xn||(xn={}));var Tl;(e=>{function t(u,h){if(Ot=(h&255)/255,Ot===1)return h;let f=h>>24&255,m=h>>16&255,v=h>>8&255,S=u>>24&255,y=u>>16&255,b=u>>8&255;return on=S+Math.round((f-S)*Ot),an=y+Math.round((m-y)*Ot),ln=b+Math.round((v-b)*Ot),qt.toRgba(on,an,ln)}e.blend=t;function n(u,h,f){let m=xn.relativeLuminance(u>>8),v=xn.relativeLuminance(h>>8);if(Ii(m,v)<f){if(v<m){let b=s(u,h,f),w=Ii(m,xn.relativeLuminance(b>>8));if(w<f){let k=o(u,h,f),C=Ii(m,xn.relativeLuminance(k>>8));return w>C?b:k}return b}let S=o(u,h,f),y=Ii(m,xn.relativeLuminance(S>>8));if(y<f){let b=s(u,h,f),w=Ii(m,xn.relativeLuminance(b>>8));return y>w?S:b}return S}}e.ensureContrastRatio=n;function s(u,h,f){let m=u>>24&255,v=u>>16&255,S=u>>8&255,y=h>>24&255,b=h>>16&255,w=h>>8&255,k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));for(;k<f&&(y>0||b>0||w>0);)y-=Math.max(0,Math.ceil(y*.1)),b-=Math.max(0,Math.ceil(b*.1)),w-=Math.max(0,Math.ceil(w*.1)),k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));return(y<<24|b<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,f){let m=u>>24&255,v=u>>16&255,S=u>>8&255,y=h>>24&255,b=h>>16&255,w=h>>8&255,k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));for(;k<f&&(y<255||b<255||w<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),k=Ii(xn.relativeLuminance2(y,b,w),xn.relativeLuminance2(m,v,S));return(y<<24|b<<16|w<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(Tl||(Tl={}));function Fs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ii(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var S1=class extends na{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ti}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),f=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==f){if(m-o>1){let v=this._getJoinedRanges(s,u,a,t,o);for(let S=0;S<v.length;S++)n.push(v[S])}o=m,u=a,h=this._workCell.fg,f=this._workCell.bg}a+=this._workCell.getChars().length||ms.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,a,t,o);for(let v=0;v<m.length;v++)n.push(m[v])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let f=this._characterJoiners[h].handler(a);for(let m=0;m<f.length;m++)Kl._mergeRanges(u,f[m])}catch(f){console.error(f)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=n;h<this._bufferService.cols;h++){let f=t.getWidth(h),m=t.getString(h).length||ms.length;if(f!==0){if(!o&&u[0]<=a&&(u[0]=h,o=!0),u[1]<=a){if(u[1]=h,u=e[++s],!u)break;u[0]<=a?(u[0]=h,o=!0):o=!1}a+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Kl=Bt([Re(0,Cn)],Kl);function x1(e){return 57508<=e&&e<=57558}function k1(e){return 9472<=e&&e<=9631}function C1(e){return x1(e)||k1(e)}function E1(){return{css:{canvas:yl(),cell:yl()},device:{canvas:yl(),cell:yl(),char:{width:0,height:0,left:0,top:0}}}}function yl(){return{width:0,height:0}}var yh=class{constructor(e,t,n,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new ti,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,h,f,m,v){let S=[],y=this._characterJoinerService.getJoinedCharacters(t),b=this._themeService.colors,w=e.getNoBgTrimmedLength();n&&w<a+1&&(w=a+1);let k,C=0,R="",E=0,F=0,I=0,K=0,Y=!1,z=0,Z=!1,G=0,Q=0,B=[],M=m!==-1&&v!==-1;for(let j=0;j<w;j++){e.loadCell(j,this._workCell);let T=this._workCell.getWidth();if(T===0)continue;let L=!1,$=j>=Q,H=j,x=this._workCell;if(y.length>0&&j===y[0][0]&&$){let Ae=y.shift(),Rt=this._isCellInSelection(Ae[0],t);for(E=Ae[0]+1;E<Ae[1];E++)$&&($=Rt===this._isCellInSelection(E,t));$&&($=!n||a<Ae[0]||a>=Ae[1]),$?(L=!0,x=new S1(this._workCell,e.translateToString(!0,Ae[0],Ae[1]),Ae[1]-Ae[0]),H=Ae[1]-1,T=x.getWidth()):Q=Ae[1]}let O=this._isCellInSelection(j,t),D=n&&j===a,A=M&&j>=m&&j<=v,W=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Ae=>{W=!0});let X=x.getChars()||ms;if(X===" "&&(x.isUnderline()||x.isOverline())&&(X=" "),G=T*h-f.get(X,x.isBold(),x.isItalic()),!k)k=this._document.createElement("span");else if(C&&(O&&Z||!O&&!Z&&x.bg===F)&&(O&&Z&&b.selectionForeground||x.fg===I)&&x.extended.ext===K&&A===Y&&G===z&&!D&&!L&&!W&&$){x.isInvisible()?R+=ms:R+=X,C++;continue}else C&&(k.textContent=R),k=this._document.createElement("span"),C=0,R="";if(F=x.bg,I=x.fg,K=x.extended.ext,Y=A,z=G,Z=O,L&&a>=j&&a<=H&&(a=j),!this._coreService.isCursorHidden&&D&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&B.push("xterm-cursor-blink"),B.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(x.isBold()&&B.push("xterm-bold"),x.isItalic()&&B.push("xterm-italic"),x.isDim()&&B.push("xterm-dim"),x.isInvisible()?R=ms:R=x.getChars()||ms,x.isUnderline()&&(B.push(`xterm-underline-${x.extended.underlineStyle}`),R===" "&&(R=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${na.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let Ae=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&Ae<8&&(Ae+=8),k.style.textDecorationColor=b.ansi[Ae].css}x.isOverline()&&(B.push("xterm-overline"),R===" "&&(R=" ")),x.isStrikethrough()&&B.push("xterm-strikethrough"),A&&(k.style.textDecoration="underline");let ie=x.getFgColor(),ce=x.getFgColorMode(),fe=x.getBgColor(),we=x.getBgColorMode(),me=!!x.isInverse();if(me){let Ae=ie;ie=fe,fe=Ae;let Rt=ce;ce=we,we=Rt}let xe,$e,ft=!1;this._decorationService.forEachDecorationAtCell(j,t,void 0,Ae=>{Ae.options.layer!=="top"&&ft||(Ae.backgroundColorRGB&&(we=50331648,fe=Ae.backgroundColorRGB.rgba>>8&16777215,xe=Ae.backgroundColorRGB),Ae.foregroundColorRGB&&(ce=50331648,ie=Ae.foregroundColorRGB.rgba>>8&16777215,$e=Ae.foregroundColorRGB),ft=Ae.options.layer==="top")}),!ft&&O&&(xe=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,fe=xe.rgba>>8&16777215,we=50331648,ft=!0,b.selectionForeground&&(ce=50331648,ie=b.selectionForeground.rgba>>8&16777215,$e=b.selectionForeground)),ft&&B.push("xterm-decoration-top");let qe;switch(we){case 16777216:case 33554432:qe=b.ansi[fe],B.push(`xterm-bg-${fe}`);break;case 50331648:qe=qt.toColor(fe>>16,fe>>8&255,fe&255),this._addStyle(k,`background-color:#${rv((fe>>>0).toString(16),"0",6)}`);break;case 0:default:me?(qe=b.foreground,B.push("xterm-bg-257")):qe=b.background}switch(xe||x.isDim()&&(xe=Ct.multiplyOpacity(qe,.5)),ce){case 16777216:case 33554432:x.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(k,qe,b.ansi[ie],x,xe,void 0)||B.push(`xterm-fg-${ie}`);break;case 50331648:let Ae=qt.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(k,qe,Ae,x,xe,$e)||this._addStyle(k,`color:#${rv(ie.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,qe,b.foreground,x,xe,$e)||me&&B.push("xterm-fg-257")}B.length&&(k.className=B.join(" "),B.length=0),!D&&!L&&!W&&$?C++:k.textContent=R,G!==this.defaultSpacing&&(k.style.letterSpacing=`${G}px`),S.push(k),j=H}return k&&C&&(k.textContent=R),S}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||C1(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,n.rgba)),h===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Ct.ensureContrastRatio(o||t,a||n,f),u.setColor((o||t).rgba,(a||n).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};yh=Bt([Re(1,Ty),Re(2,En),Re(3,$i),Re(4,Js),Re(5,ia),Re(6,$r)],yh);function rv(e,t,n){for(;e.length<n;)e=t+e;return e}var N1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,s,o,a],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),n&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},j1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[1]-o,h=Math.max(a,0),f=Math.min(u,e.rows-1);if(h>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=f,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function R1(){return new j1}var nd="xterm-dom-renderer-owner-",Jn="xterm-rows",wl="xterm-fg-",ov="xterm-bg-",Ao="xterm-focus",bl="xterm-selection",P1=1,wh=class extends st{constructor(e,t,n,s,o,a,u,h,f,m,v,S,y,b){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=f,this._optionsService=m,this._bufferService=v,this._coreService=S,this._coreBrowserService=y,this._themeService=b,this._terminalClass=P1++,this._rowElements=[],this._selectionRenderModel=R1(),this.onRequestRedraw=this._register(new Ne).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Jn),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(bl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=E1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(yh,document),this._element.classList.add(nd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(jt(()=>{this._element.classList.remove(nd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new N1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Jn} 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} .${Jn} { 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} .${Jn} .xterm-dim { color: ${Ct.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Jn}.${Ao} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Jn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${bl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${bl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${bl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${wl}${a} { color: ${u.css}; }${this._terminalSelector} .${wl}${a}.xterm-dim { color: ${Ct.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${ov}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${wl}257 { color: ${Ct.opaque(e.background).css}; }${this._terminalSelector} .${wl}257.xterm-dim { color: ${Ct.multiplyOpacity(Ct.opaque(e.background),.5).css}; }${this._terminalSelector} .${ov}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ao),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ao),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(n){let f=e[0]>t[0];h.appendChild(this._createSelectionElement(a,f?t[0]:e[0],f?e[0]:t[0],u-a+1))}else{let f=s===a?e[0]:0,m=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,f,m));let v=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,v)),a!==u){let S=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,S))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let m=f+n.ydisp,v=this._rowElements[f],S=n.lines.get(m);if(!v||!S)break;v.replaceChildren(...this._rowFactory.createRow(S,m,m===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${nd}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,f=h.ybase+h.y,m=Math.min(h.x,o-1),v=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=n;b<=s;++b){let w=b+h.ydisp,k=this._rowElements[b],C=h.lines.get(w);if(!k||!C)break;k.replaceChildren(...this._rowFactory.createRow(C,w,w===f,S,y,m,v,this.dimensions.css.cell.width,this._widthCache,a?b===n?e:0:-1,a?(b===s?t:o)-1:-1))}}};wh=Bt([Re(7,df),Re(8,tc),Re(9,En),Re(10,Cn),Re(11,Js),Re(12,$i),Re(13,$r)],wh);var bh=class extends st{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ne),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new A1(this._optionsService))}catch{this._measureStrategy=this._register(new L1(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())}};bh=Bt([Re(2,En)],bh);var Jy=class extends st{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)}},L1=class extends Jy{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},A1=class extends Jy{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}},T1=class extends st{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new D1(this._window)),this._onDprChange=this._register(new Ne),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ne),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(mn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Xe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Xe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},D1=class extends st{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Or),this._onDprChange=this._register(new Ne),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(jt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Xe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},M1=class extends st{constructor(){super(),this.linkProviders=[],this._register(jt(()=>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 yf(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function I1(e,t,n,s,o,a,u,h,f){if(!a)return;let m=yf(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(f?u/2:0))/u),m[1]=Math.ceil(m[1]/h),m[0]=Math.min(Math.max(m[0],1),s+(f?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var Sh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return I1(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=yf(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Sh=Bt([Re(0,Hi),Re(1,tc)],Sh);var O1=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Zy={};Vx(Zy,{getSafariVersion:()=>z1,isChromeOS:()=>iw,isFirefox:()=>ew,isIpad:()=>F1,isIphone:()=>$1,isLegacyEdge:()=>B1,isLinux:()=>wf,isMac:()=>ql,isNode:()=>nc,isSafari:()=>tw,isWindows:()=>nw});var nc=typeof process<"u"&&"title"in process,sa=nc?"node":navigator.userAgent,ra=nc?"node":navigator.platform,ew=sa.includes("Firefox"),B1=sa.includes("Edge"),tw=/^((?!chrome|android).)*safari/i.test(sa);function z1(){if(!tw)return 0;let e=sa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ql=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ra),F1=ra==="iPad",$1=ra==="iPhone",nw=["Windows","Win16","Win32","WinCE"].includes(ra),wf=ra.indexOf("Linux")>=0,iw=/\bCrOS\b/.test(sa),sw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},H1=class extends sw{_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())}}},U1=class extends sw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Vl=!nc&&"requestIdleCallback"in window?U1:H1,W1=class{constructor(){this._queue=new Vl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},xh=class extends st{constructor(e,t,n,s,o,a,u,h,f){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new Or),this._pausedResizeTask=new W1,this._observerDisposable=this._register(new Or),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 Ne),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ne),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ne),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ne),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new O1((m,v)=>this._renderRows(m,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new K1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(jt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=jt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};xh=Bt([Re(2,En),Re(3,tc),Re(4,Js),Re(5,ia),Re(6,Cn),Re(7,$i),Re(8,$r)],xh);var K1=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function q1(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return G1(o,a,e,t,n,s)+ic(a,t,n,s)+X1(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",Qo(Math.abs(o-e),Xo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),f=Y1(a>t?e:o,n)+(h-1)*n.cols+1+V1(a>t?o:e);return Qo(f,Xo(u,s))}function V1(e,t){return e-1}function Y1(e,t){return t.cols-e}function G1(e,t,n,s,o,a){return ic(t,s,o,a).length===0?"":Qo(ow(e,t,e,t-Qs(t,o),!1,o).length,Xo("D",a))}function ic(e,t,n,s){let o=e-Qs(e,n),a=t-Qs(t,n),u=Math.abs(o-a)-Q1(e,t,n);return Qo(u,Xo(rw(e,t),s))}function X1(e,t,n,s,o,a){let u;ic(t,s,o,a).length>0?u=s-Qs(s,o):u=t;let h=s,f=J1(e,t,n,s,o,a);return Qo(ow(e,u,n,h,f==="C",o).length,Xo(f,a))}function Q1(e,t,n){var u;let s=0,o=e-Qs(e,n),a=t-Qs(t,n);for(let h=0;h<Math.abs(o-a);h++){let f=rw(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+f*h))!=null&&u.isWrapped&&s++}return s}function Qs(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function J1(e,t,n,s,o,a){let u;return ic(n,s,o,a).length>0?u=s-Qs(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function rw(e,t){return e>t?"A":"B"}function ow(e,t,n,s,o,a){let u=e,h=t,f="";for(;(u!==n||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(f+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(f+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return f+a.buffer.translateBufferLineToString(h,!1,e,u)}function Xo(e,t){let n=t?"O":"[";return ve.ESC+n+e}function Qo(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var Z1=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 av(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 id=50,eC=15,tC=50,nC=500,iC=" ",sC=new RegExp(iC,"g"),kh=class extends st{constructor(e,t,n,s,o,a,u,h,f){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=h,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ti,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ne),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ne),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ne),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ne),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new Z1(this._bufferService),this._activeSelectionMode=0,this._register(jt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=n.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),h=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(sC," ")).join(nw?`\r
62
62
  `:`
63
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wf&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let n=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=av(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=yf(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-id),id),t/=id,t/Math.abs(t)+Math.round(t*(eC-1)))}shouldForceSelection(e){return ql?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(),tC)}_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&&!(ql&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<nC&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=q1(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),f=h,m=e[0]-h,v=0,S=0,y=0,b=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;f<u.length&&u.charAt(f+1)===" ";)f++}else{let C=e[0],R=e[0];a.getWidth(C)===0&&(v++,C--),a.getWidth(R)===2&&(S++,R++);let E=a.getString(R).length;for(E>1&&(b+=E-1,f+=E-1);C>0&&h>0&&!this._isCharWordSeparator(a.loadCell(C-1,this._workCell));){a.loadCell(C-1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,C--):F>1&&(y+=F-1,h-=F-1),h--,C--}for(;R<a.length&&f+1<u.length&&!this._isCharWordSeparator(a.loadCell(R+1,this._workCell));){a.loadCell(R+1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,R++):F>1&&(b+=F-1,f+=F-1),f++,R++}}f++;let w=h+m-v+y,k=Math.min(this._bufferService.cols,f-h+v+S-y-b);if(!(!t&&u.slice(h,f).trim()==="")){if(n&&w===0&&a.getCodePoint(0)!==32){let C=o.lines.get(e[1]-1);if(C&&a.isWrapped&&C.getCodePoint(this._bufferService.cols-1)!==32){let R=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(R){let E=this._bufferService.cols-R.start;w-=E,k+=E}}}if(s&&w+k===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let C=o.lines.get(e[1]+1);if(C!=null&&C.isWrapped&&C.getCodePoint(0)!==32){let R=this._getWordAt([0,e[1]+1],!1,!1,!0);R&&(k+=R.length)}}return{start:w,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=av(n,this._bufferService.cols)}};kh=Bt([Re(3,Cn),Re(4,Js),Re(5,hf),Re(6,En),Re(7,Hi),Re(8,$i)],kh);var lv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},cv=class{constructor(){this._color=new lv,this._css=new lv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Gt=Object.freeze((()=>{let e=[Dt.toColor("#2e3436"),Dt.toColor("#cc0000"),Dt.toColor("#4e9a06"),Dt.toColor("#c4a000"),Dt.toColor("#3465a4"),Dt.toColor("#75507b"),Dt.toColor("#06989a"),Dt.toColor("#d3d7cf"),Dt.toColor("#555753"),Dt.toColor("#ef2929"),Dt.toColor("#8ae234"),Dt.toColor("#fce94f"),Dt.toColor("#729fcf"),Dt.toColor("#ad7fa8"),Dt.toColor("#34e2e2"),Dt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],a=t[n%6];e.push({css:qt.toCss(s,o,a),rgba:qt.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:qt.toCss(s,s,s),rgba:qt.toRgba(s,s,s)})}return e})()),Us=Dt.toColor("#ffffff"),Ho=Dt.toColor("#000000"),uv=Dt.toColor("#ffffff"),dv=Ho,To={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},rC=Us,Ch=class extends st{constructor(e){super(),this._optionsService=e,this._contrastCache=new cv,this._halfContrastCache=new cv,this._onChangeColors=this._register(new Ne),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Us,background:Ho,cursor:uv,cursorAccent:dv,selectionForeground:void 0,selectionBackgroundTransparent:To,selectionBackgroundOpaque:Ct.blend(Ho,To),selectionInactiveBackgroundTransparent:To,selectionInactiveBackgroundOpaque:Ct.blend(Ho,To),scrollbarSliderBackground:Ct.opacity(Us,.2),scrollbarSliderHoverBackground:Ct.opacity(Us,.4),scrollbarSliderActiveBackground:Ct.opacity(Us,.5),overviewRulerBorder:Us,ansi:Gt.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=gt(e.foreground,Us),t.background=gt(e.background,Ho),t.cursor=Ct.blend(t.background,gt(e.cursor,uv)),t.cursorAccent=Ct.blend(t.background,gt(e.cursorAccent,dv)),t.selectionBackgroundTransparent=gt(e.selectionBackground,To),t.selectionBackgroundOpaque=Ct.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=gt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ct.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?gt(e.selectionForeground,sv):void 0,t.selectionForeground===sv&&(t.selectionForeground=void 0),Ct.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ct.opacity(t.selectionBackgroundTransparent,.3)),Ct.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ct.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=gt(e.scrollbarSliderBackground,Ct.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=gt(e.scrollbarSliderHoverBackground,Ct.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=gt(e.scrollbarSliderActiveBackground,Ct.opacity(t.foreground,.5)),t.overviewRulerBorder=gt(e.overviewRulerBorder,rC),t.ansi=Gt.slice(),t.ansi[0]=gt(e.black,Gt[0]),t.ansi[1]=gt(e.red,Gt[1]),t.ansi[2]=gt(e.green,Gt[2]),t.ansi[3]=gt(e.yellow,Gt[3]),t.ansi[4]=gt(e.blue,Gt[4]),t.ansi[5]=gt(e.magenta,Gt[5]),t.ansi[6]=gt(e.cyan,Gt[6]),t.ansi[7]=gt(e.white,Gt[7]),t.ansi[8]=gt(e.brightBlack,Gt[8]),t.ansi[9]=gt(e.brightRed,Gt[9]),t.ansi[10]=gt(e.brightGreen,Gt[10]),t.ansi[11]=gt(e.brightYellow,Gt[11]),t.ansi[12]=gt(e.brightBlue,Gt[12]),t.ansi[13]=gt(e.brightMagenta,Gt[13]),t.ansi[14]=gt(e.brightCyan,Gt[14]),t.ansi[15]=gt(e.brightWhite,Gt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=gt(e.extendedAnsi[s],Gt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Ch=Bt([Re(0,En)],Ch);function gt(e,t){if(e!==void 0)try{return Dt.toColor(e)}catch{}return t}var oC=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},aC=class{constructor(){this._services=new oC,this._services.set(df,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=ek(e).sort((a,u)=>a.index-u.index),s=[];for(let a of n){let u=this._services.get(a.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},lC={trace:0,debug:1,info:2,warn:3,error:4,off:5},cC="xterm.js: ",Eh=class extends st{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=lC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":cC)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Eh=Bt([Re(0,En)],Eh);var hv=class extends st{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ne),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ne),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ne),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},it=3,Kt=Object.freeze(new na),Sl=0,sd=2,Uo=class aw{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*it);let o=n||ti.fromCharData([0,Ey,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*it+0],s=n&2097151;return[this._data[t*it+1],n&2097152?this._combined[t]:s?fs(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*it+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*it+0]=t|2097152|n[2]<<22):this._data[t*it+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*it+0]>>22}hasWidth(t){return this._data[t*it+0]&12582912}getFg(t){return this._data[t*it+1]}getBg(t){return this._data[t*it+2]}hasContent(t){return this._data[t*it+0]&4194303}getCodePoint(t){let n=this._data[t*it+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*it+0]&2097152}getString(t){let n=this._data[t*it+0];return n&2097152?this._combined[t]:n&2097151?fs(n&2097151):""}isProtected(t){return this._data[t*it+2]&536870912}loadCell(t,n){return Sl=t*it,n.content=this._data[Sl+0],n.fg=this._data[Sl+1],n.bg=this._data[Sl+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*it+0]=n.content,this._data[t*it+1]=n.fg,this._data[t*it+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*it+0]=n|s<<22,this._data[t*it+1]=o.fg,this._data[t*it+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*it+0];o&2097152?this._combined[t]+=fs(n):o&2097151?(this._combined[t]=fs(o&2097151)+fs(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*it+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new ti;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,o));for(let a=0;a<n;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new ti;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,o));for(let a=this.length-n;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*sd<this._data.buffer.byteLength;let s=t*it;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let h=parseInt(o[u],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*sd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*sd<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new aw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303)return t+(this._data[t*it+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303||this._data[t*it+2]&50331648)return t+(this._data[t*it+0]>>22);return 0}copyCellsFrom(t,n,s,o,a){let u=t._data;if(a)for(let f=o-1;f>=0;f--){for(let m=0;m<it;m++)this._data[(s+f)*it+m]=u[(n+f)*it+m];u[(n+f)*it+2]&268435456&&(this._extendedAttrs[s+f]=t._extendedAttrs[n+f])}else for(let f=0;f<o;f++){for(let m=0;m<it;m++)this._data[(s+f)*it+m]=u[(n+f)*it+m];u[(n+f)*it+2]&268435456&&(this._extendedAttrs[s+f]=t._extendedAttrs[n+f])}let h=Object.keys(t._combined);for(let f=0;f<h.length;f++){let m=parseInt(h[f],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;n<s;){let u=this._data[n*it+0],h=u&2097151,f=u&2097152?this._combined[n]:h?fs(h):ms;if(a+=f,o)for(let m=0;m<f.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function uC(e,t,n,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let f=h,m=e.get(++f);if(!m.isWrapped)continue;let v=[e.get(h)];for(;f<e.length&&m.isWrapped;)v.push(m),m=e.get(++f);if(!a&&s>=h&&s<f){h+=v.length-1;continue}let S=0,y=Jo(v,S,t),b=1,w=0;for(;b<v.length;){let C=Jo(v,b,t),R=C-w,E=n-y,F=Math.min(R,E);v[S].copyCellsFrom(v[b],w,y,F,!1),y+=F,y===n&&(S++,y=0),w+=F,w===C&&(b++,w=0),y===0&&S!==0&&v[S-1].getWidth(n-1)===2&&(v[S].copyCellsFrom(v[S-1],n-1,y++,1,!1),v[S-1].setCell(n-1,o))}v[S].replaceCells(y,n,o);let k=0;for(let C=v.length-1;C>0&&(C>S||v[C].getTrimmedLength()===0);C--)k++;k>0&&(u.push(h+v.length-k),u.push(k)),h+=v.length-1}return u}function dC(e,t){let n=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let h=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:h}),u+=h-1,a+=h,o=t[++s]}else n.push(u);return{layout:n,countRemoved:a}}function hC(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function fC(e,t,n){let s=[],o=e.map((f,m)=>Jo(e,m,t)).reduce((f,m)=>f+m),a=0,u=0,h=0;for(;h<o;){if(o-h<n){s.push(o-h);break}a+=n;let f=Jo(e,u,t);a>f&&(a-=f,u++);let m=e[u].getWidth(a-1)===2;m&&a--;let v=m?n-1:n;s.push(v),h+=v}return s}function Jo(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var lw=class cw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=cw._nextId++,this._onDispose=this.register(new Ne),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Xs(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};lw._nextId=1;var pC=lw,Qt={},Ws=Qt.B;Qt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Qt.A={"#":"£"};Qt.B=void 0;Qt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Qt.C=Qt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Qt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Qt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Qt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Qt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Qt.E=Qt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Qt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Qt.H=Qt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Qt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fv=4294967295,pv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Kt.clone(),this.savedCharset=Ws,this.markers=[],this._nullCell=ti.fromCharData([0,Ey,1,0]),this._whitespaceCell=ti.fromCharData([0,ms,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Vl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hv(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 Ul),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 Ul),this._whitespaceCell}getBlankLine(e,t){return new Uo(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>fv?fv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Kt);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 hv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Kt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let a=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Uo(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Uo(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=uC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Kt),n);if(s.length>0){let o=dC(this.lines,s);hC(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Kt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Uo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Kt),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let h=this.lines.get(u);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let f=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),f.unshift(h);if(!n){let F=this.ybase+this.y;if(F>=u&&F<u+f.length)continue}let m=f[f.length-1].getTrimmedLength(),v=fC(f,this._cols,e),S=v.length-f.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+S):y=Math.max(0,this.lines.length-this.lines.maxLength+S);let b=[];for(let F=0;F<S;F++){let I=this.getBlankLine(Kt,!0);b.push(I)}b.length>0&&(o.push({start:u+f.length+a,newLines:b}),a+=b.length),f.push(...b);let w=v.length-1,k=v[w];k===0&&(w--,k=v[w]);let C=f.length-S-1,R=m;for(;C>=0;){let F=Math.min(R,k);if(f[w]===void 0)break;if(f[w].copyCellsFrom(f[C],R-F,k-F,F,!0),k-=F,k===0&&(w--,k=v[w]),R-=F,R===0){C--;let I=Math.max(C,0);R=Jo(f,I,this._cols)}}for(let F=0;F<f.length;F++)v[F]<e&&f[F].setCell(v[F],s);let E=S-y;for(;E-- >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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let k=0;k<this.lines.length;k++)h.push(this.lines.get(k));let f=this.lines.length,m=f-1,v=0,S=o[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let k=Math.min(this.lines.maxLength-1,f+a-1);k>=0;k--)if(S&&S.start>m+y){for(let C=S.newLines.length-1;C>=0;C--)this.lines.set(k--,S.newLines[C]);k++,u.push({index:m+1,amount:S.newLines.length}),y+=S.newLines.length,S=o[++v]}else this.lines.set(k,h[m--]);let b=0;for(let k=u.length-1;k>=0;k--)u[k].index+=b,this.lines.onInsertEmitter.fire(u[k]),b+=u[k].amount;let w=Math.max(0,f+a-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new pC(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},mC=class extends st{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ne),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 pv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new pv(!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)}},uw=2,dw=1,Nh=class extends st{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ne),this.onResize=this._onResize.event,this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,uw),this.rows=Math.max(e.rawOptions.rows||0,dw),this.buffers=this._register(new mC(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;a===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=a-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Nh=Bt([Re(0,En)],Nh);var Er={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:ql,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},gC=["normal","bold","100","200","300","400","500","600","700","800","900"],vC=class extends st{constructor(e){super(),this._onOptionChange=this._register(new Ne),this.onOptionChange=this._onOptionChange.event;let t={...Er};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(jt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Er))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Er))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Er[e]),!_C(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Er[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=gC.includes(t)?t:Er[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 _C(e){return e==="block"||e==="underline"||e==="bar"}function Wo(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Wo(e[s],t-1);return n}var mv=Object.freeze({insertMode:!1}),gv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),jh=class extends st{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ne),this.onData=this._onData.event,this._onUserInput=this._register(new Ne),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ne),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ne),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Wo(mv),this.decPrivateModes=Wo(gv)}reset(){this.modes=Wo(mv),this.decPrivateModes=Wo(gv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};jh=Bt([Re(0,Cn),Re(1,Ly),Re(2,En)],jh);var vv={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 rd(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var od=String.fromCharCode,_v={DEFAULT:e=>{let t=[rd(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${od(t[0])}${od(t[1])}${od(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${rd(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${rd(e,!0)};${e.x};${e.y}${t}`}},Rh=class extends st{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ne),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(vv))this.addProtocol(s,vv[s]);for(let s of Object.keys(_v))this.addEncoding(s,_v[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Rh=Bt([Re(0,Cn),Re(1,Js),Re(2,En)],Rh);var ad=[[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]],yC=[[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]],Xt;function wC(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var bC=class{constructor(){if(this.version="6",!Xt){Xt=new Uint8Array(65536),Xt.fill(1),Xt[0]=0,Xt.fill(0,1,32),Xt.fill(0,127,160),Xt.fill(2,4352,4448),Xt[9001]=2,Xt[9002]=2,Xt.fill(2,11904,42192),Xt[12351]=1,Xt.fill(2,44032,55204),Xt.fill(2,63744,64256),Xt.fill(2,65040,65050),Xt.fill(2,65072,65136),Xt.fill(2,65280,65377),Xt.fill(2,65504,65511);for(let e=0;e<ad.length;++e)Xt.fill(0,ad[e][0],ad[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Xt[e]:wC(e,yC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Vs.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Vs.createPropertyValue(0,n,s)}},Vs=class Dl{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ne,this.onChange=this._onChange.event;let t=new bC;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return n+this.wcwidth(u);let m=t.charCodeAt(a);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let h=this.charProperties(u,s),f=Dl.extractWidth(h);Dl.extractShouldJoin(h)&&(f-=Dl.extractWidth(s)),n+=f,s=h}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},SC=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 yv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Do=2147483647,xC=256,hw=class Ph{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>xC)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Ph;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)n.addSubParam(o[a]);else n.addParam(o)}return n}clone(){let t=new Ph(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>Do?Do: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>Do?Do:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Do):t}},Mo=[],kC=class{constructor(){this._state=0,this._active=Mo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Mo}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=Mo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Mo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Mo,this._id=-1,this._state=0}}},Fn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Io=[],CC=class{constructor(){this._handlers=Object.create(null),this._active=Io,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Io}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Io,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Io,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Io,this._ident=0}},Ko=new hw;Ko.addParam(0);var wv=class{constructor(e){this._handler=e,this._data="",this._params=Ko,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ko,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Ko,this._data="",this._hitLimit=!1,n));return this._params=Ko,this._data="",this._hitLimit=!1,t}},EC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},ei=160,NC=(function(){let e=new EC(4095),t=Array.apply(null,Array(256)).map((h,f)=>f),n=(h,f)=>t.slice(h,f),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let a=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in a)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ei,0,2,0),e.add(ei,8,5,8),e.add(ei,6,0,6),e.add(ei,11,0,11),e.add(ei,13,13,13),e})(),jC=class extends st{constructor(e=NC){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 hw,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(jt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kC),this._dcsParser=this._register(new CC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(u=h[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(u=h[f](),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:ei)],o>>4){case 2:for(let y=h+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|s],m=f?f.length-1:-1;for(;m>=0&&(u=f[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,f,m,o,h),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let v=this._escHandlers[this._collect<<8|s],S=v?v.length-1:-1;for(;S>=0&&(u=v[S](),u!==!0);S--)if(u instanceof Promise)return this._preserveStack(4,v,S,o,h),u;S<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=h+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<ei){this._dcsParser.put(e,h,y),h=y-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,h),u;s===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 y=h+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<ei){this._oscParser.put(e,h,y),h=y-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},RC=/^([\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})$/,PC=/^[\da-f]+$/;function bv(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=RC.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),PC.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function ld(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function LC(e,t=16){let[n,s,o]=e;return`rgb:${ld(n,t)}/${ld(s,t)}/${ld(o,t)}`}var AC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ds=131072,Sv=10;function xv(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 kv=5e3,Cv=0,TC=class extends st{constructor(e,t,n,s,o,a,u,h,f=new jC){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Jx,this._utf8Decoder=new Zx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Kt.clone(),this._eraseAttrDataInternal=Kt.clone(),this._onRequestBell=this._register(new Ne),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ne),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ne),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ne),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ne),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ne),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ne),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ne),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ne),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ne),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ne),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ne),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 Lh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:v.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,v,S)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:v,data:S})}),this._parser.setDcsHandlerFallback((m,v,S)=>{v==="HOOK"&&(S=S.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:v,payload:S})}),this._parser.setPrintHandler((m,v,S)=>this.print(m,v,S)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ve.BEL,()=>this.bell()),this._parser.setExecuteHandler(ve.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ve.BS,()=>this.backspace()),this._parser.setExecuteHandler(ve.HT,()=>this.tab()),this._parser.setExecuteHandler(ve.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ve.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Al.IND,()=>this.index()),this._parser.setExecuteHandler(Al.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Al.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Fn(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new Fn(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new Fn(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new Fn(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new Fn(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new Fn(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new Fn(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new Fn(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new Fn(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new Fn(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new Fn(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new Fn(m=>this.restoreCursorColor(m))),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 m in Qt)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new wv((m,v)=>this.requestStatusString(m,v)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),kv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ds&&(a=this._parseStack.position+ds)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ds&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ds))),u||this._dirtyRowTracker.clearRange(),e.length>ds)for(let m=a;m<e.length;m+=ds){let v=m+ds<e.length?m+ds:e.length,S=typeof e=="string"?this._stringDecoder.decode(e.substring(m,v),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,S))return this._preserveStack(s,o,S,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,v=this._curAttrData,S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let y=this._parser.precedingJoinState;for(let b=t;b<n;++b){if(s=e[b],s<127&&a){let R=a[String.fromCharCode(s)];R&&(s=R.charCodeAt(0))}let w=this._unicodeService.charProperties(s,y);o=Vs.extractWidth(w);let k=Vs.extractShouldJoin(w),C=k?Vs.extractWidth(y):0;if(y=w,u&&this._onA11yChar.fire(fs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-C>h){if(f){let R=S,E=this._activeBuffer.x-C;for(this._activeBuffer.x=C,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),S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),C>0&&S instanceof Uo&&S.copyCellsFrom(R,E,0,C,!1);E<h;)R.setCellFromCodepoint(E++,0,1,v)}else if(this._activeBuffer.x=h-1,o===2)continue}if(k&&this._activeBuffer.x){let R=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-R,s,o);for(let E=o-C;--E>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(m&&(S.insertCells(this._activeBuffer.x,o-C,this._activeBuffer.getNullCell(v)),S.getWidth(h-1)===2&&S.setCellFromCodepoint(h-1,0,1,v)),S.setCellFromCodepoint(this._activeBuffer.x++,s,o,v),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=y,this._activeBuffer.x<h&&n-t>0&&S.getWidth(this._activeBuffer.x)===0&&!S.hasContent(this._activeBuffer.x)&&S.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>xv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new wv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Fn(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Kt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Vs.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*n),h=0;for(let m=0;m<a.length;){let v=a.codePointAt(m)||0;u[h++]=v,m+=v>65535?2:1}let f=h;for(let m=1;m<n;++m)u.copyWithin(f,0,h),f+=h;return this.print(u,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ve.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ve.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ve.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ve.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ve.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,Ws),this._charsetService.setgCharset(1,Ws),this._charsetService.setgCharset(2,Ws),this._charsetService.setgCharset(3,Ws);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){(k=>(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:f}=this._bufferService,{active:m,alt:v}=h,S=this._optionsService.rawOptions,y=(k,C)=>(u.triggerDataEvent(`${ve.ESC}[${t?"":"?"}${k};${C}$y`),!0),b=k=>k?1:2,w=e.params[0];return t?w===2?y(w,4):w===4?y(w,b(u.modes.insertMode)):w===12?y(w,3):w===20?y(w,b(S.convertEol)):y(w,0):w===1?y(w,b(s.applicationCursorKeys)):w===3?y(w,S.windowOptions.setWinLines?f===80?2:f===132?1:0:0):w===6?y(w,b(s.origin)):w===7?y(w,b(s.wraparound)):w===8?y(w,3):w===9?y(w,b(o==="X10")):w===12?y(w,b(S.cursorBlink)):w===25?y(w,b(!u.isCursorHidden)):w===45?y(w,b(s.reverseWraparound)):w===66?y(w,b(s.applicationKeypad)):w===67?y(w,4):w===1e3?y(w,b(o==="VT200")):w===1002?y(w,b(o==="DRAG")):w===1003?y(w,b(o==="ANY")):w===1004?y(w,b(s.sendFocus)):w===1005?y(w,4):w===1006?y(w,b(a==="SGR")):w===1015?y(w,4):w===1016?y(w,b(a==="SGR_PIXELS")):w===1048?y(w,1):w===47||w===1047||w===1049?y(w,b(m===v)):w===2004?y(w,b(s.bracketedPasteMode)):w===2026?y(w,b(s.synchronizedOutput)):y(w,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=na.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=u[h];while(++h<u.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_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=Kt.fg,e.bg=Kt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Kt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Kt.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Kt.fg&16777215,s.bg&=-67108864,s.bg|=Kt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ve.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[?${t};${n}R`);break}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=Kt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!xv(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(`${ve.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Sv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Sv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Ev(a))if(o==="?")t.push({type:0,index:a});else{let u=bv(o);u&&t.push({type:1,index:a,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=bv(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Ev(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,Ws),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(AC[e[0]],Qt[e[1]]||Ws),!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=Kt.clone(),this._eraseAttrDataInternal=Kt.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 ti;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ve.ESC}${u}${ve.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.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)}},Lh=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&&(Cv=e,e=t,t=Cv),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Lh=Bt([Re(0,Cn)],Lh);function Ev(e){return 0<=e&&e<256}var DC=5e7,Nv=12,MC=50,IC=class extends st{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 Ne),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>DC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-n>=Nv?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(n,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Nv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>MC&&(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()}},Ah=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 h=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(f,h)),this._dataByLinkId.set(f.id,f),f.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(u,a)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Ah=Bt([Re(0,Cn)],Ah);var jv=!1,OC=class extends st{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Or),this._onBinary=this._register(new Ne),this.onBinary=this._onBinary.event,this._onData=this._register(new Ne),this.onData=this._onData.event,this._onLineFeed=this._register(new Ne),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ne),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ne),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ne),this._instantiationService=new aC,this.optionsService=this._register(new vC(e)),this._instantiationService.setService(En,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Nh)),this._instantiationService.setService(Cn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Eh)),this._instantiationService.setService(Ly,this._logService),this.coreService=this._register(this._instantiationService.createInstance(jh)),this._instantiationService.setService(Js,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Rh)),this._instantiationService.setService(Py,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Vs)),this._instantiationService.setService(ik,this.unicodeService),this._charsetService=this._instantiationService.createInstance(SC),this._instantiationService.setService(nk,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ah),this._instantiationService.setService(Ay,this._oscLinkService),this._inputHandler=this._register(new TC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mn.forward(this._bufferService.onResize,this._onResize)),this._register(mn.forward(this.coreService.onData,this._onData)),this._register(mn.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 IC((t,n)=>this._inputHandler.parse(t,n))),this._register(mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ne),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!jv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jv=!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,uw),t=Math.max(t,dw),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(yv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(yv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=jt(()=>{for(let t of e)t.dispose()})}}},BC={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 zC(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},a=(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=ve.ESC+"OA":o.key=ve.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ve.DEL,e.altKey&&(o.key=ve.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ve.ESC+"[Z";break}o.key=ve.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ve.ESC+ve.CR:ve.CR,o.cancel=!0;break;case 27:o.key=ve.ESC,e.altKey&&(o.key=ve.ESC+ve.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"D":t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"C":t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"A":t?o.key=ve.ESC+"OA":o.key=ve.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"B":t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ve.ESC+"[2~");break;case 46:a?o.key=ve.ESC+"[3;"+(a+1)+"~":o.key=ve.ESC+"[3~";break;case 36:a?o.key=ve.ESC+"[1;"+(a+1)+"H":t?o.key=ve.ESC+"OH":o.key=ve.ESC+"[H";break;case 35:a?o.key=ve.ESC+"[1;"+(a+1)+"F":t?o.key=ve.ESC+"OF":o.key=ve.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ve.ESC+"[5;"+(a+1)+"~":o.key=ve.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ve.ESC+"[6;"+(a+1)+"~":o.key=ve.ESC+"[6~";break;case 112:a?o.key=ve.ESC+"[1;"+(a+1)+"P":o.key=ve.ESC+"OP";break;case 113:a?o.key=ve.ESC+"[1;"+(a+1)+"Q":o.key=ve.ESC+"OQ";break;case 114:a?o.key=ve.ESC+"[1;"+(a+1)+"R":o.key=ve.ESC+"OR";break;case 115:a?o.key=ve.ESC+"[1;"+(a+1)+"S":o.key=ve.ESC+"OS";break;case 116:a?o.key=ve.ESC+"[15;"+(a+1)+"~":o.key=ve.ESC+"[15~";break;case 117:a?o.key=ve.ESC+"[17;"+(a+1)+"~":o.key=ve.ESC+"[17~";break;case 118:a?o.key=ve.ESC+"[18;"+(a+1)+"~":o.key=ve.ESC+"[18~";break;case 119:a?o.key=ve.ESC+"[19;"+(a+1)+"~":o.key=ve.ESC+"[19~";break;case 120:a?o.key=ve.ESC+"[20;"+(a+1)+"~":o.key=ve.ESC+"[20~";break;case 121:a?o.key=ve.ESC+"[21;"+(a+1)+"~":o.key=ve.ESC+"[21~";break;case 122:a?o.key=ve.ESC+"[23;"+(a+1)+"~":o.key=ve.ESC+"[23~";break;case 123:a?o.key=ve.ESC+"[24;"+(a+1)+"~":o.key=ve.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=ve.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ve.DEL:e.keyCode===219?o.key=ve.ESC:e.keyCode===220?o.key=ve.FS:e.keyCode===221&&(o.key=ve.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=(u=BC[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=ve.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(f);e.shiftKey&&(m=m.toUpperCase()),o.key=ve.ESC+m}else if(e.keyCode===32)o.key=ve.ESC+(e.ctrlKey?ve.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=ve.ESC+f,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ve.US),e.key==="@"&&(o.key=ve.NUL));break}return o}var $t=0,FC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Vl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Vl,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,a)=>this._getKey(o)-this._getKey(a)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($t=this._search(t),$t===-1)||this._getKey(this._array[$t])!==t)return!1;do if(this._array[$t]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($t),!0;while(++$t<this._array.length&&this._getKey(this._array[$t])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do yield this._array[$t];while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do t(this._array[$t]);while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},cd=0,Rv=0,$C=class extends st{constructor(){super(),this._decorations=new FC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Ne),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ne),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(jt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new HC(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{cd=o.options.x??0,Rv=cd+(o.options.width??1),e>=cd&&e<Rv&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},HC=class extends _s{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ne),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ne),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=Dt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Dt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},UC=1e3,WC=class{constructor(e,t=UC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_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)}},Pv=20,Yl=class extends st{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let 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 a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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 WC(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(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
63
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wf&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let n=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=av(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=yf(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-id),id),t/=id,t/Math.abs(t)+Math.round(t*(eC-1)))}shouldForceSelection(e){return ql?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(),tC)}_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&&!(ql&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<nC&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=q1(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),f=h,m=e[0]-h,v=0,S=0,y=0,b=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;f<u.length&&u.charAt(f+1)===" ";)f++}else{let C=e[0],R=e[0];a.getWidth(C)===0&&(v++,C--),a.getWidth(R)===2&&(S++,R++);let E=a.getString(R).length;for(E>1&&(b+=E-1,f+=E-1);C>0&&h>0&&!this._isCharWordSeparator(a.loadCell(C-1,this._workCell));){a.loadCell(C-1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,C--):F>1&&(y+=F-1,h-=F-1),h--,C--}for(;R<a.length&&f+1<u.length&&!this._isCharWordSeparator(a.loadCell(R+1,this._workCell));){a.loadCell(R+1,this._workCell);let F=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,R++):F>1&&(b+=F-1,f+=F-1),f++,R++}}f++;let w=h+m-v+y,k=Math.min(this._bufferService.cols,f-h+v+S-y-b);if(!(!t&&u.slice(h,f).trim()==="")){if(n&&w===0&&a.getCodePoint(0)!==32){let C=o.lines.get(e[1]-1);if(C&&a.isWrapped&&C.getCodePoint(this._bufferService.cols-1)!==32){let R=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(R){let E=this._bufferService.cols-R.start;w-=E,k+=E}}}if(s&&w+k===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let C=o.lines.get(e[1]+1);if(C!=null&&C.isWrapped&&C.getCodePoint(0)!==32){let R=this._getWordAt([0,e[1]+1],!1,!1,!0);R&&(k+=R.length)}}return{start:w,length:k}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=av(n,this._bufferService.cols)}};kh=Bt([Re(3,Cn),Re(4,Js),Re(5,hf),Re(6,En),Re(7,Hi),Re(8,$i)],kh);var lv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},cv=class{constructor(){this._color=new lv,this._css=new lv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Xt=Object.freeze((()=>{let e=[Dt.toColor("#2e3436"),Dt.toColor("#cc0000"),Dt.toColor("#4e9a06"),Dt.toColor("#c4a000"),Dt.toColor("#3465a4"),Dt.toColor("#75507b"),Dt.toColor("#06989a"),Dt.toColor("#d3d7cf"),Dt.toColor("#555753"),Dt.toColor("#ef2929"),Dt.toColor("#8ae234"),Dt.toColor("#fce94f"),Dt.toColor("#729fcf"),Dt.toColor("#ad7fa8"),Dt.toColor("#34e2e2"),Dt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],a=t[n%6];e.push({css:qt.toCss(s,o,a),rgba:qt.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:qt.toCss(s,s,s),rgba:qt.toRgba(s,s,s)})}return e})()),Us=Dt.toColor("#ffffff"),Ho=Dt.toColor("#000000"),uv=Dt.toColor("#ffffff"),dv=Ho,To={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},rC=Us,Ch=class extends st{constructor(e){super(),this._optionsService=e,this._contrastCache=new cv,this._halfContrastCache=new cv,this._onChangeColors=this._register(new Ne),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Us,background:Ho,cursor:uv,cursorAccent:dv,selectionForeground:void 0,selectionBackgroundTransparent:To,selectionBackgroundOpaque:Ct.blend(Ho,To),selectionInactiveBackgroundTransparent:To,selectionInactiveBackgroundOpaque:Ct.blend(Ho,To),scrollbarSliderBackground:Ct.opacity(Us,.2),scrollbarSliderHoverBackground:Ct.opacity(Us,.4),scrollbarSliderActiveBackground:Ct.opacity(Us,.5),overviewRulerBorder:Us,ansi:Xt.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=gt(e.foreground,Us),t.background=gt(e.background,Ho),t.cursor=Ct.blend(t.background,gt(e.cursor,uv)),t.cursorAccent=Ct.blend(t.background,gt(e.cursorAccent,dv)),t.selectionBackgroundTransparent=gt(e.selectionBackground,To),t.selectionBackgroundOpaque=Ct.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=gt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ct.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?gt(e.selectionForeground,sv):void 0,t.selectionForeground===sv&&(t.selectionForeground=void 0),Ct.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ct.opacity(t.selectionBackgroundTransparent,.3)),Ct.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ct.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=gt(e.scrollbarSliderBackground,Ct.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=gt(e.scrollbarSliderHoverBackground,Ct.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=gt(e.scrollbarSliderActiveBackground,Ct.opacity(t.foreground,.5)),t.overviewRulerBorder=gt(e.overviewRulerBorder,rC),t.ansi=Xt.slice(),t.ansi[0]=gt(e.black,Xt[0]),t.ansi[1]=gt(e.red,Xt[1]),t.ansi[2]=gt(e.green,Xt[2]),t.ansi[3]=gt(e.yellow,Xt[3]),t.ansi[4]=gt(e.blue,Xt[4]),t.ansi[5]=gt(e.magenta,Xt[5]),t.ansi[6]=gt(e.cyan,Xt[6]),t.ansi[7]=gt(e.white,Xt[7]),t.ansi[8]=gt(e.brightBlack,Xt[8]),t.ansi[9]=gt(e.brightRed,Xt[9]),t.ansi[10]=gt(e.brightGreen,Xt[10]),t.ansi[11]=gt(e.brightYellow,Xt[11]),t.ansi[12]=gt(e.brightBlue,Xt[12]),t.ansi[13]=gt(e.brightMagenta,Xt[13]),t.ansi[14]=gt(e.brightCyan,Xt[14]),t.ansi[15]=gt(e.brightWhite,Xt[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=gt(e.extendedAnsi[s],Xt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Ch=Bt([Re(0,En)],Ch);function gt(e,t){if(e!==void 0)try{return Dt.toColor(e)}catch{}return t}var oC=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},aC=class{constructor(){this._services=new oC,this._services.set(df,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=ek(e).sort((a,u)=>a.index-u.index),s=[];for(let a of n){let u=this._services.get(a.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(u)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},lC={trace:0,debug:1,info:2,warn:3,error:4,off:5},cC="xterm.js: ",Eh=class extends st{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=lC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":cC)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Eh=Bt([Re(0,En)],Eh);var hv=class extends st{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ne),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ne),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ne),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},it=3,Kt=Object.freeze(new na),Sl=0,sd=2,Uo=class aw{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*it);let o=n||ti.fromCharData([0,Ey,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*it+0],s=n&2097151;return[this._data[t*it+1],n&2097152?this._combined[t]:s?fs(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*it+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*it+0]=t|2097152|n[2]<<22):this._data[t*it+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*it+0]>>22}hasWidth(t){return this._data[t*it+0]&12582912}getFg(t){return this._data[t*it+1]}getBg(t){return this._data[t*it+2]}hasContent(t){return this._data[t*it+0]&4194303}getCodePoint(t){let n=this._data[t*it+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*it+0]&2097152}getString(t){let n=this._data[t*it+0];return n&2097152?this._combined[t]:n&2097151?fs(n&2097151):""}isProtected(t){return this._data[t*it+2]&536870912}loadCell(t,n){return Sl=t*it,n.content=this._data[Sl+0],n.fg=this._data[Sl+1],n.bg=this._data[Sl+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*it+0]=n.content,this._data[t*it+1]=n.fg,this._data[t*it+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*it+0]=n|s<<22,this._data[t*it+1]=o.fg,this._data[t*it+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*it+0];o&2097152?this._combined[t]+=fs(n):o&2097151?(this._combined[t]=fs(o&2097151)+fs(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*it+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new ti;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,o));for(let a=0;a<n;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,n,s){if(t%=this.length,n<this.length-t){let o=new ti;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,o));for(let a=this.length-n;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*sd<this._data.buffer.byteLength;let s=t*it;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let h=parseInt(o[u],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*sd<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*sd<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new aw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303)return t+(this._data[t*it+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*it+0]&4194303||this._data[t*it+2]&50331648)return t+(this._data[t*it+0]>>22);return 0}copyCellsFrom(t,n,s,o,a){let u=t._data;if(a)for(let f=o-1;f>=0;f--){for(let m=0;m<it;m++)this._data[(s+f)*it+m]=u[(n+f)*it+m];u[(n+f)*it+2]&268435456&&(this._extendedAttrs[s+f]=t._extendedAttrs[n+f])}else for(let f=0;f<o;f++){for(let m=0;m<it;m++)this._data[(s+f)*it+m]=u[(n+f)*it+m];u[(n+f)*it+2]&268435456&&(this._extendedAttrs[s+f]=t._extendedAttrs[n+f])}let h=Object.keys(t._combined);for(let f=0;f<h.length;f++){let m=parseInt(h[f],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;n<s;){let u=this._data[n*it+0],h=u&2097151,f=u&2097152?this._combined[n]:h?fs(h):ms;if(a+=f,o)for(let m=0;m<f.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function uC(e,t,n,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let f=h,m=e.get(++f);if(!m.isWrapped)continue;let v=[e.get(h)];for(;f<e.length&&m.isWrapped;)v.push(m),m=e.get(++f);if(!a&&s>=h&&s<f){h+=v.length-1;continue}let S=0,y=Jo(v,S,t),b=1,w=0;for(;b<v.length;){let C=Jo(v,b,t),R=C-w,E=n-y,F=Math.min(R,E);v[S].copyCellsFrom(v[b],w,y,F,!1),y+=F,y===n&&(S++,y=0),w+=F,w===C&&(b++,w=0),y===0&&S!==0&&v[S-1].getWidth(n-1)===2&&(v[S].copyCellsFrom(v[S-1],n-1,y++,1,!1),v[S-1].setCell(n-1,o))}v[S].replaceCells(y,n,o);let k=0;for(let C=v.length-1;C>0&&(C>S||v[C].getTrimmedLength()===0);C--)k++;k>0&&(u.push(h+v.length-k),u.push(k)),h+=v.length-1}return u}function dC(e,t){let n=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let h=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:h}),u+=h-1,a+=h,o=t[++s]}else n.push(u);return{layout:n,countRemoved:a}}function hC(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function fC(e,t,n){let s=[],o=e.map((f,m)=>Jo(e,m,t)).reduce((f,m)=>f+m),a=0,u=0,h=0;for(;h<o;){if(o-h<n){s.push(o-h);break}a+=n;let f=Jo(e,u,t);a>f&&(a-=f,u++);let m=e[u].getWidth(a-1)===2;m&&a--;let v=m?n-1:n;s.push(v),h+=v}return s}function Jo(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var lw=class cw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=cw._nextId++,this._onDispose=this.register(new Ne),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Xs(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};lw._nextId=1;var pC=lw,Jt={},Ws=Jt.B;Jt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Jt.A={"#":"£"};Jt.B=void 0;Jt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Jt.C=Jt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Jt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Jt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Jt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Jt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Jt.E=Jt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Jt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Jt.H=Jt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Jt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fv=4294967295,pv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Kt.clone(),this.savedCharset=Ws,this.markers=[],this._nullCell=ti.fromCharData([0,Ey,1,0]),this._whitespaceCell=ti.fromCharData([0,ms,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Vl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hv(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 Ul),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 Ul),this._whitespaceCell}getBlankLine(e,t){return new Uo(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>fv?fv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Kt);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 hv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Kt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,n);let a=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Uo(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Uo(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=uC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Kt),n);if(s.length>0){let o=dC(this.lines,s);hC(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(Kt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Uo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Kt),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let h=this.lines.get(u);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let f=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),f.unshift(h);if(!n){let F=this.ybase+this.y;if(F>=u&&F<u+f.length)continue}let m=f[f.length-1].getTrimmedLength(),v=fC(f,this._cols,e),S=v.length-f.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+S):y=Math.max(0,this.lines.length-this.lines.maxLength+S);let b=[];for(let F=0;F<S;F++){let I=this.getBlankLine(Kt,!0);b.push(I)}b.length>0&&(o.push({start:u+f.length+a,newLines:b}),a+=b.length),f.push(...b);let w=v.length-1,k=v[w];k===0&&(w--,k=v[w]);let C=f.length-S-1,R=m;for(;C>=0;){let F=Math.min(R,k);if(f[w]===void 0)break;if(f[w].copyCellsFrom(f[C],R-F,k-F,F,!0),k-=F,k===0&&(w--,k=v[w]),R-=F,R===0){C--;let I=Math.max(C,0);R=Jo(f,I,this._cols)}}for(let F=0;F<f.length;F++)v[F]<e&&f[F].setCell(v[F],s);let E=S-y;for(;E-- >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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let k=0;k<this.lines.length;k++)h.push(this.lines.get(k));let f=this.lines.length,m=f-1,v=0,S=o[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let k=Math.min(this.lines.maxLength-1,f+a-1);k>=0;k--)if(S&&S.start>m+y){for(let C=S.newLines.length-1;C>=0;C--)this.lines.set(k--,S.newLines[C]);k++,u.push({index:m+1,amount:S.newLines.length}),y+=S.newLines.length,S=o[++v]}else this.lines.set(k,h[m--]);let b=0;for(let k=u.length-1;k>=0;k--)u[k].index+=b,this.lines.onInsertEmitter.fire(u[k]),b+=u[k].amount;let w=Math.max(0,f+a-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new pC(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},mC=class extends st{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Ne),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 pv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new pv(!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)}},uw=2,dw=1,Nh=class extends st{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ne),this.onResize=this._onResize.event,this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,uw),this.rows=Math.max(e.rawOptions.rows||0,dw),this.buffers=this._register(new mC(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;a===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=a-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Nh=Bt([Re(0,En)],Nh);var Er={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:ql,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},gC=["normal","bold","100","200","300","400","500","600","700","800","900"],vC=class extends st{constructor(e){super(),this._onOptionChange=this._register(new Ne),this.onOptionChange=this._onOptionChange.event;let t={...Er};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(jt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Er))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Er))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Er[e]),!_C(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Er[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=gC.includes(t)?t:Er[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 _C(e){return e==="block"||e==="underline"||e==="bar"}function Wo(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Wo(e[s],t-1);return n}var mv=Object.freeze({insertMode:!1}),gv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),jh=class extends st{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ne),this.onData=this._onData.event,this._onUserInput=this._register(new Ne),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ne),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ne),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Wo(mv),this.decPrivateModes=Wo(gv)}reset(){this.modes=Wo(mv),this.decPrivateModes=Wo(gv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};jh=Bt([Re(0,Cn),Re(1,Ly),Re(2,En)],jh);var vv={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 rd(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var od=String.fromCharCode,_v={DEFAULT:e=>{let t=[rd(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${od(t[0])}${od(t[1])}${od(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${rd(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${rd(e,!0)};${e.x};${e.y}${t}`}},Rh=class extends st{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ne),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(vv))this.addProtocol(s,vv[s]);for(let s of Object.keys(_v))this.addEncoding(s,_v[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Rh=Bt([Re(0,Cn),Re(1,Js),Re(2,En)],Rh);var ad=[[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]],yC=[[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]],Qt;function wC(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var bC=class{constructor(){if(this.version="6",!Qt){Qt=new Uint8Array(65536),Qt.fill(1),Qt[0]=0,Qt.fill(0,1,32),Qt.fill(0,127,160),Qt.fill(2,4352,4448),Qt[9001]=2,Qt[9002]=2,Qt.fill(2,11904,42192),Qt[12351]=1,Qt.fill(2,44032,55204),Qt.fill(2,63744,64256),Qt.fill(2,65040,65050),Qt.fill(2,65072,65136),Qt.fill(2,65280,65377),Qt.fill(2,65504,65511);for(let e=0;e<ad.length;++e)Qt.fill(0,ad[e][0],ad[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Qt[e]:wC(e,yC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Vs.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Vs.createPropertyValue(0,n,s)}},Vs=class Dl{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ne,this.onChange=this._onChange.event;let t=new bC;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return n+this.wcwidth(u);let m=t.charCodeAt(a);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let h=this.charProperties(u,s),f=Dl.extractWidth(h);Dl.extractShouldJoin(h)&&(f-=Dl.extractWidth(s)),n+=f,s=h}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},SC=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 yv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Do=2147483647,xC=256,hw=class Ph{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>xC)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Ph;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)n.addSubParam(o[a]);else n.addParam(o)}return n}clone(){let t=new Ph(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>Do?Do: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>Do?Do:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Do):t}},Mo=[],kC=class{constructor(){this._state=0,this._active=Mo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Mo}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=Mo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Mo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Mo,this._id=-1,this._state=0}}},Fn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Io=[],CC=class{constructor(){this._handlers=Object.create(null),this._active=Io,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Io}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Io,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Io,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",ec(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Io,this._ident=0}},Ko=new hw;Ko.addParam(0);var wv=class{constructor(e){this._handler=e,this._data="",this._params=Ko,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ko,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=ec(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Ko,this._data="",this._hitLimit=!1,n));return this._params=Ko,this._data="",this._hitLimit=!1,t}},EC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},ei=160,NC=(function(){let e=new EC(4095),t=Array.apply(null,Array(256)).map((h,f)=>f),n=(h,f)=>t.slice(h,f),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let a=n(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in a)e.addMany([24,26,153,154],u,3,0),e.addMany(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ei,0,2,0),e.add(ei,8,5,8),e.add(ei,6,0,6),e.add(ei,11,0,11),e.add(ei,13,13,13),e})(),jC=class extends st{constructor(e=NC){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 hw,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(jt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kC),this._dcsParser=this._register(new CC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&f>-1){for(;f>=0&&(u=h[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 4:if(n===!1&&f>-1){for(;f>=0&&(u=h[f](),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],u=this._oscParser.end(s!==24&&s!==26,n),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:ei)],o>>4){case 2:for(let y=h+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<ei){this._printHandler(e,h,y),h=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|s],m=f?f.length-1:-1;for(;m>=0&&(u=f[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,f,m,o,h),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let v=this._escHandlers[this._collect<<8|s],S=v?v.length-1:-1;for(;S>=0&&(u=v[S](),u!==!0);S--)if(u instanceof Promise)return this._preserveStack(4,v,S,o,h),u;S<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=h+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<ei){this._dcsParser.put(e,h,y),h=y-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,h),u;s===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 y=h+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<ei){this._oscParser.put(e,h,y),h=y-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},RC=/^([\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})$/,PC=/^[\da-f]+$/;function bv(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=RC.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),PC.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function ld(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function LC(e,t=16){let[n,s,o]=e;return`rgb:${ld(n,t)}/${ld(s,t)}/${ld(o,t)}`}var AC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ds=131072,Sv=10;function xv(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 kv=5e3,Cv=0,TC=class extends st{constructor(e,t,n,s,o,a,u,h,f=new jC){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Jx,this._utf8Decoder=new Zx,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Kt.clone(),this._eraseAttrDataInternal=Kt.clone(),this._onRequestBell=this._register(new Ne),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ne),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ne),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ne),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ne),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ne),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ne),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ne),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ne),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ne),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ne),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ne),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ne),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 Lh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:v.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,v,S)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:v,data:S})}),this._parser.setDcsHandlerFallback((m,v,S)=>{v==="HOOK"&&(S=S.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:v,payload:S})}),this._parser.setPrintHandler((m,v,S)=>this.print(m,v,S)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ve.BEL,()=>this.bell()),this._parser.setExecuteHandler(ve.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ve.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ve.BS,()=>this.backspace()),this._parser.setExecuteHandler(ve.HT,()=>this.tab()),this._parser.setExecuteHandler(ve.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ve.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Al.IND,()=>this.index()),this._parser.setExecuteHandler(Al.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Al.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Fn(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new Fn(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new Fn(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new Fn(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new Fn(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new Fn(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new Fn(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new Fn(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new Fn(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new Fn(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new Fn(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new Fn(m=>this.restoreCursorColor(m))),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 m in Jt)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new wv((m,v)=>this.requestStatusString(m,v)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),kv))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${kv} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ds&&(a=this._parseStack.position+ds)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ds&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ds))),u||this._dirtyRowTracker.clearRange(),e.length>ds)for(let m=a;m<e.length;m+=ds){let v=m+ds<e.length?m+ds:e.length,S=typeof e=="string"?this._stringDecoder.decode(e.substring(m,v),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,S))return this._preserveStack(s,o,S,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,v=this._curAttrData,S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let y=this._parser.precedingJoinState;for(let b=t;b<n;++b){if(s=e[b],s<127&&a){let R=a[String.fromCharCode(s)];R&&(s=R.charCodeAt(0))}let w=this._unicodeService.charProperties(s,y);o=Vs.extractWidth(w);let k=Vs.extractShouldJoin(w),C=k?Vs.extractWidth(y):0;if(y=w,u&&this._onA11yChar.fire(fs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-C>h){if(f){let R=S,E=this._activeBuffer.x-C;for(this._activeBuffer.x=C,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),S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),C>0&&S instanceof Uo&&S.copyCellsFrom(R,E,0,C,!1);E<h;)R.setCellFromCodepoint(E++,0,1,v)}else if(this._activeBuffer.x=h-1,o===2)continue}if(k&&this._activeBuffer.x){let R=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-R,s,o);for(let E=o-C;--E>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(m&&(S.insertCells(this._activeBuffer.x,o-C,this._activeBuffer.getNullCell(v)),S.getWidth(h-1)===2&&S.setCellFromCodepoint(h-1,0,1,v)),S.setCellFromCodepoint(this._activeBuffer.x++,s,o,v),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=y,this._activeBuffer.x<h&&n-t>0&&S.getWidth(this._activeBuffer.x)===0&&!S.hasContent(this._activeBuffer.x)&&S.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>xv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new wv(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Fn(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Kt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Vs.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*n),h=0;for(let m=0;m<a.length;){let v=a.codePointAt(m)||0;u[h++]=v,m+=v>65535?2:1}let f=h;for(let m=1;m<n;++m)u.copyWithin(f,0,h),f+=h;return this.print(u,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ve.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ve.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ve.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ve.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ve.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,Ws),this._charsetService.setgCharset(1,Ws),this._charsetService.setgCharset(2,Ws),this._charsetService.setgCharset(3,Ws);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){(k=>(k[k.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",k[k.SET=1]="SET",k[k.RESET=2]="RESET",k[k.PERMANENTLY_SET=3]="PERMANENTLY_SET",k[k.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:f}=this._bufferService,{active:m,alt:v}=h,S=this._optionsService.rawOptions,y=(k,C)=>(u.triggerDataEvent(`${ve.ESC}[${t?"":"?"}${k};${C}$y`),!0),b=k=>k?1:2,w=e.params[0];return t?w===2?y(w,4):w===4?y(w,b(u.modes.insertMode)):w===12?y(w,3):w===20?y(w,b(S.convertEol)):y(w,0):w===1?y(w,b(s.applicationCursorKeys)):w===3?y(w,S.windowOptions.setWinLines?f===80?2:f===132?1:0:0):w===6?y(w,b(s.origin)):w===7?y(w,b(s.wraparound)):w===8?y(w,3):w===9?y(w,b(o==="X10")):w===12?y(w,b(S.cursorBlink)):w===25?y(w,b(!u.isCursorHidden)):w===45?y(w,b(s.reverseWraparound)):w===66?y(w,b(s.applicationKeypad)):w===67?y(w,4):w===1e3?y(w,b(o==="VT200")):w===1002?y(w,b(o==="DRAG")):w===1003?y(w,b(o==="ANY")):w===1004?y(w,b(s.sendFocus)):w===1005?y(w,4):w===1006?y(w,b(a==="SGR")):w===1015?y(w,4):w===1016?y(w,b(a==="SGR_PIXELS")):w===1048?y(w,1):w===47||w===1047||w===1049?y(w,b(m===v)):w===2004?y(w,b(s.bracketedPasteMode)):w===2026?y(w,b(s.synchronizedOutput)):y(w,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=na.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=u[h];while(++h<u.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_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=Kt.fg,e.bg=Kt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=Kt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Kt.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=Kt.fg&16777215,s.bg&=-67108864,s.bg|=Kt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ve.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ve.ESC}[?${t};${n}R`);break}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=Kt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!xv(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(`${ve.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Sv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Sv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Ev(a))if(o==="?")t.push({type:0,index:a});else{let u=bv(o);u&&t.push({type:1,index:a,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=bv(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Ev(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,Ws),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(AC[e[0]],Jt[e[1]]||Ws),!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=Kt.clone(),this._eraseAttrDataInternal=Kt.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 ti;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${ve.ESC}${u}${ve.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.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)}},Lh=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&&(Cv=e,e=t,t=Cv),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Lh=Bt([Re(0,Cn)],Lh);function Ev(e){return 0<=e&&e<256}var DC=5e7,Nv=12,MC=50,IC=class extends st{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 Ne),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>DC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-n>=Nv?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(n,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Nv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>MC&&(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()}},Ah=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 h=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(f,h)),this._dataByLinkId.set(f.id,f),f.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(u,a)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Ah=Bt([Re(0,Cn)],Ah);var jv=!1,OC=class extends st{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Or),this._onBinary=this._register(new Ne),this.onBinary=this._onBinary.event,this._onData=this._register(new Ne),this.onData=this._onData.event,this._onLineFeed=this._register(new Ne),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ne),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ne),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ne),this._instantiationService=new aC,this.optionsService=this._register(new vC(e)),this._instantiationService.setService(En,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Nh)),this._instantiationService.setService(Cn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Eh)),this._instantiationService.setService(Ly,this._logService),this.coreService=this._register(this._instantiationService.createInstance(jh)),this._instantiationService.setService(Js,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Rh)),this._instantiationService.setService(Py,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Vs)),this._instantiationService.setService(ik,this.unicodeService),this._charsetService=this._instantiationService.createInstance(SC),this._instantiationService.setService(nk,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ah),this._instantiationService.setService(Ay,this._oscLinkService),this._inputHandler=this._register(new TC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mn.forward(this._bufferService.onResize,this._onResize)),this._register(mn.forward(this.coreService.onData,this._onData)),this._register(mn.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 IC((t,n)=>this._inputHandler.parse(t,n))),this._register(mn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ne),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!jv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jv=!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,uw),t=Math.max(t,dw),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(yv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(yv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=jt(()=>{for(let t of e)t.dispose()})}}},BC={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 zC(e,t,n,s){var u;let o={type:0,cancel:!1,key:void 0},a=(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=ve.ESC+"OA":o.key=ve.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ve.DEL,e.altKey&&(o.key=ve.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ve.ESC+"[Z";break}o.key=ve.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ve.ESC+ve.CR:ve.CR,o.cancel=!0;break;case 27:o.key=ve.ESC,e.altKey&&(o.key=ve.ESC+ve.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"D":t?o.key=ve.ESC+"OD":o.key=ve.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"C":t?o.key=ve.ESC+"OC":o.key=ve.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"A":t?o.key=ve.ESC+"OA":o.key=ve.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=ve.ESC+"[1;"+(a+1)+"B":t?o.key=ve.ESC+"OB":o.key=ve.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ve.ESC+"[2~");break;case 46:a?o.key=ve.ESC+"[3;"+(a+1)+"~":o.key=ve.ESC+"[3~";break;case 36:a?o.key=ve.ESC+"[1;"+(a+1)+"H":t?o.key=ve.ESC+"OH":o.key=ve.ESC+"[H";break;case 35:a?o.key=ve.ESC+"[1;"+(a+1)+"F":t?o.key=ve.ESC+"OF":o.key=ve.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ve.ESC+"[5;"+(a+1)+"~":o.key=ve.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ve.ESC+"[6;"+(a+1)+"~":o.key=ve.ESC+"[6~";break;case 112:a?o.key=ve.ESC+"[1;"+(a+1)+"P":o.key=ve.ESC+"OP";break;case 113:a?o.key=ve.ESC+"[1;"+(a+1)+"Q":o.key=ve.ESC+"OQ";break;case 114:a?o.key=ve.ESC+"[1;"+(a+1)+"R":o.key=ve.ESC+"OR";break;case 115:a?o.key=ve.ESC+"[1;"+(a+1)+"S":o.key=ve.ESC+"OS";break;case 116:a?o.key=ve.ESC+"[15;"+(a+1)+"~":o.key=ve.ESC+"[15~";break;case 117:a?o.key=ve.ESC+"[17;"+(a+1)+"~":o.key=ve.ESC+"[17~";break;case 118:a?o.key=ve.ESC+"[18;"+(a+1)+"~":o.key=ve.ESC+"[18~";break;case 119:a?o.key=ve.ESC+"[19;"+(a+1)+"~":o.key=ve.ESC+"[19~";break;case 120:a?o.key=ve.ESC+"[20;"+(a+1)+"~":o.key=ve.ESC+"[20~";break;case 121:a?o.key=ve.ESC+"[21;"+(a+1)+"~":o.key=ve.ESC+"[21~";break;case 122:a?o.key=ve.ESC+"[23;"+(a+1)+"~":o.key=ve.ESC+"[23~";break;case 123:a?o.key=ve.ESC+"[24;"+(a+1)+"~":o.key=ve.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=ve.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ve.DEL:e.keyCode===219?o.key=ve.ESC:e.keyCode===220?o.key=ve.FS:e.keyCode===221&&(o.key=ve.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=(u=BC[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=ve.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(f);e.shiftKey&&(m=m.toUpperCase()),o.key=ve.ESC+m}else if(e.keyCode===32)o.key=ve.ESC+(e.ctrlKey?ve.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=ve.ESC+f,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ve.US),e.key==="@"&&(o.key=ve.NUL));break}return o}var $t=0,FC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Vl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Vl,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,a)=>this._getKey(o)-this._getKey(a)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($t=this._search(t),$t===-1)||this._getKey(this._array[$t])!==t)return!1;do if(this._array[$t]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($t),!0;while(++$t<this._array.length&&this._getKey(this._array[$t])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do yield this._array[$t];while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($t=this._search(e),!($t<0||$t>=this._array.length)&&this._getKey(this._array[$t])===e))do t(this._array[$t]);while(++$t<this._array.length&&this._getKey(this._array[$t])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},cd=0,Rv=0,$C=class extends st{constructor(){super(),this._decorations=new FC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Ne),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ne),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(jt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new HC(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{cd=o.options.x??0,Rv=cd+(o.options.width??1),e>=cd&&e<Rv&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},HC=class extends _s{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ne),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ne),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=Dt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Dt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},UC=1e3,WC=class{constructor(e,t=UC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_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)}},Pv=20,Yl=class extends st{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let 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 a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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 WC(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(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
64
64
  `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Xe(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(jt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Pv+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
65
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Pv+1&&(this._liveRegion.textContent+=Jd.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let a=n.lines.get(n.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",f=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(h.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=h,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",f),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,h;if(t===0?(u=n,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=n,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}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(){var h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:f,offset:m})=>{let v=f instanceof Text?f.parentNode:f,S=parseInt(v==null?void 0:v.getAttribute("aria-posinset"),10)-1;if(isNaN(S))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(v);if(!y)return console.warn("columns is null. Race condition?"),null;let b=m<y.length?y[m]:y.slice(-1)[0]+1;return b>=this._terminal.cols&&(++S,b=0),{row:S,column:b}},a=o(t),u=o(n);if(!(!a||!u)){if(a.row>u.row||a.row===u.row&&a.column>=u.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(u.row-a.row)*this._terminal.cols-a.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,n=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Yl=Bt([Re(1,df),Re(2,$i),Re(3,Hi)],Yl);var Th=class extends st{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ne),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ne),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(jt(()=>{var a;Xs(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Xe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Xe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Xe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Xe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];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){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):u.provideLinks(e.y,h=>{var m,v;if(this._isMouseOut)return;let f=h==null?void 0:h.map(S=>({link:S}));(m=this._activeProviderReplies)==null||m.set(a,f),n=this._checkLinkProviderResult(a,e,n),((v=this._activeProviderReplies)==null?void 0:v.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let u=o[a],h=u.link.range.start.y<e?0:u.link.range.start.x,f=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let m=h;m<=f;m++){if(n.has(m)){o.splice(a--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(h=>this._linkAtPosition(h.link,t));u&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let u=0;u<this._activeProviderReplies.size;u++){let h=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(f=>this._linkAtPosition(f.link,t));if(h){n=!0,this._handleNewLink(h);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&KC(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,Xs(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:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};Th=Bt([Re(1,hf),Re(2,Hi),Re(3,Cn),Re(4,Dy)],Th);function KC(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 qC=class extends OC{constructor(e={}){super(e),this._linkifier=this._register(new Or),this.browser=Zy,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Or),this._onCursorMove=this._register(new Ne),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ne),this.onKey=this._onKey.event,this._onRender=this._register(new Ne),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ne),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ne),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ne),this.onBell=this._onBell.event,this._onFocus=this._register(new Ne),this._onBlur=this._register(new Ne),this._onA11yCharEmitter=this._register(new Ne),this._onA11yTabEmitter=this._register(new Ne),this._onWillOpen=this._register(new Ne),this._setup(),this._decorationService=this._instantiationService.createInstance($C),this._instantiationService.setService(ia,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(M1),this._instantiationService.setService(Dy,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(eh)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 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(mn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(mn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(mn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(mn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(jt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Ct.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ve.ESC}]${s};${LC(o)}${Qy.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=qt.toColor(...t.color));else{let a=n;this._themeService.modifyColors(u=>u[a]=qt.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(Yl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ve.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ve.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Xe(this.element,"copy",t=>{this.hasSelection()&&Xx(t,this._selectionService)}));let e=t=>Qx(t,this.textarea,this.coreService,this.optionsService);this._register(Xe(this.textarea,"paste",e)),this._register(Xe(this.element,"paste",e)),ew?this._register(Xe(this.element,"mousedown",t=>{t.button===2&&Fg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Xe(this.element,"contextmenu",t=>{Fg(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wf&&this._register(Xe(this.element,"auxclick",t=>{t.button===1&&Cy(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Xe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Xe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Xe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Xe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Xe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Xe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Xe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;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"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Xe(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Qd.get()),iw||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(T1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService($i,this._coreBrowserService),this._register(Xe(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Xe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(bh,this._document,this._helperContainer),this._instantiationService.setService(tc,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ch),this._instantiationService.setService($r,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(Ty,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(xh,this.rows,this.screenElement)),this._instantiationService.setService(Hi,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(_h,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Sh),this._instantiationService.setService(hf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Th,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(gh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(kh,this.element,this.screenElement,s)),this._instantiationService.setService(rk,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(mn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(vh,this.screenElement)),this._register(Xe(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(Yl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(wh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var m,v,S,y,b;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let h,f;switch(a.overrideType||a.type){case"mousemove":f=32,a.buttons===void 0?(h=3,a.button!==void 0&&(h=a.button<3?a.button:3)):h=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":f=0,h=a.button<3?a.button:3;break;case"mousedown":f=1,h=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let w=a.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(a,(y=(S=(v=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:v.device)==null?void 0:S.cell)==null?void 0:y.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;f=w<0?0:1,h=4;break;default:return!1}return f===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:h,action:f,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),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()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Xe(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Xe(t,"wheel",a=>{var u,h,f,m,v;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(m=(f=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:f.cell)==null?void 0:m.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return this.cancel(a,!0);let S=ve.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(S,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){ky(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=zC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===ve.ETX||n.key===ve.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(VC(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){var n;(n=this._charSizeService)==null||n.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(Kt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ve.ESC+"[I"):this.coreService.triggerDataEvent(ve.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ve.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ve.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function VC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var YC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},GC=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 ti)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Lv=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 GC(t)}getNullCell(){return new ti}},XC=class extends st{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ne),this.onBufferChange=this._onBufferChange.event,this._normal=new Lv(this._core.buffers.normal,"normal"),this._alternate=new Lv(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)}},QC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},JC=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}},ZC=["cols","rows"],vi=0,eE=class extends st{constructor(e){super(),this._core=this._register(new qC(e)),this._addonManager=this._register(new YC),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(ZC.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 QC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new JC(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 XC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
66
66
  `,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 Qd.get()},set promptLabel(e){Qd.set(e)},get tooMuchOutput(){return Jd.get()},set tooMuchOutput(e){Jd.set(e)}}}_verifyIntegers(...e){for(vi of e)if(vi===1/0||isNaN(vi)||vi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(vi of e)if(vi&&(vi===1/0||isNaN(vi)||vi%1!==0||vi<0))throw new Error("This API only accepts positive integers")}};/**
@@ -74,20 +74,20 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
74
74
  * Fabrice Bellard's javascript vt100 for jslinux:
75
75
  * http://bellard.org/jslinux/
76
76
  * Copyright (c) 2011 Fabrice Bellard
77
- */var tE=2,nE=1,iE=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(){var S;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:((S=this._terminal.options.overviewRuler)==null?void 0:S.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=u.top+u.bottom,f=u.right+u.left,m=s-h,v=o-f-t;return{cols:Math.max(tE,Math.floor(v/e.css.cell.width)),rows:Math.max(nE,Math.floor(m/e.css.cell.height))}}};function sE(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function rE({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:f,onExit:m,onFiles:v,retryBaseMs:S=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const w=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${sE(t,n)}`;let k=null,C=!1,R=!1,E=null,F=0,I=h;const K=()=>{if(C||R||E)return;const z=Math.min(5e3,Math.max(0,S)*2**Math.min(F++,5));E=setTimeout(()=>{E=null,Y()},z)},Y=()=>{if(C||R)return;const z=new WebSocket(w);k=z,z.binaryType="arraybuffer",z.onopen=()=>{if(k!==z||C)return;F=0;const Z={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(Z.takeSize=u),z.send(JSON.stringify(Z)),I!==void 0&&z.send(JSON.stringify({type:"focus",on:!!I}))},z.onmessage=Z=>{if(!(k!==z||C))if(typeof Z.data=="string"){let G;try{G=JSON.parse(Z.data)}catch{return}G.type==="exit"&&(R=!0,m&&m(G.code)),G.type==="files"&&v&&v(G)}else f&&f(new Uint8Array(Z.data))},z.onerror=()=>{if(k===z)try{z.close()}catch{}},z.onclose=Z=>{k!==z||C||R||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||K()}};return Y(),{sendInput:z=>{if(!k||k.readyState!==1)return!1;try{return k.send(typeof z=="string"?new TextEncoder().encode(z):z),!0}catch{try{k.close()}catch{}return!1}},isReady:()=>!!k&&k.readyState===1,resize:(z,Z)=>{s=z,o=Z,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"resize",cols:z,rows:Z}))},action:z=>{(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"action",name:z}))},focus:z=>{I=z,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"focus",on:!!z}))},close:()=>{if(C=!0,E&&clearTimeout(E),E=null,k)try{k.close()}catch{}},get raw(){return k}}}async function Av(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const oE="\r";function aE(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function lE({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(oE)!==!1}catch{return!1}}}function cE(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function uE(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const dE=450,Tv=8;function hE(e,t,n,s){return Math.abs(Number(n)-Number(e))>Tv||Math.abs(Number(s)-Number(t))>Tv}const fE=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function ud(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function Dv(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function pE(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=fE.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function fw({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=Ht,onProgress:u=()=>{},now:h=Date.now()}={}){const f=Array.from(e||[]).filter(Boolean),m=[],v=[];if(!n||!f.length)return{paths:m,errors:v};const S=cn(s?String(s).split("/"):[]);for(let y=0;y<f.length;y+=1){const b=f[y],w=pE(b,y,h);u({index:y,total:f.length,name:w,state:"uploading"});try{const k=new FormData;k.append("session",n),k.append("paste",o?"true":"false"),k.append("file",b,w);const C=await a(`${S}/files/upload`,t,{method:"POST",body:k}),R=await C.json().catch(()=>({}));if(!C.ok||R.error)throw new Error(R.error||`HTTP ${C.status}`);m.push(R.path),u({index:y,total:f.length,name:w,state:"done",path:R.path})}catch(k){const C=String((k==null?void 0:k.message)||k);v.push({name:w,message:C}),u({index:y,total:f.length,name:w,state:"error",error:C})}}return{paths:m,errors:v}}const mE=420,gE=32;function vE(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function Dh({documentRef:e,navigatorRef:t}={}){const n=e||(typeof document<"u"?document:null),s=t||(typeof navigator<"u"?navigator:null);let o=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),o=!0)}catch{}const a=n&&n.activeElement;let u=!1;if(vE(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function pw(e,t,n=!1){const s=e&&e.textarea;if(!s)return null;const a=t==="single-tap"||t==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function _E(e,t){if(!e||!e.textarea)return!1;pw(e,"double-tap",!0);try{e.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function yE(e,t,n){return e==="never"?{open:!1,next:null}:e==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:t&&n.at>=t.at&&n.at-t.at<=mE&&Math.hypot(n.x-t.x,n.y-t.y)<=gE?{open:!0,next:null}:{open:!1,next:n}}const wE=24,Mv=80,mw=8,bE="\x1B[5~",SE="\x1B[6~",xE=64,kE=65;function CE(e,t,n){const s=e==="up"?xE:kE,o=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${o(t)};${o(n)}M`}function EE({alternateScreen:e=!1,readonly:t=!1,mouseTracking:n=!1}={}){return t?"scroll":n?"mouse":e?"page":"scroll"}function NE(e,t){return e==="page"?Number.isFinite(t)&&t>0?Math.max(Mv,t):Mv:Number.isFinite(t)&&t>0?t:wE}function jE({mode:e="scroll",accumulated:t=0,threshold:n=0}={}){const s=NE(e,n);if(!Number.isFinite(t))return{mode:e,up:0,down:0,remainder:0};const o=Math.abs(t);if(o<s)return{mode:e,up:0,down:0,remainder:t};const a=Math.floor(o/s),u=Math.min(a,mw),h=(t>=0?1:-1)*(o%s);return{mode:e,up:t>0?u:0,down:t<0?u:0,remainder:h}}function RE(e,t=null){const n=[],s=t&&Number.isFinite(t.col)?t.col:1,o=t&&Number.isFinite(t.row)?t.row:1,a=h=>Math.min(mw,Number.isFinite(h)?Math.max(0,Math.floor(h)):0),u=h=>e.mode==="mouse"?{kind:"input",seq:CE(h,s,o)}:e.mode==="page"?{kind:"input",seq:h==="up"?bE:SE}:{kind:"action",name:h==="up"?"scroll-up":"scroll-down"};for(let h=0;h<a(e.up);h+=1)n.push(u("up"));for(let h=0;h<a(e.down);h+=1)n.push(u("down"));return n}function gw({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:f,ctrlRef:m,setCtrlArmed:v,onFiles:S,fontSize:y=13,selectionMode:b=!1,onSelectionModeChange:w,keyboardGesture:k="double-tap"}){const C=N.useRef(null),R=N.useRef(null),E=N.useRef(y);E.current=y;const F=N.useRef(a);F.current=a;const I=N.useRef(b);I.current=b;const K=N.useRef(k);K.current=k;const[Y,z]=N.useState(""),[Z,G]=N.useState(""),[Q,B]=N.useState(null),[M,j]=N.useState(null),[T,L]=N.useState(!1),$=async()=>{var D,A,W,X;const x=((A=(D=R.current)==null?void 0:D.term)==null?void 0:A.getSelection())||Y;if(!x){G(p("copy-empty")),setTimeout(()=>G(""),1500);return}const O=await Av(x);G(p(O?"copied":"copy-manual")),O&&((X=(W=R.current)==null?void 0:W.term)==null||X.clearSelection(),z(""),L(!1),w==null||w(!1)),setTimeout(()=>G(""),1800)},H=N.useRef($);return H.current=$,N.useEffect(()=>{const x=R.current;x&&x.sock&&x.sock.focus&&x.sock.focus(!!a)},[a]),N.useEffect(()=>{const x=R.current;x&&(x.term.options.fontSize=y,x.fit.fit(),x.sock.resize(x.term.cols,x.term.rows))},[y]),N.useEffect(()=>{var x,O;(O=(x=R.current)==null?void 0:x.setKeyboardGesture)==null||O.call(x,k)},[k]),N.useEffect(()=>{var Es,Vr,Ns,Yr,tr,ca,Et;const x=new eE({cursorBlink:!0,fontSize:E.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),O=new iE;x.loadAddon(O),x.open(C.current),O.fit();let D=!1,A=!1;const W=pe=>He=>{for(const Ye of He){const Ve=Array.isArray(Ye)?Ye[0]:Ye;Ve===1006&&(D=pe),Ve===1016&&(A=pe)}return!1};(Vr=(Es=x.parser)==null?void 0:Es.registerCsiHandler)==null||Vr.call(Es,{prefix:"?",final:"h"},W(!0)),(Yr=(Ns=x.parser)==null?void 0:Ns.registerCsiHandler)==null||Yr.call(Ns,{prefix:"?",final:"l"},W(!1)),(ca=(tr=x.parser)==null?void 0:tr.registerEscHandler)==null||ca.call(tr,{final:"c"},()=>(D=!1,A=!1,!1));const X=()=>D&&!A&&(x.modes&&x.modes.mouseTrackingMode||"none")!=="none",ie=new TextDecoder;let ue=K.current==="single-tap",fe=null;const we=()=>{ue=K.current==="single-tap",pw(x,K.current,ue)},me=pe=>{K.current=pe,fe=null,we()},xe=()=>K.current==="never"?!1:(ue=!0,_E(x));we();const $e=x.textarea,ft=()=>{K.current==="double-tap"&&we()};$e==null||$e.addEventListener("blur",ft);let qe;try{qe=rE({session:e,node:t,token:n,readonly:s,takeSize:o,focused:F.current,onFiles:S,cols:x.cols,rows:x.rows,onData:pe=>x.write(ie.decode(pe)),onExit:()=>x.write(`\r
77
+ */var tE=2,nE=1,iE=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(){var S;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:((S=this._terminal.options.overviewRuler)==null?void 0:S.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=u.top+u.bottom,f=u.right+u.left,m=s-h,v=o-f-t;return{cols:Math.max(tE,Math.floor(v/e.css.cell.width)),rows:Math.max(nE,Math.floor(m/e.css.cell.height))}}};function sE(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function rE({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:f,onExit:m,onFiles:v,retryBaseMs:S=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const w=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${sE(t,n)}`;let k=null,C=!1,R=!1,E=null,F=0,I=h;const K=()=>{if(C||R||E)return;const z=Math.min(5e3,Math.max(0,S)*2**Math.min(F++,5));E=setTimeout(()=>{E=null,Y()},z)},Y=()=>{if(C||R)return;const z=new WebSocket(w);k=z,z.binaryType="arraybuffer",z.onopen=()=>{if(k!==z||C)return;F=0;const Z={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(Z.takeSize=u),z.send(JSON.stringify(Z)),I!==void 0&&z.send(JSON.stringify({type:"focus",on:!!I}))},z.onmessage=Z=>{if(!(k!==z||C))if(typeof Z.data=="string"){let G;try{G=JSON.parse(Z.data)}catch{return}G.type==="exit"&&(R=!0,m&&m(G.code)),G.type==="files"&&v&&v(G)}else f&&f(new Uint8Array(Z.data))},z.onerror=()=>{if(k===z)try{z.close()}catch{}},z.onclose=Z=>{k!==z||C||R||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||K()}};return Y(),{sendInput:z=>{if(!k||k.readyState!==1)return!1;try{return k.send(typeof z=="string"?new TextEncoder().encode(z):z),!0}catch{try{k.close()}catch{}return!1}},isReady:()=>!!k&&k.readyState===1,resize:(z,Z)=>{s=z,o=Z,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"resize",cols:z,rows:Z}))},action:z=>{(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"action",name:z}))},focus:z=>{I=z,(k==null?void 0:k.readyState)===1&&k.send(JSON.stringify({type:"focus",on:!!z}))},close:()=>{if(C=!0,E&&clearTimeout(E),E=null,k)try{k.close()}catch{}},get raw(){return k}}}async function Av(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const oE="\r";function aE(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function lE({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(oE)!==!1}catch{return!1}}}function cE(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function uE(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const dE=450,Tv=8;function hE(e,t,n,s){return Math.abs(Number(n)-Number(e))>Tv||Math.abs(Number(s)-Number(t))>Tv}const fE=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function ud(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function Dv(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function pE(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=fE.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function fw({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=Ht,onProgress:u=()=>{},now:h=Date.now()}={}){const f=Array.from(e||[]).filter(Boolean),m=[],v=[];if(!n||!f.length)return{paths:m,errors:v};const S=cn(s?String(s).split("/"):[]);for(let y=0;y<f.length;y+=1){const b=f[y],w=pE(b,y,h);u({index:y,total:f.length,name:w,state:"uploading"});try{const k=new FormData;k.append("session",n),k.append("paste",o?"true":"false"),k.append("file",b,w);const C=await a(`${S}/files/upload`,t,{method:"POST",body:k}),R=await C.json().catch(()=>({}));if(!C.ok||R.error)throw new Error(R.error||`HTTP ${C.status}`);m.push(R.path),u({index:y,total:f.length,name:w,state:"done",path:R.path})}catch(k){const C=String((k==null?void 0:k.message)||k);v.push({name:w,message:C}),u({index:y,total:f.length,name:w,state:"error",error:C})}}return{paths:m,errors:v}}const mE=420,gE=32;function vE(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function Dh({documentRef:e,navigatorRef:t}={}){const n=e||(typeof document<"u"?document:null),s=t||(typeof navigator<"u"?navigator:null);let o=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),o=!0)}catch{}const a=n&&n.activeElement;let u=!1;if(vE(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function pw(e,t,n=!1){const s=e&&e.textarea;if(!s)return null;const a=t==="single-tap"||t==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function _E(e,t){if(!e||!e.textarea)return!1;pw(e,"double-tap",!0);try{e.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function yE(e,t,n){return e==="never"?{open:!1,next:null}:e==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:t&&n.at>=t.at&&n.at-t.at<=mE&&Math.hypot(n.x-t.x,n.y-t.y)<=gE?{open:!0,next:null}:{open:!1,next:n}}const wE=24,Mv=80,mw=8,bE="\x1B[5~",SE="\x1B[6~",xE=64,kE=65;function CE(e,t,n){const s=e==="up"?xE:kE,o=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${o(t)};${o(n)}M`}function EE({alternateScreen:e=!1,readonly:t=!1,mouseTracking:n=!1}={}){return t?"scroll":n?"mouse":e?"page":"scroll"}function NE(e,t){return e==="page"?Number.isFinite(t)&&t>0?Math.max(Mv,t):Mv:Number.isFinite(t)&&t>0?t:wE}function jE({mode:e="scroll",accumulated:t=0,threshold:n=0}={}){const s=NE(e,n);if(!Number.isFinite(t))return{mode:e,up:0,down:0,remainder:0};const o=Math.abs(t);if(o<s)return{mode:e,up:0,down:0,remainder:t};const a=Math.floor(o/s),u=Math.min(a,mw),h=(t>=0?1:-1)*(o%s);return{mode:e,up:t>0?u:0,down:t<0?u:0,remainder:h}}function RE(e,t=null){const n=[],s=t&&Number.isFinite(t.col)?t.col:1,o=t&&Number.isFinite(t.row)?t.row:1,a=h=>Math.min(mw,Number.isFinite(h)?Math.max(0,Math.floor(h)):0),u=h=>e.mode==="mouse"?{kind:"input",seq:CE(h,s,o)}:e.mode==="page"?{kind:"input",seq:h==="up"?bE:SE}:{kind:"action",name:h==="up"?"scroll-up":"scroll-down"};for(let h=0;h<a(e.up);h+=1)n.push(u("up"));for(let h=0;h<a(e.down);h+=1)n.push(u("down"));return n}function gw({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:f,ctrlRef:m,setCtrlArmed:v,onFiles:S,fontSize:y=13,selectionMode:b=!1,onSelectionModeChange:w,keyboardGesture:k="double-tap"}){const C=N.useRef(null),R=N.useRef(null),E=N.useRef(y);E.current=y;const F=N.useRef(a);F.current=a;const I=N.useRef(b);I.current=b;const K=N.useRef(k);K.current=k;const[Y,z]=N.useState(""),[Z,G]=N.useState(""),[Q,B]=N.useState(null),[M,j]=N.useState(null),[T,L]=N.useState(!1),$=async()=>{var D,A,W,X;const x=((A=(D=R.current)==null?void 0:D.term)==null?void 0:A.getSelection())||Y;if(!x){G(p("copy-empty")),setTimeout(()=>G(""),1500);return}const O=await Av(x);G(p(O?"copied":"copy-manual")),O&&((X=(W=R.current)==null?void 0:W.term)==null||X.clearSelection(),z(""),L(!1),w==null||w(!1)),setTimeout(()=>G(""),1800)},H=N.useRef($);return H.current=$,N.useEffect(()=>{const x=R.current;x&&x.sock&&x.sock.focus&&x.sock.focus(!!a)},[a]),N.useEffect(()=>{const x=R.current;x&&(x.term.options.fontSize=y,x.fit.fit(),x.sock.resize(x.term.cols,x.term.rows))},[y]),N.useEffect(()=>{var x,O;(O=(x=R.current)==null?void 0:x.setKeyboardGesture)==null||O.call(x,k)},[k]),N.useEffect(()=>{var Es,Vr,Ns,Yr,tr,ca,Et;const x=new eE({cursorBlink:!0,fontSize:E.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),O=new iE;x.loadAddon(O),x.open(C.current),O.fit();let D=!1,A=!1;const W=pe=>He=>{for(const Ye of He){const Ve=Array.isArray(Ye)?Ye[0]:Ye;Ve===1006&&(D=pe),Ve===1016&&(A=pe)}return!1};(Vr=(Es=x.parser)==null?void 0:Es.registerCsiHandler)==null||Vr.call(Es,{prefix:"?",final:"h"},W(!0)),(Yr=(Ns=x.parser)==null?void 0:Ns.registerCsiHandler)==null||Yr.call(Ns,{prefix:"?",final:"l"},W(!1)),(ca=(tr=x.parser)==null?void 0:tr.registerEscHandler)==null||ca.call(tr,{final:"c"},()=>(D=!1,A=!1,!1));const X=()=>D&&!A&&(x.modes&&x.modes.mouseTrackingMode||"none")!=="none",ie=new TextDecoder;let ce=K.current==="single-tap",fe=null;const we=()=>{ce=K.current==="single-tap",pw(x,K.current,ce)},me=pe=>{K.current=pe,fe=null,we()},xe=()=>K.current==="never"?!1:(ce=!0,_E(x));we();const $e=x.textarea,ft=()=>{K.current==="double-tap"&&we()};$e==null||$e.addEventListener("blur",ft);let qe;try{qe=rE({session:e,node:t,token:n,readonly:s,takeSize:o,focused:F.current,onFiles:S,cols:x.cols,rows:x.rows,onData:pe=>x.write(ie.decode(pe)),onExit:()=>x.write(`\r
78
78
  \x1B[33m[sessione finita]\x1B[0m\r
79
79
  `)})}catch(pe){return x.write(`\r
80
80
  \x1B[31m${pe.message}\x1B[0m\r
81
- `),()=>x.dispose()}R.current={term:x,fit:O,sock:qe,setKeyboardGesture:me};let Ae=null;const Rt=x.onData(pe=>{if(s){Ae&&(Ae.ok=!1);return}if(!Ae&&m&&m.current&&pe.length===1){const Ye=pe.charCodeAt(0);let Ve=Ye;Ye>=97&&Ye<=122?Ve=Ye-96:Ye>=64&&Ye<=95?Ve=Ye-64:Ye===32&&(Ve=0),pe=String.fromCharCode(Ve),m.current=!1,v&&v(!1)}const He=qe.sendInput(pe);Ae&&(Ae.seen=!0,Ae.ok=Ae.ok&&He)});u&&(u.current=pe=>qe.sendInput(pe)),f&&(f.current=pe=>qe.action(pe)),h&&(h.current=lE({isReady:()=>!s&&qe.isReady(),paste:pe=>{const He={seen:!1,ok:!0};Ae=He;try{x.paste(pe)}catch{He.ok=!1}finally{Ae=null}return He.seen&&He.ok},send:pe=>qe.sendInput(pe)}));const Jt=x.onSelectionChange(()=>{const pe=x.getSelection();pe?(z(pe),L(!1)):L(!0)});x.attachCustomKeyEventHandler(pe=>(pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="c"&&x.getSelection()?(pe.type==="keydown"&&Av(x.getSelection()),!1):!0);const Oe=C.current;let Pt=!1;const bt=async pe=>{if(!pe.length||Pt)return;if(s){B({error:p("settings-readonly")});return}Pt=!0,B({current:0,total:pe.length,name:""});const He=await fw({files:pe,token:n,session:e,node:t,paste:!0,onProgress:({index:Ye,total:Ve,name:_t,state:St,error:Ut})=>B({current:Ye+1,total:Ve,name:_t,...St==="error"?{error:Ut}:{}})});Pt=!1,He.errors.length?B({error:He.errors.map(Ye=>`${Ye.name}: ${Ye.message}`).join(" · ")}):(B({done:!0,total:He.paths.length}),setTimeout(()=>B(null),1600))},dt=pe=>{const He=pe.clipboardData;if(!ud(He))return;const Ye=Dv(He);Ye.length&&(pe.preventDefault(),pe.stopPropagation(),bt(Ye))},ht=pe=>{ud(pe.dataTransfer)&&(pe.preventDefault(),pe.stopPropagation())},Qe=pe=>{ud(pe.dataTransfer)&&(pe.preventDefault(),pe.stopPropagation(),bt(Dv(pe.dataTransfer)))};Oe.addEventListener("paste",dt,!0),Oe.addEventListener("dragenter",ht,!0),Oe.addEventListener("dragover",ht,!0),Oe.addEventListener("drop",Qe,!0);const ot=24,oe=(pe,He)=>{const Ve=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),_t=Math.floor((pe-Ve.left)/Math.max(1,Ve.width)*x.cols)+1,St=Math.floor((He-Ve.top)/Math.max(1,Ve.height)*x.rows)+1;return{col:Math.max(1,Math.min(x.cols,_t)),row:Math.max(1,Math.min(x.rows,St))}},ke=(pe,He={mode:null,remainder:0},Ye=null,Ve=null)=>{const _t=C.current,St=_t?_t.getBoundingClientRect().height:ot,Ut=EE({alternateScreen:x.buffer.active.type==="alternate",readonly:s,mouseTracking:X()}),en=Ut==="mouse"?"mouse":Ye||Ut,dc=He.mode===en?He.remainder+pe:pe,Nn=jE({mode:en,accumulated:dc,threshold:en==="page"?St:ot});for(const Gr of RE(Nn,Ve))Gr.kind==="input"?qe.sendInput(Gr.seq):qe.action(Gr.name);return{mode:en,remainder:Nn.remainder}};let Te=null,ae=null,re=null,Pe=null,q=!1,te=!1,U={mode:null,remainder:0},ce=null,de=null,ge=null,De=!1,_e=0;const Ee=()=>{ge&&clearTimeout(ge),ge=null},nt=(pe,He)=>{const Ve=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),_t=Math.max(0,Math.min(x.cols-1,Math.floor((pe-Ve.left)/Math.max(1,Ve.width)*x.cols))),St=Math.max(0,Math.min(x.rows-1,Math.floor((He-Ve.top)/Math.max(1,Ve.height)*x.rows)));return{col:_t,row:x.buffer.active.viewportY+St}},at=2,Je=pe=>{const Ye=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect();return Math.max(0,Math.min(x.rows-1,Math.floor((pe-Ye.top)/Math.max(1,Ye.height)*x.rows)))<at?at:-at},Mt=(pe,He)=>{const _t=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect().height/Math.max(1,x.rows);return nt(pe.clientX,pe.clientY+He*_t)},ct=pe=>{const Ye=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),Ve=Oe.getBoundingClientRect(),_t=Ye.width/Math.max(1,x.cols),St=Ye.height/Math.max(1,x.rows),Ut=Number(x.buffer.active.viewportY)||0,en=Math.max(0,Math.min(x.rows-1,pe.row-Ut));j({left:`${Ye.left-Ve.left+pe.col*_t}px`,top:`${Ye.top-Ve.top+en*St}px`,width:`${_t}px`,height:`${St}px`})},et=pe=>{if(Ee(),De=!1,q=!1,te||pe.touches.length!==1){te=!0,q=!0,fe=null,j(null),_e=0,Te=null,ae=null,re=null,Pe=null;return}if(I.current){pe.preventDefault(),pe.stopPropagation(),_e=Je(pe.touches[0].clientY),de=Mt(pe.touches[0],_e),x.clearSelection(),ct(de);return}Te=pe.touches[0].clientY,ae=pe.touches[0].clientX,re=ae,Pe=Te,U={mode:null,remainder:0},ce=null;const He={x:ae,y:Te};ge=setTimeout(()=>{var Ut;ge=null,De=!0,q=!0,fe=null,I.current=!0,w==null||w(!0),de=nt(He.x,He.y),_e=Je(He.y);const Ye=Mt({clientX:He.x,clientY:He.y},_e);x.clearSelection();const Ve=de.row*x.cols+de.col,_t=Ye.row*x.cols+Ye.col,St=Ve<=_t?de:Ye;x.select(St.col,St.row,Math.abs(_t-Ve)+1),ct(Ye);try{(Ut=navigator.vibrate)==null||Ut.call(navigator,10)}catch{}Te=null,ae=null,ce=null,U={mode:null,remainder:0}},dE)},Zt=pe=>{if(De&&de&&pe.touches.length===1){pe.preventDefault(),pe.stopPropagation();const Ve=Mt(pe.touches[0],_e),_t=de.row*x.cols+de.col,St=Ve.row*x.cols+Ve.col,Ut=_t<=St?de:Ve;x.select(Ut.col,Ut.row,Math.abs(St-_t)+1),ct(Ve);return}if(I.current&&de&&pe.touches.length===1){pe.preventDefault(),pe.stopPropagation();const Ve=Mt(pe.touches[0],_e),_t=de.row*x.cols+de.col,St=Ve.row*x.cols+Ve.col,Ut=_t<=St?de:Ve;x.select(Ut.col,Ut.row,Math.abs(St-_t)+1),ct(Ve);return}if(Te===null||pe.touches.length!==1)return;pe.preventDefault(),pe.stopPropagation();const He=pe.touches[0];if(hE(re,Pe,He.clientX,He.clientY)&&(q=!0,fe=null,ge&&Ee()),ce===null&&(Math.abs(He.clientY-Te)>8||Math.abs(He.clientX-ae)>8)&&(ce=Math.abs(He.clientY-Te)>Math.abs(He.clientX-ae)),!ce)return;const Ye=He.clientY-Te;Te=He.clientY,U=ke(Ye,U,"scroll",oe(He.clientX,He.clientY))},ni=()=>{Ee(),Te=null,ae=null,re=null,Pe=null,de=null,De=!1,q=!1,te=!1,_e=0,j(null),U={mode:null,remainder:0}},Wn=pe=>{if(te){fe=null,Ee(),(!pe.touches||pe.touches.length===0)&&ni();return}const He=pe.changedTouches&&pe.changedTouches[0];if(!q&&!De&&!I.current&&He){const Ye={at:Date.now(),x:He.clientX,y:He.clientY},Ve=yE(K.current,fe,Ye);fe=Ve.next,Ve.open&&xe()}ni()},ui=()=>{fe=null,ni()};let he={mode:null,remainder:0};const je=pe=>{pe.preventDefault(),pe.stopPropagation(),he=ke(-pe.deltaY,he,"scroll",oe(pe.clientX,pe.clientY))};Oe.addEventListener("touchstart",et,{passive:!1}),Oe.addEventListener("touchmove",Zt,{passive:!1,capture:!0}),Oe.addEventListener("touchend",Wn,{passive:!0}),Oe.addEventListener("touchcancel",ui,{passive:!0});const Ke=()=>{!I.current&&K.current==="double-tap"&&xe()};Oe.addEventListener("dblclick",Ke);const pt=pe=>{(I.current||De)&&(pe.preventDefault(),pe.stopPropagation())};Oe.addEventListener("contextmenu",pt,!0),Oe.addEventListener("wheel",je,{passive:!1,capture:!0});let vt=null;const bs=pe=>{cE(pe)&&(pe.preventDefault(),pe.stopPropagation(),vt=nt(pe.clientX,pe.clientY),x.clearSelection())},Ui=pe=>{var St;if(!vt){(St=x.hasSelection)!=null&&St.call(x)&&X()&&(pe.preventDefault(),pe.stopPropagation());return}pe.preventDefault(),pe.stopPropagation();const He=nt(pe.clientX,pe.clientY),Ye=vt.row*x.cols+vt.col,Ve=He.row*x.cols+He.col,_t=Ye<=Ve?vt:He;x.select(_t.col,_t.row,Math.abs(Ve-Ye)+1)},Ss=pe=>{vt&&(pe.stopPropagation(),vt=null)};Oe.addEventListener("mousedown",bs,!0),Oe.addEventListener("mousemove",Ui,!0),Oe.addEventListener("mouseup",Ss,!0);const xs=pe=>{!uE(pe)||!(R.current&&R.current.term&&R.current.term.getSelection())||(pe.preventDefault(),pe.stopPropagation(),H.current&&H.current())};Oe.addEventListener("keydown",xs,!0);const di=()=>{O.fit(),qe.resize(x.cols,x.rows)};window.addEventListener("resize",di);const Kn=window.visualViewport;let Kr=Kn&&Number(Kn.height);const la=()=>{const pe=Kn&&Number(Kn.height);ue&&K.current==="double-tap"&&Number.isFinite(Kr)&&Number.isFinite(pe)&&pe>Kr+80&&we(),Kr=pe,di()};Kn&&(Kn.addEventListener("resize",la),Kn.addEventListener("scroll",di));const zt=typeof navigator<"u"?navigator.virtualKeyboard:null,qr=()=>{var pe;ue&&K.current==="double-tap"&&Number(((pe=zt==null?void 0:zt.boundingRect)==null?void 0:pe.height)||0)===0&&we()};(Et=zt==null?void 0:zt.addEventListener)==null||Et.call(zt,"geometrychange",qr);let ks=null,Cs=0;return typeof ResizeObserver<"u"&&(ks=new ResizeObserver(()=>{Cs&&cancelAnimationFrame(Cs),Cs=requestAnimationFrame(di)}),ks.observe(Oe)),()=>{var pe;R.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),f&&(f.current=()=>!1),Rt.dispose(),Jt.dispose(),Oe.removeEventListener("touchstart",et),Oe.removeEventListener("touchmove",Zt,{capture:!0}),Oe.removeEventListener("touchend",Wn),Oe.removeEventListener("touchcancel",ui),Oe.removeEventListener("dblclick",Ke),Oe.removeEventListener("contextmenu",pt,!0),Ee(),Oe.removeEventListener("wheel",je,{capture:!0}),Oe.removeEventListener("mousedown",bs,!0),Oe.removeEventListener("mousemove",Ui,!0),Oe.removeEventListener("mouseup",Ss,!0),Oe.removeEventListener("keydown",xs,!0),Oe.removeEventListener("paste",dt,!0),Oe.removeEventListener("dragenter",ht,!0),Oe.removeEventListener("dragover",ht,!0),Oe.removeEventListener("drop",Qe,!0),window.removeEventListener("resize",di),Kn&&(Kn.removeEventListener("resize",la),Kn.removeEventListener("scroll",di)),(pe=zt==null?void 0:zt.removeEventListener)==null||pe.call(zt,"geometrychange",qr),$e==null||$e.removeEventListener("blur",ft),ks&&ks.disconnect(),Cs&&cancelAnimationFrame(Cs),qe.close(),x.dispose()}},[e,t,n,s,o,u,h,f,m,v,S]),c.jsxs("div",{className:`nc-terminal${b?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:C}),M&&c.jsx("div",{className:"nc-touch-selection-caret",style:M,"aria-hidden":"true"}),Q&&c.jsx("div",{className:`nc-upload-state${Q.error?" error":""}`,role:"status",children:Q.error?Q.error:Q.done?p("attach-uploaded").replace("{n}",String(Q.total||0)):p("attach-upload-progress").replace("{n}",String(Q.current||0)).replace("{total}",String(Q.total||0))}),(Y||b)&&c.jsxs("div",{className:"nc-selection-tools",children:[Y?c.jsx("button",{type:"button",onClick:$,children:Z||p("copy")}):c.jsx("span",{children:p("select-drag")}),Y&&T&&c.jsx("span",{className:"nc-selection-held",children:p("selection-held")}),c.jsx("button",{type:"button",onClick:()=>{var x,O;(O=(x=R.current)==null?void 0:x.term)==null||O.clearSelection(),z(""),L(!1),w==null||w(!1)},children:p("cancel")}),Z===p("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:Y,onFocus:x=>x.target.select()})]})]})}const Iv="",wt="\x1B",PE=[{label:"↑",seq:wt+"[A"},{label:"↓",seq:wt+"[B"},{label:"PGUP",seq:wt+"[5~"},{label:"PGDN",seq:wt+"[6~"}],LE=new Set([wt+"[A",wt+"[B",wt+"[C",wt+"[D",wt+"[5~",wt+"[6~"]),AE=350,TE=55;function DE({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,onCellSwitcher:h,cellSwitcherOpen:f=!1,keepKeyboardClosed:m=!0,showEnter:v=!0,keybarLayout:S="full"}){const[y,b]=N.useState(!1),[w,k]=N.useState(!1),[C,R]=N.useState(!1),[E,F]=N.useState(!1),I=S==="compact"&&!E,K=N.useRef({delay:null,interval:null}),Y=N.useRef(()=>{}),z=()=>{const O=K.current;O.delay!==null&&clearTimeout(O.delay),O.interval!==null&&clearInterval(O.interval),O.delay=null,O.interval=null};Y.current=z,N.useEffect(()=>{const O=()=>{document.visibilityState==="hidden"&&Y.current()},D=()=>Y.current();return window.addEventListener("blur",D),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",O),Y.current()}},[]),N.useEffect(()=>{S!=="compact"&&F(!1)},[S]);const Z=O=>{C?(e(wt+O),R(!1)):e(O)},G=O=>{m&&Dh(),O()},Q=O=>({onPointerDown:D=>{D.preventDefault(),G(O)},onClick:D=>{D.detail===0&&G(O)}}),B=O=>({onPointerDown:D=>{D.preventDefault(),z(),G(O),!C&&(K.current.delay=setTimeout(()=>{K.current.delay=null,O(),K.current.interval=setInterval(O,TE)},AE))},onPointerUp:z,onPointerLeave:z,onPointerCancel:z,onLostPointerCapture:z,onTouchCancel:z,onClick:D=>{D.detail===0&&G(O)}}),M=(O,D,A)=>c.jsx("button",{type:"button",...LE.has(D)&&!A?B(()=>Z(D)):Q(()=>{Z(D),A&&A()}),children:O},O),j=(O,D)=>c.jsx("button",{type:"button",...Q(()=>{t(D),k(!1)}),children:O},O),T=h?c.jsx("button",{type:"button","aria-label":p("fleet-cells"),title:p("fleet-cells"),"aria-expanded":f,...Q(h),children:"◫"},"cells"):c.jsx("button",{type:"button",...Q(()=>{o&&o()}),children:"⌨"},"kbd"),L=v&&c.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...Q(()=>Z("\r")),children:c.jsx(Ze,{name:"enter",size:24})}),$=w&&c.jsxs("div",{className:"nc-keymenu",children:[j("←WIN","prev-window"),j("WIN→","next-window"),j("⬅PANE","pane-left"),j("PANE➡","pane-right"),M("SCROLL",Iv+"[",()=>{b(!0),k(!1)}),c.jsx("button",{type:"button",className:a?"armed":"",...Q(()=>{u==null||u(!a),k(!1)}),children:"SELECT"}),M("⌃C","",()=>k(!1)),M("DETACH",Iv+"d",()=>k(!1))]});if(y)return c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),PE.map(O=>M(O.label,O.seq)),M("ESCI (q)","q",()=>b(!1))]});if(I)return c.jsxs("div",{className:"nc-keybar termux",children:[$,c.jsxs("div",{className:`nc-keygrid compact${v?"":" no-enter"}`,children:[c.jsx("div",{className:"nc-keyrows",children:c.jsxs("div",{className:"row",children:[c.jsx("button",{type:"button","aria-label":p("keybar-expand"),title:p("expand"),...Q(()=>F(!0)),children:c.jsx(Ze,{name:"chevronUp",size:20})},"expand"),T,c.jsx("button",{type:"button",className:w?"armed":"",...Q(()=>k(O=>!O)),children:"☰"},"menu"),M("↑",wt+"[A"),M("↓",wt+"[B"),M("←",wt+"[D"),M("→",wt+"[C"),M("PGUP",wt+"[5~"),M("PGDN",wt+"[6~")]})}),L]})]});const H=S==="compact"&&E,x=H&&c.jsx("button",{type:"button",className:"nc-retract-key","aria-label":p("keybar-retract"),title:p("retract"),...Q(()=>F(!1)),children:c.jsx(Ze,{name:"chevronDown",size:20})});return c.jsxs("div",{className:`nc-keybar termux${H?" expanded":""}`,children:[$,c.jsxs("div",{className:`nc-keygrid${v?"":" no-enter"}${H?" expanded":""}`,children:[x,c.jsxs("div",{className:"nc-keyrows",children:[c.jsxs("div",{className:"row",children:[M("ESC",wt),c.jsx("button",{type:"button",className:w?"armed":"",...Q(()=>k(O=>!O)),children:"☰"},"menu"),M("/","/"),M("—","-"),M("HOME",wt+"[H"),M("↑",wt+"[A"),M("END",wt+"[F"),M("PGUP",wt+"[5~")]}),c.jsxs("div",{className:"row",children:[M("⇥"," "),T,c.jsx("button",{type:"button",className:n?"armed":"",...Q(()=>{s&&s()}),children:"CTRL"},"ctrl"),c.jsx("button",{type:"button",className:C?"armed":"",...Q(()=>R(O=>!O)),children:"ALT"},"alt"),M("←",wt+"[D"),M("↓",wt+"[B"),M("→",wt+"[C"),M("PGDN",wt+"[6~")]})]}),L]})]})}const ME=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function vw({session:e,node:t,token:n,filesEvent:s,onClose:o}){kn();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,f]=N.useState("outbox"),[m,v]=N.useState({inbox:[],outbox:[]}),[S,y]=N.useState(""),b=N.useRef(null);async function w(){try{const F=await(await Ht(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if(F.error){y(F.error);return}v(F);const I=F.outbox[0]?F.outbox[0].mtime:0;localStorage.setItem(X_(u),String(I))}catch(E){y(String(E))}}N.useEffect(()=>{w()},[e,t]),N.useEffect(()=>{s&&s.session===e&&w()},[s]);async function k(E){for(const F of E){y(`carico ${F.name}…`);const I=new FormData;I.append("session",e),I.append("file",F);try{const Y=await(await Ht(`${a}/files/upload`,n,{method:"POST",body:I})).json();y(Y.error?`errore: ${Y.error}`:"")}catch(K){y(String(K))}}w()}async function C(E){const F=await Ht(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(E)}`,n);if(!F.ok){y("errore download");return}const I=await F.blob(),K=URL.createObjectURL(I),Y=document.createElement("a");Y.href=K,Y.download=E,Y.click(),URL.revokeObjectURL(K)}async function R(E){await Ht(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(E)}`,n,{method:"DELETE"}),w()}return c.jsxs("div",{className:"nc-files",children:[c.jsxs("header",{children:[c.jsx("b",{children:t?`${t}:${e}`:e}),c.jsx("button",{onClick:o,title:p("close"),children:c.jsx(Ze,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>f("outbox"),children:"outbox"}),c.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>f("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>b.current&&b.current.click(),children:[c.jsx(Ze,{name:"upload",size:18})," ",p("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:b,style:{display:"none"},onChange:E=>{k(Array.from(E.target.files||[])),E.target.value=""}})]}),S&&c.jsx("div",{className:"nc-busy",children:S}),c.jsxs("ul",{children:[m[h].map(E=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>C(E.name),children:E.name}),c.jsx("small",{children:ME(E.size)}),c.jsx("button",{onClick:()=>R(E.name),title:p("delete"),children:c.jsx(Ze,{name:"trash",size:18})})]},E.name)),m[h].length===0&&c.jsx("li",{className:"empty",children:p("empty-files")})]})]})}const sc="nc_composer_v1",Mh="nc-composer-reset",IE=50,_w=256*1024,yw=512*1024,OE=768*1024,Ov=2*1024*1024,ww=720*60*60*1e3,Ih=1;function bw(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function bf(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Gl(){return{version:Ih,cells:{}}}function Sw(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=bw(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>_w)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=IE))break}let n=0;return t.filter(s=>n+s.text.length>OE?!1:(n+=s.text.length,!0))}function Xl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=yw?e.draft:"",n=Sw(e.history),s=bw(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function BE(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Gl()}if(!t||typeof t!="object"||t.version!==Ih||!t.cells||typeof t.cells!="object")return Gl();const n=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=Xl(o);a&&(n[s]=a)}return{version:Ih,cells:n}}function xw(e){const t=bf(e);if(!t)return Gl();try{return BE(t.getItem(sc))}catch{return Gl()}}function Bv(e){try{return JSON.stringify(e).length}catch{return 1/0}}function zE(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>ww&&delete e.cells[s]}function kw(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function FE(e,t){for(;Bv(e)>Ov;){const n=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of kw(e,t)){if(Bv(e)<=Ov)break;delete e.cells[n]}}function Cw(e,t,n){const s=bf(e);if(!s)return!1;FE(t,n);const o=()=>(s.setItem(sc,JSON.stringify(t)),!0);try{return o()}catch{for(const u of kw(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function oa(e,t,n,s){const o=xw(t);zE(o,n,e);const a=Xl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=Xl(u);return h?o.cells[e]={...h,updatedAt:n}:delete o.cells[e],{ok:Cw(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function $E({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=Mr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Oo(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=xw(t),o=Xl(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>ww?(s.cells[e]&&(delete s.cells[e],Cw(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function zv(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>yw?!1:oa(e,n,s,a=>({...a,draft:o})).ok}function Fv(e,t,n=Date.now()){return e?oa(e,t,n,s=>({...s,draft:""})).ok:!1}function HE(e,t,n,s=Date.now()){return e?oa(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function UE(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>_w?!1:oa(e,n,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:Sw(u)}}).ok}function WE(e,t,n=Date.now()){return e?oa(e,t,n,s=>({...s,history:[]})).ok:!1}function KE(e){const t=bf(e);if(!t)return!1;try{return t.removeItem(sc),!0}catch{return!1}}const qE=300;function VE(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function YE({ownerId:e,node:t,session:n,storage:s=VE()}){const o=N.useMemo(()=>$E({ownerId:e,node:t,session:n}),[e,t,n]),a=N.useMemo(()=>Oo(o,s),[]),[u,h]=N.useState(a.draft),[f,m]=N.useState(a.expanded),[v,S]=N.useState(a.history),[y,b]=N.useState(-1),w=N.useRef(o),k=N.useRef(a.draft),C=N.useRef(null),R=N.useRef(a.updatedAt||0),E=N.useRef(a.draft),F=N.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),I=N.useCallback(()=>{F(),zv(w.current,k.current,s)},[F,s]),K=N.useCallback(()=>{F(),C.current=setTimeout(()=>{C.current=null,zv(w.current,k.current,s)},qE)},[F,s]),Y=N.useCallback(T=>{const L=String(typeof T=="function"?T(k.current):T||"");k.current=L,R.current=Date.now(),E.current=L,b(-1),h(L),K()},[K]),z=N.useCallback((T,L)=>{F(),k.current=T,R.current=Date.now(),h(T),b(L),K()},[F,K]),Z=N.useCallback(()=>{if(!v.length)return!1;const T=Math.min(y+1,v.length-1);return y<0&&(E.current=k.current),z(v[T].text,T),!0},[z,v,y]),G=N.useCallback(()=>{if(y<0)return!1;const T=y-1;return z(T<0?E.current:v[T].text,T),!0},[z,v,y]),Q=N.useCallback(T=>{E.current=k.current;const L=v.findIndex($=>$.text===T);z(String(T||""),L)},[z,v]),B=N.useCallback(()=>{m(T=>{const L=!T;return HE(w.current,L,s),L})},[s]),M=N.useCallback((T,L,$)=>{if(!T)return;if(UE(T,$,s),!(w.current===T)){Oo(T,s).draft===L&&Fv(T,s);return}S(Oo(T,s).history),E.current="",b(-1),k.current===L?(F(),k.current="",R.current=Date.now(),h(""),Fv(T,s)):K()},[F,K,s]),j=N.useCallback(()=>{WE(w.current,s),S([]),b(-1),E.current=k.current},[s]);return N.useEffect(()=>{if(w.current===o)return;I(),w.current=o;const T=Oo(o,s);k.current=T.draft,R.current=T.updatedAt||0,E.current=T.draft,h(T.draft),m(T.expanded),S(T.history),b(-1)},[o,I,s]),N.useEffect(()=>{const T=()=>I(),L=()=>{document.visibilityState==="hidden"&&I()};return window.addEventListener("pagehide",T),document.addEventListener("visibilitychange",L),()=>{window.removeEventListener("pagehide",T),document.removeEventListener("visibilitychange",L),I()}},[I]),N.useEffect(()=>{const T=()=>{F(),k.current="",R.current=0,E.current="",h(""),m(!1),S([]),b(-1)},L=H=>{if(H.key!==sc)return;if(H.newValue==null){T();return}const x=Oo(w.current,s);x.updatedAt<R.current||(F(),k.current=x.draft,R.current=x.updatedAt,E.current=x.draft,h(x.draft),m(x.expanded),S(x.history),b(-1))},$=()=>T();return window.addEventListener("storage",L),window.addEventListener(Mh,$),()=>{window.removeEventListener("storage",L),window.removeEventListener(Mh,$)}},[F,s]),{cellKey:o,text:u,setText:Y,expanded:f,toggleExpanded:B,history:v,historyCursor:y,recallPrevious:Z,recallNext:G,selectHistory:Q,confirmSubmitted:M,clearHistory:j,flush:I}}function Ew({submitText:e,token:t,session:n,node:s,ownerId:o,keepKeyboardClosedOnVoice:a=!0}){kn();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:m,expanded:v,toggleExpanded:S,history:y,historyCursor:b,recallPrevious:w,recallNext:k,selectHistory:C,confirmSubmitted:R,clearHistory:E,flush:F}=YE({ownerId:o,node:s,session:n}),[I,K]=N.useState(!1),[Y,z]=N.useState(""),[Z,G]=N.useState(!1),Q=N.useRef(null),B=N.useRef(null),M=N.useRef(null),[j,T]=N.useState(!1),[L,$]=N.useState({left:0,bottom:0}),[H,x]=N.useState(!1),[O,D]=N.useState(!1),A=N.useRef(null),W=N.useRef(null),X=N.useRef(null),ie=N.useRef(null),ue=N.useRef(null),fe=N.useRef(null),we=N.useRef(null),me=N.useRef(!1),[xe,$e]=N.useState(!1),[ft,qe]=N.useState({left:0,bottom:0,width:320}),Ae=N.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);N.useEffect(()=>{let re=!1;if(s){G(!1);return}return Ht(`${u}/voice/status`,t).then(Pe=>Pe.json()).then(Pe=>{re||G(!!Pe.serverSttConfigured)}).catch(()=>{re||G(!1)}),()=>{re=!0}},[t,u]);const Jt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||Z);async function Oe(){const re=M.current&&typeof M.current.value=="string"?M.current.value:f;Dh(),re!==f&&m(re);const Pe=re,q=aE(Pe);if(!q||O)return;D(!0),z("");let te=!1;try{te=!!await e(q)}catch{te=!1}te?R(h,Pe,q):z(p("composer-send-failed")),D(!1)}function Pt(){const re=A.current&&A.current.getBoundingClientRect();re&&$({left:Math.max(6,Math.min(re.left,window.innerWidth-186)),bottom:window.innerHeight-re.top+6}),T(!0)}function bt(re){T(!1),re&&A.current&&A.current.focus()}function dt(){const re=X.current&&X.current.getBoundingClientRect();if(re){const Pe=Math.max(220,Math.min(360,window.innerWidth-12));qe({left:Math.max(6,Math.min(re.right-Pe,window.innerWidth-Pe-6)),bottom:window.innerHeight-re.top+6,width:Pe})}$e(!0)}function ht(re){$e(!1),re&&X.current&&X.current.focus()}N.useEffect(()=>{if(!j)return;const re=q=>{q.key==="Escape"&&bt(!0)},Pe=q=>{const te=W.current&&W.current.contains(q.target),U=A.current&&A.current.contains(q.target);!te&&!U&&bt(!1)};return document.addEventListener("keydown",re),document.addEventListener("pointerdown",Pe),()=>{document.removeEventListener("keydown",re),document.removeEventListener("pointerdown",Pe)}},[j]),N.useEffect(()=>{if(!xe)return;const re=q=>{q.key==="Escape"&&ht(!0)},Pe=q=>{const te=ie.current&&ie.current.contains(q.target),U=X.current&&X.current.contains(q.target);!te&&!U&&ht(!1)};return document.addEventListener("keydown",re),document.addEventListener("pointerdown",Pe),()=>{document.removeEventListener("keydown",re),document.removeEventListener("pointerdown",Pe)}},[xe]);function Qe(re){if(!(re.isComposing||me.current||re.altKey||re.ctrlKey||re.metaKey)){if(re.key==="ArrowUp"&&re.currentTarget.selectionStart===0&&re.currentTarget.selectionEnd===0){w()&&re.preventDefault();return}re.key==="ArrowDown"&&b>=0&&re.currentTarget.selectionStart===f.length&&re.currentTarget.selectionEnd===f.length&&k()&&re.preventDefault()}}function ot(re){bt(!1),re.current&&re.current.click()}async function oe(re){if(!re.length||!n)return;x(!0),z("");const{paths:Pe,errors:q}=await fw({files:re,token:t,session:n,node:s,paste:!1});q.length&&z(q.map(te=>`${te.name}: ${te.message}`).join(" · ")),Pe.length&&m(te=>te+(te&&!te.endsWith(" ")?" ":"")+Pe.join(" ")),x(!1)}function ke(){Q.current&&Q.current.stop(),B.current&&B.current.stop(),K(!1)}async function Te(){z("");const re=window.SpeechRecognition||window.webkitSpeechRecognition;if(re){const Pe=new re;Pe.lang="it-IT",Pe.continuous=!1,Pe.interimResults=!0;const q=f?`${f} `:"";Pe.onresult=te=>{const U=Array.from(te.results).map(ce=>ce[0].transcript).join("");m(q+U)},Pe.onend=()=>K(!1),Pe.onerror=te=>{z(`voice: ${te.error||"errore"}`),K(!1)},Q.current=Pe,Pe.start(),K(!0);return}try{const Pe=await navigator.mediaDevices.getUserMedia({audio:!0}),q=new MediaRecorder(Pe),te=[];q.ondataavailable=U=>te.push(U.data),q.onstop=async()=>{Pe.getTracks().forEach(U=>U.stop()),K(!1),z("trascrivo…");try{const U=new Blob(te,{type:q.mimeType||"audio/webm"}),de=await(await Ht(`${u}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:U})).json();de.error?z(de.error):(z(""),m(ge=>ge+(ge?" ":"")+(de.text||"")))}catch(U){z(String(U))}},B.current={stop:()=>q.state!=="inactive"&&q.stop()},q.start(),K(!0)}catch{z("microfono non disponibile"),K(!1)}}function ae(){a&&Dh(),I?ke():Te()}return c.jsxs("div",{className:"nc-composer",children:[Y&&c.jsx("div",{className:"nc-composer-err",children:Y}),c.jsxs("div",{className:"nc-composer-row",children:[n&&c.jsx("button",{ref:A,className:H?"attach busy":"attach",disabled:H,onClick:()=>j?bt(!1):Pt(),title:p(H?"attach-uploading":"attach"),"aria-label":p("attach"),"aria-haspopup":"menu","aria-expanded":j,"aria-controls":Ae.current,children:c.jsx(Ze,{name:"attach",size:22})}),j&&c.jsxs("div",{ref:W,id:Ae.current,role:"menu",className:"nc-attach-menu",style:{left:L.left,bottom:L.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>ot(ue),children:[c.jsx(Ze,{name:"file",size:18})," ",p("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>ot(fe),children:[c.jsx(Ze,{name:"camera",size:18})," ",p("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>ot(we),children:[c.jsx(Ze,{name:"image",size:18})," ",p("attach-gallery")]})]}),c.jsx("button",{ref:X,type:"button",className:"history",onPointerDown:re=>re.preventDefault(),onClick:()=>xe?ht(!1):dt(),title:p("composer-history-tools"),"aria-label":p("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":xe,children:c.jsx(Ze,{name:"history",size:21})}),xe&&c.jsxs("div",{ref:ie,role:"menu",className:"nc-composer-history-menu",style:{left:ft.left,bottom:ft.bottom,width:ft.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:re=>re.preventDefault(),onClick:()=>{S(),ht(!1)},children:[c.jsx(Ze,{name:v?"chevronDown":"chevronUp",size:18}),p(v?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:p("composer-history")}),y.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:p("composer-history-empty")}),y.map((re,Pe)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:q=>q.preventDefault(),onClick:()=>{C(re.text),ht(!1)},children:[c.jsx("span",{children:re.text.replace(/\s+/g," ").slice(0,180)}),re.at>0&&c.jsx("small",{children:new Date(re.at).toLocaleString()})]},`${re.at}:${Pe}`)),y.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:re=>re.preventDefault(),onClick:()=>{E(),ht(!1)},children:p("composer-history-clear")})]}),c.jsx("input",{ref:ue,type:"file",multiple:!0,hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("input",{ref:fe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("input",{ref:we,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("textarea",{ref:M,className:v?"expanded":"",rows:v?8:2,value:f,placeholder:p("composer-placeholder"),onChange:re=>m(re.target.value),onKeyDown:Qe,onCompositionStart:()=>{me.current=!0},onCompositionEnd:()=>{me.current=!1},onBlur:F}),Jt&&c.jsx("button",{type:"button",className:I?"mic on":"mic",title:p("voice"),"aria-label":p("voice"),onPointerDown:re=>{re.preventDefault(),ae()},onClick:re=>{re.detail===0&&ae()},children:c.jsx(Ze,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:re=>re.preventDefault(),onClick:Oe,title:p("send"),children:c.jsx(Ze,{name:"enter",size:22})})]})]})}function dd(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const GE=180,XE=480,Nr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function QE({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:f,onKill:m,onVisibility:v,onNew:S,onNodeRename:y,onSettings:b,onBootError:w,localNodeId:k,fleetCapabilities:C=[],bootSettlement:R=null,onBootSettlementApplied:E,onOpenVlSession:F,width:I=240,collapsed:K=!1,onResize:Y,onToggleCollapse:z}){const[Z,G]=kn(),{pins:Q,orders:B,togglePin:M,viewFor:j,updateView:T,canMoveRoster:L,moveRoster:$,stepRoster:H}=rf(),{groupsFor:x,moveNode:O,stepNode:D,nodeKey:A}=py(),W=new Set((t||[]).map(q=>q.tmuxSession)),X=new Map((e||[]).map(q=>[q.name,q])),ie=(q,te)=>vx(Q,q,te),ue=_x,fe=[...t||[]].sort((q,te)=>ue(ie(q.tmuxSession,(X.get(q.tmuxSession)||{}).activity),ie(te.tmuxSession,(X.get(te.tmuxSession)||{}).activity))),we=(e||[]).filter(q=>!W.has(q.name)).sort((q,te)=>ue(ie(q.name,q.activity),ie(te.name,te.activity))||q.name.localeCompare(te.name)),me=new Set(n||[]),xe=af(fe,we,X),$e=gs(xe,Q,j("local").filter,Fi(B,"local")),qe=x(s||[]).map(q=>{const te=(q.route&&q.route.length?q.route:[q.name]).join("/"),U=j(te);if(q.kind==="vl")return{g:q,nodeRoute:te,groupView:U,rawItems:[],items:[]};const{rawItems:ce}=Fl(q),de=gs(ce,Q,U.filter,Fi(B,te));return{g:q,nodeRoute:te,groupView:U,rawItems:ce,items:de}}),Ae=(q,te,U)=>o&&o({session:q,...te?{node:te}:{},...Mr.test(String(U||""))?{ownerId:U}:{}}),Rt=async q=>{if(!(q!=null&&q.direct)||!y)return;const te=window.prompt(p("rename-node-prompt"),q.label||q.name);if(te!==null)try{await y(q,te)||window.alert(p("rename-node-invalid"))}catch(U){window.alert(String((U==null?void 0:U.message)||U))}},[Jt,Oe]=N.useState({}),[Pt,bt]=N.useState(new Set);N.useEffect(()=>{const q=new Map;for(const te of t||[])q.set(Nr(te.cell),!!te.boot);for(const te of s||[]){const U=te.route||[te.name];for(const ce of te.cells||[])q.set(Nr(ce.cell,U),!!ce.boot)}Oe(te=>{let U=!1;const ce={...te};for(const[de,ge]of Object.entries(te))q.has(de)&&q.get(de)===ge&&(delete ce[de],U=!0);return U?ce:te})},[t,s]),N.useEffect(()=>{if(!(R!=null&&R.cell))return;const q=Array.isArray(R.route)?R.route:[],te=Nr(R.cell,q);Oe(U=>({...U,[te]:!!R.enabled})),E&&E(R.id)},[R,E]);const dt=(q,te=[])=>{const U=Nr(q.cell,te);return Object.prototype.hasOwnProperty.call(Jt,U)?Jt[U]:!!q.boot},ht=async(q,te,U=[])=>{if(q.stopPropagation(),!h)return;const ce=Nr(te.cell,U),de=!dt(te,U);Oe(ge=>({...ge,[ce]:de})),bt(ge=>new Set(ge).add(ce));try{await h(te.cell,de,U)}catch(ge){Oe(De=>{const _e={...De};return delete _e[ce],_e}),w&&w(ge)}finally{bt(ge=>{const De=new Set(ge);return De.delete(ce),De})}},Qe=(q,te=[])=>{const U=Nr(q.cell,te),ce=dt(q,te),de=`${p(ce?"boot-disable":"boot-enable")} ${q.cell}`;return c.jsx("button",{className:`nc-boot${ce?" on":""}`,disabled:Pt.has(U),onClick:ge=>ht(ge,q,te),title:de,"aria-label":de,children:c.jsx(Ze,{name:"boot",size:14})})},[ot,oe]=N.useState(null),ke=(q,te)=>{const U=q.currentTarget.getBoundingClientRect();oe({text:te,y:U.top+U.height/2})},Te=()=>oe(null),ae=N.useRef(null);N.useEffect(()=>()=>{ae.current&&ae.current()},[]);function re(q){q.preventDefault(),q.stopPropagation();const te=q.clientX,U=I,ce=ge=>{const De=Math.max(GE,Math.min(XE,U+(ge.clientX-te)));Y&&Y(De)},de=()=>{window.removeEventListener("pointermove",ce),window.removeEventListener("pointerup",de),window.removeEventListener("pointercancel",de),window.removeEventListener("blur",de),ae.current=null};window.addEventListener("pointermove",ce),window.addEventListener("pointerup",de),window.addEventListener("pointercancel",de),window.addEventListener("blur",de),ae.current=de}const Pe=K?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return K?c.jsxs("aside",{className:"nc-sidebar mini",style:Pe,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:p("settings"),onMouseEnter:q=>ke(q,p("settings")),onMouseLeave:Te,children:c.jsx(Ze,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[j("local").open&&$e.map(q=>q.type==="cell"?(()=>{const te=q.value,U=te.degraded?"warn":te.tmux?"on":"",ce=!!te.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${me.has(te.tmuxSession)?" active":""}`,onMouseEnter:de=>ke(de,`${te.cell}: ${q.subtitle}`),onMouseLeave:Te,draggable:ce,onDragStart:ce?de=>de.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:ce?()=>a&&a(te.tmuxSession):()=>u&&u(te),onDoubleClick:ce?()=>Ae(te.tmuxSession,"",k):void 0,children:c.jsx("span",{className:`nc-dot ${U}${q.working?" working":""}`})},q.key)})():(()=>{const te=q.value;return c.jsx("button",{type:"button",className:`nc-mini-init${me.has(te.name)?" active":""}`,onMouseEnter:U=>ke(U,te.name),onMouseLeave:Te,draggable:!0,onDragStart:U=>U.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Ae(te.name,"",k),children:dd(te.name)},q.key)})()),qe.flatMap(({g:q,nodeRoute:te,groupView:U,items:ce})=>q.kind==="vl"?q.status==="up"&&q.sessions.length?q.sessions.map(de=>c.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:ge=>ke(ge,`${q.label||te}: ${de.name}`),onMouseLeave:Te,onClick:()=>F&&F(q.peer),children:dd(de.name)},de.key)):[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:de=>ke(de,`${q.label||q.name}: ${q.status==="up"?p("no-sessions-short"):Bi(q)}`),onMouseLeave:Te,children:c.jsx("span",{className:`nc-dot${q.status==="up"?" on":" warn"}`})},`nodo-vl-${te}-${q.name}`)]:q.status==="up"?U.open?ce.map(de=>de.type==="cell"?(()=>{const ge=de.value,De=!!ge.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${me.has(de.key)?" active":""}`,onMouseEnter:_e=>ke(_e,`${q.label||te}: ${ge.cell} · ${de.subtitle}`),onMouseLeave:Te,draggable:De,onDragStart:De?_e=>_e.dataTransfer.setData("text/nc-session",de.key):void 0,onClick:De?()=>a&&a(de.key):()=>u&&u({...ge,route:q.route,availableEngines:q.engines||[]}),onDoubleClick:De?()=>Ae(ge.tmuxSession,te,q.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${ge.degraded?"warn":De?`on${de.working?" working":""}`:""}`})},de.key)})():(()=>{const ge=de.value;return c.jsx("button",{type:"button",className:`nc-mini-init${me.has(de.key)?" active":""}`,onMouseEnter:De=>ke(De,`${q.label||te}: ${ge.name}`),onMouseLeave:Te,draggable:!0,onDragStart:De=>De.dataTransfer.setData("text/nc-session",de.key),onClick:()=>a&&a(de.key),onDoubleClick:()=>Ae(ge.name,te,q.instanceId),children:dd(ge.name)},de.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:de=>ke(de,`${q.label||(q.route||[q.name]).join(" › ")}: ${Bi(q)}`),onMouseLeave:Te,children:c.jsx("span",{className:`nc-dot${q.status==="passive"?"":" warn"}`})},`nodo-${(q.route||[q.name]).join("/")}`)])]})}),ot&&c.jsx("div",{className:"nc-mini-tip",style:{top:ot.y},children:ot.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:Pe,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:p("fleet")}),c.jsxs("button",{className:"nc-new-btn",onClick:S,title:p("fleet-new-cell"),children:["+ ",p("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:p("settings"),children:[c.jsx(Ze,{name:"gear",size:15})," ",p("settings")]}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(JE,{label:p("position-local"),count:$e.length,state:j("local"),onToggle:()=>T("local",{open:!j("local").open}),onFilter:q=>T("local",{filter:q})}),j("local").open&&c.jsxs("div",{className:"nc-side-group",children:[$e.map(q=>q.type==="cell"?(()=>{const te=q.value,U=te.degraded?"warn":te.tmux?"on":"",ce=te.degraded?p("cell-degraded"):q.working?q.subtitle:te.tmux?p("cell-idle"):p("cell-off"),de=!!te.tmux;return c.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-cell${de?" live":""}${me.has(te.tmuxSession)?" active":""}`,title:`${te.cell} · ${q.subtitle}${ce===q.subtitle?"":` · ${ce}`}`,"aria-label":`${te.cell}, ${q.subtitle}${ce===q.subtitle?"":`, ${ce}`}`,draggable:de,onDragStart:de?ge=>ge.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:de?()=>a&&a(te.tmuxSession):void 0,onDoubleClick:de?()=>Ae(te.tmuxSession,"",k):void 0,children:[c.jsx(bi,{position:"local",itemKey:q.key,label:te.cell,canMove:L,onMove:(ge,De)=>$("local",ge,De,xe),onStep:ge=>H("local",q.key,ge,xe)}),c.jsx("span",{className:`nc-dot ${U}${q.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:te.cell,children:te.cell}),c.jsx("small",{title:q.subtitle,children:q.subtitle})]}),c.jsx("button",{className:`nc-pin${Q.includes(q.key)?" on":""}`,title:p("pin"),onClick:ge=>{ge.stopPropagation(),M(q.key)},children:Q.includes(q.key)?"★":"☆"}),h&&C.includes("boot")&&Qe(te),c.jsx("button",{className:`nc-power${te.tmux?" on":""}${te.degraded?" warn":""}`,onClick:ge=>{ge.stopPropagation(),u&&u({...te,boot:dt(te)})},title:te.active?p("power-off"):p("power-on"),children:c.jsx(Ze,{name:"power",size:14})})]},q.key)})():(()=>{var U;const te=q.value;return c.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-side-card${me.has(te.name)?" active":""}`,draggable:!0,onDragStart:ce=>ce.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Ae(te.name,"",k),children:[c.jsx(bi,{position:"local",itemKey:q.key,label:te.name,canMove:L,onMove:(ce,de)=>$("local",ce,de,xe),onStep:ce=>H("local",q.key,ce,xe)}),c.jsx("span",{className:te.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:te.name}),c.jsxs("small",{children:[te.preview||te.cmd||p("windows").replace("{n}",String(te.windows||0)),((U=te.outbox)==null?void 0:U.count)>0?` · 📦${te.outbox.count}`:""]})]}),te.activity?c.jsx("span",{className:"nc-rel",children:Dr(te.activity)}):null,c.jsx("button",{className:`nc-pin${Q.includes(q.key)?" on":""}`,title:p("pin"),onClick:ce=>{ce.stopPropagation(),M(q.key)},children:Q.includes(q.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${te.technical?" on":""}`,title:te.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${te.technical?p("mark-normal"):p("mark-technical")} ${te.name}`,onClick:ce=>{ce.stopPropagation(),v&&v(te.name,!te.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:ce=>{ce.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",te.name))&&m&&m(te.name)},children:"⋯"})]},q.key)})()),$e.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]}),qe.map(({g:q,nodeRoute:te,groupView:U,rawItems:ce,items:de})=>{const De=my(q.health)||(q.status==="up"?"on":q.status==="passive"?"":"warn");return q.kind==="vl"?c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":A(q),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>T(te,{open:!U.open}),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),T(te,{open:!U.open}))},children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:A(q),label:q.label||q.name,onMove:(_e,Ee)=>O(_e,Ee,s||[]),onStep:_e=>D(A(q),_e,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:U.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${De}`,title:q.health?qo(q.health):""}),c.jsx("b",{children:q.label||q.name}),c.jsxs("small",{children:[" · ",q.status==="up"?p("node-sessions").replace("{n}",String(q.sessions.length)):Bi(q)]})]}),q.status==="up"&&U.open&&c.jsxs("div",{className:"nc-side-group",children:[q.sessions.map(_e=>c.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>F&&F(q.peer),onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),F&&F(q.peer))},children:[c.jsx("span",{className:"nc-dot on"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:_e.name}),c.jsx("small",{children:p("vl-events-title")})]})]},_e.key)),q.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-vl-${te}-${q.name}`):c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":A(q),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:q.direct&&y?_e=>{_e.preventDefault(),Rt(q)}:void 0,onClick:()=>T(te,{open:!U.open}),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),T(te,{open:!U.open}))},children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:A(q),label:q.label||q.name,onMove:(_e,Ee)=>O(_e,Ee,s||[]),onStep:_e=>D(A(q),_e,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:U.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${De}`,title:q.health?qo(q.health):""}),c.jsx("b",{children:q.label||q.name}),c.jsxs("small",{children:[" · ",q.status==="up"?p("node-sessions").replace("{n}",String(de.length)):q.health&&qo(q.health)||Bi(q)]}),c.jsxs("select",{className:"nc-node-filter",value:U.filter,title:p(`view-${U.filter}`),onClick:_e=>_e.stopPropagation(),onChange:_e=>T(te,{filter:_e.target.value}),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]}),q.direct&&y&&c.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${q.label||q.name}`,onClick:_e=>{_e.stopPropagation(),Rt(q)},children:"✎"}),q.direct&&q.health&&q.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${q.tunnelStatus==="up"?" on":""}`,title:q.tunnelStatus==="up"?p("power-off"):p("power-on"),onClick:_e=>{_e.stopPropagation(),f&&f(q)},children:c.jsx(Ze,{name:"power",size:14})})]}),q.status==="up"&&U.open&&c.jsxs("div",{className:"nc-side-group",children:[de.map(_e=>_e.type==="cell"?(()=>{const Ee=_e.value,nt=!!Ee.tmux,at=Ee.degraded?"warn":Ee.tmux?"on":"";return c.jsxs("div",{"data-roster-key":_e.key,"data-position":te,className:`nc-side-card nc-cell${nt?" live":""}${me.has(Ee.key)?" active":""}`,title:_e.working?_e.subtitle:Ee.tmux?p("cell-idle"):p("cell-off"),draggable:nt,onDragStart:nt?Je=>Je.dataTransfer.setData("text/nc-session",Ee.key):void 0,onClick:nt?()=>a&&a(Ee.key):void 0,onDoubleClick:nt?()=>Ae(Ee.tmuxSession,te,q.instanceId):void 0,children:[c.jsx(bi,{position:te,itemKey:_e.key,label:Ee.cell,canMove:L,onMove:(Je,Mt)=>$(te,Je,Mt,ce),onStep:Je=>H(te,_e.key,Je,ce)}),c.jsx("span",{className:`nc-dot ${at}${_e.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ee.cell}),c.jsx("small",{title:_e.subtitle,children:_e.subtitle})]}),c.jsx("button",{className:`nc-pin${Q.includes(_e.key)?" on":""}`,title:p("pin"),onClick:Je=>{Je.stopPropagation(),M(_e.key)},children:Q.includes(_e.key)?"★":"☆"}),h&&(q.capabilities||[]).includes("boot")&&Qe(Ee,q.route||[]),(q.capabilities||[]).includes(Ee.active?"down":"up")&&c.jsx("button",{className:`nc-power${Ee.active?" on":""}${Ee.degraded?" warn":""}`,onClick:Je=>{Je.stopPropagation(),u&&u({...Ee,boot:dt(Ee,q.route||[]),route:q.route,availableEngines:q.engines||[]})},title:Ee.active?p("power-off"):p("power-on"),children:c.jsx(Ze,{name:"power",size:14})})]},_e.key)})():(()=>{const Ee=_e.value;return c.jsxs("div",{"data-roster-key":_e.key,"data-position":te,className:`nc-side-card${me.has(Ee.key)?" active":""}`,draggable:!0,onDragStart:nt=>nt.dataTransfer.setData("text/nc-session",Ee.key),onClick:()=>a&&a(Ee.key),onDoubleClick:()=>Ae(Ee.name,Ee.node||te,q.instanceId),children:[c.jsx(bi,{position:te,itemKey:_e.key,label:Ee.name,canMove:L,onMove:(nt,at)=>$(te,nt,at,ce),onStep:nt=>H(te,_e.key,nt,ce)}),c.jsx("span",{className:Ee.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ee.name}),c.jsx("small",{children:Ee.preview?Ee.preview:Ee.cmd?Ee.cmd:p("windows").replace("{n}",String(Ee.windows||0))})]}),Ee.activity?c.jsx("span",{className:"nc-rel",children:Dr(Ee.activity)}):null,c.jsx("button",{className:`nc-pin${Q.includes(_e.key)?" on":""}`,title:p("pin"),onClick:nt=>{nt.stopPropagation(),M(_e.key)},children:Q.includes(_e.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Ee.technical?" on":""}`,title:Ee.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${Ee.technical?p("mark-normal"):p("mark-technical")} ${Ee.name}`,onClick:nt=>{nt.stopPropagation(),v&&v(Ee.name,!Ee.technical,q.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:nt=>{nt.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",Ee.name))&&m&&m(Ee.name,q.route)},children:"⋯"})]},_e.key)})()),de.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-${(q.route||[q.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:uy.map((q,te)=>c.jsxs("span",{children:[te>0&&" · ",c.jsx("button",{className:`nc-lang-btn${Z===q?" on":""}`,onClick:()=>G(q),title:q,children:q.toUpperCase()})]},q))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:re,title:""})]})}function JE({label:e,count:t,state:n,onToggle:s,onFilter:o}){return c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[c.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:e}),c.jsxs("small",{children:[" · ",p("node-sessions").replace("{n}",String(t))]}),c.jsxs("select",{className:"nc-node-filter",value:n.filter,title:p(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]})]})}function ZE(e,t,n){return!e&&t?n+1:n}const Sf="nc_input_preferences_v1",hd="nc-input-preferences",Nw=Object.freeze(["double-tap","single-tap","never"]),jw=Object.freeze(["full","compact"]),ps=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function xf(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Nw.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:ps.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:ps.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:ps.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:ps.showKeybarEnter,keybarLayout:jw.includes(t.keybarLayout)?t.keybarLayout:ps.keybarLayout}}function Rw(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function $v(e=Rw()){if(!e)return{...ps};try{return xf(JSON.parse(e.getItem(Sf)||"null"))}catch{return{...ps}}}function eN(e,t=Rw()){const n=xf(e);if(t)try{t.setItem(Sf,JSON.stringify(n))}catch{}return n}function kf(){const[e,t]=N.useState($v);N.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Sf&&o.key!==null)return;const a=o!=null&&o.detail?xf(o.detail):$v();t(a)};return window.addEventListener(hd,s),window.addEventListener("storage",s),()=>{window.removeEventListener(hd,s),window.removeEventListener("storage",s)}},[]);const n=N.useCallback(s=>{t(o=>{const a=eN({...o,...s||{}});return window.dispatchEvent(new CustomEvent(hd,{detail:a})),a})},[]);return[e,n]}function tN({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:f,onOpenSingle:m,alive:v=!0,available:S=!0,fontSize:y=ta,onZoom:b,decks:w=[],currentDeck:k,onSendToDeck:C}){const[R]=kf(),E=s||e,F=N.useRef(()=>{}),I=N.useRef(()=>!1),K=N.useRef(()=>{}),Y=N.useRef(!1),[z,Z]=N.useState(!1),[G,Q]=N.useState(!1),[B,M]=N.useState(!1),[j,T]=N.useState(null),[L,$]=N.useState(0),H=N.useRef(v),x=t?`${t}:${e}`:e,O=w.filter(D=>D.id!==k&&D.available!==!1);return N.useEffect(()=>{const D=H.current;!D&&v&&$(A=>ZE(D,v,A)),H.current=v},[v]),c.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(x),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:D=>{D.dataTransfer.setData("text/nc-session",x),D.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(x),title:t?`${E} · ${t}`:E,children:[c.jsx("span",{className:v?"nc-dot on":"nc-dot"}),c.jsx("b",{children:E})]}),c.jsxs("span",{className:"nc-tile-actions",children:[b&&c.jsx("button",{onClick:()=>b(-1),title:p("zoom-out"),children:c.jsx(Ze,{name:"zoomOut",size:14})}),b&&c.jsx("button",{onClick:()=>b(1),title:p("zoom-in"),children:c.jsx(Ze,{name:"zoomIn",size:14})}),C&&O.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:p("send-to-deck"),value:"",onMouseDown:D=>D.stopPropagation(),onChange:D=>{const A=D.target.value;A&&C(x,A),D.target.value=""},children:[c.jsx("option",{value:"",children:p("send-to-deck")}),O.map(D=>c.jsxs("option",{value:D.id,children:[D.ownerLabel," · ",D.name]},D.id))]}),c.jsx("button",{onClick:()=>Q(D=>!D),title:p("composer"),children:"⌨"}),c.jsx("button",{onClick:()=>M(D=>!D),title:p("files"),children:"📁"}),m&&c.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:n}),title:p("single-view"),children:"↗"}),f&&c.jsx("button",{className:"nc-tile-close",onClick:()=>f(x),title:p("close"),children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[S?c.jsx(gw,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:F,composerRef:I,actionRef:K,ctrlRef:Y,setCtrlArmed:Z,onFiles:T,fontSize:y,keyboardGesture:R.terminalKeyboardGesture},`${x}:${L}`):c.jsx("div",{className:"nc-tile-unavailable",children:p("deck-owner-unavailable")}),S&&B&&c.jsx("div",{className:"nc-tile-files",onMouseDown:D=>D.stopPropagation(),children:c.jsx(vw,{session:e,node:t,token:o,filesEvent:j,onClose:()=>M(!1)})})]}),S&&G&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:D=>D.stopPropagation(),children:c.jsx(Ew,{submitText:D=>I.current(D),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:R.voiceKeepsKeyboardClosed})})]})}function nN({session:e,node:t,ownerId:n,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const f of h){if(!f||(Array.isArray(f.route)?f.route:[]).join("/")!==t||n&&f.instanceId&&String(n)!==String(f.instanceId))continue;const v=(Array.isArray(f.cells)?f.cells:[]).find(S=>S&&S.tmuxSession===a);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function Cf({session:e,cell:t,node:n,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const h=nN({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const Hv=.2,Uv=.28,Pw=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),fd=e=>Pw(e,"text/nc-session"),Wv=e=>{var t;return Pw(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function iN(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<Uv?"left":s>1-Uv?"right":o<.5?"top":"bottom"}function sN({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:f=[],currentDeck:m,onSendToDeck:v,cells:S=[],nodeGroups:y=[]}){kn();const[b,w]=N.useState(null),k=N.useRef(null),C=N.useRef([]),R=N.useRef(null);function E(B,M){const j=()=>{window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("blur",j),R.current=null};window.addEventListener("pointermove",B),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("blur",j),R.current=j}N.useEffect(()=>()=>{R.current&&R.current()},[]),N.useEffect(()=>{const B=()=>w(null);return window.addEventListener("dragend",B),window.addEventListener("drop",B),()=>{window.removeEventListener("dragend",B),window.removeEventListener("drop",B)}},[]);const F=e.columns.length,I=B=>b&&b.col===B&&b.row===void 0,K=!!b&&b.col===F,Y=(B,M)=>b&&b.col===B&&b.row===M&&b.quadrant?` drop-${b.quadrant}`:"";function z(B){if(B.preventDefault(),Wv(B.dataTransfer)){w(null);return}const M=B.dataTransfer.getData("text/nc-session"),j=b;if(w(null),!M||!j)return;let T;if(j.quadrant){if(T=Lx(e,j.col,j.row,j.quadrant),!T)return}else T={col:j.col};t(ki(e).includes(M)?Ex(e,M,T):cf(e,M,T))}function Z(B,M){B.preventDefault(),B.stopPropagation();const j=B.clientX,T=e.columns[M].width,L=k.current&&k.current.clientWidth||1,$=e.columns[M+1];E(x=>{let O=Math.max(Hv,T+(x.clientX-j)/L);if($){const D=Mg(O/(O+$.width));O=D/(1-D)*$.width}t(jx(e,M,O))})}function G(B,M,j){B.preventDefault(),B.stopPropagation();const T=B.clientY,L=e.columns[M].tiles[j].height,$=C.current[M],H=$&&$.clientHeight||1,x=e.columns[M].tiles[j+1];E(D=>{let A=Math.max(Hv,L+(D.clientY-T)/H);if(x){const W=Mg(A/(A+x.height));A=W/(1-W)*x.height}t(Rx(e,M,j,A))})}function Q(B){t(Hl(e,B))}return c.jsxs("div",{className:"nc-grid",ref:k,onDragOver:B=>{if(Wv(B.dataTransfer)){B.preventDefault(),w(null);return}fd(B.dataTransfer)&&(B.preventDefault(),b&&b.col===F||w({col:F}))},onDrop:z,onDragLeave:B=>{const M=B.relatedTarget;(!M||!(k.current&&k.current.contains(M)))&&w(null)},children:[e.columns.flatMap((B,M)=>{const j=[];return j.push(c.jsx("div",{className:`nc-col${I(M)?" drop-newcol":""}`,ref:T=>{C.current[M]=T},style:{flexGrow:B.width,flexBasis:0},onDragOver:T=>{fd(T.dataTransfer)&&(T.preventDefault(),T.stopPropagation(),b&&b.col===M&&b.row===void 0||w({col:M}))},children:B.tiles.flatMap((T,L)=>{const $=[],H=$n(T),x=Cf({session:T.session,node:T.node,ownerId:T.ownerId,cells:S,nodeGroups:y});return $.push(c.jsx("div",{className:`nc-tile-slot${Y(M,L)}`,style:{flexGrow:T.height,flexBasis:0},onDragOver:O=>{if(!fd(O.dataTransfer))return;O.preventDefault(),O.stopPropagation();const D=iN(O.clientX,O.clientY,O.currentTarget.getBoundingClientRect());b&&b.col===M&&b.row===L&&b.quadrant===D||w({col:M,row:L,quadrant:D})},children:c.jsx(tN,{session:T.session,node:T.node,ownerId:T.ownerId,cellName:x,token:n,readonly:s,focused:a===H,onFocus:u,onClose:Q,onOpenSingle:h,available:T.unavailable!==!0,alive:T.unavailable!==!0&&(!o||o.has(H)),fontSize:T.fontSize,onZoom:O=>t(Px(e,M,L,O)),decks:f,currentDeck:m,onSendToDeck:v})},H)),L<B.tiles.length-1&&$.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:O=>G(O,M,L)},`h${L}`)),$})},`c${M}`)),M<F-1&&j.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:T=>Z(T,M)},`v${M}`)),j}),K&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),F===0&&c.jsx("div",{className:"nc-grid-empty",children:p("grid-empty")})]})}const Si="local",Hn=/^[a-f0-9]{16,64}$/;function Ar(e,t){return`${e&&Hn.test(e)?e:Si}:${t}`}function rc(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==Si&&!Hn.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Si?null:s,name:o}}function oc(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Ef(e){return{columns:Ys(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function rN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Hn.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(oc(n.route),n.instanceId);return t}function oN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Hn.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function Oh(e,t,n=[]){const s=Ef(e),o=rN(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&Hn.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Bh(e,t,n=[]){const s=Ef(e),o=new Map;for(const a of n)a&&Hn.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const u of a.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=oc(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function Kv(e,t,n=[]){const s=Ef(e),o=oN(n);for(const a of s.columns)for(const u of a.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=oc(o.get(u.ownerId))));return s}function Lw(e,t,n=[]){const s=ys(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Hn.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>oc(a&&a.route)===s.node);return{...s,...o&&Hn.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const aN=/^[a-z0-9-]{1,32}$/,Un="main",Aw="nc_decks",Tw="nc_deck_order_v1",Dw=24;function qv(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Br(e){return typeof e=="string"&&aN.test(e)}function lN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Br(n)?n:Un}return Un}function cN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Ar(null,Un),ownerId:null,name:Un}}if(Hn.test(s)&&Br(o))return{id:Ar(s,o),ownerId:s,name:o}}const n=lN(e);return{id:Ar(null,n),ownerId:null,name:n}}function pd(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:rc(e)||{ownerId:null,name:e},s=Br(n.name)?n.name:Un,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===Un?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function Mw(e){return e===Un?"nc_grid_v1":`nc_grid_v1__${e}`}function Iw(e){const t=[Un];if(Array.isArray(e)){for(const n of e)if(Br(n)&&n!==Un&&!t.includes(n)&&t.push(n),t.length>=Dw)break}return t}function Ur(){return typeof localStorage<"u"?localStorage:null}function uN(){const e=Ur();if(!e)return[Un];try{return Iw(JSON.parse(e.getItem(Aw)||"null"))}catch{return[Un]}}function dN(e){const t=Ur();if(t)try{t.setItem(Aw,JSON.stringify(Iw(e)))}catch{}}function aa(e){return e==="local"||Hn.test(String(e||""))}function ac(e,t){const n=rc(e);return!!n&&(n.ownerId||"local")===t}function Ei(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!aa(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&ac(a,n)))].slice(0,Dw);o.length&&(t[n]=o)}return t}function xl(e=Ur()){if(!e)return{};try{return Ei(JSON.parse(e.getItem(Tw)||"null"))}catch{return{}}}function md(e,t=Ur()){const n=Ei(e);if(t)try{t.setItem(Tw,JSON.stringify(n))}catch{}return n}function lc(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function hN(e,t,n,s,o=[]){if(!aa(t)||n===s)return Ei(e);const a=[...new Set(o.filter(S=>ac(S,t)))];if(!a.includes(n)||!a.includes(s))return Ei(e);const u=lc(e,t).filter(S=>a.includes(S)),h=[...u,...a.filter(S=>!u.includes(S))],f=h.indexOf(n),m=h.indexOf(s);h.splice(f,1);const v=h.indexOf(s);return h.splice(f<m?v+1:v,0,n),Ei({...e,[t]:h})}function fN(e,t,n,s){if(!aa(t)||!ac(s,t))return Ei(e);const o=lc(e,t);return o.includes(n)?Ei({...e,[t]:o.map(a=>a===n?s:a)}):Ei(e)}function pN(e,t,n){return aa(t)?Ei({...e,[t]:lc(e,t).filter(s=>s!==n)}):Ei(e)}function Vv(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!aa(a)||!ac(o==null?void 0:o.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(o))}const s=[];for(const[,o]of n){const a=o[0].local?"local":o[0].ownerId,u=lc(t,a),h=new Map(u.map((f,m)=>[f,m]));o.sort((f,m)=>{const v=h.has(f.id)?h.get(f.id):Number.MAX_SAFE_INTEGER,S=h.has(m.id)?h.get(m.id):Number.MAX_SAFE_INTEGER;return v-S}),s.push(...o)}return s}function zh(e){const t=Ur();if(!t)return null;try{return JSON.parse(t.getItem(Mw(e))||"null")}catch{return null}}function mN(e,t){const n=Ur();if(n)try{n.setItem(Mw(e),JSON.stringify(t))}catch{}}const Nf="nc_deckbar_collapsed_v1",Ow=64;function jf(e){return e===Si||Hn.test(String(e||""))}function Rf(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Ow)break;if(jf(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function Bw(e,t){return jf(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function gN(e,t){const n=Rf(e);return jf(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=Ow&&delete n[Object.keys(n)[0]],n[t]=!Bw(n,t)),n}function zw(){return typeof localStorage<"u"?localStorage:null}function Yv(e=zw()){if(!e)return{};try{return Rf(JSON.parse(e.getItem(Nf)||"null"))}catch{return{}}}function vN(e,t=zw()){const n=Rf(e);if(t)try{t.setItem(Nf,JSON.stringify(n))}catch{}return n}function _N(){const[e,t]=N.useState(Yv);N.useEffect(()=>{const o=a=>{(a.key===Nf||a.key===null)&&t(Yv())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=N.useCallback(o=>Bw(e,o),[e]),s=N.useCallback(o=>{t(a=>vN(gN(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const Pf="nc_deck_presence_v1",Gv=3e4,yN=18e4,Fw=1e4,$w=32,wN=/^[A-Za-z0-9_-]{1,64}$/,bN=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),Xv="working",SN="on",xN="neutral",kN="warn";function Lf(e){return typeof e=="string"&&wN.test(e)&&!bN.has(e)}function Hw(e){return typeof e=="string"&&rc(e)!==null}function Af(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function zr(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=$w)break;Lf(s)&&(!o||typeof o!="object"||Hw(o.deckId)&&Af(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function Uw(e,t){const n=zr(e);if(!Af(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?Gv:yN,h=t-u;a.ts>=h&&a.ts<=t+Gv&&(s[o]=a)}return s}function Qv(e,t,n,s){if(!Lf(t)||!Af(s))return zr(e);const o=Uw(e,s);if(!Hw(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=$w){let a="",u=1/0;for(const[h,f]of Object.entries(o))f.ts<u&&(a=h,u=f.ts);a&&delete o[a]}return o[t]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},zr(o)}function CN(e,t){const n=zr(e);if(!Lf(t))return n;const s={...n};return delete s[t],s}function EN(e,t){const n=Uw(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?Xv:SN;s[o.deckId]!==Xv&&(s[o.deckId]=a)}return s}function Ww(){return typeof localStorage<"u"?localStorage:null}function kl(e=Ww()){if(!e)return{};try{return zr(JSON.parse(e.getItem(Pf)||"null"))}catch{return{}}}function gd(e,t=Ww()){const n=zr(e);if(t)try{t.setItem(Pf,JSON.stringify(n))}catch{}return n}const NN=Math.min(Fw,5e3);function jN(){var e,t;try{const n=(t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const RN=jN();function Jv(){const e=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,t=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:e,visible:t}}function PN(e,t=!0){const s=N.useRef(RN).current,o=N.useRef(e);o.current=e;const[a,u]=N.useState(()=>({map:{},now:Date.now()})),h=N.useCallback(()=>{u({map:kl(),now:Date.now()})},[]);N.useEffect(()=>{if(!t)return;const v=()=>{const C=Date.now(),R=Qv(kl(),s,{deckId:o.current,...Jv()},C);return gd(R),{map:R,now:C}},S=()=>u(v());S();const y=setInterval(v,Fw),b=setInterval(h,NN),w=S,k=C=>{(C.key===Pf||C.key===null)&&h()};return window.addEventListener("focus",w),window.addEventListener("blur",w),typeof document<"u"&&document.addEventListener("visibilitychange",w),window.addEventListener("storage",k),()=>{clearInterval(y),clearInterval(b),window.removeEventListener("focus",w),window.removeEventListener("blur",w),typeof document<"u"&&document.removeEventListener("visibilitychange",w),window.removeEventListener("storage",k);try{gd(CN(kl(),s))}catch{}}},[t,s,h]),N.useEffect(()=>{if(!t)return;const v=Date.now(),S=Qv(kl(),s,{deckId:e,...Jv()},v);gd(S),u({map:S,now:v})},[e,t,s]);const f=N.useMemo(()=>t?EN(a.map,a.now):{},[t,a]);return{dotFor:N.useCallback((v,S=!1)=>t?S?kN:f[v]||xN:null,[f,t]),windowId:s}}const Zv=52,e_=18;function LN({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=N.useRef(null),u=N.useRef(0),[h,f]=N.useState(!1),m=()=>{var k,C,R,E;const w=a.current;(C=(k=w==null?void 0:w.over)==null?void 0:k.classList)==null||C.remove("nc-deck-over"),(E=(R=w==null?void 0:w.source)==null?void 0:R.classList)==null||E.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},v=(w=!1)=>{const k=a.current;if(!k)return;const C=k.target;m(),a.current=null,f(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}w&&C&&C!==t&&s(t,C)},S=(w,k)=>{var I,K,Y,z,Z,G,Q,B;const C=a.current;if(!C)return;C.x=w,C.y=k;const R=(K=(I=document.elementFromPoint(w,k))==null?void 0:I.closest)==null?void 0:K.call(I,"[data-deck-id][data-owner-key]"),E=(Y=R==null?void 0:R.dataset)==null?void 0:Y.deckId,F=((z=R==null?void 0:R.dataset)==null?void 0:z.ownerKey)===e&&E&&E!==t;C.over!==(F?R:null)&&((G=(Z=C.over)==null?void 0:Z.classList)==null||G.remove("nc-deck-over"),C.over=F?R:null,(B=(Q=C.over)==null?void 0:Q.classList)==null||B.add("nc-deck-over")),C.target=F?E:null},y=()=>{var C,R;const w=a.current;if(!w){u.current=0;return}const k=(R=(C=w.container)==null?void 0:C.getBoundingClientRect)==null?void 0:R.call(C);if(k){const E=w.x<k.left+Zv?-e_:w.x>k.right-Zv?e_:0;E&&(w.container.scrollLeft+=E,S(w.x,w.y))}u.current=requestAnimationFrame(y)};N.useEffect(()=>{const w=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),v(!1))},k=()=>v(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",k),m(),a.current=null}},[t,e]);const b=w=>{var R;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const k=w.currentTarget.closest("[data-deck-id][data-owner-key]"),C=w.currentTarget.closest(".nc-deckbar");a.current={pointerId:w.pointerId,handle:w.currentTarget,source:k,container:C,target:null,over:null,x:w.clientX,y:w.clientY},(R=k==null?void 0:k.classList)==null||R.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}f(!0),u.current=requestAnimationFrame(y)};return c.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:p("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{a.current&&v(!1)},children:"↔"})}function AN({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:f="idle",error:m="",sidebarVisible:v,onToggleSidebar:S}){kn();const{isCollapsed:y,toggle:b}=_N(),{dotFor:w}=PN(t),[k,C]=N.useState(null),[R,E]=N.useState(""),[F,I]=N.useState(!1),[K,Y]=N.useState(""),[z,Z]=N.useState(""),G=qv(R),Q=Br(G),B=[];for(const $ of e){const H=$.local?"local":$.ownerId;let x=B.find(O=>O.key===H);x||(x={key:H,label:$.ownerLabel||($.local?"Local":H),local:!!$.local,decks:[]},B.push(x)),x.decks.push($)}const M=async()=>{if(Q){I(!0),Y("");try{n&&await n(G,k),E(""),C(null)}catch($){Y(String($.message||$))}I(!1)}},j=$=>{Z(""),u&&u($.id)||Z($.id)},T=async $=>{if(!($.id===t||!h||F||$.available===!1)){I(!0),Y("");try{await h($.id)}catch(H){Y(String((H==null?void 0:H.message)||H))}I(!1)}},L=($,H,x)=>{const O=$.decks.findIndex(A=>A.id===H.id),D=$.decks[O+x];O>=0&&D&&a&&!F&&a(H.id,D.id)};return c.jsxs("div",{className:"nc-deckbar",children:[S&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:p("toggle-sidebar"),onClick:S,children:v?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:p("decks")}),c.jsx("div",{className:"nc-deck-chips",children:B.map($=>{const H=y($.key),x=`nc-deck-content-${$.key}`,O=$.local?"Local":$.label,D=$.decks.some(X=>X.id===t),A=($.decks.find(X=>X.id===t)||{}).name,W=p($.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",$.decks.length);return c.jsxs("span",{className:`nc-deck-owner-group${H?" collapsed":""}`,"data-owner-key":$.key,"data-collapsed":H?"1":"0",children:[c.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!H,"aria-controls":x,title:p(H?"expand-owner":"collapse-owner").replace("{owner}",O),onClick:()=>{!H&&k===$.key&&(E(""),C(null)),b($.key)},children:[c.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:H?"▸":"▾"}),c.jsx("span",{className:"nc-deck-owner",children:O})]}),H&&c.jsxs("span",{className:"nc-deck-summary",title:W,children:[c.jsx("span",{className:"nc-deck-summary-count",children:$.decks.length}),D&&c.jsxs("span",{className:"nc-deck-summary-current",children:["• ",A]})]}),c.jsxs("span",{id:x,className:"nc-deck-owner-content",hidden:H,children:[$.decks.map(X=>{const ie=w(X.id,X.available===!1);return c.jsxs("span",{"data-deck-id":X.id,"data-owner-key":$.key,className:`nc-deck-chip${X.id===t?" current":""}${X.available===!1?" offline":""}`,children:[ie&&c.jsx(TN,{state:ie}),c.jsx(LN,{ownerKey:$.key,deckId:X.id,label:`${$.label} · ${X.name}`,onMove:(ue,fe)=>{a&&!F&&a(ue,fe)},onStep:ue=>L($,X,ue)}),c.jsxs("button",{className:"nc-deck-open",title:X.available===!1?`${X.ownerLabel} offline`:X.id===t?p("deck-current"):`${X.ownerLabel} · ${X.name}`,disabled:F||X.available===!1,onClick:()=>T(X),children:[X.name,X.id===t?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:X.available===!1,title:p("detach-deck"),onClick:()=>j(X),children:"↗"}),X.name!==Un&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:X.available===!1,title:p("rename-deck"),onClick:()=>{const ue=(typeof window<"u"?window.prompt(p("rename-deck"),X.name):"")||"",fe=qv(ue);Br(fe)&&fe!==X.name&&s&&s(X.id,fe).catch(we=>Y(String(we.message||we)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:X.available===!1,title:p("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(p("delete-deck-confirm").replace("{name}",`${X.ownerLabel} · ${X.name}`)))&&o&&o(X.id).catch(ue=>Y(String(ue.message||ue)))},children:"✕"})]})]},X.id)}),k===$.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:Q||!R?"":"invalid",placeholder:p("deck-name"),value:R,onChange:X=>E(X.target.value),onKeyDown:X=>{X.key==="Enter"&&M(),X.key==="Escape"&&(E(""),C(null))}}),R&&Q&&G!==R&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",G]}),c.jsx("button",{className:"nc-deck-ok",disabled:!Q||F,onClick:M,children:p("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{E(""),C(null)},children:p("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:F||$.decks.every(X=>X.available===!1),title:`${p("new-deck")} · ${$.label}`,onClick:()=>{E(""),C($.key)},children:["+ ",p("new")]})]})]},$.key)})}),c.jsx("span",{className:`nc-deck-state ${f}`,title:p("deck-autosave"),children:p(f==="saving"?"saving":f==="saved"?"saved":"deck-autosave")}),(K||m)&&c.jsx("span",{className:"nc-deck-error",children:K||m}),z&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(z),children:p("popup-blocked")})]})}function TN({state:e}){if(!e)return null;const t=p(`dot-${e}`);return c.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var jr={},vd,t_;function DN(){return t_||(t_=1,vd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),vd}var _d={},hs={},n_;function Zs(){if(n_)return hs;n_=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return hs.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},hs.getSymbolTotalCodewords=function(s){return t[s]},hs.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},hs.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},hs.isKanjiModeEnabled=function(){return typeof e<"u"},hs.toSJIS=function(s){return e(s)},hs}var yd={},i_;function Tf(){return i_||(i_=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(yd)),yd}var wd,s_;function MN(){if(s_)return wd;s_=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},wd=e,wd}var bd,r_;function IN(){if(r_)return bd;r_=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const a=t*this.size+n;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},bd=e,bd}var Sd={},o_;function ON(){return o_||(o_=1,(function(e){const t=Zs().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let f=1;f<o-1;f++)h[f]=h[f-1]-u;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let h=0;h<u;h++)for(let f=0;f<u;f++)h===0&&f===0||h===0&&f===u-1||h===u-1&&f===0||o.push([a[h],a[f]]);return o}})(Sd)),Sd}var xd={},a_;function BN(){if(a_)return xd;a_=1;const e=Zs().getSymbolSize,t=7;return xd.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},xd}var kd={},l_;function zN(){return l_||(l_=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,h=0,f=0,m=null,v=null;for(let S=0;S<a;S++){h=f=0,m=v=null;for(let y=0;y<a;y++){let b=o.get(S,y);b===m?h++:(h>=5&&(u+=t.N1+(h-5)),m=b,h=1),b=o.get(y,S),b===v?f++:(f>=5&&(u+=t.N1+(f-5)),v=b,f=1)}h>=5&&(u+=t.N1+(h-5)),f>=5&&(u+=t.N1+(f-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let f=0;f<a-1;f++){const m=o.get(h,f)+o.get(h,f+1)+o.get(h+1,f)+o.get(h+1,f+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,f=0;for(let m=0;m<a;m++){h=f=0;for(let v=0;v<a;v++)h=h<<1&2047|o.get(m,v),v>=10&&(h===1488||h===93)&&u++,f=f<<1&2047|o.get(v,m),v>=10&&(f===1488||f===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let f=0;f<u;f++)a+=o.data[f];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function n(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const u=a.size;for(let h=0;h<u;h++)for(let f=0;f<u;f++)a.isReserved(f,h)||a.xor(f,h,n(o,f,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,f=1/0;for(let m=0;m<u;m++){a(m),e.applyMask(m,o);const v=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),v<f&&(f=v,h=m)}return h}})(kd)),kd}var Cl={},c_;function Kw(){if(c_)return Cl;c_=1;const e=Tf(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Cl.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Cl.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Cl}var Cd={},Bo={},u_;function FN(){if(u_)return Bo;u_=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Bo.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Bo.exp=function(s){return e[s]},Bo.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Bo}var d_;function $N(){return d_||(d_=1,(function(e){const t=FN();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let h=0;h<o.length;h++)a[u+h]^=t.mul(s[u],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let f=0;f<o.length;f++)a[f]^=t.mul(o[f],u);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Cd)),Cd}var Ed,h_;function HN(){if(h_)return Ed;h_=1;const e=$N();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const h=new Uint8Array(this.degree);return h.set(a,u),h}return a},Ed=t,Ed}var Nd={},jd={},Rd={},f_;function qw(){return f_||(f_=1,Rd.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Rd}var _i={},p_;function Vw(){if(p_)return _i;p_=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
81
+ `),()=>x.dispose()}R.current={term:x,fit:O,sock:qe,setKeyboardGesture:me};let Ae=null;const Rt=x.onData(pe=>{if(s){Ae&&(Ae.ok=!1);return}if(!Ae&&m&&m.current&&pe.length===1){const Ye=pe.charCodeAt(0);let Ve=Ye;Ye>=97&&Ye<=122?Ve=Ye-96:Ye>=64&&Ye<=95?Ve=Ye-64:Ye===32&&(Ve=0),pe=String.fromCharCode(Ve),m.current=!1,v&&v(!1)}const He=qe.sendInput(pe);Ae&&(Ae.seen=!0,Ae.ok=Ae.ok&&He)});u&&(u.current=pe=>qe.sendInput(pe)),f&&(f.current=pe=>qe.action(pe)),h&&(h.current=lE({isReady:()=>!s&&qe.isReady(),paste:pe=>{const He={seen:!1,ok:!0};Ae=He;try{x.paste(pe)}catch{He.ok=!1}finally{Ae=null}return He.seen&&He.ok},send:pe=>qe.sendInput(pe)}));const Vt=x.onSelectionChange(()=>{const pe=x.getSelection();pe?(z(pe),L(!1)):L(!0)});x.attachCustomKeyEventHandler(pe=>(pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="c"&&x.getSelection()?(pe.type==="keydown"&&Av(x.getSelection()),!1):!0);const Oe=C.current;let Pt=!1;const bt=async pe=>{if(!pe.length||Pt)return;if(s){B({error:p("settings-readonly")});return}Pt=!0,B({current:0,total:pe.length,name:""});const He=await fw({files:pe,token:n,session:e,node:t,paste:!0,onProgress:({index:Ye,total:Ve,name:_t,state:St,error:Ut})=>B({current:Ye+1,total:Ve,name:_t,...St==="error"?{error:Ut}:{}})});Pt=!1,He.errors.length?B({error:He.errors.map(Ye=>`${Ye.name}: ${Ye.message}`).join(" · ")}):(B({done:!0,total:He.paths.length}),setTimeout(()=>B(null),1600))},dt=pe=>{const He=pe.clipboardData;if(!ud(He))return;const Ye=Dv(He);Ye.length&&(pe.preventDefault(),pe.stopPropagation(),bt(Ye))},ht=pe=>{ud(pe.dataTransfer)&&(pe.preventDefault(),pe.stopPropagation())},Qe=pe=>{ud(pe.dataTransfer)&&(pe.preventDefault(),pe.stopPropagation(),bt(Dv(pe.dataTransfer)))};Oe.addEventListener("paste",dt,!0),Oe.addEventListener("dragenter",ht,!0),Oe.addEventListener("dragover",ht,!0),Oe.addEventListener("drop",Qe,!0);const ot=24,oe=(pe,He)=>{const Ve=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),_t=Math.floor((pe-Ve.left)/Math.max(1,Ve.width)*x.cols)+1,St=Math.floor((He-Ve.top)/Math.max(1,Ve.height)*x.rows)+1;return{col:Math.max(1,Math.min(x.cols,_t)),row:Math.max(1,Math.min(x.rows,St))}},ke=(pe,He={mode:null,remainder:0},Ye=null,Ve=null)=>{const _t=C.current,St=_t?_t.getBoundingClientRect().height:ot,Ut=EE({alternateScreen:x.buffer.active.type==="alternate",readonly:s,mouseTracking:X()}),en=Ut==="mouse"?"mouse":Ye||Ut,dc=He.mode===en?He.remainder+pe:pe,Nn=jE({mode:en,accumulated:dc,threshold:en==="page"?St:ot});for(const Gr of RE(Nn,Ve))Gr.kind==="input"?qe.sendInput(Gr.seq):qe.action(Gr.name);return{mode:en,remainder:Nn.remainder}};let Te=null,ae=null,re=null,Pe=null,q=!1,te=!1,U={mode:null,remainder:0},ue=null,de=null,ge=null,De=!1,_e=0;const Ee=()=>{ge&&clearTimeout(ge),ge=null},nt=(pe,He)=>{const Ve=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),_t=Math.max(0,Math.min(x.cols-1,Math.floor((pe-Ve.left)/Math.max(1,Ve.width)*x.cols))),St=Math.max(0,Math.min(x.rows-1,Math.floor((He-Ve.top)/Math.max(1,Ve.height)*x.rows)));return{col:_t,row:x.buffer.active.viewportY+St}},at=2,Je=pe=>{const Ye=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect();return Math.max(0,Math.min(x.rows-1,Math.floor((pe-Ye.top)/Math.max(1,Ye.height)*x.rows)))<at?at:-at},Mt=(pe,He)=>{const _t=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect().height/Math.max(1,x.rows);return nt(pe.clientX,pe.clientY+He*_t)},ct=pe=>{const Ye=(Oe.querySelector(".xterm-screen")||Oe).getBoundingClientRect(),Ve=Oe.getBoundingClientRect(),_t=Ye.width/Math.max(1,x.cols),St=Ye.height/Math.max(1,x.rows),Ut=Number(x.buffer.active.viewportY)||0,en=Math.max(0,Math.min(x.rows-1,pe.row-Ut));j({left:`${Ye.left-Ve.left+pe.col*_t}px`,top:`${Ye.top-Ve.top+en*St}px`,width:`${_t}px`,height:`${St}px`})},et=pe=>{if(Ee(),De=!1,q=!1,te||pe.touches.length!==1){te=!0,q=!0,fe=null,j(null),_e=0,Te=null,ae=null,re=null,Pe=null;return}if(I.current){pe.preventDefault(),pe.stopPropagation(),_e=Je(pe.touches[0].clientY),de=Mt(pe.touches[0],_e),x.clearSelection(),ct(de);return}Te=pe.touches[0].clientY,ae=pe.touches[0].clientX,re=ae,Pe=Te,U={mode:null,remainder:0},ue=null;const He={x:ae,y:Te};ge=setTimeout(()=>{var Ut;ge=null,De=!0,q=!0,fe=null,I.current=!0,w==null||w(!0),de=nt(He.x,He.y),_e=Je(He.y);const Ye=Mt({clientX:He.x,clientY:He.y},_e);x.clearSelection();const Ve=de.row*x.cols+de.col,_t=Ye.row*x.cols+Ye.col,St=Ve<=_t?de:Ye;x.select(St.col,St.row,Math.abs(_t-Ve)+1),ct(Ye);try{(Ut=navigator.vibrate)==null||Ut.call(navigator,10)}catch{}Te=null,ae=null,ue=null,U={mode:null,remainder:0}},dE)},Zt=pe=>{if(De&&de&&pe.touches.length===1){pe.preventDefault(),pe.stopPropagation();const Ve=Mt(pe.touches[0],_e),_t=de.row*x.cols+de.col,St=Ve.row*x.cols+Ve.col,Ut=_t<=St?de:Ve;x.select(Ut.col,Ut.row,Math.abs(St-_t)+1),ct(Ve);return}if(I.current&&de&&pe.touches.length===1){pe.preventDefault(),pe.stopPropagation();const Ve=Mt(pe.touches[0],_e),_t=de.row*x.cols+de.col,St=Ve.row*x.cols+Ve.col,Ut=_t<=St?de:Ve;x.select(Ut.col,Ut.row,Math.abs(St-_t)+1),ct(Ve);return}if(Te===null||pe.touches.length!==1)return;pe.preventDefault(),pe.stopPropagation();const He=pe.touches[0];if(hE(re,Pe,He.clientX,He.clientY)&&(q=!0,fe=null,ge&&Ee()),ue===null&&(Math.abs(He.clientY-Te)>8||Math.abs(He.clientX-ae)>8)&&(ue=Math.abs(He.clientY-Te)>Math.abs(He.clientX-ae)),!ue)return;const Ye=He.clientY-Te;Te=He.clientY,U=ke(Ye,U,"scroll",oe(He.clientX,He.clientY))},ni=()=>{Ee(),Te=null,ae=null,re=null,Pe=null,de=null,De=!1,q=!1,te=!1,_e=0,j(null),U={mode:null,remainder:0}},Wn=pe=>{if(te){fe=null,Ee(),(!pe.touches||pe.touches.length===0)&&ni();return}const He=pe.changedTouches&&pe.changedTouches[0];if(!q&&!De&&!I.current&&He){const Ye={at:Date.now(),x:He.clientX,y:He.clientY},Ve=yE(K.current,fe,Ye);fe=Ve.next,Ve.open&&xe()}ni()},ui=()=>{fe=null,ni()};let he={mode:null,remainder:0};const je=pe=>{pe.preventDefault(),pe.stopPropagation(),he=ke(-pe.deltaY,he,"scroll",oe(pe.clientX,pe.clientY))};Oe.addEventListener("touchstart",et,{passive:!1}),Oe.addEventListener("touchmove",Zt,{passive:!1,capture:!0}),Oe.addEventListener("touchend",Wn,{passive:!0}),Oe.addEventListener("touchcancel",ui,{passive:!0});const Ke=()=>{!I.current&&K.current==="double-tap"&&xe()};Oe.addEventListener("dblclick",Ke);const pt=pe=>{(I.current||De)&&(pe.preventDefault(),pe.stopPropagation())};Oe.addEventListener("contextmenu",pt,!0),Oe.addEventListener("wheel",je,{passive:!1,capture:!0});let vt=null;const bs=pe=>{cE(pe)&&(pe.preventDefault(),pe.stopPropagation(),vt=nt(pe.clientX,pe.clientY),x.clearSelection())},Ui=pe=>{var St;if(!vt){(St=x.hasSelection)!=null&&St.call(x)&&X()&&(pe.preventDefault(),pe.stopPropagation());return}pe.preventDefault(),pe.stopPropagation();const He=nt(pe.clientX,pe.clientY),Ye=vt.row*x.cols+vt.col,Ve=He.row*x.cols+He.col,_t=Ye<=Ve?vt:He;x.select(_t.col,_t.row,Math.abs(Ve-Ye)+1)},Ss=pe=>{vt&&(pe.stopPropagation(),vt=null)};Oe.addEventListener("mousedown",bs,!0),Oe.addEventListener("mousemove",Ui,!0),Oe.addEventListener("mouseup",Ss,!0);const xs=pe=>{!uE(pe)||!(R.current&&R.current.term&&R.current.term.getSelection())||(pe.preventDefault(),pe.stopPropagation(),H.current&&H.current())};Oe.addEventListener("keydown",xs,!0);const di=()=>{O.fit(),qe.resize(x.cols,x.rows)};window.addEventListener("resize",di);const Kn=window.visualViewport;let Kr=Kn&&Number(Kn.height);const la=()=>{const pe=Kn&&Number(Kn.height);ce&&K.current==="double-tap"&&Number.isFinite(Kr)&&Number.isFinite(pe)&&pe>Kr+80&&we(),Kr=pe,di()};Kn&&(Kn.addEventListener("resize",la),Kn.addEventListener("scroll",di));const zt=typeof navigator<"u"?navigator.virtualKeyboard:null,qr=()=>{var pe;ce&&K.current==="double-tap"&&Number(((pe=zt==null?void 0:zt.boundingRect)==null?void 0:pe.height)||0)===0&&we()};(Et=zt==null?void 0:zt.addEventListener)==null||Et.call(zt,"geometrychange",qr);let ks=null,Cs=0;return typeof ResizeObserver<"u"&&(ks=new ResizeObserver(()=>{Cs&&cancelAnimationFrame(Cs),Cs=requestAnimationFrame(di)}),ks.observe(Oe)),()=>{var pe;R.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),f&&(f.current=()=>!1),Rt.dispose(),Vt.dispose(),Oe.removeEventListener("touchstart",et),Oe.removeEventListener("touchmove",Zt,{capture:!0}),Oe.removeEventListener("touchend",Wn),Oe.removeEventListener("touchcancel",ui),Oe.removeEventListener("dblclick",Ke),Oe.removeEventListener("contextmenu",pt,!0),Ee(),Oe.removeEventListener("wheel",je,{capture:!0}),Oe.removeEventListener("mousedown",bs,!0),Oe.removeEventListener("mousemove",Ui,!0),Oe.removeEventListener("mouseup",Ss,!0),Oe.removeEventListener("keydown",xs,!0),Oe.removeEventListener("paste",dt,!0),Oe.removeEventListener("dragenter",ht,!0),Oe.removeEventListener("dragover",ht,!0),Oe.removeEventListener("drop",Qe,!0),window.removeEventListener("resize",di),Kn&&(Kn.removeEventListener("resize",la),Kn.removeEventListener("scroll",di)),(pe=zt==null?void 0:zt.removeEventListener)==null||pe.call(zt,"geometrychange",qr),$e==null||$e.removeEventListener("blur",ft),ks&&ks.disconnect(),Cs&&cancelAnimationFrame(Cs),qe.close(),x.dispose()}},[e,t,n,s,o,u,h,f,m,v,S]),c.jsxs("div",{className:`nc-terminal${b?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:C}),M&&c.jsx("div",{className:"nc-touch-selection-caret",style:M,"aria-hidden":"true"}),Q&&c.jsx("div",{className:`nc-upload-state${Q.error?" error":""}`,role:"status",children:Q.error?Q.error:Q.done?p("attach-uploaded").replace("{n}",String(Q.total||0)):p("attach-upload-progress").replace("{n}",String(Q.current||0)).replace("{total}",String(Q.total||0))}),(Y||b)&&c.jsxs("div",{className:"nc-selection-tools",children:[Y?c.jsx("button",{type:"button",onClick:$,children:Z||p("copy")}):c.jsx("span",{children:p("select-drag")}),Y&&T&&c.jsx("span",{className:"nc-selection-held",children:p("selection-held")}),c.jsx("button",{type:"button",onClick:()=>{var x,O;(O=(x=R.current)==null?void 0:x.term)==null||O.clearSelection(),z(""),L(!1),w==null||w(!1)},children:p("cancel")}),Z===p("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:Y,onFocus:x=>x.target.select()})]})]})}const Iv="",wt="\x1B",PE=[{label:"↑",seq:wt+"[A"},{label:"↓",seq:wt+"[B"},{label:"PGUP",seq:wt+"[5~"},{label:"PGDN",seq:wt+"[6~"}],LE=new Set([wt+"[A",wt+"[B",wt+"[C",wt+"[D",wt+"[5~",wt+"[6~"]),AE=350,TE=55;function DE({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,onCellSwitcher:h,cellSwitcherOpen:f=!1,keepKeyboardClosed:m=!0,showEnter:v=!0,keybarLayout:S="full"}){const[y,b]=N.useState(!1),[w,k]=N.useState(!1),[C,R]=N.useState(!1),[E,F]=N.useState(!1),I=S==="compact"&&!E,K=N.useRef({delay:null,interval:null}),Y=N.useRef(()=>{}),z=()=>{const O=K.current;O.delay!==null&&clearTimeout(O.delay),O.interval!==null&&clearInterval(O.interval),O.delay=null,O.interval=null};Y.current=z,N.useEffect(()=>{const O=()=>{document.visibilityState==="hidden"&&Y.current()},D=()=>Y.current();return window.addEventListener("blur",D),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("blur",D),document.removeEventListener("visibilitychange",O),Y.current()}},[]),N.useEffect(()=>{S!=="compact"&&F(!1)},[S]);const Z=O=>{C?(e(wt+O),R(!1)):e(O)},G=O=>{m&&Dh(),O()},Q=O=>({onPointerDown:D=>{D.preventDefault(),G(O)},onClick:D=>{D.detail===0&&G(O)}}),B=O=>({onPointerDown:D=>{D.preventDefault(),z(),G(O),!C&&(K.current.delay=setTimeout(()=>{K.current.delay=null,O(),K.current.interval=setInterval(O,TE)},AE))},onPointerUp:z,onPointerLeave:z,onPointerCancel:z,onLostPointerCapture:z,onTouchCancel:z,onClick:D=>{D.detail===0&&G(O)}}),M=(O,D,A)=>c.jsx("button",{type:"button",...LE.has(D)&&!A?B(()=>Z(D)):Q(()=>{Z(D),A&&A()}),children:O},O),j=(O,D)=>c.jsx("button",{type:"button",...Q(()=>{t(D),k(!1)}),children:O},O),T=h?c.jsx("button",{type:"button","aria-label":p("fleet-cells"),title:p("fleet-cells"),"aria-expanded":f,...Q(h),children:"◫"},"cells"):c.jsx("button",{type:"button",...Q(()=>{o&&o()}),children:"⌨"},"kbd"),L=v&&c.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...Q(()=>Z("\r")),children:c.jsx(Ze,{name:"enter",size:24})}),$=w&&c.jsxs("div",{className:"nc-keymenu",children:[j("←WIN","prev-window"),j("WIN→","next-window"),j("⬅PANE","pane-left"),j("PANE➡","pane-right"),M("SCROLL",Iv+"[",()=>{b(!0),k(!1)}),c.jsx("button",{type:"button",className:a?"armed":"",...Q(()=>{u==null||u(!a),k(!1)}),children:"SELECT"}),M("⌃C","",()=>k(!1)),M("DETACH",Iv+"d",()=>k(!1))]});if(y)return c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),PE.map(O=>M(O.label,O.seq)),M("ESCI (q)","q",()=>b(!1))]});if(I)return c.jsxs("div",{className:"nc-keybar termux",children:[$,c.jsxs("div",{className:`nc-keygrid compact${v?"":" no-enter"}`,children:[c.jsx("div",{className:"nc-keyrows",children:c.jsxs("div",{className:"row",children:[c.jsx("button",{type:"button","aria-label":p("keybar-expand"),title:p("expand"),...Q(()=>F(!0)),children:c.jsx(Ze,{name:"chevronUp",size:20})},"expand"),T,c.jsx("button",{type:"button",className:w?"armed":"",...Q(()=>k(O=>!O)),children:"☰"},"menu"),M("↑",wt+"[A"),M("↓",wt+"[B"),M("←",wt+"[D"),M("→",wt+"[C"),M("PGUP",wt+"[5~"),M("PGDN",wt+"[6~")]})}),L]})]});const H=S==="compact"&&E,x=H&&c.jsx("button",{type:"button",className:"nc-retract-key","aria-label":p("keybar-retract"),title:p("retract"),...Q(()=>F(!1)),children:c.jsx(Ze,{name:"chevronDown",size:20})});return c.jsxs("div",{className:`nc-keybar termux${H?" expanded":""}`,children:[$,c.jsxs("div",{className:`nc-keygrid${v?"":" no-enter"}${H?" expanded":""}`,children:[x,c.jsxs("div",{className:"nc-keyrows",children:[c.jsxs("div",{className:"row",children:[M("ESC",wt),c.jsx("button",{type:"button",className:w?"armed":"",...Q(()=>k(O=>!O)),children:"☰"},"menu"),M("/","/"),M("—","-"),M("HOME",wt+"[H"),M("↑",wt+"[A"),M("END",wt+"[F"),M("PGUP",wt+"[5~")]}),c.jsxs("div",{className:"row",children:[M("⇥"," "),T,c.jsx("button",{type:"button",className:n?"armed":"",...Q(()=>{s&&s()}),children:"CTRL"},"ctrl"),c.jsx("button",{type:"button",className:C?"armed":"",...Q(()=>R(O=>!O)),children:"ALT"},"alt"),M("←",wt+"[D"),M("↓",wt+"[B"),M("→",wt+"[C"),M("PGDN",wt+"[6~")]})]}),L]})]})}const ME=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function vw({session:e,node:t,token:n,filesEvent:s,onClose:o}){kn();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,f]=N.useState("outbox"),[m,v]=N.useState({inbox:[],outbox:[]}),[S,y]=N.useState(""),b=N.useRef(null);async function w(){try{const F=await(await Ht(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if(F.error){y(F.error);return}v(F);const I=F.outbox[0]?F.outbox[0].mtime:0;localStorage.setItem(X_(u),String(I))}catch(E){y(String(E))}}N.useEffect(()=>{w()},[e,t]),N.useEffect(()=>{s&&s.session===e&&w()},[s]);async function k(E){for(const F of E){y(`carico ${F.name}…`);const I=new FormData;I.append("session",e),I.append("file",F);try{const Y=await(await Ht(`${a}/files/upload`,n,{method:"POST",body:I})).json();y(Y.error?`errore: ${Y.error}`:"")}catch(K){y(String(K))}}w()}async function C(E){const F=await Ht(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(E)}`,n);if(!F.ok){y("errore download");return}const I=await F.blob(),K=URL.createObjectURL(I),Y=document.createElement("a");Y.href=K,Y.download=E,Y.click(),URL.revokeObjectURL(K)}async function R(E){await Ht(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(E)}`,n,{method:"DELETE"}),w()}return c.jsxs("div",{className:"nc-files",children:[c.jsxs("header",{children:[c.jsx("b",{children:t?`${t}:${e}`:e}),c.jsx("button",{onClick:o,title:p("close"),children:c.jsx(Ze,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>f("outbox"),children:"outbox"}),c.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>f("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>b.current&&b.current.click(),children:[c.jsx(Ze,{name:"upload",size:18})," ",p("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:b,style:{display:"none"},onChange:E=>{k(Array.from(E.target.files||[])),E.target.value=""}})]}),S&&c.jsx("div",{className:"nc-busy",children:S}),c.jsxs("ul",{children:[m[h].map(E=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>C(E.name),children:E.name}),c.jsx("small",{children:ME(E.size)}),c.jsx("button",{onClick:()=>R(E.name),title:p("delete"),children:c.jsx(Ze,{name:"trash",size:18})})]},E.name)),m[h].length===0&&c.jsx("li",{className:"empty",children:p("empty-files")})]})]})}const sc="nc_composer_v1",Mh="nc-composer-reset",IE=50,_w=256*1024,yw=512*1024,OE=768*1024,Ov=2*1024*1024,ww=720*60*60*1e3,Ih=1;function bw(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function bf(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Gl(){return{version:Ih,cells:{}}}function Sw(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=bw(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>_w)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=IE))break}let n=0;return t.filter(s=>n+s.text.length>OE?!1:(n+=s.text.length,!0))}function Xl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=yw?e.draft:"",n=Sw(e.history),s=bw(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function BE(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Gl()}if(!t||typeof t!="object"||t.version!==Ih||!t.cells||typeof t.cells!="object")return Gl();const n=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=Xl(o);a&&(n[s]=a)}return{version:Ih,cells:n}}function xw(e){const t=bf(e);if(!t)return Gl();try{return BE(t.getItem(sc))}catch{return Gl()}}function Bv(e){try{return JSON.stringify(e).length}catch{return 1/0}}function zE(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>ww&&delete e.cells[s]}function kw(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function FE(e,t){for(;Bv(e)>Ov;){const n=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of kw(e,t)){if(Bv(e)<=Ov)break;delete e.cells[n]}}function Cw(e,t,n){const s=bf(e);if(!s)return!1;FE(t,n);const o=()=>(s.setItem(sc,JSON.stringify(t)),!0);try{return o()}catch{for(const u of kw(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function oa(e,t,n,s){const o=xw(t);zE(o,n,e);const a=Xl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=Xl(u);return h?o.cells[e]={...h,updatedAt:n}:delete o.cells[e],{ok:Cw(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function $E({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=Mr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Oo(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=xw(t),o=Xl(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>ww?(s.cells[e]&&(delete s.cells[e],Cw(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function zv(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>yw?!1:oa(e,n,s,a=>({...a,draft:o})).ok}function Fv(e,t,n=Date.now()){return e?oa(e,t,n,s=>({...s,draft:""})).ok:!1}function HE(e,t,n,s=Date.now()){return e?oa(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function UE(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>_w?!1:oa(e,n,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:Sw(u)}}).ok}function WE(e,t,n=Date.now()){return e?oa(e,t,n,s=>({...s,history:[]})).ok:!1}function KE(e){const t=bf(e);if(!t)return!1;try{return t.removeItem(sc),!0}catch{return!1}}const qE=300;function VE(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function YE({ownerId:e,node:t,session:n,storage:s=VE()}){const o=N.useMemo(()=>$E({ownerId:e,node:t,session:n}),[e,t,n]),a=N.useMemo(()=>Oo(o,s),[]),[u,h]=N.useState(a.draft),[f,m]=N.useState(a.expanded),[v,S]=N.useState(a.history),[y,b]=N.useState(-1),w=N.useRef(o),k=N.useRef(a.draft),C=N.useRef(null),R=N.useRef(a.updatedAt||0),E=N.useRef(a.draft),F=N.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),I=N.useCallback(()=>{F(),zv(w.current,k.current,s)},[F,s]),K=N.useCallback(()=>{F(),C.current=setTimeout(()=>{C.current=null,zv(w.current,k.current,s)},qE)},[F,s]),Y=N.useCallback(T=>{const L=String(typeof T=="function"?T(k.current):T||"");k.current=L,R.current=Date.now(),E.current=L,b(-1),h(L),K()},[K]),z=N.useCallback((T,L)=>{F(),k.current=T,R.current=Date.now(),h(T),b(L),K()},[F,K]),Z=N.useCallback(()=>{if(!v.length)return!1;const T=Math.min(y+1,v.length-1);return y<0&&(E.current=k.current),z(v[T].text,T),!0},[z,v,y]),G=N.useCallback(()=>{if(y<0)return!1;const T=y-1;return z(T<0?E.current:v[T].text,T),!0},[z,v,y]),Q=N.useCallback(T=>{E.current=k.current;const L=v.findIndex($=>$.text===T);z(String(T||""),L)},[z,v]),B=N.useCallback(()=>{m(T=>{const L=!T;return HE(w.current,L,s),L})},[s]),M=N.useCallback((T,L,$)=>{if(!T)return;if(UE(T,$,s),!(w.current===T)){Oo(T,s).draft===L&&Fv(T,s);return}S(Oo(T,s).history),E.current="",b(-1),k.current===L?(F(),k.current="",R.current=Date.now(),h(""),Fv(T,s)):K()},[F,K,s]),j=N.useCallback(()=>{WE(w.current,s),S([]),b(-1),E.current=k.current},[s]);return N.useEffect(()=>{if(w.current===o)return;I(),w.current=o;const T=Oo(o,s);k.current=T.draft,R.current=T.updatedAt||0,E.current=T.draft,h(T.draft),m(T.expanded),S(T.history),b(-1)},[o,I,s]),N.useEffect(()=>{const T=()=>I(),L=()=>{document.visibilityState==="hidden"&&I()};return window.addEventListener("pagehide",T),document.addEventListener("visibilitychange",L),()=>{window.removeEventListener("pagehide",T),document.removeEventListener("visibilitychange",L),I()}},[I]),N.useEffect(()=>{const T=()=>{F(),k.current="",R.current=0,E.current="",h(""),m(!1),S([]),b(-1)},L=H=>{if(H.key!==sc)return;if(H.newValue==null){T();return}const x=Oo(w.current,s);x.updatedAt<R.current||(F(),k.current=x.draft,R.current=x.updatedAt,E.current=x.draft,h(x.draft),m(x.expanded),S(x.history),b(-1))},$=()=>T();return window.addEventListener("storage",L),window.addEventListener(Mh,$),()=>{window.removeEventListener("storage",L),window.removeEventListener(Mh,$)}},[F,s]),{cellKey:o,text:u,setText:Y,expanded:f,toggleExpanded:B,history:v,historyCursor:y,recallPrevious:Z,recallNext:G,selectHistory:Q,confirmSubmitted:M,clearHistory:j,flush:I}}function Ew({submitText:e,token:t,session:n,node:s,ownerId:o,keepKeyboardClosedOnVoice:a=!0}){kn();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:m,expanded:v,toggleExpanded:S,history:y,historyCursor:b,recallPrevious:w,recallNext:k,selectHistory:C,confirmSubmitted:R,clearHistory:E,flush:F}=YE({ownerId:o,node:s,session:n}),[I,K]=N.useState(!1),[Y,z]=N.useState(""),[Z,G]=N.useState(!1),Q=N.useRef(null),B=N.useRef(null),M=N.useRef(null),[j,T]=N.useState(!1),[L,$]=N.useState({left:0,bottom:0}),[H,x]=N.useState(!1),[O,D]=N.useState(!1),A=N.useRef(null),W=N.useRef(null),X=N.useRef(null),ie=N.useRef(null),ce=N.useRef(null),fe=N.useRef(null),we=N.useRef(null),me=N.useRef(!1),[xe,$e]=N.useState(!1),[ft,qe]=N.useState({left:0,bottom:0,width:320}),Ae=N.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);N.useEffect(()=>{let re=!1;if(s){G(!1);return}return Ht(`${u}/voice/status`,t).then(Pe=>Pe.json()).then(Pe=>{re||G(!!Pe.serverSttConfigured)}).catch(()=>{re||G(!1)}),()=>{re=!0}},[t,u]);const Vt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||Z);async function Oe(){const re=M.current&&typeof M.current.value=="string"?M.current.value:f;Dh(),re!==f&&m(re);const Pe=re,q=aE(Pe);if(!q||O)return;D(!0),z("");let te=!1;try{te=!!await e(q)}catch{te=!1}te?R(h,Pe,q):z(p("composer-send-failed")),D(!1)}function Pt(){const re=A.current&&A.current.getBoundingClientRect();re&&$({left:Math.max(6,Math.min(re.left,window.innerWidth-186)),bottom:window.innerHeight-re.top+6}),T(!0)}function bt(re){T(!1),re&&A.current&&A.current.focus()}function dt(){const re=X.current&&X.current.getBoundingClientRect();if(re){const Pe=Math.max(220,Math.min(360,window.innerWidth-12));qe({left:Math.max(6,Math.min(re.right-Pe,window.innerWidth-Pe-6)),bottom:window.innerHeight-re.top+6,width:Pe})}$e(!0)}function ht(re){$e(!1),re&&X.current&&X.current.focus()}N.useEffect(()=>{if(!j)return;const re=q=>{q.key==="Escape"&&bt(!0)},Pe=q=>{const te=W.current&&W.current.contains(q.target),U=A.current&&A.current.contains(q.target);!te&&!U&&bt(!1)};return document.addEventListener("keydown",re),document.addEventListener("pointerdown",Pe),()=>{document.removeEventListener("keydown",re),document.removeEventListener("pointerdown",Pe)}},[j]),N.useEffect(()=>{if(!xe)return;const re=q=>{q.key==="Escape"&&ht(!0)},Pe=q=>{const te=ie.current&&ie.current.contains(q.target),U=X.current&&X.current.contains(q.target);!te&&!U&&ht(!1)};return document.addEventListener("keydown",re),document.addEventListener("pointerdown",Pe),()=>{document.removeEventListener("keydown",re),document.removeEventListener("pointerdown",Pe)}},[xe]);function Qe(re){if(!(re.isComposing||me.current||re.altKey||re.ctrlKey||re.metaKey)){if(re.key==="ArrowUp"&&re.currentTarget.selectionStart===0&&re.currentTarget.selectionEnd===0){w()&&re.preventDefault();return}re.key==="ArrowDown"&&b>=0&&re.currentTarget.selectionStart===f.length&&re.currentTarget.selectionEnd===f.length&&k()&&re.preventDefault()}}function ot(re){bt(!1),re.current&&re.current.click()}async function oe(re){if(!re.length||!n)return;x(!0),z("");const{paths:Pe,errors:q}=await fw({files:re,token:t,session:n,node:s,paste:!1});q.length&&z(q.map(te=>`${te.name}: ${te.message}`).join(" · ")),Pe.length&&m(te=>te+(te&&!te.endsWith(" ")?" ":"")+Pe.join(" ")),x(!1)}function ke(){Q.current&&Q.current.stop(),B.current&&B.current.stop(),K(!1)}async function Te(){z("");const re=window.SpeechRecognition||window.webkitSpeechRecognition;if(re){const Pe=new re;Pe.lang="it-IT",Pe.continuous=!1,Pe.interimResults=!0;const q=f?`${f} `:"";Pe.onresult=te=>{const U=Array.from(te.results).map(ue=>ue[0].transcript).join("");m(q+U)},Pe.onend=()=>K(!1),Pe.onerror=te=>{z(`voice: ${te.error||"errore"}`),K(!1)},Q.current=Pe,Pe.start(),K(!0);return}try{const Pe=await navigator.mediaDevices.getUserMedia({audio:!0}),q=new MediaRecorder(Pe),te=[];q.ondataavailable=U=>te.push(U.data),q.onstop=async()=>{Pe.getTracks().forEach(U=>U.stop()),K(!1),z("trascrivo…");try{const U=new Blob(te,{type:q.mimeType||"audio/webm"}),de=await(await Ht(`${u}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:U})).json();de.error?z(de.error):(z(""),m(ge=>ge+(ge?" ":"")+(de.text||"")))}catch(U){z(String(U))}},B.current={stop:()=>q.state!=="inactive"&&q.stop()},q.start(),K(!0)}catch{z("microfono non disponibile"),K(!1)}}function ae(){a&&Dh(),I?ke():Te()}return c.jsxs("div",{className:"nc-composer",children:[Y&&c.jsx("div",{className:"nc-composer-err",children:Y}),c.jsxs("div",{className:"nc-composer-row",children:[n&&c.jsx("button",{ref:A,className:H?"attach busy":"attach",disabled:H,onClick:()=>j?bt(!1):Pt(),title:p(H?"attach-uploading":"attach"),"aria-label":p("attach"),"aria-haspopup":"menu","aria-expanded":j,"aria-controls":Ae.current,children:c.jsx(Ze,{name:"attach",size:22})}),j&&c.jsxs("div",{ref:W,id:Ae.current,role:"menu",className:"nc-attach-menu",style:{left:L.left,bottom:L.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>ot(ce),children:[c.jsx(Ze,{name:"file",size:18})," ",p("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>ot(fe),children:[c.jsx(Ze,{name:"camera",size:18})," ",p("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>ot(we),children:[c.jsx(Ze,{name:"image",size:18})," ",p("attach-gallery")]})]}),c.jsx("button",{ref:X,type:"button",className:"history",onPointerDown:re=>re.preventDefault(),onClick:()=>xe?ht(!1):dt(),title:p("composer-history-tools"),"aria-label":p("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":xe,children:c.jsx(Ze,{name:"history",size:21})}),xe&&c.jsxs("div",{ref:ie,role:"menu",className:"nc-composer-history-menu",style:{left:ft.left,bottom:ft.bottom,width:ft.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:re=>re.preventDefault(),onClick:()=>{S(),ht(!1)},children:[c.jsx(Ze,{name:v?"chevronDown":"chevronUp",size:18}),p(v?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:p("composer-history")}),y.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:p("composer-history-empty")}),y.map((re,Pe)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:q=>q.preventDefault(),onClick:()=>{C(re.text),ht(!1)},children:[c.jsx("span",{children:re.text.replace(/\s+/g," ").slice(0,180)}),re.at>0&&c.jsx("small",{children:new Date(re.at).toLocaleString()})]},`${re.at}:${Pe}`)),y.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:re=>re.preventDefault(),onClick:()=>{E(),ht(!1)},children:p("composer-history-clear")})]}),c.jsx("input",{ref:ce,type:"file",multiple:!0,hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("input",{ref:fe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("input",{ref:we,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:re=>{oe(Array.from(re.target.files||[])),re.target.value=""}}),c.jsx("textarea",{ref:M,className:v?"expanded":"",rows:v?8:2,value:f,placeholder:p("composer-placeholder"),onChange:re=>m(re.target.value),onKeyDown:Qe,onCompositionStart:()=>{me.current=!0},onCompositionEnd:()=>{me.current=!1},onBlur:F}),Vt&&c.jsx("button",{type:"button",className:I?"mic on":"mic",title:p("voice"),"aria-label":p("voice"),onPointerDown:re=>{re.preventDefault(),ae()},onClick:re=>{re.detail===0&&ae()},children:c.jsx(Ze,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:re=>re.preventDefault(),onClick:Oe,title:p("send"),children:c.jsx(Ze,{name:"enter",size:22})})]})]})}function dd(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const GE=180,XE=480,Nr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function QE({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:f,onKill:m,onVisibility:v,onNew:S,onNodeRename:y,onSettings:b,onBootError:w,localNodeId:k,fleetCapabilities:C=[],bootSettlement:R=null,onBootSettlementApplied:E,onOpenVlSession:F,width:I=240,collapsed:K=!1,onResize:Y,onToggleCollapse:z}){const[Z,G]=kn(),{pins:Q,orders:B,togglePin:M,viewFor:j,updateView:T,canMoveRoster:L,moveRoster:$,stepRoster:H}=rf(),{groupsFor:x,moveNode:O,stepNode:D,nodeKey:A}=py(),W=new Set((t||[]).map(q=>q.tmuxSession)),X=new Map((e||[]).map(q=>[q.name,q])),ie=(q,te)=>vx(Q,q,te),ce=_x,fe=[...t||[]].sort((q,te)=>ce(ie(q.tmuxSession,(X.get(q.tmuxSession)||{}).activity),ie(te.tmuxSession,(X.get(te.tmuxSession)||{}).activity))),we=(e||[]).filter(q=>!W.has(q.name)).sort((q,te)=>ce(ie(q.name,q.activity),ie(te.name,te.activity))||q.name.localeCompare(te.name)),me=new Set(n||[]),xe=af(fe,we,X),$e=gs(xe,Q,j("local").filter,Fi(B,"local")),qe=x(s||[]).map(q=>{const te=(q.route&&q.route.length?q.route:[q.name]).join("/"),U=j(te);if(q.kind==="vl")return{g:q,nodeRoute:te,groupView:U,rawItems:[],items:[]};const{rawItems:ue}=Fl(q),de=gs(ue,Q,U.filter,Fi(B,te));return{g:q,nodeRoute:te,groupView:U,rawItems:ue,items:de}}),Ae=(q,te,U)=>o&&o({session:q,...te?{node:te}:{},...Mr.test(String(U||""))?{ownerId:U}:{}}),Rt=async q=>{if(!(q!=null&&q.direct)||!y)return;const te=window.prompt(p("rename-node-prompt"),q.label||q.name);if(te!==null)try{await y(q,te)||window.alert(p("rename-node-invalid"))}catch(U){window.alert(String((U==null?void 0:U.message)||U))}},[Vt,Oe]=N.useState({}),[Pt,bt]=N.useState(new Set);N.useEffect(()=>{const q=new Map;for(const te of t||[])q.set(Nr(te.cell),!!te.boot);for(const te of s||[]){const U=te.route||[te.name];for(const ue of te.cells||[])q.set(Nr(ue.cell,U),!!ue.boot)}Oe(te=>{let U=!1;const ue={...te};for(const[de,ge]of Object.entries(te))q.has(de)&&q.get(de)===ge&&(delete ue[de],U=!0);return U?ue:te})},[t,s]),N.useEffect(()=>{if(!(R!=null&&R.cell))return;const q=Array.isArray(R.route)?R.route:[],te=Nr(R.cell,q);Oe(U=>({...U,[te]:!!R.enabled})),E&&E(R.id)},[R,E]);const dt=(q,te=[])=>{const U=Nr(q.cell,te);return Object.prototype.hasOwnProperty.call(Vt,U)?Vt[U]:!!q.boot},ht=async(q,te,U=[])=>{if(q.stopPropagation(),!h)return;const ue=Nr(te.cell,U),de=!dt(te,U);Oe(ge=>({...ge,[ue]:de})),bt(ge=>new Set(ge).add(ue));try{await h(te.cell,de,U)}catch(ge){Oe(De=>{const _e={...De};return delete _e[ue],_e}),w&&w(ge)}finally{bt(ge=>{const De=new Set(ge);return De.delete(ue),De})}},Qe=(q,te=[])=>{const U=Nr(q.cell,te),ue=dt(q,te),de=`${p(ue?"boot-disable":"boot-enable")} ${q.cell}`;return c.jsx("button",{className:`nc-boot${ue?" on":""}`,disabled:Pt.has(U),onClick:ge=>ht(ge,q,te),title:de,"aria-label":de,children:c.jsx(Ze,{name:"boot",size:14})})},[ot,oe]=N.useState(null),ke=(q,te)=>{const U=q.currentTarget.getBoundingClientRect();oe({text:te,y:U.top+U.height/2})},Te=()=>oe(null),ae=N.useRef(null);N.useEffect(()=>()=>{ae.current&&ae.current()},[]);function re(q){q.preventDefault(),q.stopPropagation();const te=q.clientX,U=I,ue=ge=>{const De=Math.max(GE,Math.min(XE,U+(ge.clientX-te)));Y&&Y(De)},de=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",de),window.removeEventListener("pointercancel",de),window.removeEventListener("blur",de),ae.current=null};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",de),window.addEventListener("pointercancel",de),window.addEventListener("blur",de),ae.current=de}const Pe=K?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return K?c.jsxs("aside",{className:"nc-sidebar mini",style:Pe,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:p("settings"),onMouseEnter:q=>ke(q,p("settings")),onMouseLeave:Te,children:c.jsx(Ze,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[j("local").open&&$e.map(q=>q.type==="cell"?(()=>{const te=q.value,U=te.degraded?"warn":te.tmux?"on":"",ue=!!te.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${me.has(te.tmuxSession)?" active":""}`,onMouseEnter:de=>ke(de,`${te.cell}: ${q.subtitle}`),onMouseLeave:Te,draggable:ue,onDragStart:ue?de=>de.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:ue?()=>a&&a(te.tmuxSession):()=>u&&u(te),onDoubleClick:ue?()=>Ae(te.tmuxSession,"",k):void 0,children:c.jsx("span",{className:`nc-dot ${U}${q.working?" working":""}`})},q.key)})():(()=>{const te=q.value;return c.jsx("button",{type:"button",className:`nc-mini-init${me.has(te.name)?" active":""}`,onMouseEnter:U=>ke(U,te.name),onMouseLeave:Te,draggable:!0,onDragStart:U=>U.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Ae(te.name,"",k),children:dd(te.name)},q.key)})()),qe.flatMap(({g:q,nodeRoute:te,groupView:U,items:ue})=>q.kind==="vl"?q.status==="up"&&q.sessions.length?q.sessions.map(de=>c.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:ge=>ke(ge,`${q.label||te}: ${de.name}`),onMouseLeave:Te,onClick:()=>F&&F(q.peer),children:dd(de.name)},de.key)):[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:de=>ke(de,`${q.label||q.name}: ${q.status==="up"?p("no-sessions-short"):Bi(q)}`),onMouseLeave:Te,children:c.jsx("span",{className:`nc-dot${q.status==="up"?" on":" warn"}`})},`nodo-vl-${te}-${q.name}`)]:q.status==="up"?U.open?ue.map(de=>de.type==="cell"?(()=>{const ge=de.value,De=!!ge.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${me.has(de.key)?" active":""}`,onMouseEnter:_e=>ke(_e,`${q.label||te}: ${ge.cell} · ${de.subtitle}`),onMouseLeave:Te,draggable:De,onDragStart:De?_e=>_e.dataTransfer.setData("text/nc-session",de.key):void 0,onClick:De?()=>a&&a(de.key):()=>u&&u({...ge,route:q.route,availableEngines:q.engines||[]}),onDoubleClick:De?()=>Ae(ge.tmuxSession,te,q.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${ge.degraded?"warn":De?`on${de.working?" working":""}`:""}`})},de.key)})():(()=>{const ge=de.value;return c.jsx("button",{type:"button",className:`nc-mini-init${me.has(de.key)?" active":""}`,onMouseEnter:De=>ke(De,`${q.label||te}: ${ge.name}`),onMouseLeave:Te,draggable:!0,onDragStart:De=>De.dataTransfer.setData("text/nc-session",de.key),onClick:()=>a&&a(de.key),onDoubleClick:()=>Ae(ge.name,te,q.instanceId),children:dd(ge.name)},de.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:de=>ke(de,`${q.label||(q.route||[q.name]).join(" › ")}: ${Bi(q)}`),onMouseLeave:Te,children:c.jsx("span",{className:`nc-dot${q.status==="passive"?"":" warn"}`})},`nodo-${(q.route||[q.name]).join("/")}`)])]})}),ot&&c.jsx("div",{className:"nc-mini-tip",style:{top:ot.y},children:ot.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:Pe,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:p("fleet")}),c.jsxs("button",{className:"nc-new-btn",onClick:S,title:p("fleet-new-cell"),children:["+ ",p("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:p("settings"),children:[c.jsx(Ze,{name:"gear",size:15})," ",p("settings")]}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(JE,{label:p("position-local"),count:$e.length,state:j("local"),onToggle:()=>T("local",{open:!j("local").open}),onFilter:q=>T("local",{filter:q})}),j("local").open&&c.jsxs("div",{className:"nc-side-group",children:[$e.map(q=>q.type==="cell"?(()=>{const te=q.value,U=te.degraded?"warn":te.tmux?"on":"",ue=te.degraded?p("cell-degraded"):q.working?q.subtitle:te.tmux?p("cell-idle"):p("cell-off"),de=!!te.tmux;return c.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-cell${de?" live":""}${me.has(te.tmuxSession)?" active":""}`,title:`${te.cell} · ${q.subtitle}${ue===q.subtitle?"":` · ${ue}`}`,"aria-label":`${te.cell}, ${q.subtitle}${ue===q.subtitle?"":`, ${ue}`}`,draggable:de,onDragStart:de?ge=>ge.dataTransfer.setData("text/nc-session",te.tmuxSession):void 0,onClick:de?()=>a&&a(te.tmuxSession):void 0,onDoubleClick:de?()=>Ae(te.tmuxSession,"",k):void 0,children:[c.jsx(bi,{position:"local",itemKey:q.key,label:te.cell,canMove:L,onMove:(ge,De)=>$("local",ge,De,xe),onStep:ge=>H("local",q.key,ge,xe)}),c.jsx("span",{className:`nc-dot ${U}${q.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:te.cell,children:te.cell}),c.jsx("small",{title:q.subtitle,children:q.subtitle})]}),c.jsx("button",{className:`nc-pin${Q.includes(q.key)?" on":""}`,title:p("pin"),onClick:ge=>{ge.stopPropagation(),M(q.key)},children:Q.includes(q.key)?"★":"☆"}),h&&C.includes("boot")&&Qe(te),c.jsx("button",{className:`nc-power${te.tmux?" on":""}${te.degraded?" warn":""}`,onClick:ge=>{ge.stopPropagation(),u&&u({...te,boot:dt(te)})},title:te.active?p("power-off"):p("power-on"),children:c.jsx(Ze,{name:"power",size:14})})]},q.key)})():(()=>{var U;const te=q.value;return c.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-side-card${me.has(te.name)?" active":""}`,draggable:!0,onDragStart:ue=>ue.dataTransfer.setData("text/nc-session",te.name),onClick:()=>a&&a(te.name),onDoubleClick:()=>Ae(te.name,"",k),children:[c.jsx(bi,{position:"local",itemKey:q.key,label:te.name,canMove:L,onMove:(ue,de)=>$("local",ue,de,xe),onStep:ue=>H("local",q.key,ue,xe)}),c.jsx("span",{className:te.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:te.name}),c.jsxs("small",{children:[te.preview||te.cmd||p("windows").replace("{n}",String(te.windows||0)),((U=te.outbox)==null?void 0:U.count)>0?` · 📦${te.outbox.count}`:""]})]}),te.activity?c.jsx("span",{className:"nc-rel",children:Dr(te.activity)}):null,c.jsx("button",{className:`nc-pin${Q.includes(q.key)?" on":""}`,title:p("pin"),onClick:ue=>{ue.stopPropagation(),M(q.key)},children:Q.includes(q.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${te.technical?" on":""}`,title:te.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${te.technical?p("mark-normal"):p("mark-technical")} ${te.name}`,onClick:ue=>{ue.stopPropagation(),v&&v(te.name,!te.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:ue=>{ue.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",te.name))&&m&&m(te.name)},children:"⋯"})]},q.key)})()),$e.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]}),qe.map(({g:q,nodeRoute:te,groupView:U,rawItems:ue,items:de})=>{const De=my(q.health)||(q.status==="up"?"on":q.status==="passive"?"":"warn");return q.kind==="vl"?c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":A(q),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>T(te,{open:!U.open}),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),T(te,{open:!U.open}))},children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:A(q),label:q.label||q.name,onMove:(_e,Ee)=>O(_e,Ee,s||[]),onStep:_e=>D(A(q),_e,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:U.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${De}`,title:q.health?qo(q.health):""}),c.jsx("b",{children:q.label||q.name}),c.jsxs("small",{children:[" · ",q.status==="up"?p("node-sessions").replace("{n}",String(q.sessions.length)):Bi(q)]})]}),q.status==="up"&&U.open&&c.jsxs("div",{className:"nc-side-group",children:[q.sessions.map(_e=>c.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>F&&F(q.peer),onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),F&&F(q.peer))},children:[c.jsx("span",{className:"nc-dot on"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:_e.name}),c.jsx("small",{children:p("vl-events-title")})]})]},_e.key)),q.sessions.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-vl-${te}-${q.name}`):c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":A(q),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:q.direct&&y?_e=>{_e.preventDefault(),Rt(q)}:void 0,onClick:()=>T(te,{open:!U.open}),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),T(te,{open:!U.open}))},children:[c.jsx(bi,{scope:"node",position:"nodes",itemKey:A(q),label:q.label||q.name,onMove:(_e,Ee)=>O(_e,Ee,s||[]),onStep:_e=>D(A(q),_e,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:U.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${De}`,title:q.health?qo(q.health):""}),c.jsx("b",{children:q.label||q.name}),c.jsxs("small",{children:[" · ",q.status==="up"?p("node-sessions").replace("{n}",String(de.length)):q.health&&qo(q.health)||Bi(q)]}),c.jsxs("select",{className:"nc-node-filter",value:U.filter,title:p(`view-${U.filter}`),onClick:_e=>_e.stopPropagation(),onChange:_e=>T(te,{filter:_e.target.value}),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]}),q.direct&&y&&c.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${q.label||q.name}`,onClick:_e=>{_e.stopPropagation(),Rt(q)},children:"✎"}),q.direct&&q.health&&q.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${q.tunnelStatus==="up"?" on":""}`,title:q.tunnelStatus==="up"?p("power-off"):p("power-on"),onClick:_e=>{_e.stopPropagation(),f&&f(q)},children:c.jsx(Ze,{name:"power",size:14})})]}),q.status==="up"&&U.open&&c.jsxs("div",{className:"nc-side-group",children:[de.map(_e=>_e.type==="cell"?(()=>{const Ee=_e.value,nt=!!Ee.tmux,at=Ee.degraded?"warn":Ee.tmux?"on":"";return c.jsxs("div",{"data-roster-key":_e.key,"data-position":te,className:`nc-side-card nc-cell${nt?" live":""}${me.has(Ee.key)?" active":""}`,title:_e.working?_e.subtitle:Ee.tmux?p("cell-idle"):p("cell-off"),draggable:nt,onDragStart:nt?Je=>Je.dataTransfer.setData("text/nc-session",Ee.key):void 0,onClick:nt?()=>a&&a(Ee.key):void 0,onDoubleClick:nt?()=>Ae(Ee.tmuxSession,te,q.instanceId):void 0,children:[c.jsx(bi,{position:te,itemKey:_e.key,label:Ee.cell,canMove:L,onMove:(Je,Mt)=>$(te,Je,Mt,ue),onStep:Je=>H(te,_e.key,Je,ue)}),c.jsx("span",{className:`nc-dot ${at}${_e.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ee.cell}),c.jsx("small",{title:_e.subtitle,children:_e.subtitle})]}),c.jsx("button",{className:`nc-pin${Q.includes(_e.key)?" on":""}`,title:p("pin"),onClick:Je=>{Je.stopPropagation(),M(_e.key)},children:Q.includes(_e.key)?"★":"☆"}),h&&(q.capabilities||[]).includes("boot")&&Qe(Ee,q.route||[]),(q.capabilities||[]).includes(Ee.active?"down":"up")&&c.jsx("button",{className:`nc-power${Ee.active?" on":""}${Ee.degraded?" warn":""}`,onClick:Je=>{Je.stopPropagation(),u&&u({...Ee,boot:dt(Ee,q.route||[]),route:q.route,availableEngines:q.engines||[]})},title:Ee.active?p("power-off"):p("power-on"),children:c.jsx(Ze,{name:"power",size:14})})]},_e.key)})():(()=>{const Ee=_e.value;return c.jsxs("div",{"data-roster-key":_e.key,"data-position":te,className:`nc-side-card${me.has(Ee.key)?" active":""}`,draggable:!0,onDragStart:nt=>nt.dataTransfer.setData("text/nc-session",Ee.key),onClick:()=>a&&a(Ee.key),onDoubleClick:()=>Ae(Ee.name,Ee.node||te,q.instanceId),children:[c.jsx(bi,{position:te,itemKey:_e.key,label:Ee.name,canMove:L,onMove:(nt,at)=>$(te,nt,at,ue),onStep:nt=>H(te,_e.key,nt,ue)}),c.jsx("span",{className:Ee.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Ee.name}),c.jsx("small",{children:Ee.preview?Ee.preview:Ee.cmd?Ee.cmd:p("windows").replace("{n}",String(Ee.windows||0))})]}),Ee.activity?c.jsx("span",{className:"nc-rel",children:Dr(Ee.activity)}):null,c.jsx("button",{className:`nc-pin${Q.includes(_e.key)?" on":""}`,title:p("pin"),onClick:nt=>{nt.stopPropagation(),M(_e.key)},children:Q.includes(_e.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Ee.technical?" on":""}`,title:Ee.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${Ee.technical?p("mark-normal"):p("mark-technical")} ${Ee.name}`,onClick:nt=>{nt.stopPropagation(),v&&v(Ee.name,!Ee.technical,q.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:nt=>{nt.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",Ee.name))&&m&&m(Ee.name,q.route)},children:"⋯"})]},_e.key)})()),de.length===0&&c.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-${(q.route||[q.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:uy.map((q,te)=>c.jsxs("span",{children:[te>0&&" · ",c.jsx("button",{className:`nc-lang-btn${Z===q?" on":""}`,onClick:()=>G(q),title:q,children:q.toUpperCase()})]},q))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:re,title:""})]})}function JE({label:e,count:t,state:n,onToggle:s,onFilter:o}){return c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[c.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:e}),c.jsxs("small",{children:[" · ",p("node-sessions").replace("{n}",String(t))]}),c.jsxs("select",{className:"nc-node-filter",value:n.filter,title:p(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[c.jsx("option",{value:"all",children:p("view-all")}),c.jsx("option",{value:"pinned",children:p("view-pinned")}),c.jsx("option",{value:"active",children:p("view-active")}),c.jsx("option",{value:"off",children:p("view-off")}),c.jsx("option",{value:"technical",children:p("view-technical")})]})]})}function ZE(e,t,n){return!e&&t?n+1:n}const Sf="nc_input_preferences_v1",hd="nc-input-preferences",Nw=Object.freeze(["double-tap","single-tap","never"]),jw=Object.freeze(["full","compact"]),ps=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function xf(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Nw.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:ps.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:ps.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:ps.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:ps.showKeybarEnter,keybarLayout:jw.includes(t.keybarLayout)?t.keybarLayout:ps.keybarLayout}}function Rw(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function $v(e=Rw()){if(!e)return{...ps};try{return xf(JSON.parse(e.getItem(Sf)||"null"))}catch{return{...ps}}}function eN(e,t=Rw()){const n=xf(e);if(t)try{t.setItem(Sf,JSON.stringify(n))}catch{}return n}function kf(){const[e,t]=N.useState($v);N.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Sf&&o.key!==null)return;const a=o!=null&&o.detail?xf(o.detail):$v();t(a)};return window.addEventListener(hd,s),window.addEventListener("storage",s),()=>{window.removeEventListener(hd,s),window.removeEventListener("storage",s)}},[]);const n=N.useCallback(s=>{t(o=>{const a=eN({...o,...s||{}});return window.dispatchEvent(new CustomEvent(hd,{detail:a})),a})},[]);return[e,n]}function tN({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:f,onOpenSingle:m,alive:v=!0,available:S=!0,fontSize:y=ta,onZoom:b,decks:w=[],currentDeck:k,onSendToDeck:C}){const[R]=kf(),E=s||e,F=N.useRef(()=>{}),I=N.useRef(()=>!1),K=N.useRef(()=>{}),Y=N.useRef(!1),[z,Z]=N.useState(!1),[G,Q]=N.useState(!1),[B,M]=N.useState(!1),[j,T]=N.useState(null),[L,$]=N.useState(0),H=N.useRef(v),x=t?`${t}:${e}`:e,O=w.filter(D=>D.id!==k&&D.available!==!1);return N.useEffect(()=>{const D=H.current;!D&&v&&$(A=>ZE(D,v,A)),H.current=v},[v]),c.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(x),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:D=>{D.dataTransfer.setData("text/nc-session",x),D.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(x),title:t?`${E} · ${t}`:E,children:[c.jsx("span",{className:v?"nc-dot on":"nc-dot"}),c.jsx("b",{children:E})]}),c.jsxs("span",{className:"nc-tile-actions",children:[b&&c.jsx("button",{onClick:()=>b(-1),title:p("zoom-out"),children:c.jsx(Ze,{name:"zoomOut",size:14})}),b&&c.jsx("button",{onClick:()=>b(1),title:p("zoom-in"),children:c.jsx(Ze,{name:"zoomIn",size:14})}),C&&O.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:p("send-to-deck"),value:"",onMouseDown:D=>D.stopPropagation(),onChange:D=>{const A=D.target.value;A&&C(x,A),D.target.value=""},children:[c.jsx("option",{value:"",children:p("send-to-deck")}),O.map(D=>c.jsxs("option",{value:D.id,children:[D.ownerLabel," · ",D.name]},D.id))]}),c.jsx("button",{onClick:()=>Q(D=>!D),title:p("composer"),children:"⌨"}),c.jsx("button",{onClick:()=>M(D=>!D),title:p("files"),children:"📁"}),m&&c.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:n}),title:p("single-view"),children:"↗"}),f&&c.jsx("button",{className:"nc-tile-close",onClick:()=>f(x),title:p("close"),children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[S?c.jsx(gw,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:F,composerRef:I,actionRef:K,ctrlRef:Y,setCtrlArmed:Z,onFiles:T,fontSize:y,keyboardGesture:R.terminalKeyboardGesture},`${x}:${L}`):c.jsx("div",{className:"nc-tile-unavailable",children:p("deck-owner-unavailable")}),S&&B&&c.jsx("div",{className:"nc-tile-files",onMouseDown:D=>D.stopPropagation(),children:c.jsx(vw,{session:e,node:t,token:o,filesEvent:j,onClose:()=>M(!1)})})]}),S&&G&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:D=>D.stopPropagation(),children:c.jsx(Ew,{submitText:D=>I.current(D),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:R.voiceKeepsKeyboardClosed})})]})}function nN({session:e,node:t,ownerId:n,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const f of h){if(!f||(Array.isArray(f.route)?f.route:[]).join("/")!==t||n&&f.instanceId&&String(n)!==String(f.instanceId))continue;const v=(Array.isArray(f.cells)?f.cells:[]).find(S=>S&&S.tmuxSession===a);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function Cf({session:e,cell:t,node:n,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const h=nN({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const Hv=.2,Uv=.28,Pw=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),fd=e=>Pw(e,"text/nc-session"),Wv=e=>{var t;return Pw(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function iN(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<Uv?"left":s>1-Uv?"right":o<.5?"top":"bottom"}function sN({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:f=[],currentDeck:m,onSendToDeck:v,cells:S=[],nodeGroups:y=[]}){kn();const[b,w]=N.useState(null),k=N.useRef(null),C=N.useRef([]),R=N.useRef(null);function E(B,M){const j=()=>{window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("blur",j),R.current=null};window.addEventListener("pointermove",B),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("blur",j),R.current=j}N.useEffect(()=>()=>{R.current&&R.current()},[]),N.useEffect(()=>{const B=()=>w(null);return window.addEventListener("dragend",B),window.addEventListener("drop",B),()=>{window.removeEventListener("dragend",B),window.removeEventListener("drop",B)}},[]);const F=e.columns.length,I=B=>b&&b.col===B&&b.row===void 0,K=!!b&&b.col===F,Y=(B,M)=>b&&b.col===B&&b.row===M&&b.quadrant?` drop-${b.quadrant}`:"";function z(B){if(B.preventDefault(),Wv(B.dataTransfer)){w(null);return}const M=B.dataTransfer.getData("text/nc-session"),j=b;if(w(null),!M||!j)return;let T;if(j.quadrant){if(T=Lx(e,j.col,j.row,j.quadrant),!T)return}else T={col:j.col};t(ki(e).includes(M)?Ex(e,M,T):cf(e,M,T))}function Z(B,M){B.preventDefault(),B.stopPropagation();const j=B.clientX,T=e.columns[M].width,L=k.current&&k.current.clientWidth||1,$=e.columns[M+1];E(x=>{let O=Math.max(Hv,T+(x.clientX-j)/L);if($){const D=Mg(O/(O+$.width));O=D/(1-D)*$.width}t(jx(e,M,O))})}function G(B,M,j){B.preventDefault(),B.stopPropagation();const T=B.clientY,L=e.columns[M].tiles[j].height,$=C.current[M],H=$&&$.clientHeight||1,x=e.columns[M].tiles[j+1];E(D=>{let A=Math.max(Hv,L+(D.clientY-T)/H);if(x){const W=Mg(A/(A+x.height));A=W/(1-W)*x.height}t(Rx(e,M,j,A))})}function Q(B){t(Hl(e,B))}return c.jsxs("div",{className:"nc-grid",ref:k,onDragOver:B=>{if(Wv(B.dataTransfer)){B.preventDefault(),w(null);return}fd(B.dataTransfer)&&(B.preventDefault(),b&&b.col===F||w({col:F}))},onDrop:z,onDragLeave:B=>{const M=B.relatedTarget;(!M||!(k.current&&k.current.contains(M)))&&w(null)},children:[e.columns.flatMap((B,M)=>{const j=[];return j.push(c.jsx("div",{className:`nc-col${I(M)?" drop-newcol":""}`,ref:T=>{C.current[M]=T},style:{flexGrow:B.width,flexBasis:0},onDragOver:T=>{fd(T.dataTransfer)&&(T.preventDefault(),T.stopPropagation(),b&&b.col===M&&b.row===void 0||w({col:M}))},children:B.tiles.flatMap((T,L)=>{const $=[],H=$n(T),x=Cf({session:T.session,node:T.node,ownerId:T.ownerId,cells:S,nodeGroups:y});return $.push(c.jsx("div",{className:`nc-tile-slot${Y(M,L)}`,style:{flexGrow:T.height,flexBasis:0},onDragOver:O=>{if(!fd(O.dataTransfer))return;O.preventDefault(),O.stopPropagation();const D=iN(O.clientX,O.clientY,O.currentTarget.getBoundingClientRect());b&&b.col===M&&b.row===L&&b.quadrant===D||w({col:M,row:L,quadrant:D})},children:c.jsx(tN,{session:T.session,node:T.node,ownerId:T.ownerId,cellName:x,token:n,readonly:s,focused:a===H,onFocus:u,onClose:Q,onOpenSingle:h,available:T.unavailable!==!0,alive:T.unavailable!==!0&&(!o||o.has(H)),fontSize:T.fontSize,onZoom:O=>t(Px(e,M,L,O)),decks:f,currentDeck:m,onSendToDeck:v})},H)),L<B.tiles.length-1&&$.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:O=>G(O,M,L)},`h${L}`)),$})},`c${M}`)),M<F-1&&j.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:T=>Z(T,M)},`v${M}`)),j}),K&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),F===0&&c.jsx("div",{className:"nc-grid-empty",children:p("grid-empty")})]})}const Si="local",Hn=/^[a-f0-9]{16,64}$/;function Ar(e,t){return`${e&&Hn.test(e)?e:Si}:${t}`}function rc(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==Si&&!Hn.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Si?null:s,name:o}}function oc(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Ef(e){return{columns:Ys(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function rN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Hn.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(oc(n.route),n.instanceId);return t}function oN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Hn.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function Oh(e,t,n=[]){const s=Ef(e),o=rN(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&Hn.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Bh(e,t,n=[]){const s=Ef(e),o=new Map;for(const a of n)a&&Hn.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const u of a.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=oc(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function Kv(e,t,n=[]){const s=Ef(e),o=oN(n);for(const a of s.columns)for(const u of a.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=oc(o.get(u.ownerId))));return s}function Lw(e,t,n=[]){const s=ys(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Hn.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>oc(a&&a.route)===s.node);return{...s,...o&&Hn.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const aN=/^[a-z0-9-]{1,32}$/,Un="main",Aw="nc_decks",Tw="nc_deck_order_v1",Dw=24;function qv(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Br(e){return typeof e=="string"&&aN.test(e)}function lN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Br(n)?n:Un}return Un}function cN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Ar(null,Un),ownerId:null,name:Un}}if(Hn.test(s)&&Br(o))return{id:Ar(s,o),ownerId:s,name:o}}const n=lN(e);return{id:Ar(null,n),ownerId:null,name:n}}function pd(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:rc(e)||{ownerId:null,name:e},s=Br(n.name)?n.name:Un,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===Un?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function Mw(e){return e===Un?"nc_grid_v1":`nc_grid_v1__${e}`}function Iw(e){const t=[Un];if(Array.isArray(e)){for(const n of e)if(Br(n)&&n!==Un&&!t.includes(n)&&t.push(n),t.length>=Dw)break}return t}function Ur(){return typeof localStorage<"u"?localStorage:null}function uN(){const e=Ur();if(!e)return[Un];try{return Iw(JSON.parse(e.getItem(Aw)||"null"))}catch{return[Un]}}function dN(e){const t=Ur();if(t)try{t.setItem(Aw,JSON.stringify(Iw(e)))}catch{}}function aa(e){return e==="local"||Hn.test(String(e||""))}function ac(e,t){const n=rc(e);return!!n&&(n.ownerId||"local")===t}function Ei(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!aa(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&ac(a,n)))].slice(0,Dw);o.length&&(t[n]=o)}return t}function xl(e=Ur()){if(!e)return{};try{return Ei(JSON.parse(e.getItem(Tw)||"null"))}catch{return{}}}function md(e,t=Ur()){const n=Ei(e);if(t)try{t.setItem(Tw,JSON.stringify(n))}catch{}return n}function lc(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function hN(e,t,n,s,o=[]){if(!aa(t)||n===s)return Ei(e);const a=[...new Set(o.filter(S=>ac(S,t)))];if(!a.includes(n)||!a.includes(s))return Ei(e);const u=lc(e,t).filter(S=>a.includes(S)),h=[...u,...a.filter(S=>!u.includes(S))],f=h.indexOf(n),m=h.indexOf(s);h.splice(f,1);const v=h.indexOf(s);return h.splice(f<m?v+1:v,0,n),Ei({...e,[t]:h})}function fN(e,t,n,s){if(!aa(t)||!ac(s,t))return Ei(e);const o=lc(e,t);return o.includes(n)?Ei({...e,[t]:o.map(a=>a===n?s:a)}):Ei(e)}function pN(e,t,n){return aa(t)?Ei({...e,[t]:lc(e,t).filter(s=>s!==n)}):Ei(e)}function Vv(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!aa(a)||!ac(o==null?void 0:o.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(o))}const s=[];for(const[,o]of n){const a=o[0].local?"local":o[0].ownerId,u=lc(t,a),h=new Map(u.map((f,m)=>[f,m]));o.sort((f,m)=>{const v=h.has(f.id)?h.get(f.id):Number.MAX_SAFE_INTEGER,S=h.has(m.id)?h.get(m.id):Number.MAX_SAFE_INTEGER;return v-S}),s.push(...o)}return s}function zh(e){const t=Ur();if(!t)return null;try{return JSON.parse(t.getItem(Mw(e))||"null")}catch{return null}}function mN(e,t){const n=Ur();if(n)try{n.setItem(Mw(e),JSON.stringify(t))}catch{}}const Nf="nc_deckbar_collapsed_v1",Ow=64;function jf(e){return e===Si||Hn.test(String(e||""))}function Rf(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=Ow)break;if(jf(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function Bw(e,t){return jf(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function gN(e,t){const n=Rf(e);return jf(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=Ow&&delete n[Object.keys(n)[0]],n[t]=!Bw(n,t)),n}function zw(){return typeof localStorage<"u"?localStorage:null}function Yv(e=zw()){if(!e)return{};try{return Rf(JSON.parse(e.getItem(Nf)||"null"))}catch{return{}}}function vN(e,t=zw()){const n=Rf(e);if(t)try{t.setItem(Nf,JSON.stringify(n))}catch{}return n}function _N(){const[e,t]=N.useState(Yv);N.useEffect(()=>{const o=a=>{(a.key===Nf||a.key===null)&&t(Yv())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=N.useCallback(o=>Bw(e,o),[e]),s=N.useCallback(o=>{t(a=>vN(gN(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const Pf="nc_deck_presence_v1",Gv=3e4,yN=18e4,Fw=1e4,$w=32,wN=/^[A-Za-z0-9_-]{1,64}$/,bN=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),Xv="working",SN="on",xN="neutral",kN="warn";function Lf(e){return typeof e=="string"&&wN.test(e)&&!bN.has(e)}function Hw(e){return typeof e=="string"&&rc(e)!==null}function Af(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function zr(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=$w)break;Lf(s)&&(!o||typeof o!="object"||Hw(o.deckId)&&Af(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function Uw(e,t){const n=zr(e);if(!Af(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?Gv:yN,h=t-u;a.ts>=h&&a.ts<=t+Gv&&(s[o]=a)}return s}function Qv(e,t,n,s){if(!Lf(t)||!Af(s))return zr(e);const o=Uw(e,s);if(!Hw(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=$w){let a="",u=1/0;for(const[h,f]of Object.entries(o))f.ts<u&&(a=h,u=f.ts);a&&delete o[a]}return o[t]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},zr(o)}function CN(e,t){const n=zr(e);if(!Lf(t))return n;const s={...n};return delete s[t],s}function EN(e,t){const n=Uw(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?Xv:SN;s[o.deckId]!==Xv&&(s[o.deckId]=a)}return s}function Ww(){return typeof localStorage<"u"?localStorage:null}function kl(e=Ww()){if(!e)return{};try{return zr(JSON.parse(e.getItem(Pf)||"null"))}catch{return{}}}function gd(e,t=Ww()){const n=zr(e);if(t)try{t.setItem(Pf,JSON.stringify(n))}catch{}return n}const NN=Math.min(Fw,5e3);function jN(){var e,t;try{const n=(t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const RN=jN();function Jv(){const e=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,t=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:e,visible:t}}function PN(e,t=!0){const s=N.useRef(RN).current,o=N.useRef(e);o.current=e;const[a,u]=N.useState(()=>({map:{},now:Date.now()})),h=N.useCallback(()=>{u({map:kl(),now:Date.now()})},[]);N.useEffect(()=>{if(!t)return;const v=()=>{const C=Date.now(),R=Qv(kl(),s,{deckId:o.current,...Jv()},C);return gd(R),{map:R,now:C}},S=()=>u(v());S();const y=setInterval(v,Fw),b=setInterval(h,NN),w=S,k=C=>{(C.key===Pf||C.key===null)&&h()};return window.addEventListener("focus",w),window.addEventListener("blur",w),typeof document<"u"&&document.addEventListener("visibilitychange",w),window.addEventListener("storage",k),()=>{clearInterval(y),clearInterval(b),window.removeEventListener("focus",w),window.removeEventListener("blur",w),typeof document<"u"&&document.removeEventListener("visibilitychange",w),window.removeEventListener("storage",k);try{gd(CN(kl(),s))}catch{}}},[t,s,h]),N.useEffect(()=>{if(!t)return;const v=Date.now(),S=Qv(kl(),s,{deckId:e,...Jv()},v);gd(S),u({map:S,now:v})},[e,t,s]);const f=N.useMemo(()=>t?EN(a.map,a.now):{},[t,a]);return{dotFor:N.useCallback((v,S=!1)=>t?S?kN:f[v]||xN:null,[f,t]),windowId:s}}const Zv=52,e_=18;function LN({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=N.useRef(null),u=N.useRef(0),[h,f]=N.useState(!1),m=()=>{var k,C,R,E;const w=a.current;(C=(k=w==null?void 0:w.over)==null?void 0:k.classList)==null||C.remove("nc-deck-over"),(E=(R=w==null?void 0:w.source)==null?void 0:R.classList)==null||E.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},v=(w=!1)=>{const k=a.current;if(!k)return;const C=k.target;m(),a.current=null,f(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}w&&C&&C!==t&&s(t,C)},S=(w,k)=>{var I,K,Y,z,Z,G,Q,B;const C=a.current;if(!C)return;C.x=w,C.y=k;const R=(K=(I=document.elementFromPoint(w,k))==null?void 0:I.closest)==null?void 0:K.call(I,"[data-deck-id][data-owner-key]"),E=(Y=R==null?void 0:R.dataset)==null?void 0:Y.deckId,F=((z=R==null?void 0:R.dataset)==null?void 0:z.ownerKey)===e&&E&&E!==t;C.over!==(F?R:null)&&((G=(Z=C.over)==null?void 0:Z.classList)==null||G.remove("nc-deck-over"),C.over=F?R:null,(B=(Q=C.over)==null?void 0:Q.classList)==null||B.add("nc-deck-over")),C.target=F?E:null},y=()=>{var C,R;const w=a.current;if(!w){u.current=0;return}const k=(R=(C=w.container)==null?void 0:C.getBoundingClientRect)==null?void 0:R.call(C);if(k){const E=w.x<k.left+Zv?-e_:w.x>k.right-Zv?e_:0;E&&(w.container.scrollLeft+=E,S(w.x,w.y))}u.current=requestAnimationFrame(y)};N.useEffect(()=>{const w=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),v(!1))},k=()=>v(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",k),m(),a.current=null}},[t,e]);const b=w=>{var R;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const k=w.currentTarget.closest("[data-deck-id][data-owner-key]"),C=w.currentTarget.closest(".nc-deckbar");a.current={pointerId:w.pointerId,handle:w.currentTarget,source:k,container:C,target:null,over:null,x:w.clientX,y:w.clientY},(R=k==null?void 0:k.classList)==null||R.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}f(!0),u.current=requestAnimationFrame(y)};return c.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:p("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{a.current&&v(!1)},children:"↔"})}function AN({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:f="idle",error:m="",sidebarVisible:v,onToggleSidebar:S}){kn();const{isCollapsed:y,toggle:b}=_N(),{dotFor:w}=PN(t),[k,C]=N.useState(null),[R,E]=N.useState(""),[F,I]=N.useState(!1),[K,Y]=N.useState(""),[z,Z]=N.useState(""),G=qv(R),Q=Br(G),B=[];for(const $ of e){const H=$.local?"local":$.ownerId;let x=B.find(O=>O.key===H);x||(x={key:H,label:$.ownerLabel||($.local?"Local":H),local:!!$.local,decks:[]},B.push(x)),x.decks.push($)}const M=async()=>{if(Q){I(!0),Y("");try{n&&await n(G,k),E(""),C(null)}catch($){Y(String($.message||$))}I(!1)}},j=$=>{Z(""),u&&u($.id)||Z($.id)},T=async $=>{if(!($.id===t||!h||F||$.available===!1)){I(!0),Y("");try{await h($.id)}catch(H){Y(String((H==null?void 0:H.message)||H))}I(!1)}},L=($,H,x)=>{const O=$.decks.findIndex(A=>A.id===H.id),D=$.decks[O+x];O>=0&&D&&a&&!F&&a(H.id,D.id)};return c.jsxs("div",{className:"nc-deckbar",children:[S&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:p("toggle-sidebar"),onClick:S,children:v?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:p("decks")}),c.jsx("div",{className:"nc-deck-chips",children:B.map($=>{const H=y($.key),x=`nc-deck-content-${$.key}`,O=$.local?"Local":$.label,D=$.decks.some(X=>X.id===t),A=($.decks.find(X=>X.id===t)||{}).name,W=p($.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",$.decks.length);return c.jsxs("span",{className:`nc-deck-owner-group${H?" collapsed":""}`,"data-owner-key":$.key,"data-collapsed":H?"1":"0",children:[c.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!H,"aria-controls":x,title:p(H?"expand-owner":"collapse-owner").replace("{owner}",O),onClick:()=>{!H&&k===$.key&&(E(""),C(null)),b($.key)},children:[c.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:H?"▸":"▾"}),c.jsx("span",{className:"nc-deck-owner",children:O})]}),H&&c.jsxs("span",{className:"nc-deck-summary",title:W,children:[c.jsx("span",{className:"nc-deck-summary-count",children:$.decks.length}),D&&c.jsxs("span",{className:"nc-deck-summary-current",children:["• ",A]})]}),c.jsxs("span",{id:x,className:"nc-deck-owner-content",hidden:H,children:[$.decks.map(X=>{const ie=w(X.id,X.available===!1);return c.jsxs("span",{"data-deck-id":X.id,"data-owner-key":$.key,className:`nc-deck-chip${X.id===t?" current":""}${X.available===!1?" offline":""}`,children:[ie&&c.jsx(TN,{state:ie}),c.jsx(LN,{ownerKey:$.key,deckId:X.id,label:`${$.label} · ${X.name}`,onMove:(ce,fe)=>{a&&!F&&a(ce,fe)},onStep:ce=>L($,X,ce)}),c.jsxs("button",{className:"nc-deck-open",title:X.available===!1?`${X.ownerLabel} offline`:X.id===t?p("deck-current"):`${X.ownerLabel} · ${X.name}`,disabled:F||X.available===!1,onClick:()=>T(X),children:[X.name,X.id===t?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:X.available===!1,title:p("detach-deck"),onClick:()=>j(X),children:"↗"}),X.name!==Un&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:X.available===!1,title:p("rename-deck"),onClick:()=>{const ce=(typeof window<"u"?window.prompt(p("rename-deck"),X.name):"")||"",fe=qv(ce);Br(fe)&&fe!==X.name&&s&&s(X.id,fe).catch(we=>Y(String(we.message||we)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:X.available===!1,title:p("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(p("delete-deck-confirm").replace("{name}",`${X.ownerLabel} · ${X.name}`)))&&o&&o(X.id).catch(ce=>Y(String(ce.message||ce)))},children:"✕"})]})]},X.id)}),k===$.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:Q||!R?"":"invalid",placeholder:p("deck-name"),value:R,onChange:X=>E(X.target.value),onKeyDown:X=>{X.key==="Enter"&&M(),X.key==="Escape"&&(E(""),C(null))}}),R&&Q&&G!==R&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",G]}),c.jsx("button",{className:"nc-deck-ok",disabled:!Q||F,onClick:M,children:p("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{E(""),C(null)},children:p("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:F||$.decks.every(X=>X.available===!1),title:`${p("new-deck")} · ${$.label}`,onClick:()=>{E(""),C($.key)},children:["+ ",p("new")]})]})]},$.key)})}),c.jsx("span",{className:`nc-deck-state ${f}`,title:p("deck-autosave"),children:p(f==="saving"?"saving":f==="saved"?"saved":"deck-autosave")}),(K||m)&&c.jsx("span",{className:"nc-deck-error",children:K||m}),z&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(z),children:p("popup-blocked")})]})}function TN({state:e}){if(!e)return null;const t=p(`dot-${e}`);return c.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var jr={},vd,t_;function DN(){return t_||(t_=1,vd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),vd}var _d={},hs={},n_;function Zs(){if(n_)return hs;n_=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return hs.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},hs.getSymbolTotalCodewords=function(s){return t[s]},hs.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},hs.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},hs.isKanjiModeEnabled=function(){return typeof e<"u"},hs.toSJIS=function(s){return e(s)},hs}var yd={},i_;function Tf(){return i_||(i_=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(yd)),yd}var wd,s_;function MN(){if(s_)return wd;s_=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},wd=e,wd}var bd,r_;function IN(){if(r_)return bd;r_=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const a=t*this.size+n;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},bd=e,bd}var Sd={},o_;function ON(){return o_||(o_=1,(function(e){const t=Zs().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let f=1;f<o-1;f++)h[f]=h[f-1]-u;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let h=0;h<u;h++)for(let f=0;f<u;f++)h===0&&f===0||h===0&&f===u-1||h===u-1&&f===0||o.push([a[h],a[f]]);return o}})(Sd)),Sd}var xd={},a_;function BN(){if(a_)return xd;a_=1;const e=Zs().getSymbolSize,t=7;return xd.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},xd}var kd={},l_;function zN(){return l_||(l_=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,h=0,f=0,m=null,v=null;for(let S=0;S<a;S++){h=f=0,m=v=null;for(let y=0;y<a;y++){let b=o.get(S,y);b===m?h++:(h>=5&&(u+=t.N1+(h-5)),m=b,h=1),b=o.get(y,S),b===v?f++:(f>=5&&(u+=t.N1+(f-5)),v=b,f=1)}h>=5&&(u+=t.N1+(h-5)),f>=5&&(u+=t.N1+(f-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let f=0;f<a-1;f++){const m=o.get(h,f)+o.get(h,f+1)+o.get(h+1,f)+o.get(h+1,f+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,f=0;for(let m=0;m<a;m++){h=f=0;for(let v=0;v<a;v++)h=h<<1&2047|o.get(m,v),v>=10&&(h===1488||h===93)&&u++,f=f<<1&2047|o.get(v,m),v>=10&&(f===1488||f===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let f=0;f<u;f++)a+=o.data[f];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function n(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const u=a.size;for(let h=0;h<u;h++)for(let f=0;f<u;f++)a.isReserved(f,h)||a.xor(f,h,n(o,f,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,f=1/0;for(let m=0;m<u;m++){a(m),e.applyMask(m,o);const v=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),v<f&&(f=v,h=m)}return h}})(kd)),kd}var Cl={},c_;function Kw(){if(c_)return Cl;c_=1;const e=Tf(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Cl.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Cl.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Cl}var Cd={},Bo={},u_;function FN(){if(u_)return Bo;u_=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Bo.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Bo.exp=function(s){return e[s]},Bo.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Bo}var d_;function $N(){return d_||(d_=1,(function(e){const t=FN();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let h=0;h<o.length;h++)a[u+h]^=t.mul(s[u],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let f=0;f<o.length;f++)a[f]^=t.mul(o[f],u);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Cd)),Cd}var Ed,h_;function HN(){if(h_)return Ed;h_=1;const e=$N();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const h=new Uint8Array(this.degree);return h.set(a,u),h}return a},Ed=t,Ed}var Nd={},jd={},Rd={},f_;function qw(){return f_||(f_=1,Rd.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Rd}var _i={},p_;function Vw(){if(p_)return _i;p_=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
82
82
  ]))+`;_i.KANJI=new RegExp(n,"g"),_i.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),_i.BYTE=new RegExp(s,"g"),_i.NUMERIC=new RegExp(e,"g"),_i.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return _i.testKanji=function(f){return o.test(f)},_i.testNumeric=function(f){return a.test(f)},_i.testAlphanumeric=function(f){return u.test(f)},_i}var m_;function er(){return m_||(m_=1,(function(e){const t=qw(),n=Vw();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,u){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?a.ccBits[0]:u<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return n.testNumeric(a)?e.NUMERIC:n.testAlphanumeric(a)?e.ALPHANUMERIC:n.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,u){if(e.isValid(a))return a;try{return s(a)}catch{return u}}})(jd)),jd}var g_;function UN(){return g_||(g_=1,(function(e){const t=Zs(),n=Kw(),s=Tf(),o=er(),a=qw(),u=7973,h=t.getBCHDigit(u);function f(y,b,w){for(let k=1;k<=40;k++)if(b<=e.getCapacity(k,w,y))return k}function m(y,b){return o.getCharCountIndicator(y,b)+4}function v(y,b){let w=0;return y.forEach(function(k){const C=m(k.mode,b);w+=C+k.getBitsLength()}),w}function S(y,b){for(let w=1;w<=40;w++)if(v(y,w)<=e.getCapacity(w,b,o.MIXED))return w}e.from=function(b,w){return a.isValid(b)?parseInt(b,10):w},e.getCapacity=function(b,w,k){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof k>"u"&&(k=o.BYTE);const C=t.getSymbolTotalCodewords(b),R=n.getTotalCodewordsCount(b,w),E=(C-R)*8;if(k===o.MIXED)return E;const F=E-m(k,b);switch(k){case o.NUMERIC:return Math.floor(F/10*3);case o.ALPHANUMERIC:return Math.floor(F/11*2);case o.KANJI:return Math.floor(F/13);case o.BYTE:default:return Math.floor(F/8)}},e.getBestVersionForData=function(b,w){let k;const C=s.from(w,s.M);if(Array.isArray(b)){if(b.length>1)return S(b,C);if(b.length===0)return 1;k=b[0]}else k=b;return f(k.mode,k.getLength(),C)},e.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let w=b<<12;for(;t.getBCHDigit(w)-h>=0;)w^=u<<t.getBCHDigit(w)-h;return b<<12|w}})(Nd)),Nd}var Pd={},v_;function WN(){if(v_)return Pd;v_=1;const e=Zs(),t=1335,n=21522,s=e.getBCHDigit(t);return Pd.getEncodedBits=function(a,u){const h=a.bit<<3|u;let f=h<<10;for(;e.getBCHDigit(f)-s>=0;)f^=t<<e.getBCHDigit(f)-s;return(h<<10|f)^n},Pd}var Ld={},Ad,__;function KN(){if(__)return Ad;__=1;const e=er();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,u;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),u=parseInt(a,10),s.put(u,10);const h=this.data.length-o;h>0&&(a=this.data.substr(o),u=parseInt(a,10),s.put(u,h*3+1))},Ad=t,Ad}var Td,y_;function qN(){if(y_)return Td;y_=1;const e=er(),t=["0","1","2","3","4","5","6","7","8","9","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"," ","$","%","*","+","-",".","/",":"];function n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let u=t.indexOf(this.data[a])*45;u+=t.indexOf(this.data[a+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Td=n,Td}var Dd,w_;function VN(){if(w_)return Dd;w_=1;const e=er();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},Dd=t,Dd}var Md,b_;function YN(){if(b_)return Md;b_=1;const e=er(),t=Zs();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
83
83
  Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Md=n,Md}var Id={exports:{}},S_;function GN(){return S_||(S_=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var f,m,v,S,y,b,w,k,C;!h.empty();){f=h.pop(),m=f.value,S=f.cost,y=n[m]||{};for(v in y)y.hasOwnProperty(v)&&(b=y[v],w=S+b,k=u[v],C=typeof u[v]>"u",(C||k>w)&&(u[v]=w,h.push(v,w),a[v]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var R=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(R)}return a},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],a=s;a;)o.push(a),n[a],a=n[a];return o.reverse(),o},find_path:function(n,s,o){var a=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},a;n=n||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Id)),Id.exports}var x_;function XN(){return x_||(x_=1,(function(e){const t=er(),n=KN(),s=qN(),o=VN(),a=YN(),u=Vw(),h=Zs(),f=GN();function m(R){return unescape(encodeURIComponent(R)).length}function v(R,E,F){const I=[];let K;for(;(K=R.exec(F))!==null;)I.push({data:K[0],index:K.index,mode:E,length:K[0].length});return I}function S(R){const E=v(u.NUMERIC,t.NUMERIC,R),F=v(u.ALPHANUMERIC,t.ALPHANUMERIC,R);let I,K;return h.isKanjiModeEnabled()?(I=v(u.BYTE,t.BYTE,R),K=v(u.KANJI,t.KANJI,R)):(I=v(u.BYTE_KANJI,t.BYTE,R),K=[]),E.concat(F,I,K).sort(function(z,Z){return z.index-Z.index}).map(function(z){return{data:z.data,mode:z.mode,length:z.length}})}function y(R,E){switch(E){case t.NUMERIC:return n.getBitsLength(R);case t.ALPHANUMERIC:return s.getBitsLength(R);case t.KANJI:return a.getBitsLength(R);case t.BYTE:return o.getBitsLength(R)}}function b(R){return R.reduce(function(E,F){const I=E.length-1>=0?E[E.length-1]:null;return I&&I.mode===F.mode?(E[E.length-1].data+=F.data,E):(E.push(F),E)},[])}function w(R){const E=[];for(let F=0;F<R.length;F++){const I=R[F];switch(I.mode){case t.NUMERIC:E.push([I,{data:I.data,mode:t.ALPHANUMERIC,length:I.length},{data:I.data,mode:t.BYTE,length:I.length}]);break;case t.ALPHANUMERIC:E.push([I,{data:I.data,mode:t.BYTE,length:I.length}]);break;case t.KANJI:E.push([I,{data:I.data,mode:t.BYTE,length:m(I.data)}]);break;case t.BYTE:E.push([{data:I.data,mode:t.BYTE,length:m(I.data)}])}}return E}function k(R,E){const F={},I={start:{}};let K=["start"];for(let Y=0;Y<R.length;Y++){const z=R[Y],Z=[];for(let G=0;G<z.length;G++){const Q=z[G],B=""+Y+G;Z.push(B),F[B]={node:Q,lastCount:0},I[B]={};for(let M=0;M<K.length;M++){const j=K[M];F[j]&&F[j].node.mode===Q.mode?(I[j][B]=y(F[j].lastCount+Q.length,Q.mode)-y(F[j].lastCount,Q.mode),F[j].lastCount+=Q.length):(F[j]&&(F[j].lastCount=Q.length),I[j][B]=y(Q.length,Q.mode)+4+t.getCharCountIndicator(Q.mode,E))}}K=Z}for(let Y=0;Y<K.length;Y++)I[K[Y]].end=0;return{map:I,table:F}}function C(R,E){let F;const I=t.getBestModeForData(R);if(F=t.from(E,I),F!==t.BYTE&&F.bit<I.bit)throw new Error('"'+R+'" cannot be encoded with mode '+t.toString(F)+`.
84
- Suggested mode is: `+t.toString(I));switch(F===t.KANJI&&!h.isKanjiModeEnabled()&&(F=t.BYTE),F){case t.NUMERIC:return new n(R);case t.ALPHANUMERIC:return new s(R);case t.KANJI:return new a(R);case t.BYTE:return new o(R)}}e.fromArray=function(E){return E.reduce(function(F,I){return typeof I=="string"?F.push(C(I,null)):I.data&&F.push(C(I.data,I.mode)),F},[])},e.fromString=function(E,F){const I=S(E,h.isKanjiModeEnabled()),K=w(I),Y=k(K,F),z=f.find_path(Y.map,"start","end"),Z=[];for(let G=1;G<z.length-1;G++)Z.push(Y.table[z[G]].node);return e.fromArray(b(Z))},e.rawSplit=function(E){return e.fromArray(S(E,h.isKanjiModeEnabled()))}})(Ld)),Ld}var k_;function QN(){if(k_)return _d;k_=1;const e=Zs(),t=Tf(),n=MN(),s=IN(),o=ON(),a=BN(),u=zN(),h=Kw(),f=HN(),m=UN(),v=WN(),S=er(),y=XN();function b(Y,z){const Z=Y.size,G=a.getPositions(z);for(let Q=0;Q<G.length;Q++){const B=G[Q][0],M=G[Q][1];for(let j=-1;j<=7;j++)if(!(B+j<=-1||Z<=B+j))for(let T=-1;T<=7;T++)M+T<=-1||Z<=M+T||(j>=0&&j<=6&&(T===0||T===6)||T>=0&&T<=6&&(j===0||j===6)||j>=2&&j<=4&&T>=2&&T<=4?Y.set(B+j,M+T,!0,!0):Y.set(B+j,M+T,!1,!0))}}function w(Y){const z=Y.size;for(let Z=8;Z<z-8;Z++){const G=Z%2===0;Y.set(Z,6,G,!0),Y.set(6,Z,G,!0)}}function k(Y,z){const Z=o.getPositions(z);for(let G=0;G<Z.length;G++){const Q=Z[G][0],B=Z[G][1];for(let M=-2;M<=2;M++)for(let j=-2;j<=2;j++)M===-2||M===2||j===-2||j===2||M===0&&j===0?Y.set(Q+M,B+j,!0,!0):Y.set(Q+M,B+j,!1,!0)}}function C(Y,z){const Z=Y.size,G=m.getEncodedBits(z);let Q,B,M;for(let j=0;j<18;j++)Q=Math.floor(j/3),B=j%3+Z-8-3,M=(G>>j&1)===1,Y.set(Q,B,M,!0),Y.set(B,Q,M,!0)}function R(Y,z,Z){const G=Y.size,Q=v.getEncodedBits(z,Z);let B,M;for(B=0;B<15;B++)M=(Q>>B&1)===1,B<6?Y.set(B,8,M,!0):B<8?Y.set(B+1,8,M,!0):Y.set(G-15+B,8,M,!0),B<8?Y.set(8,G-B-1,M,!0):B<9?Y.set(8,15-B-1+1,M,!0):Y.set(8,15-B-1,M,!0);Y.set(G-8,8,1,!0)}function E(Y,z){const Z=Y.size;let G=-1,Q=Z-1,B=7,M=0;for(let j=Z-1;j>0;j-=2)for(j===6&&j--;;){for(let T=0;T<2;T++)if(!Y.isReserved(Q,j-T)){let L=!1;M<z.length&&(L=(z[M]>>>B&1)===1),Y.set(Q,j-T,L),B--,B===-1&&(M++,B=7)}if(Q+=G,Q<0||Z<=Q){Q-=G,G=-G;break}}}function F(Y,z,Z){const G=new n;Z.forEach(function(T){G.put(T.mode.bit,4),G.put(T.getLength(),S.getCharCountIndicator(T.mode,Y)),T.write(G)});const Q=e.getSymbolTotalCodewords(Y),B=h.getTotalCodewordsCount(Y,z),M=(Q-B)*8;for(G.getLengthInBits()+4<=M&&G.put(0,4);G.getLengthInBits()%8!==0;)G.putBit(0);const j=(M-G.getLengthInBits())/8;for(let T=0;T<j;T++)G.put(T%2?17:236,8);return I(G,Y,z)}function I(Y,z,Z){const G=e.getSymbolTotalCodewords(z),Q=h.getTotalCodewordsCount(z,Z),B=G-Q,M=h.getBlocksCount(z,Z),j=G%M,T=M-j,L=Math.floor(G/M),$=Math.floor(B/M),H=$+1,x=L-$,O=new f(x);let D=0;const A=new Array(M),W=new Array(M);let X=0;const ie=new Uint8Array(Y.buffer);for(let xe=0;xe<M;xe++){const $e=xe<T?$:H;A[xe]=ie.slice(D,D+$e),W[xe]=O.encode(A[xe]),D+=$e,X=Math.max(X,$e)}const ue=new Uint8Array(G);let fe=0,we,me;for(we=0;we<X;we++)for(me=0;me<M;me++)we<A[me].length&&(ue[fe++]=A[me][we]);for(we=0;we<x;we++)for(me=0;me<M;me++)ue[fe++]=W[me][we];return ue}function K(Y,z,Z,G){let Q;if(Array.isArray(Y))Q=y.fromArray(Y);else if(typeof Y=="string"){let L=z;if(!L){const $=y.rawSplit(Y);L=m.getBestVersionForData($,Z)}Q=y.fromString(Y,L||40)}else throw new Error("Invalid data");const B=m.getBestVersionForData(Q,Z);if(!B)throw new Error("The amount of data is too big to be stored in a QR Code");if(!z)z=B;else if(z<B)throw new Error(`
84
+ Suggested mode is: `+t.toString(I));switch(F===t.KANJI&&!h.isKanjiModeEnabled()&&(F=t.BYTE),F){case t.NUMERIC:return new n(R);case t.ALPHANUMERIC:return new s(R);case t.KANJI:return new a(R);case t.BYTE:return new o(R)}}e.fromArray=function(E){return E.reduce(function(F,I){return typeof I=="string"?F.push(C(I,null)):I.data&&F.push(C(I.data,I.mode)),F},[])},e.fromString=function(E,F){const I=S(E,h.isKanjiModeEnabled()),K=w(I),Y=k(K,F),z=f.find_path(Y.map,"start","end"),Z=[];for(let G=1;G<z.length-1;G++)Z.push(Y.table[z[G]].node);return e.fromArray(b(Z))},e.rawSplit=function(E){return e.fromArray(S(E,h.isKanjiModeEnabled()))}})(Ld)),Ld}var k_;function QN(){if(k_)return _d;k_=1;const e=Zs(),t=Tf(),n=MN(),s=IN(),o=ON(),a=BN(),u=zN(),h=Kw(),f=HN(),m=UN(),v=WN(),S=er(),y=XN();function b(Y,z){const Z=Y.size,G=a.getPositions(z);for(let Q=0;Q<G.length;Q++){const B=G[Q][0],M=G[Q][1];for(let j=-1;j<=7;j++)if(!(B+j<=-1||Z<=B+j))for(let T=-1;T<=7;T++)M+T<=-1||Z<=M+T||(j>=0&&j<=6&&(T===0||T===6)||T>=0&&T<=6&&(j===0||j===6)||j>=2&&j<=4&&T>=2&&T<=4?Y.set(B+j,M+T,!0,!0):Y.set(B+j,M+T,!1,!0))}}function w(Y){const z=Y.size;for(let Z=8;Z<z-8;Z++){const G=Z%2===0;Y.set(Z,6,G,!0),Y.set(6,Z,G,!0)}}function k(Y,z){const Z=o.getPositions(z);for(let G=0;G<Z.length;G++){const Q=Z[G][0],B=Z[G][1];for(let M=-2;M<=2;M++)for(let j=-2;j<=2;j++)M===-2||M===2||j===-2||j===2||M===0&&j===0?Y.set(Q+M,B+j,!0,!0):Y.set(Q+M,B+j,!1,!0)}}function C(Y,z){const Z=Y.size,G=m.getEncodedBits(z);let Q,B,M;for(let j=0;j<18;j++)Q=Math.floor(j/3),B=j%3+Z-8-3,M=(G>>j&1)===1,Y.set(Q,B,M,!0),Y.set(B,Q,M,!0)}function R(Y,z,Z){const G=Y.size,Q=v.getEncodedBits(z,Z);let B,M;for(B=0;B<15;B++)M=(Q>>B&1)===1,B<6?Y.set(B,8,M,!0):B<8?Y.set(B+1,8,M,!0):Y.set(G-15+B,8,M,!0),B<8?Y.set(8,G-B-1,M,!0):B<9?Y.set(8,15-B-1+1,M,!0):Y.set(8,15-B-1,M,!0);Y.set(G-8,8,1,!0)}function E(Y,z){const Z=Y.size;let G=-1,Q=Z-1,B=7,M=0;for(let j=Z-1;j>0;j-=2)for(j===6&&j--;;){for(let T=0;T<2;T++)if(!Y.isReserved(Q,j-T)){let L=!1;M<z.length&&(L=(z[M]>>>B&1)===1),Y.set(Q,j-T,L),B--,B===-1&&(M++,B=7)}if(Q+=G,Q<0||Z<=Q){Q-=G,G=-G;break}}}function F(Y,z,Z){const G=new n;Z.forEach(function(T){G.put(T.mode.bit,4),G.put(T.getLength(),S.getCharCountIndicator(T.mode,Y)),T.write(G)});const Q=e.getSymbolTotalCodewords(Y),B=h.getTotalCodewordsCount(Y,z),M=(Q-B)*8;for(G.getLengthInBits()+4<=M&&G.put(0,4);G.getLengthInBits()%8!==0;)G.putBit(0);const j=(M-G.getLengthInBits())/8;for(let T=0;T<j;T++)G.put(T%2?17:236,8);return I(G,Y,z)}function I(Y,z,Z){const G=e.getSymbolTotalCodewords(z),Q=h.getTotalCodewordsCount(z,Z),B=G-Q,M=h.getBlocksCount(z,Z),j=G%M,T=M-j,L=Math.floor(G/M),$=Math.floor(B/M),H=$+1,x=L-$,O=new f(x);let D=0;const A=new Array(M),W=new Array(M);let X=0;const ie=new Uint8Array(Y.buffer);for(let xe=0;xe<M;xe++){const $e=xe<T?$:H;A[xe]=ie.slice(D,D+$e),W[xe]=O.encode(A[xe]),D+=$e,X=Math.max(X,$e)}const ce=new Uint8Array(G);let fe=0,we,me;for(we=0;we<X;we++)for(me=0;me<M;me++)we<A[me].length&&(ce[fe++]=A[me][we]);for(we=0;we<x;we++)for(me=0;me<M;me++)ce[fe++]=W[me][we];return ce}function K(Y,z,Z,G){let Q;if(Array.isArray(Y))Q=y.fromArray(Y);else if(typeof Y=="string"){let L=z;if(!L){const $=y.rawSplit(Y);L=m.getBestVersionForData($,Z)}Q=y.fromString(Y,L||40)}else throw new Error("Invalid data");const B=m.getBestVersionForData(Q,Z);if(!B)throw new Error("The amount of data is too big to be stored in a QR Code");if(!z)z=B;else if(z<B)throw new Error(`
85
85
  The chosen QR Code version cannot contain this amount of data.
86
86
  Minimum version required to store current data is: `+B+`.
87
87
  `);const M=F(z,Z,Q),j=e.getSymbolSize(z),T=new s(j);return b(T,z),w(T),k(T,z),R(T,Z,0),z>=7&&C(T,z),E(T,M),isNaN(G)&&(G=u.getBestMask(T,R.bind(null,T,Z))),u.applyMask(G,T),R(T,Z,G),{modules:T,version:z,errorCorrectionLevel:Z,maskPattern:G,segments:Q}}return _d.create=function(z,Z){if(typeof z>"u"||z==="")throw new Error("No input text");let G=t.M,Q,B;return typeof Z<"u"&&(G=t.from(Z.errorCorrectionLevel,t.M),Q=m.from(Z.version),B=u.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),K(z,Q,G,B)},_d}var Od={},Bd={},C_;function Yw(){return C_||(C_=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:a,scale:a?4:u,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const u=o.modules.size,h=o.modules.data,f=e.getScale(u,a),m=Math.floor((u+a.margin*2)*f),v=a.margin*f,S=[a.color.light,a.color.dark];for(let y=0;y<m;y++)for(let b=0;b<m;b++){let w=(y*m+b)*4,k=a.color.light;if(y>=v&&b>=v&&y<m-v&&b<m-v){const C=Math.floor((y-v)/f),R=Math.floor((b-v)/f);k=S[h[C*u+R]?1:0]}s[w++]=k.r,s[w++]=k.g,s[w++]=k.b,s[w]=k.a}}})(Bd)),Bd}var E_;function JN(){return E_||(E_=1,(function(e){const t=Yw();function n(o,a,u){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=u,a.width=u,a.style.height=u+"px",a.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,u,h){let f=h,m=u;typeof f>"u"&&(!u||!u.getContext)&&(f=u,u=void 0),u||(m=s()),f=t.getOptions(f);const v=t.getImageWidth(a.modules.size,f),S=m.getContext("2d"),y=S.createImageData(v,v);return t.qrToImageData(y.data,a,f),n(S,m,v),S.putImageData(y,0,0),m},e.renderToDataURL=function(a,u,h){let f=h;typeof f>"u"&&(!u||!u.getContext)&&(f=u,u=void 0),f||(f={});const m=e.render(a,u,f),v=f.type||"image/png",S=f.rendererOpts||{};return m.toDataURL(v,S.quality)}})(Od)),Od}var zd={},N_;function ZN(){if(N_)return zd;N_=1;const e=Yw();function t(o,a){const u=o.a/255,h=a+'="'+o.hex+'"';return u<1?h+" "+a+'-opacity="'+u.toFixed(2).slice(1)+'"':h}function n(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",f=0,m=!1,v=0;for(let S=0;S<o.length;S++){const y=Math.floor(S%a),b=Math.floor(S/a);!y&&!m&&(m=!0),o[S]?(v++,S>0&&y>0&&o[S-1]||(h+=m?n("M",y+u,.5+b+u):n("m",f,0),f=0,m=!1),y+1<a&&o[S+1]||(h+=n("h",v),v=0)):f++}return h}return zd.render=function(a,u,h){const f=e.getOptions(u),m=a.modules.size,v=a.modules.data,S=m+f.margin*2,y=f.color.light.a?"<path "+t(f.color.light,"fill")+' d="M0 0h'+S+"v"+S+'H0z"/>':"",b="<path "+t(f.color.dark,"stroke")+' d="'+s(v,m,f.margin)+'"/>',w='viewBox="0 0 '+S+" "+S+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(f.width?'width="'+f.width+'" height="'+f.width+'" ':"")+w+' shape-rendering="crispEdges">'+y+b+`</svg>
88
- `;return typeof h=="function"&&h(null,C),C},zd}var j_;function e2(){if(j_)return jr;j_=1;const e=DN(),t=QN(),n=JN(),s=ZN();function o(a,u,h,f,m){const v=[].slice.call(arguments,1),S=v.length,y=typeof v[S-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(S<2)throw new Error("Too few arguments provided");S===2?(m=h,h=u,u=f=void 0):S===3&&(u.getContext&&typeof m>"u"?(m=f,f=void 0):(m=f,f=h,h=u,u=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(h=u,u=f=void 0):S===2&&!u.getContext&&(f=h,h=u,u=void 0),new Promise(function(b,w){try{const k=t.create(h,f);b(a(k,u,f))}catch(k){w(k)}})}try{const b=t.create(h,f);m(null,a(b,u,f))}catch(b){m(b)}}return jr.create=t.create,jr.toCanvas=o.bind(null,n.render),jr.toDataURL=o.bind(null,n.renderToDataURL),jr.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),jr}var t2=e2();const n2=Vh(t2);function R_(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function i2(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=$x(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function s2(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=Hx(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function P_(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=i2(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...s2(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function Ml(e,t){const n=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=vs(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=n.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function r2(e,{deviceDefault:t="",localNodeId:n="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const u=String(e.localName||Ml(a,n)||s||"").trim();return u&&(o.localName=u),o}function o2(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const a2=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function l2(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const c2="modulepreload",u2=function(e){return"/"+e},L_={},d2=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(n.map(m=>{if(m=u2(m),m in L_)return;L_[m]=!0;const v=m.endsWith(".css"),S=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${S}`))return;const y=document.createElement("link");if(y.rel=v?"stylesheet":c2,v||(y.as="script"),y.crossOrigin="",y.href=m,f&&y.setAttribute("nonce",f),document.head.appendChild(y),v)return new Promise((b,w)=>{y.addEventListener("load",b),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${m}`)))})}))}function a(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return o.then(u=>{for(const h of u||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class tt{constructor(t,n,s,o,a){this._legacyCanvasSize=tt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),h.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=tt.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await tt.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),tt._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),tt._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),tt._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?tt._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(tt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let h,f=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(h=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,f=!0):console.warn(n||s||o||a||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let m,v;[s,m]=await Promise.all([s||tt.createQrEngine(),tt._loadImage(t)]),[o,v]=tt._drawToCanvas(m,h,o,a);let S;if(s instanceof Worker){let y=s;n||tt._postWorkerMessageSync(y,"inversionMode","both"),S=await new Promise((b,w)=>{let k,C,R,E=-1;C=I=>{I.data.id===E&&(y.removeEventListener("message",C),y.removeEventListener("error",R),clearTimeout(k),I.data.data!==null?b({data:I.data.data,cornerPoints:tt._convertPoints(I.data.cornerPoints,h)}):w(tt.NO_QR_CODE_FOUND))},R=I=>{y.removeEventListener("message",C),y.removeEventListener("error",R),clearTimeout(k),w("Scanner error: "+(I?I.message||I:"Unknown Error"))},y.addEventListener("message",C),y.addEventListener("error",R),k=setTimeout(()=>R("timeout"),1e4);let F=v.getImageData(0,0,o.width,o.height);E=tt._postWorkerMessageSync(y,"decode",F,[F.data.buffer])})}else S=await Promise.race([new Promise((y,b)=>window.setTimeout(()=>b("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw tt.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:tt._convertPoints(y.cornerPoints,h)}}catch(b){if(y=b.message||b,/not implemented|service unavailable/.test(y))return tt._disableBarcodeDetector=!0,tt.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return f?S:S.data}catch(m){if(!h||!u)throw m;let v=await tt.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return f?v:v.data}finally{n||tt._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){tt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){tt._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>d2(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!tt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,f=window.getComputedStyle(t),m=f.objectFit,v=n/s,S=o/a;switch(m){case"none":var y=n,b=s;break;case"fill":y=o,b=a;break;default:(m==="cover"?v>S:v<S)?(b=a,y=b*v):(y=o,b=y/v),m==="scale-down"&&(y=Math.min(y,n),b=Math.min(b,s))}var[w,k]=f.objectPosition.split(" ").map((R,E)=>{const F=parseFloat(R);return R.endsWith("%")?(E?a-b:o-y)*F/100:F});f=this._scanRegion.width||n,S=this._scanRegion.height||s,m=this._scanRegion.x||0;var C=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${f/n*y}px`,v.height=`${S/s*b}px`,v.top=`${h+k+C/s*b}px`,s=/scaleX\(-1\)/.test(t.style.transform),v.left=`${u+(s?o-w-y:w)+(s?n-m-f:m)/n*y}px`,v.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await tt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!tt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=tt.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==tt.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,h=n&&n.width?n.width:t.videoWidth||t.width,f=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:h,n=n&&n.downScaledHeight?n.downScaledHeight:f,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,a,u,h,f,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await tt._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await tt._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return tt._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=tt._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}tt.DEFAULT_CANVAS_SIZE=400;tt.NO_QR_CODE_FOUND="No QR code found";tt._disableBarcodeDetector=!1;tt._workerMessageId=0;function h2({onResult:e,onClose:t}){const n=N.useRef(null),s=N.useRef(null),o=N.useRef(!1),[a,u]=N.useState("");N.useEffect(()=>{let f=!1;const m=n.current,v=S=>{f||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(p("qr-unsupported"));return}let S=!1;try{S=await tt.hasCamera()}catch{S=!1}if(!S){u(p("qr-no-camera"));return}if(f||!m)return;const y=new tt(m,b=>{const w=R_(b);w&&v(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const w=b.videoWidth||640,k=b.videoHeight||480,C=Math.max(1,Math.round(Math.min(w,k)*.92));return{x:Math.round((w-C)/2),y:Math.round((k-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(b){if(f)return;const w=b&&b.name||"";u(p(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{f=!0;const S=s.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}s.current=null}const y=m,b=y&&y.srcObject;if(b&&typeof b.getTracks=="function"){for(const w of b.getTracks())try{w.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const h=async f=>{const m=f.target.files&&f.target.files[0];if(f.target.value="",!!m)try{const v=await tt.scanImage(m,{returnDetailedScanResult:!0}),S=R_(v);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{u(p("pairing-qr-invalid"))}};return c.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:c.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:f=>f.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:p("scan-qr")})}),c.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&c.jsx("div",{className:"nc-err",role:"alert",children:a}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[p("qr-upload"),c.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:p("cancel")})]})]})})}const A_=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Gw({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:f}){const[m,v]=N.useState(A_),[S,y]=N.useState(!1),[b,w]=N.useState(!1),[k,C]=N.useState("idle"),[R,E]=N.useState(null),[F,I]=N.useState(""),[K,Y]=N.useState(!1),[z,Z]=N.useState(!1),G=N.useRef(o2()),Q=N.useRef(new Set),B=k==="busy",M=Ml(m.localLabel||s,o)||a,j=z?m.localName:M;N.useEffect(()=>(f&&f(B),()=>{f&&f(!1)}),[B,f]);const T=async D=>{const A=String(D.pairingUrl||"").trim();if(G.current.start(A)){C("busy"),E(null),I("");try{await j0(e,r2({...D,localName:z?D.localName:Ml(D.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),C("ok"),y(!1),v(A_()),Q.current=new Set,Y(!1),Z(!1),G.current.finish(),h&&await h()}catch(W){const X=l2(W);E(X),C("idle"),G.current.finish(),X.code==="peer-name-conflict"&&Yd(X.suggestedName)&&(Z(!0),Q.current.add("localName"),v(ie=>({...ie,localName:X.suggestedName}))),(X.stage==="validation"||X.stage==="conflict"||X.stage==="ssh-start"||X.stage==="ssh-ready"||String(X.code||"").startsWith("ssh-"))&&y(!0)}}},L=(D,A=!0)=>{const{classification:W,form:X}=P_(m,D,Q.current,K),ie=X.pairingUrl;if(E(null),I(""),k==="ok"&&C("idle"),v(X),W.kind==="invalid"){E({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(W.kind==="partial"){y(!0),I(W.missing.includes("ssh")?p("pair-missing-ssh"):p("pair-missing-name"));return}W.kind==="complete"&&A&&!u&&G.current.canAuto(ie)&&T(X)};N.useEffect(()=>{t&&L(t,n)},[]);const $=()=>{const D=String(m.pairingUrl||"").trim(),{classification:A,form:W}=P_(m,D,Q.current,K);if(v(W),I(""),E(null),A.kind==="empty"){E({stage:"validation",message:p("pairing-required"),retryable:!0});return}if(A.kind==="invalid"){E({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(!W.ssh||!W.name){y(!0),I(W.ssh?p("pair-missing-name"):p("pair-missing-ssh"));return}if(W.label&&!Ir(W.label)){E({stage:"validation",message:p("err-label"),retryable:!0});return}if(W.localLabel&&!Ir(W.localLabel)){E({stage:"validation",message:p("err-label"),retryable:!0});return}const X=z?W.localName:Ml(W.localLabel||s,o)||a;if(!Yd(X)||X==="localhost"){y(!0),E({stage:"validation",code:"bad-local-name",message:p("err-local-name"),retryable:!0});return}G.current.reset(D),T(W)},H=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const D=await navigator.clipboard.readText();D&&D.trim()?L(D):I(p("pair-clipboard-empty"))}catch{I(p("pair-clipboard-denied"))}},x=(D,A)=>{Q.current.add(D),v(W=>({...W,[D]:A}))},O=R&&R.stage&&(a2.includes(R.stage)||R.stage==="internal")?p(`pair-stage-${R.stage}`):p("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:p("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:p("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:p("pair-paste-ph"),value:m.pairingUrl,disabled:u||B,onChange:D=>{v({...m,pairingUrl:D.target.value}),E(null),I("")},onPaste:D=>{const A=D.clipboardData&&D.clipboardData.getData("text")||"";A.trim()&&(D.preventDefault(),L(A))},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),$())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:H,children:p("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:()=>w(!0),children:p("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||B,title:u?p("settings-readonly"):"",onClick:$,children:p("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[B&&c.jsx("div",{className:"nc-pair-progress",children:p("pair-progress")}),k==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:p("node-connected")}),F&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:F}),R&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:O})," — ",R.message,R.hint&&c.jsx("div",{className:"nc-pair-hint",children:R.hint}),R.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:$,children:p("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:B,onClick:()=>y(D=>!D),children:[S?"▾":"▸"," ",p("pair-advanced")]}),S&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[p("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:m.label,disabled:u||B,onChange:D=>{Q.current.add("label"),v(A=>({...A,label:D.target.value,name:K?A.name:vs(D.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[p("node-name-label"),c.jsx("input",{placeholder:p("node-name-ph"),value:m.name,disabled:u||B,onChange:D=>{Y(!0),Q.current.add("name"),v(A=>({...A,name:D.target.value?vs(D.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:p("node-slug-hint").replace("{slug}",m.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[p("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:m.ssh,disabled:u||B,onChange:D=>{Q.current.add("ssh"),x("ssh",D.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:p("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:p("node-ssh-port-help"),value:m.sshPort,disabled:u||B,onChange:D=>x("sshPort",D.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[p("device-name-label"),c.jsx("input",{placeholder:s||"NexusCrew",value:m.localLabel,disabled:u||B,onChange:D=>x("localLabel",D.target.value)}),c.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[p("local-route-name-label"),c.jsx("input",{placeholder:M||"nexuscrew-5bd6",value:j,disabled:u||B,onChange:D=>{Z(!0),Q.current.add("localName"),v(A=>({...A,localName:D.target.value?vs(D.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:p("local-route-name-hint")})]})]}),b&&c.jsx(h2,{onResult:D=>{w(!1),L(D)},onClose:()=>w(!1)})]})}const wi={routed:"peer-routed",routedStale:"peer-routed-stale",up:"tunnel-up",down:"tunnel-down",passive:"node-connected-client",vlOnline:"vl-poll-online",vlOffline:"vl-poll-offline"};function Df(e){if(!e||typeof e!="object")return{key:wi.down,up:!1};if(e.kind==="vl")return e.online?{key:wi.vlOnline,up:!0}:{key:wi.vlOffline,up:!1};if(e.kind==="transitive"){const n=e.stale===!0;return{key:n?wi.routedStale:wi.routed,up:!n,routed:!0}}const t=e.tunnel&&e.tunnel.status;return t==="up"?{key:wi.up,up:!0}:t==="passive"?{key:wi.passive,up:!1,passive:!0}:{key:wi.down,up:!1}}function Xw(e){if(!e||typeof e!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(e.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(e.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const t=e.visibility||"network";if(t==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:t};if(t==="selected"){const n=Array.isArray(e.selected)?e.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:t,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:t}}function f2(e){const n=e.health&&typeof e.health.detail=="string"&&e.health.detail.trim()||p(e.online?wi.vlOnline:wi.vlOffline);return e.ownerLabel?`${e.ownerLabel} · ${n}`:n}function p2(e){if(!e||typeof e!="object")return null;const t=typeof e.name=="string"?e.name:"";if(!t)return null;const n=e.kind==="transitive";return{name:t,title:typeof e.label=="string"&&e.label.trim()||t,subtitle:e.kind==="vl"?f2(e):t,reach:Df(e),exposure:Xw(e),routed:n,routeLabel:n&&Array.isArray(e.route)?e.route.join(" › "):null}}function m2(e){if(!e||typeof e!="object"||typeof e.name!="string"||!e.name)return null;const t=e.kind==="transitive";return{name:e.name,title:typeof e.label=="string"&&e.label.trim()||e.name,routed:t,route:t&&Array.isArray(e.route)?[...e.route]:null,ssh:!t&&e.direction==="outbound"&&e.ssh?String(e.ssh):null,inbound:!t&&e.direction==="inbound",transport:e.tunnel&&typeof e.tunnel.transport=="string"&&e.tunnel.transport||null}}function g2(e){return!e||typeof e!="object"?null:e.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function v2(e,t){if(!e||e.visibility!=="selected")return[];const n=[...new Set(Array.isArray(e.selected)?e.selected:[])],s=new Map;for(const o of Array.isArray(t)?t:[])o&&o.nodeId&&!s.has(o.nodeId)&&s.set(o.nodeId,o);return n.map(o=>{const a=s.get(o);return{id:o,label:a?typeof a.label=="string"&&a.label.trim()||a.name:o,known:!!a}})}function _2(e,t,n=""){if(!e)return[];const s=new Set(Array.isArray(e.selected)?e.selected:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[],h=f=>e.nodeId?f.nodeId===e.nodeId:f.name===e.name;for(const f of Array.isArray(t)?t:[]){if(!f||!f.nodeId||h(f)||s.has(f.nodeId)||a.has(f.nodeId))continue;const m=typeof f.label=="string"&&f.label.trim()||f.name;o&&!`${m} ${f.name}`.toLowerCase().includes(o)||(a.add(f.nodeId),u.push({id:f.nodeId,label:m,name:f.name}))}return u.sort((f,m)=>f.label.localeCompare(m.label))}function y2(e,{readonly:t=!1,busy:n=!1}={}){if(!e||typeof e!="object")return[];const s=e.actions&&typeof e.actions=="object"?e.actions:{},o=Df(e).up,a=[],u=(h,f,{mutating:m=!0,danger:v=!1}={})=>{a.push({key:h,action:f,danger:v,disabled:n||m&&t})};return s.edit&&u("edit","edit"),s.test&&u("node-test","test",{mutating:!1}),s.disconnect&&o&&u("tunnel-stop","down"),s.connect&&!o&&u("tunnel-start","up"),s.restart&&u("tunnel-restart","restart"),s.remove&&u("delete","remove",{danger:!0}),a}function Qw(e){const t=e&&typeof e.cellVisibility=="string"?e.cellVisibility:"all";return["all","none","selected"].includes(t)?t:"all"}function w2(e,t){if(Qw(e)!=="selected")return[];const n=[...new Set(Array.isArray(e.cells)?e.cells:[])];if(!Array.isArray(t))return n.map(o=>({id:o,label:o,known:!0}));const s=new Set(t.map(o=>typeof o=="string"?o:o&&(o.cell||o.id)).filter(Boolean));return n.map(o=>({id:o,label:o,known:s.has(o)}))}function b2(e,t,n=""){const s=new Set(Array.isArray(e&&e.cells)?e.cells:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[];for(const h of Array.isArray(t)?t:[]){const f=typeof h=="string"?h:h&&(h.cell||h.id);!f||s.has(f)||a.has(f)||o&&!f.toLowerCase().includes(o)||(a.add(f),u.push({id:f,label:f}))}return u.sort((h,f)=>h.label.localeCompare(f.label))}function S2(e,t,{readonly:n=!1,busy:s=!1}={}){const o=m2(e);return o?{identity:o,reach:Df(e),authority:g2(e),exposure:Xw(e),grants:v2(e,t),cellScope:Qw(e),actions:y2(e,{readonly:n,busy:s}),canEditVisibility:!!(e.actions&&e.actions.visibility)&&e.shared===!0&&e.kind!=="transitive",canEditCellScope:!!(e.actions&&e.actions.edit)&&e.kind!=="transitive"}:null}const x2=new Set(["update_candidate"]),T_=4096,k2=new Set(["prompt"]),D_={logs:{limit:50}};function C2(e){if(!e||e.kind!=="vl")return[];const t=Array.isArray(e.capabilities)?e.capabilities:[],n=new Set,s=[];for(const o of t)typeof o!="string"||!o||x2.has(o)||k2.has(o)||n.has(o)||(n.add(o),s.push(o));return s}function M_(e){return!!(e&&e.kind==="vl"&&Array.isArray(e.capabilities)&&e.capabilities.includes("prompt"))}function E2(e){return D_[e]?{...D_[e]}:{}}function N2(e,t){return e?e.inflight&&typeof e.inflight=="object"?{phase:"inflight",kind:e.inflight.kind}:t?e.lastAck&&e.lastAck.id===t.id?{phase:"done",kind:t.kind,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:{phase:"submitted",kind:t.kind}:e.lastAck&&typeof e.lastAck=="object"?{phase:"done",kind:null,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:null:null}function j2({title:e,subtitle:t,status:n,footer:s,onClose:o,plain:a=!1,children:u}){const h=N.useRef(null),f=N.useRef(null);return N.useEffect(()=>(f.current=document.activeElement,h.current&&h.current.focus(),()=>{const m=f.current;m&&typeof m.focus=="function"&&document.contains(m)&&m.focus()}),[]),N.useEffect(()=>{const m=v=>{v.key==="Escape"&&(v.stopPropagation(),o&&o())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[o]),c.jsx("div",{className:"nc-detail-overlay",onMouseDown:m=>{m.target===m.currentTarget&&o&&o()},children:c.jsxs("div",{className:"nc-detail-sheet",ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof e=="string"?e:void 0,children:[c.jsxs("div",{className:"nc-detail-head",children:[c.jsxs("div",{className:"nc-detail-title",children:[c.jsx("b",{children:e}),t&&c.jsx("small",{children:t})]}),n,c.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:o,"aria-label":p("close"),children:c.jsx(Ze,{name:"x",size:14})})]}),c.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:u}),s&&c.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Rr({title:e,hint:t,children:n}){return n==null||n===!1?null:c.jsxs("section",{className:"nc-detail-section",children:[e&&c.jsx("div",{className:"nc-sheet-label",children:e}),t&&c.jsx("small",{className:"nc-set-hint",children:t}),n]})}function R2({node:e,nodes:t,token:n,readonly:s,refresh:o,onClose:a}){var ke,Te;kn();const[u,h]=N.useState(null),[f,m]=N.useState(null),[v,S]=N.useState(null),[y,b]=N.useState(null),[w,k]=N.useState(!1),[C,R]=N.useState(""),[E,F]=N.useState(!1),[I,K]=N.useState(null),[Y,z]=N.useState(""),[Z,G]=N.useState(!1),[Q,B]=N.useState(null),[M,j]=N.useState(!1),[T,L]=N.useState(""),$=N.useMemo(()=>S2(e,t,{readonly:s,busy:!!u}),[e,t,s,u]);if(!$)return null;const{identity:H,reach:x,authority:O,exposure:D,grants:A,actions:W,canEditVisibility:X,canEditCellScope:ie,cellScope:ue}=$,fe=H.routed?{up:x.up,since:null}:Gd(e.tunnel,Date.now()),we=async(ae,re)=>{m(null),h(ae);try{await re()}catch(Pe){m(String(Pe&&Pe.message||Pe))}h(null)},me=ae=>{if(ae==="edit"){b({label:e.label||e.name,ssh:e.ssh||"",sshPort:e.sshPort?String(e.sshPort):"",autostart:e.autostart===!0,visibility:e.visibility||"network"});return}if(ae==="remove"){k(!0);return}we(`${e.name}:${ae}`,async()=>{const re=await ef(n,e.name,ae);ae==="test"&&S(re),await o()})},xe=(ae,re=E2(ae))=>we(`${e.nodeId}:${ae}`,async()=>{const Pe=await wg(n,e.nodeId,ae,re,e.route||[]);B({id:Pe.id,kind:ae,submittedAt:Date.now()}),await o()}),$e=()=>{const ae=T.trim().slice(0,T_);ae&&we(`${e.nodeId}:prompt`,async()=>{const re=await wg(n,e.nodeId,"prompt",{text:ae},e.route||[]);B({id:re.id,kind:"prompt",submittedAt:Date.now()}),L(""),j(!1),await o()})},ft=()=>{if(!Ir(y.label)){m(p("err-label"));return}const ae=H.inbound?{label:y.label,visibility:y.visibility,selected:y.visibility==="selected"?[...e.selected||[]]:[]}:{label:y.label,ssh:y.ssh,autostart:y.autostart,...y.sshPort?{sshPort:Number(y.sshPort)}:{}};return we(`${e.name}:edit`,async()=>{await xg(n,e.name,ae),b(null),await o()})},qe=(ae,re)=>we(`${e.name}:visibility`,async()=>{await D0(n,e.name,ae,re),await o()}),Ae=X&&e.visibility==="selected"?_2(e,t,C):[],Rt=(ae,re)=>we(`${e.name}:cell-scope`,async()=>{await xg(n,e.name,ae==="selected"?{cellVisibility:ae,cells:Array.isArray(re)?re:e.cells||[]}:{cellVisibility:ae}),await o()}),Jt=async()=>{if(I===null)try{const ae=await Jl(n);K(Array.isArray(ae&&ae.cells)?ae.cells:[])}catch{K([])}},Oe=w2(e,I),Pt=ue==="selected"?b2(e,I,Y):[],bt=c.jsxs("span",{className:`nc-set-tunnel${x.up?" up":""}`,children:[p(x.key),fe.since?` · ${fe.since}`:""]}),dt=e.kind==="vl",ht=dt?C2(e):[],Qe=dt?N2(e,Q):null,ot=ae=>{const re=`vl-cmd-${ae}`,Pe=p(re);return Pe===re?ae:Pe},oe=dt?[...ht.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>xe(ae),children:ot(ae)},ae)),...M_(e)?[c.jsx("button",{type:"button",className:`nc-btn ghost${M?" on":""}`,disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>j(ae=>!ae),children:ot("prompt")},"prompt")]:[]]:W.map(ae=>c.jsx("button",{type:"button",className:`nc-btn ${ae.danger?"danger":"ghost"}`,disabled:ae.disabled,title:ae.disabled&&s?p("settings-readonly"):void 0,onClick:()=>me(ae.action),children:ae.action==="remove"?c.jsxs(c.Fragment,{children:[c.jsx(Ze,{name:"trash",size:14})," ",p(ae.key)]}):p(ae.key)},ae.action));return c.jsxs(j2,{title:H.title,subtitle:H.name,status:bt,footer:oe,onClose:a,children:[c.jsxs(Rr,{title:p("node-detail-reach"),children:[c.jsxs("dl",{className:"nc-detail-facts",children:[H.route&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-route")}),c.jsx("dd",{children:H.route.join(" › ")})]}),H.ssh&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-ssh")}),c.jsxs("dd",{children:[H.ssh,e.sshPort?`:${e.sshPort}`:""]})]}),H.transport&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-transport")}),c.jsx("dd",{children:H.transport})]}),dt&&e.ownerLabel&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-owner")}),c.jsx("dd",{children:e.ownerLabel})]})]}),((ke=e.health)==null?void 0:ke.detail)&&c.jsx("div",{className:`nc-set-test${dt?e.health.state==="running"?" ok":e.health.state==="starting"?"":" ko":e.health.status==="healthy"?" ok":e.health.status==="passive"?"":" ko"}`,children:e.health.detail}),v&&c.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),dt&&c.jsxs(Rr,{title:p("node-detail-command"),children:[ht.length===0&&!M_(e)&&c.jsx("small",{className:"nc-set-hint",children:p("vl-no-commands")}),M&&c.jsxs("div",{className:"nc-vl-prompt",children:[c.jsx("textarea",{value:T,maxLength:T_,placeholder:p("vl-prompt-placeholder"),"aria-label":p("vl-prompt-placeholder"),disabled:!!u||s,onChange:ae=>L(ae.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!T.trim(),onClick:$e,children:p("vl-prompt-send")})]}),Qe&&c.jsxs("div",{className:`nc-set-test${Qe.phase==="done"?Qe.status==="ok"?" ok":" ko":""}`,children:[Qe.kind&&`${ot(Qe.kind)}: `,Qe.phase==="submitted"&&p("vl-cmd-phase-submitted"),Qe.phase==="inflight"&&p("vl-cmd-phase-inflight"),Qe.phase==="done"&&p(Qe.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),Qe.phase==="done"&&((Te=Qe.result)!=null&&Te.detail)?` — ${Qe.result.detail}`:""]})]}),c.jsxs(Rr,{title:p("node-detail-authority"),children:[c.jsx("div",{className:"nc-set-info",children:p(O.key)}),O.grants.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("authority-no-grants")})]}),c.jsxs(Rr,{title:p("node-detail-network-view"),children:[c.jsx("div",{className:"nc-set-info",children:p(dt?D.key:D.shared?"peer-shared":"peer-private")}),X&&c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),c.jsxs("select",{value:e.visibility||"network",disabled:s||!!u,onChange:ae=>qe(ae.target.value),children:[c.jsx("option",{value:"network",children:p("visibility-network")}),c.jsx("option",{value:"relay-only",children:p("visibility-relay")}),c.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}),e.visibility==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[A.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("node-grant-none")}),A.map(ae=>c.jsxs("div",{className:`nc-detail-grant${ae.known?"":" unknown"}`,children:[c.jsxs("span",{children:[ae.label,ae.known?"":` — ${p("node-grant-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>qe("selected",(e.selected||[]).filter(re=>re!==ae.id)),children:p("node-grant-remove")})]},ae.id)),!E&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{F(!0),R("")},children:p("node-grant-add")}),E&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:C,placeholder:p("node-grant-search"),disabled:s||!!u,onChange:ae=>R(ae.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[Ae.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("node-grant-no-candidates")}),Ae.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await qe("selected",[...e.selected||[],ae.id]),F(!1),R("")},children:ae.label},ae.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{F(!1),R("")},children:p("cancel")})]})]})]})]}),ie&&c.jsxs(Rr,{title:p("cell-scope"),children:[c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-help")}),c.jsx("label",{className:"nc-field",children:c.jsxs("select",{value:ue,disabled:s||!!u,onChange:ae=>{ae.target.value==="selected"&&Jt(),Rt(ae.target.value)},children:[c.jsx("option",{value:"all",children:p("cell-scope-all")}),c.jsx("option",{value:"none",children:p("cell-scope-none")}),c.jsx("option",{value:"selected",children:p("cell-scope-selected")})]})}),ue==="selected"&&Oe.length>0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-reset-warning")}),ue==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[Oe.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-none-granted")}),Oe.map(ae=>c.jsxs("div",{className:`nc-detail-grant${ae.known?"":" unknown"}`,children:[c.jsxs("span",{children:[ae.label,ae.known?"":` — ${p("cell-scope-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Rt("selected",(e.cells||[]).filter(re=>re!==ae.id)),children:p("node-grant-remove")})]},ae.id)),!Z&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Jt(),G(!0),z("")},children:p("cell-scope-add")}),Z&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:Y,placeholder:p("cell-scope-search"),disabled:s||!!u,onChange:ae=>z(ae.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[Pt.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-no-candidates")}),Pt.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Rt("selected",[...e.cells||[],ae.id]),G(!1),z("")},children:ae.label},ae.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{G(!1),z("")},children:p("cancel")})]})]})]}),y&&c.jsxs(Rr,{title:p("edit"),children:[c.jsxs("label",{className:"nc-field",children:[p("node-display-label"),c.jsx("input",{value:y.label,disabled:!!u,onChange:ae=>b({...y,label:ae.target.value})})]}),H.inbound?c.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),c.jsxs("select",{value:y.visibility,disabled:!!u,onChange:ae=>b({...y,visibility:ae.target.value}),children:[c.jsx("option",{value:"network",children:p("visibility-network")}),c.jsx("option",{value:"relay-only",children:p("visibility-relay")}),c.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[p("node-ssh-label"),c.jsx("input",{value:y.ssh,disabled:!!u,onChange:ae=>b({...y,ssh:ae.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:y.sshPort,disabled:!!u,onChange:ae=>b({...y,sshPort:ae.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:y.autostart,disabled:!!u,onChange:ae=>b({...y,autostart:ae.target.checked})})," ",p("boot-persist")]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:ft,children:p("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>b(null),children:p("cancel")})]})]}),w&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:p("node-remove-confirm").replace("{name}",H.title)}),c.jsx("small",{children:p("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>we(`${e.name}:remove`,async()=>{await A0(n,e.name),k(!1),await o(),a&&a()}),children:p("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>k(!1),children:p("cancel")})]})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function Mf(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function P2(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function L2(){if(!Mf())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function A2(e){if(!Mf())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await Ht("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:P2(s)}),u=await Ht("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const h=await u.json().catch(()=>({}));throw new Error(h.error||`HTTP ${u.status}`)}return!0}async function T2(e){if(!Mf())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await Ht("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Fh="nexuscrew.fleet",Jw=3,D2="nexuscrew.cells",Zw=/^[A-Za-z0-9._-]{1,32}$/,cc=/^[a-z0-9._-]{1,32}$/,eb=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,tb=new Set(["standard","unsafe"]),M2=4096,I2=4096,Ql=256,nb=8192,O2=4096,B2=32,z2=64,F2=24,$2=new Set(["format","version","exportedAt","cells","engines"]),H2=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label"]),U2=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Ks(e){if(typeof e!="string"||e.length>I2)return null;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(e==="")return"";if(e.charAt(0)==="/"||/^[A-Za-z]:/.test(e))return null;const t=[];for(const n of e.split("/"))if(!(n===""||n===".")){if(n==="..")return null;t.push(n)}return t.join("/")}const W2=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),K2=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function Oi(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function If(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function Yo(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,a]of n){if(!cc.test(o)||!t(a))return null;s[o]=a}return s}function ib(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!H2.has(h))||!Zw.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=Ks(e.cwdRel);if(t===null||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const n=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof n!="string"||n.length>nb)return null;const s=Yo(e.models,h=>typeof h=="string"&&!!h&&h.length<=Ql),o=Yo(e.permissionPolicies,h=>tb.has(h)),a=Yo(e.commands,h=>Oi(h,O2)&&!If(h));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:n};if(e.model&&(u.model=e.model),e.label!==void 0){if(!Oi(e.label,z2)||!String(e.label).trim())return null;u.label=String(e.label).trim()}return Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function q2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!U2.has(a))||!Zw.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>M2||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>nb)return null;const n=Yo(e.models,a=>typeof a=="string"&&!!a&&a.length<=Ql),s=Yo(e.permissionPolicies,a=>tb.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function V2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!K2.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!Oi(s,n==="baseUrl"?512:128)||If(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!eb.test(t.envKey)?null:t}function sb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!W2.has(s))||!cc.test(String(e.id||""))||!Oi(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=V2(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!Oi(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!Oi(s,1024)||If(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!Oi(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!Oi(e.model.flag,32)||/\s/.test(e.model.flag)||!Oi(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!eb.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function rb(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},n=sb(t);return n||null}function Y2(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const m of Array.isArray(e)?e:[]){if(!a.has(m.id))continue;const v=ib({id:m.id,cwdRel:m.cwdRel,engine:m.engine,boot:m.boot===!0,...m.label?{label:m.label}:{},...m.model?{model:m.model}:{},...m.models?{models:m.models}:{},...m.permissionPolicies?{permissionPolicies:m.permissionPolicies}:{},systemPrompt:m.prompt||"",...m.commands?{commands:m.commands}:{}});if(!v)return{ok:!1,error:"invalid-cell",invalidCellIds:[m.id]};h.push(v)}const f=[];for(const m of Array.isArray(n)?n:[]){if(!u.has(m.id))continue;const v=rb(m);v&&f.push(v)}return{format:Fh,version:Jw,exportedAt:o.toISOString(),cells:h,engines:f}}function G2(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===D2&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===Fh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===Fh&&(t==null?void 0:t.version)===Jw,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(S=>!$2.has(S))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>B2||u&&(!Array.isArray(t.engines)||t.engines.length>F2))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],f=new Set;for(const S of t.cells){const y=a?q2(S):ib(S);if(!y)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(f.has(y.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};f.add(y.id),h.push(y)}const m=[],v=new Set;for(const S of u?t.engines:[]){const y=sb(S);if(!y)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(y.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(y.id),m.push(y)}return{ok:!0,cells:h,engines:m,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function X2(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([v])=>s.has(v))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.label=="string"&&e.label&&(a.label=e.label),typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),h=o(e.permissionPolicies),f=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),Object.keys(f).length&&(a.commands=f),a}const Q2=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",credentialSourcePolicy:"auto",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),I_=(e="")=>({id:"",cwd:"",engine:e,boot:!1,label:"",model:"",prompt:"",commands:{},command:""}),ob=e=>e==="claude"?"unsafe":"standard",Zo=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),J2=(e,t)=>{var n;return((n=Zo(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function Z2(e){var t,n,s,o,a,u,h,f,m,v,S,y,b,w,k;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
88
+ `;return typeof h=="function"&&h(null,C),C},zd}var j_;function e2(){if(j_)return jr;j_=1;const e=DN(),t=QN(),n=JN(),s=ZN();function o(a,u,h,f,m){const v=[].slice.call(arguments,1),S=v.length,y=typeof v[S-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(S<2)throw new Error("Too few arguments provided");S===2?(m=h,h=u,u=f=void 0):S===3&&(u.getContext&&typeof m>"u"?(m=f,f=void 0):(m=f,f=h,h=u,u=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(h=u,u=f=void 0):S===2&&!u.getContext&&(f=h,h=u,u=void 0),new Promise(function(b,w){try{const k=t.create(h,f);b(a(k,u,f))}catch(k){w(k)}})}try{const b=t.create(h,f);m(null,a(b,u,f))}catch(b){m(b)}}return jr.create=t.create,jr.toCanvas=o.bind(null,n.render),jr.toDataURL=o.bind(null,n.renderToDataURL),jr.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),jr}var t2=e2();const n2=Vh(t2);function R_(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function i2(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=$x(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function s2(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=Hx(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function P_(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=i2(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...s2(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function Ml(e,t){const n=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=vs(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=n.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function r2(e,{deviceDefault:t="",localNodeId:n="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const u=String(e.localName||Ml(a,n)||s||"").trim();return u&&(o.localName=u),o}function o2(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const a2=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function l2(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const c2="modulepreload",u2=function(e){return"/"+e},L_={},d2=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(n.map(m=>{if(m=u2(m),m in L_)return;L_[m]=!0;const v=m.endsWith(".css"),S=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${S}`))return;const y=document.createElement("link");if(y.rel=v?"stylesheet":c2,v||(y.as="script"),y.crossOrigin="",y.href=m,f&&y.setAttribute("nonce",f),document.head.appendChild(y),v)return new Promise((b,w)=>{y.addEventListener("load",b),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${m}`)))})}))}function a(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return o.then(u=>{for(const h of u||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class tt{constructor(t,n,s,o,a){this._legacyCanvasSize=tt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),h.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=tt.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await tt.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),tt._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),tt._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),tt._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?tt._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(tt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let h,f=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(h=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,f=!0):console.warn(n||s||o||a||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let m,v;[s,m]=await Promise.all([s||tt.createQrEngine(),tt._loadImage(t)]),[o,v]=tt._drawToCanvas(m,h,o,a);let S;if(s instanceof Worker){let y=s;n||tt._postWorkerMessageSync(y,"inversionMode","both"),S=await new Promise((b,w)=>{let k,C,R,E=-1;C=I=>{I.data.id===E&&(y.removeEventListener("message",C),y.removeEventListener("error",R),clearTimeout(k),I.data.data!==null?b({data:I.data.data,cornerPoints:tt._convertPoints(I.data.cornerPoints,h)}):w(tt.NO_QR_CODE_FOUND))},R=I=>{y.removeEventListener("message",C),y.removeEventListener("error",R),clearTimeout(k),w("Scanner error: "+(I?I.message||I:"Unknown Error"))},y.addEventListener("message",C),y.addEventListener("error",R),k=setTimeout(()=>R("timeout"),1e4);let F=v.getImageData(0,0,o.width,o.height);E=tt._postWorkerMessageSync(y,"decode",F,[F.data.buffer])})}else S=await Promise.race([new Promise((y,b)=>window.setTimeout(()=>b("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw tt.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:tt._convertPoints(y.cornerPoints,h)}}catch(b){if(y=b.message||b,/not implemented|service unavailable/.test(y))return tt._disableBarcodeDetector=!0,tt.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return f?S:S.data}catch(m){if(!h||!u)throw m;let v=await tt.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return f?v:v.data}finally{n||tt._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){tt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){tt._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>d2(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!tt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,f=window.getComputedStyle(t),m=f.objectFit,v=n/s,S=o/a;switch(m){case"none":var y=n,b=s;break;case"fill":y=o,b=a;break;default:(m==="cover"?v>S:v<S)?(b=a,y=b*v):(y=o,b=y/v),m==="scale-down"&&(y=Math.min(y,n),b=Math.min(b,s))}var[w,k]=f.objectPosition.split(" ").map((R,E)=>{const F=parseFloat(R);return R.endsWith("%")?(E?a-b:o-y)*F/100:F});f=this._scanRegion.width||n,S=this._scanRegion.height||s,m=this._scanRegion.x||0;var C=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${f/n*y}px`,v.height=`${S/s*b}px`,v.top=`${h+k+C/s*b}px`,s=/scaleX\(-1\)/.test(t.style.transform),v.left=`${u+(s?o-w-y:w)+(s?n-m-f:m)/n*y}px`,v.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await tt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!tt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=tt.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==tt.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,h=n&&n.width?n.width:t.videoWidth||t.width,f=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:h,n=n&&n.downScaledHeight?n.downScaledHeight:f,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,a,u,h,f,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await tt._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await tt._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return tt._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=tt._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}tt.DEFAULT_CANVAS_SIZE=400;tt.NO_QR_CODE_FOUND="No QR code found";tt._disableBarcodeDetector=!1;tt._workerMessageId=0;function h2({onResult:e,onClose:t}){const n=N.useRef(null),s=N.useRef(null),o=N.useRef(!1),[a,u]=N.useState("");N.useEffect(()=>{let f=!1;const m=n.current,v=S=>{f||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(p("qr-unsupported"));return}let S=!1;try{S=await tt.hasCamera()}catch{S=!1}if(!S){u(p("qr-no-camera"));return}if(f||!m)return;const y=new tt(m,b=>{const w=R_(b);w&&v(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const w=b.videoWidth||640,k=b.videoHeight||480,C=Math.max(1,Math.round(Math.min(w,k)*.92));return{x:Math.round((w-C)/2),y:Math.round((k-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(b){if(f)return;const w=b&&b.name||"";u(p(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{f=!0;const S=s.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}s.current=null}const y=m,b=y&&y.srcObject;if(b&&typeof b.getTracks=="function"){for(const w of b.getTracks())try{w.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const h=async f=>{const m=f.target.files&&f.target.files[0];if(f.target.value="",!!m)try{const v=await tt.scanImage(m,{returnDetailedScanResult:!0}),S=R_(v);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{u(p("pairing-qr-invalid"))}};return c.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:c.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:f=>f.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:p("scan-qr")})}),c.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&c.jsx("div",{className:"nc-err",role:"alert",children:a}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[p("qr-upload"),c.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:p("cancel")})]})]})})}const A_=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Gw({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:f}){const[m,v]=N.useState(A_),[S,y]=N.useState(!1),[b,w]=N.useState(!1),[k,C]=N.useState("idle"),[R,E]=N.useState(null),[F,I]=N.useState(""),[K,Y]=N.useState(!1),[z,Z]=N.useState(!1),G=N.useRef(o2()),Q=N.useRef(new Set),B=k==="busy",M=Ml(m.localLabel||s,o)||a,j=z?m.localName:M;N.useEffect(()=>(f&&f(B),()=>{f&&f(!1)}),[B,f]);const T=async D=>{const A=String(D.pairingUrl||"").trim();if(G.current.start(A)){C("busy"),E(null),I("");try{await j0(e,r2({...D,localName:z?D.localName:Ml(D.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),C("ok"),y(!1),v(A_()),Q.current=new Set,Y(!1),Z(!1),G.current.finish(),h&&await h()}catch(W){const X=l2(W);E(X),C("idle"),G.current.finish(),X.code==="peer-name-conflict"&&Yd(X.suggestedName)&&(Z(!0),Q.current.add("localName"),v(ie=>({...ie,localName:X.suggestedName}))),(X.stage==="validation"||X.stage==="conflict"||X.stage==="ssh-start"||X.stage==="ssh-ready"||String(X.code||"").startsWith("ssh-"))&&y(!0)}}},L=(D,A=!0)=>{const{classification:W,form:X}=P_(m,D,Q.current,K),ie=X.pairingUrl;if(E(null),I(""),k==="ok"&&C("idle"),v(X),W.kind==="invalid"){E({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(W.kind==="partial"){y(!0),I(W.missing.includes("ssh")?p("pair-missing-ssh"):p("pair-missing-name"));return}W.kind==="complete"&&A&&!u&&G.current.canAuto(ie)&&T(X)};N.useEffect(()=>{t&&L(t,n)},[]);const $=()=>{const D=String(m.pairingUrl||"").trim(),{classification:A,form:W}=P_(m,D,Q.current,K);if(v(W),I(""),E(null),A.kind==="empty"){E({stage:"validation",message:p("pairing-required"),retryable:!0});return}if(A.kind==="invalid"){E({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(!W.ssh||!W.name){y(!0),I(W.ssh?p("pair-missing-name"):p("pair-missing-ssh"));return}if(W.label&&!Ir(W.label)){E({stage:"validation",message:p("err-label"),retryable:!0});return}if(W.localLabel&&!Ir(W.localLabel)){E({stage:"validation",message:p("err-label"),retryable:!0});return}const X=z?W.localName:Ml(W.localLabel||s,o)||a;if(!Yd(X)||X==="localhost"){y(!0),E({stage:"validation",code:"bad-local-name",message:p("err-local-name"),retryable:!0});return}G.current.reset(D),T(W)},H=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const D=await navigator.clipboard.readText();D&&D.trim()?L(D):I(p("pair-clipboard-empty"))}catch{I(p("pair-clipboard-denied"))}},x=(D,A)=>{Q.current.add(D),v(W=>({...W,[D]:A}))},O=R&&R.stage&&(a2.includes(R.stage)||R.stage==="internal")?p(`pair-stage-${R.stage}`):p("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:p("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:p("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:p("pair-paste-ph"),value:m.pairingUrl,disabled:u||B,onChange:D=>{v({...m,pairingUrl:D.target.value}),E(null),I("")},onPaste:D=>{const A=D.clipboardData&&D.clipboardData.getData("text")||"";A.trim()&&(D.preventDefault(),L(A))},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),$())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:H,children:p("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:()=>w(!0),children:p("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||B,title:u?p("settings-readonly"):"",onClick:$,children:p("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[B&&c.jsx("div",{className:"nc-pair-progress",children:p("pair-progress")}),k==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:p("node-connected")}),F&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:F}),R&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:O})," — ",R.message,R.hint&&c.jsx("div",{className:"nc-pair-hint",children:R.hint}),R.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||B,onClick:$,children:p("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:B,onClick:()=>y(D=>!D),children:[S?"▾":"▸"," ",p("pair-advanced")]}),S&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[p("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:m.label,disabled:u||B,onChange:D=>{Q.current.add("label"),v(A=>({...A,label:D.target.value,name:K?A.name:vs(D.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[p("node-name-label"),c.jsx("input",{placeholder:p("node-name-ph"),value:m.name,disabled:u||B,onChange:D=>{Y(!0),Q.current.add("name"),v(A=>({...A,name:D.target.value?vs(D.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:p("node-slug-hint").replace("{slug}",m.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[p("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:m.ssh,disabled:u||B,onChange:D=>{Q.current.add("ssh"),x("ssh",D.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:p("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:p("node-ssh-port-help"),value:m.sshPort,disabled:u||B,onChange:D=>x("sshPort",D.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[p("device-name-label"),c.jsx("input",{placeholder:s||"NexusCrew",value:m.localLabel,disabled:u||B,onChange:D=>x("localLabel",D.target.value)}),c.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[p("local-route-name-label"),c.jsx("input",{placeholder:M||"nexuscrew-5bd6",value:j,disabled:u||B,onChange:D=>{Z(!0),Q.current.add("localName"),v(A=>({...A,localName:D.target.value?vs(D.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:p("local-route-name-hint")})]})]}),b&&c.jsx(h2,{onResult:D=>{w(!1),L(D)},onClose:()=>w(!1)})]})}const wi={routed:"peer-routed",routedStale:"peer-routed-stale",up:"tunnel-up",down:"tunnel-down",passive:"node-connected-client",vlOnline:"vl-poll-online",vlOffline:"vl-poll-offline"};function Df(e){if(!e||typeof e!="object")return{key:wi.down,up:!1};if(e.kind==="vl")return e.online?{key:wi.vlOnline,up:!0}:{key:wi.vlOffline,up:!1};if(e.kind==="transitive"){const n=e.stale===!0;return{key:n?wi.routedStale:wi.routed,up:!n,routed:!0}}const t=e.tunnel&&e.tunnel.status;return t==="up"?{key:wi.up,up:!0}:t==="passive"?{key:wi.passive,up:!1,passive:!0}:{key:wi.down,up:!1}}function Xw(e){if(!e||typeof e!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(e.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(e.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const t=e.visibility||"network";if(t==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:t};if(t==="selected"){const n=Array.isArray(e.selected)?e.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:t,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:t}}function f2(e){const n=e.health&&typeof e.health.detail=="string"&&e.health.detail.trim()||p(e.online?wi.vlOnline:wi.vlOffline);return e.ownerLabel?`${e.ownerLabel} · ${n}`:n}function p2(e){if(!e||typeof e!="object")return null;const t=typeof e.name=="string"?e.name:"";if(!t)return null;const n=e.kind==="transitive";return{name:t,title:typeof e.label=="string"&&e.label.trim()||t,subtitle:e.kind==="vl"?f2(e):t,reach:Df(e),exposure:Xw(e),routed:n,routeLabel:n&&Array.isArray(e.route)?e.route.join(" › "):null}}function m2(e){if(!e||typeof e!="object"||typeof e.name!="string"||!e.name)return null;const t=e.kind==="transitive";return{name:e.name,title:typeof e.label=="string"&&e.label.trim()||e.name,routed:t,route:t&&Array.isArray(e.route)?[...e.route]:null,ssh:!t&&e.direction==="outbound"&&e.ssh?String(e.ssh):null,inbound:!t&&e.direction==="inbound",transport:e.tunnel&&typeof e.tunnel.transport=="string"&&e.tunnel.transport||null}}function g2(e){return!e||typeof e!="object"?null:e.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function v2(e,t){if(!e||e.visibility!=="selected")return[];const n=[...new Set(Array.isArray(e.selected)?e.selected:[])],s=new Map;for(const o of Array.isArray(t)?t:[])o&&o.nodeId&&!s.has(o.nodeId)&&s.set(o.nodeId,o);return n.map(o=>{const a=s.get(o);return{id:o,label:a?typeof a.label=="string"&&a.label.trim()||a.name:o,known:!!a}})}function _2(e,t,n=""){if(!e)return[];const s=new Set(Array.isArray(e.selected)?e.selected:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[],h=f=>e.nodeId?f.nodeId===e.nodeId:f.name===e.name;for(const f of Array.isArray(t)?t:[]){if(!f||!f.nodeId||h(f)||s.has(f.nodeId)||a.has(f.nodeId))continue;const m=typeof f.label=="string"&&f.label.trim()||f.name;o&&!`${m} ${f.name}`.toLowerCase().includes(o)||(a.add(f.nodeId),u.push({id:f.nodeId,label:m,name:f.name}))}return u.sort((f,m)=>f.label.localeCompare(m.label))}function y2(e,{readonly:t=!1,busy:n=!1}={}){if(!e||typeof e!="object")return[];const s=e.actions&&typeof e.actions=="object"?e.actions:{},o=Df(e).up,a=[],u=(h,f,{mutating:m=!0,danger:v=!1}={})=>{a.push({key:h,action:f,danger:v,disabled:n||m&&t})};return s.edit&&u("edit","edit"),s.test&&u("node-test","test",{mutating:!1}),s.disconnect&&o&&u("tunnel-stop","down"),s.connect&&!o&&u("tunnel-start","up"),s.restart&&u("tunnel-restart","restart"),s.remove&&u("delete","remove",{danger:!0}),a}function Qw(e){const t=e&&typeof e.cellVisibility=="string"?e.cellVisibility:"all";return["all","none","selected"].includes(t)?t:"all"}function w2(e,t){if(Qw(e)!=="selected")return[];const n=[...new Set(Array.isArray(e.cells)?e.cells:[])];if(!Array.isArray(t))return n.map(o=>({id:o,label:o,known:!0}));const s=new Set(t.map(o=>typeof o=="string"?o:o&&(o.cell||o.id)).filter(Boolean));return n.map(o=>({id:o,label:o,known:s.has(o)}))}function b2(e,t,n=""){const s=new Set(Array.isArray(e&&e.cells)?e.cells:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[];for(const h of Array.isArray(t)?t:[]){const f=typeof h=="string"?h:h&&(h.cell||h.id);!f||s.has(f)||a.has(f)||o&&!f.toLowerCase().includes(o)||(a.add(f),u.push({id:f,label:f}))}return u.sort((h,f)=>h.label.localeCompare(f.label))}function S2(e,t,{readonly:n=!1,busy:s=!1}={}){const o=m2(e);return o?{identity:o,reach:Df(e),authority:g2(e),exposure:Xw(e),grants:v2(e,t),cellScope:Qw(e),actions:y2(e,{readonly:n,busy:s}),canEditVisibility:!!(e.actions&&e.actions.visibility)&&e.shared===!0&&e.kind!=="transitive",canEditCellScope:!!(e.actions&&e.actions.edit)&&e.kind!=="transitive"}:null}const x2=new Set(["update_candidate"]),T_=4096,k2=new Set(["prompt"]),D_={logs:{limit:50}};function C2(e){if(!e||e.kind!=="vl")return[];const t=Array.isArray(e.capabilities)?e.capabilities:[],n=new Set,s=[];for(const o of t)typeof o!="string"||!o||x2.has(o)||k2.has(o)||n.has(o)||(n.add(o),s.push(o));return s}function M_(e){return!!(e&&e.kind==="vl"&&Array.isArray(e.capabilities)&&e.capabilities.includes("prompt"))}function E2(e){return D_[e]?{...D_[e]}:{}}function N2(e,t){return e?e.inflight&&typeof e.inflight=="object"?{phase:"inflight",kind:e.inflight.kind}:t?e.lastAck&&e.lastAck.id===t.id?{phase:"done",kind:t.kind,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:{phase:"submitted",kind:t.kind}:e.lastAck&&typeof e.lastAck=="object"?{phase:"done",kind:null,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:null:null}function j2({title:e,subtitle:t,status:n,footer:s,onClose:o,plain:a=!1,children:u}){const h=N.useRef(null),f=N.useRef(null);return N.useEffect(()=>(f.current=document.activeElement,h.current&&h.current.focus(),()=>{const m=f.current;m&&typeof m.focus=="function"&&document.contains(m)&&m.focus()}),[]),N.useEffect(()=>{const m=v=>{v.key==="Escape"&&(v.stopPropagation(),o&&o())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[o]),c.jsx("div",{className:"nc-detail-overlay",onMouseDown:m=>{m.target===m.currentTarget&&o&&o()},children:c.jsxs("div",{className:"nc-detail-sheet",ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof e=="string"?e:void 0,children:[c.jsxs("div",{className:"nc-detail-head",children:[c.jsxs("div",{className:"nc-detail-title",children:[c.jsx("b",{children:e}),t&&c.jsx("small",{children:t})]}),n,c.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:o,"aria-label":p("close"),children:c.jsx(Ze,{name:"x",size:14})})]}),c.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:u}),s&&c.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Rr({title:e,hint:t,children:n}){return n==null||n===!1?null:c.jsxs("section",{className:"nc-detail-section",children:[e&&c.jsx("div",{className:"nc-sheet-label",children:e}),t&&c.jsx("small",{className:"nc-set-hint",children:t}),n]})}function R2({node:e,nodes:t,token:n,readonly:s,refresh:o,onClose:a}){var ke,Te;kn();const[u,h]=N.useState(null),[f,m]=N.useState(null),[v,S]=N.useState(null),[y,b]=N.useState(null),[w,k]=N.useState(!1),[C,R]=N.useState(""),[E,F]=N.useState(!1),[I,K]=N.useState(null),[Y,z]=N.useState(""),[Z,G]=N.useState(!1),[Q,B]=N.useState(null),[M,j]=N.useState(!1),[T,L]=N.useState(""),$=N.useMemo(()=>S2(e,t,{readonly:s,busy:!!u}),[e,t,s,u]);if(!$)return null;const{identity:H,reach:x,authority:O,exposure:D,grants:A,actions:W,canEditVisibility:X,canEditCellScope:ie,cellScope:ce}=$,fe=H.routed?{up:x.up,since:null}:Gd(e.tunnel,Date.now()),we=async(ae,re)=>{m(null),h(ae);try{await re()}catch(Pe){m(String(Pe&&Pe.message||Pe))}h(null)},me=ae=>{if(ae==="edit"){b({label:e.label||e.name,ssh:e.ssh||"",sshPort:e.sshPort?String(e.sshPort):"",autostart:e.autostart===!0,visibility:e.visibility||"network"});return}if(ae==="remove"){k(!0);return}we(`${e.name}:${ae}`,async()=>{const re=await ef(n,e.name,ae);ae==="test"&&S(re),await o()})},xe=(ae,re=E2(ae))=>we(`${e.nodeId}:${ae}`,async()=>{const Pe=await wg(n,e.nodeId,ae,re,e.route||[]);B({id:Pe.id,kind:ae,submittedAt:Date.now()}),await o()}),$e=()=>{const ae=T.trim().slice(0,T_);ae&&we(`${e.nodeId}:prompt`,async()=>{const re=await wg(n,e.nodeId,"prompt",{text:ae},e.route||[]);B({id:re.id,kind:"prompt",submittedAt:Date.now()}),L(""),j(!1),await o()})},ft=()=>{if(!Ir(y.label)){m(p("err-label"));return}const ae=H.inbound?{label:y.label,visibility:y.visibility,selected:y.visibility==="selected"?[...e.selected||[]]:[]}:{label:y.label,ssh:y.ssh,autostart:y.autostart,...y.sshPort?{sshPort:Number(y.sshPort)}:{}};return we(`${e.name}:edit`,async()=>{await xg(n,e.name,ae),b(null),await o()})},qe=(ae,re)=>we(`${e.name}:visibility`,async()=>{await D0(n,e.name,ae,re),await o()}),Ae=X&&e.visibility==="selected"?_2(e,t,C):[],Rt=(ae,re)=>we(`${e.name}:cell-scope`,async()=>{await xg(n,e.name,ae==="selected"?{cellVisibility:ae,cells:Array.isArray(re)?re:e.cells||[]}:{cellVisibility:ae}),await o()}),Vt=async()=>{if(I===null)try{const ae=await Jl(n);K(Array.isArray(ae&&ae.cells)?ae.cells:[])}catch{K([])}};N.useEffect(()=>{ie&&ce==="selected"&&I===null&&Vt()},[ie,ce,I]);const Oe=w2(e,I),Pt=ce==="selected"?b2(e,I,Y):[],bt=c.jsxs("span",{className:`nc-set-tunnel${x.up?" up":""}`,children:[p(x.key),fe.since?` · ${fe.since}`:""]}),dt=e.kind==="vl",ht=dt?C2(e):[],Qe=dt?N2(e,Q):null,ot=ae=>{const re=`vl-cmd-${ae}`,Pe=p(re);return Pe===re?ae:Pe},oe=dt?[...ht.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>xe(ae),children:ot(ae)},ae)),...M_(e)?[c.jsx("button",{type:"button",className:`nc-btn ghost${M?" on":""}`,disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>j(ae=>!ae),children:ot("prompt")},"prompt")]:[]]:W.map(ae=>c.jsx("button",{type:"button",className:`nc-btn ${ae.danger?"danger":"ghost"}`,disabled:ae.disabled,title:ae.disabled&&s?p("settings-readonly"):void 0,onClick:()=>me(ae.action),children:ae.action==="remove"?c.jsxs(c.Fragment,{children:[c.jsx(Ze,{name:"trash",size:14})," ",p(ae.key)]}):p(ae.key)},ae.action));return c.jsxs(j2,{title:H.title,subtitle:H.name,status:bt,footer:oe,onClose:a,children:[c.jsxs(Rr,{title:p("node-detail-reach"),children:[c.jsxs("dl",{className:"nc-detail-facts",children:[H.route&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-route")}),c.jsx("dd",{children:H.route.join(" › ")})]}),H.ssh&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-ssh")}),c.jsxs("dd",{children:[H.ssh,e.sshPort?`:${e.sshPort}`:""]})]}),H.transport&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-transport")}),c.jsx("dd",{children:H.transport})]}),dt&&e.ownerLabel&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:p("node-detail-owner")}),c.jsx("dd",{children:e.ownerLabel})]})]}),((ke=e.health)==null?void 0:ke.detail)&&c.jsx("div",{className:`nc-set-test${dt?e.health.state==="running"?" ok":e.health.state==="starting"?"":" ko":e.health.status==="healthy"?" ok":e.health.status==="passive"?"":" ko"}`,children:e.health.detail}),v&&c.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),dt&&c.jsxs(Rr,{title:p("node-detail-command"),children:[ht.length===0&&!M_(e)&&c.jsx("small",{className:"nc-set-hint",children:p("vl-no-commands")}),M&&c.jsxs("div",{className:"nc-vl-prompt",children:[c.jsx("textarea",{value:T,maxLength:T_,placeholder:p("vl-prompt-placeholder"),"aria-label":p("vl-prompt-placeholder"),disabled:!!u||s,onChange:ae=>L(ae.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!T.trim(),onClick:$e,children:p("vl-prompt-send")})]}),Qe&&c.jsxs("div",{className:`nc-set-test${Qe.phase==="done"?Qe.status==="ok"?" ok":" ko":""}`,children:[Qe.kind&&`${ot(Qe.kind)}: `,Qe.phase==="submitted"&&p("vl-cmd-phase-submitted"),Qe.phase==="inflight"&&p("vl-cmd-phase-inflight"),Qe.phase==="done"&&p(Qe.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),Qe.phase==="done"&&((Te=Qe.result)!=null&&Te.detail)?` — ${Qe.result.detail}`:""]})]}),c.jsxs(Rr,{title:p("node-detail-authority"),children:[c.jsx("div",{className:"nc-set-info",children:p(O.key)}),O.grants.length===0&&c.jsx("small",{className:"nc-set-hint",children:p(ie?"authority-no-grants":"authority-no-grants-elsewhere")})]}),c.jsxs(Rr,{title:p("node-detail-network-view"),children:[c.jsx("div",{className:"nc-set-info",children:p(dt?D.key:D.shared?"peer-shared":"peer-private")}),X&&c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),c.jsxs("select",{value:e.visibility||"network",disabled:s||!!u,onChange:ae=>qe(ae.target.value),children:[c.jsx("option",{value:"network",children:p("visibility-network")}),c.jsx("option",{value:"relay-only",children:p("visibility-relay")}),c.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}),e.visibility==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[A.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("node-grant-none")}),A.map(ae=>c.jsxs("div",{className:`nc-detail-grant${ae.known?"":" unknown"}`,children:[c.jsxs("span",{children:[ae.label,ae.known?"":` — ${p("node-grant-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>qe("selected",(e.selected||[]).filter(re=>re!==ae.id)),children:p("node-grant-remove")})]},ae.id)),!E&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{F(!0),R("")},children:p("node-grant-add")}),E&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:C,placeholder:p("node-grant-search"),disabled:s||!!u,onChange:ae=>R(ae.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[Ae.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("node-grant-no-candidates")}),Ae.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await qe("selected",[...e.selected||[],ae.id]),F(!1),R("")},children:ae.label},ae.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{F(!1),R("")},children:p("cancel")})]})]})]})]}),ie&&c.jsxs(Rr,{title:p("cell-scope"),children:[c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-help")}),c.jsx("label",{className:"nc-field",children:c.jsxs("select",{value:ce,disabled:s||!!u,onChange:ae=>{ae.target.value==="selected"&&Vt(),Rt(ae.target.value)},children:[c.jsx("option",{value:"all",children:p("cell-scope-all")}),c.jsx("option",{value:"none",children:p("cell-scope-none")}),c.jsx("option",{value:"selected",children:p("cell-scope-selected")})]})}),ce==="selected"&&Oe.length>0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-reset-warning")}),ce==="selected"&&c.jsxs("div",{className:"nc-detail-grants",children:[Oe.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-none-granted")}),Oe.map(ae=>c.jsxs("div",{className:`nc-detail-grant${ae.known?"":" unknown"}`,children:[c.jsxs("span",{children:[ae.label,ae.known?"":` — ${p("cell-scope-unknown")}`]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Rt("selected",(e.cells||[]).filter(re=>re!==ae.id)),children:p("node-grant-remove")})]},ae.id)),!Z&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Vt(),G(!0),z("")},children:p("cell-scope-add")}),Z&&c.jsxs("div",{className:"nc-detail-picker",children:[c.jsx("input",{value:Y,placeholder:p("cell-scope-search"),disabled:s||!!u,onChange:ae=>z(ae.target.value)}),c.jsxs("div",{className:"nc-detail-picker-list",children:[Pt.length===0&&c.jsx("small",{className:"nc-set-hint",children:p("cell-scope-no-candidates")}),Pt.map(ae=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Rt("selected",[...e.cells||[],ae.id]),G(!1),z("")},children:ae.label},ae.id))]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{G(!1),z("")},children:p("cancel")})]})]})]}),y&&c.jsxs(Rr,{title:p("edit"),children:[c.jsxs("label",{className:"nc-field",children:[p("node-display-label"),c.jsx("input",{value:y.label,disabled:!!u,onChange:ae=>b({...y,label:ae.target.value})})]}),H.inbound?c.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),c.jsxs("select",{value:y.visibility,disabled:!!u,onChange:ae=>b({...y,visibility:ae.target.value}),children:[c.jsx("option",{value:"network",children:p("visibility-network")}),c.jsx("option",{value:"relay-only",children:p("visibility-relay")}),c.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[p("node-ssh-label"),c.jsx("input",{value:y.ssh,disabled:!!u,onChange:ae=>b({...y,ssh:ae.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:y.sshPort,disabled:!!u,onChange:ae=>b({...y,sshPort:ae.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:y.autostart,disabled:!!u,onChange:ae=>b({...y,autostart:ae.target.checked})})," ",p("boot-persist")]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:ft,children:p("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>b(null),children:p("cancel")})]})]}),w&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:p("node-remove-confirm").replace("{name}",H.title)}),c.jsx("small",{children:p("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>we(`${e.name}:remove`,async()=>{await A0(n,e.name),k(!1),await o(),a&&a()}),children:p("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>k(!1),children:p("cancel")})]})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function Mf(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function P2(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function L2(){if(!Mf())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function A2(e){if(!Mf())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await Ht("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:P2(s)}),u=await Ht("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const h=await u.json().catch(()=>({}));throw new Error(h.error||`HTTP ${u.status}`)}return!0}async function T2(e){if(!Mf())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await Ht("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Fh="nexuscrew.fleet",Jw=3,D2="nexuscrew.cells",Zw=/^[A-Za-z0-9._-]{1,32}$/,cc=/^[a-z0-9._-]{1,32}$/,eb=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,tb=new Set(["standard","unsafe"]),M2=4096,I2=4096,Ql=256,nb=8192,O2=4096,B2=32,z2=64,F2=24,$2=new Set(["format","version","exportedAt","cells","engines"]),H2=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label"]),U2=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Ks(e){if(typeof e!="string"||e.length>I2)return null;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(e==="")return"";if(e.charAt(0)==="/"||/^[A-Za-z]:/.test(e))return null;const t=[];for(const n of e.split("/"))if(!(n===""||n===".")){if(n==="..")return null;t.push(n)}return t.join("/")}const W2=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),K2=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function Oi(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function If(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function Yo(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,a]of n){if(!cc.test(o)||!t(a))return null;s[o]=a}return s}function ib(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!H2.has(h))||!Zw.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=Ks(e.cwdRel);if(t===null||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const n=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof n!="string"||n.length>nb)return null;const s=Yo(e.models,h=>typeof h=="string"&&!!h&&h.length<=Ql),o=Yo(e.permissionPolicies,h=>tb.has(h)),a=Yo(e.commands,h=>Oi(h,O2)&&!If(h));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:n};if(e.model&&(u.model=e.model),e.label!==void 0){if(!Oi(e.label,z2)||!String(e.label).trim())return null;u.label=String(e.label).trim()}return Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function q2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!U2.has(a))||!Zw.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>M2||!cc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Ql)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>nb)return null;const n=Yo(e.models,a=>typeof a=="string"&&!!a&&a.length<=Ql),s=Yo(e.permissionPolicies,a=>tb.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function V2(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!K2.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!Oi(s,n==="baseUrl"?512:128)||If(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!eb.test(t.envKey)?null:t}function sb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!W2.has(s))||!cc.test(String(e.id||""))||!Oi(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=V2(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!Oi(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!Oi(s,1024)||If(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!Oi(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!Oi(e.model.flag,32)||/\s/.test(e.model.flag)||!Oi(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!eb.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function rb(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},n=sb(t);return n||null}function Y2(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const m of Array.isArray(e)?e:[]){if(!a.has(m.id))continue;const v=ib({id:m.id,cwdRel:m.cwdRel,engine:m.engine,boot:m.boot===!0,...m.label?{label:m.label}:{},...m.model?{model:m.model}:{},...m.models?{models:m.models}:{},...m.permissionPolicies?{permissionPolicies:m.permissionPolicies}:{},systemPrompt:m.prompt||"",...m.commands?{commands:m.commands}:{}});if(!v)return{ok:!1,error:"invalid-cell",invalidCellIds:[m.id]};h.push(v)}const f=[];for(const m of Array.isArray(n)?n:[]){if(!u.has(m.id))continue;const v=rb(m);v&&f.push(v)}return{format:Fh,version:Jw,exportedAt:o.toISOString(),cells:h,engines:f}}function G2(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===D2&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===Fh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===Fh&&(t==null?void 0:t.version)===Jw,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(S=>!$2.has(S))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>B2||u&&(!Array.isArray(t.engines)||t.engines.length>F2))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],f=new Set;for(const S of t.cells){const y=a?q2(S):ib(S);if(!y)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(f.has(y.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};f.add(y.id),h.push(y)}const m=[],v=new Set;for(const S of u?t.engines:[]){const y=sb(S);if(!y)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(y.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(y.id),m.push(y)}return{ok:!0,cells:h,engines:m,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function X2(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([v])=>s.has(v))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.label=="string"&&e.label&&(a.label=e.label),typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),h=o(e.permissionPolicies),f=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),Object.keys(f).length&&(a.commands=f),a}const Q2=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",credentialSourcePolicy:"auto",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),I_=(e="")=>({id:"",cwd:"",engine:e,boot:!1,label:"",model:"",prompt:"",commands:{},command:""}),ob=e=>e==="claude"?"unsafe":"standard",Zo=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),J2=(e,t)=>{var n;return((n=Zo(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function Z2(e){var t,n,s,o,a,u,h,f,m,v,S,y,b,w,k;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
89
89
  `),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||ob((u=e.managed)==null?void 0:u.client),credentialSourcePolicy:((h=e.managed)==null?void 0:h.credentialSourcePolicy)||"auto",displayName:((f=e.managed)==null?void 0:f.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((v=e.managed)==null?void 0:v.baseUrl)||"",envKey:((S=e.managed)==null?void 0:S.envKey)||"",providerId:((y=e.managed)==null?void 0:y.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((b=e.managedInfo)==null?void 0:b.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((w=e.model)==null?void 0:w.flag)||"",modelValue:((k=e.model)==null?void 0:k.value)||"",envRows:(e.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function ej(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.client==="shell"?"":e.managedModel||"",permissionPolicy:e.client==="shell"?"standard":e.permissionPolicy||ob(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile),e.credentialSourcePolicy&&e.credentialSourcePolicy!=="auto"&&(o.credentialSourcePolicy=e.credentialSourcePolicy);const a=Zo(n,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||J2(n,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
90
90
  `).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function $s({children:e,onClose:t,label:n,error:s=""}){const o=N.useRef(null),a=N.useRef(null),u=N.useRef(t);return u.current=t,N.useEffect(()=>{const h=document.activeElement,f=o.current,m=()=>Array.from((f==null?void 0:f.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),v=requestAnimationFrame(()=>{var y;return(y=m()[0]||f)==null?void 0:y.focus({preventScroll:!0})}),S=y=>{var C;if(y.key==="Escape"){y.preventDefault(),(C=u.current)==null||C.call(u);return}if(y.key!=="Tab")return;const b=m();if(!b.length){y.preventDefault(),f==null||f.focus();return}const w=b[0],k=b[b.length-1];y.shiftKey&&document.activeElement===w?(y.preventDefault(),k.focus()):!y.shiftKey&&document.activeElement===k&&(y.preventDefault(),w.focus())};return document.addEventListener("keydown",S),()=>{cancelAnimationFrame(v),document.removeEventListener("keydown",S),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),N.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),c.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:c.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||p("settings"),tabIndex:-1,children:[e,s&&c.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function Fd({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[a,u]=N.useState([]),[h,f]=N.useState(0);N.useEffect(()=>{let C=!0;async function R(){const F=[{route:[],label:p("local")}].concat((t||[]).map(K=>({route:Array.isArray(K.route)?K.route:[],label:K.label||(K.route||[]).join(" › ")}))),I=await Promise.all(F.map(async K=>{const Y={...K,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const z=await ws(e,K.route);Y.available=!!z.available,Y.capabilities=z.capabilities||[],Y.provider=z.provider||null,Y.cells=(z.cells||[]).map(Z=>({...Z,route:K.route}));try{Y.readonly=!!(await Zh(e,K.route)).readonlyDefault}catch{}try{const Z=await Jh(e,K.route),G=new Set(Y.cells.map(Q=>Q.tmuxSession).filter(Boolean));Y.unmanaged=(Z.sessions||[]).filter(Q=>Q&&!G.has(Q.name))}catch{}}catch(z){Y.err=String(z&&z.message||z)}return Y}));C&&u(I)}R();const E=setInterval(R,6e3);return()=>{C=!1,clearInterval(E)}},[e,t,h]);const m=(C,R)=>Array.isArray(C.capabilities)&&C.capabilities.includes(R)&&!n&&!C.readonly,v=()=>f(C=>C+1),S=(C,R)=>{s&&s({...C,route:R})},y=(C,R)=>{s&&s({...C,route:R})},b=async(C,R)=>{try{await Fo(e,C.cell,R)}catch{}v()},w=async(C,R)=>{if(window.confirm(p("fleet-remove-cell").replace("{id}",C.cell))){try{await Z_(e,C.cell,!0,R)}catch{}v()}},k=async(C,R)=>{if(window.confirm(p("terminate-confirm").replace("{name}",C.name))){try{await Xh(e,C.name,R)}catch{}v()}};return c.jsxs("div",{className:"nc-fleet-inventory",children:[c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:p("fleet-inventory")}),c.jsx("small",{children:p("fleet-inventory-help")})]}),a.map(C=>{const R=C.route.length?C.route.join("/"):"local";return c.jsxs("div",{className:"nc-fleet-pos",children:[c.jsxs("div",{className:"nc-fleet-pos-title",children:[c.jsx("span",{className:`dot ${C.available?"on":"warn"}`}),c.jsx("b",{children:C.label}),c.jsx("small",{children:C.available?`${C.cells.length} ${p("fleet-cells")} · ${C.unmanaged.length} ${p("fleet-tmux")}`:C.err||p("fleet-not-available")})]}),C.cells.map(E=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[c.jsxs("span",{children:[c.jsx("b",{children:E.cell}),c.jsx("small",{children:`${E.engine||""}${E.key?`·${E.key}`:""}${E.active?"":` · ${p("cell-off")}`}`})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[E.active&&m(C,"down")&&c.jsx("button",{className:"nc-btn ghost",title:p("power-off"),onClick:()=>y(E,C.route),children:p("stop")}),!E.active&&m(C,"up")&&c.jsx("button",{className:"nc-btn ghost",title:p("power-on"),onClick:()=>S(E,C.route),children:p("start")}),m(C,"restart")&&E.active&&c.jsx("button",{className:"nc-btn ghost",title:p("restart"),onClick:()=>b(E,C.route),children:p("restart")}),m(C,"remove")&&c.jsx("button",{className:"nc-btn danger",title:p("delete"),onClick:()=>w(E,C.route),children:"×"})]})]},`${R}:${E.cell}`)),C.unmanaged.map(E=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[c.jsxs("span",{children:[c.jsx("b",{children:E.name}),c.jsx("small",{children:p("fleet-tmux")})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(C,"import")&&o&&c.jsx("button",{className:"nc-btn ghost",title:p("import-as-cell"),onClick:()=>o(E,C.route),children:p("import-as-cell")}),c.jsx("button",{className:"nc-btn danger",title:p("terminate"),onClick:()=>k(E,C.route),children:"×"})]})]},`${R}:u:${E.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&c.jsx("div",{className:"nc-empty",children:p("fleet-inventory-empty")})]},R)})]})}function tj({cells:e=[],engines:t=[],busy:n,canRestore:s=!1,onRestore:o,onClose:a}){const[u,h]=N.useState("export"),[f,m]=N.useState(()=>new Set(e.map(j=>j.id))),[v,S]=N.useState(()=>new Set(t.map(j=>j.id))),[y,b]=N.useState([]),[w,k]=N.useState([]),[C,R]=N.useState(""),E=new Set(t.map(j=>j.id)),F=new Set(e.map(j=>j.id)),I=(j,T)=>j(L=>{const $=new Set(L);return $.has(T)?$.delete(T):$.add(T),$}),K=()=>{const j=Y2(e,f,t,v);if(j.ok===!1){R(p(`fleet-backup-${j.error}`));return}const T=e.filter(O=>f.has(O.id)).length,L=t.filter(O=>v.has(O.id)).length;if(j.cells.length!==T){R(p("fleet-backup-invalid-cell"));return}if(j.engines.length!==L){R(p("fleet-backup-invalid-engine"));return}if(!j.cells.length&&!j.engines.length){R(p("fleet-backup-select-one"));return}const $=new Blob([`${JSON.stringify(j,null,2)}
91
- `],{type:"application/json"}),H=URL.createObjectURL($),x=document.createElement("a");x.href=H,x.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(x),x.click(),x.remove(),setTimeout(()=>URL.revokeObjectURL(H),0),R("")},Y=async j=>{if(R(""),b([]),k([]),!!j){if(j.size>1024*1024){R(p("fleet-backup-too-large"));return}try{const T=G2(await j.text());if(!T.ok){R(p(`fleet-backup-${T.error}`));return}const L=new Set(T.engines.map($=>$.id));k(T.engines.map($=>({engine:$,exists:E.has($.id),selected:!E.has($.id)}))),b(T.cells.map($=>{const H=E.has($.engine)||L.has($.engine),x=F.has($.id);return{cell:$,engine:H?$.engine:"",selected:H&&!x,exists:x}}))}catch(T){R(String(T.message||T))}}},z=(j,T)=>b(L=>L.map(($,H)=>H===j?{...$,...T}:$)),Z=(j,T)=>k(L=>L.map(($,H)=>H===j?{...$,...T}:$)),G=new Set([...E,...w.filter(j=>j.selected).map(j=>j.engine.id)]),Q=y.filter(j=>j.selected&&j.engine&&G.has(j.engine)),B=w.filter(j=>j.selected),M=[...new Map([...t.map(j=>[j.id,j.label||j.id]),...w.filter(j=>j.selected).map(j=>[j.engine.id,j.engine.label||j.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:p("fleet-backup")}),c.jsx("small",{children:p("fleet-backup-help")}),c.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),R("")},children:p("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":p("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),R("")},children:p("fleet-backup-import")})]}),u==="export"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set(e.map(j=>j.id))),S(new Set(t.map(j=>j.id)))},children:p("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),S(new Set)},children:p("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:p("fleet-engines")}),t.map(j=>{var T;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:v.has(j.id),onChange:()=>I(S,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.label||j.id}),c.jsxs("small",{children:[j.id,(T=j.envKeys)!=null&&T.length?` · ${j.envKeys.length} ${p("fleet-backup-env-names")}`:""]})]})]},j.id)}),c.jsx("b",{children:p("fleet-cells")}),e.map(j=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:f.has(j.id),onChange:()=>I(m,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.id}),c.jsxs("small",{children:[j.engine," · ",p("fleet-system-prompt")," ",(j.prompt||"").length," ",p("characters")]})]})]},j.id)),!e.length&&!t.length&&c.jsx("div",{className:"nc-empty",children:p("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!f.size&&!v.size,onClick:K,children:p("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:j=>Y(j.target.files&&j.target.files[0])}),c.jsx("small",{children:p("fleet-backup-import-help")}),!!(y.length||w.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(j=>j.map(T=>({...T,selected:!0}))),b(j=>j.map(T=>({...T,selected:!!T.engine})))},children:p("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(j=>j.map(T=>({...T,selected:!1}))),b(j=>j.map(T=>({...T,selected:!1})))},children:p("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&c.jsx("b",{children:p("fleet-engines")}),w.map((j,T)=>{var L;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,onChange:$=>Z(T,{selected:$.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.engine.label||j.engine.id}),c.jsxs("small",{children:[j.engine.id," · ",j.exists?p("fleet-backup-overwrite"):p("fleet-backup-new"),(L=j.engine.envKeys)!=null&&L.length?` · ${p("fleet-backup-env-values-required")}`:""]})]})]})},j.engine.id)}),!!y.length&&c.jsx("b",{children:p("fleet-cells")}),y.map((j,T)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,disabled:!j.engine||!G.has(j.engine),onChange:L=>z(T,{selected:L.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.cell.id}),c.jsxs("small",{children:[j.exists?p("fleet-backup-overwrite"):p("fleet-backup-new")," · ",p("fleet-system-prompt")," ",j.cell.systemPrompt.length," ",p("characters")]})]})]}),c.jsxs("select",{value:j.engine,onChange:L=>z(T,{engine:L.target.value,selected:!!L.target.value}),children:[c.jsx("option",{value:"",children:p("fleet-backup-engine-missing")}),M.map(([L,$])=>c.jsx("option",{value:L,children:$},L))]})]},j.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!Q.length&&!B.length,onClick:()=>o({engineRows:w,cellRows:y}),children:p("fleet-backup-restore")})]})]}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function nj({state:e,setState:t,busy:n,onSave:s,catalog:o}){var R;const a=e.form,u=E=>t({...e,form:{...a,...E}}),h=a.envRows||[],f=[...new Map(o.map(E=>[E.client,E.clientLabel||E.client])).entries()],m=o.filter(E=>E.client===a.client),v=Zo(o,a),S=typeof(v==null?void 0:v.credentialEnv)=="string"?v.credentialEnv:"",y=Array.isArray(v==null?void 0:v.credentialUsedBy)?v.credentialUsedBy:[],b=(v==null?void 0:v.credentialSource)||"missing",w=!!(v!=null&&v.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",k=!!S&&e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,C=E=>{E&&u({client:E.client,provider:E.provider,credentialProfile:E.credentialProfile||"",managedModel:E.model||"",protocol:E.protocol||"",permissionPolicy:E.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!E.rc,displayName:E.custom?p("fleet-custom-provider-default"):"",baseUrl:E.custom?"":E.endpoint||"",envKey:E.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:E.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:e.mode==="new"?p("fleet-new-engine"):`${p("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:E=>u({id:E.target.value})}),c.jsx("input",{value:a.label,placeholder:p("label"),onChange:E=>u({label:E.target.value})}),c.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:E=>u({kind:E.target.value}),children:[c.jsx("option",{value:"managed",children:p("fleet-managed")}),c.jsx("option",{value:"custom",children:p("fleet-custom")})]}),a.kind==="managed"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:E=>C(o.find(F=>F.client===E.target.value&&F.default)||o.find(F=>F.client===E.target.value)),children:f.map(([E,F])=>c.jsx("option",{value:E,children:F},E))}),c.jsx("select",{value:((R=Zo(o,a))==null?void 0:R.id)||"",disabled:e.mode!=="new",onChange:E=>C(o.find(F=>F.id===E.target.value)),children:m.map(E=>c.jsx("option",{value:E.id,children:E.label},E.id))})]}),a.client!=="shell"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:p(v!=null&&v.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:E=>u({managedModel:E.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(v==null?void 0:v.models)||[],...a.modelOptions||[]].filter((E,F,I)=>E&&I.indexOf(E)===F).map(E=>c.jsx("option",{value:E},E))})]}),v!=null&&v.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:E=>u({permissionPolicy:E.target.value}),children:[c.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]}):c.jsx("small",{children:p("fleet-standard-permissions")}),(v==null?void 0:v.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),w&&c.jsxs("select",{"aria-label":p("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:E=>u({credentialSourcePolicy:E.target.value}),children:[c.jsx("option",{value:"auto",children:p("fleet-credential-source-policy-auto")}),c.jsx("option",{value:"nexuscrew-store",children:p("fleet-credential-source-policy-nexuscrew-store")}),c.jsx("option",{value:"environment",children:p("fleet-credential-source-policy-environment")})]}),(v==null?void 0:v.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:E=>u({envKey:E.target.value})}),c.jsx("small",{children:p("fleet-custom-secret-help")})]}),S&&c.jsxs("section",{className:"nc-fleet-key","aria-label":p("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:p("fleet-key-section")}),c.jsx("span",{children:p(`fleet-credential-source-${b}`)})]}),c.jsxs("label",{className:"nc-field",children:[p("fleet-key-variable"),c.jsx("input",{value:S,readOnly:!0,"aria-label":p("fleet-key-variable")})]}),c.jsx("small",{children:y.length?p("fleet-key-used-by").replace("{engines}",y.join(", ")):p("fleet-key-used-by-none")}),y.length>0&&c.jsx("small",{children:p("fleet-key-shared-impact").replace("{key}",S).replace("{engines}",y.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":p("fleet-key-value").replace("{key}",S),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:v!=null&&v.authConfigured||e.mode==="edit"?p("fleet-key-blank-keeps"):p("fleet-key-enter"),onChange:E=>u({credentialValue:E.target.value,allowMissingCredential:E.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:p("fleet-key-local-help")}),e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&c.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[c.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:E=>u({allowMissingCredential:E.target.checked})}),p("fleet-key-create-missing")]}),(v==null?void 0:v.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${v.notice}`)})]}),(v==null?void 0:v.notice)&&!S&&c.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${v.notice}`)}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:p("fleet-provider-display"),onChange:E=>u({displayName:E.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:E=>u({baseUrl:E.target.value})}),((v==null?void 0:v.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:E=>u({protocol:E.target.value}),children:v.protocols.map(E=>c.jsx("option",{value:E,children:E},E))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:E=>u({envKey:E.target.value})}),c.jsx("input",{value:a.providerId,placeholder:p("fleet-provider-id"),onChange:E=>u({providerId:E.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",p("fleet-custom-secret-help")]})]}),c.jsx("small",{children:p(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:p("command-path"),onChange:E=>u({command:E.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:p("args-lines"),onChange:E=>u({argsText:E.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:E=>u({rc:E.target.checked})})," remote control"]}),c.jsxs("select",{value:a.promptMode,onChange:E=>u({promptMode:E.target.value}),children:[c.jsx("option",{value:"send-keys",children:"send-keys"}),c.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&c.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:E=>u({promptFlag:E.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:E=>u({modelFlag:E.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:E=>u({modelValue:E.target.value})})]}),c.jsx("small",{children:p("env-write-only")}),h.map((E,F)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:E.key,disabled:E.configured,placeholder:"ENV_KEY",onChange:I=>{const K=h.slice();K[F]={...E,key:I.target.value},u({envRows:K})}}),c.jsx("input",{type:"password",value:E.value,placeholder:E.configured?"•••••• (unchanged)":"value",onChange:I=>{const K=h.slice();K[F]={...E,value:I.target.value},u({envRows:K})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((I,K)=>K!==F)}),children:"×"})]},`${E.key}-${F}`)),c.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||k||a.kind==="custom"&&!a.command||a.kind==="managed"&&(v==null?void 0:v.requiresModel)&&!a.managedModel||a.kind==="managed"&&(v==null?void 0:v.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:p("save")})]})]})}function ij({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:h,busy:f,onSave:m}){var Y;const[v,S]=N.useState(null),[y,b]=N.useState(""),w=a.form,k=z=>u({...a,form:{...w,...z}}),C=h.find(z=>z.id===w.engine),R=((Y=C==null?void 0:C.managed)==null?void 0:Y.client)==="shell",E=z=>{var Q,B,M,j;const Z=h.find(T=>T.id===z),G={...w.commands||{}};((Q=C==null?void 0:C.managed)==null?void 0:Q.client)==="shell"&&(w.command?G[w.engine]=w.command:delete G[w.engine]),k({engine:z,model:((B=w.models)==null?void 0:B[z])||((M=Z==null?void 0:Z.managed)==null?void 0:M.model)||((j=Z==null?void 0:Z.model)==null?void 0:j.value)||"",commands:G,command:G[z]||""})},F=z=>{const Z={...w.commands||{}};z?Z[w.engine]=z:delete Z[w.engine],k({command:z,commands:Z})},I=R&&/[|&;<>()`$*?{}\[\]~]/.test(w.command||""),K=async z=>{try{const Z=await Qh(e,z,t);S(Z),k({cwd:Z.path}),b("")}catch(Z){b(String(Z.message||Z))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?p("fleet-new-cell"):`${p("edit")} ${w.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[p("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:s,onChange:z=>{o(z.target.value),k({engine:""})},children:[c.jsx("option",{value:"",children:p("local")}),n.map(z=>c.jsxs("option",{value:z.route.join("/"),disabled:z.status&&z.status!=="up",children:[z.label,z.status&&z.status!=="up"?` · ${p("node-offline")}`:""]},z.route.join("/")))]})]}),c.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:z=>k({id:z.target.value})}),c.jsx("input",{value:w.label||"",maxLength:64,placeholder:p("fleet-cell-label"),onChange:z=>k({label:z.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:w.cwd,placeholder:p("cwd"),onChange:z=>k({cwd:z.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>v?S(null):K(w.cwd),children:p("browse")})]}),v&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:v.path}),c.jsxs("div",{className:"nc-fs-list",children:[v.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>K(v.parent),children:["↑ ",p("fs-parent")]}),(v.dirs||[]).map(z=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>K(`${v.path.replace(/\/$/,"")}/${z}`),children:["📁 ",z]},z))]})]}),y&&c.jsx("div",{className:"nc-err",children:y}),c.jsx("select",{value:w.engine,onChange:z=>E(z.target.value),children:h.map(z=>c.jsx("option",{value:z.id,children:z.label},z.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:z=>k({boot:z.target.checked})})," boot"]}),R?c.jsxs(c.Fragment,{children:[c.jsx("input",{value:w.command||"",maxLength:4096,placeholder:p("fleet-shell-command-placeholder"),onChange:z=>F(z.target.value)}),c.jsx("small",{children:w.command?p("fleet-shell-command-help"):p("fleet-shell-interactive")}),I&&c.jsx("small",{className:"nc-note",children:p("fleet-shell-command-metachar")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:p("fleet-model-override"),onChange:z=>k({model:z.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(z=>c.jsx("option",{value:z},z))}),c.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:z=>k({prompt:z.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:f||!w.id||!w.cwd||!w.engine,onClick:m,children:p("save")})]})]})}function O_({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,h]=N.useState(null),[f,m]=N.useState([]),[v,S]=N.useState(""),y=Array.isArray(t)?t.join("/"):"";N.useEffect(()=>{let R=!0;return Jl(e,y?y.split("/"):[]).then(E=>{R&&(m(E.engines||[]),S(""))}).catch(E=>{R&&(m([]),S(String(E.message||E)))}),()=>{R=!1}},[e,y]);const b=n.form,w=R=>s({...n,form:{...b,...R}}),k=async R=>{try{const E=await Qh(e,R,t);h(E),w({cwd:E.path})}catch{}},C=!b.id&&b.tmuxSession?b.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):b.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[p("import-as-cell")," · ",b.tmuxSession]}),c.jsx("small",{children:p("import-help")}),c.jsx("input",{value:b.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:b.id,placeholder:p("name"),onChange:R=>w({id:R.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:b.cwd,placeholder:p("cwd"),onChange:R=>w({cwd:R.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):k(b.cwd),children:p("browse")})]}),u&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:u.path}),c.jsxs("div",{className:"nc-fs-list",children:[u.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>k(u.parent),children:["↑ ",p("fs-parent")]}),(u.dirs||[]).map(R=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>k(`${u.path.replace(/\/$/,"")}/${R}`),children:["📁 ",R]},R))]})]}),c.jsxs("select",{value:b.engine,onChange:R=>w({engine:R.target.value}),children:[c.jsx("option",{value:"",children:p("import-engine-required")}),f.map(R=>c.jsx("option",{value:R.id,children:R.label},R.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:R=>w({boot:R.target.checked})})," boot"]}),(n.err||v)&&c.jsx("div",{className:"nc-err",children:n.err||v}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:o||!b.tmuxSession||!b.engine||!f.length,onClick:a,children:p(C?"import-as-cell":"save")})]})]})}function El(e){const t=Ks(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function sj(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:n}=e;return!n||t===n||!t.startsWith(n+"/")?"":t.slice(n.length+1).replace(/\/+$/,"")}function rj({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=N.useState(""),[f,m]=N.useState(null),[v,S]=N.useState(!1),[y,b]=N.useState(""),w=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Ks(n.cwdSuggestion)!==null?Ks(n.cwdSuggestion):null,[k,C]=N.useState(w),R=n==null?void 0:n.id,E=s||v,F=async G=>{const Q=Ks(G);if(Q===null){m({rel:"",dirs:[],loading:!1,err:p("fleet-cwd-repair-invalid")});return}m({rel:Q,dirs:[],loading:!0,err:""});try{const B=await Qh(e,Q,t),M=sj(B);m({rel:M,dirs:Array.isArray(B.dirs)?B.dirs:[],loading:!1,err:""})}catch(B){m({rel:Q,dirs:[],loading:!1,err:String(B&&B.message||B)})}},I=G=>{if(!f)return;const Q=f.rel?`${f.rel}/${G}`:G;F(Q)},K=()=>{f!=null&&f.rel&&F(f.rel.split("/").slice(0,-1).join("/"))},Y=()=>{f&&(h(f.rel||""),m(null),b(""),C(null))},z=()=>{k!==null&&(h(k),C(null),b(""))},Z=async()=>{if(E)return;const G=Ks(u);if(G===null){b(p("fleet-cwd-repair-invalid"));return}const Q=El(G);let B=!0;try{B=window.confirm(p("fleet-cwd-repair-confirm").replace("{id}",String(R||"")).replace("{path}",Q))}catch{B=!1}if(B){S(!0),b(""),C(null);try{const M=await J_(e,R,{cwdRel:G},t);o==null||o(M)}catch(M){const j=M&&M.data||{};if(j.code==="unportable-cwd"){b(p("fleet-cwd-repair-unportable"));const T=Array.isArray(j.cells)?j.cells.find($=>$&&$.id===R):null,L=T&&typeof T.suggestion=="string"?T.suggestion:null;L!==null&&Ks(L)!==null&&C(L)}else b(String(M&&M.message||M))}finally{S(!1)}}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[c.jsx("b",{children:p("fleet-cwd-repair-title").replace("{id}",String(R||""))}),c.jsx("small",{className:"nc-set-info",children:p("fleet-cwd-repair-help")}),c.jsx("small",{className:"nc-cwd-no-source",children:p("fleet-cwd-repair-no-source-path")}),c.jsxs("label",{className:"nc-field",children:[p("cwd"),c.jsxs("div",{className:"nc-cwd-rel-row",children:[c.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),c.jsx("input",{value:u,placeholder:p("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:G=>h(G.target.value)}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:E,onClick:()=>f?m(null):F(""),children:p(f?"close":"fleet-cwd-repair-browse")})]})]}),c.jsx("div",{className:"nc-cwd-preview",children:p("fleet-cwd-repair-preview").replace("{path}",El(u))}),f&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:El(f.rel)}),c.jsxs("div",{className:"nc-fs-list",children:[f.rel&&c.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:K,children:["↑ ",p("fs-parent")]}),f.loading&&c.jsx("div",{className:"nc-fs-empty",children:"…"}),!f.loading&&f.dirs.length===0&&c.jsx("div",{className:"nc-fs-empty",children:p("fleet-cwd-repair-fs-empty")}),!f.loading&&f.dirs.map(G=>c.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>I(G),children:["📁 ",G]},G))]}),f.err&&c.jsx("div",{className:"nc-err",children:f.err}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{type:"button",className:"nc-btn primary",disabled:E||f.loading||!!f.err,onClick:Y,children:p("fleet-cwd-repair-use-current")})})]}),y&&c.jsx("div",{className:"nc-err",role:"alert",children:y}),k!==null&&c.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[c.jsx("span",{children:p("fleet-cwd-repair-suggestion")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:z,children:p("fleet-cwd-repair-use-suggestion").replace("{path}",El(k))})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:E,onClick:Z,children:v?"…":p("save")})]})]})}function oj({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=N.useState({engines:[],cells:[],managedCatalog:[]}),[h,f]=N.useState({available:!1,capabilities:[]}),[m,v]=N.useState(!1),[S,y]=N.useState(null),[b,w]=N.useState(null),[k,C]=N.useState(!1),[R,E]=N.useState(""),[F,I]=N.useState(""),[K,Y]=N.useState(o),[z,Z]=N.useState(!1),[G,Q]=N.useState(null),[B,M]=N.useState(null),[j,T]=N.useState(null),[L,$]=N.useState(!1),[H,x]=N.useState([]),[O,D]=N.useState(null),[A,W]=N.useState("manage"),X=N.useRef(!1),ie=K?K.split("/"):[],ue=N.useCallback(async()=>{try{const oe=await ws(e,ie);f(oe);try{const ke=await Zh(e,ie);Z(!!ke.readonlyDefault)}catch{Z(!1)}if(oe.provider==="builtin"&&(oe.capabilities||[]).includes("definitions")){const ke=await Jl(e,ie),Te=new Map((oe.engines||[]).map(ae=>[ae.id,ae]));if(ke.engines=(ke.engines||[]).map(ae=>{var re;return{...ae,availableModels:((re=Te.get(ae.id))==null?void 0:re.models)||[]}}),u(ke),(oe.capabilities||[]).includes("credentials"))try{x((await m0(e,ie)).credentials||[])}catch{x([])}else x([])}E("")}catch(oe){E(String(oe.message||oe))}finally{v(!0)}},[e,K]);N.useEffect(()=>{ue();const oe=setInterval(ue,5e3);return()=>clearInterval(oe)},[ue]);const fe=new Set((h.cells||[]).filter(oe=>oe.active).map(oe=>oe.cell)),we=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),me=(h.capabilities||[]).includes("restore");N.useEffect(()=>{!s||X.current||!we||!a.engines.length||(X.current=!0,w({mode:"new",form:I_(a.engines[0].id)}))},[s,we,a.engines]);const xe=async oe=>{C(!0),E(""),I("");try{await oe(),await ue()}catch(ke){E(String(ke.message||ke))}C(!1)},$e=()=>xe(async()=>{var ge;const oe=S.mode==="new",ke=S.form,Te=a.managedCatalog||[],ae=ke.kind==="managed"?Zo(Te,ke):null,re=typeof(ae==null?void 0:ae.credentialEnv)=="string"?ae.credentialEnv:"",Pe=re&&ke.credentialValue||"",q=ej(ke,oe,Te);!oe&&S.form.kind==="custom"&&!S.form.modelFlag&&(q.model=null),!oe&&S.form.kind==="custom"&&S.form.promptMode!=="flag"&&(q.promptFlag=null);let te;if(oe)te=await v0(e,q,ie);else{const De=S.original,_e=new Set(S.form.envRows.filter(at=>!at.remove).map(at=>at.key)),Ee=(De.envKeys||[]).filter(at=>!_e.has(at)),nt=Object.fromEntries(S.form.envRows.filter(at=>!at.remove&&at.key&&(!at.configured||at.value!=="")).map(at=>[at.key,at.value]));te=await _0(e,De.id,q,S.form.kind==="custom"?{set:nt,remove:Ee}:void 0,ie)}let U=null;if(re&&Pe)try{U=await yg(e,re,Pe,ie),x(U.credentials||[])}catch{throw await ue(),oe&&y({mode:"edit",original:{...q,id:ke.id},form:{...ke,credentialReveal:!1}}),new Error(p(oe?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ue(),y(null),I(p("fleet-saved"));const ce=((ge=((U==null?void 0:U.credentials)||[]).find(De=>De.envKey===re))==null?void 0:ge.activeCells)||[],de=[...new Set([...(te==null?void 0:te.activeCells)||[],...ce])];if(de.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",de.join(", "))))for(const De of de)await Fo(e,De,ie)}),ft=()=>xe(async()=>{var U,ce,de,ge,De,_e;const oe=b.mode==="new",ke=b.form,Te={...oe?{id:ke.id}:{},cwd:ke.cwd,engine:ke.engine,boot:!!ke.boot},ae={...ke.commands||{}},re=a.engines.find(Ee=>Ee.id===ke.engine);((U=re==null?void 0:re.managed)==null?void 0:U.client)==="shell"&&typeof ke.command=="string"&&ke.command.length?ae[ke.engine]=ke.command:((ce=re==null?void 0:re.managed)==null?void 0:ce.client)==="shell"&&delete ae[ke.engine],(Object.keys(ae).length||!oe)&&(Te.commands=ae);const Pe=(ke.label||"").trim();oe?Pe&&(Te.label=Pe):Te.label=Pe||null,oe?(((de=re==null?void 0:re.managed)==null?void 0:de.client)!=="shell"&&ke.model&&(Te.model=ke.model),((ge=re==null?void 0:re.managed)==null?void 0:ge.client)!=="shell"&&ke.prompt&&(Te.prompt=ke.prompt)):(Te.model=((De=re==null?void 0:re.managed)==null?void 0:De.client)==="shell"?null:ke.model||null,((_e=re==null?void 0:re.managed)==null?void 0:_e.client)!=="shell"&&(Te.prompt=ke.prompt||null));const q=oe?await w0(e,Te,ie):await J_(e,b.original.id,Te,ie),te=oe?ke.id:b.original.id;w(null),I(p("fleet-saved")),!oe&&(q!=null&&q.active)&&window.confirm(p("fleet-restart-confirm").replace("{cells}",te))&&await Fo(e,te,ie)}),qe=t||z,Ae=oe=>H.find(ke=>{var Te;return(Te=ke.engines)==null?void 0:Te.includes(oe.id)})||null,Rt=()=>xe(async()=>{var Te;const oe=await yg(e,O.envKey,O.value,ie);x(oe.credentials||[]),D(null),I(p("fleet-credential-saved"));const ke=((Te=(oe.credentials||[]).find(ae=>ae.envKey===O.envKey))==null?void 0:Te.activeCells)||[];if(ke.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",ke.join(", "))))for(const ae of ke)await Fo(e,ae,ie)}),Jt=oe=>xe(async()=>{if(!window.confirm(p("fleet-credential-remove-confirm").replace("{key}",oe.envKey)))return;const ke=await g0(e,oe.envKey,ie);x(ke.credentials||[]),I(p("fleet-credential-removed"))}),Oe=oe=>Q({...oe,route:Array.isArray(oe==null?void 0:oe.route)?oe.route:ie}),Pt=async oe=>{if(!G)return;const ke=G.cell||G.id,Te=Array.isArray(G.route)?G.route:ie;if(oe.action==="up"){const ae=await Gh(e,{cell:ke,boot:!!oe.boot,...oe.engine?{engine:oe.engine}:{},...oe.model!==void 0?{model:oe.model}:{},...oe.permissionPolicy?{permissionPolicy:oe.permissionPolicy}:{}},Te),re=uf(ae);re&&I(re.text)}else await Il(e,{cell:ke,boot:!!oe.boot},Te)},bt=(oe,ke)=>{E(""),M({mode:"new",route:Array.isArray(ke)?ke:ie,form:{tmuxSession:oe.name,id:"",engine:"",cwd:"",boot:!1},err:""})},dt=()=>xe(async()=>{const oe=B.form;if(!oe.engine){M({...B,err:p("import-engine-required")});return}await b0(e,{tmuxSession:oe.tmuxSession,id:oe.id||void 0,engine:oe.engine,cwd:oe.cwd||void 0,boot:!!oe.boot},oe.route||ie),M(null),I(p("fleet-saved"))}),ht=({engineRows:oe=[],cellRows:ke=[]})=>xe(async()=>{const Te=oe.filter(ge=>ge.selected),ae=Te.map(ge=>rb(ge.engine));if(ae.some(ge=>!ge))throw new Error(p("fleet-backup-invalid-engine"));const re=Te.filter(ge=>ge.exists).map(ge=>ge.engine.id);if(re.length&&!window.confirm(p("fleet-backup-confirm-engine-overwrite").replace("{engines}",re.join(", "))))return;const Pe=[...new Set([...a.engines.map(ge=>ge.id),...ae.map(ge=>ge.id)])],q=[];for(const ge of ke.filter(De=>De.selected)){const De=X2(ge.cell,ge.engine,Pe);if(!De)throw new Error(`${ge.cell.id}: ${p("fleet-backup-engine-missing")}`);q.push(De)}const te=ke.filter(ge=>ge.selected&&ge.exists).map(ge=>ge.cell.id);if(te.length&&!window.confirm(p("fleet-backup-confirm-overwrite").replace("{cells}",te.join(", "))))return;const U=ae.length?await x0(e,ae,re.length>0,ie):{needsRestart:[]},ce=q.length?await S0(e,q,ie):{needsRestart:[]},de=[...new Set([...U.needsRestart||[],...ce.needsRestart||[]])];$(!1),I(`${p("fleet-backup-restored").replace("{n}",String(q.length))}${ae.length?` · ${ae.length} ${p("fleet-engines").toLowerCase()}`:""}${de.length?` · ${p("fleet-backup-needs-restart").replace("{cells}",de.join(", "))}`:""}`)}),Qe=c.jsxs("label",{className:"nc-field",children:[p("location"),c.jsxs("select",{value:K,onChange:oe=>{Y(oe.target.value),y(null),w(null),E(""),I(""),Z(!1),v(!1),f({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),x([]),D(null)},children:[c.jsx("option",{value:"",children:p("local")}),n.map(oe=>c.jsxs("option",{value:oe.route.join("/"),disabled:oe.status&&oe.status!=="up",children:[oe.label,oe.status&&oe.status!=="up"?` · ${p("node-offline")}`:""]},oe.route.join("/")))]})]}),ot=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":p("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":A==="manage",className:`nc-set-tabbtn${A==="manage"?" on":""}`,onClick:()=>W("manage"),children:p("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":A==="overview",className:`nc-set-tabbtn${A==="overview"?" on":""}`,onClick:()=>W("overview"),children:p("fleet-network-overview")})]});return m?we?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-manage-help")}),Qe,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),$(!0)},children:p("fleet-backup")}),c.jsx("small",{children:p("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:p("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:qe||k||!a.engines.length,onClick:()=>{var oe;E(""),w({mode:"new",form:I_((oe=a.engines[0])==null?void 0:oe.id)})},children:["+ ",p("add")]})})]}),a.cells.map(oe=>{const ke=fe.has(oe.id),Te=h.capabilities||[],ae=oe.needsRepair===!0;return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:oe.id}),oe.label?c.jsxs("small",{className:"nc-fleet-label",children:[" ",oe.label]}):null,c.jsxs("small",{children:[oe.engine," · ",ae?c.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:p("fleet-cwd-needs-repair")}):oe.cwd,ke?` · ${p("service-active")}`:` · ${p("cell-off")}`]})]}),c.jsxs("span",{children:[ke&&Te.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>xe(()=>Il(e,{cell:oe.id},ie)),children:p("stop")}),!ke&&Te.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:qe||k,onClick:()=>Oe({cell:oe.id,id:oe.id,engine:oe.engine,model:oe.model,models:oe.models,permissionPolicies:oe.permissionPolicies,active:!1,boot:oe.boot}),children:p("start")}),ke&&Te.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>xe(()=>Fo(e,oe.id,ie)),children:p("restart")}),ae?c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),T(oe)},children:p("fleet-cwd-repair")}):c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{var re;E(""),w({mode:"edit",original:oe,form:{...oe,commands:{...oe.commands||{}},command:((re=oe.commands)==null?void 0:re[oe.engine])||""}})},children:p("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>xe(async()=>{window.confirm(p("fleet-remove-cell").replace("{id}",oe.id))&&await Z_(e,oe.id,!0,ie)}),children:"×"})]})]},oe.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:p("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:qe||k,onClick:()=>{E(""),y({mode:"new",form:Q2()})},children:["+ ",p("add")]})]}),a.engines.map(oe=>{var Te,ae;const ke=Ae(oe);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:oe.label}),c.jsx("small",{children:oe.managed?`${oe.id} · ${oe.managed.client} / ${oe.managed.provider} · ${(Te=oe.managedInfo)!=null&&Te.configured?p("fleet-ready"):((ae=oe.managedInfo)==null?void 0:ae.reason)||p("fleet-not-ready")}`:`${oe.id} · ${oe.command}`}),ke&&c.jsxs("small",{children:[ke.envKey," · ",p(`fleet-credential-source-${ke.source||"missing"}`)]})]}),c.jsxs("span",{children:[ke&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),D({envKey:ke.envKey,value:""})},children:ke.configured?p("fleet-credential-change"):p("fleet-credential-set")}),(ke==null?void 0:ke.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>Jt(ke),children:p("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),y({mode:"edit",original:oe,form:Z2(oe)})},children:p("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>xe(async()=>{window.confirm(p("fleet-remove-engine").replace("{id}",oe.id))&&await y0(e,oe.id,ie)}),children:"×"})]})]},oe.id)})]}),S&&c.jsx($s,{onClose:()=>y(null),label:p("fleet-new-engine"),error:R,children:c.jsx(nj,{state:S,setState:y,busy:k,onSave:$e,catalog:a.managedCatalog||[]})}),b&&c.jsx($s,{onClose:()=>w(null),label:p("fleet-new-cell"),error:R,children:c.jsx(ij,{token:e,route:ie,targets:n,location:K,setLocation:Y,state:b,setState:w,engines:a.engines,busy:k,onSave:ft})}),j&&c.jsx($s,{onClose:()=>T(null),label:p("fleet-cwd-repair-title").replace("{id}",j.id),error:"",children:c.jsx(rj,{token:e,route:ie,cell:j,busy:k,onSaved:async()=>{T(null),I(p("fleet-cwd-repaired")),await ue()},onClose:()=>T(null)})}),F&&c.jsx("div",{className:"nc-set-note",children:F}),R&&c.jsx("div",{className:"nc-err",children:R}),L&&c.jsx($s,{onClose:()=>$(!1),label:p("fleet-backup"),error:R,children:c.jsx(tj,{cells:a.cells,engines:a.engines,busy:k,canRestore:me,onRestore:ht,onClose:()=>$(!1)})}),O&&c.jsx($s,{onClose:()=>D(null),label:p("fleet-credential-title"),error:R,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:p("fleet-credential-title")}),c.jsx("small",{children:p("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[O.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:O.value,onChange:oe=>D({...O,value:oe.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>D(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:k||!O.value,onClick:Rt,children:p("save")})]})]})}),B&&c.jsx($s,{onClose:()=>M(null),label:p("import-as-cell"),error:R,children:c.jsx(O_,{token:e,route:B.route||ie,state:B,setState:M,busy:k,onSave:dt})}),G&&c.jsx(Bl,{cell:G,token:e,route:Array.isArray(G.route)?G.route:ie,onConfirm:async oe=>{try{await Pt(oe)}finally{await ue()}},onClose:()=>Q(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[Qe,c.jsxs("div",{className:"nc-set-info",children:[p(R?"fleet-editor-load-error":"fleet-editor-unavailable"),!R&&h.reason?` ${h.reason}`:""]})]}),R&&c.jsx("div",{className:"nc-err",children:R}),B&&c.jsx($s,{onClose:()=>M(null),label:p("import-as-cell"),error:R,children:c.jsx(O_,{token:e,route:B.route||ie,state:B,setState:M,busy:k,onSave:dt})}),G&&c.jsx(Bl,{cell:G,token:e,route:Array.isArray(G.route)?G.route:ie,onConfirm:async oe=>{try{await Pt(oe)}finally{await ue()}},onClose:()=>Q(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[Qe,c.jsx("div",{className:"nc-set-info",children:p("fleet-editor-loading")})]})]})}const Of="nc_notification_speech_v1",Nl="nc-notification-speech",$h="nc-notification-speech-preview",aj=320,lj=2,cj=3e4,uj=1e4,dj=6e4,hj=64,B_=Object.freeze({enabled:!1}),fj=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),pj=Object.freeze({it:new Set(["che","con","correzione","della","delle","difetto","il","lavoro","nessun","non","per","pronto","pubblicata","pubblicato","rilascio","sono","stato","tutti","verificata","verificato","versione","completata","completato","riepilogo"]),en:new Set(["all","and","completed","fix","for","issue","no","published","ready","release","summary","the","verified","version","with","work"]),es:new Set(["con","correccion","defecto","el","esta","para","publicada","publicado","resumen","sin","todos","trabajo","verificada","verificado","version","y"])}),Bf=new WeakSet;function zf(e){return{enabled:(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).enabled===!0}}function ab(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function z_(e=ab()){if(!e)return{...B_};try{return zf(JSON.parse(e.getItem(Of)||"null"))}catch{return{...B_}}}function mj(e,t=ab()){const n=zf(e);if(t)try{t.setItem(Of,JSON.stringify(n))}catch{}return n}function Wr(){try{return typeof window<"u"?window:null}catch{return null}}function ea(e=Wr()){try{return!!(e&&e.speechSynthesis&&typeof e.speechSynthesis.speak=="function"&&typeof e.SpeechSynthesisUtterance=="function")}catch{return!1}}function lb(e=Wr()){return!!(e&&(typeof e=="object"||typeof e=="function")&&Bf.has(e))}function Hh(e=Wr()){e&&(typeof e=="object"||typeof e=="function")&&Bf.delete(e)}function Tr(e){const t=String(e||"").trim().toLowerCase().split("-")[0];return fj[t]||""}function uc(e){return String(e||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function gj(e){const t=uc(e).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(t.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(pj).map(([o,a])=>({lang:o,score:[...n].reduce((u,h)=>u+(a.has(h)?1:0),0)})).sort((o,a)=>a.score-o.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function vj(e,t){const n=Tr(e&&e.lang);return n||Tr(gj(e&&e.body))||Tr(t)}function cb(e){try{const t=e&&e.speechSynthesis&&e.speechSynthesis.getVoices;return typeof t=="function"?Array.from(t.call(e.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function ub(e,t){const n=Tr(t);if(!n)return null;const s=Array.from(e||[]).filter(h=>h&&typeof h.lang=="string"&&h.lang.trim()),o=s.filter(h=>h.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),u=s.filter(h=>h.lang.trim().toLowerCase().split("-")[0]===a);return o.find(h=>h.default===!0)||o[0]||u.find(h=>h.default===!0)||u[0]||null}function F_(e){return uc(e).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function _j(e,t=aj){const n=F_(e&&e.title),s=F_(e&&e.body),o=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(o);return a.length<=t?o:`${a.slice(0,Math.max(0,t-1)).join("").trimEnd()}…`}function yj(e){try{return!!(e&&e.visibilityState==="visible"&&typeof e.hasFocus=="function"&&e.hasFocus())}catch{return!1}}function db(e=Wr()){if(!ea(e))return!1;try{return e.speechSynthesis.cancel(),!0}catch{return!1}}function wj(e){try{e&&typeof e.dispatchEvent=="function"&&typeof e.Event=="function"&&e.dispatchEvent(new e.Event($h))}catch{}}function bj(e,t,n=Wr(),s={}){var m;if(Hh(n),!ea(n))return Promise.resolve(!1);const o=uc(e);if(!o||(m=s.signal)!=null&&m.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:uj,u=s.setTimer||((v,S)=>setTimeout(v,S)),h=s.clearTimer||(v=>clearTimeout(v)),f=s.signal;return wj(n),new Promise(v=>{let S=!1,y=!1,b=null,w=null;const k=C=>{if(!S){if(S=!0,f&&w&&f.removeEventListener("abort",w),b!==null&&h(b),C)Bf.add(n);else try{n.speechSynthesis.cancel()}catch{}v(C)}};w=()=>k(!1),f&&f.addEventListener("abort",w,{once:!0});try{n.speechSynthesis.cancel();const C=new n.SpeechSynthesisUtterance(o);C.lang=Tr(t);const R=ub(cb(n),C.lang);R&&(C.voice=R),C.onstart=()=>{y=!0},C.onend=()=>k(y),C.onerror=()=>k(!1),b=u(()=>k(!1),a),n.speechSynthesis.speak(C)}catch{k(!1)}})}function Sj(e={}){const t=e.scope||Wr(),n=e.document||t&&t.document,s=Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:lj,o=Number.isFinite(e.watchdogMs)&&e.watchdogMs>0?e.watchdogMs:cj,a=Number.isFinite(e.dedupWindowMs)&&e.dedupWindowMs>0?e.dedupWindowMs:dj,u=Number.isInteger(e.maxDedup)&&e.maxDedup>0?e.maxDedup:hj,h=e.now||Date.now,f=e.setTimer||((B,M)=>setTimeout(B,M)),m=e.clearTimer||(B=>clearTimeout(B)),v=e.isPrimed||(()=>lb(t)),S=t&&t.speechSynthesis;let y=null,b=null,w=[],k=[],C=()=>{};const R=new Map,E=()=>{k=cb(t)};if(E(),S&&typeof S.addEventListener=="function")S.addEventListener("voiceschanged",E),C=()=>S.removeEventListener("voiceschanged",E);else if(S&&"onvoiceschanged"in S){const B=S.onvoiceschanged,M=(...j)=>{E(),typeof B=="function"&&B.apply(S,j)};S.onvoiceschanged=M,C=()=>{S.onvoiceschanged===M&&(S.onvoiceschanged=B)}}const F=B=>{if(B&&typeof B.id=="string"&&B.id)return`id:${B.id}`;const M=Number(B&&B.ts),j=uc(B&&B.title);return Number.isFinite(M)&&j?`frame:${M}:${j}`:""},I=B=>{if(!B)return!0;const M=h();for(const[j,T]of R)M-T>=a&&R.delete(j);if(R.has(B))return!1;for(R.set(B,M);R.size>u;)R.delete(R.keys().next().value);return!0},K=()=>{b!==null&&m(b),b=null},Y=()=>{K(),y&&(y.onend=null,y.onerror=null,y=null),db(t)},z=B=>{if(!ea(t))return w=[],"unsupported";let M;try{M=new t.SpeechSynthesisUtterance(B.text),M.lang=Tr(B.lang);const T=ub(k,M.lang);T&&(M.voice=T)}catch{return w=[],"error"}y=M;const j=()=>{if(y!==M)return;K(),y=null,M.onend=null,M.onerror=null;const T=w.shift();T&&z(T)};M.onend=j,M.onerror=j;try{return b=f(()=>{if(y!==M)return;y=null,M.onend=null,M.onerror=null;try{t.speechSynthesis.cancel()}catch{}K();const T=w.shift();T&&z(T)},o),t.speechSynthesis.speak(M),"speaking"}catch{return j(),"error"}},Z=(B,M)=>{if(!ea(t))return"unsupported";const j=_j(B);if(!j)return"empty";if(!I(F(B)))return"duplicate";if(!yj(n))return"inactive";if(!v())return"unprimed";const T={text:j,lang:M};return B&&B.urgency==="high"?(w=[],Y(),z(T)):y?s===0?"dropped":(w.length>=s&&w.shift(),w.push(T),"queued"):z(T)},G=()=>{w=[],Y()};return{enqueue:Z,stop:G,dispose:()=>{G(),C(),C=()=>{}}}}function hb(){const[e,t]=N.useState(z_);N.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Of&&o.key!==null)return;const a=(o==null?void 0:o.type)===Nl?zf(o.detail):z_();t(a)};return window.addEventListener(Nl,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Nl,s),window.removeEventListener("storage",s)}},[]);const n=N.useCallback(s=>{const o=mj({enabled:s===!0});return t(o),window.dispatchEvent(new CustomEvent(Nl,{detail:o})),o.enabled},[]);return[e.enabled,n]}function xj({text:e}){const[t,n]=N.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return c.jsxs("div",{className:"nc-set-copyline",children:[c.jsx("code",{children:e}),c.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[c.jsx(Ze,{name:"copy",size:14})," ",p(t?"copied":"copy")]})]})}function kj({value:e}){const[t,n]=N.useState("");return N.useEffect(()=>{let s=!0;return n2.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?c.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function Cj({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u,vlUnavailable:h=[]}){const[f,m]=N.useState(null),[v,S]=N.useState(null),[y,b]=N.useState(null),[w,k]=N.useState({ssh:"",sshPort:"",name:""}),[C,R]=N.useState(""),[E,F]=N.useState(""),[I,K]=N.useState(!1),[Y,z]=N.useState(null),Z=Date.now(),G=s&&s.deviceName||"",Q=(t||[]).filter(x=>x&&x.direction==="outbound"&&x.name&&x.ssh),B=Q.find(x=>x.name===C)||Q[0]||null,M=B?Gd(B.tunnel,Z):null,j=B!=null&&B.shared?M!=null&&M.up?"share-local-active":"share-local-pending":M!=null&&M.up?"share-local-private":"share-local-private-down",T=[{key:"peer-group-hubs",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(x=>x.kind==="transitive")},{key:"peer-group-vl",rows:(t||[]).filter(x=>x.kind==="vl")}],L=Y&&(t||[]).find(x=>`${x.kind||"direct"}:${x.nodeId||x.name}`===Y)||null,$=async x=>{if(B){m(null),S(`${B.name}:share`);try{const O=await T0(e,B.name,x);await a(),O&&O.reversePoolPending===!0&&m(`${B.name}: ${p("share-reverse-pool-pending")}`)}catch(O){const D=O!=null&&O.data&&O.data.shared===!1?O.data:null;if(D)try{await a()}catch{}const A=O!=null&&O.data&&typeof O.data.hint=="string"?O.data.hint:"",W=(D==null?void 0:D.revoked)===!0&&(D==null?void 0:D.localReconcilePending)===!0?p("share-off-local-reconcile-pending"):(D==null?void 0:D.revoked)===!1&&(D==null?void 0:D.reconcilePending)===!0?p("share-off-hub-reconcile-pending"):"",X=O!=null&&O.data&&O.data.reversePoolPending===!0?p("share-reverse-pool-pending"):"",ie=O!=null&&O.data&&typeof O.data.code=="string"?O.data.code:"",ue=O!=null&&O.data&&typeof O.data.detail=="string"?O.data.detail.trim():"",fe=ue&&ue!==String(O.message||"")?ue:"";m(`${B.name}: ${String(O.message||O)}${ie?` [${ie}]`:""}${fe?` — ${fe}`:""}${A?` — ${A}`:""}${W?` — ${W}`:""}${X?` — ${X}`:""}`)}S(null)}},H=async()=>{m(null);const x=vs(w.name||E||G||"NexusCrew"),O=Ix({name:x,ssh:w.ssh,sshPort:w.sshPort});if(!O.ok){m(p(O.error));return}S("invite");try{b(await R0(e,{...E||G?{label:E||G}:{},name:x,ssh:O.value.ssh,...O.value.sshPort?{sshPort:O.value.sshPort}:{}}))}catch(D){m(String(D.message||D))}S(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:p("peer-inventory-title")}),(t||[]).length===0&&c.jsx("div",{className:"nc-empty",children:p("no-nodes")}),T.map(x=>x.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[p(x.key)," ",c.jsx("span",{children:x.rows.length})]}),x.rows.map(O=>{const D=p2(O);if(!D)return null;const A=`${O.kind||"direct"}:${O.nodeId||O.name}`,W=D.routed?{up:D.reach.up,since:null}:Gd(O.tunnel,Z);return c.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${D.routed?" routed":""}`,"aria-label":`${D.title} — ${p("node-detail-open")}`,onClick:()=>z(A),children:[c.jsx("span",{className:`nc-dot ${D.reach.up?"on":""}`}),c.jsxs("span",{className:"nc-node-row-text",children:[c.jsx("b",{children:D.title}),c.jsxs("small",{children:[D.routed?D.routeLabel:`${D.subtitle} · ${p(D.exposure.shortKey)}`,!D.routed&&D.exposure.shortKey==="visibility-selected"?` (${D.exposure.count})`:""]})]}),c.jsxs("span",{className:`nc-set-tunnel${D.reach.up?" up":""}`,children:[p(D.reach.key),W.since?` · ${W.since}`:""]}),c.jsx("span",{className:"nc-node-row-more",children:c.jsx(Ze,{name:"chevronDown",size:14})})]},A)})]},x.key)),h.length>0&&c.jsxs("div",{className:"nc-err",children:[p("vl-owners-unavailable"),": ",h.map(x=>x.label||x.route.join("/")).join(", ")]}),L&&c.jsx(R2,{node:L,nodes:t||[],token:e,readonly:o,refresh:a,onClose:()=>z(null)}),(n||[]).some(x=>!x.direct&&x.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:p("routed-node-aliases-help")}),(n||[]).filter(x=>!x.direct&&x.instanceId).map(x=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${x.status==="up"?"on":""}`}),c.jsx("b",{children:x.label||x.name}),c.jsx("small",{children:(x.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{const O=window.prompt(p("node-local-alias"),x.alias||"");if(O!=null){if(O.trim()&&!Ir(O.normalize("NFC"))){m(p("err-label"));return}S(`${x.instanceId}:alias`),m(null);try{O.trim()?await L0(e,x.instanceId,O):await Sg(e,x.instanceId),u()}catch(D){m(String(D.message||D))}S(null)}},children:p("alias-on-device")}),x.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{S(`${x.instanceId}:alias-reset`),m(null);try{await Sg(e,x.instanceId),u()}catch(O){m(String(O.message||O))}S(null)},children:p("reset-alias")})]})]},x.instanceId))]}),B&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:p("share-local-heading")}),Q.length>1&&c.jsxs("label",{className:"nc-field",children:[p("share-local-hub"),c.jsx("select",{value:B.name,disabled:o||!!v,onChange:x=>R(x.target.value),children:Q.map(x=>c.jsx("option",{value:x.name,children:x.label||x.name},x.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:B.shared===!0,disabled:o||!!v,onChange:x=>$(x.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("share-local-through").replace("{device}",G||p("local")).replace("{hub}",B.label||B.name)}),c.jsx("small",{children:p(B.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${B.shared&&(M!=null&&M.up)?" ok":M!=null&&M.up?"":" ko"}`,children:p(j)}),!(M!=null&&M.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:()=>$(B.shared===!0),children:p("share-local-reconnect")})]}),c.jsx(Gw,{token:e,deviceDefault:G,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:p("invite-v2-hint")}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[p("invite-target-local"),": ",c.jsx("b",{children:G||p("invite-target-this")})]}),c.jsxs("label",{className:"nc-field",children:[p("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:w.ssh,disabled:o,onChange:x=>k({...w,ssh:x.target.value})}),c.jsx("small",{className:"nc-set-hint",children:p("invite-endpoint-needed")})]}),Q.length>0&&c.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:p("invite-hub-only")}),I&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:w.sshPort,disabled:o,onChange:x=>k({...w,sshPort:x.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[p("device-name-label"),c.jsx("input",{placeholder:G||"NexusCrew",value:E,disabled:o,onChange:x=>F(x.target.value)}),c.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[p("node-name-label"),c.jsx("input",{placeholder:vs(E||G||p("node-name-ph")),value:w.name,disabled:o,onChange:x=>k({...w,name:x.target.value?vs(x.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!v||!w.ssh.trim(),onClick:H,children:p("create-pairing-link")}),c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>K(x=>!x),children:[I?"▾":"▸"," ",p("pair-advanced")]})]}),y&&c.jsxs(c.Fragment,{children:[c.jsx(kj,{value:y.pairingUrl}),c.jsx(xj,{text:y.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:p("invite-next-steps")})]})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function Ej({token:e,readonly:t}){const[n,s]=N.useState("idle"),[o,a]=N.useState(!1),[u,h]=N.useState(null);N.useEffect(()=>{let m=!1;return L2().then(v=>{m||s(v)}),()=>{m=!0}},[]);const f=async()=>{h(null),a(!0);try{n==="subscribed"?(await T2(e),s("idle")):(await A2(e),s("subscribed"))}catch(m){const v=String(m.message||m);v==="push-denied"?(s("denied"),h(p("push-denied"))):v==="push-unsupported"?(s("unsupported"),h(p("push-unsupported"))):h(v)}a(!1)};return n==="unsupported"?c.jsx("div",{className:"nc-set-info",children:p("push-unsupported")}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?p("settings-readonly"):"",onClick:f,children:p(n==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:p(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&c.jsx("div",{className:"nc-err",children:u})]})}function Nj(){const[e,t]=hb(),[n,s]=N.useState(""),[o,a]=N.useState(""),[u,h]=N.useState(!1),[f,m]=N.useState(lb),v=N.useRef(0),S=N.useRef(!1),y=N.useRef(null),b=ea();N.useEffect(()=>()=>{var C;v.current+=1,S.current&&((C=y.current)==null||C.abort(),y.current=null,S.current=!1,Hh())},[]);const w=async()=>{const C=v.current+=1,R=typeof AbortController=="function"?new AbortController:null;s(""),a(""),h(!0),m(!1),S.current=!0,y.current=R;const E=await bj(p("notification-speech-preview"),Ol(),void 0,R?{signal:R.signal}:{});return C!==v.current||(y.current=null,S.current=!1,h(!1),m(E),E?a(p("notification-speech-preview-ok")):s(p("notification-speech-preview-failed"))),E},k=C=>{var R;if(t(C),s(""),a(""),C)w();else{v.current+=1;const E=S.current;(R=y.current)==null||R.abort(),y.current=null,S.current=!1,h(!1),m(!1),Hh(),E||db()}};return c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("notification-speech-enable"),checked:e,disabled:!b,onChange:C=>k(C.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("notification-speech-enable")}),c.jsx("small",{children:p("notification-speech-help")})]})]}),b?c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!e||u,onClick:()=>{w()},children:p(u?"notification-speech-testing":"notification-speech-test")})}):c.jsx("div",{className:"nc-set-info",children:p("notification-speech-unsupported")}),e&&!f&&!u&&!n&&c.jsx("div",{className:"nc-set-info",children:p("notification-speech-needs-test")}),o&&c.jsx("div",{className:"nc-set-info",role:"status",children:o}),n&&c.jsx("div",{className:"nc-err",children:n})]})}function jj({token:e,readonly:t,nodes:n=[],settings:s=null}){const[o,a]=N.useState(null),[u,h]=N.useState([]),[f,m]=N.useState({name:"",mode:"primary-failover",targets:[]}),[v,S]=N.useState(null),[y,b]=N.useState(!1),[w,k]=N.useState(null),[C,R]=N.useState(""),E=N.useCallback(async()=>{try{const[H,x]=await Promise.all([M0(e),z0(e)]);a(H),h(Array.isArray(x==null?void 0:x.groups)?x.groups:[]),R("")}catch(H){R(String(H.message||H))}},[e]);N.useEffect(()=>{E()},[E]);const F=async H=>{b(!0),k(null),R("");try{a(await I0(e,H))}catch(x){R(String(x.message||x))}b(!1)},I=async()=>{b(!0),k(null),R("");try{k({kind:"test",...await O0(e)})}catch(H){R(String(H.message||H))}b(!1)},K=async()=>{b(!0),k(null),R("");try{k({kind:"stop",...await B0(e)})}catch(H){R(String(H.message||H))}b(!1)},Y=[],z=new Set,Z=(H,x)=>{const O=typeof H=="string"?H.toLowerCase():"";!/^[a-f0-9]{32}$/.test(O)||z.has(O)||(z.add(O),Y.push({id:O,label:x||O}))};Z(s==null?void 0:s.nodeId,p("audio-group-local"));for(const H of n||[])Z((H==null?void 0:H.nodeId)||(H==null?void 0:H.instanceId),(H==null?void 0:H.label)||(H==null?void 0:H.name)||(H==null?void 0:H.nodeId));for(const H of f.targets)Z(H,`${H} (${p("audio-group-unavailable-target")})`);const G=(H=null)=>{R(""),H?(S(H.name),m({name:H.name,mode:H.mode,targets:[...H.targets||[]]})):(S(null),m({name:"",mode:"primary-failover",targets:[]}))},Q=(H,x)=>m(O=>({...O,targets:x?[...new Set([...O.targets,H])]:O.targets.filter(D=>D!==H)})),B=async()=>{const H=f.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(H)||f.targets.length<1){R(p("audio-group-invalid"));return}b(!0),R("");try{const x=await F0(e,H,{targets:f.targets,mode:f.mode}),O=x==null?void 0:x.group;if(!O||!O.name)throw new Error(p("audio-group-save-failed"));h(D=>[...D.filter(A=>A.name!==O.name),O].sort((A,W)=>A.name.localeCompare(W.name))),G(null)}catch(x){R(String(x.message||x))}b(!1)},M=async H=>{b(!0),R("");try{await $0(e,H),h(x=>x.filter(O=>O.name!==H)),v===H&&G(null)}catch(x){R(String(x.message||x))}b(!1)},j=(o==null?void 0:o.installed)===!0,T=(o==null?void 0:o.liveness)==="ready",L=(o==null?void 0:o.consent)===!0&&j&&T,$=w?w.kind==="stop"?p(w.stopped?"audio-stop-stopped":"audio-stop-idle"):w.status==="accepted"||w.status==="spoken"?p("audio-test-accepted"):w.status==="unknown"?p("audio-test-unknown"):`${p("audio-test-refused")}${w.reason?` (${w.reason})`:""}`:"";return c.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[c.jsxs("div",{className:"nc-set-info",children:[c.jsx("b",{children:p("audio-title")}),c.jsx("br",{}),p("audio-help")]}),o?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("audio-consent"),checked:o.consent===!0,disabled:t||y,onChange:H=>{F(H.target.checked)}}),c.jsxs("span",{children:[c.jsx("b",{children:p("audio-consent")}),c.jsx("small",{children:p("audio-consent-help")})]})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("audio-capability")}),c.jsxs("div",{className:"nc-set-info",children:[p("audio-adapter"),": ",o.adapter||p("audio-adapter-none"),c.jsx("br",{}),p("audio-installed"),": ",p(j?"audio-installed-yes":"audio-installed-no"),c.jsx("br",{}),p("audio-liveness"),": ",p(T?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(o.languages)&&o.languages.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),p("audio-languages"),": ",o.languages.join(", ")]})]}),o.limits&&c.jsxs("small",{className:"nc-set-hint",children:[p("audio-limits"),": ",o.limits]})]}),!o.consent&&c.jsx("div",{className:"nc-set-info",children:p("audio-test-needs-consent")}),!j&&c.jsx("div",{className:"nc-set-info",children:p("audio-unavailable")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y||!L,title:t?p("settings-readonly"):"",onClick:()=>{I()},children:p(y?"audio-testing":"audio-test")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{K()},children:p(y?"audio-stopping":"audio-stop")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{E()},children:p("refresh")})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("audio-groups-title")}),c.jsx("small",{className:"nc-set-hint",children:p("audio-groups-help")}),u.length===0&&c.jsx("div",{className:"nc-set-info",children:p("audio-groups-empty")}),u.map(H=>{var x;return c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("span",{children:[c.jsx("b",{children:H.name})," ",c.jsxs("small",{children:["· ",H.mode==="fanout"?p("audio-group-fanout"):p("audio-group-primary")," · ",((x=H.targets)==null?void 0:x.length)||0]})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(H),children:p("audio-group-edit")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>{M(H.name)},children:p("audio-group-delete")})]},H.name)}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(null),children:p("audio-group-new")})}),c.jsxs("label",{className:"nc-field",children:[p("audio-group-name"),c.jsx("input",{"aria-label":p("audio-group-name"),value:f.name,maxLength:"32",disabled:t||y,onChange:H=>m(x=>({...x,name:H.target.value}))})]}),c.jsxs("label",{className:"nc-field",children:[p("audio-group-mode"),c.jsxs("select",{"aria-label":p("audio-group-mode"),value:f.mode,disabled:t||y,onChange:H=>m(x=>({...x,mode:H.target.value})),children:[c.jsx("option",{value:"primary-failover",children:p("audio-group-primary")}),c.jsx("option",{value:"fanout",children:p("audio-group-fanout")})]})]}),c.jsx("div",{className:"nc-set-info",children:p("audio-group-targets")}),Y.length===0?c.jsx("small",{className:"nc-set-hint",children:p("audio-group-no-targets")}):Y.map(H=>c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:f.targets.includes(H.id),disabled:t||y,onChange:x=>Q(H.id,x.target.checked)}),c.jsxs("span",{children:[H.label,c.jsx("small",{children:H.id})]})]},H.id)),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y,onClick:()=>{B()},children:p("audio-group-save")}),v&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>G(null),children:p("audio-group-cancel")})]})]})]}):c.jsx("div",{className:"nc-set-info",children:p("audio-loading")}),$&&c.jsx("div",{className:"nc-set-note",role:"status",children:$}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function Rj(){const[e,t]=kf();return c.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[c.jsx("div",{className:"nc-set-info",children:p("input-settings-local")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-field",children:[p("terminal-keyboard-gesture"),c.jsx("select",{"aria-label":p("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Nw.map(n=>c.jsx("option",{value:n,children:p(`terminal-keyboard-${n}`)},n))}),c.jsx("small",{children:p("terminal-keyboard-gesture-help")})]}),c.jsxs("label",{className:"nc-field",children:[p("keybar-layout"),c.jsx("select",{"aria-label":p("keybar-layout"),value:e.keybarLayout,onChange:n=>t({keybarLayout:n.target.value}),children:jw.map(n=>c.jsx("option",{value:n,children:p(`keybar-layout-${n}`)},n))}),c.jsx("small",{children:p("keybar-layout-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("keybar-ime-lock")}),c.jsx("small",{children:p("keybar-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("voice-ime-lock")}),c.jsx("small",{children:p("voice-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("keybar-enter-show")}),c.jsx("small",{children:p("keybar-enter-show-help")})]})]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(ps),children:p("input-settings-reset")})})]})}function Pj({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:p("diagnostics-local"),status:"up"},...t.filter(L=>Array.isArray(L.route)&&L.route.length).map(L=>({key:L.route.join("/"),route:L.route,label:L.label||L.name,status:L.status}))],[o,a]=N.useState("local"),u=s.find(L=>L.key===o)||s[0],[h,f]=N.useState(null),[m,v]=N.useState([]),[S,y]=N.useState(""),[b,w]=N.useState(!1),[k,C]=N.useState(!0),[R,E]=N.useState(900),[F,I]=N.useState("all"),[K,Y]=N.useState(""),z=N.useRef(0),Z=N.useRef(null),G=N.useCallback(async()=>{try{const L=await K0(e,u.route);if(f(L),y(""),!b){const $=await q0(e,{after:z.current,limit:200},u.route);Array.isArray($.records)&&$.records.length&&(z.current=$.cursor,v(H=>[...H,...$.records].slice(-500)))}}catch(L){y(L&&L.status===404?p("diagnostics-unsupported"):String(L.message||L))}},[e,u.key,b]);N.useEffect(()=>{z.current=0,v([]),f(null),y("")},[u.key]),N.useEffect(()=>{let L=null,$=!0;const H=()=>{!$||document.visibilityState==="hidden"||G()},x=()=>{L&&clearInterval(L),L=document.visibilityState==="hidden"?null:setInterval(H,2e3),document.visibilityState!=="hidden"&&H()};return document.addEventListener("visibilitychange",x),x(),()=>{$=!1,L&&clearInterval(L),document.removeEventListener("visibilitychange",x)}},[G]),N.useEffect(()=>{k&&Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[m,k]);const Q=m.filter(L=>(F==="all"||L.level===F)&&(!K||String(L.component||"").toLowerCase().includes(K.toLowerCase()))),B=Q.map(L=>`${L.ts} ${L.level.toUpperCase()} ${L.component} ${L.code} ${L.message}${Object.keys(L.meta||{}).length?` ${JSON.stringify(L.meta)}`:""}`).join(`
91
+ `],{type:"application/json"}),H=URL.createObjectURL($),x=document.createElement("a");x.href=H,x.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(x),x.click(),x.remove(),setTimeout(()=>URL.revokeObjectURL(H),0),R("")},Y=async j=>{if(R(""),b([]),k([]),!!j){if(j.size>1024*1024){R(p("fleet-backup-too-large"));return}try{const T=G2(await j.text());if(!T.ok){R(p(`fleet-backup-${T.error}`));return}const L=new Set(T.engines.map($=>$.id));k(T.engines.map($=>({engine:$,exists:E.has($.id),selected:!E.has($.id)}))),b(T.cells.map($=>{const H=E.has($.engine)||L.has($.engine),x=F.has($.id);return{cell:$,engine:H?$.engine:"",selected:H&&!x,exists:x}}))}catch(T){R(String(T.message||T))}}},z=(j,T)=>b(L=>L.map(($,H)=>H===j?{...$,...T}:$)),Z=(j,T)=>k(L=>L.map(($,H)=>H===j?{...$,...T}:$)),G=new Set([...E,...w.filter(j=>j.selected).map(j=>j.engine.id)]),Q=y.filter(j=>j.selected&&j.engine&&G.has(j.engine)),B=w.filter(j=>j.selected),M=[...new Map([...t.map(j=>[j.id,j.label||j.id]),...w.filter(j=>j.selected).map(j=>[j.engine.id,j.engine.label||j.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:p("fleet-backup")}),c.jsx("small",{children:p("fleet-backup-help")}),c.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),R("")},children:p("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":p("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),R("")},children:p("fleet-backup-import")})]}),u==="export"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set(e.map(j=>j.id))),S(new Set(t.map(j=>j.id)))},children:p("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),S(new Set)},children:p("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:p("fleet-engines")}),t.map(j=>{var T;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:v.has(j.id),onChange:()=>I(S,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.label||j.id}),c.jsxs("small",{children:[j.id,(T=j.envKeys)!=null&&T.length?` · ${j.envKeys.length} ${p("fleet-backup-env-names")}`:""]})]})]},j.id)}),c.jsx("b",{children:p("fleet-cells")}),e.map(j=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:f.has(j.id),onChange:()=>I(m,j.id)}),c.jsxs("span",{children:[c.jsx("b",{children:j.id}),c.jsxs("small",{children:[j.engine," · ",p("fleet-system-prompt")," ",(j.prompt||"").length," ",p("characters")]})]})]},j.id)),!e.length&&!t.length&&c.jsx("div",{className:"nc-empty",children:p("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!f.size&&!v.size,onClick:K,children:p("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:j=>Y(j.target.files&&j.target.files[0])}),c.jsx("small",{children:p("fleet-backup-import-help")}),!!(y.length||w.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(j=>j.map(T=>({...T,selected:!0}))),b(j=>j.map(T=>({...T,selected:!!T.engine})))},children:p("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{k(j=>j.map(T=>({...T,selected:!1}))),b(j=>j.map(T=>({...T,selected:!1})))},children:p("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&c.jsx("b",{children:p("fleet-engines")}),w.map((j,T)=>{var L;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,onChange:$=>Z(T,{selected:$.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.engine.label||j.engine.id}),c.jsxs("small",{children:[j.engine.id," · ",j.exists?p("fleet-backup-overwrite"):p("fleet-backup-new"),(L=j.engine.envKeys)!=null&&L.length?` · ${p("fleet-backup-env-values-required")}`:""]})]})]})},j.engine.id)}),!!y.length&&c.jsx("b",{children:p("fleet-cells")}),y.map((j,T)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:j.selected,disabled:!j.engine||!G.has(j.engine),onChange:L=>z(T,{selected:L.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:j.cell.id}),c.jsxs("small",{children:[j.exists?p("fleet-backup-overwrite"):p("fleet-backup-new")," · ",p("fleet-system-prompt")," ",j.cell.systemPrompt.length," ",p("characters")]})]})]}),c.jsxs("select",{value:j.engine,onChange:L=>z(T,{engine:L.target.value,selected:!!L.target.value}),children:[c.jsx("option",{value:"",children:p("fleet-backup-engine-missing")}),M.map(([L,$])=>c.jsx("option",{value:L,children:$},L))]})]},j.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!Q.length&&!B.length,onClick:()=>o({engineRows:w,cellRows:y}),children:p("fleet-backup-restore")})]})]}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function nj({state:e,setState:t,busy:n,onSave:s,catalog:o}){var R;const a=e.form,u=E=>t({...e,form:{...a,...E}}),h=a.envRows||[],f=[...new Map(o.map(E=>[E.client,E.clientLabel||E.client])).entries()],m=o.filter(E=>E.client===a.client),v=Zo(o,a),S=typeof(v==null?void 0:v.credentialEnv)=="string"?v.credentialEnv:"",y=Array.isArray(v==null?void 0:v.credentialUsedBy)?v.credentialUsedBy:[],b=(v==null?void 0:v.credentialSource)||"missing",w=!!(v!=null&&v.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",k=!!S&&e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,C=E=>{E&&u({client:E.client,provider:E.provider,credentialProfile:E.credentialProfile||"",managedModel:E.model||"",protocol:E.protocol||"",permissionPolicy:E.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!E.rc,displayName:E.custom?p("fleet-custom-provider-default"):"",baseUrl:E.custom?"":E.endpoint||"",envKey:E.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:E.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:e.mode==="new"?p("fleet-new-engine"):`${p("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:E=>u({id:E.target.value})}),c.jsx("input",{value:a.label,placeholder:p("label"),onChange:E=>u({label:E.target.value})}),c.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:E=>u({kind:E.target.value}),children:[c.jsx("option",{value:"managed",children:p("fleet-managed")}),c.jsx("option",{value:"custom",children:p("fleet-custom")})]}),a.kind==="managed"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:E=>C(o.find(F=>F.client===E.target.value&&F.default)||o.find(F=>F.client===E.target.value)),children:f.map(([E,F])=>c.jsx("option",{value:E,children:F},E))}),c.jsx("select",{value:((R=Zo(o,a))==null?void 0:R.id)||"",disabled:e.mode!=="new",onChange:E=>C(o.find(F=>F.id===E.target.value)),children:m.map(E=>c.jsx("option",{value:E.id,children:E.label},E.id))})]}),a.client!=="shell"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:p(v!=null&&v.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:E=>u({managedModel:E.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(v==null?void 0:v.models)||[],...a.modelOptions||[]].filter((E,F,I)=>E&&I.indexOf(E)===F).map(E=>c.jsx("option",{value:E},E))})]}),v!=null&&v.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:E=>u({permissionPolicy:E.target.value}),children:[c.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]}):c.jsx("small",{children:p("fleet-standard-permissions")}),(v==null?void 0:v.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),w&&c.jsxs("select",{"aria-label":p("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:E=>u({credentialSourcePolicy:E.target.value}),children:[c.jsx("option",{value:"auto",children:p("fleet-credential-source-policy-auto")}),c.jsx("option",{value:"nexuscrew-store",children:p("fleet-credential-source-policy-nexuscrew-store")}),c.jsx("option",{value:"environment",children:p("fleet-credential-source-policy-environment")})]}),(v==null?void 0:v.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:E=>u({envKey:E.target.value})}),c.jsx("small",{children:p("fleet-custom-secret-help")})]}),S&&c.jsxs("section",{className:"nc-fleet-key","aria-label":p("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:p("fleet-key-section")}),c.jsx("span",{children:p(`fleet-credential-source-${b}`)})]}),c.jsxs("label",{className:"nc-field",children:[p("fleet-key-variable"),c.jsx("input",{value:S,readOnly:!0,"aria-label":p("fleet-key-variable")})]}),c.jsx("small",{children:y.length?p("fleet-key-used-by").replace("{engines}",y.join(", ")):p("fleet-key-used-by-none")}),y.length>0&&c.jsx("small",{children:p("fleet-key-shared-impact").replace("{key}",S).replace("{engines}",y.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":p("fleet-key-value").replace("{key}",S),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:v!=null&&v.authConfigured||e.mode==="edit"?p("fleet-key-blank-keeps"):p("fleet-key-enter"),onChange:E=>u({credentialValue:E.target.value,allowMissingCredential:E.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:p("fleet-key-local-help")}),e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&c.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[c.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:E=>u({allowMissingCredential:E.target.checked})}),p("fleet-key-create-missing")]}),(v==null?void 0:v.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${v.notice}`)})]}),(v==null?void 0:v.notice)&&!S&&c.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${v.notice}`)}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:p("fleet-provider-display"),onChange:E=>u({displayName:E.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:E=>u({baseUrl:E.target.value})}),((v==null?void 0:v.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:E=>u({protocol:E.target.value}),children:v.protocols.map(E=>c.jsx("option",{value:E,children:E},E))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:E=>u({envKey:E.target.value})}),c.jsx("input",{value:a.providerId,placeholder:p("fleet-provider-id"),onChange:E=>u({providerId:E.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",p("fleet-custom-secret-help")]})]}),c.jsx("small",{children:p(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:p("command-path"),onChange:E=>u({command:E.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:p("args-lines"),onChange:E=>u({argsText:E.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:E=>u({rc:E.target.checked})})," remote control"]}),c.jsxs("select",{value:a.promptMode,onChange:E=>u({promptMode:E.target.value}),children:[c.jsx("option",{value:"send-keys",children:"send-keys"}),c.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&c.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:E=>u({promptFlag:E.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:E=>u({modelFlag:E.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:E=>u({modelValue:E.target.value})})]}),c.jsx("small",{children:p("env-write-only")}),h.map((E,F)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:E.key,disabled:E.configured,placeholder:"ENV_KEY",onChange:I=>{const K=h.slice();K[F]={...E,key:I.target.value},u({envRows:K})}}),c.jsx("input",{type:"password",value:E.value,placeholder:E.configured?"•••••• (unchanged)":"value",onChange:I=>{const K=h.slice();K[F]={...E,value:I.target.value},u({envRows:K})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((I,K)=>K!==F)}),children:"×"})]},`${E.key}-${F}`)),c.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||k||a.kind==="custom"&&!a.command||a.kind==="managed"&&(v==null?void 0:v.requiresModel)&&!a.managedModel||a.kind==="managed"&&(v==null?void 0:v.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:p("save")})]})]})}function ij({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:h,busy:f,onSave:m}){var Y;const[v,S]=N.useState(null),[y,b]=N.useState(""),w=a.form,k=z=>u({...a,form:{...w,...z}}),C=h.find(z=>z.id===w.engine),R=((Y=C==null?void 0:C.managed)==null?void 0:Y.client)==="shell",E=z=>{var Q,B,M,j;const Z=h.find(T=>T.id===z),G={...w.commands||{}};((Q=C==null?void 0:C.managed)==null?void 0:Q.client)==="shell"&&(w.command?G[w.engine]=w.command:delete G[w.engine]),k({engine:z,model:((B=w.models)==null?void 0:B[z])||((M=Z==null?void 0:Z.managed)==null?void 0:M.model)||((j=Z==null?void 0:Z.model)==null?void 0:j.value)||"",commands:G,command:G[z]||""})},F=z=>{const Z={...w.commands||{}};z?Z[w.engine]=z:delete Z[w.engine],k({command:z,commands:Z})},I=R&&/[|&;<>()`$*?{}\[\]~]/.test(w.command||""),K=async z=>{try{const Z=await Qh(e,z,t);S(Z),k({cwd:Z.path}),b("")}catch(Z){b(String(Z.message||Z))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?p("fleet-new-cell"):`${p("edit")} ${w.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[p("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:s,onChange:z=>{o(z.target.value),k({engine:""})},children:[c.jsx("option",{value:"",children:p("local")}),n.map(z=>c.jsxs("option",{value:z.route.join("/"),disabled:z.status&&z.status!=="up",children:[z.label,z.status&&z.status!=="up"?` · ${p("node-offline")}`:""]},z.route.join("/")))]})]}),c.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:z=>k({id:z.target.value})}),c.jsx("input",{value:w.label||"",maxLength:64,placeholder:p("fleet-cell-label"),onChange:z=>k({label:z.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:w.cwd,placeholder:p("cwd"),onChange:z=>k({cwd:z.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>v?S(null):K(w.cwd),children:p("browse")})]}),v&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:v.path}),c.jsxs("div",{className:"nc-fs-list",children:[v.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>K(v.parent),children:["↑ ",p("fs-parent")]}),(v.dirs||[]).map(z=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>K(`${v.path.replace(/\/$/,"")}/${z}`),children:["📁 ",z]},z))]})]}),y&&c.jsx("div",{className:"nc-err",children:y}),c.jsx("select",{value:w.engine,onChange:z=>E(z.target.value),children:h.map(z=>c.jsx("option",{value:z.id,children:z.label},z.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:z=>k({boot:z.target.checked})})," boot"]}),R?c.jsxs(c.Fragment,{children:[c.jsx("input",{value:w.command||"",maxLength:4096,placeholder:p("fleet-shell-command-placeholder"),onChange:z=>F(z.target.value)}),c.jsx("small",{children:w.command?p("fleet-shell-command-help"):p("fleet-shell-interactive")}),I&&c.jsx("small",{className:"nc-note",children:p("fleet-shell-command-metachar")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:p("fleet-model-override"),onChange:z=>k({model:z.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((C==null?void 0:C.availableModels)||[]).map(z=>c.jsx("option",{value:z},z))}),c.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:z=>k({prompt:z.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:f||!w.id||!w.cwd||!w.engine,onClick:m,children:p("save")})]})]})}function O_({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,h]=N.useState(null),[f,m]=N.useState([]),[v,S]=N.useState(""),y=Array.isArray(t)?t.join("/"):"";N.useEffect(()=>{let R=!0;return Jl(e,y?y.split("/"):[]).then(E=>{R&&(m(E.engines||[]),S(""))}).catch(E=>{R&&(m([]),S(String(E.message||E)))}),()=>{R=!1}},[e,y]);const b=n.form,w=R=>s({...n,form:{...b,...R}}),k=async R=>{try{const E=await Qh(e,R,t);h(E),w({cwd:E.path})}catch{}},C=!b.id&&b.tmuxSession?b.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):b.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[p("import-as-cell")," · ",b.tmuxSession]}),c.jsx("small",{children:p("import-help")}),c.jsx("input",{value:b.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:b.id,placeholder:p("name"),onChange:R=>w({id:R.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:b.cwd,placeholder:p("cwd"),onChange:R=>w({cwd:R.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):k(b.cwd),children:p("browse")})]}),u&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:u.path}),c.jsxs("div",{className:"nc-fs-list",children:[u.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>k(u.parent),children:["↑ ",p("fs-parent")]}),(u.dirs||[]).map(R=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>k(`${u.path.replace(/\/$/,"")}/${R}`),children:["📁 ",R]},R))]})]}),c.jsxs("select",{value:b.engine,onChange:R=>w({engine:R.target.value}),children:[c.jsx("option",{value:"",children:p("import-engine-required")}),f.map(R=>c.jsx("option",{value:R.id,children:R.label},R.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:R=>w({boot:R.target.checked})})," boot"]}),(n.err||v)&&c.jsx("div",{className:"nc-err",children:n.err||v}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:o||!b.tmuxSession||!b.engine||!f.length,onClick:a,children:p(C?"import-as-cell":"save")})]})]})}function El(e){const t=Ks(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function sj(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:n}=e;return!n||t===n||!t.startsWith(n+"/")?"":t.slice(n.length+1).replace(/\/+$/,"")}function rj({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=N.useState(""),[f,m]=N.useState(null),[v,S]=N.useState(!1),[y,b]=N.useState(""),w=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Ks(n.cwdSuggestion)!==null?Ks(n.cwdSuggestion):null,[k,C]=N.useState(w),R=n==null?void 0:n.id,E=s||v,F=async G=>{const Q=Ks(G);if(Q===null){m({rel:"",dirs:[],loading:!1,err:p("fleet-cwd-repair-invalid")});return}m({rel:Q,dirs:[],loading:!0,err:""});try{const B=await Qh(e,Q,t),M=sj(B);m({rel:M,dirs:Array.isArray(B.dirs)?B.dirs:[],loading:!1,err:""})}catch(B){m({rel:Q,dirs:[],loading:!1,err:String(B&&B.message||B)})}},I=G=>{if(!f)return;const Q=f.rel?`${f.rel}/${G}`:G;F(Q)},K=()=>{f!=null&&f.rel&&F(f.rel.split("/").slice(0,-1).join("/"))},Y=()=>{f&&(h(f.rel||""),m(null),b(""),C(null))},z=()=>{k!==null&&(h(k),C(null),b(""))},Z=async()=>{if(E)return;const G=Ks(u);if(G===null){b(p("fleet-cwd-repair-invalid"));return}const Q=El(G);let B=!0;try{B=window.confirm(p("fleet-cwd-repair-confirm").replace("{id}",String(R||"")).replace("{path}",Q))}catch{B=!1}if(B){S(!0),b(""),C(null);try{const M=await J_(e,R,{cwdRel:G},t);o==null||o(M)}catch(M){const j=M&&M.data||{};if(j.code==="unportable-cwd"){b(p("fleet-cwd-repair-unportable"));const T=Array.isArray(j.cells)?j.cells.find($=>$&&$.id===R):null,L=T&&typeof T.suggestion=="string"?T.suggestion:null;L!==null&&Ks(L)!==null&&C(L)}else b(String(M&&M.message||M))}finally{S(!1)}}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[c.jsx("b",{children:p("fleet-cwd-repair-title").replace("{id}",String(R||""))}),c.jsx("small",{className:"nc-set-info",children:p("fleet-cwd-repair-help")}),c.jsx("small",{className:"nc-cwd-no-source",children:p("fleet-cwd-repair-no-source-path")}),c.jsxs("label",{className:"nc-field",children:[p("cwd"),c.jsxs("div",{className:"nc-cwd-rel-row",children:[c.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),c.jsx("input",{value:u,placeholder:p("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:G=>h(G.target.value)}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:E,onClick:()=>f?m(null):F(""),children:p(f?"close":"fleet-cwd-repair-browse")})]})]}),c.jsx("div",{className:"nc-cwd-preview",children:p("fleet-cwd-repair-preview").replace("{path}",El(u))}),f&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:El(f.rel)}),c.jsxs("div",{className:"nc-fs-list",children:[f.rel&&c.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:K,children:["↑ ",p("fs-parent")]}),f.loading&&c.jsx("div",{className:"nc-fs-empty",children:"…"}),!f.loading&&f.dirs.length===0&&c.jsx("div",{className:"nc-fs-empty",children:p("fleet-cwd-repair-fs-empty")}),!f.loading&&f.dirs.map(G=>c.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>I(G),children:["📁 ",G]},G))]}),f.err&&c.jsx("div",{className:"nc-err",children:f.err}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{type:"button",className:"nc-btn primary",disabled:E||f.loading||!!f.err,onClick:Y,children:p("fleet-cwd-repair-use-current")})})]}),y&&c.jsx("div",{className:"nc-err",role:"alert",children:y}),k!==null&&c.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[c.jsx("span",{children:p("fleet-cwd-repair-suggestion")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:z,children:p("fleet-cwd-repair-use-suggestion").replace("{path}",El(k))})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:a,children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:E,onClick:Z,children:v?"…":p("save")})]})]})}function oj({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=N.useState({engines:[],cells:[],managedCatalog:[]}),[h,f]=N.useState({available:!1,capabilities:[]}),[m,v]=N.useState(!1),[S,y]=N.useState(null),[b,w]=N.useState(null),[k,C]=N.useState(!1),[R,E]=N.useState(""),[F,I]=N.useState(""),[K,Y]=N.useState(o),[z,Z]=N.useState(!1),[G,Q]=N.useState(null),[B,M]=N.useState(null),[j,T]=N.useState(null),[L,$]=N.useState(!1),[H,x]=N.useState([]),[O,D]=N.useState(null),[A,W]=N.useState("manage"),X=N.useRef(!1),ie=K?K.split("/"):[],ce=N.useCallback(async()=>{try{const oe=await ws(e,ie);f(oe);try{const ke=await Zh(e,ie);Z(!!ke.readonlyDefault)}catch{Z(!1)}if(oe.provider==="builtin"&&(oe.capabilities||[]).includes("definitions")){const ke=await Jl(e,ie),Te=new Map((oe.engines||[]).map(ae=>[ae.id,ae]));if(ke.engines=(ke.engines||[]).map(ae=>{var re;return{...ae,availableModels:((re=Te.get(ae.id))==null?void 0:re.models)||[]}}),u(ke),(oe.capabilities||[]).includes("credentials"))try{x((await m0(e,ie)).credentials||[])}catch{x([])}else x([])}E("")}catch(oe){E(String(oe.message||oe))}finally{v(!0)}},[e,K]);N.useEffect(()=>{ce();const oe=setInterval(ce,5e3);return()=>clearInterval(oe)},[ce]);const fe=new Set((h.cells||[]).filter(oe=>oe.active).map(oe=>oe.cell)),we=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),me=(h.capabilities||[]).includes("restore");N.useEffect(()=>{!s||X.current||!we||!a.engines.length||(X.current=!0,w({mode:"new",form:I_(a.engines[0].id)}))},[s,we,a.engines]);const xe=async oe=>{C(!0),E(""),I("");try{await oe(),await ce()}catch(ke){E(String(ke.message||ke))}C(!1)},$e=()=>xe(async()=>{var ge;const oe=S.mode==="new",ke=S.form,Te=a.managedCatalog||[],ae=ke.kind==="managed"?Zo(Te,ke):null,re=typeof(ae==null?void 0:ae.credentialEnv)=="string"?ae.credentialEnv:"",Pe=re&&ke.credentialValue||"",q=ej(ke,oe,Te);!oe&&S.form.kind==="custom"&&!S.form.modelFlag&&(q.model=null),!oe&&S.form.kind==="custom"&&S.form.promptMode!=="flag"&&(q.promptFlag=null);let te;if(oe)te=await v0(e,q,ie);else{const De=S.original,_e=new Set(S.form.envRows.filter(at=>!at.remove).map(at=>at.key)),Ee=(De.envKeys||[]).filter(at=>!_e.has(at)),nt=Object.fromEntries(S.form.envRows.filter(at=>!at.remove&&at.key&&(!at.configured||at.value!=="")).map(at=>[at.key,at.value]));te=await _0(e,De.id,q,S.form.kind==="custom"?{set:nt,remove:Ee}:void 0,ie)}let U=null;if(re&&Pe)try{U=await yg(e,re,Pe,ie),x(U.credentials||[])}catch{throw await ce(),oe&&y({mode:"edit",original:{...q,id:ke.id},form:{...ke,credentialReveal:!1}}),new Error(p(oe?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ce(),y(null),I(p("fleet-saved"));const ue=((ge=((U==null?void 0:U.credentials)||[]).find(De=>De.envKey===re))==null?void 0:ge.activeCells)||[],de=[...new Set([...(te==null?void 0:te.activeCells)||[],...ue])];if(de.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",de.join(", "))))for(const De of de)await Fo(e,De,ie)}),ft=()=>xe(async()=>{var U,ue,de,ge,De,_e;const oe=b.mode==="new",ke=b.form,Te={...oe?{id:ke.id}:{},cwd:ke.cwd,engine:ke.engine,boot:!!ke.boot},ae={...ke.commands||{}},re=a.engines.find(Ee=>Ee.id===ke.engine);((U=re==null?void 0:re.managed)==null?void 0:U.client)==="shell"&&typeof ke.command=="string"&&ke.command.length?ae[ke.engine]=ke.command:((ue=re==null?void 0:re.managed)==null?void 0:ue.client)==="shell"&&delete ae[ke.engine],(Object.keys(ae).length||!oe)&&(Te.commands=ae);const Pe=(ke.label||"").trim();oe?Pe&&(Te.label=Pe):Te.label=Pe||null,oe?(((de=re==null?void 0:re.managed)==null?void 0:de.client)!=="shell"&&ke.model&&(Te.model=ke.model),((ge=re==null?void 0:re.managed)==null?void 0:ge.client)!=="shell"&&ke.prompt&&(Te.prompt=ke.prompt)):(Te.model=((De=re==null?void 0:re.managed)==null?void 0:De.client)==="shell"?null:ke.model||null,((_e=re==null?void 0:re.managed)==null?void 0:_e.client)!=="shell"&&(Te.prompt=ke.prompt||null));const q=oe?await w0(e,Te,ie):await J_(e,b.original.id,Te,ie),te=oe?ke.id:b.original.id;w(null),I(p("fleet-saved")),!oe&&(q!=null&&q.active)&&window.confirm(p("fleet-restart-confirm").replace("{cells}",te))&&await Fo(e,te,ie)}),qe=t||z,Ae=oe=>H.find(ke=>{var Te;return(Te=ke.engines)==null?void 0:Te.includes(oe.id)})||null,Rt=()=>xe(async()=>{var Te;const oe=await yg(e,O.envKey,O.value,ie);x(oe.credentials||[]),D(null),I(p("fleet-credential-saved"));const ke=((Te=(oe.credentials||[]).find(ae=>ae.envKey===O.envKey))==null?void 0:Te.activeCells)||[];if(ke.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",ke.join(", "))))for(const ae of ke)await Fo(e,ae,ie)}),Vt=oe=>xe(async()=>{if(!window.confirm(p("fleet-credential-remove-confirm").replace("{key}",oe.envKey)))return;const ke=await g0(e,oe.envKey,ie);x(ke.credentials||[]),I(p("fleet-credential-removed"))}),Oe=oe=>Q({...oe,route:Array.isArray(oe==null?void 0:oe.route)?oe.route:ie}),Pt=async oe=>{if(!G)return;const ke=G.cell||G.id,Te=Array.isArray(G.route)?G.route:ie;if(oe.action==="up"){const ae=await Gh(e,{cell:ke,boot:!!oe.boot,...oe.engine?{engine:oe.engine}:{},...oe.model!==void 0?{model:oe.model}:{},...oe.permissionPolicy?{permissionPolicy:oe.permissionPolicy}:{}},Te),re=uf(ae);re&&I(re.text)}else await Il(e,{cell:ke,boot:!!oe.boot},Te)},bt=(oe,ke)=>{E(""),M({mode:"new",route:Array.isArray(ke)?ke:ie,form:{tmuxSession:oe.name,id:"",engine:"",cwd:"",boot:!1},err:""})},dt=()=>xe(async()=>{const oe=B.form;if(!oe.engine){M({...B,err:p("import-engine-required")});return}await b0(e,{tmuxSession:oe.tmuxSession,id:oe.id||void 0,engine:oe.engine,cwd:oe.cwd||void 0,boot:!!oe.boot},oe.route||ie),M(null),I(p("fleet-saved"))}),ht=({engineRows:oe=[],cellRows:ke=[]})=>xe(async()=>{const Te=oe.filter(ge=>ge.selected),ae=Te.map(ge=>rb(ge.engine));if(ae.some(ge=>!ge))throw new Error(p("fleet-backup-invalid-engine"));const re=Te.filter(ge=>ge.exists).map(ge=>ge.engine.id);if(re.length&&!window.confirm(p("fleet-backup-confirm-engine-overwrite").replace("{engines}",re.join(", "))))return;const Pe=[...new Set([...a.engines.map(ge=>ge.id),...ae.map(ge=>ge.id)])],q=[];for(const ge of ke.filter(De=>De.selected)){const De=X2(ge.cell,ge.engine,Pe);if(!De)throw new Error(`${ge.cell.id}: ${p("fleet-backup-engine-missing")}`);q.push(De)}const te=ke.filter(ge=>ge.selected&&ge.exists).map(ge=>ge.cell.id);if(te.length&&!window.confirm(p("fleet-backup-confirm-overwrite").replace("{cells}",te.join(", "))))return;const U=ae.length?await x0(e,ae,re.length>0,ie):{needsRestart:[]},ue=q.length?await S0(e,q,ie):{needsRestart:[]},de=[...new Set([...U.needsRestart||[],...ue.needsRestart||[]])];$(!1),I(`${p("fleet-backup-restored").replace("{n}",String(q.length))}${ae.length?` · ${ae.length} ${p("fleet-engines").toLowerCase()}`:""}${de.length?` · ${p("fleet-backup-needs-restart").replace("{cells}",de.join(", "))}`:""}`)}),Qe=c.jsxs("label",{className:"nc-field",children:[p("location"),c.jsxs("select",{value:K,onChange:oe=>{Y(oe.target.value),y(null),w(null),E(""),I(""),Z(!1),v(!1),f({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),x([]),D(null)},children:[c.jsx("option",{value:"",children:p("local")}),n.map(oe=>c.jsxs("option",{value:oe.route.join("/"),disabled:oe.status&&oe.status!=="up",children:[oe.label,oe.status&&oe.status!=="up"?` · ${p("node-offline")}`:""]},oe.route.join("/")))]})]}),ot=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":p("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":A==="manage",className:`nc-set-tabbtn${A==="manage"?" on":""}`,onClick:()=>W("manage"),children:p("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":A==="overview",className:`nc-set-tabbtn${A==="overview"?" on":""}`,onClick:()=>W("overview"),children:p("fleet-network-overview")})]});return m?we?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-manage-help")}),Qe,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),$(!0)},children:p("fleet-backup")}),c.jsx("small",{children:p("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:p("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:qe||k||!a.engines.length,onClick:()=>{var oe;E(""),w({mode:"new",form:I_((oe=a.engines[0])==null?void 0:oe.id)})},children:["+ ",p("add")]})})]}),a.cells.map(oe=>{const ke=fe.has(oe.id),Te=h.capabilities||[],ae=oe.needsRepair===!0;return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:oe.id}),oe.label?c.jsxs("small",{className:"nc-fleet-label",children:[" ",oe.label]}):null,c.jsxs("small",{children:[oe.engine," · ",ae?c.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:p("fleet-cwd-needs-repair")}):oe.cwd,ke?` · ${p("service-active")}`:` · ${p("cell-off")}`]})]}),c.jsxs("span",{children:[ke&&Te.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>xe(()=>Il(e,{cell:oe.id},ie)),children:p("stop")}),!ke&&Te.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:qe||k,onClick:()=>Oe({cell:oe.id,id:oe.id,engine:oe.engine,model:oe.model,models:oe.models,permissionPolicies:oe.permissionPolicies,active:!1,boot:oe.boot}),children:p("start")}),ke&&Te.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>xe(()=>Fo(e,oe.id,ie)),children:p("restart")}),ae?c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),T(oe)},children:p("fleet-cwd-repair")}):c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{var re;E(""),w({mode:"edit",original:oe,form:{...oe,commands:{...oe.commands||{}},command:((re=oe.commands)==null?void 0:re[oe.engine])||""}})},children:p("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>xe(async()=>{window.confirm(p("fleet-remove-cell").replace("{id}",oe.id))&&await Z_(e,oe.id,!0,ie)}),children:"×"})]})]},oe.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:p("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:qe||k,onClick:()=>{E(""),y({mode:"new",form:Q2()})},children:["+ ",p("add")]})]}),a.engines.map(oe=>{var Te,ae;const ke=Ae(oe);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:oe.label}),c.jsx("small",{children:oe.managed?`${oe.id} · ${oe.managed.client} / ${oe.managed.provider} · ${(Te=oe.managedInfo)!=null&&Te.configured?p("fleet-ready"):((ae=oe.managedInfo)==null?void 0:ae.reason)||p("fleet-not-ready")}`:`${oe.id} · ${oe.command}`}),ke&&c.jsxs("small",{children:[ke.envKey," · ",p(`fleet-credential-source-${ke.source||"missing"}`)]})]}),c.jsxs("span",{children:[ke&&c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),D({envKey:ke.envKey,value:""})},children:ke.configured?p("fleet-credential-change"):p("fleet-credential-set")}),(ke==null?void 0:ke.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>Vt(ke),children:p("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:qe||k,onClick:()=>{E(""),y({mode:"edit",original:oe,form:Z2(oe)})},children:p("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:qe||k,onClick:()=>xe(async()=>{window.confirm(p("fleet-remove-engine").replace("{id}",oe.id))&&await y0(e,oe.id,ie)}),children:"×"})]})]},oe.id)})]}),S&&c.jsx($s,{onClose:()=>y(null),label:p("fleet-new-engine"),error:R,children:c.jsx(nj,{state:S,setState:y,busy:k,onSave:$e,catalog:a.managedCatalog||[]})}),b&&c.jsx($s,{onClose:()=>w(null),label:p("fleet-new-cell"),error:R,children:c.jsx(ij,{token:e,route:ie,targets:n,location:K,setLocation:Y,state:b,setState:w,engines:a.engines,busy:k,onSave:ft})}),j&&c.jsx($s,{onClose:()=>T(null),label:p("fleet-cwd-repair-title").replace("{id}",j.id),error:"",children:c.jsx(rj,{token:e,route:ie,cell:j,busy:k,onSaved:async()=>{T(null),I(p("fleet-cwd-repaired")),await ce()},onClose:()=>T(null)})}),F&&c.jsx("div",{className:"nc-set-note",children:F}),R&&c.jsx("div",{className:"nc-err",children:R}),L&&c.jsx($s,{onClose:()=>$(!1),label:p("fleet-backup"),error:R,children:c.jsx(tj,{cells:a.cells,engines:a.engines,busy:k,canRestore:me,onRestore:ht,onClose:()=>$(!1)})}),O&&c.jsx($s,{onClose:()=>D(null),label:p("fleet-credential-title"),error:R,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:p("fleet-credential-title")}),c.jsx("small",{children:p("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[O.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:O.value,onChange:oe=>D({...O,value:oe.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>D(null),children:p("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:k||!O.value,onClick:Rt,children:p("save")})]})]})}),B&&c.jsx($s,{onClose:()=>M(null),label:p("import-as-cell"),error:R,children:c.jsx(O_,{token:e,route:B.route||ie,state:B,setState:M,busy:k,onSave:dt})}),G&&c.jsx(Bl,{cell:G,token:e,route:Array.isArray(G.route)?G.route:ie,onConfirm:async oe=>{try{await Pt(oe)}finally{await ce()}},onClose:()=>Q(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[Qe,c.jsxs("div",{className:"nc-set-info",children:[p(R?"fleet-editor-load-error":"fleet-editor-unavailable"),!R&&h.reason?` ${h.reason}`:""]})]}),R&&c.jsx("div",{className:"nc-err",children:R}),B&&c.jsx($s,{onClose:()=>M(null),label:p("import-as-cell"),error:R,children:c.jsx(O_,{token:e,route:B.route||ie,state:B,setState:M,busy:k,onSave:dt})}),G&&c.jsx(Bl,{cell:G,token:e,route:Array.isArray(G.route)?G.route:ie,onConfirm:async oe=>{try{await Pt(oe)}finally{await ce()}},onClose:()=>Q(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,A==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),c.jsx(Fd,{token:e,targets:n,readonly:t,onPower:Oe,onImport:bt})]}):c.jsxs(c.Fragment,{children:[Qe,c.jsx("div",{className:"nc-set-info",children:p("fleet-editor-loading")})]})]})}const Of="nc_notification_speech_v1",Nl="nc-notification-speech",$h="nc-notification-speech-preview",aj=320,lj=2,cj=3e4,uj=1e4,dj=6e4,hj=64,B_=Object.freeze({enabled:!1}),fj=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),pj=Object.freeze({it:new Set(["che","con","correzione","della","delle","difetto","il","lavoro","nessun","non","per","pronto","pubblicata","pubblicato","rilascio","sono","stato","tutti","verificata","verificato","versione","completata","completato","riepilogo"]),en:new Set(["all","and","completed","fix","for","issue","no","published","ready","release","summary","the","verified","version","with","work"]),es:new Set(["con","correccion","defecto","el","esta","para","publicada","publicado","resumen","sin","todos","trabajo","verificada","verificado","version","y"])}),Bf=new WeakSet;function zf(e){return{enabled:(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).enabled===!0}}function ab(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function z_(e=ab()){if(!e)return{...B_};try{return zf(JSON.parse(e.getItem(Of)||"null"))}catch{return{...B_}}}function mj(e,t=ab()){const n=zf(e);if(t)try{t.setItem(Of,JSON.stringify(n))}catch{}return n}function Wr(){try{return typeof window<"u"?window:null}catch{return null}}function ea(e=Wr()){try{return!!(e&&e.speechSynthesis&&typeof e.speechSynthesis.speak=="function"&&typeof e.SpeechSynthesisUtterance=="function")}catch{return!1}}function lb(e=Wr()){return!!(e&&(typeof e=="object"||typeof e=="function")&&Bf.has(e))}function Hh(e=Wr()){e&&(typeof e=="object"||typeof e=="function")&&Bf.delete(e)}function Tr(e){const t=String(e||"").trim().toLowerCase().split("-")[0];return fj[t]||""}function uc(e){return String(e||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function gj(e){const t=uc(e).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(t.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(pj).map(([o,a])=>({lang:o,score:[...n].reduce((u,h)=>u+(a.has(h)?1:0),0)})).sort((o,a)=>a.score-o.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function vj(e,t){const n=Tr(e&&e.lang);return n||Tr(gj(e&&e.body))||Tr(t)}function cb(e){try{const t=e&&e.speechSynthesis&&e.speechSynthesis.getVoices;return typeof t=="function"?Array.from(t.call(e.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function ub(e,t){const n=Tr(t);if(!n)return null;const s=Array.from(e||[]).filter(h=>h&&typeof h.lang=="string"&&h.lang.trim()),o=s.filter(h=>h.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),u=s.filter(h=>h.lang.trim().toLowerCase().split("-")[0]===a);return o.find(h=>h.default===!0)||o[0]||u.find(h=>h.default===!0)||u[0]||null}function F_(e){return uc(e).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function _j(e,t=aj){const n=F_(e&&e.title),s=F_(e&&e.body),o=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(o);return a.length<=t?o:`${a.slice(0,Math.max(0,t-1)).join("").trimEnd()}…`}function yj(e){try{return!!(e&&e.visibilityState==="visible"&&typeof e.hasFocus=="function"&&e.hasFocus())}catch{return!1}}function db(e=Wr()){if(!ea(e))return!1;try{return e.speechSynthesis.cancel(),!0}catch{return!1}}function wj(e){try{e&&typeof e.dispatchEvent=="function"&&typeof e.Event=="function"&&e.dispatchEvent(new e.Event($h))}catch{}}function bj(e,t,n=Wr(),s={}){var m;if(Hh(n),!ea(n))return Promise.resolve(!1);const o=uc(e);if(!o||(m=s.signal)!=null&&m.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:uj,u=s.setTimer||((v,S)=>setTimeout(v,S)),h=s.clearTimer||(v=>clearTimeout(v)),f=s.signal;return wj(n),new Promise(v=>{let S=!1,y=!1,b=null,w=null;const k=C=>{if(!S){if(S=!0,f&&w&&f.removeEventListener("abort",w),b!==null&&h(b),C)Bf.add(n);else try{n.speechSynthesis.cancel()}catch{}v(C)}};w=()=>k(!1),f&&f.addEventListener("abort",w,{once:!0});try{n.speechSynthesis.cancel();const C=new n.SpeechSynthesisUtterance(o);C.lang=Tr(t);const R=ub(cb(n),C.lang);R&&(C.voice=R),C.onstart=()=>{y=!0},C.onend=()=>k(y),C.onerror=()=>k(!1),b=u(()=>k(!1),a),n.speechSynthesis.speak(C)}catch{k(!1)}})}function Sj(e={}){const t=e.scope||Wr(),n=e.document||t&&t.document,s=Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:lj,o=Number.isFinite(e.watchdogMs)&&e.watchdogMs>0?e.watchdogMs:cj,a=Number.isFinite(e.dedupWindowMs)&&e.dedupWindowMs>0?e.dedupWindowMs:dj,u=Number.isInteger(e.maxDedup)&&e.maxDedup>0?e.maxDedup:hj,h=e.now||Date.now,f=e.setTimer||((B,M)=>setTimeout(B,M)),m=e.clearTimer||(B=>clearTimeout(B)),v=e.isPrimed||(()=>lb(t)),S=t&&t.speechSynthesis;let y=null,b=null,w=[],k=[],C=()=>{};const R=new Map,E=()=>{k=cb(t)};if(E(),S&&typeof S.addEventListener=="function")S.addEventListener("voiceschanged",E),C=()=>S.removeEventListener("voiceschanged",E);else if(S&&"onvoiceschanged"in S){const B=S.onvoiceschanged,M=(...j)=>{E(),typeof B=="function"&&B.apply(S,j)};S.onvoiceschanged=M,C=()=>{S.onvoiceschanged===M&&(S.onvoiceschanged=B)}}const F=B=>{if(B&&typeof B.id=="string"&&B.id)return`id:${B.id}`;const M=Number(B&&B.ts),j=uc(B&&B.title);return Number.isFinite(M)&&j?`frame:${M}:${j}`:""},I=B=>{if(!B)return!0;const M=h();for(const[j,T]of R)M-T>=a&&R.delete(j);if(R.has(B))return!1;for(R.set(B,M);R.size>u;)R.delete(R.keys().next().value);return!0},K=()=>{b!==null&&m(b),b=null},Y=()=>{K(),y&&(y.onend=null,y.onerror=null,y=null),db(t)},z=B=>{if(!ea(t))return w=[],"unsupported";let M;try{M=new t.SpeechSynthesisUtterance(B.text),M.lang=Tr(B.lang);const T=ub(k,M.lang);T&&(M.voice=T)}catch{return w=[],"error"}y=M;const j=()=>{if(y!==M)return;K(),y=null,M.onend=null,M.onerror=null;const T=w.shift();T&&z(T)};M.onend=j,M.onerror=j;try{return b=f(()=>{if(y!==M)return;y=null,M.onend=null,M.onerror=null;try{t.speechSynthesis.cancel()}catch{}K();const T=w.shift();T&&z(T)},o),t.speechSynthesis.speak(M),"speaking"}catch{return j(),"error"}},Z=(B,M)=>{if(!ea(t))return"unsupported";const j=_j(B);if(!j)return"empty";if(!I(F(B)))return"duplicate";if(!yj(n))return"inactive";if(!v())return"unprimed";const T={text:j,lang:M};return B&&B.urgency==="high"?(w=[],Y(),z(T)):y?s===0?"dropped":(w.length>=s&&w.shift(),w.push(T),"queued"):z(T)},G=()=>{w=[],Y()};return{enqueue:Z,stop:G,dispose:()=>{G(),C(),C=()=>{}}}}function hb(){const[e,t]=N.useState(z_);N.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Of&&o.key!==null)return;const a=(o==null?void 0:o.type)===Nl?zf(o.detail):z_();t(a)};return window.addEventListener(Nl,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Nl,s),window.removeEventListener("storage",s)}},[]);const n=N.useCallback(s=>{const o=mj({enabled:s===!0});return t(o),window.dispatchEvent(new CustomEvent(Nl,{detail:o})),o.enabled},[]);return[e.enabled,n]}function xj({text:e}){const[t,n]=N.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return c.jsxs("div",{className:"nc-set-copyline",children:[c.jsx("code",{children:e}),c.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[c.jsx(Ze,{name:"copy",size:14})," ",p(t?"copied":"copy")]})]})}function kj({value:e}){const[t,n]=N.useState("");return N.useEffect(()=>{let s=!0;return n2.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?c.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function Cj({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u,vlUnavailable:h=[]}){const[f,m]=N.useState(null),[v,S]=N.useState(null),[y,b]=N.useState(null),[w,k]=N.useState({ssh:"",sshPort:"",name:""}),[C,R]=N.useState(""),[E,F]=N.useState(""),[I,K]=N.useState(!1),[Y,z]=N.useState(null),Z=Date.now(),G=s&&s.deviceName||"",Q=(t||[]).filter(x=>x&&x.direction==="outbound"&&x.name&&x.ssh),B=Q.find(x=>x.name===C)||Q[0]||null,M=B?Gd(B.tunnel,Z):null,j=B!=null&&B.shared?M!=null&&M.up?"share-local-active":"share-local-pending":M!=null&&M.up?"share-local-private":"share-local-private-down",T=[{key:"peer-group-hubs",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(x=>x.kind==="transitive")},{key:"peer-group-vl",rows:(t||[]).filter(x=>x.kind==="vl")}],L=Y&&(t||[]).find(x=>`${x.kind||"direct"}:${x.nodeId||x.name}`===Y)||null,$=async x=>{if(B){m(null),S(`${B.name}:share`);try{const O=await T0(e,B.name,x);await a(),O&&O.reversePoolPending===!0&&m(`${B.name}: ${p("share-reverse-pool-pending")}`)}catch(O){const D=O!=null&&O.data&&O.data.shared===!1?O.data:null;if(D)try{await a()}catch{}const A=O!=null&&O.data&&typeof O.data.hint=="string"?O.data.hint:"",W=(D==null?void 0:D.revoked)===!0&&(D==null?void 0:D.localReconcilePending)===!0?p("share-off-local-reconcile-pending"):(D==null?void 0:D.revoked)===!1&&(D==null?void 0:D.reconcilePending)===!0?p("share-off-hub-reconcile-pending"):"",X=O!=null&&O.data&&O.data.reversePoolPending===!0?p("share-reverse-pool-pending"):"",ie=O!=null&&O.data&&typeof O.data.code=="string"?O.data.code:"",ce=O!=null&&O.data&&typeof O.data.detail=="string"?O.data.detail.trim():"",fe=ce&&ce!==String(O.message||"")?ce:"";m(`${B.name}: ${String(O.message||O)}${ie?` [${ie}]`:""}${fe?` — ${fe}`:""}${A?` — ${A}`:""}${W?` — ${W}`:""}${X?` — ${X}`:""}`)}S(null)}},H=async()=>{m(null);const x=vs(w.name||E||G||"NexusCrew"),O=Ix({name:x,ssh:w.ssh,sshPort:w.sshPort});if(!O.ok){m(p(O.error));return}S("invite");try{b(await R0(e,{...E||G?{label:E||G}:{},name:x,ssh:O.value.ssh,...O.value.sshPort?{sshPort:O.value.sshPort}:{}}))}catch(D){m(String(D.message||D))}S(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:p("peer-inventory-title")}),(t||[]).length===0&&c.jsx("div",{className:"nc-empty",children:p("no-nodes")}),T.map(x=>x.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[p(x.key)," ",c.jsx("span",{children:x.rows.length})]}),x.rows.map(O=>{const D=p2(O);if(!D)return null;const A=`${O.kind||"direct"}:${O.nodeId||O.name}`,W=D.routed?{up:D.reach.up,since:null}:Gd(O.tunnel,Z);return c.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${D.routed?" routed":""}`,"aria-label":`${D.title} — ${p("node-detail-open")}`,onClick:()=>z(A),children:[c.jsx("span",{className:`nc-dot ${D.reach.up?"on":""}`}),c.jsxs("span",{className:"nc-node-row-text",children:[c.jsx("b",{children:D.title}),c.jsxs("small",{children:[D.routed?D.routeLabel:`${D.subtitle} · ${p(D.exposure.shortKey)}`,!D.routed&&D.exposure.shortKey==="visibility-selected"?` (${D.exposure.count})`:""]})]}),c.jsxs("span",{className:`nc-set-tunnel${D.reach.up?" up":""}`,children:[p(D.reach.key),W.since?` · ${W.since}`:""]}),c.jsx("span",{className:"nc-node-row-more",children:c.jsx(Ze,{name:"chevronDown",size:14})})]},A)})]},x.key)),h.length>0&&c.jsxs("div",{className:"nc-err",children:[p("vl-owners-unavailable"),": ",h.map(x=>x.label||x.route.join("/")).join(", ")]}),L&&c.jsx(R2,{node:L,nodes:t||[],token:e,readonly:o,refresh:a,onClose:()=>z(null)}),(n||[]).some(x=>!x.direct&&x.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:p("routed-node-aliases-help")}),(n||[]).filter(x=>!x.direct&&x.instanceId).map(x=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${x.status==="up"?"on":""}`}),c.jsx("b",{children:x.label||x.name}),c.jsx("small",{children:(x.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{const O=window.prompt(p("node-local-alias"),x.alias||"");if(O!=null){if(O.trim()&&!Ir(O.normalize("NFC"))){m(p("err-label"));return}S(`${x.instanceId}:alias`),m(null);try{O.trim()?await L0(e,x.instanceId,O):await Sg(e,x.instanceId),u()}catch(D){m(String(D.message||D))}S(null)}},children:p("alias-on-device")}),x.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{S(`${x.instanceId}:alias-reset`),m(null);try{await Sg(e,x.instanceId),u()}catch(O){m(String(O.message||O))}S(null)},children:p("reset-alias")})]})]},x.instanceId))]}),B&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:p("share-local-heading")}),Q.length>1&&c.jsxs("label",{className:"nc-field",children:[p("share-local-hub"),c.jsx("select",{value:B.name,disabled:o||!!v,onChange:x=>R(x.target.value),children:Q.map(x=>c.jsx("option",{value:x.name,children:x.label||x.name},x.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:B.shared===!0,disabled:o||!!v,onChange:x=>$(x.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("share-local-through").replace("{device}",G||p("local")).replace("{hub}",B.label||B.name)}),c.jsx("small",{children:p(B.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${B.shared&&(M!=null&&M.up)?" ok":M!=null&&M.up?"":" ko"}`,children:p(j)}),!(M!=null&&M.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:()=>$(B.shared===!0),children:p("share-local-reconnect")})]}),c.jsx(Gw,{token:e,deviceDefault:G,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:p("invite-v2-hint")}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[p("invite-target-local"),": ",c.jsx("b",{children:G||p("invite-target-this")})]}),c.jsxs("label",{className:"nc-field",children:[p("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:w.ssh,disabled:o,onChange:x=>k({...w,ssh:x.target.value})}),c.jsx("small",{className:"nc-set-hint",children:p("invite-endpoint-needed")})]}),Q.length>0&&c.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:p("invite-hub-only")}),I&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:w.sshPort,disabled:o,onChange:x=>k({...w,sshPort:x.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[p("device-name-label"),c.jsx("input",{placeholder:G||"NexusCrew",value:E,disabled:o,onChange:x=>F(x.target.value)}),c.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[p("node-name-label"),c.jsx("input",{placeholder:vs(E||G||p("node-name-ph")),value:w.name,disabled:o,onChange:x=>k({...w,name:x.target.value?vs(x.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!v||!w.ssh.trim(),onClick:H,children:p("create-pairing-link")}),c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>K(x=>!x),children:[I?"▾":"▸"," ",p("pair-advanced")]})]}),y&&c.jsxs(c.Fragment,{children:[c.jsx(kj,{value:y.pairingUrl}),c.jsx(xj,{text:y.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:p("invite-next-steps")})]})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function Ej({token:e,readonly:t}){const[n,s]=N.useState("idle"),[o,a]=N.useState(!1),[u,h]=N.useState(null);N.useEffect(()=>{let m=!1;return L2().then(v=>{m||s(v)}),()=>{m=!0}},[]);const f=async()=>{h(null),a(!0);try{n==="subscribed"?(await T2(e),s("idle")):(await A2(e),s("subscribed"))}catch(m){const v=String(m.message||m);v==="push-denied"?(s("denied"),h(p("push-denied"))):v==="push-unsupported"?(s("unsupported"),h(p("push-unsupported"))):h(v)}a(!1)};return n==="unsupported"?c.jsx("div",{className:"nc-set-info",children:p("push-unsupported")}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?p("settings-readonly"):"",onClick:f,children:p(n==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:p(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&c.jsx("div",{className:"nc-err",children:u})]})}function Nj(){const[e,t]=hb(),[n,s]=N.useState(""),[o,a]=N.useState(""),[u,h]=N.useState(!1),[f,m]=N.useState(lb),v=N.useRef(0),S=N.useRef(!1),y=N.useRef(null),b=ea();N.useEffect(()=>()=>{var C;v.current+=1,S.current&&((C=y.current)==null||C.abort(),y.current=null,S.current=!1,Hh())},[]);const w=async()=>{const C=v.current+=1,R=typeof AbortController=="function"?new AbortController:null;s(""),a(""),h(!0),m(!1),S.current=!0,y.current=R;const E=await bj(p("notification-speech-preview"),Ol(),void 0,R?{signal:R.signal}:{});return C!==v.current||(y.current=null,S.current=!1,h(!1),m(E),E?a(p("notification-speech-preview-ok")):s(p("notification-speech-preview-failed"))),E},k=C=>{var R;if(t(C),s(""),a(""),C)w();else{v.current+=1;const E=S.current;(R=y.current)==null||R.abort(),y.current=null,S.current=!1,h(!1),m(!1),Hh(),E||db()}};return c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("notification-speech-enable"),checked:e,disabled:!b,onChange:C=>k(C.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("notification-speech-enable")}),c.jsx("small",{children:p("notification-speech-help")})]})]}),b?c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!e||u,onClick:()=>{w()},children:p(u?"notification-speech-testing":"notification-speech-test")})}):c.jsx("div",{className:"nc-set-info",children:p("notification-speech-unsupported")}),e&&!f&&!u&&!n&&c.jsx("div",{className:"nc-set-info",children:p("notification-speech-needs-test")}),o&&c.jsx("div",{className:"nc-set-info",role:"status",children:o}),n&&c.jsx("div",{className:"nc-err",children:n})]})}function jj({token:e,readonly:t,nodes:n=[],settings:s=null}){const[o,a]=N.useState(null),[u,h]=N.useState([]),[f,m]=N.useState({name:"",mode:"primary-failover",targets:[]}),[v,S]=N.useState(null),[y,b]=N.useState(!1),[w,k]=N.useState(null),[C,R]=N.useState(""),E=N.useCallback(async()=>{try{const[H,x]=await Promise.all([M0(e),z0(e)]);a(H),h(Array.isArray(x==null?void 0:x.groups)?x.groups:[]),R("")}catch(H){R(String(H.message||H))}},[e]);N.useEffect(()=>{E()},[E]);const F=async H=>{b(!0),k(null),R("");try{a(await I0(e,H))}catch(x){R(String(x.message||x))}b(!1)},I=async()=>{b(!0),k(null),R("");try{k({kind:"test",...await O0(e)})}catch(H){R(String(H.message||H))}b(!1)},K=async()=>{b(!0),k(null),R("");try{k({kind:"stop",...await B0(e)})}catch(H){R(String(H.message||H))}b(!1)},Y=[],z=new Set,Z=(H,x)=>{const O=typeof H=="string"?H.toLowerCase():"";!/^[a-f0-9]{32}$/.test(O)||z.has(O)||(z.add(O),Y.push({id:O,label:x||O}))};Z(s==null?void 0:s.nodeId,p("audio-group-local"));for(const H of n||[])Z((H==null?void 0:H.nodeId)||(H==null?void 0:H.instanceId),(H==null?void 0:H.label)||(H==null?void 0:H.name)||(H==null?void 0:H.nodeId));for(const H of f.targets)Z(H,`${H} (${p("audio-group-unavailable-target")})`);const G=(H=null)=>{R(""),H?(S(H.name),m({name:H.name,mode:H.mode,targets:[...H.targets||[]]})):(S(null),m({name:"",mode:"primary-failover",targets:[]}))},Q=(H,x)=>m(O=>({...O,targets:x?[...new Set([...O.targets,H])]:O.targets.filter(D=>D!==H)})),B=async()=>{const H=f.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(H)||f.targets.length<1){R(p("audio-group-invalid"));return}b(!0),R("");try{const x=await F0(e,H,{targets:f.targets,mode:f.mode}),O=x==null?void 0:x.group;if(!O||!O.name)throw new Error(p("audio-group-save-failed"));h(D=>[...D.filter(A=>A.name!==O.name),O].sort((A,W)=>A.name.localeCompare(W.name))),G(null)}catch(x){R(String(x.message||x))}b(!1)},M=async H=>{b(!0),R("");try{await $0(e,H),h(x=>x.filter(O=>O.name!==H)),v===H&&G(null)}catch(x){R(String(x.message||x))}b(!1)},j=(o==null?void 0:o.installed)===!0,T=(o==null?void 0:o.liveness)==="ready",L=(o==null?void 0:o.consent)===!0&&j&&T,$=w?w.kind==="stop"?p(w.stopped?"audio-stop-stopped":"audio-stop-idle"):w.status==="accepted"||w.status==="spoken"?p("audio-test-accepted"):w.status==="unknown"?p("audio-test-unknown"):`${p("audio-test-refused")}${w.reason?` (${w.reason})`:""}`:"";return c.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[c.jsxs("div",{className:"nc-set-info",children:[c.jsx("b",{children:p("audio-title")}),c.jsx("br",{}),p("audio-help")]}),o?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("audio-consent"),checked:o.consent===!0,disabled:t||y,onChange:H=>{F(H.target.checked)}}),c.jsxs("span",{children:[c.jsx("b",{children:p("audio-consent")}),c.jsx("small",{children:p("audio-consent-help")})]})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("audio-capability")}),c.jsxs("div",{className:"nc-set-info",children:[p("audio-adapter"),": ",o.adapter||p("audio-adapter-none"),c.jsx("br",{}),p("audio-installed"),": ",p(j?"audio-installed-yes":"audio-installed-no"),c.jsx("br",{}),p("audio-liveness"),": ",p(T?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(o.languages)&&o.languages.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),p("audio-languages"),": ",o.languages.join(", ")]})]}),o.limits&&c.jsxs("small",{className:"nc-set-hint",children:[p("audio-limits"),": ",o.limits]})]}),!o.consent&&c.jsx("div",{className:"nc-set-info",children:p("audio-test-needs-consent")}),!j&&c.jsx("div",{className:"nc-set-info",children:p("audio-unavailable")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y||!L,title:t?p("settings-readonly"):"",onClick:()=>{I()},children:p(y?"audio-testing":"audio-test")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{K()},children:p(y?"audio-stopping":"audio-stop")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{E()},children:p("refresh")})]}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("audio-groups-title")}),c.jsx("small",{className:"nc-set-hint",children:p("audio-groups-help")}),u.length===0&&c.jsx("div",{className:"nc-set-info",children:p("audio-groups-empty")}),u.map(H=>{var x;return c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("span",{children:[c.jsx("b",{children:H.name})," ",c.jsxs("small",{children:["· ",H.mode==="fanout"?p("audio-group-fanout"):p("audio-group-primary")," · ",((x=H.targets)==null?void 0:x.length)||0]})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(H),children:p("audio-group-edit")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>{M(H.name)},children:p("audio-group-delete")})]},H.name)}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(null),children:p("audio-group-new")})}),c.jsxs("label",{className:"nc-field",children:[p("audio-group-name"),c.jsx("input",{"aria-label":p("audio-group-name"),value:f.name,maxLength:"32",disabled:t||y,onChange:H=>m(x=>({...x,name:H.target.value}))})]}),c.jsxs("label",{className:"nc-field",children:[p("audio-group-mode"),c.jsxs("select",{"aria-label":p("audio-group-mode"),value:f.mode,disabled:t||y,onChange:H=>m(x=>({...x,mode:H.target.value})),children:[c.jsx("option",{value:"primary-failover",children:p("audio-group-primary")}),c.jsx("option",{value:"fanout",children:p("audio-group-fanout")})]})]}),c.jsx("div",{className:"nc-set-info",children:p("audio-group-targets")}),Y.length===0?c.jsx("small",{className:"nc-set-hint",children:p("audio-group-no-targets")}):Y.map(H=>c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:f.targets.includes(H.id),disabled:t||y,onChange:x=>Q(H.id,x.target.checked)}),c.jsxs("span",{children:[H.label,c.jsx("small",{children:H.id})]})]},H.id)),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y,onClick:()=>{B()},children:p("audio-group-save")}),v&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>G(null),children:p("audio-group-cancel")})]})]})]}):c.jsx("div",{className:"nc-set-info",children:p("audio-loading")}),$&&c.jsx("div",{className:"nc-set-note",role:"status",children:$}),C&&c.jsx("div",{className:"nc-err",children:C})]})}function Rj(){const[e,t]=kf();return c.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[c.jsx("div",{className:"nc-set-info",children:p("input-settings-local")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsxs("label",{className:"nc-field",children:[p("terminal-keyboard-gesture"),c.jsx("select",{"aria-label":p("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Nw.map(n=>c.jsx("option",{value:n,children:p(`terminal-keyboard-${n}`)},n))}),c.jsx("small",{children:p("terminal-keyboard-gesture-help")})]}),c.jsxs("label",{className:"nc-field",children:[p("keybar-layout"),c.jsx("select",{"aria-label":p("keybar-layout"),value:e.keybarLayout,onChange:n=>t({keybarLayout:n.target.value}),children:jw.map(n=>c.jsx("option",{value:n,children:p(`keybar-layout-${n}`)},n))}),c.jsx("small",{children:p("keybar-layout-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("keybar-ime-lock")}),c.jsx("small",{children:p("keybar-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("voice-ime-lock")}),c.jsx("small",{children:p("voice-ime-lock-help")})]})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:p("keybar-enter-show")}),c.jsx("small",{children:p("keybar-enter-show-help")})]})]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(ps),children:p("input-settings-reset")})})]})}function Pj({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:p("diagnostics-local"),status:"up"},...t.filter(L=>Array.isArray(L.route)&&L.route.length).map(L=>({key:L.route.join("/"),route:L.route,label:L.label||L.name,status:L.status}))],[o,a]=N.useState("local"),u=s.find(L=>L.key===o)||s[0],[h,f]=N.useState(null),[m,v]=N.useState([]),[S,y]=N.useState(""),[b,w]=N.useState(!1),[k,C]=N.useState(!0),[R,E]=N.useState(900),[F,I]=N.useState("all"),[K,Y]=N.useState(""),z=N.useRef(0),Z=N.useRef(null),G=N.useCallback(async()=>{try{const L=await K0(e,u.route);if(f(L),y(""),!b){const $=await q0(e,{after:z.current,limit:200},u.route);Array.isArray($.records)&&$.records.length&&(z.current=$.cursor,v(H=>[...H,...$.records].slice(-500)))}}catch(L){y(L&&L.status===404?p("diagnostics-unsupported"):String(L.message||L))}},[e,u.key,b]);N.useEffect(()=>{z.current=0,v([]),f(null),y("")},[u.key]),N.useEffect(()=>{let L=null,$=!0;const H=()=>{!$||document.visibilityState==="hidden"||G()},x=()=>{L&&clearInterval(L),L=document.visibilityState==="hidden"?null:setInterval(H,2e3),document.visibilityState!=="hidden"&&H()};return document.addEventListener("visibilitychange",x),x(),()=>{$=!1,L&&clearInterval(L),document.removeEventListener("visibilitychange",x)}},[G]),N.useEffect(()=>{k&&Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[m,k]);const Q=m.filter(L=>(F==="all"||L.level===F)&&(!K||String(L.component||"").toLowerCase().includes(K.toLowerCase()))),B=Q.map(L=>`${L.ts} ${L.level.toUpperCase()} ${L.component} ${L.code} ${L.message}${Object.keys(L.meta||{}).length?` ${JSON.stringify(L.meta)}`:""}`).join(`
92
92
  `),M=async L=>{y("");try{const $=await L();f($),await G()}catch($){y(String($.message||$))}},j=async()=>{try{await navigator.clipboard.writeText(B)}catch{y(p("copy-manual"))}},T=()=>{try{const L=new Blob([`${JSON.stringify(Q,null,2)}
93
- `],{type:"application/json"}),$=URL.createObjectURL(L),H=document.createElement("a");H.href=$,H.download="nexuscrew-diagnostics.json",H.click(),URL.revokeObjectURL($)}catch{y(p("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[p("diagnostics-target"),c.jsx("select",{value:u.key,onChange:L=>a(L.target.value),children:s.map(L=>c.jsxs("option",{value:L.key,children:[L.label,L.status!=="up"?` · ${L.status}`:""]},L.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:p("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":p("diagnostics-duration"),value:R,onChange:L=>E(Number(L.target.value)),disabled:n,children:[300,900,1800,3600].map(L=>c.jsxs("option",{value:L,children:[L/60," min"]},L))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(h==null?void 0:h.verbose)===!0,onClick:()=>M(()=>kg(e,!0,R,u.route)),children:p("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(h==null?void 0:h.verbose)!==!0,onClick:()=>M(()=>kg(e,!1,R,u.route)),children:p("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?p("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):p("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":p("diagnostics-level"),value:F,onChange:L=>I(L.target.value),children:[c.jsx("option",{value:"all",children:p("diagnostics-all-levels")}),["debug","info","warn","error"].map(L=>c.jsx("option",{value:L,children:L},L))]}),c.jsx("input",{"aria-label":p("diagnostics-component"),placeholder:p("diagnostics-component"),value:K,onChange:L=>Y(L.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:b,onChange:L=>w(L.target.checked)})," ",p("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:k,onChange:L=>C(L.target.checked)})," ",p("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:Z,className:"nc-diag-log","aria-label":p("diagnostics-log"),children:B||p("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:p("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:T,children:p("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(p("diagnostics-clear-confirm"))&&M(async()=>{const L=await V0(e,u.route);return z.current=0,v([]),L})},children:p("diagnostics-clear")})]}),S&&c.jsx("div",{className:"nc-err",children:S})]})}function Lj({token:e,settings:t,readonly:n,refresh:s,roster:o,section:a,setSection:u}){const[h,f]=N.useState(null),[m,v]=N.useState(null),[S,y]=N.useState(!1),[b,w]=N.useState(!1),[k,C]=N.useState(null),[R,E]=N.useState(!0),[F,I]=N.useState(!1);N.useEffect(()=>{C(t&&t.update||null),E(!t||t.autoUpdate!==!1),I(!!(t&&t.alternateScreen))},[t]);const K=async()=>{f(null),v(null),w(!0);try{const j=await N0(e);v(j.note||"ok"),y(!1)}catch(j){f(String(j.message||j))}w(!1)},Y=async()=>{f(null),v(null),w(!0);try{const j=await H0(e);v(`${j.note||"ok"}${j.target?` (${j.target})`:""}`)}catch(j){f(String(j.message||j))}w(!1)},z=async j=>{f(null),v(null),w(!0);try{await Wd(e,{autoUpdate:j}),E(j),s&&await s()}catch(T){f(String(T.message||T))}w(!1)},Z=async j=>{f(null),v(null),w(!0);try{await Wd(e,{alternateScreen:j}),I(j),s&&await s()}catch(T){f(String(T.message||T))}w(!1)},G=async()=>{f(null),v(null),w(!0);try{C(await U0(e))}catch(j){f(String(j.message||j))}w(!1)},Q=async()=>{f(null),v(null),w(!0);try{const j=await W0(e);C(j),v(p("npm-update-restarting"))}catch(j){f(String(j.message||j))}w(!1)},B=()=>{window.confirm(p("composer-clear-confirm"))&&(f(null),KE()?(window.dispatchEvent(new Event(Mh)),v(p("composer-clear-done"))):f(p("composer-clear-failed")))},M=t&&t.service;return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":p("tab-system"),children:["general","diagnostics"].map(j=>c.jsx("button",{type:"button",role:"tab","aria-selected":a===j,className:`nc-set-tabbtn${a===j?" on":""}`,onClick:()=>u(j),children:p(`system-${j}`)},j))}),a==="general"&&c.jsxs(c.Fragment,{children:[c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-this-node")}),t&&c.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,c.jsx("br",{}),M&&M.installed?p("service-installed"):p("service-missing"),M&&M.installed?` · ${M.active?p("service-active"):p("service-inactive")}`:"",M?` · boot ${M.boot?"on":"off"}`:""]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?p("settings-readonly"):"",onClick:Y,children:p("service-regenerate")})}),c.jsx(Ej,{token:e,readonly:n}),c.jsx(Nj,{})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-updates")}),c.jsxs("div",{className:"nc-set-form nc-update-settings",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:R,disabled:n||b||k&&!k.supported,onChange:j=>z(j.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("npm-auto-update")}),c.jsx("small",{children:p("npm-auto-update-help")})]})]}),k&&c.jsxs("div",{className:"nc-set-info",children:[p("npm-update-current")," v",k.current,k.latest?` · ${p("npm-update-latest")} v${k.latest}`:""," · ",p(`npm-update-${k.supported?k.phase:"unsupported"}`)]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b||!k||!k.supported,onClick:G,children:p("npm-update-check")}),k&&k.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||b||k.phase==="installing",onClick:Q,children:p("npm-update-install")})]}),k&&k.lastError&&c.jsx("div",{className:"nc-err",children:k.lastError})]})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-security")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?p("settings-readonly"):"",onClick:()=>{f(null),v(null),y(!0)},children:p("token-rotate")})})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-local-data")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:p("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:B,children:p("composer-clear-data")})})]})]})]}),a==="diagnostics"&&c.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[c.jsx("h3",{children:p("system-diagnostics")}),c.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[c.jsx("div",{className:"nc-sheet-label",children:p("system-terminal")}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("alternate-screen"),checked:F,disabled:n||b,onChange:j=>Z(j.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("alternate-screen")}),c.jsx("small",{children:p("alternate-screen-help")})]})]})]}),c.jsx(Pj,{token:e,roster:o,readonly:n})]}),S&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:p("token-rotate-explain")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>y(!1),children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:b,onClick:K,children:p("confirm")})]})]}),m&&c.jsx("div",{className:"nc-set-note",children:m}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function Aj({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){kn();const a=n==="diagnostics"?"diagnostics":"general",[u,h]=N.useState(n==="diagnostics"?"system":n),f=N.useRef(null),m=N.useRef(null),[v,S]=N.useState({start:!1,end:!1}),[y,b]=N.useState(a),[w,k]=N.useState(null),[C,R]=N.useState([]),[E,F]=N.useState([]),[I,K]=N.useState(!1),[Y,z]=N.useState(null),[Z,G]=N.useState(0),Q=nf(e,!0,Z),B=N.useCallback(()=>{const j=f.current;if(!j)return;const T=j.scrollWidth>j.clientWidth+1,L={start:T&&j.scrollLeft>1,end:T&&j.scrollLeft+j.clientWidth<j.scrollWidth-1};S($=>$.start===L.start&&$.end===L.end?$:L)},[]);N.useEffect(()=>{const j=f.current;if(!j)return;const T=typeof ResizeObserver=="function"?new ResizeObserver(B):null;return T==null||T.observe(j),window.addEventListener("resize",B),B(),()=>{T==null||T.disconnect(),window.removeEventListener("resize",B)}},[B]),N.useEffect(()=>{var T,L;(L=(T=m.current)==null?void 0:T.scrollIntoView)==null||L.call(T,{behavior:"smooth",block:"nearest",inline:"nearest"});const j=window.requestAnimationFrame?window.requestAnimationFrame(B):setTimeout(B,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(j):clearTimeout(j)}},[u,B]);const M=N.useCallback(async()=>{var j;try{const T=await ty(e);k(T),z(null)}catch(T){z(String(T.message||T))}try{const L=(await C0(e)).peers||[];let $=[],H=[];try{const[x,O]=await Promise.all([Ht("/api/config",e).then(X=>X.json()).catch(()=>null),iy(e).catch(()=>null)]),D=x&&typeof x.instanceId=="string"?x.instanceId:"",A=[{instanceId:D||null,route:[],label:null},...hy(O,D)],W=await Promise.all(A.map(async X=>{try{return{ok:!0,peers:((await ny(e,X.route)).nodes||[]).map(fe=>dy(fe,X)).filter(Boolean)}}catch(ie){return{ok:!1,owner:X,error:ie}}}));for(const X of W){if(X.ok){$.push(...X.peers);continue}X.owner.route.length!==0&&H.push({instanceId:X.owner.instanceId,label:X.owner.label,route:X.owner.route,failure:/timeout/i.test(String(((j=X.error)==null?void 0:j.message)||X.error))?"timeout":"unreachable"})}}catch{}F(H),R([...L,...$])}catch(T){z(String(T.message||T))}},[e]);return N.useEffect(()=>{M();const j=setInterval(M,5e3);return()=>clearInterval(j)},[M]),N.useEffect(()=>{let j=!1;return Ht("/api/config",e).then(T=>T.json()).then(T=>{j||K(!!T.readonlyDefault)}).catch(()=>{}),()=>{j=!0}},[e]),c.jsx("div",{className:"nc-set-overlay",onClick:t,children:c.jsxs("div",{className:"nc-set-panel",onClick:j=>j.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(Ze,{name:"gear",size:18}),c.jsx("b",{children:p("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:p("close"),children:c.jsx(Ze,{name:"x",size:18})})]}),I&&c.jsx("div",{className:"nc-set-readonly",children:p("settings-readonly")}),Y&&c.jsx("div",{className:"nc-err",children:Y}),c.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:c.jsx("div",{className:"nc-set-tabs",ref:f,onScroll:B,children:["nodes","fleet","audio","input","system"].map(j=>c.jsx("button",{ref:u===j?m:null,type:"button",className:`nc-set-tabbtn${u===j?" on":""}`,onClick:()=>h(j),children:p(`tab-${j}`)},j))})}),c.jsxs("div",{className:"nc-set-body",children:[u==="nodes"&&c.jsx(Cj,{token:e,nodes:C,roster:Q,settings:w,readonly:I,vlUnavailable:E,refresh:M,refreshAliases:()=>G(j=>j+1)}),u==="fleet"&&c.jsx(oj,{token:e,readonly:I,startNewCell:o,initialLocation:s,targets:Q.map(j=>({route:j.route,label:j.label||j.name,status:j.status}))}),u==="audio"&&c.jsx(jj,{token:e,readonly:I,nodes:C,settings:w}),u==="input"&&c.jsx(Rj,{}),u==="system"&&c.jsx(Lj,{token:e,settings:w,readonly:I,refresh:M,roster:Q,section:y,setSection:b})]})]})})}function Tj({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){kn();const[h,f]=N.useState(t?"pair":"welcome"),[m,v]=N.useState(!1),[S,y]=N.useState(null),b=async()=>{v(!0),y(null);try{await Wd(e,{wizardDone:!0}),a&&a(),u()}catch(w){y(String(w.message||w)),v(!1)}};return c.jsx("div",{className:"nc-wiz-overlay",children:c.jsxs("div",{className:"nc-wiz",children:[c.jsxs("div",{className:"nc-wiz-head",children:[c.jsx("b",{children:p("wizard-title")}),c.jsx("small",{children:p("hydra-simple")})]}),h==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:p("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:b,children:p("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:m,onClick:()=>f("pair"),children:p("add-node")})]})]}),h==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(Gw,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:v,onSuccess:async()=>{a&&a(),f("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:()=>{a&&a(),f("welcome")},children:p("back")})})]}),h==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:p("node-connected")}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:m,onClick:b,children:p("finish")})})]}),S&&c.jsx("div",{className:"nc-err",children:S})]})})}function Dj(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const Mj=6e3,Ij=12e3;function Oj({n:e,onClose:t}){return c.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"nc-ntf-toast-txt",children:[c.jsx("b",{children:e.title}),e.body&&c.jsx("small",{children:e.body}),e.session&&c.jsx("span",{className:"nc-ntf-from",children:e.session})]}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:p("close"),children:c.jsx(Ze,{name:"x",size:14})})]})}function Bj({ask:e,token:t,onAnswered:n,onDismiss:s}){const[o,a]=N.useState(""),[u,h]=N.useState(!1),[f,m]=N.useState(null),[v,S]=N.useState(!1),y=async w=>{const k=String(w||"").trim();if(!(!k||u)){m(null),h(!0);try{await G0(t,e.id,k),n(e.id)}catch(C){m(String(C.message||C))}h(!1)}},b=async()=>{if(!v){S(!0);try{await X0(t,e.id),s(e.id)}catch{S(!1)}}};return c.jsxs("div",{className:"nc-ask-card",children:[c.jsxs("div",{className:"nc-ask-head",children:[c.jsx("span",{className:"nc-ntf-from",children:e.session}),c.jsxs("code",{className:"nc-ask-id",children:["#",e.id]}),c.jsx("button",{type:"button",className:"nc-ask-dismiss",title:p("ask-dismiss"),"aria-label":p("ask-dismiss"),disabled:v,onClick:b,children:c.jsx(Ze,{name:"x",size:14})})]}),c.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&c.jsx("div",{className:"nc-ask-opts",children:e.options.map(w=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u,onClick:()=>y(w),children:w},w))}),c.jsxs("div",{className:"nc-ask-reply",children:[c.jsx("textarea",{rows:2,placeholder:p("ask-reply-ph"),value:o,disabled:u,onChange:w=>a(w.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||!o.trim(),onClick:()=>y(o),children:p("send")})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function zj({token:e}){const[t]=kn(),[n]=hb(),[s,o]=N.useState([]),[a,u]=N.useState([]),[h,f]=N.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),m=N.useRef(0),v=N.useRef(null);v.current||(v.current=Sj());const S=N.useRef({enabled:n,lang:t});S.current={enabled:n,lang:t};const y=N.useCallback(C=>{o(R=>R.filter(E=>E.key!==C))},[]),b=N.useCallback(C=>{const R=`t${m.current+=1}`;o(F=>[...F.slice(-3),{...C,key:R}]),setTimeout(()=>y(R),C.urgency==="high"?Ij:Mj);const E=S.current;if(E.enabled)try{v.current.enqueue(C,vj(C,E.lang))}catch{}},[y]);N.useEffect(()=>{n||v.current.stop()},[n]),N.useEffect(()=>{const C=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&v.current.stop()},R=()=>v.current.stop();return document.addEventListener("visibilitychange",C),window.addEventListener("blur",C),window.addEventListener($h,R),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("blur",C),window.removeEventListener($h,R),typeof v.current.dispose=="function"?v.current.dispose():v.current.stop()}},[]),N.useEffect(()=>{if(!e)return;let C=!1;Y0(e).then(E=>{C||u(E.asks||[])}).catch(()=>{});const R=Dj(e,E=>{E.type==="notify"?b(E):E.type==="ask"&&E.ask&&E.ask.id?u(F=>F.some(I=>I.id===E.ask.id)?F:[...F,E.ask]):E.type==="ask-answered"&&E.id?u(F=>F.filter(I=>I.id!==E.id)):E.type==="ask-dismissed"&&E.id&&u(F=>F.filter(I=>I.id!==E.id))});return()=>{C=!0,R()}},[e,b]);const w=C=>u(R=>R.filter(E=>E.id!==C)),k=C=>u(R=>R.filter(E=>E.id!==C));return c.jsxs(c.Fragment,{children:[s.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:s.map(C=>c.jsx(Oj,{n:C,onClose:()=>y(C.key)},C.key))}),a.length>0&&!h&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>f(!0),title:p("asks-title"),children:["? ",c.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&h&&c.jsxs("div",{className:"nc-ask-panel",children:[c.jsxs("div",{className:"nc-ask-panel-head",children:[c.jsx("b",{children:p("asks-title")}),c.jsx("span",{className:"nc-ask-count",children:a.length}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>f(!1),title:p("close"),children:c.jsx(Ze,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:a.map(C=>c.jsx(Bj,{ask:C,token:e,onAnswered:w,onDismiss:k},C.id))})]})]})}const Fj=4e3;async function $j(e){const t=await Ht("/api/sessions",e);if((t==null?void 0:t.ok)===!1)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function $d(e,t=[]){var h;const[n,s]=await Promise.allSettled([t.length?Jh(e,t):$j(e),ws(e,t)]),o=n.status==="fulfilled"&&Array.isArray((h=n.value)==null?void 0:h.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,u=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:o,cells:u,fresh:Array.isArray(o)&&Array.isArray(u)}}function fb(e,t,n){return n===!0&&(e==null?void 0:e.degraded)!==!0&&(e==null?void 0:e.active)===!0&&e.tmux!==!1&&!!e.tmuxSession&&(t||[]).some(s=>(s==null?void 0:s.name)===e.tmuxSession)}function Hj(e){const t=new Map((e.sessions||[]).map(o=>[o.name,o])),n=[],s=(o,a,u,h=[],f="")=>{const m=new Map((a||[]).map(v=>[v.name,v]));for(const v of o||[]){const S=m.get(v.tmuxSession)||{},y=of(v,S),b=fb(v,a,u);n.push({key:Go(h,v.tmuxSession||v.cell),session:v.tmuxSession,route:h,cellName:v.cell,label:v.cell,node:h.length?h.join("/"):"",nodeLabel:f,live:b,selectable:b,verified:u===!0,working:y.working,degraded:!!v.degraded,active:v.active===!0,activity:S.activity||v.activity||0,subtitle:y.subtitle})}};s(e.cells,[...t.values()],e.localFresh===!0);for(const o of e.nodeGroups||[]){const a=Array.isArray(o.route)?o.route:[];o.kind==="vl"||!a.length||s(o.cells,o.sessions,o.switcherFresh===!0,a,o.label||o.name||"")}return n}function Uj(e){const t=new Map,n=Array.isArray(e.sessions)?e.sessions:[],s=Array.isArray(e.cells)?e.cells:[],o=new Map(n.map(u=>[u.name,u])),a=new Set(s.map(u=>u.tmuxSession).filter(Boolean));t.set("local",af(s,n.filter(u=>!a.has(u.name)),o));for(const u of e.nodeGroups||[]){const h=Array.isArray(u.route)?u.route:[];if(u.kind==="vl"||!h.length)continue;const f=Array.isArray(u.cells)?u.cells:[],m=Array.isArray(u.sessions)?u.sessions:[],v=new Set(f.map(S=>S.tmuxSession).filter(Boolean));t.set(h.join("/"),Fl({...u,route:h,cells:f,sessions:m,unmanaged:m.filter(S=>!v.has(S.name))}).rawItems)}return t}function Wj(e,t,n,s){return[...new Set(e.map(a=>a.node||"local"))].flatMap(a=>{const u=e.filter(v=>(v.node||"local")===a),h=new Map((t.get(a)||[]).map(v=>[v.key,v])),f=new Map(u.map(v=>[v.key,v])),m=u.map(v=>{const S=h.get(v.key);return{...v,label:(S==null?void 0:S.label)||v.label,live:(S==null?void 0:S.live)??v.live,fresh:(S==null?void 0:S.fresh)===!0,activity:(S==null?void 0:S.activity)??v.activity}});return gs(m,n,"all",Fi(s,a)).map(v=>f.get(v.key))})}function Kj({token:e,current:t,onPick:n,onClose:s}){const[o,a]=N.useState(Og),[u,h]=N.useState(!1),[f,m]=N.useState(!1),[v,S]=N.useState(""),[y,b]=N.useState(""),[w,k]=N.useState(""),C=N.useRef(null),R=N.useRef(null),E=N.useMemo(()=>Hj(o),[o]),F=N.useMemo(()=>Uj(o),[o]),{pins:I,orders:K,canMoveRoster:Y,moveRoster:z,stepRoster:Z}=rf(),G=N.useMemo(()=>Wj(E,F,I,K),[E,F,I,K]),Q=N.useMemo(()=>u?G:G.filter(L=>L.selectable||L.degraded&&L.active),[G,u]),B=N.useMemo(()=>E.find(L=>L.key===y&&L.selectable),[E,y]);N.useEffect(()=>{var H;const L=document.activeElement;(H=R.current)==null||H.focus();const $=x=>{x.key==="Escape"&&s()};return document.addEventListener("keydown",$),()=>{var x;document.removeEventListener("keydown",$),(x=L==null?void 0:L.focus)==null||x.call(L)}},[s]),N.useEffect(()=>{let L=!0,$=!1;const H=async()=>{if($)return;$=!0;const O=Og(),D=Array.isArray(O.nodeGroups)?O.nodeGroups:[],A=$d(e),W=me=>me.kind!=="vl"&&Array.isArray(me.route)&&me.route.length>0,X=await Promise.all(D.filter(W).map(async me=>({group:me,result:await $d(e,me.route)}))),ie=await A;if(!L)return;const ue=new Map(X.map(({group:me,result:xe})=>[JSON.stringify(me.route||[]),xe])),fe=D.map(me=>{if(!W(me))return{...me,switcherFresh:!1};const xe=ue.get(JSON.stringify(me.route||[]));return xe?{...me,sessions:xe.sessions||me.sessions||[],cells:xe.cells||me.cells||[],switcherFresh:xe.fresh}:{...me,switcherFresh:!1}}),we=Sy({...O,sessions:ie.sessions||O.sessions||[],cells:ie.cells||O.cells||[],localFresh:ie.fresh,nodeGroups:fe,refreshedAt:Date.now()});a(we),m(!0),$=!1};H();const x=setInterval(H,Fj);return()=>{L=!1,clearInterval(x)}},[e]);const M=L=>L.degraded?p("cell-degraded"):L.verified?L.selectable?L.working?p("cell-working"):p("cell-idle"):p("cell-off"):p("cell-switcher-not-confirmed"),j=L=>{if(S(""),!L.selectable){S(p("cell-switcher-not-active"));return}b(L.key)},T=async()=>{const L=B;if(!L){S(p("cell-switcher-select"));return}S(""),k(L.key);try{const $=await $d(e,L.route),H=($.cells||[]).find(x=>(x==null?void 0:x.cell)===L.cellName&&(x==null?void 0:x.tmuxSession)===L.session);if(!fb(H,$.sessions,$.fresh)){S(p("cell-switcher-not-active"));return}n({session:L.session,...L.node?{node:L.node}:{},cellName:L.cellName}),s()}catch{S(p("cell-switcher-not-active"))}finally{k("")}};return c.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:c.jsxs("aside",{ref:C,className:"nc-cell-switcher",role:"dialog","aria-label":p("fleet-cells"),tabIndex:-1,onClick:L=>L.stopPropagation(),children:[c.jsxs("div",{className:"nc-cell-switcher-list",children:[!f&&c.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-refreshing")}),f&&Q.length===0&&c.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-empty-active")}),Q.map(L=>{const $=(t==null?void 0:t.session)===L.session&&((t==null?void 0:t.node)||"")===L.node,H=y===L.key,x=M(L),O=L.node||"local",D=F.get(O)||E.filter(A=>(A.node||"local")===O);return c.jsxs("div",{className:`nc-cell-switcher-row${$?" current":""}${H?" selected":""}${L.selectable?"":" off"}`,"data-roster-key":L.key,"data-position":O,children:[c.jsx(bi,{position:O,itemKey:L.key,label:L.cellName,canMove:Y,onMove:(A,W)=>z(O,A,W,D),onStep:A=>Z(O,L.key,A,D)}),c.jsxs("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":$?"true":void 0,"aria-pressed":H,"aria-disabled":!L.selectable,disabled:w===L.key,onClick:()=>j(L),children:[c.jsx("span",{className:`nc-cell-switcher-dot${L.degraded?" warn":L.live?` on${L.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-cell-switcher-copy",children:[c.jsx("b",{children:L.cellName}),c.jsx("small",{className:"nc-cell-switcher-state",children:x}),c.jsx("small",{children:[L.nodeLabel,L.subtitle].filter(Boolean).join(" · ")})]})]})]},L.key)})]}),v&&c.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:v}),c.jsx("div",{className:"nc-cell-switcher-actions",children:c.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!B||!!w,onClick:T,children:B?`${p("cell-switcher-open")}: ${B.cellName}`:p("cell-switcher-select")})}),c.jsxs("div",{className:"nc-cell-switcher-controls",children:[c.jsx("b",{children:p("fleet-cells")}),c.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":u,onClick:()=>{S(""),h(L=>!L)},children:p(u?"cell-switcher-show-active":"cell-switcher-show-all")}),c.jsx("button",{ref:R,type:"button",className:"nc-cell-switcher-close","aria-label":p("cell-switcher-close"),title:p("cell-switcher-close"),onClick:s,children:"×"})]})]})})}const qj=2e3;function Vj(e){if(e.kind==="gap")return`${p("vl-events-gap")} ${e.count||"?"}`;if(e.kind==="truncate")return p("vl-events-truncated");if(e.kind==="turn_end")return p("vl-events-turn-end");if(e.kind==="done")return p("vl-events-done");if(e.kind==="writer_epoch")return p("vl-events-writer-epoch");if(e.kind==="tool_start")return`${p("vl-events-tool")} ${e.name||""}`.trim();if(e.kind==="tool_end"){const t=e.isError?p("vl-events-tool-failed"):p("vl-events-tool-ok");return`${p("vl-events-tool")} ${e.name||""} — ${t}`.trim()}return e.kind==="usage"?e.text||p("vl-events-usage"):e.text||""}function Yj({token:e,nodeId:t,route:n=[]}){const[s,o]=N.useState([]),[a,u]=N.useState(!1),h=N.useRef(0),f=N.useRef(!1);return N.useEffect(()=>{let m=!0;h.current=0,f.current=!1,o([]);const v=async()=>{if(!f.current){f.current=!0;try{const b=await E0(e,t,h.current,n);if(!m)return;u(!1);const k=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(C=>Number.isSafeInteger(C==null?void 0:C.seq)&&C.seq>h.current);k.length&&(o(C=>C.concat(k).slice(-500)),h.current=k[k.length-1].seq),Number.isSafeInteger(b==null?void 0:b.cursor)&&b.cursor>h.current&&(h.current=b.cursor)}catch{m&&u(!0)}finally{f.current=!1}}},S=()=>{v().catch(()=>{})};S();const y=setInterval(S,qj);return()=>{m=!1,clearInterval(y)}},[e,t,JSON.stringify(n)]),c.jsxs("div",{className:"nc-vl-events",children:[a&&c.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:p("vl-events-stale")}),s.length===0&&!a&&c.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:p("vl-events-empty")}),s.length>0&&c.jsx("ol",{className:"nc-vl-events-list",children:s.map(m=>c.jsx("li",{"data-testid":`vl-ev-${m.seq}`,className:`nc-vl-ev nc-vl-ev-${m.kind}${m.isError?" error":""}${m.kind==="gap"?" gap":""}`,children:Vj(m)},`${m.seq}-${m.kind}`))})]})}function $_({peer:e,token:t,onBack:n}){var s;return kn(),e?c.jsxs("section",{className:"nc-vl-session-view",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:n,title:p("back"),children:[c.jsx(Ze,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:p("back")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:e.label,children:e.label}),((s=e.session)==null?void 0:s.profile)&&c.jsxs("small",{className:"nc-bar-sub",children:[e.session.profile," · ",p("vl-events-title")]})]}),c.jsx("span",{className:"nc-bar-right"})]}),c.jsx("div",{className:"nc-vl-session-body",children:c.jsx(Yj,{token:t,nodeId:e.nodeId,route:e.route||[]})})]}):null}const Hd=e=>ki(Ys(e)).length===0,Ud=e=>Array.isArray(e)?e.join("/"):"";function Gj(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!Hn.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function zo(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function Hs(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:Ar(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:Oh(e.layout,a,n)}}function Xj(e,t,n,s,o=[]){const[a,u]=N.useState([]),[h,f]=N.useState(!1),[m,v]=N.useState("idle"),[S,y]=N.useState(""),[b,w]=N.useState(""),k=N.useRef([]),C=N.useRef([]),R=N.useRef(""),E=N.useRef(t),F=N.useRef(n),I=N.useRef(!1),K=N.useRef(!0),Y=N.useRef(""),z=N.useMemo(()=>Gj(o),[o]),Z=z.map(D=>`${D.instanceId}:${Ud(D.route)}:${D.status}:${D.label}`).join("|");C.current=z,F.current=n,E.current=t,k.current=a;const G=N.useCallback(D=>Bh(D.layout,R.current,C.current),[]),Q=N.useCallback((D,A=!0,W=E.current)=>{const X=Vv(D,xl()),ie=k.current.some(fe=>fe.id===W);k.current=X,u(X);const ue=X.find(fe=>fe.id===W);if(A&&ue){K.current=!0;const fe=G(ue);s(fe),ue.local&&mN(ue.name,fe)}else ie&&!ue&&(K.current=!0,s(Lr()),y("deck non più condiviso dal nodo owner"));dN(X.filter(fe=>fe.local).map(fe=>fe.name))},[s,G]),B=N.useCallback(async D=>{let A=await pl(e);const W=A.decks.find(X=>X.name==="main");if(A.decks.length===1&&W&&W.revision===0&&Hd(W.layout)){const X=uN(),ie=Ys(zh("main")||Lr());if(!Hd(ie)){const ue=Oh(ie,D,[]);A.decks[0]=await ml(e,"main",ue,0,[])}for(const ue of X.filter(fe=>fe!=="main"))try{let fe=await Cg(e,ue,[]);const we=Ys(zh(ue)||Lr());Hd(we)||(fe=await ml(e,ue,Oh(we,D,[]),fe.revision,[]))}catch{}A=await pl(e)}return A},[e]),M=N.useCallback(async({migrate:D=!1}={})=>{const A=await Zh(e,[]),W=Hn.test(String(A.instanceId||""))?A.instanceId:"";if(!W)throw new Error("instanceId locale non disponibile");R.current=W,w(W);const[X,ie]=await Promise.all([D?B(W):pl(e),bg(e,[]).catch(()=>({nodes:[]}))]),ue={instanceId:W,route:[],label:"Local"},fe=X.decks.map(me=>Hs(me,ue,ie.nodes,!0,!0)),we=k.current;return await Promise.all(C.current.map(async me=>{if(me.status!=="up"){fe.push(...we.filter(xe=>!xe.local&&xe.ownerId===me.instanceId).map(xe=>({...xe,ownerRoute:[...me.route],ownerLabel:me.label,available:!1})));return}try{const[xe,$e]=await Promise.all([pl(e,me.route),bg(e,me.route).catch(()=>({nodes:[]}))]);fe.push(...xe.decks.map(ft=>Hs(ft,me,$e.nodes,!1,!0)))}catch{fe.push(...we.filter($e=>!$e.local&&$e.ownerId===me.instanceId).map($e=>({...$e,ownerRoute:[...me.route],ownerLabel:me.label,available:!1})))}})),fe.sort((me,xe)=>me.local===xe.local?me.ownerLabel.localeCompare(xe.ownerLabel)||(me.name==="main"?-1:xe.name==="main"?1:me.name.localeCompare(xe.name)):me.local?-1:1),fe},[e,B,Z]);N.useEffect(()=>{if(!e)return;let D=!1;const A=Y.current!==e;return Y.current=e,M({migrate:A}).then(W=>{if(D)return;const X=k.current.find(fe=>fe.id===E.current),ie=W.find(fe=>fe.id===E.current),ue=ie&&(!X||ie.revision>X.revision||X.available!==ie.available||Ud(X.ownerRoute)!==Ud(ie.ownerRoute));Q(W,A||!!ue&&!I.current),f(!0),ie&&y("")}).catch(W=>{D||(f(!0),y(String(W.message||W)))}),()=>{D=!0}},[Q,M,Z,e]);const j=N.useCallback(async(D=E.current)=>{if(!h||!I.current)return!0;const A=k.current.find(W=>W.id===D);if(!A)return y(`deck inesistente: ${D}`),!1;if(A.available===!1)return y(`nodo owner offline: ${A.ownerLabel}`),!1;v("saving");try{const W=Kv(Ys(F.current),A.ownerId,A.ownerTopology),X=await ml(e,A.name,W,A.revision,A.ownerRoute),ie=Hs(X,zo(A),A.ownerTopology,A.local,!0);return Q(k.current.map(ue=>ue.id===D?ie:ue),!1),I.current=!1,v("saved"),y(""),setTimeout(()=>v("idle"),1500),!0}catch(W){if(v("error"),y(String(W.message||W)),W.status===409&&W.data&&W.data.current){const X=k.current.find(ue=>ue.id===D),ie=Hs(W.data.current,zo(X),X.ownerTopology,X.local,!0);Q(k.current.map(ue=>ue.id===D?ie:ue),!1)}return!1}},[h,e,Q]);return N.useEffect(()=>{if(!h)return;if(K.current){K.current=!1;return}I.current=!0,v("saving");const D=setTimeout(j,650);return()=>clearTimeout(D)},[n,h,j]),N.useEffect(()=>{if(!h)return;const D=setInterval(async()=>{try{const A=await M(),W=k.current.find(ue=>ue.id===E.current),X=A.find(ue=>ue.id===E.current),ie=X&&(!W||X.revision>W.revision||W.available!==X.available);Q(A,ie&&!I.current)}catch{}},5e3);return()=>clearInterval(D)},[h,M,Q]),{decks:a,records:a,localNodeId:b,ready:h,saveState:m,error:S,setError:y,saveNow:j,select:async D=>{if(I.current&&!await j(E.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const A=k.current.find(W=>W.id===D);if(!A)throw new Error(`deck inesistente: ${D}`);return I.current=!1,K.current=!0,G(A)},add:async(D,A=null)=>{const W=A===Si?k.current.find(ue=>ue.local):A?k.current.find(ue=>ue.ownerId===A):null;if(!W||W.available===!1)throw new Error("nodo owner non disponibile");const X=await Cg(e,D,W.ownerRoute),ie=Hs(X,zo(W),W.ownerTopology,W.local,!0);return Q([...k.current,ie],!1),ie},rename:async(D,A)=>{const W=k.current.find(we=>we.id===D);if(!W)throw new Error("deck inesistente");if(D===E.current&&I.current&&!await j(D))throw new Error(`salvataggio di "${W.name}" fallito: rinomina annullata`);const X=k.current.find(we=>we.id===D);if(!X)throw new Error("deck inesistente");const ie=await Q0(e,X.name,A,X.revision,X.ownerRoute),ue=Hs(ie,zo(X),X.ownerTopology,X.local,!0),fe=X.local?Si:X.ownerId;return md(fN(xl(),fe,D,ue.id)),Q(k.current.map(we=>we.id===D?ue:we),!1),ue},remove:async D=>{const A=k.current.find(X=>X.id===D);if(!A)throw new Error("deck inesistente");D===E.current&&(I.current=!1),await J0(e,A.name,A.revision,A.ownerRoute);const W=A.local?Si:A.ownerId;md(pN(xl(),W,D)),Q(k.current.filter(X=>X.id!==D),!1)},reorder:(D,A)=>{const W=k.current.find(me=>me.id===D),X=k.current.find(me=>me.id===A);if(!W||!X)return!1;const ie=W.local?Si:W.ownerId,ue=X.local?Si:X.ownerId;if(ie!==ue)return!1;const fe=k.current.filter(me=>(me.local?Si:me.ownerId)===ie).map(me=>me.id),we=md(hN(xl(),ie,D,A,fe));return Q(Vv(k.current,we),!1),!0},addTileTo:async(D,A)=>{const W=k.current.find(me=>me.id===D);if(!W)throw new Error("deck inesistente");if(W.available===!1)throw new Error(`nodo owner offline: ${W.ownerLabel}`);const X=Lw(A,R.current,C.current);if(!X)throw new Error("riferimento sessione non valido");const ie=G(W),ue=Kv(yy(ie,X),W.ownerId,W.ownerTopology),fe=await ml(e,W.name,ue,W.revision,W.ownerRoute),we=Hs(fe,zo(W),W.ownerTopology,W.local,!0);return Q(k.current.map(me=>me.id===D?we:me),!1),we},localMainId:Ar(null,"main"),parseDeckId:rc}}const Qj="/sw.js",Uh="nc-sw-update";let Wh=null,Kh=!1,qh=null,pb=Object.freeze({needed:!1,kind:null,version:""}),mb=!1;function gb(){typeof window<"u"&&window.dispatchEvent(new Event(Uh))}function vb(){const e=qh||(Kh?{kind:"reload",version:""}:null);pb=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function H_(){return pb}function Jj(e){return typeof window>"u"?()=>{}:(window.addEventListener(Uh,e),()=>window.removeEventListener(Uh,e))}function Ff(e){Kh!==e&&(Kh=e,vb(),gb())}function Zj(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(qh);qh=s,vb(),o||gb()}function eR(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Ff(!0)})}function tR(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{mb&&location.reload()}),navigator.serviceWorker.register(Qj).then(e=>{Wh=e,e.waiting&&Ff(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&eR(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function nR(){mb=!0,Ff(!1);const e=Wh&&Wh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function iR({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",f=u.get("pair")||"",m=f?`${t||""}${n||""}#pair=${f}`:"";return{token:h,pair:m,nextUrl:a}}const _b=9,yb=24,wb="nc_side_w",U_="nc_side_min",sR=240,W_="(min-width:1024px) and (pointer:fine)";function rR(){const e=Number(localStorage.getItem(wb));return e>=180&&e<=480?e:sR}function oR(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=_b&&e<=yb?e:13}function aR(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=iR({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function lR(e){try{return Ys(zh(e))}catch{return Lr()}}function K_(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function cR(){const[e,t]=N.useState(()=>window.matchMedia(W_).matches);return N.useEffect(()=>{const n=window.matchMedia(W_),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function q_({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,onBack:u,onCellSwitcher:h,cellSwitcherOpen:f=!1}){kn();const[m]=kf(),[v,S]=N.useState(!1),[y,b]=N.useState(()=>window.matchMedia("(pointer: coarse)").matches),[w,k]=N.useState(null),[C,R]=N.useState(oR),[E,F]=N.useState(s||e),[I,K]=N.useState(""),Y=$=>R(H=>{const x=Math.max(_b,Math.min(yb,H+$));return localStorage.setItem("nc_fontsize",String(x)),x}),z=N.useRef(()=>{}),Z=N.useRef(()=>!1),G=N.useRef(()=>{}),Q=N.useRef(!1),[B,M]=N.useState(!1),[j,T]=N.useState(!1),L=()=>{Q.current=!Q.current,M(Q.current)};return N.useEffect(()=>{F(s||e)},[s,e]),N.useEffect(()=>{let $=!0;const H=t?t.split("/"):[],x=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function O(){let A=null,W=null;try{const ue=await(await Ht(`${x}/sessions`,o)).json();Array.isArray(ue.sessions)&&(A=ue.sessions.find(fe=>fe.name===e))}catch{}try{const ie=await ws(o,H);ie.available&&Array.isArray(ie.cells)&&(W=ie.cells.find(ue=>ue.tmuxSession===e))}catch{}if(!$)return;F(Cf({session:e,cell:W||(s?{cell:s}:null)}));let X="";W?X=`${W.engine}${W.key?`·${W.key}`:""}`:A&&(X=A.attached?`attached · ${K_(A.activity)}`:A.activity?K_(A.activity):""),K(X)}O();const D=setInterval(O,4e3);return()=>{$=!1,clearInterval(D)}},[e,t,o]),c.jsxs("div",{className:"nc-app",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:u,title:p("sessions"),children:[c.jsx(Ze,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:p("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t?`${E} · ${t}`:E,children:E}),I&&c.jsx("small",{className:"nc-bar-sub",children:I})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>Y(-1),title:p("zoom-out"),children:c.jsx(Ze,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>Y(1),title:p("zoom-in"),children:c.jsx(Ze,{name:"zoomIn",size:18})}),c.jsx("button",{onClick:()=>b($=>!$),title:p("composer"),children:c.jsx(Ze,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>S($=>!$),title:p("files"),children:c.jsx(Ze,{name:"folder",size:20})})]})]}),c.jsx("div",{className:"nc-termwrap",children:c.jsx(gw,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:z,composerRef:Z,actionRef:G,ctrlRef:Q,setCtrlArmed:M,onFiles:k,fontSize:C,selectionMode:j,onSelectionModeChange:T,keyboardGesture:m.terminalKeyboardGesture})}),c.jsx(DE,{onKeyboard:()=>b($=>!$),onCellSwitcher:h,cellSwitcherOpen:f,send:$=>z.current($),action:$=>G.current($),ctrlArmed:B,onCtrl:L,selectionMode:j,onSelectionMode:T,keepKeyboardClosed:m.keybarKeepsKeyboardClosed,showEnter:m.showKeybarEnter,keybarLayout:m.keybarLayout}),y&&c.jsx(Ew,{submitText:$=>Z.current($),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:m.voiceKeepsKeyboardClosed}),v&&c.jsx(vw,{session:e,node:t,token:o,filesEvent:w,onClose:()=>S(!1)})]})}function uR(){kn();const[e]=N.useState(aR),[t,n]=N.useState(e.token),[s,o]=N.useState(e.pair||""),a=N.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=N.useState(!1),f=cR(),[m]=N.useState(()=>cN(typeof location<"u"?location.pathname:"/")),[v,S]=N.useState(m.id),y=v===Ar(null,Un),[b,w]=N.useState(null),k=he=>{const je=ys(he);w(je?{...je,...typeof(he==null?void 0:he.cellName)=="string"&&he.cellName?{cellName:he.cellName}:{}}:null)},[C,R]=N.useState([]),[E,F]=N.useState([]),[I,K]=N.useState([]),[Y,z]=N.useState(()=>m.ownerId?Lr():lR(m.name)),[Z,G]=N.useState(null),[Q,B]=N.useState(null),M=he=>B(ys(he)),[j,T]=N.useState(null),L=nf(t,f),$=N.useMemo(()=>(L||[]).filter(he=>he.instanceId).map(he=>({instanceId:he.instanceId,route:he.route,label:he.label,status:he.status})),[L]),H=Xj(t,v,Y,z,$),x=H.decks;N.useEffect(()=>{const he=new Map;for(const je of L||[]){const Ke=(je.route||[je.name]).join("/"),pt=new Set((je.sessions||[]).map(vt=>vt.name));for(const vt of je.cells||[])!vt.cell||!vt.tmuxSession||vt.cell===vt.tmuxSession||pt.has(vt.cell)||he.set(`${Ke}:${vt.cell}`,`${Ke}:${vt.tmuxSession}`)}z(je=>Nx(je,he))},[L]),N.useEffect(()=>{H.localNodeId&&z(he=>{const je=Bh(he,H.localNodeId,$);return JSON.stringify(je)===JSON.stringify(he)?he:je})},[$,H.localNodeId]);const[O,D]=N.useState(null),[A,W]=N.useState(null),X=N.useRef(0),[ie,ue]=N.useState(!1),[fe,we]=N.useState(rR),[me,xe]=N.useState(!y),[$e,ft]=N.useState(()=>y?localStorage.getItem(U_)==="1":!0),[qe,Ae]=N.useState(!1),[Rt,Jt]=N.useState("nodes"),[Oe,Pt]=N.useState(!1),[bt,dt]=N.useState(""),[ht,Qe]=N.useState(!1),ot=(he="nodes",je=!1,Ke="")=>{Jt(he),Pt(je),dt(Ke),Ae(!0)},[oe,ke]=N.useState(!1),[Te,ae]=N.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[re,Pe]=N.useState(!1);N.useEffect(()=>{try{localStorage.setItem(wb,String(fe))}catch{}},[fe]),N.useEffect(()=>{try{localStorage.setItem(U_,$e?"1":"")}catch{}},[$e]),N.useEffect(()=>{if(!t)return;let he=!1;return Promise.all([ty(t),Ht("/api/config",t).then(je=>je.json())]).then(([je,Ke])=>{he||(ae({deviceDefault:je.deviceName||"",localNodeId:je.nodeId||"",localNameDefault:je.localName||""}),Pe(!!Ke.readonlyDefault),(je.firstRun===!0&&!Ke.readonlyDefault||s)&&ke(!0))}).catch(()=>{}),()=>{he=!0}},[t,s]);const q=N.useCallback(async()=>{try{const je=await(await Ht("/api/sessions",t)).json();je.error||R(je.sessions||[])}catch{}try{const he=await ws(t);F(he.available?he.cells||[]:[]),K(he.available?he.capabilities||[]:[])}catch{F([]),K([])}},[t]);N.useEffect(()=>{if(!f)return;q();const he=setInterval(q,4e3);return()=>clearInterval(he)},[f,q]),N.useEffect(()=>{let he=!1;return Ht("/api/config",t).then(je=>je.json()).then(je=>{he||Zj(je.version,je.uiVersion,"0.8.52-rc.22")}).catch(()=>{}),()=>{he=!0}},[t]);const te=new Set([...C.map(he=>he.name),...L.flatMap(he=>he.sessions.map(je=>je.key))]),U=ki(Y),ce=he=>z(je=>{const Ke=Lw(he,H.localNodeId,$)||he,pt=yy(je,Ke);return pt===je&&ki(je).length>=9&&H.setError(p("grid-full")),pt}),de=async(he,je=[])=>{try{await Xh(t,he,je)}catch{return}const Ke=je.length?`${je.join("/")}:${he}`:he;z(pt=>Hl(pt,Ke)),q()},ge=async(he,je,Ke=[])=>{try{await ey(t,he,je,Ke)}catch{return}q()},De=async(he,je,Ke=[])=>{await Q_(t,{cell:he,enabled:!!je},Ke),q()},_e=async he=>{if(!O)return;const{cell:je}=O,Ke=Array.isArray(O.route)?O.route:[];if(he.action==="up"){const vt=await Gh(t,{cell:je,boot:!!he.boot,...he.engine?{engine:he.engine}:{},...he.model!==void 0?{model:he.model}:{},...he.permissionPolicy?{permissionPolicy:he.permissionPolicy}:{}},Ke),bs=uf(vt);bs&&H.setError(bs.text)}else await Il(t,{cell:je,boot:!!he.boot},Ke);const pt=he.action==="up"?!!he.boot:he.boot?!1:!!O.boot;W({id:++X.current,cell:je,route:Ke,enabled:pt}),q()},Ee=N.useCallback(he=>{W(je=>(je==null?void 0:je.id)===he?null:je)},[]),nt=async he=>{if(!(!(he!=null&&he.direct)||ie)){ue(!0);try{await ef(t,he.name,he.tunnelStatus==="up"?"down":"up")}finally{ue(!1)}}},at=async(he,je)=>{const Ke=String(je||"").trim();return!(he!=null&&he.direct)||!Ir(Ke)?!1:(await sy(t,he.name,Ke),!0)},Je=he=>{const je=x.find(Ke=>Ke.id===he);if(!je)return!1;try{const Ke=window.open(pd(je,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},Mt=async he=>{if(!he||he===v)return;const je=await H.select(he),Ke=H.records.find(pt=>pt.id===he);S(he),z(je),G(null),B(null);try{history.replaceState(null,"",pd(Ke||he,null))}catch{}},ct=async(he,je)=>{const Ke=await H.add(he,je);await Mt(Ke.id)},et=async(he,je)=>{const Ke=await H.rename(he,je);if(he===v){S(Ke.id),z(Bh(Ke.layout,H.localNodeId,$)),G(null),B(null);try{history.replaceState(null,"",pd(Ke,null))}catch{}}},Zt=async he=>{await H.remove(he),he===v&&await Mt(H.localMainId)},ni=async(he,je)=>{!je||je===v||(await H.addTileTo(je,he),z(Ke=>Hl(Ke,he)))};if(!t)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:p("auth-prompt")}),c.jsx("input",{onChange:he=>n(he.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:u,onChange:he=>h(he.target.checked)})," ",p("remember-device")]}),c.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Wn=c.jsxs(c.Fragment,{children:[qe&&c.jsx(Aj,{token:t,initialTab:Rt,initialLocation:bt,startNewCell:Oe,onClose:()=>{Ae(!1),Pt(!1),dt("")}}),oe&&c.jsx(Tj,{token:t,initialPair:s,...Te,onPairDone:a,onDone:()=>ke(!1)}),c.jsx(zj,{token:t})]});if(!f)return j?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-single-overlay",children:c.jsx($_,{peer:j,token:t,onBack:()=>T(null)})}),Wn]}):b?c.jsxs(c.Fragment,{children:[c.jsx(q_,{session:b.session,node:b.node,ownerId:b.ownerId,cellName:b.cellName,token:t,readonly:re,onBack:()=>w(null),onCellSwitcher:()=>Qe(!0),cellSwitcherOpen:ht}),ht&&c.jsx(Kj,{token:t,current:b,onPick:he=>{k(he),Qe(!1)},onClose:()=>Qe(!1)}),Wn]}):c.jsxs(c.Fragment,{children:[c.jsx(Kx,{onPick:k,token:t,onSettings:ot,onOpenVlSession:T}),Wn]});const ui=y||!me;return c.jsxs("div",{className:"nc-workspace",children:[ui&&c.jsx(QE,{sessions:C,cells:E,activeSessions:U,nodeGroups:L,fleetCapabilities:I,bootSettlement:A,onBootSettlementApplied:Ee,localNodeId:H.localNodeId,onPick:M,onAddTile:ce,onPower:D,onBoot:De,onBootError:he=>H.setError(String((he==null?void 0:he.message)||he)),onNodePower:nt,onNodeRename:at,onKill:de,onVisibility:ge,onNew:()=>ot("fleet",!0),onSettings:ot,onOpenVlSession:T,width:fe,collapsed:$e,onResize:we,onToggleCollapse:()=>ft(he=>!he)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(AN,{decks:x,currentDeck:v,onCreate:ct,onRename:et,onDelete:Zt,onReorder:H.reorder,onOpenWindow:Je,onNavigate:Mt,saveState:H.saveState,error:H.error,sidebarVisible:ui,onToggleSidebar:y?null:()=>xe(he=>!he)}),c.jsx(sN,{layout:Y,onLayoutChange:z,token:t,readonly:re,sessionsAlive:te,focusSession:Z,onFocus:G,onOpenSingle:M,decks:x,currentDeck:v,onSendToDeck:ni,cells:E,nodeGroups:L})]}),j&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx($_,{peer:j,token:t,onBack:()=>T(null)})}),Q&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(q_,{session:Q.session,node:Q.node,ownerId:Q.ownerId,cellName:Cf({session:Q.session,node:Q.node,ownerId:Q.ownerId,cells:E,nodeGroups:L}),token:t,readonly:re,onBack:()=>B(null)})}),O&&c.jsx(Bl,{cell:O,token:t,route:Array.isArray(O.route)?O.route:[],onConfirm:_e,onClose:()=>D(null)}),Wn]})}function dR(){kn();const e=N.useSyncExternalStore(Jj,H_,H_);if(!e.needed)return null;const t=e.kind==="install"?p("install-version-mismatch").replace("{v}",e.version):p("update-available").replace("{v}",e.version).replace(" "," ").trim();return c.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&c.jsx("button",{className:"nc-update-btn",onClick:nR,children:p("reload")})]})}tR();p0.createRoot(document.getElementById("root")).render(c.jsxs(a0.StrictMode,{children:[c.jsx(uR,{}),c.jsx(dR,{})]}));
93
+ `],{type:"application/json"}),$=URL.createObjectURL(L),H=document.createElement("a");H.href=$,H.download="nexuscrew-diagnostics.json",H.click(),URL.revokeObjectURL($)}catch{y(p("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[p("diagnostics-target"),c.jsx("select",{value:u.key,onChange:L=>a(L.target.value),children:s.map(L=>c.jsxs("option",{value:L.key,children:[L.label,L.status!=="up"?` · ${L.status}`:""]},L.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:p("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":p("diagnostics-duration"),value:R,onChange:L=>E(Number(L.target.value)),disabled:n,children:[300,900,1800,3600].map(L=>c.jsxs("option",{value:L,children:[L/60," min"]},L))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(h==null?void 0:h.verbose)===!0,onClick:()=>M(()=>kg(e,!0,R,u.route)),children:p("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(h==null?void 0:h.verbose)!==!0,onClick:()=>M(()=>kg(e,!1,R,u.route)),children:p("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?p("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):p("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":p("diagnostics-level"),value:F,onChange:L=>I(L.target.value),children:[c.jsx("option",{value:"all",children:p("diagnostics-all-levels")}),["debug","info","warn","error"].map(L=>c.jsx("option",{value:L,children:L},L))]}),c.jsx("input",{"aria-label":p("diagnostics-component"),placeholder:p("diagnostics-component"),value:K,onChange:L=>Y(L.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:b,onChange:L=>w(L.target.checked)})," ",p("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:k,onChange:L=>C(L.target.checked)})," ",p("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:Z,className:"nc-diag-log","aria-label":p("diagnostics-log"),children:B||p("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:p("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:T,children:p("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(p("diagnostics-clear-confirm"))&&M(async()=>{const L=await V0(e,u.route);return z.current=0,v([]),L})},children:p("diagnostics-clear")})]}),S&&c.jsx("div",{className:"nc-err",children:S})]})}function Lj({token:e,settings:t,readonly:n,refresh:s,roster:o,section:a,setSection:u}){const[h,f]=N.useState(null),[m,v]=N.useState(null),[S,y]=N.useState(!1),[b,w]=N.useState(!1),[k,C]=N.useState(null),[R,E]=N.useState(!0),[F,I]=N.useState(!1);N.useEffect(()=>{C(t&&t.update||null),E(!t||t.autoUpdate!==!1),I(!!(t&&t.alternateScreen))},[t]);const K=async()=>{f(null),v(null),w(!0);try{const j=await N0(e);v(j.note||"ok"),y(!1)}catch(j){f(String(j.message||j))}w(!1)},Y=async()=>{f(null),v(null),w(!0);try{const j=await H0(e);v(`${j.note||"ok"}${j.target?` (${j.target})`:""}`)}catch(j){f(String(j.message||j))}w(!1)},z=async j=>{f(null),v(null),w(!0);try{await Wd(e,{autoUpdate:j}),E(j),s&&await s()}catch(T){f(String(T.message||T))}w(!1)},Z=async j=>{f(null),v(null),w(!0);try{await Wd(e,{alternateScreen:j}),I(j),s&&await s()}catch(T){f(String(T.message||T))}w(!1)},G=async()=>{f(null),v(null),w(!0);try{C(await U0(e))}catch(j){f(String(j.message||j))}w(!1)},Q=async()=>{f(null),v(null),w(!0);try{const j=await W0(e);C(j),v(p("npm-update-restarting"))}catch(j){f(String(j.message||j))}w(!1)},B=()=>{window.confirm(p("composer-clear-confirm"))&&(f(null),KE()?(window.dispatchEvent(new Event(Mh)),v(p("composer-clear-done"))):f(p("composer-clear-failed")))},M=t&&t.service;return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":p("tab-system"),children:["general","diagnostics"].map(j=>c.jsx("button",{type:"button",role:"tab","aria-selected":a===j,className:`nc-set-tabbtn${a===j?" on":""}`,onClick:()=>u(j),children:p(`system-${j}`)},j))}),a==="general"&&c.jsxs(c.Fragment,{children:[c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-this-node")}),t&&c.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,c.jsx("br",{}),M&&M.installed?p("service-installed"):p("service-missing"),M&&M.installed?` · ${M.active?p("service-active"):p("service-inactive")}`:"",M?` · boot ${M.boot?"on":"off"}`:""]}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?p("settings-readonly"):"",onClick:Y,children:p("service-regenerate")})}),c.jsx(Ej,{token:e,readonly:n}),c.jsx(Nj,{})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-updates")}),c.jsxs("div",{className:"nc-set-form nc-update-settings",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:R,disabled:n||b||k&&!k.supported,onChange:j=>z(j.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("npm-auto-update")}),c.jsx("small",{children:p("npm-auto-update-help")})]})]}),k&&c.jsxs("div",{className:"nc-set-info",children:[p("npm-update-current")," v",k.current,k.latest?` · ${p("npm-update-latest")} v${k.latest}`:""," · ",p(`npm-update-${k.supported?k.phase:"unsupported"}`)]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b||!k||!k.supported,onClick:G,children:p("npm-update-check")}),k&&k.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||b||k.phase==="installing",onClick:Q,children:p("npm-update-install")})]}),k&&k.lastError&&c.jsx("div",{className:"nc-err",children:k.lastError})]})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-security")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||b,title:n?p("settings-readonly"):"",onClick:()=>{f(null),v(null),y(!0)},children:p("token-rotate")})})]}),c.jsxs("section",{className:"nc-system-group",children:[c.jsx("h3",{children:p("system-local-data")}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:p("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:p("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:B,children:p("composer-clear-data")})})]})]})]}),a==="diagnostics"&&c.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[c.jsx("h3",{children:p("system-diagnostics")}),c.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[c.jsx("div",{className:"nc-sheet-label",children:p("system-terminal")}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox","aria-label":p("alternate-screen"),checked:F,disabled:n||b,onChange:j=>Z(j.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:p("alternate-screen")}),c.jsx("small",{children:p("alternate-screen-help")})]})]})]}),c.jsx(Pj,{token:e,roster:o,readonly:n})]}),S&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:p("token-rotate-explain")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b,onClick:()=>y(!1),children:p("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:b,onClick:K,children:p("confirm")})]})]}),m&&c.jsx("div",{className:"nc-set-note",children:m}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function Aj({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){kn();const a=n==="diagnostics"?"diagnostics":"general",[u,h]=N.useState(n==="diagnostics"?"system":n),f=N.useRef(null),m=N.useRef(null),[v,S]=N.useState({start:!1,end:!1}),[y,b]=N.useState(a),[w,k]=N.useState(null),[C,R]=N.useState([]),[E,F]=N.useState([]),[I,K]=N.useState(!1),[Y,z]=N.useState(null),[Z,G]=N.useState(0),Q=nf(e,!0,Z),B=N.useCallback(()=>{const j=f.current;if(!j)return;const T=j.scrollWidth>j.clientWidth+1,L={start:T&&j.scrollLeft>1,end:T&&j.scrollLeft+j.clientWidth<j.scrollWidth-1};S($=>$.start===L.start&&$.end===L.end?$:L)},[]);N.useEffect(()=>{const j=f.current;if(!j)return;const T=typeof ResizeObserver=="function"?new ResizeObserver(B):null;return T==null||T.observe(j),window.addEventListener("resize",B),B(),()=>{T==null||T.disconnect(),window.removeEventListener("resize",B)}},[B]),N.useEffect(()=>{var T,L;(L=(T=m.current)==null?void 0:T.scrollIntoView)==null||L.call(T,{behavior:"smooth",block:"nearest",inline:"nearest"});const j=window.requestAnimationFrame?window.requestAnimationFrame(B):setTimeout(B,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(j):clearTimeout(j)}},[u,B]);const M=N.useCallback(async()=>{var j;try{const T=await ty(e);k(T),z(null)}catch(T){z(String(T.message||T))}try{const L=(await C0(e)).peers||[];let $=[],H=[];try{const[x,O]=await Promise.all([Ht("/api/config",e).then(X=>X.json()).catch(()=>null),iy(e).catch(()=>null)]),D=x&&typeof x.instanceId=="string"?x.instanceId:"",A=[{instanceId:D||null,route:[],label:null},...hy(O,D)],W=await Promise.all(A.map(async X=>{try{return{ok:!0,peers:((await ny(e,X.route)).nodes||[]).map(fe=>dy(fe,X)).filter(Boolean)}}catch(ie){return{ok:!1,owner:X,error:ie}}}));for(const X of W){if(X.ok){$.push(...X.peers);continue}X.owner.route.length!==0&&H.push({instanceId:X.owner.instanceId,label:X.owner.label,route:X.owner.route,failure:/timeout/i.test(String(((j=X.error)==null?void 0:j.message)||X.error))?"timeout":"unreachable"})}}catch{}F(H),R([...L,...$])}catch(T){z(String(T.message||T))}},[e]);return N.useEffect(()=>{M();const j=setInterval(M,5e3);return()=>clearInterval(j)},[M]),N.useEffect(()=>{let j=!1;return Ht("/api/config",e).then(T=>T.json()).then(T=>{j||K(!!T.readonlyDefault)}).catch(()=>{}),()=>{j=!0}},[e]),c.jsx("div",{className:"nc-set-overlay",onClick:t,children:c.jsxs("div",{className:"nc-set-panel",onClick:j=>j.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(Ze,{name:"gear",size:18}),c.jsx("b",{children:p("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:p("close"),children:c.jsx(Ze,{name:"x",size:18})})]}),I&&c.jsx("div",{className:"nc-set-readonly",children:p("settings-readonly")}),Y&&c.jsx("div",{className:"nc-err",children:Y}),c.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:c.jsx("div",{className:"nc-set-tabs",ref:f,onScroll:B,children:["nodes","fleet","audio","input","system"].map(j=>c.jsx("button",{ref:u===j?m:null,type:"button",className:`nc-set-tabbtn${u===j?" on":""}`,onClick:()=>h(j),children:p(`tab-${j}`)},j))})}),c.jsxs("div",{className:"nc-set-body",children:[u==="nodes"&&c.jsx(Cj,{token:e,nodes:C,roster:Q,settings:w,readonly:I,vlUnavailable:E,refresh:M,refreshAliases:()=>G(j=>j+1)}),u==="fleet"&&c.jsx(oj,{token:e,readonly:I,startNewCell:o,initialLocation:s,targets:Q.map(j=>({route:j.route,label:j.label||j.name,status:j.status}))}),u==="audio"&&c.jsx(jj,{token:e,readonly:I,nodes:C,settings:w}),u==="input"&&c.jsx(Rj,{}),u==="system"&&c.jsx(Lj,{token:e,settings:w,readonly:I,refresh:M,roster:Q,section:y,setSection:b})]})]})})}function Tj({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){kn();const[h,f]=N.useState(t?"pair":"welcome"),[m,v]=N.useState(!1),[S,y]=N.useState(null),b=async()=>{v(!0),y(null);try{await Wd(e,{wizardDone:!0}),a&&a(),u()}catch(w){y(String(w.message||w)),v(!1)}};return c.jsx("div",{className:"nc-wiz-overlay",children:c.jsxs("div",{className:"nc-wiz",children:[c.jsxs("div",{className:"nc-wiz-head",children:[c.jsx("b",{children:p("wizard-title")}),c.jsx("small",{children:p("hydra-simple")})]}),h==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:p("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:b,children:p("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:m,onClick:()=>f("pair"),children:p("add-node")})]})]}),h==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(Gw,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:v,onSuccess:async()=>{a&&a(),f("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:()=>{a&&a(),f("welcome")},children:p("back")})})]}),h==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:p("node-connected")}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:m,onClick:b,children:p("finish")})})]}),S&&c.jsx("div",{className:"nc-err",children:S})]})})}function Dj(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const Mj=6e3,Ij=12e3;function Oj({n:e,onClose:t}){return c.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"nc-ntf-toast-txt",children:[c.jsx("b",{children:e.title}),e.body&&c.jsx("small",{children:e.body}),e.session&&c.jsx("span",{className:"nc-ntf-from",children:e.session})]}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:p("close"),children:c.jsx(Ze,{name:"x",size:14})})]})}function Bj({ask:e,token:t,onAnswered:n,onDismiss:s}){const[o,a]=N.useState(""),[u,h]=N.useState(!1),[f,m]=N.useState(null),[v,S]=N.useState(!1),y=async w=>{const k=String(w||"").trim();if(!(!k||u)){m(null),h(!0);try{await G0(t,e.id,k),n(e.id)}catch(C){m(String(C.message||C))}h(!1)}},b=async()=>{if(!v){S(!0);try{await X0(t,e.id),s(e.id)}catch{S(!1)}}};return c.jsxs("div",{className:"nc-ask-card",children:[c.jsxs("div",{className:"nc-ask-head",children:[c.jsx("span",{className:"nc-ntf-from",children:e.session}),c.jsxs("code",{className:"nc-ask-id",children:["#",e.id]}),c.jsx("button",{type:"button",className:"nc-ask-dismiss",title:p("ask-dismiss"),"aria-label":p("ask-dismiss"),disabled:v,onClick:b,children:c.jsx(Ze,{name:"x",size:14})})]}),c.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&c.jsx("div",{className:"nc-ask-opts",children:e.options.map(w=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u,onClick:()=>y(w),children:w},w))}),c.jsxs("div",{className:"nc-ask-reply",children:[c.jsx("textarea",{rows:2,placeholder:p("ask-reply-ph"),value:o,disabled:u,onChange:w=>a(w.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||!o.trim(),onClick:()=>y(o),children:p("send")})]}),f&&c.jsx("div",{className:"nc-err",children:f})]})}function zj({token:e}){const[t]=kn(),[n]=hb(),[s,o]=N.useState([]),[a,u]=N.useState([]),[h,f]=N.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),m=N.useRef(0),v=N.useRef(null);v.current||(v.current=Sj());const S=N.useRef({enabled:n,lang:t});S.current={enabled:n,lang:t};const y=N.useCallback(C=>{o(R=>R.filter(E=>E.key!==C))},[]),b=N.useCallback(C=>{const R=`t${m.current+=1}`;o(F=>[...F.slice(-3),{...C,key:R}]),setTimeout(()=>y(R),C.urgency==="high"?Ij:Mj);const E=S.current;if(E.enabled)try{v.current.enqueue(C,vj(C,E.lang))}catch{}},[y]);N.useEffect(()=>{n||v.current.stop()},[n]),N.useEffect(()=>{const C=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&v.current.stop()},R=()=>v.current.stop();return document.addEventListener("visibilitychange",C),window.addEventListener("blur",C),window.addEventListener($h,R),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("blur",C),window.removeEventListener($h,R),typeof v.current.dispose=="function"?v.current.dispose():v.current.stop()}},[]),N.useEffect(()=>{if(!e)return;let C=!1;Y0(e).then(E=>{C||u(E.asks||[])}).catch(()=>{});const R=Dj(e,E=>{E.type==="notify"?b(E):E.type==="ask"&&E.ask&&E.ask.id?u(F=>F.some(I=>I.id===E.ask.id)?F:[...F,E.ask]):E.type==="ask-answered"&&E.id?u(F=>F.filter(I=>I.id!==E.id)):E.type==="ask-dismissed"&&E.id&&u(F=>F.filter(I=>I.id!==E.id))});return()=>{C=!0,R()}},[e,b]);const w=C=>u(R=>R.filter(E=>E.id!==C)),k=C=>u(R=>R.filter(E=>E.id!==C));return c.jsxs(c.Fragment,{children:[s.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:s.map(C=>c.jsx(Oj,{n:C,onClose:()=>y(C.key)},C.key))}),a.length>0&&!h&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>f(!0),title:p("asks-title"),children:["? ",c.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&h&&c.jsxs("div",{className:"nc-ask-panel",children:[c.jsxs("div",{className:"nc-ask-panel-head",children:[c.jsx("b",{children:p("asks-title")}),c.jsx("span",{className:"nc-ask-count",children:a.length}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>f(!1),title:p("close"),children:c.jsx(Ze,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:a.map(C=>c.jsx(Bj,{ask:C,token:e,onAnswered:w,onDismiss:k},C.id))})]})]})}const Fj=4e3;async function $j(e){const t=await Ht("/api/sessions",e);if((t==null?void 0:t.ok)===!1)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function $d(e,t=[]){var h;const[n,s]=await Promise.allSettled([t.length?Jh(e,t):$j(e),ws(e,t)]),o=n.status==="fulfilled"&&Array.isArray((h=n.value)==null?void 0:h.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,u=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:o,cells:u,fresh:Array.isArray(o)&&Array.isArray(u)}}function fb(e,t,n){return n===!0&&(e==null?void 0:e.degraded)!==!0&&(e==null?void 0:e.active)===!0&&e.tmux!==!1&&!!e.tmuxSession&&(t||[]).some(s=>(s==null?void 0:s.name)===e.tmuxSession)}function Hj(e){const t=new Map((e.sessions||[]).map(o=>[o.name,o])),n=[],s=(o,a,u,h=[],f="")=>{const m=new Map((a||[]).map(v=>[v.name,v]));for(const v of o||[]){const S=m.get(v.tmuxSession)||{},y=of(v,S),b=fb(v,a,u);n.push({key:Go(h,v.tmuxSession||v.cell),session:v.tmuxSession,route:h,cellName:v.cell,label:v.cell,node:h.length?h.join("/"):"",nodeLabel:f,live:b,selectable:b,verified:u===!0,working:y.working,degraded:!!v.degraded,active:v.active===!0,activity:S.activity||v.activity||0,subtitle:y.subtitle})}};s(e.cells,[...t.values()],e.localFresh===!0);for(const o of e.nodeGroups||[]){const a=Array.isArray(o.route)?o.route:[];o.kind==="vl"||!a.length||s(o.cells,o.sessions,o.switcherFresh===!0,a,o.label||o.name||"")}return n}function Uj(e){const t=new Map,n=Array.isArray(e.sessions)?e.sessions:[],s=Array.isArray(e.cells)?e.cells:[],o=new Map(n.map(u=>[u.name,u])),a=new Set(s.map(u=>u.tmuxSession).filter(Boolean));t.set("local",af(s,n.filter(u=>!a.has(u.name)),o));for(const u of e.nodeGroups||[]){const h=Array.isArray(u.route)?u.route:[];if(u.kind==="vl"||!h.length)continue;const f=Array.isArray(u.cells)?u.cells:[],m=Array.isArray(u.sessions)?u.sessions:[],v=new Set(f.map(S=>S.tmuxSession).filter(Boolean));t.set(h.join("/"),Fl({...u,route:h,cells:f,sessions:m,unmanaged:m.filter(S=>!v.has(S.name))}).rawItems)}return t}function Wj(e,t,n,s){return[...new Set(e.map(a=>a.node||"local"))].flatMap(a=>{const u=e.filter(v=>(v.node||"local")===a),h=new Map((t.get(a)||[]).map(v=>[v.key,v])),f=new Map(u.map(v=>[v.key,v])),m=u.map(v=>{const S=h.get(v.key);return{...v,label:(S==null?void 0:S.label)||v.label,live:(S==null?void 0:S.live)??v.live,fresh:(S==null?void 0:S.fresh)===!0,activity:(S==null?void 0:S.activity)??v.activity}});return gs(m,n,"all",Fi(s,a)).map(v=>f.get(v.key))})}function Kj({token:e,current:t,onPick:n,onClose:s}){const[o,a]=N.useState(Og),[u,h]=N.useState(!1),[f,m]=N.useState(!1),[v,S]=N.useState(""),[y,b]=N.useState(""),[w,k]=N.useState(""),C=N.useRef(null),R=N.useRef(null),E=N.useMemo(()=>Hj(o),[o]),F=N.useMemo(()=>Uj(o),[o]),{pins:I,orders:K,canMoveRoster:Y,moveRoster:z,stepRoster:Z}=rf(),G=N.useMemo(()=>Wj(E,F,I,K),[E,F,I,K]),Q=N.useMemo(()=>u?G:G.filter(L=>L.selectable||L.degraded&&L.active),[G,u]),B=N.useMemo(()=>E.find(L=>L.key===y&&L.selectable),[E,y]);N.useEffect(()=>{var H;const L=document.activeElement;(H=R.current)==null||H.focus();const $=x=>{x.key==="Escape"&&s()};return document.addEventListener("keydown",$),()=>{var x;document.removeEventListener("keydown",$),(x=L==null?void 0:L.focus)==null||x.call(L)}},[s]),N.useEffect(()=>{let L=!0,$=!1;const H=async()=>{if($)return;$=!0;const O=Og(),D=Array.isArray(O.nodeGroups)?O.nodeGroups:[],A=$d(e),W=me=>me.kind!=="vl"&&Array.isArray(me.route)&&me.route.length>0,X=await Promise.all(D.filter(W).map(async me=>({group:me,result:await $d(e,me.route)}))),ie=await A;if(!L)return;const ce=new Map(X.map(({group:me,result:xe})=>[JSON.stringify(me.route||[]),xe])),fe=D.map(me=>{if(!W(me))return{...me,switcherFresh:!1};const xe=ce.get(JSON.stringify(me.route||[]));return xe?{...me,sessions:xe.sessions||me.sessions||[],cells:xe.cells||me.cells||[],switcherFresh:xe.fresh}:{...me,switcherFresh:!1}}),we=Sy({...O,sessions:ie.sessions||O.sessions||[],cells:ie.cells||O.cells||[],localFresh:ie.fresh,nodeGroups:fe,refreshedAt:Date.now()});a(we),m(!0),$=!1};H();const x=setInterval(H,Fj);return()=>{L=!1,clearInterval(x)}},[e]);const M=L=>L.degraded?p("cell-degraded"):L.verified?L.selectable?L.working?p("cell-working"):p("cell-idle"):p("cell-off"):p("cell-switcher-not-confirmed"),j=L=>{if(S(""),!L.selectable){S(p("cell-switcher-not-active"));return}b(L.key)},T=async()=>{const L=B;if(!L){S(p("cell-switcher-select"));return}S(""),k(L.key);try{const $=await $d(e,L.route),H=($.cells||[]).find(x=>(x==null?void 0:x.cell)===L.cellName&&(x==null?void 0:x.tmuxSession)===L.session);if(!fb(H,$.sessions,$.fresh)){S(p("cell-switcher-not-active"));return}n({session:L.session,...L.node?{node:L.node}:{},cellName:L.cellName}),s()}catch{S(p("cell-switcher-not-active"))}finally{k("")}};return c.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:c.jsxs("aside",{ref:C,className:"nc-cell-switcher",role:"dialog","aria-label":p("fleet-cells"),tabIndex:-1,onClick:L=>L.stopPropagation(),children:[c.jsxs("div",{className:"nc-cell-switcher-list",children:[!f&&c.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-refreshing")}),f&&Q.length===0&&c.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-empty-active")}),Q.map(L=>{const $=(t==null?void 0:t.session)===L.session&&((t==null?void 0:t.node)||"")===L.node,H=y===L.key,x=M(L),O=L.node||"local",D=F.get(O)||E.filter(A=>(A.node||"local")===O);return c.jsxs("div",{className:`nc-cell-switcher-row${$?" current":""}${H?" selected":""}${L.selectable?"":" off"}`,"data-roster-key":L.key,"data-position":O,children:[c.jsx(bi,{position:O,itemKey:L.key,label:L.cellName,canMove:Y,onMove:(A,W)=>z(O,A,W,D),onStep:A=>Z(O,L.key,A,D)}),c.jsxs("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":$?"true":void 0,"aria-pressed":H,"aria-disabled":!L.selectable,disabled:w===L.key,onClick:()=>j(L),children:[c.jsx("span",{className:`nc-cell-switcher-dot${L.degraded?" warn":L.live?` on${L.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-cell-switcher-copy",children:[c.jsx("b",{children:L.cellName}),c.jsx("small",{className:"nc-cell-switcher-state",children:x}),c.jsx("small",{children:[L.nodeLabel,L.subtitle].filter(Boolean).join(" · ")})]})]})]},L.key)})]}),v&&c.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:v}),c.jsx("div",{className:"nc-cell-switcher-actions",children:c.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!B||!!w,onClick:T,children:B?`${p("cell-switcher-open")}: ${B.cellName}`:p("cell-switcher-select")})}),c.jsxs("div",{className:"nc-cell-switcher-controls",children:[c.jsx("b",{children:p("fleet-cells")}),c.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":u,onClick:()=>{S(""),h(L=>!L)},children:p(u?"cell-switcher-show-active":"cell-switcher-show-all")}),c.jsx("button",{ref:R,type:"button",className:"nc-cell-switcher-close","aria-label":p("cell-switcher-close"),title:p("cell-switcher-close"),onClick:s,children:"×"})]})]})})}const qj=2e3;function Vj(e){if(e.kind==="gap")return`${p("vl-events-gap")} ${e.count||"?"}`;if(e.kind==="truncate")return p("vl-events-truncated");if(e.kind==="turn_end")return p("vl-events-turn-end");if(e.kind==="done")return p("vl-events-done");if(e.kind==="writer_epoch")return p("vl-events-writer-epoch");if(e.kind==="tool_start")return`${p("vl-events-tool")} ${e.name||""}`.trim();if(e.kind==="tool_end"){const t=e.isError?p("vl-events-tool-failed"):p("vl-events-tool-ok");return`${p("vl-events-tool")} ${e.name||""} — ${t}`.trim()}return e.kind==="usage"?e.text||p("vl-events-usage"):e.text||""}function Yj({token:e,nodeId:t,route:n=[]}){const[s,o]=N.useState([]),[a,u]=N.useState(!1),h=N.useRef(0),f=N.useRef(!1);return N.useEffect(()=>{let m=!0;h.current=0,f.current=!1,o([]);const v=async()=>{if(!f.current){f.current=!0;try{const b=await E0(e,t,h.current,n);if(!m)return;u(!1);const k=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(C=>Number.isSafeInteger(C==null?void 0:C.seq)&&C.seq>h.current);k.length&&(o(C=>C.concat(k).slice(-500)),h.current=k[k.length-1].seq),Number.isSafeInteger(b==null?void 0:b.cursor)&&b.cursor>h.current&&(h.current=b.cursor)}catch{m&&u(!0)}finally{f.current=!1}}},S=()=>{v().catch(()=>{})};S();const y=setInterval(S,qj);return()=>{m=!1,clearInterval(y)}},[e,t,JSON.stringify(n)]),c.jsxs("div",{className:"nc-vl-events",children:[a&&c.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:p("vl-events-stale")}),s.length===0&&!a&&c.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:p("vl-events-empty")}),s.length>0&&c.jsx("ol",{className:"nc-vl-events-list",children:s.map(m=>c.jsx("li",{"data-testid":`vl-ev-${m.seq}`,className:`nc-vl-ev nc-vl-ev-${m.kind}${m.isError?" error":""}${m.kind==="gap"?" gap":""}`,children:Vj(m)},`${m.seq}-${m.kind}`))})]})}function $_({peer:e,token:t,onBack:n}){var s;return kn(),e?c.jsxs("section",{className:"nc-vl-session-view",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:n,title:p("back"),children:[c.jsx(Ze,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:p("back")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:e.label,children:e.label}),((s=e.session)==null?void 0:s.profile)&&c.jsxs("small",{className:"nc-bar-sub",children:[e.session.profile," · ",p("vl-events-title")]})]}),c.jsx("span",{className:"nc-bar-right"})]}),c.jsx("div",{className:"nc-vl-session-body",children:c.jsx(Yj,{token:t,nodeId:e.nodeId,route:e.route||[]})})]}):null}const Hd=e=>ki(Ys(e)).length===0,Ud=e=>Array.isArray(e)?e.join("/"):"";function Gj(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!Hn.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function zo(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function Hs(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:Ar(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:Oh(e.layout,a,n)}}function Xj(e,t,n,s,o=[]){const[a,u]=N.useState([]),[h,f]=N.useState(!1),[m,v]=N.useState("idle"),[S,y]=N.useState(""),[b,w]=N.useState(""),k=N.useRef([]),C=N.useRef([]),R=N.useRef(""),E=N.useRef(t),F=N.useRef(n),I=N.useRef(!1),K=N.useRef(!0),Y=N.useRef(""),z=N.useMemo(()=>Gj(o),[o]),Z=z.map(D=>`${D.instanceId}:${Ud(D.route)}:${D.status}:${D.label}`).join("|");C.current=z,F.current=n,E.current=t,k.current=a;const G=N.useCallback(D=>Bh(D.layout,R.current,C.current),[]),Q=N.useCallback((D,A=!0,W=E.current)=>{const X=Vv(D,xl()),ie=k.current.some(fe=>fe.id===W);k.current=X,u(X);const ce=X.find(fe=>fe.id===W);if(A&&ce){K.current=!0;const fe=G(ce);s(fe),ce.local&&mN(ce.name,fe)}else ie&&!ce&&(K.current=!0,s(Lr()),y("deck non più condiviso dal nodo owner"));dN(X.filter(fe=>fe.local).map(fe=>fe.name))},[s,G]),B=N.useCallback(async D=>{let A=await pl(e);const W=A.decks.find(X=>X.name==="main");if(A.decks.length===1&&W&&W.revision===0&&Hd(W.layout)){const X=uN(),ie=Ys(zh("main")||Lr());if(!Hd(ie)){const ce=Oh(ie,D,[]);A.decks[0]=await ml(e,"main",ce,0,[])}for(const ce of X.filter(fe=>fe!=="main"))try{let fe=await Cg(e,ce,[]);const we=Ys(zh(ce)||Lr());Hd(we)||(fe=await ml(e,ce,Oh(we,D,[]),fe.revision,[]))}catch{}A=await pl(e)}return A},[e]),M=N.useCallback(async({migrate:D=!1}={})=>{const A=await Zh(e,[]),W=Hn.test(String(A.instanceId||""))?A.instanceId:"";if(!W)throw new Error("instanceId locale non disponibile");R.current=W,w(W);const[X,ie]=await Promise.all([D?B(W):pl(e),bg(e,[]).catch(()=>({nodes:[]}))]),ce={instanceId:W,route:[],label:"Local"},fe=X.decks.map(me=>Hs(me,ce,ie.nodes,!0,!0)),we=k.current;return await Promise.all(C.current.map(async me=>{if(me.status!=="up"){fe.push(...we.filter(xe=>!xe.local&&xe.ownerId===me.instanceId).map(xe=>({...xe,ownerRoute:[...me.route],ownerLabel:me.label,available:!1})));return}try{const[xe,$e]=await Promise.all([pl(e,me.route),bg(e,me.route).catch(()=>({nodes:[]}))]);fe.push(...xe.decks.map(ft=>Hs(ft,me,$e.nodes,!1,!0)))}catch{fe.push(...we.filter($e=>!$e.local&&$e.ownerId===me.instanceId).map($e=>({...$e,ownerRoute:[...me.route],ownerLabel:me.label,available:!1})))}})),fe.sort((me,xe)=>me.local===xe.local?me.ownerLabel.localeCompare(xe.ownerLabel)||(me.name==="main"?-1:xe.name==="main"?1:me.name.localeCompare(xe.name)):me.local?-1:1),fe},[e,B,Z]);N.useEffect(()=>{if(!e)return;let D=!1;const A=Y.current!==e;return Y.current=e,M({migrate:A}).then(W=>{if(D)return;const X=k.current.find(fe=>fe.id===E.current),ie=W.find(fe=>fe.id===E.current),ce=ie&&(!X||ie.revision>X.revision||X.available!==ie.available||Ud(X.ownerRoute)!==Ud(ie.ownerRoute));Q(W,A||!!ce&&!I.current),f(!0),ie&&y("")}).catch(W=>{D||(f(!0),y(String(W.message||W)))}),()=>{D=!0}},[Q,M,Z,e]);const j=N.useCallback(async(D=E.current)=>{if(!h||!I.current)return!0;const A=k.current.find(W=>W.id===D);if(!A)return y(`deck inesistente: ${D}`),!1;if(A.available===!1)return y(`nodo owner offline: ${A.ownerLabel}`),!1;v("saving");try{const W=Kv(Ys(F.current),A.ownerId,A.ownerTopology),X=await ml(e,A.name,W,A.revision,A.ownerRoute),ie=Hs(X,zo(A),A.ownerTopology,A.local,!0);return Q(k.current.map(ce=>ce.id===D?ie:ce),!1),I.current=!1,v("saved"),y(""),setTimeout(()=>v("idle"),1500),!0}catch(W){if(v("error"),y(String(W.message||W)),W.status===409&&W.data&&W.data.current){const X=k.current.find(ce=>ce.id===D),ie=Hs(W.data.current,zo(X),X.ownerTopology,X.local,!0);Q(k.current.map(ce=>ce.id===D?ie:ce),!1)}return!1}},[h,e,Q]);return N.useEffect(()=>{if(!h)return;if(K.current){K.current=!1;return}I.current=!0,v("saving");const D=setTimeout(j,650);return()=>clearTimeout(D)},[n,h,j]),N.useEffect(()=>{if(!h)return;const D=setInterval(async()=>{try{const A=await M(),W=k.current.find(ce=>ce.id===E.current),X=A.find(ce=>ce.id===E.current),ie=X&&(!W||X.revision>W.revision||W.available!==X.available);Q(A,ie&&!I.current)}catch{}},5e3);return()=>clearInterval(D)},[h,M,Q]),{decks:a,records:a,localNodeId:b,ready:h,saveState:m,error:S,setError:y,saveNow:j,select:async D=>{if(I.current&&!await j(E.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const A=k.current.find(W=>W.id===D);if(!A)throw new Error(`deck inesistente: ${D}`);return I.current=!1,K.current=!0,G(A)},add:async(D,A=null)=>{const W=A===Si?k.current.find(ce=>ce.local):A?k.current.find(ce=>ce.ownerId===A):null;if(!W||W.available===!1)throw new Error("nodo owner non disponibile");const X=await Cg(e,D,W.ownerRoute),ie=Hs(X,zo(W),W.ownerTopology,W.local,!0);return Q([...k.current,ie],!1),ie},rename:async(D,A)=>{const W=k.current.find(we=>we.id===D);if(!W)throw new Error("deck inesistente");if(D===E.current&&I.current&&!await j(D))throw new Error(`salvataggio di "${W.name}" fallito: rinomina annullata`);const X=k.current.find(we=>we.id===D);if(!X)throw new Error("deck inesistente");const ie=await Q0(e,X.name,A,X.revision,X.ownerRoute),ce=Hs(ie,zo(X),X.ownerTopology,X.local,!0),fe=X.local?Si:X.ownerId;return md(fN(xl(),fe,D,ce.id)),Q(k.current.map(we=>we.id===D?ce:we),!1),ce},remove:async D=>{const A=k.current.find(X=>X.id===D);if(!A)throw new Error("deck inesistente");D===E.current&&(I.current=!1),await J0(e,A.name,A.revision,A.ownerRoute);const W=A.local?Si:A.ownerId;md(pN(xl(),W,D)),Q(k.current.filter(X=>X.id!==D),!1)},reorder:(D,A)=>{const W=k.current.find(me=>me.id===D),X=k.current.find(me=>me.id===A);if(!W||!X)return!1;const ie=W.local?Si:W.ownerId,ce=X.local?Si:X.ownerId;if(ie!==ce)return!1;const fe=k.current.filter(me=>(me.local?Si:me.ownerId)===ie).map(me=>me.id),we=md(hN(xl(),ie,D,A,fe));return Q(Vv(k.current,we),!1),!0},addTileTo:async(D,A)=>{const W=k.current.find(me=>me.id===D);if(!W)throw new Error("deck inesistente");if(W.available===!1)throw new Error(`nodo owner offline: ${W.ownerLabel}`);const X=Lw(A,R.current,C.current);if(!X)throw new Error("riferimento sessione non valido");const ie=G(W),ce=Kv(yy(ie,X),W.ownerId,W.ownerTopology),fe=await ml(e,W.name,ce,W.revision,W.ownerRoute),we=Hs(fe,zo(W),W.ownerTopology,W.local,!0);return Q(k.current.map(me=>me.id===D?we:me),!1),we},localMainId:Ar(null,"main"),parseDeckId:rc}}const Qj="/sw.js",Uh="nc-sw-update";let Wh=null,Kh=!1,qh=null,pb=Object.freeze({needed:!1,kind:null,version:""}),mb=!1;function gb(){typeof window<"u"&&window.dispatchEvent(new Event(Uh))}function vb(){const e=qh||(Kh?{kind:"reload",version:""}:null);pb=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function H_(){return pb}function Jj(e){return typeof window>"u"?()=>{}:(window.addEventListener(Uh,e),()=>window.removeEventListener(Uh,e))}function Ff(e){Kh!==e&&(Kh=e,vb(),gb())}function Zj(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(qh);qh=s,vb(),o||gb()}function eR(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Ff(!0)})}function tR(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{mb&&location.reload()}),navigator.serviceWorker.register(Qj).then(e=>{Wh=e,e.waiting&&Ff(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&eR(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function nR(){mb=!0,Ff(!1);const e=Wh&&Wh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function iR({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",f=u.get("pair")||"",m=f?`${t||""}${n||""}#pair=${f}`:"";return{token:h,pair:m,nextUrl:a}}const _b=9,yb=24,wb="nc_side_w",U_="nc_side_min",sR=240,W_="(min-width:1024px) and (pointer:fine)";function rR(){const e=Number(localStorage.getItem(wb));return e>=180&&e<=480?e:sR}function oR(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=_b&&e<=yb?e:13}function aR(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=iR({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function lR(e){try{return Ys(zh(e))}catch{return Lr()}}function K_(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function cR(){const[e,t]=N.useState(()=>window.matchMedia(W_).matches);return N.useEffect(()=>{const n=window.matchMedia(W_),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function q_({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,onBack:u,onCellSwitcher:h,cellSwitcherOpen:f=!1}){kn();const[m]=kf(),[v,S]=N.useState(!1),[y,b]=N.useState(()=>window.matchMedia("(pointer: coarse)").matches),[w,k]=N.useState(null),[C,R]=N.useState(oR),[E,F]=N.useState(s||e),[I,K]=N.useState(""),Y=$=>R(H=>{const x=Math.max(_b,Math.min(yb,H+$));return localStorage.setItem("nc_fontsize",String(x)),x}),z=N.useRef(()=>{}),Z=N.useRef(()=>!1),G=N.useRef(()=>{}),Q=N.useRef(!1),[B,M]=N.useState(!1),[j,T]=N.useState(!1),L=()=>{Q.current=!Q.current,M(Q.current)};return N.useEffect(()=>{F(s||e)},[s,e]),N.useEffect(()=>{let $=!0;const H=t?t.split("/"):[],x=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function O(){let A=null,W=null;try{const ce=await(await Ht(`${x}/sessions`,o)).json();Array.isArray(ce.sessions)&&(A=ce.sessions.find(fe=>fe.name===e))}catch{}try{const ie=await ws(o,H);ie.available&&Array.isArray(ie.cells)&&(W=ie.cells.find(ce=>ce.tmuxSession===e))}catch{}if(!$)return;F(Cf({session:e,cell:W||(s?{cell:s}:null)}));let X="";W?X=`${W.engine}${W.key?`·${W.key}`:""}`:A&&(X=A.attached?`attached · ${K_(A.activity)}`:A.activity?K_(A.activity):""),K(X)}O();const D=setInterval(O,4e3);return()=>{$=!1,clearInterval(D)}},[e,t,o]),c.jsxs("div",{className:"nc-app",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:u,title:p("sessions"),children:[c.jsx(Ze,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:p("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t?`${E} · ${t}`:E,children:E}),I&&c.jsx("small",{className:"nc-bar-sub",children:I})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>Y(-1),title:p("zoom-out"),children:c.jsx(Ze,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>Y(1),title:p("zoom-in"),children:c.jsx(Ze,{name:"zoomIn",size:18})}),c.jsx("button",{onClick:()=>b($=>!$),title:p("composer"),children:c.jsx(Ze,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>S($=>!$),title:p("files"),children:c.jsx(Ze,{name:"folder",size:20})})]})]}),c.jsx("div",{className:"nc-termwrap",children:c.jsx(gw,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:z,composerRef:Z,actionRef:G,ctrlRef:Q,setCtrlArmed:M,onFiles:k,fontSize:C,selectionMode:j,onSelectionModeChange:T,keyboardGesture:m.terminalKeyboardGesture})}),c.jsx(DE,{onKeyboard:()=>b($=>!$),onCellSwitcher:h,cellSwitcherOpen:f,send:$=>z.current($),action:$=>G.current($),ctrlArmed:B,onCtrl:L,selectionMode:j,onSelectionMode:T,keepKeyboardClosed:m.keybarKeepsKeyboardClosed,showEnter:m.showKeybarEnter,keybarLayout:m.keybarLayout}),y&&c.jsx(Ew,{submitText:$=>Z.current($),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:m.voiceKeepsKeyboardClosed}),v&&c.jsx(vw,{session:e,node:t,token:o,filesEvent:w,onClose:()=>S(!1)})]})}function uR(){kn();const[e]=N.useState(aR),[t,n]=N.useState(e.token),[s,o]=N.useState(e.pair||""),a=N.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=N.useState(!1),f=cR(),[m]=N.useState(()=>cN(typeof location<"u"?location.pathname:"/")),[v,S]=N.useState(m.id),y=v===Ar(null,Un),[b,w]=N.useState(null),k=he=>{const je=ys(he);w(je?{...je,...typeof(he==null?void 0:he.cellName)=="string"&&he.cellName?{cellName:he.cellName}:{}}:null)},[C,R]=N.useState([]),[E,F]=N.useState([]),[I,K]=N.useState([]),[Y,z]=N.useState(()=>m.ownerId?Lr():lR(m.name)),[Z,G]=N.useState(null),[Q,B]=N.useState(null),M=he=>B(ys(he)),[j,T]=N.useState(null),L=nf(t,f),$=N.useMemo(()=>(L||[]).filter(he=>he.instanceId).map(he=>({instanceId:he.instanceId,route:he.route,label:he.label,status:he.status})),[L]),H=Xj(t,v,Y,z,$),x=H.decks;N.useEffect(()=>{const he=new Map;for(const je of L||[]){const Ke=(je.route||[je.name]).join("/"),pt=new Set((je.sessions||[]).map(vt=>vt.name));for(const vt of je.cells||[])!vt.cell||!vt.tmuxSession||vt.cell===vt.tmuxSession||pt.has(vt.cell)||he.set(`${Ke}:${vt.cell}`,`${Ke}:${vt.tmuxSession}`)}z(je=>Nx(je,he))},[L]),N.useEffect(()=>{H.localNodeId&&z(he=>{const je=Bh(he,H.localNodeId,$);return JSON.stringify(je)===JSON.stringify(he)?he:je})},[$,H.localNodeId]);const[O,D]=N.useState(null),[A,W]=N.useState(null),X=N.useRef(0),[ie,ce]=N.useState(!1),[fe,we]=N.useState(rR),[me,xe]=N.useState(!y),[$e,ft]=N.useState(()=>y?localStorage.getItem(U_)==="1":!0),[qe,Ae]=N.useState(!1),[Rt,Vt]=N.useState("nodes"),[Oe,Pt]=N.useState(!1),[bt,dt]=N.useState(""),[ht,Qe]=N.useState(!1),ot=(he="nodes",je=!1,Ke="")=>{Vt(he),Pt(je),dt(Ke),Ae(!0)},[oe,ke]=N.useState(!1),[Te,ae]=N.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[re,Pe]=N.useState(!1);N.useEffect(()=>{try{localStorage.setItem(wb,String(fe))}catch{}},[fe]),N.useEffect(()=>{try{localStorage.setItem(U_,$e?"1":"")}catch{}},[$e]),N.useEffect(()=>{if(!t)return;let he=!1;return Promise.all([ty(t),Ht("/api/config",t).then(je=>je.json())]).then(([je,Ke])=>{he||(ae({deviceDefault:je.deviceName||"",localNodeId:je.nodeId||"",localNameDefault:je.localName||""}),Pe(!!Ke.readonlyDefault),(je.firstRun===!0&&!Ke.readonlyDefault||s)&&ke(!0))}).catch(()=>{}),()=>{he=!0}},[t,s]);const q=N.useCallback(async()=>{try{const je=await(await Ht("/api/sessions",t)).json();je.error||R(je.sessions||[])}catch{}try{const he=await ws(t);F(he.available?he.cells||[]:[]),K(he.available?he.capabilities||[]:[])}catch{F([]),K([])}},[t]);N.useEffect(()=>{if(!f)return;q();const he=setInterval(q,4e3);return()=>clearInterval(he)},[f,q]),N.useEffect(()=>{let he=!1;return Ht("/api/config",t).then(je=>je.json()).then(je=>{he||Zj(je.version,je.uiVersion,"0.8.52-rc.23")}).catch(()=>{}),()=>{he=!0}},[t]);const te=new Set([...C.map(he=>he.name),...L.flatMap(he=>he.sessions.map(je=>je.key))]),U=ki(Y),ue=he=>z(je=>{const Ke=Lw(he,H.localNodeId,$)||he,pt=yy(je,Ke);return pt===je&&ki(je).length>=9&&H.setError(p("grid-full")),pt}),de=async(he,je=[])=>{try{await Xh(t,he,je)}catch{return}const Ke=je.length?`${je.join("/")}:${he}`:he;z(pt=>Hl(pt,Ke)),q()},ge=async(he,je,Ke=[])=>{try{await ey(t,he,je,Ke)}catch{return}q()},De=async(he,je,Ke=[])=>{await Q_(t,{cell:he,enabled:!!je},Ke),q()},_e=async he=>{if(!O)return;const{cell:je}=O,Ke=Array.isArray(O.route)?O.route:[];if(he.action==="up"){const vt=await Gh(t,{cell:je,boot:!!he.boot,...he.engine?{engine:he.engine}:{},...he.model!==void 0?{model:he.model}:{},...he.permissionPolicy?{permissionPolicy:he.permissionPolicy}:{}},Ke),bs=uf(vt);bs&&H.setError(bs.text)}else await Il(t,{cell:je,boot:!!he.boot},Ke);const pt=he.action==="up"?!!he.boot:he.boot?!1:!!O.boot;W({id:++X.current,cell:je,route:Ke,enabled:pt}),q()},Ee=N.useCallback(he=>{W(je=>(je==null?void 0:je.id)===he?null:je)},[]),nt=async he=>{if(!(!(he!=null&&he.direct)||ie)){ce(!0);try{await ef(t,he.name,he.tunnelStatus==="up"?"down":"up")}finally{ce(!1)}}},at=async(he,je)=>{const Ke=String(je||"").trim();return!(he!=null&&he.direct)||!Ir(Ke)?!1:(await sy(t,he.name,Ke),!0)},Je=he=>{const je=x.find(Ke=>Ke.id===he);if(!je)return!1;try{const Ke=window.open(pd(je,t),"_blank");return Ke&&(Ke.opener=null),!!Ke}catch{return!1}},Mt=async he=>{if(!he||he===v)return;const je=await H.select(he),Ke=H.records.find(pt=>pt.id===he);S(he),z(je),G(null),B(null);try{history.replaceState(null,"",pd(Ke||he,null))}catch{}},ct=async(he,je)=>{const Ke=await H.add(he,je);await Mt(Ke.id)},et=async(he,je)=>{const Ke=await H.rename(he,je);if(he===v){S(Ke.id),z(Bh(Ke.layout,H.localNodeId,$)),G(null),B(null);try{history.replaceState(null,"",pd(Ke,null))}catch{}}},Zt=async he=>{await H.remove(he),he===v&&await Mt(H.localMainId)},ni=async(he,je)=>{!je||je===v||(await H.addTileTo(je,he),z(Ke=>Hl(Ke,he)))};if(!t)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:p("auth-prompt")}),c.jsx("input",{onChange:he=>n(he.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:u,onChange:he=>h(he.target.checked)})," ",p("remember-device")]}),c.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Wn=c.jsxs(c.Fragment,{children:[qe&&c.jsx(Aj,{token:t,initialTab:Rt,initialLocation:bt,startNewCell:Oe,onClose:()=>{Ae(!1),Pt(!1),dt("")}}),oe&&c.jsx(Tj,{token:t,initialPair:s,...Te,onPairDone:a,onDone:()=>ke(!1)}),c.jsx(zj,{token:t})]});if(!f)return j?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-single-overlay",children:c.jsx($_,{peer:j,token:t,onBack:()=>T(null)})}),Wn]}):b?c.jsxs(c.Fragment,{children:[c.jsx(q_,{session:b.session,node:b.node,ownerId:b.ownerId,cellName:b.cellName,token:t,readonly:re,onBack:()=>w(null),onCellSwitcher:()=>Qe(!0),cellSwitcherOpen:ht}),ht&&c.jsx(Kj,{token:t,current:b,onPick:he=>{k(he),Qe(!1)},onClose:()=>Qe(!1)}),Wn]}):c.jsxs(c.Fragment,{children:[c.jsx(Kx,{onPick:k,token:t,onSettings:ot,onOpenVlSession:T}),Wn]});const ui=y||!me;return c.jsxs("div",{className:"nc-workspace",children:[ui&&c.jsx(QE,{sessions:C,cells:E,activeSessions:U,nodeGroups:L,fleetCapabilities:I,bootSettlement:A,onBootSettlementApplied:Ee,localNodeId:H.localNodeId,onPick:M,onAddTile:ue,onPower:D,onBoot:De,onBootError:he=>H.setError(String((he==null?void 0:he.message)||he)),onNodePower:nt,onNodeRename:at,onKill:de,onVisibility:ge,onNew:()=>ot("fleet",!0),onSettings:ot,onOpenVlSession:T,width:fe,collapsed:$e,onResize:we,onToggleCollapse:()=>ft(he=>!he)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(AN,{decks:x,currentDeck:v,onCreate:ct,onRename:et,onDelete:Zt,onReorder:H.reorder,onOpenWindow:Je,onNavigate:Mt,saveState:H.saveState,error:H.error,sidebarVisible:ui,onToggleSidebar:y?null:()=>xe(he=>!he)}),c.jsx(sN,{layout:Y,onLayoutChange:z,token:t,readonly:re,sessionsAlive:te,focusSession:Z,onFocus:G,onOpenSingle:M,decks:x,currentDeck:v,onSendToDeck:ni,cells:E,nodeGroups:L})]}),j&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx($_,{peer:j,token:t,onBack:()=>T(null)})}),Q&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(q_,{session:Q.session,node:Q.node,ownerId:Q.ownerId,cellName:Cf({session:Q.session,node:Q.node,ownerId:Q.ownerId,cells:E,nodeGroups:L}),token:t,readonly:re,onBack:()=>B(null)})}),O&&c.jsx(Bl,{cell:O,token:t,route:Array.isArray(O.route)?O.route:[],onConfirm:_e,onClose:()=>D(null)}),Wn]})}function dR(){kn();const e=N.useSyncExternalStore(Jj,H_,H_);if(!e.needed)return null;const t=e.kind==="install"?p("install-version-mismatch").replace("{v}",e.version):p("update-available").replace("{v}",e.version).replace(" "," ").trim();return c.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&c.jsx("button",{className:"nc-update-btn",onClick:nR,children:p("reload")})]})}tR();p0.createRoot(document.getElementById("root")).render(c.jsxs(a0.StrictMode,{children:[c.jsx(uR,{}),c.jsx(dR,{})]}));